aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac802154
diff options
context:
space:
mode:
authorPhoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>2014-05-14 11:43:08 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-15 15:51:42 -0400
commit32edc40ae65cf84e1ab69f6f8316ce81559e115d (patch)
treee3e4435e356a0e10038c3a2a16383f6089660c9c /net/mac802154
parent8c84296fd2867118944399ab7e9051515a70d60d (diff)
ieee802154: change _cb handling slightly
The current mac_cb handling of ieee802154 is rather awkward and limited. Decompose the single flags field into multiple fields with the meanings of each subfield of the flags field to make future extensions (for example, link-layer security) easier. Also don't set the frame sequence number in upper layers, since that's a thing the MAC is supposed to set on frame transmit - we set it on header creation, but assuming that upper layers do not blindly duplicate our headers, this is fine. Signed-off-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mac802154')
-rw-r--r--net/mac802154/rx.c2
-rw-r--r--net/mac802154/wpan.c26
2 files changed, 13 insertions, 15 deletions
diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c
index 03855b0677cc..0597b96dc9ba 100644
--- a/net/mac802154/rx.c
+++ b/net/mac802154/rx.c
@@ -59,8 +59,6 @@ mac802154_subif_rx(struct ieee802154_dev *hw, struct sk_buff *skb, u8 lqi)
59 skb->protocol = htons(ETH_P_IEEE802154); 59 skb->protocol = htons(ETH_P_IEEE802154);
60 skb_reset_mac_header(skb); 60 skb_reset_mac_header(skb);
61 61
62 BUILD_BUG_ON(sizeof(struct ieee802154_mac_cb) > sizeof(skb->cb));
63
64 if (!(priv->hw.flags & IEEE802154_HW_OMIT_CKSUM)) { 62 if (!(priv->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
65 u16 crc; 63 u16 crc;
66 64
diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c
index cb34064d05f6..bb49e88c460f 100644
--- a/net/mac802154/wpan.c
+++ b/net/mac802154/wpan.c
@@ -192,15 +192,17 @@ static int mac802154_header_create(struct sk_buff *skb,
192{ 192{
193 struct ieee802154_hdr hdr; 193 struct ieee802154_hdr hdr;
194 struct mac802154_sub_if_data *priv = netdev_priv(dev); 194 struct mac802154_sub_if_data *priv = netdev_priv(dev);
195 struct ieee802154_mac_cb *cb = mac_cb(skb);
195 int hlen; 196 int hlen;
196 197
197 if (!daddr) 198 if (!daddr)
198 return -EINVAL; 199 return -EINVAL;
199 200
200 memset(&hdr.fc, 0, sizeof(hdr.fc)); 201 memset(&hdr.fc, 0, sizeof(hdr.fc));
201 hdr.fc.type = mac_cb_type(skb); 202 hdr.fc.type = cb->type;
202 hdr.fc.security_enabled = mac_cb_is_secen(skb); 203 hdr.fc.security_enabled = cb->secen;
203 hdr.fc.ack_request = mac_cb_is_ackreq(skb); 204 hdr.fc.ack_request = cb->ackreq;
205 hdr.seq = ieee802154_mlme_ops(dev)->get_dsn(dev);
204 206
205 if (!saddr) { 207 if (!saddr) {
206 spin_lock_bh(&priv->mib_lock); 208 spin_lock_bh(&priv->mib_lock);
@@ -391,12 +393,12 @@ mac802154_subif_frame(struct mac802154_sub_if_data *sdata, struct sk_buff *skb)
391 sdata->dev->stats.rx_packets++; 393 sdata->dev->stats.rx_packets++;
392 sdata->dev->stats.rx_bytes += skb->len; 394 sdata->dev->stats.rx_bytes += skb->len;
393 395
394 switch (mac_cb_type(skb)) { 396 switch (mac_cb(skb)->type) {
395 case IEEE802154_FC_TYPE_DATA: 397 case IEEE802154_FC_TYPE_DATA:
396 return mac802154_process_data(sdata->dev, skb); 398 return mac802154_process_data(sdata->dev, skb);
397 default: 399 default:
398 pr_warn("ieee802154: bad frame received (type = %d)\n", 400 pr_warn("ieee802154: bad frame received (type = %d)\n",
399 mac_cb_type(skb)); 401 mac_cb(skb)->type);
400 kfree_skb(skb); 402 kfree_skb(skb);
401 return NET_RX_DROP; 403 return NET_RX_DROP;
402 } 404 }
@@ -423,6 +425,7 @@ static int mac802154_parse_frame_start(struct sk_buff *skb)
423{ 425{
424 int hlen; 426 int hlen;
425 struct ieee802154_hdr hdr; 427 struct ieee802154_hdr hdr;
428 struct ieee802154_mac_cb *cb = mac_cb_init(skb);
426 429
427 hlen = ieee802154_hdr_pull(skb, &hdr); 430 hlen = ieee802154_hdr_pull(skb, &hdr);
428 if (hlen < 0) 431 if (hlen < 0)
@@ -433,18 +436,15 @@ static int mac802154_parse_frame_start(struct sk_buff *skb)
433 pr_debug("fc: %04x dsn: %02x\n", le16_to_cpup((__le16 *)&hdr.fc), 436 pr_debug("fc: %04x dsn: %02x\n", le16_to_cpup((__le16 *)&hdr.fc),
434 hdr.seq); 437 hdr.seq);
435 438
436 mac_cb(skb)->flags = hdr.fc.type; 439 cb->type = hdr.fc.type;
437 440 cb->ackreq = hdr.fc.ack_request;
438 if (hdr.fc.ack_request) 441 cb->secen = hdr.fc.security_enabled;
439 mac_cb(skb)->flags |= MAC_CB_FLAG_ACKREQ;
440 if (hdr.fc.security_enabled)
441 mac_cb(skb)->flags |= MAC_CB_FLAG_SECEN;
442 442
443 mac802154_print_addr("destination", &hdr.dest); 443 mac802154_print_addr("destination", &hdr.dest);
444 mac802154_print_addr("source", &hdr.source); 444 mac802154_print_addr("source", &hdr.source);
445 445
446 mac_cb(skb)->source = hdr.source; 446 cb->source = hdr.source;
447 mac_cb(skb)->dest = hdr.dest; 447 cb->dest = hdr.dest;
448 448
449 if (hdr.fc.security_enabled) { 449 if (hdr.fc.security_enabled) {
450 u64 key; 450 u64 key;