1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

133 Commits

Author SHA1 Message Date
Marian Buschsieweke
c70075b073
Merge pull request #20950 from maribu/sys/net/nanocoap/coap_get_response_hdr_len
sys/net/nanocoap: add and use coap_get_response_hdr_len()
2024-11-05 13:09:51 +00: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
2c93dc9c3b
sys/net/nanocoap: fix coap_build_reply_header()
In case no payload is added, `coap_build_reply_header()` would return
`sizeof(coap_hdr_t) + token_length` regardless of the actual header
length returned by `coap_build_hdr()`. These can be different if
RFC 8974 extended tokens are enabled (module `nanocoap_token_ext`
used): If an extended token length field is used, its size is not
considered.

Co-authored-by: benpicco <benpicco@googlemail.com>
2024-11-04 21:18:07 +01: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
Benjamin Valentin
66fe083d9b nanocoap: always write at least 1 byte in coap_block2_finish()
The CoAP block option gets written twice:
First a 'dummy' value is written by `coap_opt_add_block2()`, later this gets
overwritten by the real option value by coap_block2_finish().

The problem arises when the size of the option changes.
If the option ends up smaller than the dummy, we have garbage bytes after the
real option value, corrupting the packet.

To mitigate this, always write at least one option byte (which will be a 0 byte)
to ensure the dummy data is overwritten.

fixes #20686
2024-09-07 16:11:23 +02:00
Fabian Hüßler
c1535d25ba nanocoap: constify coap_match_path() API 2024-08-21 17:49:48 +02:00
Fabian Hüßler
f4b1306460 gcoap: pass aux local to _handle_req() 2024-05-31 12:04:48 +02:00
benpicco
3f41494e59
Merge pull request #20266 from benpicco/nanocoap_reply_separate
nanocoap_sock: implement separate response
2024-05-21 17:45:22 +00:00
Benjamin Valentin
c280076594 nanocoap: add coap_build_empty_ack() 2024-05-21 19:27:57 +02:00
Benjamin Valentin
2c232dd0d2 nanocoap: don't set type & code twice in coap_build_reply() 2024-05-21 19:25:55 +02:00
Benjamin Valentin
879d312960 nanocoap: make token const in coap_build_hdr() 2024-05-21 19:25:55 +02:00
Benjamin Valentin
6154c1270d nanocoap: allow token to be const in coap_build_hdr() 2024-03-22 16:02:45 +01:00
Marian Buschsieweke
609ad44f39
Merge pull request #20245 from benpicco/nanocoap_sock-pathquery
nanocoap_sock: always use coap_opt_put_uri_pathquery()
2024-02-19 18:28:38 +00:00
Benjamin Valentin
c71b5ae617 nanocoap: implement coap_reply_simple() using coap_build_reply_header() 2024-01-23 19:16:59 +01:00
Benjamin Valentin
158c1b8fa8 nanocoap: add coap_build_reply_header() 2024-01-23 19:16:59 +01:00
Benjamin Valentin
a6ef93fc71 nanocoap: make use of COAP_PAYLOAD_MARKER 2024-01-23 19:16:59 +01:00
Benjamin Valentin
1c24462cd9 nanocoap: implement coap_find_uri_query() 2024-01-19 10:53:03 +01:00
Benjamin Valentin
eb76b8ea62 nanocoap: allow lastonum=NULL in coap_opt_put_uri_pathquery() 2024-01-11 16:51:18 +01:00
Benjamin Valentin
0fa04a3d57 nanocoap: prevent integer underflow in coap_opt_put_uri_pathquery()
If uri contains no path but only a query "?foo=bar" `len` would underflow.
Fix this by detecting if there is no path.

Reported by @Yu3H0
2023-10-20 12:59:42 +02:00
bors[bot]
72ca81b65c
Merge #19487 #19808
19487: nanocoap: implement extended tokens (RFC 8974) r=benpicco a=benpicco



19808: boards: add ESP32-S3-USB-OTG support r=benpicco a=gschorcht

### Contribution description

This PR provides the support for the [ESP32-S3-USB-OTG](https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32s3/esp32-s3-usb-otg/user_guide.html) board.

The SD card can only be used in SPI mode at the moment. As soon as PR #19786 is merged, the SD/MMC support can be enabled and the SD card can then be used in SD mode with 4-bit data bus width.

The display uses uses the ST7789 driver IC that is compatible with the ST7735. For that purpose the ST7735 driver is extended by a pseudomodule definition `st7789` for the ST7789 which is enabled by the board and enables automatically the `st7789` (e57c48a33ee2a869c15603788e5306ba066f91cf). Vise versa, board's `Makefile.dep` enables automatically the `st7789` pseudomodule if the `st7735` is used. The pseudomodule `st7789` is just used to increase the upper limit for supported lines. This change is also part of PR #19807.

~The PR includes a very small documentation fix for ESP32-S3-DevKit board that was noticed during the development of this board definition (1155b6ac1b8efa39d8a0bd7150e602095159fdc1).~

### Testing procedure

The board has been tested with all basic tests for supported hardware including `tests/driver/st3375`:

