Skip to content

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Aug 7, 2025

Contribution description

Requests larger than CONFIG_NANOCOAP_SERVER_BUF_SIZE were previously silently ignored.
But we can do better: With sock_udp_recv_buf_aux() we don't need to copy the request into a separate buffer but can just use the buffer allocated by the network stack.

We still need CONFIG_NANOCOAP_SERVER_BUF_SIZE for the response as otherwise the size of the request packet would be the limit for the response packet. But this is now both in control of the server, a good server implementation can only use this for the header and keep the payload in a separate buffer.

The only problem is that several CoAP handler functions (e.g. _sha256_handler()) expect pkt->hdr to point to the response buffer and use pkt->hdr and buf interchangeably.

As a workaround, this also sets pkt->hdr = rbuf in coap_build_reply() to accommodate those handler functions.

Testing procedure

Issues/PRs references

@github-actions github-actions bot added Area: network Area: Networking Area: CoAP Area: Constrained Application Protocol implementations Area: sys Area: System labels Aug 7, 2025
@benpicco benpicco requested a review from maribu August 7, 2025 15:44
@crasbe crasbe added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Aug 7, 2025
@riot-ci
Copy link

riot-ci commented Aug 7, 2025

Murdock results

✔️ PASSED

ec00a16 nanocoap: ensure pkt->hdr equals rbuf in coap_build_reply()

Success Failures Total Runtime
10559 0 10560 11m:58s

Artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: CoAP Area: Constrained Application Protocol implementations Area: network Area: Networking Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants