Skip to content

Commit

Permalink
Add a documentation section to the README
Browse files Browse the repository at this point in the history
  • Loading branch information
montag451 committed Jan 19, 2014
1 parent 22388f8 commit fda1df6
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ 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.

Examples
--------
Documentation
-------------

NOTE: On most distributions you will need to be root to run these examples.
NOTE: On most distributions you will need to be root to create TUN/TAP devices.

To create a TUN device::

Expand Down Expand Up @@ -51,9 +51,26 @@ To read/write to the device, use the methods ``read(size)`` and
buf = tun.read(tun.mtu)
tun.write(buf)

When when you are done with a device, close it::
If the device is a TAP you can also get/set its MAC address::

tun.close()
tap.hwaddr = '\x00\x11\x22\x33\x44\x55'
print tap.hwaddr

To make the device persistent::

tun.persist(True)

To bring up the device::

tun.up()

To bring down the device::

tun.down()

To close the device::

tun.close()

You can also use ``TunTapDevice`` objects with all functions that expect a
``fileno()`` method (e.g ``select()``)
Expand Down

0 comments on commit fda1df6

Please sign in to comment.