Repository navigation
fix(protocol): harden UDP parsing, matching, and Block1 transfers - #32
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Blockwise response handling can prematurely report success for incomplete uploads or leave competing same-token requests outstanding.
4 open issues
What changed in this PR
This PR hardens CoAP.NET’s UDP parsing, response matching, and Block1 uploads while preserving the Resource/MVC hosting API. It also records the standards audit and separates completed validation from pending interoperability and deployment checks.
Changes:
- Reject malformed datagrams, lock failed decoders, and strengthen endpoint, message-ID, and token matching.
- Validate Block1 continuation state, report async cancellation, and correct critical-option classification.
- Add protocol regressions, small logging/test-isolation fixes, and standards audit documentation.
| File | Description |
|---|---|
| ROADMAP.md | Links protocol priorities and clarifies validation boundaries. |
| README.md | Links the standards and interoperability roadmap. |
| HANDOFF.md | Records integration results and remaining work. |
| docs/coap-standards-roadmap.md | Defines standards gaps, audit scope, and implementation priorities. |
| docs/audits/coap-20261113/validation-first-wave.json | Records initial validation and baseline failures. |
| docs/audits/coap-20261113/validation-final.json | Records final validation results and source hashes. |
| docs/audits/coap-20261113/upstream-prs.json | Catalogs upstream pull requests. |
| docs/audits/coap-20261113/issue-decisions.json | Records upstream issue triage. |
| docs/audits/coap-20261113/fork-review.json | Documents fork comparisons and adoption decisions. |
| CoAP.Test/MatcherProtocolTest.cs | Tests endpoint, message-ID, and full-token matching. |
| CoAP.Test/MalformedDatagramTest.cs | Tests malformed packet rejection and reset behavior. |
| CoAP.Test/DecoderFailureStateTest.cs | Tests decoder lockout after parsing failures. |
| CoAP.Test/CriticalOptionClassificationTest.cs | Tests critical and elective option classification. |
| CoAP.Test/CoapClientTest.cs | Resets notification counts before each test. |
| CoAP.Test/CoapClientProtocolFailureTest.cs | Tests cancellation reporting and upload response matching. |
| CoAP.Test/BlockwiseProtocolRegressionTest.cs | Tests Block1 errors, sequencing, and size changes. |
| CoAP.NET/Stack/BlockwiseLayer.cs | Validates upload acknowledgements and continuation offsets. |
| CoAP.NET/Spec.cs | Validates UDP headers and message-type/code combinations. |
| CoAP.NET/Server/CoapServer.cs | Corrects the shutdown log message. |
| CoAP.NET/Option.cs | Fixes critical-option bit classification. |
| CoAP.NET/Net/Matcher.cs | Binds matching to endpoints and complete tokens. |
| CoAP.NET/Net/CoAPEndPoint.cs | Contains decoding failures and controls malformed-packet resets. |
| CoAP.NET/Codec/MessageDecoder.cs | Prevents reuse after parsing errors. |
| CoAP.NET/Codec/DatagramReader.cs | Rejects reads beyond available input. |
| CoAP.NET/CoapClient.cs | Adds cancellation failure notifications. |
| CHANGELOG.md | Summarizes protocol fixes and audit documentation. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Malformed UDP datagrams could be dispatched, a response could match the wrong peer, and invalid or interleaved Block1/Block2 responses could advance a partial upload or strand its caller. The final change rejects malformed packets, locks failed decoders, binds matching to endpoint/MID/full token with mapped-address normalization, and serializes Block1 continuation with final Block2 response retrieval.
Blockwise handling preserves RFC 7959's legal per-block success mode, manually managed Block1 and initial 4.13 size hints. Invalid current acknowledgements explicitly cancel the original request and notify asynchronous callers through appended FailReason.Cancelled=2; existing Rejected=0 and TimedOut=1 remain unchanged. Critical-option bit classification is corrected. The narrow smeshlink PR64/PR80 shutdown-log/test-counter fixes are also included.
The audit covers all 65 upstream issues and 17 PRs, 75 visible forks (73 readable repositories, 301 refs, 47 unique heads), plus a bounded 100-candidate CoAP-topic survey across 21 named languages. It distinguishes codecs, protocol stacks, platforms, LwM2M and testing tools, records current RFC/IANA and license evidence, and leaves optional capabilities as individual open contracts.
Validation on final head 9f53d25:
The option19 legacy/default API compatibility decision remains pending in #23. Known-option semantic policy (#28), remaining lifecycle work (#29), common extensions and transports/security stay open. This PR does not publish a tag or NuGet package.
Closes #20
Closes #21
Closes #22
Refs #23, #24, #25, #26, #27, #28, #29, #30, #31.