Skip to content
Snippets Groups Projects
Commit 1d8aac62 authored by Nik | Klampfradler's avatar Nik | Klampfradler Committed by Dominik George
Browse files

Updated version.

Added first TapHandler draft.
parent f0c89051
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ PYTHON=`which python`
DESTDIR=/
BUILDIR=$(CURDIR)/debian/myprojectname
PROJECT=pytap
VERSION=0.1.1
VERSION=0.2
all:
@echo "make source - Create source package"
......
......@@ -3,7 +3,7 @@
from distutils.core import setup
setup(name = "PyTap",
version = "0.1.1",
version = "0.2",
description = "Object-oriented wrapper around Linux TUN/TAP device",
long_description = """PyTap provides an object-oriented interface to Linux' TUN/TAP device.
......
......@@ -8,6 +8,7 @@ from fcntl import ioctl
import os
import struct
import atexit
from threading import Thread
TUNSETIFF = 0x400454ca
IFF_TUN = 0x0001
......@@ -179,3 +180,21 @@ class IfconfigError(Exception):
pass
class TapHandler(Thread):
def __init__(self, tapdev, callback):
'''
Initialize a thread that handles packets coming out of the device.
tapdev - Reference to the TapDevice instance to handle
callback - Reference to the method to call upon new packets
'''
Thread.__init__(self)
self.tapdev = tapdev
self.callback = callback
def run(self):
while 1:
packet = self.tapdev.read()
self.callback(packet)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment