diff options
author | Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de> | 2014-03-14 16:24:02 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-03-14 22:15:26 -0400 |
commit | ae531b9475f62c5e1863508604cd6b3faf362d56 (patch) | |
tree | c719f25779f44c4241d799e44c8fc2c8c8065957 /net/ieee802154 | |
parent | e6278d92005e9d6e374f269b4ce39c908a68ad5d (diff) |
ieee802154: use ieee802154_addr instead of *_sa variants
Change all internal uses of ieee802154_addr_sa to ieee802154_addr,
except for those instances that communicate directly with userspace.
Signed-off-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ieee802154')
-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 |
5 files changed, 112 insertions, 101 deletions
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); |