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

318 Commits

Author SHA1 Message Date
Cenk Gündoğan
7d820f7ada
nanocoap: gcoap: use const parameter for coap_method2flag 2020-10-28 15:40:35 +01:00
Cenk Gündoğan
d4370e690e
gcoap: add a handler for request matching 2020-10-28 15:40:35 +01:00
chrysn
c0bc0c41b1 net/goap: State and check that listeners are added individually
Add a an assertion on the added listener not having a trailing chain
instead of silently overwriting it, point out the precondition in the
documentation, and guide users who want to add more than one listener
towards a more efficient way.
2020-10-23 22:33:43 +02:00
benpicco
b5cd19e73e
Merge pull request #14178 from chrysn-pull-requests/gcoap-handle-con-response
gcoap: Process CON responses
2020-10-23 14:21:33 +02:00
Bas Stottelaar
1b35d06a51 sys/*: realign ENABLE_DEBUG 2020-10-23 11:27:48 +02:00
chrysn
462f8861f4 gcoap: Suppress retransmissions when ACK was received
This introduces an additional state to the COAP_MEMO_* series to avoid
enlarging the memo struct needlessly. While they are documented
publicly, practically only the COAP_MEMO_TIMEOUT and COAP_MEMO_RESPONSE
are used in communication with the application, as a
gcoap_request_memo_t is only handed out in that state.
2020-10-22 19:08:39 +02:00
chrysn
f32d758819 gcoap: Prepare to cease retransmission
The actual implementation will follow in a separate commit, this does
the groundwork and sets the intention.
2020-10-22 19:08:39 +02:00
chrysn
0a2f97680f gcoap: Cleanup around empty responses
Simplify the code path and give consistent debug messages.
2020-10-22 19:08:39 +02:00
chrysn
ff00d66d69 gcoap: Process CON responses
This generalizes the existing code for answering CoAP pings into general
message-layer responses. Such responses are now also sent as a reaction
to CON responses, which can otherwise follow the same code path as
existing other responses.

As a side effect, issues that would crop up when responding to odd empty
requests that have token length set are resolved.

Contributes-To: https://github.com/RIOT-OS/RIOT/issues/14169
2020-10-22 19:08:39 +02:00
Bas Stottelaar
80d9da90df sys/*: add missing include of assert.h 2020-10-22 11:13:09 +02:00
Bas Stottelaar
47d376c5c3 sys/*: add explicit include of timex.h 2020-10-21 21:47:31 +02:00
chrysn
6350d22bc9 net/gcoap: Register additional resources head-first
This simplifies (written and compiled) code by doing a head rather than
a tail insertion of the new listener into gcoap's list.

As handling of listeners without a link_encoder is now fixed,
gcoap_get_resource_list can handles this now without having to manually
skip over the .well-known/core handler (which is not the first entry any
more now).

Incidentally, this allows the user to install a custom handler for
.well-known/core, as the default handler is now evaluated last.
2020-10-02 21:04:25 +02:00
chrysn
e3db58f013 net/gcoap: Avoid endless loop on error
The NULL case can not regularly be reached (because regularly
gcoap_register_listener sets thel link_encoder to a default one), but if
it is (eg. because an application unsets its link_encoder to hide a
resource set at runtime), the existing `continue` is a good idea (skip
over this entry) but erroneously created an endless loop by skipping the
advancement step.
2020-10-02 20:53:05 +02:00
Benjamin Valentin
f163f1580b sys/net/uhcp: use LOG_ functions
Using `gnrc_border_router` with `uhcp` is quite noisy.
uhcpc will regularly refresh the prefix and print a bunch of status messages.

Allow the user to tone it down by setting a higher `LOG_LEVEL`.
For this, convert calls to `printf()` and `puts()` to `LOG_xxx()`.

This requires a dummy header for `uhcpd`.
2020-09-29 09:55:28 +02:00
Hauke Petersen
3b424858de net/emcute: fix buffer overflow in _willupd_msg() 2020-09-22 11:43:00 +02:00
Akshai M
bb8d3cd72b sys/net/cord : Expose to Kconfig
Expose configurations to Kconfig

Co-authored-by: Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
2020-09-02 23:36:48 +05:30
Akshai M
536a99022c sys/net/cord : Move 'CONFIG_CORD_EP' to 'CONFIG_' 2020-09-02 23:36:48 +05:30
Akshai M
e09063e7f1 sys/net/cord : Move 'CORD_UPDATE_INTERVAL' to 'CONFIG_' 2020-09-02 23:36:48 +05:30
Akshai M
de2d33f65b sys/net/cord : Move 'CORD_LT' to 'CONFIG_' 2020-09-02 23:36:48 +05:30
Leandro Lanzieri
d25fc243c4
treewide: change prefix for generated Kconfig symbols.
This changes the prefixes of the symbols generated from USEMODULE and
USEPKG variables. The changes are as follow:

   KCONFIG_MODULE_ => KCONFIG_USEMODULE_
   KCONFIG_PKG_ => KCONFIG_USEPKG_
   MODULE_ => USEMODULE_
   PKG_ => USEPKG_
2020-08-31 09:37:09 +02:00
Marian Buschsieweke
3b6fa61829
sys: Cleanup access to internal variables
Replace direct accesses to sched_active_thread and sched_active_pid with
the helper functions thread_getpid() and thread_get_active(). This serves
two purposes:

1. It makes accidental writes to those variable from outside core less likely.
2. Casting off the volatile qualifier is now well contained to those two
   functions
2020-08-24 20:28:11 +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
Akshai M
0413a5881f net/dhcpv6 : Expose to Kconfig
Expose configurations to Kconfig. Add conditional CFLAGS to avoid
conflicts with Kconfig.
2020-07-24 00:23:08 +05:30
Akshai M
1c37e11c0e net/dhcpv6 : Move 'DHCPV6_CLIENT_PFX_LEASE_MAX' to 'CONFIG_' 2020-07-23 21:10:26 +05:30
Leandro Lanzieri
3920dd8c20
net/gcoap: Remove gcoap_finish 2020-07-17 16:33:19 +02:00
Leandro Lanzieri
60f7e3aadf
net/cord/lc: Replace usage of deprecated gcoap_finish 2020-07-17 10:01:55 +02:00
Leandro Lanzieri
f92c693682
net/cord/epsim: Replace usage of deprecated gcoap_finish 2020-07-17 09:51:34 +02:00
Akshai M
e9f270c78a net/asymcute : Expose to Kconfig 2020-07-07 16:27:57 +05:30
Akshai M
8a6d2882f7 net/asymcute : Move 'ASYMCUTE_KEEPALIVE_PING' to 'CONFIG_' 2020-07-07 16:27:57 +05:30
Akshai M
a1df2e33b0 net/asymcute : Move 'ASYMCUTE_N_RETRY' to 'CONFIG_' 2020-07-07 16:27:57 +05:30
Akshai M
6dc5747c4b net/asymcute : Move 'ASYMCUTE_T_RETRY' to 'CONFIG_' 2020-07-07 16:27:57 +05:30
Akshai M
1753b84cba net/asymcute : Move 'ASYMCUTE_KEEPALIVE' to 'CONFIG_' 2020-07-07 16:27:57 +05:30
Akshai M
7ba0d3c76f net/asymcute : Move 'ASYMCUTE_TOPIC_MAXLEN' to 'CONFIG_' 2020-07-07 16:27:57 +05:30
Aiman Ismail
869052dcd8 cord: add RD lookup client 2020-07-07 10:54:10 +02:00
Martine Lenders
2b1be158e3
Merge pull request #13837 from benpicco/dhcpv6-stale_replies
sys/net/dhcpv6: discard stale replies
2020-06-25 12:18:31 +02:00
Benjamin Valentin
2d1160426d sys/net/dhcpv6: discard stale replies
The DHCPv6 server might send reponses multiple times.
The DHCPv6 client will only handle the first response, if additional
responses are comming in they are left in the RX queue.

That results in the client always reading the response of a previous
transaction on any subsequent transactions.
In this case the client will try again, creating a new transaction - that
will again only read the previous response.

To fix this, discard previous responses by flushing the RX queue before
sending a new message to the DHCPv6 server.

fixes #13834
2020-06-21 22:07:32 +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
Leandro Lanzieri
b91c8502dc
net/nanocoap/kconfig: Explicitly define type of MODULE_NANOCOAP 2020-04-27 10:06:01 +02:00
Leandro Lanzieri
eeea9b7dae
net/coap: Expose configurations to Kconfig 2020-04-24 10:06:45 +02:00
Leandro Lanzieri
9e427e1584
net/coap: Move COAP_MAX_RETRANSMIT to 'CONFIG' namespace
COAP_MAX_RETRANSMIT is moved to the compile time configuration macro
namespace.
2020-04-24 10:06:43 +02:00
Leandro Lanzieri
afe4244ac9
net/coap: Move COAP_RANDOM_FACTOR_1000 to 'CONFIG' namespace
COAP_RANDOM_FACTOR_1000 is moved to the compile time configuration macro
namespace.
2020-04-24 10:06:43 +02:00
Leandro Lanzieri
072a0d8563
net/coap: Move COAP_ACK_TIMEOUT to 'CONFIG' namespace
COAP_ACK_TIMEOUT is moved to the compile time configuration macro
namespace.
2020-04-24 10:06:40 +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
6eae4ded84 net/gcoap: create CoAP ping request 2020-04-17 08:15:20 -04:00