xbee: add packet filtering to emulate non-transitive network.
When debugging multihop wireless network, it is useful to emulate non-transitive
network, that is, node A can communicate with B and B can communicate with C,
but A cannot communicate with C directly.
If `XBEE_DENIED_ADDRESSES`, which is an array of XBee long addresses, is
defined, packets from those addresses are dropped silently.
Example:
CFLAGS += "-DXBEE_DENIED_ADDRESSES={ 0x02, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0x02, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 }"
This commit is contained in:
parent
a6ae7c8091
commit
15ecee46ee
@ -731,6 +731,23 @@ static void _isr_event(gnrc_netdev_t *netdev, uint32_t event_type)
|
|||||||
addr_len = IEEE802154_LONG_ADDRESS_LEN;
|
addr_len = IEEE802154_LONG_ADDRESS_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef XBEE_DENIED_ADDRESSES
|
||||||
|
if (addr_len == 8) {
|
||||||
|
uint8_t denied_addresses[] = XBEE_DENIED_ADDRESSES;
|
||||||
|
for (size_t i = 0; i < sizeof(denied_addresses) / 8; i++) {
|
||||||
|
if (memcmp(&(dev->rx_buf[1]),
|
||||||
|
&denied_addresses[i * 8],
|
||||||
|
addr_len) == 0) {
|
||||||
|
dev->rx_count = 0;
|
||||||
|
|
||||||
|
DEBUG("xbee: dropping denied packet\n");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* check checksum for correctness */
|
/* check checksum for correctness */
|
||||||
for (int i = 0; i < dev->rx_limit; i++) {
|
for (int i = 0; i < dev->rx_limit; i++) {
|
||||||
cksum += dev->rx_buf[i];
|
cksum += dev->rx_buf[i];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user