[riot-notifications] [RIOT-OS/RIOT] gnrc_netif: centralize device-type-specific functions (#10524)

Marian Buschsieweke notifications at github.com
Fri Jan 4 12:30:02 CET 2019


maribu commented on this pull request.

I will hopefully find time to test on `cc110x` on Monday

> @@ -466,10 +492,41 @@ int gnrc_netif_ipv6_iid_from_addr(const gnrc_netif_t *netif,
  */
 int gnrc_netif_ipv6_iid_to_addr(const gnrc_netif_t *netif, const eui64_t *iid,
                                 uint8_t *addr);
+
+/**
+ * @brief   Derives the length link-layer address in an NDP link-layer address
+ *          option from that option's length field and the given device type.

There seems to be something missing in the sentence. Maybe "Derives the length **of** **the** link-layer address [...]"?

>  #include "net/ieee802154.h"
 
+netopt_t gnrc_netif_get_l2addr_opt(gnrc_netif_t *netif)
+{
+    netopt_t res = NETOPT_ADDRESS;
+
+    switch (netif->device_type) {
+#if defined(MODULE_NETDEV_IEEE802154) || defined(MODULE_XBEE) || \
+    defined(MODULE_NORDIC_SOFTDEVICE_BLE)
+        case NETDEV_TYPE_IEEE802154:
+        case NETDEV_TYPE_BLE: {
+                netdev_t *dev = netif->dev;
+                uint16_t tmp;
+
+                res = dev->driver->get(dev, NETOPT_SRC_LEN, &tmp, sizeof(tmp));
+                assert(res == sizeof(tmp));
+                netif->l2addr_len = (uint8_t)tmp;

It's a bit paranoid, but maybe add `assert(tmp <= UINT8_MAX);` before the casting?

-- 
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/10524#pullrequestreview-189333276
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190104/dd6c8397/attachment.html>


More information about the notifications mailing list