scapy icon indicating copy to clipboard operation
scapy copied to clipboard

RFE: long DHCPv4 options (RFC 3396)

Open evverx opened this issue 1 year ago • 0 comments

Brief description

Long DHCPv4 options longer than 255 bytes aren't supported out of the box. For example

raw(DHCP(options=[('captive-portal', 'a'*256)]))

fails with

error: While dissecting field 'options': ubyte format requires 0 <= number <= 255

but according to https://www.rfc-editor.org/rfc/rfc3396#section-1 it can be split and then it should be joined on the receiving side

when more than one option with a given type code appears in the DHCP packet, all such options should be concatenated together.

Wireshark started concatenating options according to that RFC a couple months ago: https://gitlab.com/wireshark/wireshark/-/merge_requests/18079

https://www.ietf.org/archive/id/draft-tojens-dhcp-option-concat-considerations-00.html was also mentioned there.

(It's possible to do all that manually. It's just something I noticed in the context of suboptions in https://github.com/NetworkConfiguration/dhcpcd/pull/404. It came up again when I took a look at https://github.com/secdev/scapy/pull/4638 and tried to stuff quite a few IP addresses into a reply :-))

Scapy version

7106b015379b621966f00667cf0bf3d4daec0262

Python version

Python 3.13.1

Operating system

Fedora 41

Additional environment information

No response

How to reproduce

raw(DHCP(options=[('captive-portal', 'a'*256)]))

and

DHCP(b'\x06\x02\x01\x02\x06\x02\x03\x04')

should be the same as

DHCP(b'\x06\x04\x01\x02\x03\x04')

Actual result

No response

Expected result

No response

Related resources

No response

evverx avatar Jan 16 '25 16:01 evverx