Senthil K
06/30/2009 9:41 AM
post32826
|
Hi,
i have downloaded the lsm-packfil code and compiled,load using mount command.
if any arp packets comes then the packet filter invokes the input_hook function and prints the number bytes received
and arp packet.
But if i send any other packets using packEth,its not received in the packet filter.
please find the below function
static int input_hook( void *arg, struct mbuf **m, struct ifnet *ifp, int dir ) {
in_bytes += ( *m )->m_len;
for(i=0;i<=(*m)->m_len;i++)
{
SLOG("[%x]\t",(*m)->m_data[i]);
}
return 0;
}
Thanks and Regards
K.Senthil
|
|
|
Patrik Lahti
06/30/2009 10:48 AM
post32838
|
Senthil K wrote:
> Hi,
> i have downloaded the lsm-packfil code and compiled,load using mount command.
>
> if any arp packets comes then the packet filter invokes the input_hook function and prints the number bytes received
and arp packet.
>
> But if i send any other packets using packEth,its not received in the packet filter.
>
> please find the below function
>
> static int input_hook( void *arg, struct mbuf **m, struct ifnet *ifp, int dir ) {
>
> in_bytes += ( *m )->m_len;
>
> for(i=0;i<=(*m)->m_len;i++)
> {
> SLOG("[%x]\t",(*m)->m_data[i]);
> }
>
> return 0;
> }
>
>
> Thanks and Regards
> K.Senthil
>
> _______________________________________________
> Networking Drivers
> http://community.qnx.com/sf/go/post32826
>
>
Hi Senthil,
How did you register your hook?
Did you read this documentation and examples?
http://www.qnx.com/developers/docs/6.4.1/io-pkt_en/user_guide/filtering.html
Hope this helps!
/P
|
|
|
Senthil K
06/30/2009 12:15 PM
post32855
|
Hi,
In packet filter entry function,i added
pfil_add_hook( input_hook, NULL, PFIL_IN | PFIL_WAITOK, pfh_inet );
Do you know how ethernet driver invokes the packet filter interface function.
Thanks and Regards
K.Senthil
|
|
|
Patrik Lahti
06/30/2009 2:02 PM
post32867
|
Senthil K wrote:
> Hi,
>
> In packet filter entry function,i added
> pfil_add_hook( input_hook, NULL, PFIL_IN | PFIL_WAITOK, pfh_inet );
>
> Do you know how ethernet driver invokes the packet filter interface function.
>
> Thanks and Regards
> K.Senthil
>
> _______________________________________________
> Networking Drivers
> http://community.qnx.com/sf/go/post32855
>
Not sure, but you probably need to use PFIL_ALL or add another hook for
PFIL_OUT to see packets you send.
I don't know how the packet filter hook is invoked, but you can always
check the source code. I'm just basing this on the example at:
http://www.qnx.com/developers/docs/6.4.1/io-pkt_en/user_guide/filtering.html
Previously you mention ARP packets, but you may have to use BPF to see
those. The documentation indicates that only AF_INET[6] (i.e. IPv4|6
layer traffic) is supported by pfil.
Hope this may be of help! I'm kind of new to this...
/P
|
|
|
Senthil K
06/30/2009 2:10 PM
post32868
|
Hi,
Thanks,
But i m interesting receiving packets from ethernet interface.
is there any possibility to receive all the packets(IP,ARP,ICMP) through packet filter interface.
Thanks and Regards
K.Senthil
|
|
|
Xiaodan Tang(deleted)
06/30/2009 2:50 PM
post32878
|
You need to hook up per interface. something like this.
IFNET_FOREACH(ifp) {
// only looking for DLT_IEEE802 interface
if (ifp->if_dlt != DLT_EN10MB) {
continue;
}
if (strncmp(ifp->if_xname, "en0", 3) {
ifhead = pfil_head_get(PFIL_TYPE_IFNET, (unsigned long)ifp);
pfil_add_hook(my_hook_function, handle, PFIL_ALL, ifhead);
break;
}
}
-xtang
On Tue, 2009-06-30 at 14:10 -0400, Senthil K wrote:
> Hi,
>
> Thanks,
>
> But i m interesting receiving packets from ethernet interface.
> is there any possibility to receive all the packets(IP,ARP,ICMP)
> through packet filter interface.
>
> Thanks and Regards
> K.Senthil
>
> _______________________________________________
> Networking Drivers
> http://community.qnx.com/sf/go/post32868
>
>
>
|
|
|
Senthil K
07/01/2009 1:18 AM
post32903
|
Hi,
pfil_add_hook(my_hook_function, handle, PFIL_ALL, ifhead);
what is a handle?
Thanks and Regards
K.Senthil
|
|
|
Patrik Lahti
06/30/2009 2:50 PM
post32879
|
Senthil K wrote:
> Hi,
>
> Thanks,
>
> But i m interesting receiving packets from ethernet interface.
> is there any possibility to receive all the packets(IP,ARP,ICMP) through packet filter interface.
>
> Thanks and Regards
> K.Senthil
>
> _______________________________________________
> Networking Drivers
> http://community.qnx.com/sf/go/post32868
>
>
Hi again,
ARP rides directly on Ethernet, not on the IP layer. So you may need to
use pfil with PFIL_TYPE_IFNET (I believe you use PFIL_TYPE_AF) or use
BPF instead of pfil.
The User Guide says:
"The current implementation has filtering points for only AF_INET (IPv4)
or AF_INET6 (IPv6)." about PFIL_TYPE_AF.
And about PFIL_TYPE_IFNET "When you use the interface hook
(PFIL_TYPE_IFNET), dlt is a pointer to a network interface structure."
And it says "The Berkeley Packet Filter (BPF) (in sys/net/bpf.c in the
downloaded source) provides link-layer access to data available on the
network through interfaces attached to the system.".
http://www.qnx.com/developers/docs/6.4.1/io-pkt_en/user_guide/filtering.html
Again, I'm new to this, but that's how I understood the guide. Hope that
helps!
/P
|
|
|
Senthil K
07/01/2009 1:51 AM
post32905
|
Hi,
if i m using PFIL_TYPE_IFNET instead of PFIL_TYPE_AF.
i did nt get any packts.
Thanks and Regards
K.Senthil
|
|
|
|