ieee802154: rename struct ieee802154_addr to *_sa

The struct as currently defined uses host byte order for some fields,
and most big endian/EUI display byte order for other fields. Inside the
stack, endianness should ideally match network byte order where possible
to minimize the number of byteswaps done in critical paths, but this
patch does not address this; it is only preparatory.

Signed-off-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Phoebe Buckheister 2014-03-14 21:23:57 +01:00 committed by David S. Miller
parent 177943260a
commit 376b7bd355
13 changed files with 49 additions and 48 deletions

View File

@ -119,7 +119,7 @@ static u8 fake_get_dsn(const struct net_device *dev)
* 802.15.4-2006 document. * 802.15.4-2006 document.
*/ */
static int fake_assoc_req(struct net_device *dev, static int fake_assoc_req(struct net_device *dev,
struct ieee802154_addr *addr, u8 channel, u8 page, u8 cap) struct ieee802154_addr_sa *addr, u8 channel, u8 page, u8 cap)
{ {
struct wpan_phy *phy = fake_to_phy(dev); struct wpan_phy *phy = fake_to_phy(dev);
@ -149,7 +149,7 @@ static int fake_assoc_req(struct net_device *dev,
* 802.15.4-2006 document. * 802.15.4-2006 document.
*/ */
static int fake_assoc_resp(struct net_device *dev, static int fake_assoc_resp(struct net_device *dev,
struct ieee802154_addr *addr, u16 short_addr, u8 status) struct ieee802154_addr_sa *addr, u16 short_addr, u8 status)
{ {
return 0; return 0;
} }
@ -167,7 +167,7 @@ static int fake_assoc_resp(struct net_device *dev,
* document, with the reason described in 7.3.3.2. * document, with the reason described in 7.3.3.2.
*/ */
static int fake_disassoc_req(struct net_device *dev, static int fake_disassoc_req(struct net_device *dev,
struct ieee802154_addr *addr, u8 reason) struct ieee802154_addr_sa *addr, u8 reason)
{ {
return ieee802154_nl_disassoc_confirm(dev, IEEE802154_SUCCESS); return ieee802154_nl_disassoc_confirm(dev, IEEE802154_SUCCESS);
} }
@ -191,10 +191,10 @@ static int fake_disassoc_req(struct net_device *dev,
* Note: This is in section 7.5.2.3 of the IEEE 802.15.4-2006 * Note: This is in section 7.5.2.3 of the IEEE 802.15.4-2006
* document, with 7.3.8 describing coordinator realignment. * document, with 7.3.8 describing coordinator realignment.
*/ */
static int fake_start_req(struct net_device *dev, struct ieee802154_addr *addr, static int fake_start_req(struct net_device *dev,
u8 channel, u8 page, struct ieee802154_addr_sa *addr, u8 channel, u8 page,
u8 bcn_ord, u8 sf_ord, u8 pan_coord, u8 blx, u8 bcn_ord, u8 sf_ord, u8 pan_coord, u8 blx,
u8 coord_realign) u8 coord_realign)
{ {
struct wpan_phy *phy = fake_to_phy(dev); struct wpan_phy *phy = fake_to_phy(dev);

View File

@ -36,7 +36,7 @@ enum {
/* address length, octets */ /* address length, octets */
#define IEEE802154_ADDR_LEN 8 #define IEEE802154_ADDR_LEN 8
struct ieee802154_addr { struct ieee802154_addr_sa {
int addr_type; int addr_type;
u16 pan_id; u16 pan_id;
union { union {
@ -51,7 +51,7 @@ struct ieee802154_addr {
struct sockaddr_ieee802154 { struct sockaddr_ieee802154 {
sa_family_t family; /* AF_IEEE802154 */ sa_family_t family; /* AF_IEEE802154 */
struct ieee802154_addr addr; struct ieee802154_addr_sa addr;
}; };
/* get/setsockopt */ /* get/setsockopt */

View File

@ -41,8 +41,8 @@ struct ieee802154_frag_info {
*/ */
struct ieee802154_mac_cb { struct ieee802154_mac_cb {
u8 lqi; u8 lqi;
struct ieee802154_addr sa; struct ieee802154_addr_sa sa;
struct ieee802154_addr da; struct ieee802154_addr_sa da;
u8 flags; u8 flags;
u8 seq; u8 seq;
struct ieee802154_frag_info frag_info; struct ieee802154_frag_info frag_info;
@ -95,16 +95,16 @@ struct ieee802154_mlme_ops {
/* The following fields are optional (can be NULL). */ /* The following fields are optional (can be NULL). */
int (*assoc_req)(struct net_device *dev, int (*assoc_req)(struct net_device *dev,
struct ieee802154_addr *addr, struct ieee802154_addr_sa *addr,
u8 channel, u8 page, u8 cap); u8 channel, u8 page, u8 cap);
int (*assoc_resp)(struct net_device *dev, int (*assoc_resp)(struct net_device *dev,
struct ieee802154_addr *addr, struct ieee802154_addr_sa *addr,
u16 short_addr, u8 status); u16 short_addr, u8 status);
int (*disassoc_req)(struct net_device *dev, int (*disassoc_req)(struct net_device *dev,
struct ieee802154_addr *addr, struct ieee802154_addr_sa *addr,
u8 reason); u8 reason);
int (*start_req)(struct net_device *dev, int (*start_req)(struct net_device *dev,
struct ieee802154_addr *addr, struct ieee802154_addr_sa *addr,
u8 channel, u8 page, u8 bcn_ord, u8 sf_ord, u8 channel, u8 page, u8 bcn_ord, u8 sf_ord,
u8 pan_coord, u8 blx, u8 coord_realign); u8 pan_coord, u8 blx, u8 coord_realign);
int (*scan_req)(struct net_device *dev, int (*scan_req)(struct net_device *dev,

View File

@ -22,7 +22,7 @@
#define IEEE802154_NL_H #define IEEE802154_NL_H
struct net_device; struct net_device;
struct ieee802154_addr; struct ieee802154_addr_sa;
/** /**
* ieee802154_nl_assoc_indic - Notify userland of an association request. * ieee802154_nl_assoc_indic - Notify userland of an association request.
@ -37,7 +37,7 @@ struct ieee802154_addr;
* Note: This is in section 7.3.1 of the IEEE 802.15.4-2006 document. * Note: This is in section 7.3.1 of the IEEE 802.15.4-2006 document.
*/ */
int ieee802154_nl_assoc_indic(struct net_device *dev, int ieee802154_nl_assoc_indic(struct net_device *dev,
struct ieee802154_addr *addr, u8 cap); struct ieee802154_addr_sa *addr, u8 cap);
/** /**
* ieee802154_nl_assoc_confirm - Notify userland of association. * ieee802154_nl_assoc_confirm - Notify userland of association.
@ -65,7 +65,7 @@ int ieee802154_nl_assoc_confirm(struct net_device *dev,
* Note: This is in section 7.3.3 of the IEEE 802.15.4 document. * Note: This is in section 7.3.3 of the IEEE 802.15.4 document.
*/ */
int ieee802154_nl_disassoc_indic(struct net_device *dev, int ieee802154_nl_disassoc_indic(struct net_device *dev,
struct ieee802154_addr *addr, u8 reason); struct ieee802154_addr_sa *addr, u8 reason);
/** /**
* ieee802154_nl_disassoc_confirm - Notify userland of disassociation * ieee802154_nl_disassoc_confirm - Notify userland of disassociation

View File

@ -91,7 +91,7 @@ static int lowpan_header_create(struct sk_buff *skb,
{ {
const u8 *saddr = _saddr; const u8 *saddr = _saddr;
const u8 *daddr = _daddr; const u8 *daddr = _daddr;
struct ieee802154_addr sa, da; struct ieee802154_addr_sa sa, da;
/* TODO: /* TODO:
* if this package isn't ipv6 one, where should it be routed? * if this package isn't ipv6 one, where should it be routed?
@ -171,7 +171,7 @@ static int lowpan_give_skb_to_devices(struct sk_buff *skb,
static int process_data(struct sk_buff *skb) static int process_data(struct sk_buff *skb)
{ {
u8 iphc0, iphc1; u8 iphc0, iphc1;
const struct ieee802154_addr *_saddr, *_daddr; const struct ieee802154_addr_sa *_saddr, *_daddr;
raw_dump_table(__func__, "raw skb data dump", skb->data, skb->len); raw_dump_table(__func__, "raw skb data dump", skb->data, skb->len);
/* at least two bytes will be used for the encoding */ /* at least two bytes will be used for the encoding */

View File

@ -31,6 +31,6 @@ extern struct proto ieee802154_dgram_prot;
void ieee802154_raw_deliver(struct net_device *dev, struct sk_buff *skb); void ieee802154_raw_deliver(struct net_device *dev, struct sk_buff *skb);
int ieee802154_dgram_deliver(struct net_device *dev, struct sk_buff *skb); int ieee802154_dgram_deliver(struct net_device *dev, struct sk_buff *skb);
struct net_device *ieee802154_get_dev(struct net *net, struct net_device *ieee802154_get_dev(struct net *net,
struct ieee802154_addr *addr); struct ieee802154_addr_sa *addr);
#endif #endif

View File

@ -44,7 +44,7 @@
* Utility function for families * Utility function for families
*/ */
struct net_device *ieee802154_get_dev(struct net *net, struct net_device *ieee802154_get_dev(struct net *net,
struct ieee802154_addr *addr) struct ieee802154_addr_sa *addr)
{ {
struct net_device *dev = NULL; struct net_device *dev = NULL;
struct net_device *tmp; struct net_device *tmp;

View File

@ -41,8 +41,8 @@ static DEFINE_RWLOCK(dgram_lock);
struct dgram_sock { struct dgram_sock {
struct sock sk; struct sock sk;
struct ieee802154_addr src_addr; struct ieee802154_addr_sa src_addr;
struct ieee802154_addr dst_addr; struct ieee802154_addr_sa dst_addr;
unsigned int bound:1; unsigned int bound:1;
unsigned int want_ack:1; unsigned int want_ack:1;
@ -113,7 +113,7 @@ static int dgram_bind(struct sock *sk, struct sockaddr *uaddr, int len)
goto out_put; goto out_put;
} }
memcpy(&ro->src_addr, &addr->addr, sizeof(struct ieee802154_addr)); memcpy(&ro->src_addr, &addr->addr, sizeof(struct ieee802154_addr_sa));
ro->bound = 1; ro->bound = 1;
err = 0; err = 0;
@ -181,7 +181,7 @@ static int dgram_connect(struct sock *sk, struct sockaddr *uaddr,
goto out; goto out;
} }
memcpy(&ro->dst_addr, &addr->addr, sizeof(struct ieee802154_addr)); memcpy(&ro->dst_addr, &addr->addr, sizeof(struct ieee802154_addr_sa));
out: out:
release_sock(sk); release_sock(sk);

View File

@ -40,7 +40,7 @@
#include "ieee802154.h" #include "ieee802154.h"
int ieee802154_nl_assoc_indic(struct net_device *dev, int ieee802154_nl_assoc_indic(struct net_device *dev,
struct ieee802154_addr *addr, u8 cap) struct ieee802154_addr_sa *addr, u8 cap)
{ {
struct sk_buff *msg; struct sk_buff *msg;
@ -99,7 +99,7 @@ nla_put_failure:
EXPORT_SYMBOL(ieee802154_nl_assoc_confirm); EXPORT_SYMBOL(ieee802154_nl_assoc_confirm);
int ieee802154_nl_disassoc_indic(struct net_device *dev, int ieee802154_nl_disassoc_indic(struct net_device *dev,
struct ieee802154_addr *addr, u8 reason) struct ieee802154_addr_sa *addr, u8 reason)
{ {
struct sk_buff *msg; struct sk_buff *msg;
@ -304,7 +304,7 @@ static struct net_device *ieee802154_nl_get_dev(struct genl_info *info)
int ieee802154_associate_req(struct sk_buff *skb, struct genl_info *info) int ieee802154_associate_req(struct sk_buff *skb, struct genl_info *info)
{ {
struct net_device *dev; struct net_device *dev;
struct ieee802154_addr addr; struct ieee802154_addr_sa addr;
u8 page; u8 page;
int ret = -EOPNOTSUPP; int ret = -EOPNOTSUPP;
@ -351,7 +351,7 @@ out:
int ieee802154_associate_resp(struct sk_buff *skb, struct genl_info *info) int ieee802154_associate_resp(struct sk_buff *skb, struct genl_info *info)
{ {
struct net_device *dev; struct net_device *dev;
struct ieee802154_addr addr; struct ieee802154_addr_sa addr;
int ret = -EOPNOTSUPP; int ret = -EOPNOTSUPP;
if (!info->attrs[IEEE802154_ATTR_STATUS] || if (!info->attrs[IEEE802154_ATTR_STATUS] ||
@ -383,7 +383,7 @@ out:
int ieee802154_disassociate_req(struct sk_buff *skb, struct genl_info *info) int ieee802154_disassociate_req(struct sk_buff *skb, struct genl_info *info)
{ {
struct net_device *dev; struct net_device *dev;
struct ieee802154_addr addr; struct ieee802154_addr_sa addr;
int ret = -EOPNOTSUPP; int ret = -EOPNOTSUPP;
if ((!info->attrs[IEEE802154_ATTR_DEST_HW_ADDR] && if ((!info->attrs[IEEE802154_ATTR_DEST_HW_ADDR] &&
@ -425,7 +425,7 @@ out:
int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info) int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info)
{ {
struct net_device *dev; struct net_device *dev;
struct ieee802154_addr addr; struct ieee802154_addr_sa addr;
u8 channel, bcn_ord, sf_ord; u8 channel, bcn_ord, sf_ord;
u8 page; u8 page;

View File

@ -36,8 +36,8 @@ static int lowpan_frag_reasm(struct lowpan_frag_queue *fq,
struct sk_buff *prev, struct net_device *dev); struct sk_buff *prev, struct net_device *dev);
static unsigned int lowpan_hash_frag(__be16 tag, u16 d_size, static unsigned int lowpan_hash_frag(__be16 tag, u16 d_size,
const struct ieee802154_addr *saddr, const struct ieee802154_addr_sa *saddr,
const struct ieee802154_addr *daddr) const struct ieee802154_addr_sa *daddr)
{ {
u32 c; u32 c;
@ -103,7 +103,7 @@ out:
static inline struct lowpan_frag_queue * static inline struct lowpan_frag_queue *
fq_find(struct net *net, const struct ieee802154_frag_info *frag_info, fq_find(struct net *net, const struct ieee802154_frag_info *frag_info,
const struct ieee802154_addr *src, const struct ieee802154_addr *dst) const struct ieee802154_addr_sa *src, const struct ieee802154_addr_sa *dst)
{ {
struct inet_frag_queue *q; struct inet_frag_queue *q;
struct lowpan_create_arg arg; struct lowpan_create_arg arg;

View File

@ -6,8 +6,8 @@
struct lowpan_create_arg { struct lowpan_create_arg {
__be16 tag; __be16 tag;
u16 d_size; u16 d_size;
const struct ieee802154_addr *src; const struct ieee802154_addr_sa *src;
const struct ieee802154_addr *dst; const struct ieee802154_addr_sa *dst;
}; };
/* Equivalent of ipv4 struct ip /* Equivalent of ipv4 struct ip
@ -17,11 +17,11 @@ struct lowpan_frag_queue {
__be16 tag; __be16 tag;
u16 d_size; u16 d_size;
struct ieee802154_addr saddr; struct ieee802154_addr_sa saddr;
struct ieee802154_addr daddr; struct ieee802154_addr_sa daddr;
}; };
static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a) static inline u32 ieee802154_addr_hash(const struct ieee802154_addr_sa *a)
{ {
switch (a->addr_type) { switch (a->addr_type) {
case IEEE802154_ADDR_LONG: case IEEE802154_ADDR_LONG:
@ -34,8 +34,9 @@ static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a)
} }
} }
static inline bool ieee802154_addr_addr_equal(const struct ieee802154_addr *a1, static inline bool
const struct ieee802154_addr *a2) ieee802154_addr_addr_equal(const struct ieee802154_addr_sa *a1,
const struct ieee802154_addr_sa *a2)
{ {
if (a1->pan_id != a2->pan_id) if (a1->pan_id != a2->pan_id)
return false; return false;

View File

@ -34,7 +34,7 @@
#include "mac802154.h" #include "mac802154.h"
static int mac802154_mlme_start_req(struct net_device *dev, static int mac802154_mlme_start_req(struct net_device *dev,
struct ieee802154_addr *addr, struct ieee802154_addr_sa *addr,
u8 channel, u8 page, u8 channel, u8 page,
u8 bcn_ord, u8 sf_ord, u8 bcn_ord, u8 sf_ord,
u8 pan_coord, u8 blx, u8 pan_coord, u8 blx,

View File

@ -132,9 +132,9 @@ static int mac802154_header_create(struct sk_buff *skb,
const void *_saddr, const void *_saddr,
unsigned len) unsigned len)
{ {
const struct ieee802154_addr *saddr = _saddr; const struct ieee802154_addr_sa *saddr = _saddr;
const struct ieee802154_addr *daddr = _daddr; const struct ieee802154_addr_sa *daddr = _daddr;
struct ieee802154_addr dev_addr; struct ieee802154_addr_sa dev_addr;
struct mac802154_sub_if_data *priv = netdev_priv(dev); struct mac802154_sub_if_data *priv = netdev_priv(dev);
int pos = 2; int pos = 2;
u8 head[MAC802154_FRAME_HARD_HEADER_LEN]; u8 head[MAC802154_FRAME_HARD_HEADER_LEN];
@ -219,7 +219,7 @@ mac802154_header_parse(const struct sk_buff *skb, unsigned char *haddr)
{ {
const u8 *hdr = skb_mac_header(skb); const u8 *hdr = skb_mac_header(skb);
const u8 *tail = skb_tail_pointer(skb); const u8 *tail = skb_tail_pointer(skb);
struct ieee802154_addr *addr = (struct ieee802154_addr *)haddr; struct ieee802154_addr_sa *addr = (struct ieee802154_addr_sa *)haddr;
u16 fc; u16 fc;
int da_type; int da_type;
@ -304,7 +304,7 @@ mac802154_header_parse(const struct sk_buff *skb, unsigned char *haddr)
goto malformed; goto malformed;
} }
return sizeof(struct ieee802154_addr); return sizeof(struct ieee802154_addr_sa);
malformed: malformed:
pr_debug("malformed packet\n"); pr_debug("malformed packet\n");