-
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
gcoap: add remote sock_udp_ep_t to coap_request_ctx_t #18519
gcoap: add remote sock_udp_ep_t to coap_request_ctx_t #18519
Conversation
3190d8b
to
628edcc
Compare
This allows us to remove some warts introduced by the GCoAP forward proxy - and since the |
acfce49
to
388c1c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do not intend to add local address information in this PR and murdock becomes green, I think this is ready to be merged.
Just some testing:
diff --git a/sys/net/application_layer/gcoap/fileserver.c b/sys/net/application_layer/gcoap/fileserver.c
index eaf14a252b..35c742816d 100644
--- a/sys/net/application_layer/gcoap/fileserver.c
+++ b/sys/net/application_layer/gcoap/fileserver.c
@@ -25,10 +25,12 @@
#include "checksum/fletcher32.h"
#include "net/gcoap/fileserver.h"
#include "net/gcoap.h"
+#include "net/nanocoap.h"
+#include "net/sock/util.h"
#include "vfs.h"
#include "vfs_util.h"
-#define ENABLE_DEBUG 0
+#define ENABLE_DEBUG 1
#include "debug.h"
/** Maximum length of an expressible path, including the trailing 0 character. */
@@ -514,6 +516,16 @@ ssize_t gcoap_fileserver_handler(coap_pkt_t *pdu, uint8_t *buf, size_t len,
const char *resource = coap_request_ctx_get_path(ctx);
struct requestdata request = {0};
+ if (ENABLE_DEBUG) {
+ if (GCOAP_SOCKET_TYPE_UDP == coap_request_ctx_get_tl_type(ctx)) {
+ const sock_udp_ep_t *ep = coap_request_ctx_get_remote_udp(ctx);
+ char addr_str[] = "0000:0000:0000:0000:0000:0000:0000:0000";
+ uint16_t port;
+ sock_udp_ep_fmt(ep, addr_str, &port);
+ DEBUG("gcoap_fileserver: got a request from [%s]:%u\n", addr_str, port);
+ }
+ }
+
/** Index in request.namebuf. Must not point at the last entry as that will be
* zeroed to get a 0-terminated string. */
size_t namelength = 0;
2022-09-11 14:36:46,131 # gcoap_fileserver: got a request from [fe80::3478:9157:9fd5:81c3%6]:34428
cbdfdc8
to
0ba9a50
Compare
I think this PR does enough already. We can add local address information in a follow-up. |
0ba9a50
to
5070ca9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
Thank you for the review! |
Contribution description
It can be useful to know over which interface a CoAP request was received.
(e.g. we have a device with two SLIP + power interfaces, both can be turned off and on individually. If a board registers with the central control board, we want to know to which interface it is connected so we know where to cut power.)
Testing procedure
Issues/PRs references