Newsgroups: comp.os.linux.networking
Subject: Re: How can I catch a IP packet in Linux?
References: 
[email protected] (Carlos) writes:

> Hello,
> I want to program a Firewall in Linux using C/C++ and I have a cople
> of questions:
> 
> - How can I catch a IP packet? and then process it...

There are many tools for this:
- libpacp
- raw IP sockets
- TAP interface
- TUN interface
(there could also be other options)

What you specifically need to do and the enviroment you use
specify what you need to use. 

> - Should I process the ethernet interrupt and then take the packets
> from the input queue? How do you do it
> - I was reading some info and they say you can implement it with
> tcpdump, is it true?

tcpdump can capture packets at IP and at network level (for example
Ethernet). The packet capturing is done using a librafy called
libpcap, which provides cross-platform paccket capturing interface.
It works well in practice. For more information take a look at 
http://www.tcpdump.org/

> - Do you now any link or any kind of documentation for do it?

Check the "Special network packet hacking" section at
http://www.epanorama.net/pc/linux.html#networking

It gives you link to many documents on this.
 
> Any extra info is welcome...
> 
> Thank you for your help.
> Carlos.

-- 
Tomi Engdahl (http://www.iki.fi/then/)
Take a look at my electronics web links and documents at 
http://www.epanorama.net/