![IMG_20230707_105556](https://github.com/RIOT-OS/RIOT/assets/31932013/88d4ac11-0c02-4339-a423-7900e1c0904c)

- [x] tests/drivers/st3375
- [x] tests/periph/gpio
- [x] tests/periph/pwm
- [x] tests/periph/spi
- [x] tests/periph/uart
- [x] tests/sys/usbus_cdc_ecm 

### Issues/PRs references


Co-authored-by: Benjamin Valentin <benpicco@beuth-hochschule.de>
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
2023-07-07 17:41:40 +00:00
Benjamin Valentin
661829f43f nanocoap: homogenize name of the module 2023-06-08 16:29:12 +02:00
Benjamin Valentin
923c9a32ef nanocoap: clean up coap_iterate_option(), make it public 2023-06-07 16:07:17 +02:00
Benjamin Valentin
660c77e2c3 nanocoap: implement extended tokens (RFC 8974) 2023-06-05 18:35:29 +02:00
Benjamin Valentin
44c267c84a nanocoap: allow to define CoAP resources as XFA 2023-02-28 20:13:18 +01:00
Benjamin Valentin
c09ad471a1 nanocoap: whitespace fixes 2023-02-22 18:03:04 +01:00
Benjamin Valentin
8a11ca2f87 nanocoap: don't hide coap_request_ctx_t content 2022-11-22 10:41:32 +01:00
Benjamin Valentin
55e13a9d61 nanocoap: add coap_request_ctx_init() 2022-10-28 15:24:23 +02:00
Benjamin Valentin
c6f9654461 nanocoap: request context to coap_handle_req() 2022-10-28 14:21:52 +02:00
Jan Romann
d916b33bc6 sys/net/nanocoap: introduce Accept option helper 2022-10-19 16:44:13 +02:00
benpicco
72d16e152a
Merge pull request #17983 from kfessel/p-remove-coap_pkt-token
net/nanocoap: remove coap_pkt token ptr
2022-10-16 04:21:47 +02:00
Benjamin Valentin
56f36c09a0 nanocoap: add support for no-response option
See https://datatracker.ietf.org/doc/rfc7967/
2022-10-13 19:04:09 +02:00
Karl Fessel
14096a935f sys/net: cleanup coap_pkt_t.token uses 2022-10-06 00:20:10 +02:00
Martine Lenders
b9d7028a8f
coap: provide definition for version field value 2022-09-29 11:26:03 +02:00
Benjamin Valentin
a37b283ebe nanocoap: coap_tree_handler(): accept resources in any order 2022-09-26 20:32:30 +02:00
Benjamin Valentin
1552267d19 gcoap: drop duplicate context field from coap_request_ctx_t 2022-09-12 17:51:26 +02:00
Benjamin Valentin
2376343547 gcoap: add remote sock_udp_ep_t to coap_request_ctx_t 2022-09-12 17:51:26 +02:00
Benjamin Valentin
d7bb42296a gcoap: move tl_type to coap_request_ctx_t 2022-07-17 18:05:07 +02:00
Benjamin Valentin
3806f7d532 nanocoap: make coap_request_ctx_t members internal 2022-07-17 14:32:16 +02:00
Benjamin Valentin
acfab72296 nanocoap: make use of coap_request_ctx_t 2022-07-17 14:29:39 +02:00
Benjamin Valentin
00221818b6 nanocoap: use uint8_t for szx value
The value is an exponent, 8 bits totally suffice here
2022-05-23 23:41:21 +02:00
benpicco
7c62c8983d
Merge pull request #17958 from benpicco/nanocoap-blockwise_put
nanocoap_sock: add nanocoap_sock_block_request()
2022-05-18 10:40:24 +02:00
Benjamin Valentin
f2279e43ae nanocoap_sock: support sending CoAP packet with payload snips 2022-05-17 23:07:23 +02:00
Benjamin Valentin
0847c18a18 nanocoap: use size_t for payload_len 2022-05-03 11:32:20 +02:00
Benjamin Valentin
cabb2c912d nanocoap: use void * for payload bytes 2022-05-03 11:32:20 +02:00
eecac6945b nanocoap: Add handler for resource-based subtrees
This adds a coap_handler_t function that can be used to parse new
subtrees. The subtree information is included in the context pointer of
the call and must be of type coap_resource_subtree_t. This object then
contains the pointer and length of a different coap_resource_t instance.
2022-04-23 10:12:18 +02:00
benpicco
c032e40fba
Merge pull request #17976 from benpicco/coap_get_token
nanocoap: add coap_get_token()
2022-04-22 10:08:30 +02:00
Benjamin Valentin
845a757eed nanocoap: don't set lastonum if no option was added 2022-04-21 15:39:25 +02:00
Benjamin Valentin
c4f6249992 nanocoap: make use of coap_get_token() 2022-04-21 15:34:31 +02:00
Martine Lenders
00fdd8a146
nanocoap: introduce coap_opt_remove() 2022-03-31 09:47:57 +02:00
Benjamin Valentin
7dc2f730d2 nanocoap: check if all critical options were handled 2022-02-24 12:20:05 +01:00