From f8cdb38f287b7f5102eb223dd4b73e6232b6f33d Mon Sep 17 00:00:00 2001 From: montag451 Date: Tue, 6 Mar 2012 15:10:29 +0100 Subject: [PATCH] Add LICENSE file. --- LICENSE | 19 +++++++++++++++++ README | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0552d33 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2011, montag451. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README b/README index e4d5fe3..78899af 100644 --- a/README +++ b/README @@ -1 +1,62 @@ -Linux TUN/TAP wrapper for Python. +Linux TUN/TAP wrapper for Python +================================ + +``pytun`` is a Python module which let you create TUN/TAP device very easily. + +License: MIT (see LICENSE) + +Installation and Dependencies +----------------------------- + +To install ``pytun``, `download the zip archive `, decompress it and execute ``python setup.py install``. As ``pytun`` is a C module you will need a compiler (e.g GCC) and the Python developpement headers installed on your system (e.g on Debian-like distribution check that ``build-essential`` and ``python-dev`` are present). There are no dependencies other than the Python Standard Library. + +Example +------- + +To create a TUN device + +:: + + from pytun import TunTapDevice + + tun = TunTapDevice() + +To create a TAP device + +:: + + from pytun import TunTapDevice, IFF_TAP + + tap = TunTapDevice(flags=IFF_TAP) + +To create a TUN/TAP device with a custom name use the ``name`` keyword + +:: + + tun = TunTapDevice(name='mytun') + +You can get/set some parameters of the device directly + +:: + + print tun.name + tun.addr = '10.8.0.1 + tun.dstaddr = '10.8.0.2 + tun.netmask = '255.255.255.0' + tun.mtu = 1500 + +To read/write to the device, use the methods ``read(size)`` and ``write(buf)`` + +:: + + buf = tun.read(tun.mtu) + tun.send(buf) + +When when you are done with a device, close it + +:: + + tun.close() + +You can also use ``TunTapDevice`` objects with all functions that expect a ``fileno()`` method (e.g ``select()``) +