[riot-notifications] [RIOT-OS/RIOT] WIP net/ndp: make addr array ptr c++ compliant (#11299)

Martine Lenders notifications at github.com
Tue Sep 24 10:01:50 CEST 2019


To be more exact: there are some accesses of the `addrs` array also in this function:

https://github.com/RIOT-OS/RIOT/blob/1e6a070e4af8dc9c4116584b37648f75083ff251/sys/net/gnrc/network_layer/ipv6/nib/nib.c#L1350-L1406

Either we introduce an auxilary header there or we just use pointer arithmetics:

```
diff --git a/sys/net/gnrc/network_layer/ipv6/nib/nib.c b/sys/net/gnrc/network_layer/ipv6/nib/nib.c
index 793ad3ac50..9ac1ae4ed1 100644
--- a/sys/net/gnrc/network_layer/ipv6/nib/nib.c
+++ b/sys/net/gnrc/network_layer/ipv6/nib/nib.c
@@ -1362,14 +1362,14 @@ static uint32_t _handle_rdnsso(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
         return ltime;
     }
     /* select first if unassigned, search possible address otherwise */
-    addr = (sock_dns_server.port == 0) ? &rdnsso->addrs[0] : NULL;
+    addr = (sock_dns_server.port == 0) ? (ipv6_addr_t *)(rdnsso + 1) : NULL;
     if (addr == NULL) {
         unsigned addrs_num = (rdnsso->len - 1) / 2;
+        ipv6_addr_t addrs = (ipv6_addr_t *)(rdnsso + 1);
         for (unsigned i = 0; i < addrs_num; i++) {
-            if (memcmp(sock_dns_server.addr.ipv6,
-                       &rdnsso->addrs[i],
-                       sizeof(rdnsso->addrs[i])) == 0) {
-                addr = &rdnsso->addrs[i];
+            if (memcmp(sock_dns_server.addr.ipv6, addrs[i],
+                       sizeof(sock_dns_server.addr.ipv6)) == 0) {
+                addr = &addrs[i];
                 break;
             }
         }
@@ -1381,7 +1381,7 @@ static uint32_t _handle_rdnsso(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
             sock_dns_server.port = SOCK_DNS_PORT;
             sock_dns_server.family = AF_INET6;
             sock_dns_server.netif = netif->pid;
-            memcpy(sock_dns_server.addr.ipv6, rdnsso->addrs,
+            memcpy(sock_dns_server.addr.ipv6, (rdnsso + 1),
                    sizeof(sock_dns_server.addr.ipv6));
 
             if (ltime < UINT32_MAX) {
```

-- 
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/11299#issuecomment-534441574
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190924/03728252/attachment.htm>


More information about the notifications mailing list