cc <c files> -o <executable> -lpnet6 -lpthread
libpnet6 is a programming library designed to simplify and abstract most of the work involved in writing (advanced) network applications. The emphasis of libpnet6 lies on ease-of-use and platform independence, without giving up any of the functionality or features that are part of any serious network program.
The 6 in libpnet6 reflects the fact that the library has full support for IPv6, the internet protocol designed to replace the current IP protocol version 4.
By default, if present and enabled, libpnet6 will automatically use IPv6; if IPv6 is not available, libpnet6 will fall back to IPv4 (assuming that one's enabled too).
The functionality that libpnet6 currently offers is quite extensive. libpnet6's sockets API is fairly complete: among others, it supports non-blocking I/O, multicasting, broadcasting, socket options at the IP, TCP, and UDP level, for both IPv4 and IPv6; ancillary data (or control information), where present, can also be accessed in an intuitive way. In addition, extensive logging is available, which makes it easy to follow and debug the workings of a particular program. Also, where supported, a program can be started as a daemon process.
Below is a more detailed review of libpnet6's functionality. Refer to the specific man pages for more details on a given topic.
IP level protocols
Full IPv4 and IPv6 support, including ICMP and ICMPv6 and miscellaneous IP options. Also, on system's where available the Unix domain protocol is also supported (see pnet6-ip(3)).
User level protocol
Full TCP and UDP support, including their miscellaneous obscure features and options. For more details, see pnet6-tcp(3) and pnet6-udp(3).
Network interface access
In the current version of libpnet6, you can query the interfaces on the system, in order to obtain such information about them as hardware address, IP address, broadcast address, netmask, etc... Setting such parameters is not supported yet, but it's not too much work to implement. We promise nothing however. See pnet6-if(3).
You can read and write IP packets on a raw socket (usually created through the socket( ..., SOCK_RAW, protocol) mechanism). Normally, this can be used to send ICMP messages from a user process (ping-like). Refer to pnet6-raw(3).
You can use libpnet6 for direct access to packets on the network wire, so to speak. With reading, this normally means packets that have not yet been processed by the kernel; with writing, you can bypass the kernel, and write whatever kinds of packets you like directly to the network. In general, only packets destined for the local machine can be accessed in this fashion; however, if a network device supports the so-called promiscuous mode, by enabling it, one can monitor all the packets on the local network. Naturally, this involves moral and ethical issues since you could be sniffing someone's private e-mails, so be aware of this. For all the exciting details, see pnet6-datalink(3).
The functionality available for the writing of server programs is quite extended. Depending on the kind of environment where a server is deployed, different solutions are required to make a server program fast and robust. Possibilities exist to use multi-threaded or forked UDP and TCP servers, with full syslog(3), support.
pnet6(3), pnet6-addr(3), pnet6-api(3), pnet6-aux(3), pnet6-if(3), pnet6-ip(3), pnet6-log(3), pnet6-pkt(3), pnet6-raw(3), pnet6-socket(3), pnet6-tcp(3), pnet6-threads(3), pnet6-udp(3).
The current version of libpnet6 is highly experimental.
You can always get the most recent version from http://pnet6.sourceforge.net.
Peter Bozarov. Send mail to kingofgib (at) users.sourceforge.net