Conversation
|
The bulk of the code is for address/port/URI handling. Since this is something that is used at $JOB, I’d love to get this (seemingly) generic feature merged (of course, in a form that is deemed appropriate) and only keep hacking $JOB-specific things on top. |
a06fffd to
a69852a
Compare
|
Ping, is this something that could live upstream? |
|
It is something that can be added in upstream , modelled as how AF_UNIX support is done. However, how you specify the Host in the URI in a way that the parser can understand and differentiate between IPv4, IPv6, AF_UNIX and AF_LLC is what I am thinking about. I am thinking something like where I also would prefer not to have to use the Support would need to be added in for DTLS and potentially TCP(Stream) and TLS. |
|
Thanks for taking a look!
Your suggestion looks pretty clean, I like it. Trying to figure out URIs for this was the most time-consuming. :)
Aye. Switching back to draft, will change the address handling and then look at additional protocol support. |
867dcfa to
f44f6d2
Compare
|
DTLS and TCP works, didn’t test TLS, but nothing should prevent that from working as well. One caveat: I believe that one is a kernel bug, so I proposed a fix: https://lore.kernel.org/netdev/20260415063457.1008868-1-ernestas.k@iconn-networks.com/T/ Example use (of course, substitute own interface addresses):
|
|
Thanks for doing this.
Server man pages (and usage()) need updating for
Need to do a LLC check here I guess. |
|
Also wondering whether |
IMO, it would be somewhat unusual to use decimal numbers in this case. |
725721f to
ca1a8dc
Compare
Done, pending decision re hex vs decimal notation.
Updated man pages and added address examples for server under
Done, hopefully I’m not wrong about the kernel issue and that will resolve itself eventually. |
mrdeep1
left a comment
There was a problem hiding this comment.
In general looking good.
In your environment what is the SAP you are using?
| #define COAP_SOCKET_CAN_CONNECT 0x0800 /**< non blocking client socket can now connect without blocking */ | ||
| #define COAP_SOCKET_MULTICAST 0x1000 /**< socket is used for multicast communication */ | ||
| #define COAP_SOCKET_SLAVE 0x2000 /**< socket is a slave socket - do not close */ | ||
| #define COAP_SOCKET_WANT_SENDTO 0x4000 /**< socket requires a destination address for sending */ |
There was a problem hiding this comment.
I do not believe that COAP_SOCKET_WANT_SENDTO is needed as COAP_SOCKET_CONNECTED is set when COAP_SOCKET_WANT_SENDTO is set.
There was a problem hiding this comment.
Perhaps the flag itself isn’t necessary, but sendmsg() without a destination address results in the local socket address being used:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/net/llc/af_llc.c?id=85cb0757d7e1f9370a8b52a8b8144c37941cba0a#n945
Notice how &llc->addr is used and not &llc->daddr:
if (addr) {
if (msg->msg_namelen < sizeof(*addr))
goto out;
} else {
if (llc_ui_addr_null(&llc->addr))
goto out;
addr = &llc->addr;
}Not sure if this behavior is intended, need to spend more time looking at the code, but some way to force using sendto() is needed. Otherwise, the client will just send messages to itself (Wireshark quickly revealed why nothing seemed to work).
There was a problem hiding this comment.
Yes, we need to keep this. However, it is required to not do a send(), but to do a sendmsg() or sendto() depending on whether HAVE_STRUCT_CMSGHDR is set or not circa line 680 in src/coap_dgrm_posix.c.
There was a problem hiding this comment.
Right, sorry, I use those three interchangably (since send() and sendto() are pretty much just wrappers for sendmsg(), at least on Linux). Indeed the goal is to avoid plain send() and go straight to sendmsg() with constructed header or sendto() with destination address.
Should I change anything here?
I see equal parts of |
|
We need to document a client example in |
Ah, that would be something to fix. AF_LLC sockets auto-bind to the first available interface if not bound explicitly. Requiring |
Useful in embedded contexts, where devices might only have a link-layer connection, but still need to exchange information.
|
Pushed a change to require |
Useful in embedded contexts, where devices might only have a link-layer connection, but still need to exchange information.