TAPPER - sample code for work with tap devices on linux and os x
Copyright (c) 2009-2013, Ivan Vucica, http://ivan.vucica.net/
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
Providing simple code for creating a tap device, outputting onto stdout the
network traffic generated by kernel for the tap device, and writing into
tap device the traffic from stdin for processing by the kernel.
That is: a two way tunnel between stdio and tap network device.
Not sure. You obviously need tun driver for networking (to be able to
create tap device) -- if you don't have /dev/net/tun something's wrong.
Under OS X, you need the tun/tap kernel extension:
Otherwise, this was made in the era of 2.6.30 kernels on a 2.6.26 kernel,
and with eglibc 2.9 installed (debian release of eglibc 2.9-12).
It was also tested as of 2013 on Debian and OS X Mountain Lion.
* tapper.c - provides the tap device
* README - this file
* Makefile - builds tapper
* testrun.sh - shows how to use twinpipe and netcat to tunnel traffic
in a simple way
* pack.sh - packs for use in a certain embedded system
* TINYFREELICENSE - does not apply to tapper. license of twinpipe.sh
* twinpipe.sh - runs two processes and interconnects them via pipes.
twinpipe was obtained from this URL:
Alternative tutorial with extra info
This is neat and simple code, but perhaps not best and definitely with
much room for improvement and cleanup. So here's another nice article:
and another one: