Strip option 53 out of the options map, as the value is parsed into Type.

This commit is contained in:
David Anderson 2016-02-28 01:08:12 -08:00
parent 621a0c28e5
commit d6ac0332dd
2 changed files with 1 additions and 3 deletions

View File

@ -283,6 +283,7 @@ func Unmarshal(bs []byte) (*Packet, error) {
return nil, errors.New("packet has no DHCP Message Type") return nil, errors.New("packet has no DHCP Message Type")
} }
ret.Type = MessageType(typ) ret.Type = MessageType(typ)
delete(ret.Options, 53)
switch ret.Type { switch ret.Type {
case MsgDiscover, MsgRequest, MsgDecline, MsgRelease, MsgInform: case MsgDiscover, MsgRequest, MsgDecline, MsgRelease, MsgInform:
if bs[0] != 1 { if bs[0] != 1 {

View File

@ -11,7 +11,6 @@ DHCPDISCOVER
BootFilename: BootFilename:
Options: Options:
53: []byte{0x1}
55: []byte{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0xb, 0xc, 0xd, 0xf, 0x10, 0x11, 0x12, 0x16, 0x17, 0x1c, 0x28, 0x29, 0x2a, 0x2b, 0x32, 0x33, 0x36, 0x3a, 0x3b, 0x3c, 0x42, 0x43, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87} 55: []byte{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0xb, 0xc, 0xd, 0xf, 0x10, 0x11, 0x12, 0x16, 0x17, 0x1c, 0x28, 0x29, 0x2a, 0x2b, 0x32, 0x33, 0x36, 0x3a, 0x3b, 0x3c, 0x42, 0x43, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87}
57: []byte{0x4, 0xec} 57: []byte{0x4, 0xec}
60: []byte{0x50, 0x58, 0x45, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3a, 0x41, 0x72, 0x63, 0x68, 0x3a, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3a, 0x55, 0x4e, 0x44, 0x49, 0x3a, 0x30, 0x30, 0x32, 0x30, 0x30, 0x31} 60: []byte{0x50, 0x58, 0x45, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x3a, 0x41, 0x72, 0x63, 0x68, 0x3a, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3a, 0x55, 0x4e, 0x44, 0x49, 0x3a, 0x30, 0x30, 0x32, 0x30, 0x30, 0x31}
@ -33,7 +32,6 @@ DHCPOFFER
Options: Options:
43: []byte{0x6, 0x1, 0x3, 0x8, 0x7, 0x80, 0x0, 0x1, 0xc0, 0xa8, 0x10, 0xa, 0x9, 0xc, 0x80, 0x0, 0x9, 0x50, 0x69, 0x78, 0x69, 0x65, 0x63, 0x6f, 0x72, 0x65, 0xa, 0xa, 0x0, 0x50, 0x69, 0x78, 0x69, 0x65, 0x63, 0x6f, 0x72, 0x65, 0xff} 43: []byte{0x6, 0x1, 0x3, 0x8, 0x7, 0x80, 0x0, 0x1, 0xc0, 0xa8, 0x10, 0xa, 0x9, 0xc, 0x80, 0x0, 0x9, 0x50, 0x69, 0x78, 0x69, 0x65, 0x63, 0x6f, 0x72, 0x65, 0xa, 0xa, 0x0, 0x50, 0x69, 0x78, 0x69, 0x65, 0x63, 0x6f, 0x72, 0x65, 0xff}
53: []byte{0x2}
54: []byte{0xc0, 0xa8, 0x10, 0xa} 54: []byte{0xc0, 0xa8, 0x10, 0xa}
60: []byte{0x50, 0x58, 0x45, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74} 60: []byte{0x50, 0x58, 0x45, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74}
97: []byte{0x0, 0x0, 0x2, 0x0, 0x3, 0x0, 0x4, 0x0, 0x5, 0x0, 0x6, 0x0, 0x7, 0x0, 0x8, 0x0, 0x9} 97: []byte{0x0, 0x0, 0x2, 0x0, 0x3, 0x0, 0x4, 0x0, 0x5, 0x0, 0x6, 0x0, 0x7, 0x0, 0x8, 0x0, 0x9}
@ -58,7 +56,6 @@ DHCPOFFER
15: []byte{0x68, 0x6f, 0x6d, 0x65, 0x2e, 0x75, 0x6e, 0x69, 0x76, 0x65, 0x72, 0x73, 0x65, 0x2e, 0x74, 0x66} 15: []byte{0x68, 0x6f, 0x6d, 0x65, 0x2e, 0x75, 0x6e, 0x69, 0x76, 0x65, 0x72, 0x73, 0x65, 0x2e, 0x74, 0x66}
28: []byte{0xc0, 0xa8, 0x10, 0xff} 28: []byte{0xc0, 0xa8, 0x10, 0xff}
51: []byte{0x0, 0x0, 0xe, 0x10} 51: []byte{0x0, 0x0, 0xe, 0x10}
53: []byte{0x2}
54: []byte{0xc0, 0xa8, 0x10, 0x1} 54: []byte{0xc0, 0xa8, 0x10, 0x1}
58: []byte{0x0, 0x0, 0x7, 0x8} 58: []byte{0x0, 0x0, 0x7, 0x8}
59: []byte{0x0, 0x0, 0xc, 0x4e} 59: []byte{0x0, 0x0, 0xc, 0x4e}