[riot-notifications] [RIOT-OS/RIOT] gnrc_sock_tcp: add gnrc sock tcp (#16494)

Martine Lenders notifications at github.com
Fri Aug 6 16:31:43 CEST 2021


@miri64 commented on this pull request.



> +    return gnrc_tcp_get_local(tcb, local);
+}
+
+int sock_tcp_get_remote(sock_tcp_t *sock, sock_tcp_ep_t *ep)
+{
+    /* Asserts defined by API. */
+    assert(sock != NULL);
+    assert(ep != NULL);
+
+    /* Asserts to protect GNRC_TCP. */
+    assert(sizeof(sock_tcp_t) == sizeof(gnrc_tcp_tcb_t));
+    assert(sizeof(sock_tcp_ep_t) == sizeof(gnrc_tcp_ep_t));
+
+    /* NOTE: GNRC_TCP and GNRC_SOCK_TCP types must have the same memory representation. */
+    gnrc_tcp_tcb_t *tcb = (gnrc_tcp_tcb_t *) sock;
+    gnrc_tcp_ep_t *remote = (gnrc_tcp_ep_t *) ep;

To prevent casting, we could have a union inside `gnrc_tcp_ep_t` that maps it to `sock_tcp_ep_t` when `sock_tcp` is compiled in.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16494#discussion_r684281795
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210806/30cb7e6e/attachment.htm>


More information about the notifications mailing list