1 # Copyright (c) Twisted Matrix Laboratories.
2 # See LICENSE for details.
4 from twisted.internet import reactor, protocol
5 from twisted.pair import ethernet, rawudp, ip
6 from twisted.pair import tuntap
8 class MyProto(protocol.DatagramProtocol):
9 def datagramReceived(self, *a, **kw):
12 p_udp = rawudp.RawUDPProtocol()
13 p_udp.addProto(42, MyProto())
14 p_ip = ip.IPProtocol()
15 p_ip.addProto(17, p_udp)
16 p_eth = ethernet.EthernetProtocol()
17 p_eth.addProto(0x800, p_ip)
19 reactor.listenWith(tuntap.TuntapPort,
20 interface='tap0', proto=p_eth, reactor=reactor)