ieee802154_netdev.h (376b7bd3558eaf12d3e5c24aa71d0c162d2701fd) | ieee802154_netdev.h (46ef0eb3ea65e7043aac17cb92982be879c65366) |
---|---|
1/* 2 * An interface between IEEE802.15.4 device and rest of the kernel. 3 * 4 * Copyright (C) 2007-2012 Siemens AG 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 8 * as published by the Free Software Foundation. --- 15 unchanged lines hidden (view full) --- 24 * Alexander Smirnov <alex.bluesman.smirnov@gmail.com> 25 */ 26 27#ifndef IEEE802154_NETDEVICE_H 28#define IEEE802154_NETDEVICE_H 29 30#include <net/af_ieee802154.h> 31 | 1/* 2 * An interface between IEEE802.15.4 device and rest of the kernel. 3 * 4 * Copyright (C) 2007-2012 Siemens AG 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 8 * as published by the Free Software Foundation. --- 15 unchanged lines hidden (view full) --- 24 * Alexander Smirnov <alex.bluesman.smirnov@gmail.com> 25 */ 26 27#ifndef IEEE802154_NETDEVICE_H 28#define IEEE802154_NETDEVICE_H 29 30#include <net/af_ieee802154.h> 31 |
32struct ieee802154_addr { 33 u8 mode; 34 __le16 pan_id; 35 union { 36 __le16 short_addr; 37 __le64 extended_addr; 38 }; 39}; 40 41static inline bool ieee802154_addr_equal(const struct ieee802154_addr *a1, 42 const struct ieee802154_addr *a2) 43{ 44 if (a1->pan_id != a2->pan_id || a1->mode != a2->mode) 45 return false; 46 47 if ((a1->mode == IEEE802154_ADDR_LONG && 48 a1->extended_addr != a2->extended_addr) || 49 (a1->mode == IEEE802154_ADDR_SHORT && 50 a1->short_addr != a2->short_addr)) 51 return false; 52 53 return true; 54} 55 56static inline __le64 ieee802154_devaddr_from_raw(const void *raw) 57{ 58 u64 temp; 59 60 memcpy(&temp, raw, IEEE802154_ADDR_LEN); 61 return (__force __le64)swab64(temp); 62} 63 64static inline void ieee802154_devaddr_to_raw(void *raw, __le64 addr) 65{ 66 u64 temp = swab64((__force u64)addr); 67 68 memcpy(raw, &temp, IEEE802154_ADDR_LEN); 69} 70 71static inline void ieee802154_addr_from_sa(struct ieee802154_addr *a, 72 const struct ieee802154_addr_sa *sa) 73{ 74 a->mode = sa->addr_type; 75 a->pan_id = cpu_to_le16(sa->pan_id); 76 77 switch (a->mode) { 78 case IEEE802154_ADDR_SHORT: 79 a->short_addr = cpu_to_le16(sa->short_addr); 80 break; 81 case IEEE802154_ADDR_LONG: 82 a->extended_addr = ieee802154_devaddr_from_raw(sa->hwaddr); 83 break; 84 } 85} 86 87static inline void ieee802154_addr_to_sa(struct ieee802154_addr_sa *sa, 88 const struct ieee802154_addr *a) 89{ 90 sa->addr_type = a->mode; 91 sa->pan_id = le16_to_cpu(a->pan_id); 92 93 switch (a->mode) { 94 case IEEE802154_ADDR_SHORT: 95 sa->short_addr = le16_to_cpu(a->short_addr); 96 break; 97 case IEEE802154_ADDR_LONG: 98 ieee802154_devaddr_to_raw(sa->hwaddr, a->extended_addr); 99 break; 100 } 101} 102 103 |
|
32struct ieee802154_frag_info { 33 __be16 d_tag; 34 u16 d_size; 35 u8 d_offset; 36}; 37 38/* 39 * A control block of skb passed between the ARPHRD_IEEE802154 device --- 109 unchanged lines hidden --- | 104struct ieee802154_frag_info { 105 __be16 d_tag; 106 u16 d_size; 107 u8 d_offset; 108}; 109 110/* 111 * A control block of skb passed between the ARPHRD_IEEE802154 device --- 109 unchanged lines hidden --- |