Skip to content

feat(application): dissect DHCP and BOOTP over UDP ports 67 and 68 (#2959) - #3199

Merged
JarryShaw merged 1 commit into
developfrom
feat/2959-dhcp-bootp
Nov 29, 2026
Merged

JarryShaw merged 1 commit into
developfrom
feat/2959-dhcp-bootp

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Please follow the guide below

  • Put an x into every box [ ] that applies to your pull request (like this: [x])

  • Use the Preview tab to see how your pull request will look

  • Searched for similar pull requests

  • Followed the coding style (make pylint, make mypy, make isort)

  • make test passes, and a test case covers the change

  • Described the user-visible change below and left its changelog entry to the maintainer, keeping docs/source/changelog/ and CHANGELOG.md out of the diff, if the change is user-visible: N/A — centralised

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect

  • feat — adds a feature

  • perf — changes performance, not behaviour

  • refactor — changes neither behaviour nor performance

  • test — tests only

  • docs — documentation only

  • ci — workflows or build tooling

  • release — bumps the version or rolls up a distribution

  • chore — anything else

  • Also tick if it regenerates constant or registry tables, members keeping their numeric values (the const label)


Description of your pull request and other information

Closes #2959.

  • DHCP is a dispatching base over BOOTP (RFC 951, 1542) and DHCPv4 (RFC 2131), which share its schema; UDP 67 and 68 bind it, and it picks DHCPv4 where the options carry the DHCP Message Type option whole before any option runs past its field. A base may join protocols where one is the RFC-defined extension of the other on the same format and port (RFC 2131 §1), recorded on protocol-family-grouping.rst; with no version, fields through the base raise and each member builds itself. An option a capture cut leaves is kept raw as padding and the cut recorded, so the message rebuilds as captured. DHCPv4.id() is ('DHCP',), as ICMPv4's is ('ICMP',).
  • DHCP.__option__ (register_dhcp_option) decodes RFC 2132's options and User Class, Client FQDN, Relay Agent Information, PXE, Domain Search, Classless Static Route and Vendor-Identifying, each as its RFC defines it; BOOTP decodes RFC 2132 §3–8 alone, DHCPv4 also the overloaded sname/file, and a repeated code keeps its octets (RFC 3396 §7; concatenating them is feat(application): concatenate repeated DHCP options per RFC 3396 #3200). Domain names reuse corekit.schema.domain_name.
  • const/vendor dhcp: options, message types and relay agent sub-options crawled from IANA; op codes from a DATA literal (RFC 951).
  • Re-pins the dhcp*.pcapng chains to Ethernet:IPv4:UDP:DHCP and adds UDP 67/68 to the port pin; feat(application): dissect SMTP over TCP ports 25 and 587 (#2960) #3195 (feat(application): dissect SMTP over TCP ports 25 and 587 #2960) adds TCP rows there, so this rebases onto it as release: 1.10.0 scope #2948 rules.

Tests: tests/protocols/application/test_dhcp_unit.py and tests/vendor/test_vendor_dhcp_2959_unit.py fail on an origin/develop export; new modules at 100% statement and branch coverage. tests/protocols/*.py, tests/project, tests/*.py, tests/integration and the touched directories pass.

@JarryShaw JarryShaw linked an issue Nov 28, 2026 that may be closed by this pull request
@JarryShaw JarryShaw added feat Pull requests that add a new capability (feat: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Nov 28, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.10 milestone Nov 28, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 28, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Decision needed: should BOOTP and DHCPv4 share a base? #3199 groups them under an abstract DHCP: ports 67/68 bind the base, the base dispatches on option 53, and there is no version keyword. It also records that rule on protocol-family-grouping.rst. A Sonnet review found the code sound, but the rule is new policy: "Grouping by Name" says members share a base because they share a name, not a wire format, and BOOTP and DHCP share no name.

  • (A) Keep the family, and narrow the rule: a base may join protocols where one is the RFC-defined extension of the other on the same wire format and port (RFC 2131 §1: DHCP "is based on" BOOTP).
  • (B) Use one DHCP class with no family, reading a BOOTP message as one without option 53 (RFC 1534 interoperation).

Recommendation: (A). 'BOOTP' in frame stays able to pick out pure BOOTP traffic, and the narrowed rule can't reach protocols that only share a name or only share bytes. I'm going ahead with (A); say (B) and the worker folds the members into one class.

Separately, needs changes. A DHCP message cut short by snaplen, such as a DISCOVER truncated at 244–260 bytes, classifies as BOOTP even though option 53 is present. The fix is to classify by the first complete option 53 and parse the incomplete tail raw. The page's mermaid chart and table also still show version-less octets as refused. Repeated options concatenated per RFC 3396 are filed as #3200, in 1.10.0's Batch 2.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment needs: decision Waiting on the maintainer to decide — not blocked by other work and removed review: running A cross-review is in flight against the current head - no verdict yet labels Nov 28, 2026
@JarryShaw JarryShaw moved this from In review to Needs decision in PyPCAPKit Nov 28, 2026
@JarryShaw
JarryShaw force-pushed the feat/2959-dhcp-bootp branch from f491e31 to 91e21fe Compare November 28, 2026 16:30
@JarryShaw

Copy link
Copy Markdown
Owner Author

Good to go at 91e21fef05, under (A), the recommendation. I checked the fold-in on the head:

needs: decision stays open. If you choose (B), the worker folds BOOTP and DHCPv4 into one class. #3195 merges first, then this rebases.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Nov 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 94.88% (unit tier, Python 3.15, 91e21fef0, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 110 4 20 2 95.38%
pcapkit/const 22229 224 3156 191 98.26%
pcapkit/corekit 3160 83 1058 40 96.85%
pcapkit/dumpkit 423 3 148 5 98.60%
pcapkit/foundation 4138 24 1332 26 99.09%
pcapkit/interface 103 4 34 3 94.89%
pcapkit/protocols 28351 158 7466 129 99.19%
pcapkit/toolkit 1016 26 360 8 96.80%
pcapkit/utilities 596 7 162 5 98.42%
pcapkit/vendor 6468 2392 1456 254 59.69%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw

Copy link
Copy Markdown
Owner Author

take recommendations

@JarryShaw

Copy link
Copy Markdown
Owner Author

Reconciled: you've taken the recommendation, (A). BOOTP and DHCPv4 keep their shared DHCP base, under the narrowed rule now on protocol-family-grouping.rst: one protocol is the RFC-defined extension of the other on the same format and port (RFC 2131 §1). (B), one class, is dropped. The PR stands as it is at 91e21fef05. I've removed needs: decision, and review: good-to-go stays. The one step left is the rebase once #3195 (SMTP) merges, which keeps both ports' rows in the dispatch pins.

@JarryShaw JarryShaw removed the needs: decision Waiting on the maintainer to decide — not blocked by other work label Nov 28, 2026
@JarryShaw JarryShaw moved this from Needs decision to In review in PyPCAPKit Nov 28, 2026
…2959)

- pcapkit.protocols.application.dhcp: DHCP, the dispatching base of BOOTP
  (RFC 951, 1542) and DHCPv4 (RFC 2131), which share its header schema and
  option data models; UDP ports 67 and 68 bind it, and it picks DHCPv4 where
  the options carry the DHCP Message Type option whole before any option runs
  past its field. Fields through the base are refused; each member builds
  itself. An option a capture cut leaves is kept raw and the cut recorded.
- Options decode through DHCP.__option__ (register_dhcp_option): RFC 2132's,
  User Class, Client FQDN, Relay Agent Information, the PXE options, Domain
  Search, Classless Static Route, Vendor-Identifying and others, each as its
  RFC defines it; BOOTP decodes the vendor extensions alone, DHCPv4 the
  overloaded sname and file fields, and a repeated code keeps its octets.
- pcapkit.const.dhcp and pcapkit.vendor.dhcp: op codes, options, message
  types and relay agent sub-options, crawled from IANA's BOOTP/DHCP tables.
- Export the classes, remove NotImplemented/dhcp.py, document the family, and
  record the rule it dispatches by on protocol-family-grouping.rst.

New modules at 100% statement and branch coverage; tests pass.
@JarryShaw
JarryShaw force-pushed the feat/2959-dhcp-bootp branch from 91e21fe to 699b85a Compare November 29, 2026 03:04
@JarryShaw

Copy link
Copy Markdown
Owner Author

Rebased onto develop after #3195 (SMTP) merged: 91e21fef0 → 699b85afe, still one commit.

  • Three conflicts were resolved by keeping both sides: the Application line in protocols/index.rst, the TODO list in application/__init__.py, and the TCP/UDP port pin in test_dispatch_bindings_unit.py (TCP now has 25 and 587, UDP has 67 and 68).
  • git range-diff shows the DHCP change itself is unchanged; only SMTP context moved. It also merges cleanly over today's a9c176bc1 and alongside feat(foundation)!: trace UDP and IP conversations as flows (#2956) #3197.
  • The verdict stands at good-to-go, and CI is re-running on the new head.

@JarryShaw
JarryShaw merged commit d2e7bd9 into develop Nov 29, 2026
68 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 29, 2026
@JarryShaw
JarryShaw deleted the feat/2959-dhcp-bootp branch November 29, 2026 03:14
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Pull requests that add a new capability (feat: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat(application): dissect DHCP and BOOTP over UDP ports 67 and 68

1 participant