Commit 118a5cf8 authored by Alexander Aring's avatar Alexander Aring Committed by Marcel Holtmann

ieee802154: add short address helpers

This patch introduce some short address handling functionality into
ieee802154 headers.
Reviewed-by: default avatarStefan Schmidt <stefan@osg.samsung.com>
Signed-off-by: default avatarAlexander Aring <aar@pengutronix.de>
Acked-by: default avatarJukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent b7594148
......@@ -47,6 +47,7 @@
#define IEEE802154_ADDR_SHORT_UNSPEC 0xfffe
#define IEEE802154_EXTENDED_ADDR_LEN 8
#define IEEE802154_SHORT_ADDR_LEN 2
#define IEEE802154_LIFS_PERIOD 40
#define IEEE802154_SIFS_PERIOD 12
......@@ -289,6 +290,34 @@ static inline bool ieee802154_is_valid_extended_unicast_addr(__le64 addr)
!(addr & cpu_to_le64(0x0100000000000000ULL)));
}
/**
* ieee802154_is_broadcast_short_addr - check if short addr is broadcast
* @addr: short addr to check
*/
static inline bool ieee802154_is_broadcast_short_addr(__le16 addr)
{
return (addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST));
}
/**
* ieee802154_is_unspec_short_addr - check if short addr is unspecified
* @addr: short addr to check
*/
static inline bool ieee802154_is_unspec_short_addr(__le16 addr)
{
return (addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC));
}
/**
* ieee802154_is_valid_src_short_addr - check if source short address is valid
* @addr: short addr to check
*/
static inline bool ieee802154_is_valid_src_short_addr(__le16 addr)
{
return !(ieee802154_is_broadcast_short_addr(addr) ||
ieee802154_is_unspec_short_addr(addr));
}
/**
* ieee802154_random_extended_addr - generates a random extended address
* @addr: extended addr pointer to place the random address
......
......@@ -287,6 +287,16 @@ static inline void ieee802154_le16_to_be16(void *be16_dst, const void *le16_src)
put_unaligned_be16(get_unaligned_le16(le16_src), be16_dst);
}
/**
* ieee802154_be16_to_le16 - copies and convert be16 to le16
* @le16_dst: le16 destination pointer
* @be16_src: be16 source pointer
*/
static inline void ieee802154_be16_to_le16(void *le16_dst, const void *be16_src)
{
put_unaligned_le16(get_unaligned_be16(be16_src), le16_dst);
}
/**
* ieee802154_alloc_hw - Allocate a new hardware device
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment