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

Source Code for Module dpkt.icmp6

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