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

Source Code for Module dpkt.sll

 1  # $Id: loopback.py 64 2005-01-26 19:13:17Z dugsong $ 
 2   
 3  """Linux libpcap "cooked" capture encapsulation.""" 
 4   
 5  import arp, dpkt, ethernet 
 6   
7 -class SLL(dpkt.Packet):
8 __hdr__ = ( 9 ('type', 'H', 0), # 0: to us, 1: bcast, 2: mcast, 3: other, 4: from us 10 ('hrd', 'H', arp.ARP_HRD_ETH), 11 ('hlen', 'H', 6), # hardware address length 12 ('hdr', '8s', ''), # first 8 bytes of link-layer header 13 ('ethtype', 'H', ethernet.ETH_TYPE_IP), 14 ) 15 _typesw = ethernet.Ethernet._typesw 16
17 - def unpack(self, buf):
18 dpkt.Packet.unpack(self, buf) 19 try: 20 self.data = self._typesw[self.ethtype](self.data) 21 setattr(self, self.data.__class__.__name__.lower(), self.data) 22 except (KeyError, dpkt.UnpackError): 23 pass
24