Package dpkt :: Module pppoe
[hide private]
[frames] | no frames]

Source Code for Module dpkt.pppoe

 1  # $Id: pppoe.py 23 2006-11-08 15:45:33Z dugsong $ 
 2   
 3  """PPP-over-Ethernet.""" 
 4   
 5  import dpkt, ppp 
 6   
 7  # RFC 2516 codes 
 8  PPPoE_PADI      = 0x09 
 9  PPPoE_PADO      = 0x07 
10  PPPoE_PADR      = 0x19 
11  PPPoE_PADS      = 0x65 
12  PPPoE_PADT      = 0xA7 
13  PPPoE_SESSION   = 0x00 
14   
15 -class PPPoE(dpkt.Packet):
16 __hdr__ = ( 17 ('v_type', 'B', 0x11), 18 ('code', 'B', 0), 19 ('session', 'H', 0), 20 ('len', 'H', 0) # payload length 21 )
22 - def _get_v(self): return self.v_type >> 4
23 - def _set_v(self, v): self.v_type = (v << 4) | (self.v_type & 0xf)
24 v = property(_get_v, _set_v) 25
26 - def _get_type(self): return self.v_type & 0xf
27 - def _set_type(self, t): self.v_type = (self.v_type & 0xf0) | t
28 type = property(_get_type, _set_type) 29
30 - def unpack(self, buf):
31 dpkt.Packet.unpack(self, buf) 32 try: 33 if self.code == 0: 34 self.data = self.ppp = ppp.PPP(self.data) 35 except dpkt.UnpackError: 36 pass
37 38 # XXX - TODO TLVs, etc. 39