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

Source Code for Module dpkt.icmp6

 1  # $Id: icmp6.py 290 2006-01-22 02:43:28Z dugsong $ 
 2   
 3  """Internet Control Message Protocol for IPv6.""" 
 4   
 5  import dpkt, ip6 
 6   
 7  ICMP6_DST_UNREACH            = 1       # dest unreachable, codes: 
 8  ICMP6_PACKET_TOO_BIG         = 2       # packet too big 
 9  ICMP6_TIME_EXCEEDED          = 3       # time exceeded, code: 
10  ICMP6_PARAM_PROB             = 4       # ip6 header bad 
11   
12  ICMP6_ECHO_REQUEST           = 128     # echo service 
13  ICMP6_ECHO_REPLY             = 129     # echo reply 
14  MLD_LISTENER_QUERY           = 130     # multicast listener query 
15  MLD_LISTENER_REPORT          = 131     # multicast listener report 
16  MLD_LISTENER_DONE            = 132     # multicast listener done 
17   
18  # RFC2292 decls 
19  ICMP6_MEMBERSHIP_QUERY       = 130     # group membership query 
20  ICMP6_MEMBERSHIP_REPORT      = 131     # group membership report 
21  ICMP6_MEMBERSHIP_REDUCTION   = 132     # group membership termination 
22   
23  ND_ROUTER_SOLICIT            = 133     # router solicitation 
24  ND_ROUTER_ADVERT             = 134     # router advertisment 
25  ND_NEIGHBOR_SOLICIT          = 135     # neighbor solicitation 
26  ND_NEIGHBOR_ADVERT           = 136     # neighbor advertisment 
27  ND_REDIRECT                  = 137     # redirect 
28   
29  ICMP6_ROUTER_RENUMBERING     = 138     # router renumbering 
30   
31  ICMP6_WRUREQUEST             = 139     # who are you request 
32  ICMP6_WRUREPLY               = 140     # who are you reply 
33  ICMP6_FQDN_QUERY             = 139     # FQDN query 
34  ICMP6_FQDN_REPLY             = 140     # FQDN reply 
35  ICMP6_NI_QUERY               = 139     # node information request 
36  ICMP6_NI_REPLY               = 140     # node information reply 
37   
38  ICMP6_MAXTYPE                = 201 
39   
40 -class ICMP6(dpkt.Packet):
41 __hdr__ = ( 42 ('type', 'B', 0), 43 ('code', 'B', 0), 44 ('sum', 'H', 0) 45 )
46 - class Error(dpkt.Packet):
47 __hdr__ = (('pad', 'I', 0), )
48 - def unpack(self, buf):
49 dpkt.Packet.unpack(self, buf) 50 self.data = self.ip6 = ip6.IP6(self.data)
51 - class Unreach(Error):
52 pass
53 - class TooBig(Error):
54 __hdr__ = (('mtu', 'I', 1232), )
55 - class TimeExceed(Error):
56 pass
57 - class ParamProb(Error):
58 __hdr__ = (('ptr', 'I', 0), )
59
60 - class Echo(dpkt.Packet):
61 __hdr__ = (('id', 'H', 0), ('seq', 'H', 0))
62 63 _typesw = { 1:Unreach, 2:TooBig, 3:TimeExceed, 4:ParamProb, 64 128:Echo, 129:Echo } 65
66 - def unpack(self, buf):
67 dpkt.Packet.unpack(self, buf) 68 try: 69 self.data = self._typesw[self.type](self.data) 70 setattr(self, self.data.__class__.__name__.lower(), self.data) 71 except (KeyError, dpkt.UnpackError): 72 self.data = buf
73