Subject: Re: filtering packtes before OS takes care about them

From: Pedro Fortuna <[email-masked]>
Date: Tue, 1 Mar 2005 16:33:49 +0000

This subject is rather new to me. Is there some literature about linux
kernel networking API  that you would recommend?
thanks,
-Pedro Fortuna

On Mon, 28 Feb 2005 21:35:09 -0600, Asim Shankar <[email-masked]> wrote:
> > In my case, I'll need to intercept all outgoing IP packets and change
> > them (including L2 frame) before they are passed to the network
> > interface driver.
> > The reverse operation is applied to incoming IP Packets in the destination host.
> > I didnt investigate the packet_type example you provided but I hope I
> > will be able to used for the purposes I explained.
> 
> If the type field of the struct packet_type you register ==
> htons(ETH_P_ALL), then your packet handling function will be added to
> the head of the ptype_all list.
> 
> As a result, it will see all incoming and outgoing packets - incoming
> will be delivered to your function from netif_receive_skb() before the
> IP/other packet handlers get to see it and outgoing packets will be
> delivered from dev_queue_xmit() (which calls dev_queue_xmit_nit())
> just before the packet is queued for sending by the NIC. This may work
> for you.
> 
> I'm assuming all outgoing packets go through dev_queue_xmit(), though
> that may not always be the case (someone more knowledgeable would have
> to explain this).
> 
> Regards,
> 
> -- Asim
>