Merge pull request #1158 from guedou/Fix_1147

Fix 1147
This commit is contained in:
Pierre Lalet 2018-02-21 12:18:38 +01:00 committed by GitHub
commit 7a80b2f5bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 26 deletions

View File

@ -41,6 +41,25 @@ from scapy.utils6 import in6_addrtovendor, in6_islladdr
def get_cls(name, fallback_cls):
return globals().get(name, fallback_cls)
dhcp6_cls_by_type = { 1: "DHCP6_Solicit",
2: "DHCP6_Advertise",
3: "DHCP6_Request",
4: "DHCP6_Confirm",
5: "DHCP6_Renew",
6: "DHCP6_Rebind",
7: "DHCP6_Reply",
8: "DHCP6_Release",
9: "DHCP6_Decline",
10: "DHCP6_Reconf",
11: "DHCP6_InfoRequest",
12: "DHCP6_RelayForward",
13: "DHCP6_RelayReply" }
def _dhcp6_dispatcher(x, *args, **kargs):
cls = conf.raw_layer
if len(x) >= 2:
cls = get_cls(dhcp6_cls_by_type.get(orb(x[0]), "Raw"), conf.raw_layer)
return cls(x, *args, **kargs)
#############################################################################
#############################################################################
@ -906,7 +925,7 @@ class DHCP6OptRelayMsg(_DHCP6OptGuessPayload): # RFC sect 22.10
fields_desc = [ ShortEnumField("optcode", 9, dhcp6opts),
FieldLenField("optlen", None, fmt="!H",
length_of="message"),
PacketLenField("message", DHCP6(), DHCP6,
PacketLenField("message", DHCP6(), _dhcp6_dispatcher,
length_from=lambda p: p.optlen) ]
#####################################################################
@ -1170,26 +1189,6 @@ class DHCP6_RelayReply(DHCP6_RelayForward):
self.peeraddr == other.peeraddr )
dhcp6_cls_by_type = { 1: "DHCP6_Solicit",
2: "DHCP6_Advertise",
3: "DHCP6_Request",
4: "DHCP6_Confirm",
5: "DHCP6_Renew",
6: "DHCP6_Rebind",
7: "DHCP6_Reply",
8: "DHCP6_Release",
9: "DHCP6_Decline",
10: "DHCP6_Reconf",
11: "DHCP6_InfoRequest",
12: "DHCP6_RelayForward",
13: "DHCP6_RelayReply" }
def _dhcp6_dispatcher(x, *args, **kargs):
cls = conf.raw_layer
if len(x) >= 2:
cls = get_cls(dhcp6_cls_by_type.get(orb(x[0]), "Raw"), conf.raw_layer)
return cls(x, *args, **kargs)
bind_bottom_up(UDP, _dhcp6_dispatcher, { "dport": 547 } )
bind_bottom_up(UDP, _dhcp6_dispatcher, { "dport": 546 } )

View File

@ -735,7 +735,7 @@ def in6_chksum(nh, u, p):
# Inherited by all extension header classes
class _IPv6ExtHdr(_IPv6GuessPayload, Packet):
name = 'Abstract IPV6 Option Header'
name = 'Abstract IPv6 Option Header'
aliastypes = [IPv6, IPerror6] # TODO ...

View File

@ -4716,8 +4716,13 @@ a=DHCP6_RelayForward(b'\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
a.msgtype == 12 and a.hopcount == 0 and a.linkaddr == "::" and a.peeraddr == "::"
= DHCP6_RelayForward - Dissection with options
a = DHCP6_RelayForward(b'\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x04\x00\x01\x00\x00')
a.msgtype == 12 and DHCP6OptRelayMsg in a and isinstance(a.message, DHCP6)
a = DHCP6_RelayForward(b'\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x04\x03\x01\x00\x00')
a.msgtype == 12 and DHCP6OptRelayMsg in a and isinstance(a.message, DHCP6_Request)
= DHCP6_RelayForward - Advanced dissection
s = b'`\x00\x00\x00\x002\x11@\xfe\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x02\x02#\x02#\x002\xf0\xaf\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x04\x01\x00\x00\x00'
p = IPv6(s)
assert DHCP6OptRelayMsg in p and isinstance(p.message, DHCP6_Solicit)
############
@ -4732,8 +4737,8 @@ a=DHCP6OptRelayMsg(b'\x00\r\x00\x00')
assert a.optcode == 13
= DHCP6OptRelayMsg - Embedded DHCP6 packet
p = DHCP6OptRelayMsg(b'\x00\t\x00\x04\x00\x00\x00\x00')
isinstance(p.message, DHCP6)
p = DHCP6OptRelayMsg(b'\x00\t\x00\x04\x01\x00\x00\x00')
isinstance(p.message, DHCP6_Solicit)
############
############