aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Aring <aar@pengutronix.de>2016-04-11 05:04:15 -0400
committerMarcel Holtmann <marcel@holtmann.org>2016-04-13 04:41:08 -0400
commit118a5cf8ae236cdfa1eb4f21530843a8494722ef (patch)
treef7d743055aa6fb4e20ae88eaff4b372009a9e081
parentb7594148c73cb506487b5f00a6574beceea0e3a0 (diff)
ieee802154: add short address helpers
This patch introduce some short address handling functionality into ieee802154 headers. Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com> Signed-off-by: Alexander Aring <aar@pengutronix.de> Acked-by: Jukka Rissanen <jukka.rissanen@linux.intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--include/linux/ieee802154.h29
-rw-r--r--include/net/mac802154.h10
2 files changed, 39 insertions, 0 deletions
diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
index 9d84a924b747..acedbb68a5a3 100644
--- a/include/linux/ieee802154.h
+++ b/include/linux/ieee802154.h
@@ -47,6 +47,7 @@
47#define IEEE802154_ADDR_SHORT_UNSPEC 0xfffe 47#define IEEE802154_ADDR_SHORT_UNSPEC 0xfffe
48 48
49#define IEEE802154_EXTENDED_ADDR_LEN 8 49#define IEEE802154_EXTENDED_ADDR_LEN 8
50#define IEEE802154_SHORT_ADDR_LEN 2
50 51
51#define IEEE802154_LIFS_PERIOD 40 52#define IEEE802154_LIFS_PERIOD 40
52#define IEEE802154_SIFS_PERIOD 12 53#define IEEE802154_SIFS_PERIOD 12
@@ -290,6 +291,34 @@ static inline bool ieee802154_is_valid_extended_unicast_addr(__le64 addr)
290} 291}
291 292
292/** 293/**
294 * ieee802154_is_broadcast_short_addr - check if short addr is broadcast
295 * @addr: short addr to check
296 */
297static inline bool ieee802154_is_broadcast_short_addr(__le16 addr)
298{
299 return (addr == cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST));
300}
301
302/**
303 * ieee802154_is_unspec_short_addr - check if short addr is unspecified
304 * @addr: short addr to check
305 */
306static inline bool ieee802154_is_unspec_short_addr(__le16 addr)
307{
308 return (addr == cpu_to_le16(IEEE802154_ADDR_SHORT_UNSPEC));
309}
310
311/**
312 * ieee802154_is_valid_src_short_addr - check if source short address is valid
313 * @addr: short addr to check
314 */
315static inline bool ieee802154_is_valid_src_short_addr(__le16 addr)
316{
317 return !(ieee802154_is_broadcast_short_addr(addr) ||
318 ieee802154_is_unspec_short_addr(addr));
319}
320
321/**
293 * ieee802154_random_extended_addr - generates a random extended address 322 * ieee802154_random_extended_addr - generates a random extended address
294 * @addr: extended addr pointer to place the random address 323 * @addr: extended addr pointer to place the random address
295 */ 324 */
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index 6cd7a70706a9..e465c8551ac3 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -288,6 +288,16 @@ static inline void ieee802154_le16_to_be16(void *be16_dst, const void *le16_src)
288} 288}
289 289
290/** 290/**
291 * ieee802154_be16_to_le16 - copies and convert be16 to le16
292 * @le16_dst: le16 destination pointer
293 * @be16_src: be16 source pointer
294 */
295static inline void ieee802154_be16_to_le16(void *le16_dst, const void *be16_src)
296{
297 put_unaligned_le16(get_unaligned_be16(be16_src), le16_dst);
298}
299
300/**
291 * ieee802154_alloc_hw - Allocate a new hardware device 301 * ieee802154_alloc_hw - Allocate a new hardware device
292 * 302 *
293 * This must be called once for each hardware device. The returned pointer 303 * This must be called once for each hardware device. The returned pointer