2012-01-12 00:34:12 +01:00
|
|
|
Ether2Any and PyTap
|
|
|
|
===================
|
2012-01-15 01:48:36 +01:00
|
|
|
Ether2Any is a Python base class for writing arbitrary Ethernet/IP tunnels
|
|
|
|
using a TUN/TAP device.
|
|
|
|
|
|
|
|
PyTap is a Python class for handling a TUN/TAP device. It exposes
|
|
|
|
reading/writing to the device and abstracts a bit of the network configuration.
|
2012-01-12 00:34:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
Installation and requirements
|
|
|
|
=============================
|
|
|
|
Just put it somewhere and import it. For PyTaps network configuration
|
|
|
|
functions you need /sbin/ifconfig.
|
|
|
|
|
|
|
|
|
|
|
|
How to write an Ethernet/IP tunnel
|
|
|
|
==================================
|
2012-01-15 01:48:36 +01:00
|
|
|
Writing a tunnel with this is rather easy. All you have to do is to create a
|
|
|
|
class inheriting from Ether2Any and implement the method sendToNet().
|
|
|
|
sendToNet() will be called for each incoming network packet. If you add extra
|
|
|
|
sockets to the select loop via addSocket, sendToDev() needs to be implemented,
|
|
|
|
which gets the socket with the new data. If you don't want to rely on select you
|
|
|
|
are free to pass self.dev (which is a PyTap() instance) and call dev.write()
|
|
|
|
whenever you like. Note that if you write invalid network packets on it, you may
|
|
|
|
get an exception.
|
|
|
|
|
|
|
|
Afterwards you can instantiate your class and call the run() method to start
|
2012-01-12 00:34:12 +01:00
|
|
|
your tunnel.
|
|
|
|
|
|
|
|
|
|
|
|
What could be done
|
|
|
|
==================
|
|
|
|
* Builtin packet aggregation would be nice
|
|
|
|
* Various FIXMEs/TODOs
|
|
|
|
* Replace ifconfig with the ip utility
|
2012-01-15 01:48:36 +01:00
|
|
|
* Add plugin architecture to PyTap for traffic mangling
|
2012-01-12 00:34:12 +01:00
|
|
|
* setuptools/pypi dance
|
2012-01-15 01:48:36 +01:00
|
|
|
|