Skip to content

Commit

Permalink
cpu/nrf52/radio/nrf802154: fix beacon frame acceptance in _l2filter
Browse files Browse the repository at this point in the history
  • Loading branch information
lulu254b committed Nov 13, 2024
1 parent 4933563 commit 71d062b
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions cpu/nrf52/radio/nrf802154/nrf802154_radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,22 @@ static void _power_off(void)
static bool _l2filter(uint8_t *mhr)
{
uint8_t dst_addr[IEEE802154_LONG_ADDRESS_LEN];
uint8_t src_addr[IEEE802154_LONG_ADDRESS_LEN];
le_uint16_t dst_pan;
le_uint16_t src_pan;
uint8_t pan_bcast[] = IEEE802154_PANID_BCAST;

int addr_len = ieee802154_get_dst(mhr, dst_addr, &dst_pan);
int dst_addr_len = ieee802154_get_dst(mhr, dst_addr, &dst_pan);

int src_addr_len = ieee802154_get_src(mhr, src_addr, &src_pan);

if ((mhr[0] & IEEE802154_FCF_TYPE_MASK) == IEEE802154_FCF_TYPE_BEACON) {
if ((memcmp(&nrf802154_pan_id, pan_bcast, 2) == 0)) {
return true;
if(src_addr_len == IEEE802154_SHORT_ADDRESS_LEN ||

Check failure on line 132 in cpu/nrf52/radio/nrf802154/nrf802154_radio.c

View workflow job for this annotation

GitHub Actions / static-tests

trailing whitespace.

Check warning on line 132 in cpu/nrf52/radio/nrf802154/nrf802154_radio.c

View workflow job for this annotation

GitHub Actions / static-tests

keyword 'if' not followed by a single space

Check warning on line 132 in cpu/nrf52/radio/nrf802154/nrf802154_radio.c

View workflow job for this annotation

GitHub Actions / static-tests

trailing whitespace
src_addr_len == IEEE802154_LONG_ADDRESS_LEN){
if ((memcmp(&nrf802154_pan_id, src_pan.u8, 2) == 0) ||

Check failure on line 134 in cpu/nrf52/radio/nrf802154/nrf802154_radio.c

View workflow job for this annotation

GitHub Actions / static-tests

trailing whitespace.

Check warning on line 134 in cpu/nrf52/radio/nrf802154/nrf802154_radio.c

View workflow job for this annotation

GitHub Actions / static-tests

trailing whitespace
(memcmp(&nrf802154_pan_id, pan_bcast, 2) == 0)) {

Check failure on line 135 in cpu/nrf52/radio/nrf802154/nrf802154_radio.c

View workflow job for this annotation

GitHub Actions / static-tests

trailing whitespace.

Check warning on line 135 in cpu/nrf52/radio/nrf802154/nrf802154_radio.c

View workflow job for this annotation

GitHub Actions / static-tests

trailing whitespace
return true;
}
}
}
/* filter PAN ID */
Expand All @@ -138,11 +146,11 @@ static bool _l2filter(uint8_t *mhr)
}

/* check destination address */
if (((addr_len == IEEE802154_SHORT_ADDRESS_LEN) &&
(memcmp(nrf802154_short_addr, dst_addr, addr_len) == 0 ||
memcmp(ieee802154_addr_bcast, dst_addr, addr_len) == 0)) ||
((addr_len == IEEE802154_LONG_ADDRESS_LEN) &&
(memcmp(nrf802154_long_addr, dst_addr, addr_len) == 0))) {
if (((dst_addr_len == IEEE802154_SHORT_ADDRESS_LEN) &&
(memcmp(nrf802154_short_addr, dst_addr, dst_addr_len) == 0 ||
memcmp(ieee802154_addr_bcast, dst_addr, dst_addr_len) == 0)) ||
((dst_addr_len == IEEE802154_LONG_ADDRESS_LEN) &&
(memcmp(nrf802154_long_addr, dst_addr, dst_addr_len) == 0))) {
return true;
}

Expand Down

0 comments on commit 71d062b

Please sign in to comment.