-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys: Add stdio_coap #19289
base: master
Are you sure you want to change the base?
sys: Add stdio_coap #19289
Conversation
With the latest updates, this collaborates well with other gcoap resources, so it can also be used together with the gcoap example. (It doesn't work with the rust-gcoap example: That still usurps the full CoAP tree). It suffers a bit from the lack of the built-in .well-known/core's block-wise transfer or filtering, but that's a topic of its own. (More concretely, with the default buffer sizes and the gcoap example, only one of two resources is listed, making stdout work but stdin not). |
19329: MAINTAINING.md: add some notes on Bors r=benpicco a=benpicco 19330: native/stdio: Explicitly provide getchar r=chrysn a=chrysn ### Contribution description This ensures that even when libc does not implement getchar through getc, any custom stdio is still in the loop when getchar is used. Frankly, I don't know when this broke -- I'm pretty sure custom stdio worked just a few days ago -- but either way, without this patch RIOT on native currently bypasses a configured stdio for me. ### Testing procedure * `make -C examples/saul all debug` * `break stdio_read` * `run` Without this patch, observe how the shell runs w/o ever breaking. After, lots of breakpoint hits. This is the way it behaves for me (Debian sid, libc6:i386 2.36-8). If it works for you before this patch, we might start bisecting the differences between the systems, but we may also accept that libcs may imlpement getchar in different ways, and not all of them pass by the getc which we're patching. ### Issues/PRs references This is needed for testing #19289. The implementation stems from the `fgetc(3)` man page, which states that "getchar() is equivalent to getc(stdin)". Co-authored-by: Benjamin Valentin <benpicco@beuth-hochschule.de> Co-authored-by: chrysn <chrysn@fsfe.org>
Now updated to also work over DTLS. There's no checking of which credentials are used -- stdio is even accepted over unprotected CoAP -- but how we'd establish actual DTLS credentials that are not just "secretPSK" is something that'll need a bit of thought anyway. (Possibly together with considering RFC9202 and a corresponding update to credman). So
|
16158: gnrc_sixlowpan_frag_sfr_congure_sfr: initial import r=miri64 a=miri64 19331: pkg/tinydtls: Adjust defaults r=miri64 a=chrysn ### Contribution description This adjusts two defaults in tinydtls: * Default verbosity is set to warning. At the info level, this module produces way more output (several lines per new connection, and even per message) than is common in RIOT. * If gcoap is used, the buffer size is adjusted to the gcoap buffer size plus overhead. Otherwise, CoAP-over-DTLS works fine until one happens to request larger resources. ### Testing procedure * Run examples/gcoap_dtls * Send a CoAP request from outside, eg. with `aiocoap-client 'coaps://[fe80::3c63:beff:fe85:ca96%tapbr0]/.well-known/core' --credentials testserver.json` (where testserver.json is `{"coaps://[fe80::3c63:beff:fe85:ca96%tapbr0]/*": {"dtls": {"psk": {"ascii": "secretPSK"}, "client-identity": {"ascii": "Client_identity"}}}}`). Before, there are messages shown for every request; now there are none. Modify `examples/gcoap/server.c` as follows: ```patch diff --git a/examples/gcoap/server.c b/examples/gcoap/server.c index bf2315cd01..28e1faac27 100644 --- a/examples/gcoap/server.c +++ b/examples/gcoap/server.c `@@` -68,7 +68,7 `@@` static const coap_resource_t _resources[] = { }; static const char *_link_params[] = { - ";ct=0;rt=\"count\";obs", + ";ct=0;rt=\"count\";obs;looooooooooooooooooooooong-attribute=\"loooooooooooooooooooooooooooooong\"", NULL }; ``` The request passes; without this patch, it is stuck in retransmissions until "Network error: Retransmissions exceeded". ### Issues/PRs references This contributes to making #19289 usable with a minimum level of security. (That module fills up the gcoap buffer to the brim). While the module handles the verbosity as well as it can (occasionally admitting that it lost bytes of output), the previous verbosity produces an infinite stream of stdout data. (But the default should be quiet immaterial of that particular PR). Co-authored-by: Martine Lenders <m.lenders@fu-berlin.de> Co-authored-by: chrysn <chrysn@fsfe.org>
19331: pkg/tinydtls: Adjust defaults r=benpicco a=chrysn ### Contribution description This adjusts two defaults in tinydtls: * Default verbosity is set to warning. At the info level, this module produces way more output (several lines per new connection, and even per message) than is common in RIOT. * If gcoap is used, the buffer size is adjusted to the gcoap buffer size plus overhead. Otherwise, CoAP-over-DTLS works fine until one happens to request larger resources. ### Testing procedure * Run examples/gcoap_dtls * Send a CoAP request from outside, eg. with `aiocoap-client 'coaps://[fe80::3c63:beff:fe85:ca96%tapbr0]/.well-known/core' --credentials testserver.json` (where testserver.json is `{"coaps://[fe80::3c63:beff:fe85:ca96%tapbr0]/*": {"dtls": {"psk": {"ascii": "secretPSK"}, "client-identity": {"ascii": "Client_identity"}}}}`). Before, there are messages shown for every request; now there are none. Modify `examples/gcoap/server.c` as follows: ```patch diff --git a/examples/gcoap/server.c b/examples/gcoap/server.c index bf2315cd01..28e1faac27 100644 --- a/examples/gcoap/server.c +++ b/examples/gcoap/server.c `@@` -68,7 +68,7 `@@` static const coap_resource_t _resources[] = { }; static const char *_link_params[] = { - ";ct=0;rt=\"count\";obs", + ";ct=0;rt=\"count\";obs;looooooooooooooooooooooong-attribute=\"loooooooooooooooooooooooooooooong\"", NULL }; ``` The request passes; without this patch, it is stuck in retransmissions until "Network error: Retransmissions exceeded". ### Issues/PRs references This contributes to making #19289 usable with a minimum level of security. (That module fills up the gcoap buffer to the brim). While the module handles the verbosity as well as it can (occasionally admitting that it lost bytes of output), the previous verbosity produces an infinite stream of stdout data. (But the default should be quiet immaterial of that particular PR). Co-authored-by: chrysn <chrysn@fsfe.org>
18515: libschc: initial import as package r=miri64 a=miri64 19331: pkg/tinydtls: Adjust defaults r=miri64 a=chrysn ### Contribution description This adjusts two defaults in tinydtls: * Default verbosity is set to warning. At the info level, this module produces way more output (several lines per new connection, and even per message) than is common in RIOT. * If gcoap is used, the buffer size is adjusted to the gcoap buffer size plus overhead. Otherwise, CoAP-over-DTLS works fine until one happens to request larger resources. ### Testing procedure * Run examples/gcoap_dtls * Send a CoAP request from outside, eg. with `aiocoap-client 'coaps://[fe80::3c63:beff:fe85:ca96%tapbr0]/.well-known/core' --credentials testserver.json` (where testserver.json is `{"coaps://[fe80::3c63:beff:fe85:ca96%tapbr0]/*": {"dtls": {"psk": {"ascii": "secretPSK"}, "client-identity": {"ascii": "Client_identity"}}}}`). Before, there are messages shown for every request; now there are none. Modify `examples/gcoap/server.c` as follows: ```patch diff --git a/examples/gcoap/server.c b/examples/gcoap/server.c index bf2315cd01..28e1faac27 100644 --- a/examples/gcoap/server.c +++ b/examples/gcoap/server.c `@@` -68,7 +68,7 `@@` static const coap_resource_t _resources[] = { }; static const char *_link_params[] = { - ";ct=0;rt=\"count\";obs", + ";ct=0;rt=\"count\";obs;looooooooooooooooooooooong-attribute=\"loooooooooooooooooooooooooooooong\"", NULL }; ``` The request passes; without this patch, it is stuck in retransmissions until "Network error: Retransmissions exceeded". ### Issues/PRs references This contributes to making #19289 usable with a minimum level of security. (That module fills up the gcoap buffer to the brim). While the module handles the verbosity as well as it can (occasionally admitting that it lost bytes of output), the previous verbosity produces an infinite stream of stdout data. (But the default should be quiet immaterial of that particular PR). Co-authored-by: Martine Lenders <m.lenders@fu-berlin.de> Co-authored-by: chrysn <chrysn@fsfe.org>
19331: pkg/tinydtls: Adjust defaults r=miri64 a=chrysn ### Contribution description This adjusts two defaults in tinydtls: * Default verbosity is set to warning. At the info level, this module produces way more output (several lines per new connection, and even per message) than is common in RIOT. * If gcoap is used, the buffer size is adjusted to the gcoap buffer size plus overhead. Otherwise, CoAP-over-DTLS works fine until one happens to request larger resources. ### Testing procedure * Run examples/gcoap_dtls * Send a CoAP request from outside, eg. with `aiocoap-client 'coaps://[fe80::3c63:beff:fe85:ca96%tapbr0]/.well-known/core' --credentials testserver.json` (where testserver.json is `{"coaps://[fe80::3c63:beff:fe85:ca96%tapbr0]/*": {"dtls": {"psk": {"ascii": "secretPSK"}, "client-identity": {"ascii": "Client_identity"}}}}`). Before, there are messages shown for every request; now there are none. Modify `examples/gcoap/server.c` as follows: ```patch diff --git a/examples/gcoap/server.c b/examples/gcoap/server.c index bf2315cd01..28e1faac27 100644 --- a/examples/gcoap/server.c +++ b/examples/gcoap/server.c `@@` -68,7 +68,7 `@@` static const coap_resource_t _resources[] = { }; static const char *_link_params[] = { - ";ct=0;rt=\"count\";obs", + ";ct=0;rt=\"count\";obs;looooooooooooooooooooooong-attribute=\"loooooooooooooooooooooooooooooong\"", NULL }; ``` The request passes; without this patch, it is stuck in retransmissions until "Network error: Retransmissions exceeded". ### Issues/PRs references This contributes to making #19289 usable with a minimum level of security. (That module fills up the gcoap buffer to the brim). While the module handles the verbosity as well as it can (occasionally admitting that it lost bytes of output), the previous verbosity produces an infinite stream of stdout data. (But the default should be quiet immaterial of that particular PR). Co-authored-by: chrysn <chrysn@fsfe.org>
Contribution description
This adds a new stdio through CoAP, roughly following the proposed interface.
It consists of largely independent channels for data out (effectively implemented in the scroll-ring crate), and one for data in (backed by the same kind of ring buffer, but different in its overwrite and blocking behaviors).
The behavior of stdout is that writes never block and happily overwrite the ring buffer -- if data is not obtained fast enough1, it is lost. Still, a byte counter is kept (overflowing at 32bit), so that not only the presence but also the size of holes in the readout can be determined. Right now, the CoAP handler can only be polled. Future versions will hopefully support observe, in which case the hole indication becomes even more important: The fetch can then report the latest slice, and if the client is interested it can still fetch the missed data if it's around by then.
The behavior of stdin is much easier: Data is POSTed there, stored in a buffer, and POSTs are rejected if there's not enough space in the buffer. (It could be way easier if users of stdin asked for data in chunks and not byte-wise, for then we could save the buffer and deliver data right from the request in there -- but even the shell that has a line-sized buffer pulls data bytewise).
Testing procedure
So far, this only works on applications that do not start gcoap on their own, for (at least the simple version of) the discovery procedure relies on .well-known/core being handled by this module. [edit: More precisely, the stdio_coap module currently makes all other gcoap resources indiscoverable.]
USEMODULE+=stdio_coap make -C examples/saul all term
-- this won't print anything on its own.In a separate terminal,
This uses multicast CoAP to discover the precise address of the device; if there are multiple ones around, it picks the one that responds fastest (so in that case, please give the unicast address).
The autodiscovery process also finds the precise paths; applications that set up gcoap manually may need that.
Open issues
How strongly should this pull in gcoap and the network stack? Am I depending on the right modules?
Right now this registers all own resources in a single Rust CoAP handler that's registered as a Gcoap listener. This is not transparent to the resource enumeration process.
There is no sensible
make term
helper -- do we need one? (That'd require passing information at least about the network interface around, likePORT=[fe80::...%tapbr0]
, which we don't have so far)I don't want this merged without a usable security model. I haven't tried going through DTLS -- can our DTLS by now use different keys to gain different levels of authorization?
My goal here is to make things work with OSCORE. That won't be too tricky as long as we're in a all-resources-from-Rust ecosystem, but there's no clear roadmap for integration with on-Rust CoAP resources.
A minimal viable solution could be that OSCORE is available only for these resources, discovery is compatible with other resources, and for the time being, this module negotiates the key between build system and device.
Footnotes
precisely: if more data is written in one go than fits in the ring buffer, or if data is not fetched frequently enough, or the task reading the ring buffer is doing that too slowly, or there are writers that are so low in their priority that that the rest of the ring buffer gets filled before the low priority task completes ↩