Skip to content

Commit

Permalink
xbee: add packet filtering to emulate non-transitive network.
Browse files Browse the repository at this point in the history
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 }"
  • Loading branch information
Yonezawa-T2 committed Dec 9, 2015
1 parent a696e48 commit d5aed5a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions drivers/xbee/xbee.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,23 @@ static void _isr_event(gnrc_netdev_t *netdev, uint32_t event_type)
addr_len = 8;
}

#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 */
for (int i = 0; i < dev->rx_limit; i++) {
cksum += dev->rx_buf[i];
Expand Down

0 comments on commit d5aed5a

Please sign in to comment.