Browse Source

net/gnrc/802154: enable filtering of L2 addresses

master
Hauke Petersen 5 years ago
parent
commit
145e4761c1
  1. 15
      drivers/netdev_ieee802154/netdev_ieee802154.c
  2. 13
      sys/net/gnrc/link_layer/netdev/gnrc_netdev_ieee802154.c

15
drivers/netdev_ieee802154/netdev_ieee802154.c

@ -125,6 +125,13 @@ int netdev_ieee802154_get(netdev_ieee802154_t *dev, netopt_t opt, void *value,
*((netstats_t **)value) = &dev->netdev.stats;
res = sizeof(uintptr_t);
break;
#endif
#ifdef MODULE_L2FILTER
case NETOPT_L2FILTER:
assert(max_len >= sizeof(l2filter_t **));
*((l2filter_t **)value) = dev->netdev.filter;
res = sizeof(l2filter_t **);
break;
#endif
default:
break;
@ -207,6 +214,14 @@ int netdev_ieee802154_set(netdev_ieee802154_t *dev, netopt_t opt, void *value,
dev->proto = *((gnrc_nettype_t *)value);
res = sizeof(gnrc_nettype_t);
break;
#endif
#ifdef MODULE_L2FILTER
case NETOPT_L2FILTER:
res = l2filter_add(dev->netdev.filter, value, len);
break;
case NETOPT_L2FILTER_RM:
res = l2filter_rm(dev->netdev.filter, value, len);
break;
#endif
default:
break;

13
sys/net/gnrc/link_layer/netdev/gnrc_netdev_ieee802154.c

@ -16,6 +16,7 @@
#include <stddef.h>
#include "od.h"
#include "net/l2filter.h"
#include "net/gnrc.h"
#include "net/ieee802154.h"
@ -112,7 +113,19 @@ static gnrc_pktsnip_t *_recv(gnrc_netdev_t *gnrc_netdev)
gnrc_pktbuf_release(pkt);
return NULL;
}
hdr = netif_hdr->data;
#ifdef MODULE_L2FILTER
if (!l2filter_pass(netdev->filter, gnrc_netif_hdr_get_src_addr(hdr),
hdr->src_l2addr_len)) {
gnrc_pktbuf_release(pkt);
gnrc_pktbuf_release(netif_hdr);
DEBUG("_recv_ieee802154: packet dropped by l2filter\n");
return NULL;
}
#endif
hdr->lqi = rx_info.lqi;
hdr->rssi = rx_info.rssi;
hdr->if_pid = thread_getpid();

Loading…
Cancel
Save