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

112 Commits

Author SHA1 Message Date
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
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
Francisco Molina
9195f772ad sys/net/nanocoap: block_finish returns if more are expected 2021-08-06 09:29:03 +02:00
Benjamin Valentin
d4e5c25b70 nanocoap: add coap_opt_put_uri_pathquery() 2021-02-23 18:27:54 +01:00
Benjamin Valentin
b24480538a nanocoap: add coap_opt_put_string_with_len() 2021-01-21 15:17:28 +01:00
Bas Stottelaar
1b35d06a51 sys/*: realign ENABLE_DEBUG 2020-10-23 11:27:48 +02:00
Benjamin Valentin
d4aa8aad10 nanocoap: validate input with NDEBUG
A malformed or malicious CoAP request may contain invalid field lengths.
`nanocoap` protects with this by using `assert()`, which safely crashes
the application in debug mode.

In release mode the check is removed.

Instead of allowing arbitrary memory writes, return 0 on invalid inputs.

Discovered by [Coverity](https://scan3.coverity.com/reports.htm#v46910/p10250/fileInstanceId=38357789&defectInstanceId=9793779&mergedDefectId=297306)
2020-08-11 15:54:23 +02:00
Maciej Jurczak
edf016a6cb nanocoap: Added token length validation.
Implemented a check in coap_parse() to verify if TKL value is within valid range as specified by RFC7252. The token length must be within 0-8 range, any other value should be considered as invalid and the packet should produce message format error.
A test case was added to tests-nanocoap.c to verify correct behavior in case of TKL in range and out of range.

Update sys/net/application_layer/nanocoap/nanocoap.c

Prefixed debug message with module name and abbreviations expanded.

Co-authored-by: Martine Lenders <mail@martine-lenders.eu>

Update sys/net/application_layer/nanocoap/nanocoap.c

Prefixed debug message with module name and abbreviations expanded.

Co-authored-by: Martine Lenders <mail@martine-lenders.eu>
2020-05-25 22:44:50 +02:00
Maciej Jurczak
3be2c51c42 nanocoap: Fixed buffer read out of the input packet bounds issue.
If token length in the header was longer than actually provided in the following payload, read out of the input buffer bounds or processing of data beyond the actual input packet bound could happen. In order to remove the risk, the options loop condition was modified to early detect the condition and abort packet processing if a malformed packet is detected.

nanocoap: Added pointer range check after token length parsing.

Added a check to verify if the current packet parsing pointer is still within the packet boundaries after incrementing by the token length declared in the header. If packet is malformed an error code is returned.

nanocoap: Combined packet length checks

Combined packet length checks after reading token length and processing options into a single packet length validation after the options parsing loop. The entry to the options parsing loop is safe as the while loop condition protects against entering the loop if the token length was invalid.
2020-05-25 22:44:39 +02:00
Ken Bannister
595e8c631f
Merge pull request #13726 from benpicco/nanocoap-payload_helper
nanocoap: add payload helper functions
2020-05-03 08:56:30 -04:00
Benjamin Valentin
e5c20b143d nanocoap: add coap_payload_put_char() 2020-05-01 13:58:22 +02:00
Benjamin Valentin
2751708341 nanocoap: add payload helper functions
This adds two functions `coap_payload_add()` and `coap_payload_advance()`.

 - `coap_payload_add()` will add n bytes to the payload buffer and advance
    payload pointer accordingly.

    const char hello[] = "Hello CoAP!";
    coap_payload_add(pkt, hello, sizeof(hello));

 - `coap_payload_advance()` will advance the payload buffer after data
    has been added to it.

    int len = snprintf(pkt->payload, pkt->payload_len, "%s %s!", "Hello", "CoAP");
    coap_payload_advance(pkt, len);

I considered adding an additional parameter to keep track of the total request size
(returned size from coap_opt_finish() incremented by each added payload fragment),
but decided against it to keep consistency with the existing API.
2020-05-01 13:58:22 +02:00
Cenk Gündoğan
ea616abfda nanocoap: allow coap_opt_add_string() for zero-terminated strings 2020-04-22 12:28:48 +02:00
Leandro Lanzieri
46507ff247
Merge pull request #13894 from kb2ma/gcoap/ping
net/gcoap: add CoAP ping request
2020-04-21 12:23:54 +02:00
Cenk Gündoğan
6859de7855 nanocoap: export coap_opt_get_uint() 2020-04-17 22:39:44 +02:00
Ken Bannister
2d3eb1a343 net/nanocoap: validate empty message length 2020-04-17 08:15:20 -04:00
Leandro Lanzieri
b6be8af81c
net/nanocoap: Move NANOCOAP_QS_MAX to 'CONFIG_' namespace 2020-04-07 17:00:53 +02:00
Leandro Lanzieri
2f72189aa2
net/nanocoap: Move NANOCOAP_BLOCK_SIZE_EXP_MAX to 'CONFIG_' namespace 2020-04-07 17:00:53 +02:00
Leandro Lanzieri
4052c01e85
net/nanocoap: Move NANOCOAP_URI_MAX to 'CONFIG_' namespace 2020-04-07 17:00:53 +02:00
Leandro Lanzieri
c84576ef6e
net/nanocoap: Move NANOCOAP_NOPTS_MAX to 'CONFIG_' namespace 2020-04-07 17:00:52 +02:00
Ken Bannister
d57340c964 net/nanocoap: use new Uri-Query functions as primary implementation 2020-04-06 06:19:44 -04:00
Cenk Gündoğan
50900a1fbe nanocoap: add convenience function for PROXY_URI 2020-03-28 14:50:51 +01:00
Cenk Gündoğan
5e42e26a6e nanocoap: add const qualifier to pkt of coap_opt_get_opaque() 2020-03-25 13:38:21 +01:00