diff options
Diffstat (limited to 'net/ieee802154')
-rw-r--r-- | net/ieee802154/6lowpan.c | 87 | ||||
-rw-r--r-- | net/ieee802154/6lowpan.h | 3 | ||||
-rw-r--r-- | net/ieee802154/dgram.c | 6 | ||||
-rw-r--r-- | net/ieee802154/nl-mac.c | 146 | ||||
-rw-r--r-- | net/ieee802154/nl-phy.c | 38 | ||||
-rw-r--r-- | net/ieee802154/raw.c | 2 |
6 files changed, 148 insertions, 134 deletions
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 840821b90bcd..32eb4179e8fa 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c | |||
@@ -196,7 +196,7 @@ lowpan_compress_addr_64(u8 **hc06_ptr, u8 shift, const struct in6_addr *ipaddr, | |||
196 | static void | 196 | static void |
197 | lowpan_uip_ds6_set_addr_iid(struct in6_addr *ipaddr, unsigned char *lladdr) | 197 | lowpan_uip_ds6_set_addr_iid(struct in6_addr *ipaddr, unsigned char *lladdr) |
198 | { | 198 | { |
199 | memcpy(&ipaddr->s6_addr[8], lladdr, IEEE802154_ALEN); | 199 | memcpy(&ipaddr->s6_addr[8], lladdr, IEEE802154_ADDR_LEN); |
200 | /* second bit-flip (Universe/Local) is done according RFC2464 */ | 200 | /* second bit-flip (Universe/Local) is done according RFC2464 */ |
201 | ipaddr->s6_addr[8] ^= 0x02; | 201 | ipaddr->s6_addr[8] ^= 0x02; |
202 | } | 202 | } |
@@ -221,7 +221,7 @@ lowpan_uncompress_addr(struct sk_buff *skb, struct in6_addr *ipaddr, | |||
221 | 221 | ||
222 | if (lladdr) | 222 | if (lladdr) |
223 | lowpan_raw_dump_inline(__func__, "linklocal address", | 223 | lowpan_raw_dump_inline(__func__, "linklocal address", |
224 | lladdr, IEEE802154_ALEN); | 224 | lladdr, IEEE802154_ADDR_LEN); |
225 | if (prefcount > 0) | 225 | if (prefcount > 0) |
226 | memcpy(ipaddr, prefix, prefcount); | 226 | memcpy(ipaddr, prefix, prefcount); |
227 | 227 | ||
@@ -371,7 +371,7 @@ err: | |||
371 | static int lowpan_header_create(struct sk_buff *skb, | 371 | static int lowpan_header_create(struct sk_buff *skb, |
372 | struct net_device *dev, | 372 | struct net_device *dev, |
373 | unsigned short type, const void *_daddr, | 373 | unsigned short type, const void *_daddr, |
374 | const void *_saddr, unsigned len) | 374 | const void *_saddr, unsigned int len) |
375 | { | 375 | { |
376 | u8 tmp, iphc0, iphc1, *hc06_ptr; | 376 | u8 tmp, iphc0, iphc1, *hc06_ptr; |
377 | struct ipv6hdr *hdr; | 377 | struct ipv6hdr *hdr; |
@@ -650,6 +650,53 @@ static void lowpan_fragment_timer_expired(unsigned long entry_addr) | |||
650 | kfree(entry); | 650 | kfree(entry); |
651 | } | 651 | } |
652 | 652 | ||
653 | static struct lowpan_fragment * | ||
654 | lowpan_alloc_new_frame(struct sk_buff *skb, u8 iphc0, u8 len, u8 tag) | ||
655 | { | ||
656 | struct lowpan_fragment *frame; | ||
657 | |||
658 | frame = kzalloc(sizeof(struct lowpan_fragment), | ||
659 | GFP_ATOMIC); | ||
660 | if (!frame) | ||
661 | goto frame_err; | ||
662 | |||
663 | INIT_LIST_HEAD(&frame->list); | ||
664 | |||
665 | frame->length = (iphc0 & 7) | (len << 3); | ||
666 | frame->tag = tag; | ||
667 | |||
668 | /* allocate buffer for frame assembling */ | ||
669 | frame->skb = alloc_skb(frame->length + | ||
670 | sizeof(struct ipv6hdr), GFP_ATOMIC); | ||
671 | |||
672 | if (!frame->skb) | ||
673 | goto skb_err; | ||
674 | |||
675 | frame->skb->priority = skb->priority; | ||
676 | frame->skb->dev = skb->dev; | ||
677 | |||
678 | /* reserve headroom for uncompressed ipv6 header */ | ||
679 | skb_reserve(frame->skb, sizeof(struct ipv6hdr)); | ||
680 | skb_put(frame->skb, frame->length); | ||
681 | |||
682 | init_timer(&frame->timer); | ||
683 | /* time out is the same as for ipv6 - 60 sec */ | ||
684 | frame->timer.expires = jiffies + LOWPAN_FRAG_TIMEOUT; | ||
685 | frame->timer.data = (unsigned long)frame; | ||
686 | frame->timer.function = lowpan_fragment_timer_expired; | ||
687 | |||
688 | add_timer(&frame->timer); | ||
689 | |||
690 | list_add_tail(&frame->list, &lowpan_fragments); | ||
691 | |||
692 | return frame; | ||
693 | |||
694 | skb_err: | ||
695 | kfree(frame); | ||
696 | frame_err: | ||
697 | return NULL; | ||
698 | } | ||
699 | |||
653 | static int | 700 | static int |
654 | lowpan_process_data(struct sk_buff *skb) | 701 | lowpan_process_data(struct sk_buff *skb) |
655 | { | 702 | { |
@@ -692,41 +739,9 @@ lowpan_process_data(struct sk_buff *skb) | |||
692 | 739 | ||
693 | /* alloc new frame structure */ | 740 | /* alloc new frame structure */ |
694 | if (!found) { | 741 | if (!found) { |
695 | frame = kzalloc(sizeof(struct lowpan_fragment), | 742 | frame = lowpan_alloc_new_frame(skb, iphc0, len, tag); |
696 | GFP_ATOMIC); | ||
697 | if (!frame) | 743 | if (!frame) |
698 | goto unlock_and_drop; | 744 | goto unlock_and_drop; |
699 | |||
700 | INIT_LIST_HEAD(&frame->list); | ||
701 | |||
702 | frame->length = (iphc0 & 7) | (len << 3); | ||
703 | frame->tag = tag; | ||
704 | |||
705 | /* allocate buffer for frame assembling */ | ||
706 | frame->skb = alloc_skb(frame->length + | ||
707 | sizeof(struct ipv6hdr), GFP_ATOMIC); | ||
708 | |||
709 | if (!frame->skb) { | ||
710 | kfree(frame); | ||
711 | goto unlock_and_drop; | ||
712 | } | ||
713 | |||
714 | frame->skb->priority = skb->priority; | ||
715 | frame->skb->dev = skb->dev; | ||
716 | |||
717 | /* reserve headroom for uncompressed ipv6 header */ | ||
718 | skb_reserve(frame->skb, sizeof(struct ipv6hdr)); | ||
719 | skb_put(frame->skb, frame->length); | ||
720 | |||
721 | init_timer(&frame->timer); | ||
722 | /* time out is the same as for ipv6 - 60 sec */ | ||
723 | frame->timer.expires = jiffies + LOWPAN_FRAG_TIMEOUT; | ||
724 | frame->timer.data = (unsigned long)frame; | ||
725 | frame->timer.function = lowpan_fragment_timer_expired; | ||
726 | |||
727 | add_timer(&frame->timer); | ||
728 | |||
729 | list_add_tail(&frame->list, &lowpan_fragments); | ||
730 | } | 745 | } |
731 | 746 | ||
732 | if ((iphc0 & LOWPAN_DISPATCH_MASK) == LOWPAN_DISPATCH_FRAG1) | 747 | if ((iphc0 & LOWPAN_DISPATCH_MASK) == LOWPAN_DISPATCH_FRAG1) |
diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h index aeff3f310482..8c2251fb0a3f 100644 --- a/net/ieee802154/6lowpan.h +++ b/net/ieee802154/6lowpan.h | |||
@@ -53,9 +53,6 @@ | |||
53 | #ifndef __6LOWPAN_H__ | 53 | #ifndef __6LOWPAN_H__ |
54 | #define __6LOWPAN_H__ | 54 | #define __6LOWPAN_H__ |
55 | 55 | ||
56 | /* need to know address length to manipulate with it */ | ||
57 | #define IEEE802154_ALEN 8 | ||
58 | |||
59 | #define UIP_802154_SHORTADDR_LEN 2 /* compressed ipv6 address length */ | 56 | #define UIP_802154_SHORTADDR_LEN 2 /* compressed ipv6 address length */ |
60 | #define UIP_IPH_LEN 40 /* ipv6 fixed header size */ | 57 | #define UIP_IPH_LEN 40 /* ipv6 fixed header size */ |
61 | #define UIP_PROTO_UDP 17 /* ipv6 next header value for UDP */ | 58 | #define UIP_PROTO_UDP 17 /* ipv6 next header value for UDP */ |
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c index 1b09eaabaac1..6fbb2ad7bb6d 100644 --- a/net/ieee802154/dgram.c +++ b/net/ieee802154/dgram.c | |||
@@ -44,8 +44,8 @@ struct dgram_sock { | |||
44 | struct ieee802154_addr src_addr; | 44 | struct ieee802154_addr src_addr; |
45 | struct ieee802154_addr dst_addr; | 45 | struct ieee802154_addr dst_addr; |
46 | 46 | ||
47 | unsigned bound:1; | 47 | unsigned int bound:1; |
48 | unsigned want_ack:1; | 48 | unsigned int want_ack:1; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | static inline struct dgram_sock *dgram_sk(const struct sock *sk) | 51 | static inline struct dgram_sock *dgram_sk(const struct sock *sk) |
@@ -206,7 +206,7 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
206 | struct msghdr *msg, size_t size) | 206 | struct msghdr *msg, size_t size) |
207 | { | 207 | { |
208 | struct net_device *dev; | 208 | struct net_device *dev; |
209 | unsigned mtu; | 209 | unsigned int mtu; |
210 | struct sk_buff *skb; | 210 | struct sk_buff *skb; |
211 | struct dgram_sock *ro = dgram_sk(sk); | 211 | struct dgram_sock *ro = dgram_sk(sk); |
212 | int hlen, tlen; | 212 | int hlen, tlen; |
diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c index adaf46214905..ca92587720f4 100644 --- a/net/ieee802154/nl-mac.c +++ b/net/ieee802154/nl-mac.c | |||
@@ -63,15 +63,14 @@ int ieee802154_nl_assoc_indic(struct net_device *dev, | |||
63 | if (!msg) | 63 | if (!msg) |
64 | return -ENOBUFS; | 64 | return -ENOBUFS; |
65 | 65 | ||
66 | NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name); | 66 | if (nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name) || |
67 | NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex); | 67 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || |
68 | NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | 68 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, |
69 | dev->dev_addr); | 69 | dev->dev_addr) || |
70 | 70 | nla_put(msg, IEEE802154_ATTR_SRC_HW_ADDR, IEEE802154_ADDR_LEN, | |
71 | NLA_PUT(msg, IEEE802154_ATTR_SRC_HW_ADDR, IEEE802154_ADDR_LEN, | 71 | addr->hwaddr) || |
72 | addr->hwaddr); | 72 | nla_put_u8(msg, IEEE802154_ATTR_CAPABILITY, cap)) |
73 | 73 | goto nla_put_failure; | |
74 | NLA_PUT_U8(msg, IEEE802154_ATTR_CAPABILITY, cap); | ||
75 | 74 | ||
76 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); | 75 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); |
77 | 76 | ||
@@ -92,14 +91,13 @@ int ieee802154_nl_assoc_confirm(struct net_device *dev, u16 short_addr, | |||
92 | if (!msg) | 91 | if (!msg) |
93 | return -ENOBUFS; | 92 | return -ENOBUFS; |
94 | 93 | ||
95 | NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name); | 94 | if (nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name) || |
96 | NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex); | 95 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || |
97 | NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | 96 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, |
98 | dev->dev_addr); | 97 | dev->dev_addr) || |
99 | 98 | nla_put_u16(msg, IEEE802154_ATTR_SHORT_ADDR, short_addr) || | |
100 | NLA_PUT_U16(msg, IEEE802154_ATTR_SHORT_ADDR, short_addr); | 99 | nla_put_u8(msg, IEEE802154_ATTR_STATUS, status)) |
101 | NLA_PUT_U8(msg, IEEE802154_ATTR_STATUS, status); | 100 | goto nla_put_failure; |
102 | |||
103 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); | 101 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); |
104 | 102 | ||
105 | nla_put_failure: | 103 | nla_put_failure: |
@@ -119,20 +117,22 @@ int ieee802154_nl_disassoc_indic(struct net_device *dev, | |||
119 | if (!msg) | 117 | if (!msg) |
120 | return -ENOBUFS; | 118 | return -ENOBUFS; |
121 | 119 | ||
122 | NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name); | 120 | if (nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name) || |
123 | NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex); | 121 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || |
124 | NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | 122 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, |
125 | dev->dev_addr); | 123 | dev->dev_addr)) |
126 | 124 | goto nla_put_failure; | |
127 | if (addr->addr_type == IEEE802154_ADDR_LONG) | 125 | if (addr->addr_type == IEEE802154_ADDR_LONG) { |
128 | NLA_PUT(msg, IEEE802154_ATTR_SRC_HW_ADDR, IEEE802154_ADDR_LEN, | 126 | if (nla_put(msg, IEEE802154_ATTR_SRC_HW_ADDR, IEEE802154_ADDR_LEN, |
129 | addr->hwaddr); | 127 | addr->hwaddr)) |
130 | else | 128 | goto nla_put_failure; |
131 | NLA_PUT_U16(msg, IEEE802154_ATTR_SRC_SHORT_ADDR, | 129 | } else { |
132 | addr->short_addr); | 130 | if (nla_put_u16(msg, IEEE802154_ATTR_SRC_SHORT_ADDR, |
133 | 131 | addr->short_addr)) | |
134 | NLA_PUT_U8(msg, IEEE802154_ATTR_REASON, reason); | 132 | goto nla_put_failure; |
135 | 133 | } | |
134 | if (nla_put_u8(msg, IEEE802154_ATTR_REASON, reason)) | ||
135 | goto nla_put_failure; | ||
136 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); | 136 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); |
137 | 137 | ||
138 | nla_put_failure: | 138 | nla_put_failure: |
@@ -151,13 +151,12 @@ int ieee802154_nl_disassoc_confirm(struct net_device *dev, u8 status) | |||
151 | if (!msg) | 151 | if (!msg) |
152 | return -ENOBUFS; | 152 | return -ENOBUFS; |
153 | 153 | ||
154 | NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name); | 154 | if (nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name) || |
155 | NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex); | 155 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || |
156 | NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | 156 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, |
157 | dev->dev_addr); | 157 | dev->dev_addr) || |
158 | 158 | nla_put_u8(msg, IEEE802154_ATTR_STATUS, status)) | |
159 | NLA_PUT_U8(msg, IEEE802154_ATTR_STATUS, status); | 159 | goto nla_put_failure; |
160 | |||
161 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); | 160 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); |
162 | 161 | ||
163 | nla_put_failure: | 162 | nla_put_failure: |
@@ -177,13 +176,13 @@ int ieee802154_nl_beacon_indic(struct net_device *dev, | |||
177 | if (!msg) | 176 | if (!msg) |
178 | return -ENOBUFS; | 177 | return -ENOBUFS; |
179 | 178 | ||
180 | NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name); | 179 | if (nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name) || |
181 | NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex); | 180 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || |
182 | NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | 181 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, |
183 | dev->dev_addr); | 182 | dev->dev_addr) || |
184 | NLA_PUT_U16(msg, IEEE802154_ATTR_COORD_SHORT_ADDR, coord_addr); | 183 | nla_put_u16(msg, IEEE802154_ATTR_COORD_SHORT_ADDR, coord_addr) || |
185 | NLA_PUT_U16(msg, IEEE802154_ATTR_COORD_PAN_ID, panid); | 184 | nla_put_u16(msg, IEEE802154_ATTR_COORD_PAN_ID, panid)) |
186 | 185 | goto nla_put_failure; | |
187 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); | 186 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); |
188 | 187 | ||
189 | nla_put_failure: | 188 | nla_put_failure: |
@@ -204,19 +203,17 @@ int ieee802154_nl_scan_confirm(struct net_device *dev, | |||
204 | if (!msg) | 203 | if (!msg) |
205 | return -ENOBUFS; | 204 | return -ENOBUFS; |
206 | 205 | ||
207 | NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name); | 206 | if (nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name) || |
208 | NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex); | 207 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || |
209 | NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | 208 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, |
210 | dev->dev_addr); | 209 | dev->dev_addr) || |
211 | 210 | nla_put_u8(msg, IEEE802154_ATTR_STATUS, status) || | |
212 | NLA_PUT_U8(msg, IEEE802154_ATTR_STATUS, status); | 211 | nla_put_u8(msg, IEEE802154_ATTR_SCAN_TYPE, scan_type) || |
213 | NLA_PUT_U8(msg, IEEE802154_ATTR_SCAN_TYPE, scan_type); | 212 | nla_put_u32(msg, IEEE802154_ATTR_CHANNELS, unscanned) || |
214 | NLA_PUT_U32(msg, IEEE802154_ATTR_CHANNELS, unscanned); | 213 | nla_put_u8(msg, IEEE802154_ATTR_PAGE, page) || |
215 | NLA_PUT_U8(msg, IEEE802154_ATTR_PAGE, page); | 214 | (edl && |
216 | 215 | nla_put(msg, IEEE802154_ATTR_ED_LIST, 27, edl))) | |
217 | if (edl) | 216 | goto nla_put_failure; |
218 | NLA_PUT(msg, IEEE802154_ATTR_ED_LIST, 27, edl); | ||
219 | |||
220 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); | 217 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); |
221 | 218 | ||
222 | nla_put_failure: | 219 | nla_put_failure: |
@@ -235,13 +232,12 @@ int ieee802154_nl_start_confirm(struct net_device *dev, u8 status) | |||
235 | if (!msg) | 232 | if (!msg) |
236 | return -ENOBUFS; | 233 | return -ENOBUFS; |
237 | 234 | ||
238 | NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name); | 235 | if (nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name) || |
239 | NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex); | 236 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || |
240 | NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | 237 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, |
241 | dev->dev_addr); | 238 | dev->dev_addr) || |
242 | 239 | nla_put_u8(msg, IEEE802154_ATTR_STATUS, status)) | |
243 | NLA_PUT_U8(msg, IEEE802154_ATTR_STATUS, status); | 240 | goto nla_put_failure; |
244 | |||
245 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); | 241 | return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); |
246 | 242 | ||
247 | nla_put_failure: | 243 | nla_put_failure: |
@@ -266,16 +262,16 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 pid, | |||
266 | phy = ieee802154_mlme_ops(dev)->get_phy(dev); | 262 | phy = ieee802154_mlme_ops(dev)->get_phy(dev); |
267 | BUG_ON(!phy); | 263 | BUG_ON(!phy); |
268 | 264 | ||
269 | NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name); | 265 | if (nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name) || |
270 | NLA_PUT_STRING(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)); | 266 | nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || |
271 | NLA_PUT_U32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex); | 267 | nla_put_u32(msg, IEEE802154_ATTR_DEV_INDEX, dev->ifindex) || |
272 | 268 | nla_put(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | |
273 | NLA_PUT(msg, IEEE802154_ATTR_HW_ADDR, IEEE802154_ADDR_LEN, | 269 | dev->dev_addr) || |
274 | dev->dev_addr); | 270 | nla_put_u16(msg, IEEE802154_ATTR_SHORT_ADDR, |
275 | NLA_PUT_U16(msg, IEEE802154_ATTR_SHORT_ADDR, | 271 | ieee802154_mlme_ops(dev)->get_short_addr(dev)) || |
276 | ieee802154_mlme_ops(dev)->get_short_addr(dev)); | 272 | nla_put_u16(msg, IEEE802154_ATTR_PAN_ID, |
277 | NLA_PUT_U16(msg, IEEE802154_ATTR_PAN_ID, | 273 | ieee802154_mlme_ops(dev)->get_pan_id(dev))) |
278 | ieee802154_mlme_ops(dev)->get_pan_id(dev)); | 274 | goto nla_put_failure; |
279 | wpan_phy_put(phy); | 275 | wpan_phy_put(phy); |
280 | return genlmsg_end(msg, hdr); | 276 | return genlmsg_end(msg, hdr); |
281 | 277 | ||
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c index c64a38d57aa3..eed291626da6 100644 --- a/net/ieee802154/nl-phy.c +++ b/net/ieee802154/nl-phy.c | |||
@@ -53,18 +53,18 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 pid, | |||
53 | goto out; | 53 | goto out; |
54 | 54 | ||
55 | mutex_lock(&phy->pib_lock); | 55 | mutex_lock(&phy->pib_lock); |
56 | NLA_PUT_STRING(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)); | 56 | if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || |
57 | 57 | nla_put_u8(msg, IEEE802154_ATTR_PAGE, phy->current_page) || | |
58 | NLA_PUT_U8(msg, IEEE802154_ATTR_PAGE, phy->current_page); | 58 | nla_put_u8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel)) |
59 | NLA_PUT_U8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel); | 59 | goto nla_put_failure; |
60 | for (i = 0; i < 32; i++) { | 60 | for (i = 0; i < 32; i++) { |
61 | if (phy->channels_supported[i]) | 61 | if (phy->channels_supported[i]) |
62 | buf[pages++] = phy->channels_supported[i] | (i << 27); | 62 | buf[pages++] = phy->channels_supported[i] | (i << 27); |
63 | } | 63 | } |
64 | if (pages) | 64 | if (pages && |
65 | NLA_PUT(msg, IEEE802154_ATTR_CHANNEL_PAGE_LIST, | 65 | nla_put(msg, IEEE802154_ATTR_CHANNEL_PAGE_LIST, |
66 | pages * sizeof(uint32_t), buf); | 66 | pages * sizeof(uint32_t), buf)) |
67 | 67 | goto nla_put_failure; | |
68 | mutex_unlock(&phy->pib_lock); | 68 | mutex_unlock(&phy->pib_lock); |
69 | kfree(buf); | 69 | kfree(buf); |
70 | return genlmsg_end(msg, hdr); | 70 | return genlmsg_end(msg, hdr); |
@@ -179,6 +179,7 @@ static int ieee802154_add_iface(struct sk_buff *skb, | |||
179 | const char *devname; | 179 | const char *devname; |
180 | int rc = -ENOBUFS; | 180 | int rc = -ENOBUFS; |
181 | struct net_device *dev; | 181 | struct net_device *dev; |
182 | int type = __IEEE802154_DEV_INVALID; | ||
182 | 183 | ||
183 | pr_debug("%s\n", __func__); | 184 | pr_debug("%s\n", __func__); |
184 | 185 | ||
@@ -221,7 +222,13 @@ static int ieee802154_add_iface(struct sk_buff *skb, | |||
221 | goto nla_put_failure; | 222 | goto nla_put_failure; |
222 | } | 223 | } |
223 | 224 | ||
224 | dev = phy->add_iface(phy, devname); | 225 | if (info->attrs[IEEE802154_ATTR_DEV_TYPE]) { |
226 | type = nla_get_u8(info->attrs[IEEE802154_ATTR_DEV_TYPE]); | ||
227 | if (type >= __IEEE802154_DEV_MAX) | ||
228 | return -EINVAL; | ||
229 | } | ||
230 | |||
231 | dev = phy->add_iface(phy, devname, type); | ||
225 | if (IS_ERR(dev)) { | 232 | if (IS_ERR(dev)) { |
226 | rc = PTR_ERR(dev); | 233 | rc = PTR_ERR(dev); |
227 | goto nla_put_failure; | 234 | goto nla_put_failure; |
@@ -245,9 +252,9 @@ static int ieee802154_add_iface(struct sk_buff *skb, | |||
245 | goto dev_unregister; | 252 | goto dev_unregister; |
246 | } | 253 | } |
247 | 254 | ||
248 | NLA_PUT_STRING(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)); | 255 | if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || |
249 | NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name); | 256 | nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name)) |
250 | 257 | goto nla_put_failure; | |
251 | dev_put(dev); | 258 | dev_put(dev); |
252 | 259 | ||
253 | wpan_phy_put(phy); | 260 | wpan_phy_put(phy); |
@@ -333,10 +340,9 @@ static int ieee802154_del_iface(struct sk_buff *skb, | |||
333 | 340 | ||
334 | rtnl_unlock(); | 341 | rtnl_unlock(); |
335 | 342 | ||
336 | 343 | if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || | |
337 | NLA_PUT_STRING(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)); | 344 | nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, name)) |
338 | NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, name); | 345 | goto nla_put_failure; |
339 | |||
340 | wpan_phy_put(phy); | 346 | wpan_phy_put(phy); |
341 | 347 | ||
342 | return ieee802154_nl_reply(msg, info); | 348 | return ieee802154_nl_reply(msg, info); |
diff --git a/net/ieee802154/raw.c b/net/ieee802154/raw.c index f96bae8fd330..50e823927d49 100644 --- a/net/ieee802154/raw.c +++ b/net/ieee802154/raw.c | |||
@@ -106,7 +106,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
106 | size_t size) | 106 | size_t size) |
107 | { | 107 | { |
108 | struct net_device *dev; | 108 | struct net_device *dev; |
109 | unsigned mtu; | 109 | unsigned int mtu; |
110 | struct sk_buff *skb; | 110 | struct sk_buff *skb; |
111 | int hlen, tlen; | 111 | int hlen, tlen; |
112 | int err; | 112 | int err; |