Skip to content
Snippets Groups Projects
Commit c2a40be4 authored by Semjon Kerner's avatar Semjon Kerner
Browse files

drivers/netdev_ieee802154: add mac header filter

parent e3e2b6df
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (C) 2016 Freie Universität Berlin
* Copyright (C) 2016-2019 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
......@@ -177,6 +177,21 @@ int netdev_ieee802154_get(netdev_ieee802154_t *dev, netopt_t opt, void *value,
int netdev_ieee802154_set(netdev_ieee802154_t *dev, netopt_t opt, const void *value,
size_t value_len);
/**
* @brief This funtion compares destination address and pan id with addresses
* and pan id of the device
*
* this funciton is meant top be used by drivers that do not support address
* filtering in hw
*
* @param[in] dev network device descriptor
* @param[in] mhr mac header
*
* @return 0 successfull if packet is for the device
* @return 1 fails if packet is not for the device or pan
*/
int netdev_ieee802154_dst_filter(netdev_ieee802154_t *dev, const uint8_t *mhr);
#ifdef __cplusplus
}
#endif
......
......@@ -253,4 +253,30 @@ int netdev_ieee802154_set(netdev_ieee802154_t *dev, netopt_t opt, const void *va
return res;
}
int netdev_ieee802154_dst_filter(netdev_ieee802154_t *dev, const uint8_t *mhr)
{
uint8_t dst_addr[IEEE802154_LONG_ADDRESS_LEN];
le_uint16_t dst_pan;
uint8_t pan_bcast[] = IEEE802154_PANID_BCAST;
int addr_len = ieee802154_get_dst(mhr, dst_addr, &dst_pan);
/* filter PAN ID */
if ((memcmp(pan_bcast, dst_pan.u8, 2) != 0) &&
(memcmp(&dev->pan, dst_pan.u8, 2) != 0)) {
return 1;
}
/* check destination address */
if (((addr_len == IEEE802154_SHORT_ADDRESS_LEN) &&
(memcmp(dev->short_addr, dst_addr, addr_len) == 0 ||
memcmp(ieee802154_addr_bcast, dst_addr, addr_len) == 0)) ||
((addr_len == IEEE802154_LONG_ADDRESS_LEN) &&
(memcmp(dev->long_addr, dst_addr, addr_len) == 0))) {
return 0;
}
return 1;
}
/** @} */
/*
* Copyright (C) 2015-16 Freie Universität Berlin
* Copyright (C) 2015-2019 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
......@@ -31,6 +31,11 @@
extern "C" {
#endif
/**
* @brief Default start frame delimiter
*/
#define IEEE802154_SFD (0xa7)
/**
* @brief IEEE 802.15.4 address lengths
* @{
......@@ -144,6 +149,13 @@ extern const uint8_t ieee802154_addr_bcast[IEEE802154_ADDR_BCAST_LEN];
#define IEEE802154_DEFAULT_PANID (0x0023U)
#endif
/**
* @brief IEEE802.15.4 Broadcast PANID
*/
#ifndef IEEE802154_PANID_BCAST
#define IEEE802154_PANID_BCAST { 0xff, 0xff }
#endif
/**
* @brief IEEE802.15.4 default TX power (in dBm)
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment