diff options
-rw-r--r-- | drivers/net/ieee802154/fakehard.c | 8 | ||||
-rw-r--r-- | include/net/ieee802154_netdev.h | 12 | ||||
-rw-r--r-- | include/net/nl802154.h | 6 | ||||
-rw-r--r-- | net/ieee802154/6lowpan_rtnl.c | 38 | ||||
-rw-r--r-- | net/ieee802154/dgram.c | 2 | ||||
-rw-r--r-- | net/ieee802154/nl-mac.c | 114 | ||||
-rw-r--r-- | net/ieee802154/reassembly.c | 17 | ||||
-rw-r--r-- | net/ieee802154/reassembly.h | 42 | ||||
-rw-r--r-- | net/mac802154/mac_cmd.c | 8 | ||||
-rw-r--r-- | net/mac802154/wpan.c | 35 |
10 files changed, 146 insertions, 136 deletions
diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c index 3c98030e0e0b..78f18be3bbf2 100644 --- a/drivers/net/ieee802154/fakehard.c +++ b/drivers/net/ieee802154/fakehard.c | |||
@@ -119,7 +119,7 @@ static u8 fake_get_dsn(const struct net_device *dev) | |||
119 | * 802.15.4-2006 document. | 119 | * 802.15.4-2006 document. |
120 | */ | 120 | */ |
121 | static int fake_assoc_req(struct net_device *dev, | 121 | static int fake_assoc_req(struct net_device *dev, |
122 | struct ieee802154_addr_sa *addr, u8 channel, u8 page, u8 cap) | 122 | struct ieee802154_addr *addr, u8 channel, u8 page, u8 cap) |
123 | { | 123 | { |
124 | struct wpan_phy *phy = fake_to_phy(dev); | 124 | struct wpan_phy *phy = fake_to_phy(dev); |
125 | 125 | ||
@@ -149,7 +149,7 @@ static int fake_assoc_req(struct net_device *dev, | |||
149 | * 802.15.4-2006 document. | 149 | * 802.15.4-2006 document. |
150 | */ | 150 | */ |
151 | static int fake_assoc_resp(struct net_device *dev, | 151 | static int fake_assoc_resp(struct net_device *dev, |
152 | struct ieee802154_addr_sa *addr, __le16 short_addr, u8 status) | 152 | struct ieee802154_addr *addr, __le16 short_addr, u8 status) |
153 | { | 153 | { |
154 | return 0; | 154 | return 0; |
155 | } | 155 | } |
@@ -167,7 +167,7 @@ static int fake_assoc_resp(struct net_device *dev, | |||
167 | * document, with the reason described in 7.3.3.2. | 167 | * document, with the reason described in 7.3.3.2. |
168 | */ | 168 | */ |
169 | static int fake_disassoc_req(struct net_device *dev, | 169 | static int fake_disassoc_req(struct net_device *dev, |
170 | struct ieee802154_addr_sa *addr, u8 reason) | 170 | struct ieee802154_addr *addr, u8 reason) |
171 | { | 171 | { |
172 | return ieee802154_nl_disassoc_confirm(dev, IEEE802154_SUCCESS); | 172 | return ieee802154_nl_disassoc_confirm(dev, IEEE802154_SUCCESS); |
173 | } | 173 | } |
@@ -192,7 +192,7 @@ static int fake_disassoc_req(struct net_device *dev, | |||
192 | * document, with 7.3.8 describing coordinator realignment. | 192 | * document, with 7.3.8 describing coordinator realignment. |
193 | */ | 193 | */ |
194 | static int fake_start_req(struct net_device *dev, | 194 | static int fake_start_req(struct net_device *dev, |
195 | struct ieee802154_addr_sa *addr, u8 channel, u8 page, | 195 | struct ieee802154_addr *addr, u8 channel, u8 page, |
196 | u8 bcn_ord, u8 sf_ord, u8 pan_coord, u8 blx, | 196 | u8 bcn_ord, u8 sf_ord, u8 pan_coord, u8 blx, |
197 | u8 coord_realign) | 197 | u8 coord_realign) |
198 | { | 198 | { |
diff --git a/include/net/ieee802154_netdev.h b/include/net/ieee802154_netdev.h index 8e7f6903db98..827e3e33c422 100644 --- a/include/net/ieee802154_netdev.h +++ b/include/net/ieee802154_netdev.h | |||
@@ -200,11 +200,11 @@ struct ieee802154_frag_info { | |||
200 | */ | 200 | */ |
201 | struct ieee802154_mac_cb { | 201 | struct ieee802154_mac_cb { |
202 | u8 lqi; | 202 | u8 lqi; |
203 | struct ieee802154_addr_sa sa; | ||
204 | struct ieee802154_addr_sa da; | ||
205 | u8 flags; | 203 | u8 flags; |
206 | u8 seq; | 204 | u8 seq; |
207 | struct ieee802154_frag_info frag_info; | 205 | struct ieee802154_frag_info frag_info; |
206 | struct ieee802154_addr source; | ||
207 | struct ieee802154_addr dest; | ||
208 | }; | 208 | }; |
209 | 209 | ||
210 | static inline struct ieee802154_mac_cb *mac_cb(struct sk_buff *skb) | 210 | static inline struct ieee802154_mac_cb *mac_cb(struct sk_buff *skb) |
@@ -248,16 +248,16 @@ struct ieee802154_mlme_ops { | |||
248 | /* The following fields are optional (can be NULL). */ | 248 | /* The following fields are optional (can be NULL). */ |
249 | 249 | ||
250 | int (*assoc_req)(struct net_device *dev, | 250 | int (*assoc_req)(struct net_device *dev, |
251 | struct ieee802154_addr_sa *addr, | 251 | struct ieee802154_addr *addr, |
252 | u8 channel, u8 page, u8 cap); | 252 | u8 channel, u8 page, u8 cap); |
253 | int (*assoc_resp)(struct net_device *dev, | 253 | int (*assoc_resp)(struct net_device *dev, |
254 | struct ieee802154_addr_sa *addr, | 254 | struct ieee802154_addr *addr, |
255 | __le16 short_addr, u8 status); | 255 | __le16 short_addr, u8 status); |
256 | int (*disassoc_req)(struct net_device *dev, | 256 | int (*disassoc_req)(struct net_device *dev, |
257 | struct ieee802154_addr_sa *addr, | 257 | struct ieee802154_addr *addr, |
258 | u8 reason); | 258 | u8 reason); |
259 | int (*start_req)(struct net_device *dev, | 259 | int (*start_req)(struct net_device *dev, |
260 | struct ieee802154_addr_sa *addr, | 260 | struct ieee802154_addr *addr, |
261 | u8 channel, u8 page, u8 bcn_ord, u8 sf_ord, | 261 | u8 channel, u8 page, u8 bcn_ord, u8 sf_ord, |
262 | u8 pan_coord, u8 blx, u8 coord_realign); | 262 | u8 pan_coord, u8 blx, u8 coord_realign); |
263 | int (*scan_req)(struct net_device *dev, | 263 | int (*scan_req)(struct net_device *dev, |
diff --git a/include/net/nl802154.h b/include/net/nl802154.h index 3121ed047c1e..b23548e04098 100644 --- a/include/net/nl802154.h +++ b/include/net/nl802154.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #define IEEE802154_NL_H | 22 | #define IEEE802154_NL_H |
23 | 23 | ||
24 | struct net_device; | 24 | struct net_device; |
25 | struct ieee802154_addr_sa; | 25 | struct ieee802154_addr; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * ieee802154_nl_assoc_indic - Notify userland of an association request. | 28 | * ieee802154_nl_assoc_indic - Notify userland of an association request. |
@@ -37,7 +37,7 @@ struct ieee802154_addr_sa; | |||
37 | * Note: This is in section 7.3.1 of the IEEE 802.15.4-2006 document. | 37 | * Note: This is in section 7.3.1 of the IEEE 802.15.4-2006 document. |
38 | */ | 38 | */ |
39 | int ieee802154_nl_assoc_indic(struct net_device *dev, | 39 | int ieee802154_nl_assoc_indic(struct net_device *dev, |
40 | struct ieee802154_addr_sa *addr, u8 cap); | 40 | struct ieee802154_addr *addr, u8 cap); |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * ieee802154_nl_assoc_confirm - Notify userland of association. | 43 | * ieee802154_nl_assoc_confirm - Notify userland of association. |
@@ -65,7 +65,7 @@ int ieee802154_nl_assoc_confirm(struct net_device *dev, | |||
65 | * Note: This is in section 7.3.3 of the IEEE 802.15.4 document. | 65 | * Note: This is in section 7.3.3 of the IEEE 802.15.4 document. |
66 | */ | 66 | */ |
67 | int ieee802154_nl_disassoc_indic(struct net_device *dev, | 67 | int ieee802154_nl_disassoc_indic(struct net_device *dev, |
68 | struct ieee802154_addr_sa *addr, u8 reason); | 68 | struct ieee802154_addr *addr, u8 reason); |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * ieee802154_nl_disassoc_confirm - Notify userland of disassociation | 71 | * ieee802154_nl_disassoc_confirm - Notify userland of disassociation |
diff --git a/net/ieee802154/6lowpan_rtnl.c b/net/ieee802154/6lowpan_rtnl.c index 678564c7718b..d4edd20dab5f 100644 --- a/net/ieee802154/6lowpan_rtnl.c +++ b/net/ieee802154/6lowpan_rtnl.c | |||
@@ -168,10 +168,11 @@ static int lowpan_give_skb_to_devices(struct sk_buff *skb, | |||
168 | return stat; | 168 | return stat; |
169 | } | 169 | } |
170 | 170 | ||
171 | static int process_data(struct sk_buff *skb) | 171 | static int process_data(struct sk_buff *skb, const struct ieee802154_hdr *hdr) |
172 | { | 172 | { |
173 | u8 iphc0, iphc1; | 173 | u8 iphc0, iphc1; |
174 | const struct ieee802154_addr_sa *_saddr, *_daddr; | 174 | struct ieee802154_addr_sa sa, da; |
175 | void *sap, *dap; | ||
175 | 176 | ||
176 | raw_dump_table(__func__, "raw skb data dump", skb->data, skb->len); | 177 | raw_dump_table(__func__, "raw skb data dump", skb->data, skb->len); |
177 | /* at least two bytes will be used for the encoding */ | 178 | /* at least two bytes will be used for the encoding */ |
@@ -184,14 +185,23 @@ static int process_data(struct sk_buff *skb) | |||
184 | if (lowpan_fetch_skb_u8(skb, &iphc1)) | 185 | if (lowpan_fetch_skb_u8(skb, &iphc1)) |
185 | goto drop; | 186 | goto drop; |
186 | 187 | ||
187 | _saddr = &mac_cb(skb)->sa; | 188 | ieee802154_addr_to_sa(&sa, &hdr->source); |
188 | _daddr = &mac_cb(skb)->da; | 189 | ieee802154_addr_to_sa(&da, &hdr->dest); |
189 | 190 | ||
190 | return lowpan_process_data(skb, skb->dev, (u8 *)_saddr->hwaddr, | 191 | if (sa.addr_type == IEEE802154_ADDR_SHORT) |
191 | _saddr->addr_type, IEEE802154_ADDR_LEN, | 192 | sap = &sa.short_addr; |
192 | (u8 *)_daddr->hwaddr, _daddr->addr_type, | 193 | else |
193 | IEEE802154_ADDR_LEN, iphc0, iphc1, | 194 | sap = &sa.hwaddr; |
194 | lowpan_give_skb_to_devices); | 195 | |
196 | if (da.addr_type == IEEE802154_ADDR_SHORT) | ||
197 | dap = &da.short_addr; | ||
198 | else | ||
199 | dap = &da.hwaddr; | ||
200 | |||
201 | return lowpan_process_data(skb, skb->dev, sap, sa.addr_type, | ||
202 | IEEE802154_ADDR_LEN, dap, da.addr_type, | ||
203 | IEEE802154_ADDR_LEN, iphc0, iphc1, | ||
204 | lowpan_give_skb_to_devices); | ||
195 | 205 | ||
196 | drop: | 206 | drop: |
197 | kfree_skb(skb); | 207 | kfree_skb(skb); |
@@ -438,6 +448,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev, | |||
438 | struct packet_type *pt, struct net_device *orig_dev) | 448 | struct packet_type *pt, struct net_device *orig_dev) |
439 | { | 449 | { |
440 | struct sk_buff *local_skb; | 450 | struct sk_buff *local_skb; |
451 | struct ieee802154_hdr hdr; | ||
441 | int ret; | 452 | int ret; |
442 | 453 | ||
443 | if (!netif_running(dev)) | 454 | if (!netif_running(dev)) |
@@ -446,6 +457,9 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev, | |||
446 | if (dev->type != ARPHRD_IEEE802154) | 457 | if (dev->type != ARPHRD_IEEE802154) |
447 | goto drop_skb; | 458 | goto drop_skb; |
448 | 459 | ||
460 | if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0) | ||
461 | goto drop_skb; | ||
462 | |||
449 | local_skb = skb_clone(skb, GFP_ATOMIC); | 463 | local_skb = skb_clone(skb, GFP_ATOMIC); |
450 | if (!local_skb) | 464 | if (!local_skb) |
451 | goto drop_skb; | 465 | goto drop_skb; |
@@ -466,14 +480,14 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev, | |||
466 | } else { | 480 | } else { |
467 | switch (skb->data[0] & 0xe0) { | 481 | switch (skb->data[0] & 0xe0) { |
468 | case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */ | 482 | case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */ |
469 | ret = process_data(local_skb); | 483 | ret = process_data(local_skb, &hdr); |
470 | if (ret == NET_RX_DROP) | 484 | if (ret == NET_RX_DROP) |
471 | goto drop; | 485 | goto drop; |
472 | break; | 486 | break; |
473 | case LOWPAN_DISPATCH_FRAG1: /* first fragment header */ | 487 | case LOWPAN_DISPATCH_FRAG1: /* first fragment header */ |
474 | ret = lowpan_frag_rcv(local_skb, LOWPAN_DISPATCH_FRAG1); | 488 | ret = lowpan_frag_rcv(local_skb, LOWPAN_DISPATCH_FRAG1); |
475 | if (ret == 1) { | 489 | if (ret == 1) { |
476 | ret = process_data(local_skb); | 490 | ret = process_data(local_skb, &hdr); |
477 | if (ret == NET_RX_DROP) | 491 | if (ret == NET_RX_DROP) |
478 | goto drop; | 492 | goto drop; |
479 | } | 493 | } |
@@ -481,7 +495,7 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev, | |||
481 | case LOWPAN_DISPATCH_FRAGN: /* next fragments headers */ | 495 | case LOWPAN_DISPATCH_FRAGN: /* next fragments headers */ |
482 | ret = lowpan_frag_rcv(local_skb, LOWPAN_DISPATCH_FRAGN); | 496 | ret = lowpan_frag_rcv(local_skb, LOWPAN_DISPATCH_FRAGN); |
483 | if (ret == 1) { | 497 | if (ret == 1) { |
484 | ret = process_data(local_skb); | 498 | ret = process_data(local_skb, &hdr); |
485 | if (ret == NET_RX_DROP) | 499 | if (ret == NET_RX_DROP) |
486 | goto drop; | 500 | goto drop; |
487 | } | 501 | } |
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c index 0a926c6bc8ca..55f2dc45a7dc 100644 --- a/net/ieee802154/dgram.c +++ b/net/ieee802154/dgram.c | |||
@@ -313,7 +313,7 @@ static int dgram_recvmsg(struct kiocb *iocb, struct sock *sk, | |||
313 | 313 | ||
314 | if (saddr) { | 314 | if (saddr) { |
315 | saddr->family = AF_IEEE802154; | 315 | saddr->family = AF_IEEE802154; |
316 | saddr->addr = mac_cb(skb)->sa; | 316 | ieee802154_addr_to_sa(&saddr->addr, &mac_cb(skb)->source); |
317 | *addr_len = sizeof(*saddr); | 317 | *addr_len = sizeof(*saddr); |
318 | } | 318 | } |
319 | 319 | ||
diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c index 58fa523fb536..bda8dba4f993 100644 --- a/net/ieee802154/nl-mac.c +++ b/net/ieee802154/nl-mac.c | |||
@@ -39,14 +39,34 @@ | |||
39 | 39 | ||
40 | #include "ieee802154.h" | 40 | #include "ieee802154.h" |
41 | 41 | ||
42 | static int nla_put_hwaddr(struct sk_buff *msg, int type, __le64 hwaddr) | ||
43 | { | ||
44 | return nla_put_u64(msg, type, swab64((__force u64)hwaddr)); | ||
45 | } | ||
46 | |||
47 | static __le64 nla_get_hwaddr(const struct nlattr *nla) | ||
48 | { | ||
49 | return ieee802154_devaddr_from_raw(nla_data(nla)); | ||
50 | } | ||
51 | |||
52 | static int nla_put_shortaddr(struct sk_buff *msg, int type, __le16 addr) | ||
53 | { | ||
54 | return nla_put_u16(msg, type, le16_to_cpu(addr)); | ||
55 | } | ||
56 | |||
57 | static __le16 nla_get_shortaddr(const struct nlattr *nla) | ||
58 | { | ||
59 | return cpu_to_le16(nla_get_u16(nla)); | ||
60 | } | ||
61 | |||
42 | int ieee802154_nl_assoc_indic(struct net_device *dev, | 62 | int ieee802154_nl_assoc_indic(struct net_device *dev, |
43 | struct ieee802154_addr_sa *addr, u8 cap) | 63 | struct ieee802154_addr *addr, u8 cap) |
44 | { | 64 | { |
45 | struct sk_buff *msg; | 65 | struct sk_buff *msg; |
46 | 66 | ||
47 | pr_debug("%s\n", __func__); | 67 | pr_debug("%s\n", __func__); |
48 | 68 | ||
49 | if (addr->addr_type != IEEE802154_ADDR_LONG) { | 69 | if (addr->mode != IEEE802154_ADDR_LONG) { |
50 | pr_err("%s: received non-long source address!\n", __func__); | 70 | pr_err("%s: received non-long source address!\n", __func__); |
51 | return -EINVAL; | 71 | return -EINVAL; |
52 | } | 72 | } |
@@ -59,8 +79,8 @@ int ieee802154_nl_assoc_indic(struct net_device *dev, | |||
59 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || | 79 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || |
60 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | 80 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, |
61 | dev->dev_addr) || | 81 | dev->dev_addr) || |
62 | nla_put(msg, IEEE802154_ATTR_SRC_HW_ADDR, IEEE802154_ADDR_LEN, | 82 | nla_put_hwaddr(msg, IEEE802154_ATTR_SRC_HW_ADDR, |
63 | addr->hwaddr) || | 83 | addr->extended_addr) || |
64 | nla_put_u8(msg, IEEE802154_ATTR_CAPABILITY, cap)) | 84 | nla_put_u8(msg, IEEE802154_ATTR_CAPABILITY, cap)) |
65 | goto nla_put_failure; | 85 | goto nla_put_failure; |
66 | 86 | ||
@@ -87,8 +107,7 @@ int ieee802154_nl_assoc_confirm(struct net_device *dev, __le16 short_addr, | |||
87 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || | 107 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || |
88 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | 108 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, |
89 | dev->dev_addr) || | 109 | dev->dev_addr) || |
90 | nla_put_u16(msg, IEEE802154_ATTR_SHORT_ADDR, | 110 | nla_put_shortaddr(msg, IEEE802154_ATTR_SHORT_ADDR, short_addr) || |
91 | le16_to_cpu(short_addr)) || | ||
92 | nla_put_u8(msg, IEEE802154_ATTR_STATUS, status)) | 111 | nla_put_u8(msg, IEEE802154_ATTR_STATUS, status)) |
93 | goto nla_put_failure; | 112 | goto nla_put_failure; |
94 | return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP); | 113 | return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP); |
@@ -100,7 +119,7 @@ nla_put_failure: | |||
100 | EXPORT_SYMBOL(ieee802154_nl_assoc_confirm); | 119 | EXPORT_SYMBOL(ieee802154_nl_assoc_confirm); |
101 | 120 | ||
102 | int ieee802154_nl_disassoc_indic(struct net_device *dev, | 121 | int ieee802154_nl_disassoc_indic(struct net_device *dev, |
103 | struct ieee802154_addr_sa *addr, u8 reason) | 122 | struct ieee802154_addr *addr, u8 reason) |
104 | { | 123 | { |
105 | struct sk_buff *msg; | 124 | struct sk_buff *msg; |
106 | 125 | ||
@@ -115,13 +134,13 @@ int ieee802154_nl_disassoc_indic(struct net_device *dev, | |||
115 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | 134 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, |
116 | dev->dev_addr)) | 135 | dev->dev_addr)) |
117 | goto nla_put_failure; | 136 | goto nla_put_failure; |
118 | if (addr->addr_type == IEEE802154_ADDR_LONG) { | 137 | if (addr->mode == IEEE802154_ADDR_LONG) { |
119 | if (nla_put(msg, IEEE802154_ATTR_SRC_HW_ADDR, IEEE802154_ADDR_LEN, | 138 | if (nla_put_hwaddr(msg, IEEE802154_ATTR_SRC_HW_ADDR, |
120 | addr->hwaddr)) | 139 | addr->extended_addr)) |
121 | goto nla_put_failure; | 140 | goto nla_put_failure; |
122 | } else { | 141 | } else { |
123 | if (nla_put_u16(msg, IEEE802154_ATTR_SRC_SHORT_ADDR, | 142 | if (nla_put_shortaddr(msg, IEEE802154_ATTR_SRC_SHORT_ADDR, |
124 | addr->short_addr)) | 143 | addr->short_addr)) |
125 | goto nla_put_failure; | 144 | goto nla_put_failure; |
126 | } | 145 | } |
127 | if (nla_put_u8(msg, IEEE802154_ATTR_REASON, reason)) | 146 | if (nla_put_u8(msg, IEEE802154_ATTR_REASON, reason)) |
@@ -173,10 +192,9 @@ int ieee802154_nl_beacon_indic(struct net_device *dev, __le16 panid, | |||
173 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || | 192 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || |
174 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | 193 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, |
175 | dev->dev_addr) || | 194 | dev->dev_addr) || |
176 | nla_put_u16(msg, IEEE802154_ATTR_COORD_SHORT_ADDR, | 195 | nla_put_shortaddr(msg, IEEE802154_ATTR_COORD_SHORT_ADDR, |
177 | le16_to_cpu(coord_addr)) || | 196 | coord_addr) || |
178 | nla_put_u16(msg, IEEE802154_ATTR_COORD_PAN_ID, | 197 | nla_put_shortaddr(msg, IEEE802154_ATTR_COORD_PAN_ID, panid)) |
179 | le16_to_cpu(panid))) | ||
180 | goto nla_put_failure; | 198 | goto nla_put_failure; |
181 | return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP); | 199 | return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP); |
182 | 200 | ||
@@ -246,7 +264,7 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid, | |||
246 | { | 264 | { |
247 | void *hdr; | 265 | void *hdr; |
248 | struct wpan_phy *phy; | 266 | struct wpan_phy *phy; |
249 | u16 short_addr, pan_id; | 267 | __le16 short_addr, pan_id; |
250 | 268 | ||
251 | pr_debug("%s\n", __func__); | 269 | pr_debug("%s\n", __func__); |
252 | 270 | ||
@@ -258,16 +276,16 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid, | |||
258 | phy = ieee802154_mlme_ops(dev)->get_phy(dev); | 276 | phy = ieee802154_mlme_ops(dev)->get_phy(dev); |
259 | BUG_ON(!phy); | 277 | BUG_ON(!phy); |
260 | 278 | ||
261 | short_addr = le16_to_cpu(ieee802154_mlme_ops(dev)->get_short_addr(dev)); | 279 | short_addr = ieee802154_mlme_ops(dev)->get_short_addr(dev); |
262 | pan_id = le16_to_cpu(ieee802154_mlme_ops(dev)->get_pan_id(dev)); | 280 | pan_id = ieee802154_mlme_ops(dev)->get_pan_id(dev); |
263 | 281 | ||
264 | if (nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name) || | 282 | if (nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name) || |
265 | nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || | 283 | nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || |
266 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || | 284 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || |
267 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | 285 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, |
268 | dev->dev_addr) || | 286 | dev->dev_addr) || |
269 | nla_put_u16(msg, IEEE802154_ATTR_SHORT_ADDR, short_addr) || | 287 | nla_put_shortaddr(msg, IEEE802154_ATTR_SHORT_ADDR, short_addr) || |
270 | nla_put_u16(msg, IEEE802154_ATTR_PAN_ID, pan_id)) | 288 | nla_put_shortaddr(msg, IEEE802154_ATTR_PAN_ID, pan_id)) |
271 | goto nla_put_failure; | 289 | goto nla_put_failure; |
272 | wpan_phy_put(phy); | 290 | wpan_phy_put(phy); |
273 | return genlmsg_end(msg, hdr); | 291 | return genlmsg_end(msg, hdr); |
@@ -309,7 +327,7 @@ static struct net_device *ieee802154_nl_get_dev(struct genl_info *info) | |||
309 | int ieee802154_associate_req(struct sk_buff *skb, struct genl_info *info) | 327 | int ieee802154_associate_req(struct sk_buff *skb, struct genl_info *info) |
310 | { | 328 | { |
311 | struct net_device *dev; | 329 | struct net_device *dev; |
312 | struct ieee802154_addr_sa addr; | 330 | struct ieee802154_addr addr; |
313 | u8 page; | 331 | u8 page; |
314 | int ret = -EOPNOTSUPP; | 332 | int ret = -EOPNOTSUPP; |
315 | 333 | ||
@@ -327,16 +345,16 @@ int ieee802154_associate_req(struct sk_buff *skb, struct genl_info *info) | |||
327 | goto out; | 345 | goto out; |
328 | 346 | ||
329 | if (info->attrs[IEEE802154_ATTR_COORD_HW_ADDR]) { | 347 | if (info->attrs[IEEE802154_ATTR_COORD_HW_ADDR]) { |
330 | addr.addr_type = IEEE802154_ADDR_LONG; | 348 | addr.mode = IEEE802154_ADDR_LONG; |
331 | nla_memcpy(addr.hwaddr, | 349 | addr.extended_addr = nla_get_hwaddr( |
332 | info->attrs[IEEE802154_ATTR_COORD_HW_ADDR], | 350 | info->attrs[IEEE802154_ATTR_COORD_HW_ADDR]); |
333 | IEEE802154_ADDR_LEN); | ||
334 | } else { | 351 | } else { |
335 | addr.addr_type = IEEE802154_ADDR_SHORT; | 352 | addr.mode = IEEE802154_ADDR_SHORT; |
336 | addr.short_addr = nla_get_u16( | 353 | addr.short_addr = nla_get_shortaddr( |
337 | info->attrs[IEEE802154_ATTR_COORD_SHORT_ADDR]); | 354 | info->attrs[IEEE802154_ATTR_COORD_SHORT_ADDR]); |
338 | } | 355 | } |
339 | addr.pan_id = nla_get_u16(info->attrs[IEEE802154_ATTR_COORD_PAN_ID]); | 356 | addr.pan_id = nla_get_shortaddr( |
357 | info->attrs[IEEE802154_ATTR_COORD_PAN_ID]); | ||
340 | 358 | ||
341 | if (info->attrs[IEEE802154_ATTR_PAGE]) | 359 | if (info->attrs[IEEE802154_ATTR_PAGE]) |
342 | page = nla_get_u8(info->attrs[IEEE802154_ATTR_PAGE]); | 360 | page = nla_get_u8(info->attrs[IEEE802154_ATTR_PAGE]); |
@@ -356,7 +374,7 @@ out: | |||
356 | int ieee802154_associate_resp(struct sk_buff *skb, struct genl_info *info) | 374 | int ieee802154_associate_resp(struct sk_buff *skb, struct genl_info *info) |
357 | { | 375 | { |
358 | struct net_device *dev; | 376 | struct net_device *dev; |
359 | struct ieee802154_addr_sa addr; | 377 | struct ieee802154_addr addr; |
360 | int ret = -EOPNOTSUPP; | 378 | int ret = -EOPNOTSUPP; |
361 | 379 | ||
362 | if (!info->attrs[IEEE802154_ATTR_STATUS] || | 380 | if (!info->attrs[IEEE802154_ATTR_STATUS] || |
@@ -370,13 +388,13 @@ int ieee802154_associate_resp(struct sk_buff *skb, struct genl_info *info) | |||
370 | if (!ieee802154_mlme_ops(dev)->assoc_resp) | 388 | if (!ieee802154_mlme_ops(dev)->assoc_resp) |
371 | goto out; | 389 | goto out; |
372 | 390 | ||
373 | addr.addr_type = IEEE802154_ADDR_LONG; | 391 | addr.mode = IEEE802154_ADDR_LONG; |
374 | nla_memcpy(addr.hwaddr, info->attrs[IEEE802154_ATTR_DEST_HW_ADDR], | 392 | addr.extended_addr = nla_get_hwaddr( |
375 | IEEE802154_ADDR_LEN); | 393 | info->attrs[IEEE802154_ATTR_DEST_HW_ADDR]); |
376 | addr.pan_id = le16_to_cpu(ieee802154_mlme_ops(dev)->get_pan_id(dev)); | 394 | addr.pan_id = ieee802154_mlme_ops(dev)->get_pan_id(dev); |
377 | 395 | ||
378 | ret = ieee802154_mlme_ops(dev)->assoc_resp(dev, &addr, | 396 | ret = ieee802154_mlme_ops(dev)->assoc_resp(dev, &addr, |
379 | cpu_to_le16(nla_get_u16(info->attrs[IEEE802154_ATTR_DEST_SHORT_ADDR])), | 397 | nla_get_shortaddr(info->attrs[IEEE802154_ATTR_DEST_SHORT_ADDR]), |
380 | nla_get_u8(info->attrs[IEEE802154_ATTR_STATUS])); | 398 | nla_get_u8(info->attrs[IEEE802154_ATTR_STATUS])); |
381 | 399 | ||
382 | out: | 400 | out: |
@@ -387,7 +405,7 @@ out: | |||
387 | int ieee802154_disassociate_req(struct sk_buff *skb, struct genl_info *info) | 405 | int ieee802154_disassociate_req(struct sk_buff *skb, struct genl_info *info) |
388 | { | 406 | { |
389 | struct net_device *dev; | 407 | struct net_device *dev; |
390 | struct ieee802154_addr_sa addr; | 408 | struct ieee802154_addr addr; |
391 | int ret = -EOPNOTSUPP; | 409 | int ret = -EOPNOTSUPP; |
392 | 410 | ||
393 | if ((!info->attrs[IEEE802154_ATTR_DEST_HW_ADDR] && | 411 | if ((!info->attrs[IEEE802154_ATTR_DEST_HW_ADDR] && |
@@ -402,16 +420,15 @@ int ieee802154_disassociate_req(struct sk_buff *skb, struct genl_info *info) | |||
402 | goto out; | 420 | goto out; |
403 | 421 | ||
404 | if (info->attrs[IEEE802154_ATTR_DEST_HW_ADDR]) { | 422 | if (info->attrs[IEEE802154_ATTR_DEST_HW_ADDR]) { |
405 | addr.addr_type = IEEE802154_ADDR_LONG; | 423 | addr.mode = IEEE802154_ADDR_LONG; |
406 | nla_memcpy(addr.hwaddr, | 424 | addr.extended_addr = nla_get_hwaddr( |
407 | info->attrs[IEEE802154_ATTR_DEST_HW_ADDR], | 425 | info->attrs[IEEE802154_ATTR_DEST_HW_ADDR]); |
408 | IEEE802154_ADDR_LEN); | ||
409 | } else { | 426 | } else { |
410 | addr.addr_type = IEEE802154_ADDR_SHORT; | 427 | addr.mode = IEEE802154_ADDR_SHORT; |
411 | addr.short_addr = nla_get_u16( | 428 | addr.short_addr = nla_get_shortaddr( |
412 | info->attrs[IEEE802154_ATTR_DEST_SHORT_ADDR]); | 429 | info->attrs[IEEE802154_ATTR_DEST_SHORT_ADDR]); |
413 | } | 430 | } |
414 | addr.pan_id = le16_to_cpu(ieee802154_mlme_ops(dev)->get_pan_id(dev)); | 431 | addr.pan_id = ieee802154_mlme_ops(dev)->get_pan_id(dev); |
415 | 432 | ||
416 | ret = ieee802154_mlme_ops(dev)->disassoc_req(dev, &addr, | 433 | ret = ieee802154_mlme_ops(dev)->disassoc_req(dev, &addr, |
417 | nla_get_u8(info->attrs[IEEE802154_ATTR_REASON])); | 434 | nla_get_u8(info->attrs[IEEE802154_ATTR_REASON])); |
@@ -429,7 +446,7 @@ out: | |||
429 | int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info) | 446 | int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info) |
430 | { | 447 | { |
431 | struct net_device *dev; | 448 | struct net_device *dev; |
432 | struct ieee802154_addr_sa addr; | 449 | struct ieee802154_addr addr; |
433 | 450 | ||
434 | u8 channel, bcn_ord, sf_ord; | 451 | u8 channel, bcn_ord, sf_ord; |
435 | u8 page; | 452 | u8 page; |
@@ -453,10 +470,11 @@ int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info) | |||
453 | if (!ieee802154_mlme_ops(dev)->start_req) | 470 | if (!ieee802154_mlme_ops(dev)->start_req) |
454 | goto out; | 471 | goto out; |
455 | 472 | ||
456 | addr.addr_type = IEEE802154_ADDR_SHORT; | 473 | addr.mode = IEEE802154_ADDR_SHORT; |
457 | addr.short_addr = nla_get_u16( | 474 | addr.short_addr = nla_get_shortaddr( |
458 | info->attrs[IEEE802154_ATTR_COORD_SHORT_ADDR]); | 475 | info->attrs[IEEE802154_ATTR_COORD_SHORT_ADDR]); |
459 | addr.pan_id = nla_get_u16(info->attrs[IEEE802154_ATTR_COORD_PAN_ID]); | 476 | addr.pan_id = nla_get_shortaddr( |
477 | info->attrs[IEEE802154_ATTR_COORD_PAN_ID]); | ||
460 | 478 | ||
461 | channel = nla_get_u8(info->attrs[IEEE802154_ATTR_CHANNEL]); | 479 | channel = nla_get_u8(info->attrs[IEEE802154_ATTR_CHANNEL]); |
462 | bcn_ord = nla_get_u8(info->attrs[IEEE802154_ATTR_BCN_ORD]); | 480 | bcn_ord = nla_get_u8(info->attrs[IEEE802154_ATTR_BCN_ORD]); |
@@ -471,7 +489,7 @@ int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info) | |||
471 | page = 0; | 489 | page = 0; |
472 | 490 | ||
473 | 491 | ||
474 | if (addr.short_addr == IEEE802154_ADDR_BROADCAST) { | 492 | if (addr.short_addr == cpu_to_le16(IEEE802154_ADDR_BROADCAST)) { |
475 | ieee802154_nl_start_confirm(dev, IEEE802154_NO_SHORT_ADDRESS); | 493 | ieee802154_nl_start_confirm(dev, IEEE802154_NO_SHORT_ADDRESS); |
476 | dev_put(dev); | 494 | dev_put(dev); |
477 | return -EINVAL; | 495 | return -EINVAL; |
diff --git a/net/ieee802154/reassembly.c b/net/ieee802154/reassembly.c index f08b37a24b1d..a2b9e4e533f8 100644 --- a/net/ieee802154/reassembly.c +++ b/net/ieee802154/reassembly.c | |||
@@ -36,8 +36,8 @@ static int lowpan_frag_reasm(struct lowpan_frag_queue *fq, | |||
36 | struct sk_buff *prev, struct net_device *dev); | 36 | struct sk_buff *prev, struct net_device *dev); |
37 | 37 | ||
38 | static unsigned int lowpan_hash_frag(__be16 tag, u16 d_size, | 38 | static unsigned int lowpan_hash_frag(__be16 tag, u16 d_size, |
39 | const struct ieee802154_addr_sa *saddr, | 39 | const struct ieee802154_addr *saddr, |
40 | const struct ieee802154_addr_sa *daddr) | 40 | const struct ieee802154_addr *daddr) |
41 | { | 41 | { |
42 | u32 c; | 42 | u32 c; |
43 | 43 | ||
@@ -65,8 +65,8 @@ static bool lowpan_frag_match(struct inet_frag_queue *q, void *a) | |||
65 | 65 | ||
66 | fq = container_of(q, struct lowpan_frag_queue, q); | 66 | fq = container_of(q, struct lowpan_frag_queue, q); |
67 | return fq->tag == arg->tag && fq->d_size == arg->d_size && | 67 | return fq->tag == arg->tag && fq->d_size == arg->d_size && |
68 | ieee802154_addr_addr_equal(&fq->saddr, arg->src) && | 68 | ieee802154_addr_equal(&fq->saddr, arg->src) && |
69 | ieee802154_addr_addr_equal(&fq->daddr, arg->dst); | 69 | ieee802154_addr_equal(&fq->daddr, arg->dst); |
70 | } | 70 | } |
71 | 71 | ||
72 | static void lowpan_frag_init(struct inet_frag_queue *q, void *a) | 72 | static void lowpan_frag_init(struct inet_frag_queue *q, void *a) |
@@ -103,7 +103,8 @@ out: | |||
103 | 103 | ||
104 | static inline struct lowpan_frag_queue * | 104 | static inline struct lowpan_frag_queue * |
105 | fq_find(struct net *net, const struct ieee802154_frag_info *frag_info, | 105 | fq_find(struct net *net, const struct ieee802154_frag_info *frag_info, |
106 | const struct ieee802154_addr_sa *src, const struct ieee802154_addr_sa *dst) | 106 | const struct ieee802154_addr *src, |
107 | const struct ieee802154_addr *dst) | ||
107 | { | 108 | { |
108 | struct inet_frag_queue *q; | 109 | struct inet_frag_queue *q; |
109 | struct lowpan_create_arg arg; | 110 | struct lowpan_create_arg arg; |
@@ -346,8 +347,12 @@ int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type) | |||
346 | struct lowpan_frag_queue *fq; | 347 | struct lowpan_frag_queue *fq; |
347 | struct net *net = dev_net(skb->dev); | 348 | struct net *net = dev_net(skb->dev); |
348 | struct ieee802154_frag_info *frag_info = &mac_cb(skb)->frag_info; | 349 | struct ieee802154_frag_info *frag_info = &mac_cb(skb)->frag_info; |
350 | struct ieee802154_addr source, dest; | ||
349 | int err; | 351 | int err; |
350 | 352 | ||
353 | source = mac_cb(skb)->source; | ||
354 | dest = mac_cb(skb)->dest; | ||
355 | |||
351 | err = lowpan_get_frag_info(skb, frag_type, frag_info); | 356 | err = lowpan_get_frag_info(skb, frag_type, frag_info); |
352 | if (err < 0) | 357 | if (err < 0) |
353 | goto err; | 358 | goto err; |
@@ -357,7 +362,7 @@ int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type) | |||
357 | 362 | ||
358 | inet_frag_evictor(&net->ieee802154_lowpan.frags, &lowpan_frags, false); | 363 | inet_frag_evictor(&net->ieee802154_lowpan.frags, &lowpan_frags, false); |
359 | 364 | ||
360 | fq = fq_find(net, frag_info, &mac_cb(skb)->sa, &mac_cb(skb)->da); | 365 | fq = fq_find(net, frag_info, &source, &dest); |
361 | if (fq != NULL) { | 366 | if (fq != NULL) { |
362 | int ret; | 367 | int ret; |
363 | spin_lock(&fq->q.lock); | 368 | spin_lock(&fq->q.lock); |
diff --git a/net/ieee802154/reassembly.h b/net/ieee802154/reassembly.h index 895721ae71e1..74e4a7c98191 100644 --- a/net/ieee802154/reassembly.h +++ b/net/ieee802154/reassembly.h | |||
@@ -6,8 +6,8 @@ | |||
6 | struct lowpan_create_arg { | 6 | struct lowpan_create_arg { |
7 | __be16 tag; | 7 | __be16 tag; |
8 | u16 d_size; | 8 | u16 d_size; |
9 | const struct ieee802154_addr_sa *src; | 9 | const struct ieee802154_addr *src; |
10 | const struct ieee802154_addr_sa *dst; | 10 | const struct ieee802154_addr *dst; |
11 | }; | 11 | }; |
12 | 12 | ||
13 | /* Equivalent of ipv4 struct ip | 13 | /* Equivalent of ipv4 struct ip |
@@ -17,16 +17,16 @@ struct lowpan_frag_queue { | |||
17 | 17 | ||
18 | __be16 tag; | 18 | __be16 tag; |
19 | u16 d_size; | 19 | u16 d_size; |
20 | struct ieee802154_addr_sa saddr; | 20 | struct ieee802154_addr saddr; |
21 | struct ieee802154_addr_sa daddr; | 21 | struct ieee802154_addr daddr; |
22 | }; | 22 | }; |
23 | 23 | ||
24 | static inline u32 ieee802154_addr_hash(const struct ieee802154_addr_sa *a) | 24 | static inline u32 ieee802154_addr_hash(const struct ieee802154_addr *a) |
25 | { | 25 | { |
26 | switch (a->addr_type) { | 26 | switch (a->mode) { |
27 | case IEEE802154_ADDR_LONG: | 27 | case IEEE802154_ADDR_LONG: |
28 | return (__force u32)((((u32 *)a->hwaddr))[0] ^ | 28 | return (((__force u64)a->extended_addr) >> 32) ^ |
29 | ((u32 *)(a->hwaddr))[1]); | 29 | (((__force u64)a->extended_addr) & 0xffffffff); |
30 | case IEEE802154_ADDR_SHORT: | 30 | case IEEE802154_ADDR_SHORT: |
31 | return (__force u32)(a->short_addr); | 31 | return (__force u32)(a->short_addr); |
32 | default: | 32 | default: |
@@ -34,32 +34,6 @@ static inline u32 ieee802154_addr_hash(const struct ieee802154_addr_sa *a) | |||
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
37 | static inline bool | ||
38 | ieee802154_addr_addr_equal(const struct ieee802154_addr_sa *a1, | ||
39 | const struct ieee802154_addr_sa *a2) | ||
40 | { | ||
41 | if (a1->pan_id != a2->pan_id) | ||
42 | return false; | ||
43 | |||
44 | if (a1->addr_type != a2->addr_type) | ||
45 | return false; | ||
46 | |||
47 | switch (a1->addr_type) { | ||
48 | case IEEE802154_ADDR_LONG: | ||
49 | if (memcmp(a1->hwaddr, a2->hwaddr, IEEE802154_ADDR_LEN)) | ||
50 | return false; | ||
51 | break; | ||
52 | case IEEE802154_ADDR_SHORT: | ||
53 | if (a1->short_addr != a2->short_addr) | ||
54 | return false; | ||
55 | break; | ||
56 | default: | ||
57 | return false; | ||
58 | } | ||
59 | |||
60 | return true; | ||
61 | } | ||
62 | |||
63 | int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type); | 37 | int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type); |
64 | void lowpan_net_frag_exit(void); | 38 | void lowpan_net_frag_exit(void); |
65 | int lowpan_net_frag_init(void); | 39 | int lowpan_net_frag_init(void); |
diff --git a/net/mac802154/mac_cmd.c b/net/mac802154/mac_cmd.c index f551ef2cdf56..15bac3358889 100644 --- a/net/mac802154/mac_cmd.c +++ b/net/mac802154/mac_cmd.c | |||
@@ -34,16 +34,16 @@ | |||
34 | #include "mac802154.h" | 34 | #include "mac802154.h" |
35 | 35 | ||
36 | static int mac802154_mlme_start_req(struct net_device *dev, | 36 | static int mac802154_mlme_start_req(struct net_device *dev, |
37 | struct ieee802154_addr_sa *addr, | 37 | struct ieee802154_addr *addr, |
38 | u8 channel, u8 page, | 38 | u8 channel, u8 page, |
39 | u8 bcn_ord, u8 sf_ord, | 39 | u8 bcn_ord, u8 sf_ord, |
40 | u8 pan_coord, u8 blx, | 40 | u8 pan_coord, u8 blx, |
41 | u8 coord_realign) | 41 | u8 coord_realign) |
42 | { | 42 | { |
43 | BUG_ON(addr->addr_type != IEEE802154_ADDR_SHORT); | 43 | BUG_ON(addr->mode != IEEE802154_ADDR_SHORT); |
44 | 44 | ||
45 | mac802154_dev_set_pan_id(dev, cpu_to_le16(addr->pan_id)); | 45 | mac802154_dev_set_pan_id(dev, addr->pan_id); |
46 | mac802154_dev_set_short_addr(dev, cpu_to_le16(addr->short_addr)); | 46 | mac802154_dev_set_short_addr(dev, addr->short_addr); |
47 | mac802154_dev_set_ieee_addr(dev); | 47 | mac802154_dev_set_ieee_addr(dev); |
48 | mac802154_dev_set_page_channel(dev, page, channel); | 48 | mac802154_dev_set_page_channel(dev, page, channel); |
49 | 49 | ||
diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c index 051ed46ffca9..b61426662867 100644 --- a/net/mac802154/wpan.c +++ b/net/mac802154/wpan.c | |||
@@ -251,18 +251,18 @@ static int mac802154_process_data(struct net_device *dev, struct sk_buff *skb) | |||
251 | static int | 251 | static int |
252 | mac802154_subif_frame(struct mac802154_sub_if_data *sdata, struct sk_buff *skb) | 252 | mac802154_subif_frame(struct mac802154_sub_if_data *sdata, struct sk_buff *skb) |
253 | { | 253 | { |
254 | u16 span, sshort; | 254 | __le16 span, sshort; |
255 | 255 | ||
256 | pr_debug("getting packet via slave interface %s\n", sdata->dev->name); | 256 | pr_debug("getting packet via slave interface %s\n", sdata->dev->name); |
257 | 257 | ||
258 | spin_lock_bh(&sdata->mib_lock); | 258 | spin_lock_bh(&sdata->mib_lock); |
259 | 259 | ||
260 | span = le16_to_cpu(sdata->pan_id); | 260 | span = sdata->pan_id; |
261 | sshort = le16_to_cpu(sdata->short_addr); | 261 | sshort = sdata->short_addr; |
262 | 262 | ||
263 | switch (mac_cb(skb)->da.addr_type) { | 263 | switch (mac_cb(skb)->dest.mode) { |
264 | case IEEE802154_ADDR_NONE: | 264 | case IEEE802154_ADDR_NONE: |
265 | if (mac_cb(skb)->sa.addr_type != IEEE802154_ADDR_NONE) | 265 | if (mac_cb(skb)->dest.mode != IEEE802154_ADDR_NONE) |
266 | /* FIXME: check if we are PAN coordinator */ | 266 | /* FIXME: check if we are PAN coordinator */ |
267 | skb->pkt_type = PACKET_OTHERHOST; | 267 | skb->pkt_type = PACKET_OTHERHOST; |
268 | else | 268 | else |
@@ -270,23 +270,22 @@ mac802154_subif_frame(struct mac802154_sub_if_data *sdata, struct sk_buff *skb) | |||
270 | skb->pkt_type = PACKET_HOST; | 270 | skb->pkt_type = PACKET_HOST; |
271 | break; | 271 | break; |
272 | case IEEE802154_ADDR_LONG: | 272 | case IEEE802154_ADDR_LONG: |
273 | if (mac_cb(skb)->da.pan_id != span && | 273 | if (mac_cb(skb)->dest.pan_id != span && |
274 | mac_cb(skb)->da.pan_id != IEEE802154_PANID_BROADCAST) | 274 | mac_cb(skb)->dest.pan_id != cpu_to_le16(IEEE802154_PANID_BROADCAST)) |
275 | skb->pkt_type = PACKET_OTHERHOST; | 275 | skb->pkt_type = PACKET_OTHERHOST; |
276 | else if (!memcmp(mac_cb(skb)->da.hwaddr, sdata->dev->dev_addr, | 276 | else if (mac_cb(skb)->dest.extended_addr == sdata->extended_addr) |
277 | IEEE802154_ADDR_LEN)) | ||
278 | skb->pkt_type = PACKET_HOST; | 277 | skb->pkt_type = PACKET_HOST; |
279 | else | 278 | else |
280 | skb->pkt_type = PACKET_OTHERHOST; | 279 | skb->pkt_type = PACKET_OTHERHOST; |
281 | break; | 280 | break; |
282 | case IEEE802154_ADDR_SHORT: | 281 | case IEEE802154_ADDR_SHORT: |
283 | if (mac_cb(skb)->da.pan_id != span && | 282 | if (mac_cb(skb)->dest.pan_id != span && |
284 | mac_cb(skb)->da.pan_id != IEEE802154_PANID_BROADCAST) | 283 | mac_cb(skb)->dest.pan_id != cpu_to_le16(IEEE802154_PANID_BROADCAST)) |
285 | skb->pkt_type = PACKET_OTHERHOST; | 284 | skb->pkt_type = PACKET_OTHERHOST; |
286 | else if (mac_cb(skb)->da.short_addr == sshort) | 285 | else if (mac_cb(skb)->dest.short_addr == sshort) |
287 | skb->pkt_type = PACKET_HOST; | 286 | skb->pkt_type = PACKET_HOST; |
288 | else if (mac_cb(skb)->da.short_addr == | 287 | else if (mac_cb(skb)->dest.short_addr == |
289 | IEEE802154_ADDR_BROADCAST) | 288 | cpu_to_le16(IEEE802154_ADDR_BROADCAST)) |
290 | skb->pkt_type = PACKET_BROADCAST; | 289 | skb->pkt_type = PACKET_BROADCAST; |
291 | else | 290 | else |
292 | skb->pkt_type = PACKET_OTHERHOST; | 291 | skb->pkt_type = PACKET_OTHERHOST; |
@@ -332,8 +331,8 @@ static void mac802154_print_addr(const char *name, | |||
332 | 331 | ||
333 | static int mac802154_parse_frame_start(struct sk_buff *skb) | 332 | static int mac802154_parse_frame_start(struct sk_buff *skb) |
334 | { | 333 | { |
335 | struct ieee802154_hdr hdr; | ||
336 | int hlen; | 334 | int hlen; |
335 | struct ieee802154_hdr hdr; | ||
337 | 336 | ||
338 | hlen = ieee802154_hdr_pull(skb, &hdr); | 337 | hlen = ieee802154_hdr_pull(skb, &hdr); |
339 | if (hlen < 0) | 338 | if (hlen < 0) |
@@ -346,9 +345,6 @@ static int mac802154_parse_frame_start(struct sk_buff *skb) | |||
346 | 345 | ||
347 | mac_cb(skb)->flags = hdr.fc.type; | 346 | mac_cb(skb)->flags = hdr.fc.type; |
348 | 347 | ||
349 | ieee802154_addr_to_sa(&mac_cb(skb)->sa, &hdr.source); | ||
350 | ieee802154_addr_to_sa(&mac_cb(skb)->da, &hdr.dest); | ||
351 | |||
352 | if (hdr.fc.ack_request) | 348 | if (hdr.fc.ack_request) |
353 | mac_cb(skb)->flags |= MAC_CB_FLAG_ACKREQ; | 349 | mac_cb(skb)->flags |= MAC_CB_FLAG_ACKREQ; |
354 | if (hdr.fc.security_enabled) | 350 | if (hdr.fc.security_enabled) |
@@ -357,6 +353,9 @@ static int mac802154_parse_frame_start(struct sk_buff *skb) | |||
357 | mac802154_print_addr("destination", &hdr.dest); | 353 | mac802154_print_addr("destination", &hdr.dest); |
358 | mac802154_print_addr("source", &hdr.source); | 354 | mac802154_print_addr("source", &hdr.source); |
359 | 355 | ||
356 | mac_cb(skb)->source = hdr.source; | ||
357 | mac_cb(skb)->dest = hdr.dest; | ||
358 | |||
360 | if (hdr.fc.security_enabled) { | 359 | if (hdr.fc.security_enabled) { |
361 | u64 key; | 360 | u64 key; |
362 | 361 | ||