libtins is a high-level, multiplatform C++ network packet sniffing and crafting library.
Its main purpose is to provide the C++ developer an easy, efficient, platform and endianness-independent way to create tools which need to send, receive and manipulate network packets.
It uses a BSD-2 license and it's hosted at github.
The library is very simple to use. As a short example, this is how it could be used to print the source and destination addresses and ports of every TCP packet captured in the eth0 interface:
libtins was designed keeping efficiency in mind at all times. In fact, it is one of the fastest packet sniffing and interpretation libraries available. The benchmark section contains some actual measurements of how fast it works.
Almost as much time was invested testing the library than developing it. At the moment of writing, there are 624 unit tests, which check that everything in libtins does what's expected.
Making your applications portable is very important. That is why a lot of work has been done so that libtins works on Windows, OSX and both little and big endian GNU/Linux and FreeBSD operating systems. This means you can develop some sniffing application, cross-compile it and execute it directly on your ARM or MIPS routers, or any other device that has sniffing capabilities, provided it has enough RAM. (libtins is ~10MB)
libtins supports several protocols and features: