1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 09:33:50 +01:00

2656 Commits

Author SHA1 Message Date
MrKevinWeiss
f770f72202
treewide: Fix spelling mistakes 2025-03-13 13:59:07 +01:00
Marian Buschsieweke
da0218323b
sys/net/nanocoap: improve coap_build_reply
- The responsibility for handling matching CoAP No-Response Options
  has been split:
    - `coap_build_reply()` only needs to report this and return
      `-ECANCLED`
    - `coap_handle_req()` does generate the empty ACK is needed.
  ==> As a result, writing CoAP request handlers correctly becomes a
      lost easier. Correct error handling to be present is now
      sufficient for correct handling of No-Response options.
  ==> This change is backward compatible with existing code.
- The API doc has been cleaned up and straightened

Co-authored-by: mguetschow <mikolai.guetschow@tu-dresden.de>
2025-03-12 08:56:20 +01:00
Marian Buschsieweke
05289a7d1f
sys/include/net/coap.h: Add COAP_PAYLOAD_MARKER_SIZE
Using a constant is easier than explaining where the magic 1 came from
in size estimations.
2025-03-12 08:33:58 +01:00
Marian Buschsieweke
be27eafc4f
sys/net/nanocoap: fix API inconsistency
For in-band signalling that a content format is not valid / present,
the magic number `COAP_FORMAT_NONE` was introduced and the type
`uint16_t` was used. Some APIs however used different in-band signalling
values and types:

- coap_reply_simple(): No signal available, `unsigned int`
- coap_build_reply_header(): negative values, `int`
    (Using `int` would prevent using larger content format numbers on
    8-bit and 16-bit archs, where `int` and `int16_t` have the same
    range.)

This changes the behavior to consistently use `COAP_FORMAT_NONE` as
"no content format" signal and `uint16_t` as type.
2025-02-24 12:05:35 +01:00
benpicco
f67055c3b2
Merge pull request #19668 from benpicco/ieee802154_symbol_time_on_demand
ieee802154/submac: calculate symbol time on demand
2025-02-20 12:04:10 +00:00
Benjamin Valentin
73e45dd6ca ieee802154/submac: implement MR-FSK timings 2025-02-20 12:00:00 +01:00
krzysztof-cabaj
a2dfd78b27 treewide: fix double the in doc and comments 2025-02-18 13:25:02 +01:00
Marian Buschsieweke
4de6aa10e9
Merge pull request #21212 from mguetschow/examples-rename-match
treewide: fix example references in docs
2025-02-14 18:44:12 +00:00
Mikolai Gütschow
ca5fe72bf8
treewide: fix example references in docs
adapt to folder structure from #21135
2025-02-14 19:14:22 +01:00
Benjamin Valentin
82e892089e sys/net/gnrc/netif: pktqueue: don't clash with GNRC_NETIF_FLAGS_6LO_HC 2025-02-14 16:48:43 +01:00
Benjamin Valentin
a886adf611 ieee802154/submac: implement MR-OFDM timings 2025-02-10 14:56:14 +01:00
Marian Buschsieweke
5b6bac000a
sys/net/nanocoap: drop typedef hack
There is an `typdef void sock_udp_ep_t` hack in `nanocoap.h` that tries
allow using parts of nanocoap without a RIOT network stack.

There is a similar hack to allow it to be used without RIOT at all. This
has been used in the early days during development on Linux directly.
This however has not been tested and left bit rotting.

Both hacks are remove and nanocoap now just depends on sock/udp.h.

In a future cleanup, the CoAP packet parsing and building code of
nanocoap can be separated from the part that does the transmission and
reception of UDP packets. That way, using nanocoap's packet parsing and
building will again be available without using a network stack.

Until then, let's drop the hacks and just depend on a network stack.
2025-02-05 14:56:42 +01:00
benpicco
139404df35
Merge pull request #21147 from maribu/sys/net/nanocoap/observe
sys/net/nanocoap: Implement Observe (Server-Side)
2025-01-23 15:49:26 +00:00
Marian Buschsieweke
feeb68470f
sys/net/nanocoap: implement observe
This adds the new `nanocoap_server_observe` module that implements the
server side of the CoAP Observe option. It does require cooperation
from the resource handler to work, though.

Co-Authored-By: mguetschow <mikolai.guetschow@tu-dresden.de>
Co-authored-by: benpicco <benpicco@googlemail.com>
2025-01-23 14:25:39 +01:00
Marian Buschsieweke
1c7ba9e055
sys/net/nanocoap: improve separate response handling
This allows sending a separate response with CoAP Options and adds a
helper to detect duplicate requests, so that resource handlers can
repeat their empty ACK on duplicates.
2025-01-23 14:25:02 +01:00
Benjamin Valentin
2374b9e2f1 gnrc/ipv6/nib: deprecate CONFIG_GNRC_IPV6_STATIC_LLADDR_IS_FIXED
This should just be the only behavior of CONFIG_GNRC_IPV6_STATIC_LLADDR.
2025-01-23 13:32:45 +01:00
Benjamin Valentin
28016ee416 gnrc/ipv6/nib: make CONFIG_GNRC_IPV6_STATIC_LLADDR_IS_FIXED the default
The auto-increment is very surprising and no actual use-cases for it are known.
2025-01-23 13:32:31 +01:00
Benjamin Valentin
a95bd508a5 gnrc_netif: fix timeout in gnrc_netif_ipv6_wait_for_global_address() 2025-01-16 16:07:40 +01:00
Marian Buschsieweke
590ca5d7ff
sys/net/gcoap: get rid of API abuse
Calling `coap_get_token()` and `coap_get_token_length()` on an
(mostly) uninitialized `coap_pkt_t` did work so far due to
implementation details matching the expectations, but this is not
backed up by any API contract.

This fixes the API abuse by introducing and using a new API that does
read a token and token length from a CoAP over UDP packet out of a
buffer. This now provides the behavior expected by the caller and
commits to it via API contract.

Co-authored-by: mguetschow <mikolai.guetschow@tu-dresden.de>
Co-authored-by: benpicco <benpicco@googlemail.com>
2025-01-10 21:31:08 +01:00
Oleg Hahm
395bdb83fe sys: net: dns: use Quad resolver
Replaces Google's solver with the Quad9 (https://quad9.net/) ones.
2025-01-03 10:05:46 +01:00
Marian Buschsieweke
ab116ec71c
sys/net/nanocoap: Fix sending bogus separate responses
When module `nanocoap_server_separate` is not used, the functions to
send separate responses are still provided, just in a broken version:
They will send the separate replies from a different endpoint than the
request was received at (even on machines with only one IP address, as
also the source port is randomized).

This changes the behavior to only provide the functions for separate
response when the do work, so that others will detect an invalid
configuration at compile time rather than at run time.

The documentation is duly updated.
2024-12-13 08:40:43 +01:00
Marian Buschsieweke
7a738d0e0b
sys/net/nanocoap: fix buffer overflow in separate response handling
When RFC 8974 support (module `nanocoap_token_ext`) is in use, the
request token may be longer than the buffer in the separate response
context is large. This adds a check to not overflow the buffer.

Sadly, this is an API change: Preparing the separate response context
can actually fail, so we need to report this with a return value.

The example application has been adapted to only proceed if the separate
reply context could have been prepared, and rather directly emit a
reset message if the token exceeds the static buffer.

Co-authored-by: benpicco <benpicco@googlemail.com>
2024-12-12 14:28:28 +01:00
Benjamin Valentin
ea1670ab0f sys/net/gnrc_pktbuf: move CANARY to header file 2024-11-19 15:23:03 +01:00
Benjamin Valentin
db2f3bd3dd sys/net/gnrc/pkt: use uint8_t for user count
It's very unlikely that a pkt snip will have more than 255 users.
Use a uint8_t here to save 4 bytes per snip as this now fits into
the ununsed struct padding.
2024-11-14 18:48:55 +01:00
Marian Buschsieweke
cec85cfc88
Merge pull request #20945 from maribu/sys/net/gcoap/replace-super-insane-hack-with-less-insane-hack
sys/net/gcoap: reduce insanity of hack
2024-11-08 20:03:37 +00:00
Marian Buschsieweke
2b6f65a08a
build_system/xfa: change API to fix alignment
This changes the API of xfa from

    XFA(array_name, prio) type element_name = INITIALIZER;

to

    XFA(type, array_name, prio) element_name = INITIALIZER;

this allows forcing natural alignment of the type, fixing failing tests
on `native64`.
2024-11-07 16:30:01 +01:00
Marian Buschsieweke
68beb52f14
sys/net/nanocoap: add and use coap_get_response_hdr_len()
Before, handlers writing blockwise transfer assumed that the response
header length will match the request header length. This is true for
UDP, but not for TCP: The CoAP over TCP header contains a Len field,
that gets extended for larger messages. Since the reply often is indeed
larger than the request, this is indeed often the case for CoAP over
TCP.

Note: Right now, no CoAP over TCP implementation is upstream. However,
      getting rid of incorrect assumptions now will make life easier
      later on.
2024-11-05 10:46:02 +01:00
Marian Buschsieweke
765dc3a299
sys/net/gcoap: reduce insanity of hack
gcoap contains a hack where a `coap_pkt_t` is pulled out of thin air,
parts of the members are left uninitialized and a function is called on
that mostly uninitialized data while crossing fingers hard that the
result will be correct. (With the current implementation of the used
function this hack does actually work.)

Estimated level of insanity: 😱😱😱😱😱

This adds to insane functions to get the length of a token and the
length of a header of a CoAP packet while crossing fingers hard that
the packet is valid and that the functions do not overread.

Estimated level of insanity: 😱😱😱

The newly introduced insane functions are used to replace the old
insane hack, resulting in an estimated reduction of insanity of 😱😱.

Side note: This actually does fix a bug, as the old code did not take
           into account the length of the extended TKL field in case of
           RFC 8974 being used. But that is a bug in the abused API,
           and not in the caller abusing the API.
2024-11-01 16:32:59 +01:00
Marian Buschsieweke
469edf4827
sys/net/nanocoap: fix coap_get_total_hdr_len()
Before `coap_get_total_hdr_len()` did not take the extended TKL field
(RFC 8974) into account. This fixes the issue.
2024-11-01 13:58:34 +01:00
Vjorald
d4fb64cfbc cord/doc: Update references to RFC 9176 2024-10-18 23:52:35 +02:00
benpicco
bada659375
Merge pull request #20918 from maribu/sys/net/nanocoap/coap_pkt_set_code
sys/nanocoap: add coap_pkt_set_code()
2024-10-17 16:02:19 +00:00
Marian Buschsieweke
f16875b6ec
sys/nanocoap: add coap_pkt_set_code()
This adds a small convenience function to set the CoAP code of a packet
and converts users of coap_hdr_set_code() where applicable.
2024-10-17 14:56:54 +02:00
Marian Buschsieweke
835571c0a7
sys/net/nanocoap: fix UB when building hdr
Some calls to `coap_build_hdr()` were done with the target buffer for
the header and the source buffer for the token overlapping:
They reuse the buffer that held the request to assemble the response in.
We cannot use `memcpy()` in this case to copy the token into the target
buffer, as source and destination would (fully) overlap.

This commit makes reusing the request buffer for the response a special
case: `memcpy()` is only used to copy the token if source and
destination address of the token differ.

An alternative fix would have been to use `memmove()` unconditionally.
But `memmove()` does not make any assumption about the layout of target
and source buffer, while we know that the token either will already be
at the right position (when reusing the request buffer for the response)
or be in a non-overlapping buffer (when generating a fresh token). This
approach is more efficient than `memmove()`.
2024-10-17 14:02:06 +02:00
benpicco
3706589959
Merge pull request #20834 from derMihai/mir/nib/drop_for_unreachable_rebase
gnrc/ipv6/nib: don't queue packets on 6lo neighbors and drop/flush if…
2024-10-16 09:16:40 +00:00
Mihai Renea
3a5612ee57 gnrc/ipv6/nib: don't queue packets on 6lo neighbors and drop/flush if UNREACHABLE 2024-10-16 09:01:36 +02:00
benpicco
5c06502c4d
Merge pull request #20835 from xnumad/nib-route-hide-on-link-prefixes
gnrc/ipv6: `nib route`: hide off-link PLEs
2024-09-24 15:42:48 +00:00
Fabian Hüßler
02e513e04b sys/include/net: better documentation of nanocoap_sock_request_cb 2024-09-10 16:44:19 +02:00
Fabian Hüßler
95b46ee2a5 sys/net/application_layer/nanocoap: add nanocoap_sock_get_non 2024-09-10 16:43:44 +02:00
xnumad
48a2417892 gnrc/ipv6: nib route: hide off-link PLEs 2024-08-26 16:30:58 +02:00
benpicco
1626919da7
Merge pull request #20684 from fabian18/pr/fix_gcoap_observe_response_correlation
sys/net/application_layer/gcoap: fix Observe notifications correlation
2024-08-26 14:11:59 +00:00
Daniel Lockau
7240d37fc2 nib.c: allow selection of interfaces for static link local addresses 2024-08-26 08:31:21 +02:00
Fabian Hüßler
a181c7b543 sys/gcoap: add public function to find a resource by path 2024-08-21 17:49:48 +02:00
Fabian Hüßler
c1535d25ba nanocoap: constify coap_match_path() API 2024-08-21 17:49:48 +02:00
Fabian Hüßler
08f6ec49c4 gcoap: lock CoAP state mutex in observe API 2024-08-21 17:49:48 +02:00
Fabian Hüßler
a2a7f41a59 gcoap: send Observe notifications from request address 2024-08-21 17:34:18 +02:00
Benjamin Valentin
2aaaf6df9e net/gcoap: fix guards around defines 2024-07-29 19:04:15 +02:00
Martine Lenders
53d853342f
doc: fix links to GNRC master thesis 2024-07-15 11:25:30 +02:00
benpicco
4ba7c46e4d
Merge pull request #20711 from fabian18/pr/gcoap_aux_local_in_req_send
gcoap: propagate local tx aux to gcoap_req_send() and in _handler_req()
2024-07-05 12:07:38 +00:00
Fabian Hüßler
c12375eec4 gcoap/forward_proxy: reply from request destination address 2024-05-31 12:04:48 +02:00
Fabian Hüßler
f4b1306460 gcoap: pass aux local to _handle_req() 2024-05-31 12:04:48 +02:00