mirror of https://github.com/secdev/scapy.git
Merge pull request #700 from guedou/Issue_#699
Fix DHCPv6 Relay message behavior
This commit is contained in:
commit
2f6b9fee76
|
@ -24,7 +24,8 @@ from scapy.error import warning
|
|||
from scapy.fields import BitField, ByteEnumField, ByteField, FieldLenField, \
|
||||
FlagsField, IntEnumField, IntField, MACField, PacketField, \
|
||||
PacketListField, ShortEnumField, ShortField, StrField, StrFixedLenField, \
|
||||
StrLenField, UTCTimeField, X3BytesField, XIntField, XShortEnumField
|
||||
StrLenField, UTCTimeField, X3BytesField, XIntField, XShortEnumField, \
|
||||
PacketLenField
|
||||
from scapy.layers.inet import UDP
|
||||
from scapy.layers.inet6 import DomainNameListField, IP6Field, IP6ListField, IPv6
|
||||
from scapy.packet import Packet, bind_bottom_up
|
||||
|
@ -444,20 +445,6 @@ class DHCP6OptElapsedTime(_DHCP6OptGuessPayload):# RFC sect 22.9
|
|||
_ElapsedTimeField("elapsedtime", 0) ]
|
||||
|
||||
|
||||
#### DHCPv6 Relay Message Option ####################################
|
||||
|
||||
# Relayed message is seen as a payload.
|
||||
class DHCP6OptRelayMsg(_DHCP6OptGuessPayload):# RFC sect 22.10
|
||||
name = "DHCP6 Relay Message Option"
|
||||
fields_desc = [ ShortEnumField("optcode", 9, dhcp6opts),
|
||||
ShortField("optlen", None ) ]
|
||||
def post_build(self, p, pay):
|
||||
if self.optlen is None:
|
||||
l = len(pay)
|
||||
p = p[:2]+struct.pack("!H", l)
|
||||
return p + pay
|
||||
|
||||
|
||||
#### DHCPv6 Authentication Option ###################################
|
||||
|
||||
# The following fields are set in an Authentication option for the
|
||||
|
@ -912,6 +899,17 @@ class DHCP6(_DHCP6OptGuessPayload):
|
|||
def hashret(self):
|
||||
return struct.pack("!I", self.trid)[1:4]
|
||||
|
||||
#### DHCPv6 Relay Message Option ####################################
|
||||
|
||||
# Relayed message is seen as a payload.
|
||||
class DHCP6OptRelayMsg(_DHCP6OptGuessPayload): # RFC sect 22.10
|
||||
name = "DHCP6 Relay Message Option"
|
||||
fields_desc = [ ShortEnumField("optcode", 9, dhcp6opts),
|
||||
FieldLenField("optlen", None, fmt="!H",
|
||||
length_of="message"),
|
||||
PacketLenField("message", DHCP6(), DHCP6,
|
||||
length_from=lambda p: p.optlen) ]
|
||||
|
||||
#####################################################################
|
||||
# Solicit Message : sect 17.1.1 RFC3315
|
||||
# - sent by client
|
||||
|
|
|
@ -4377,7 +4377,7 @@ 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 DHCP6OptClientId in a
|
||||
a.msgtype == 12 and DHCP6OptRelayMsg in a and isinstance(a.message, DHCP6)
|
||||
|
||||
|
||||
############
|
||||
|
@ -4385,12 +4385,16 @@ a.msgtype == 12 and DHCP6OptRelayMsg in a and DHCP6OptClientId in a
|
|||
+ Test DHCP6 Messages - DHCP6OptRelayMsg
|
||||
|
||||
= DHCP6OptRelayMsg - Basic Instantiation
|
||||
str(DHCP6OptRelayMsg(optcode=37)) == b'\x00%\x00\x00'
|
||||
str(DHCP6OptRelayMsg(optcode=37)) == b'\x00%\x00\x04\x00\x00\x00\x00'
|
||||
|
||||
= DHCP6OptRelayMsg - Basic Dissection
|
||||
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)
|
||||
|
||||
############
|
||||
############
|
||||
+ Test DHCP6 Messages - DHCP6_RelayReply
|
||||
|
|
Loading…
Reference in New Issue