Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Reg - Packet filter: (9 Items)
   
Reg - Packet filter  
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
Re: Reg - Packet filter  
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
Re: Reg - Packet filter  
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
Re: Reg - Packet filter  
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
Re: Reg - Packet filter  
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
Re: Reg - Packet filter  
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
> 
> 
> 
Re: Reg - Packet filter  
Hi,

pfil_add_hook(my_hook_function, handle, PFIL_ALL, ifhead);

what is a handle?

Thanks and Regards
K.Senthil
Re: Reg - Packet filter  
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


Re: Reg - Packet filter  
Hi,

if i m using PFIL_TYPE_IFNET instead of PFIL_TYPE_AF.
i did nt get any packts.

Thanks and Regards
K.Senthil