Commit 4710d806 authored by Varka Bhadram's avatar Varka Bhadram Committed by David S. Miller

6lowpan: mac802154: fix coding style issues

This patch fixed the coding style issues reported by checkpatch.pl

following issues fixed:
	CHECK: Alignment should match open parenthesis
	WARNING: line over 80 characters
	CHECK: Blank lines aren't necessary before a close brace '}'
	WARNING: networking block comments don't use an empty /* line, use /* Comment...
	WARNING: Missing a blank line after declarations
	WARNING: networking block comments start with * on subsequent lines
	CHECK: braces {} should be used on all arms of this statement
Signed-off-by: default avatarVarka Bhadram <varkab@cdac.in>
Tested-by: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 46c9521f
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
* written by Alexander Smirnov <alex.bluesman.smirnov@gmail.com> * written by Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
*/ */
/* /* Based on patches from Jon Smirl <jonsmirl@gmail.com>
* Based on patches from Jon Smirl <jonsmirl@gmail.com>
* Copyright (c) 2011 Jon Smirl <jonsmirl@gmail.com> * Copyright (c) 2011 Jon Smirl <jonsmirl@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -58,16 +57,15 @@ ...@@ -58,16 +57,15 @@
#include <net/ipv6.h> #include <net/ipv6.h>
#include <net/af_ieee802154.h> #include <net/af_ieee802154.h>
/* /* Uncompress address function for source and
* Uncompress address function for source and
* destination address(non-multicast). * destination address(non-multicast).
* *
* address_mode is sam value or dam value. * address_mode is sam value or dam value.
*/ */
static int uncompress_addr(struct sk_buff *skb, static int uncompress_addr(struct sk_buff *skb,
struct in6_addr *ipaddr, const u8 address_mode, struct in6_addr *ipaddr, const u8 address_mode,
const u8 *lladdr, const u8 addr_type, const u8 *lladdr, const u8 addr_type,
const u8 addr_len) const u8 addr_len)
{ {
bool fail; bool fail;
...@@ -140,13 +138,12 @@ static int uncompress_addr(struct sk_buff *skb, ...@@ -140,13 +138,12 @@ static int uncompress_addr(struct sk_buff *skb,
return 0; return 0;
} }
/* /* Uncompress address function for source context
* Uncompress address function for source context
* based address(non-multicast). * based address(non-multicast).
*/ */
static int uncompress_context_based_src_addr(struct sk_buff *skb, static int uncompress_context_based_src_addr(struct sk_buff *skb,
struct in6_addr *ipaddr, struct in6_addr *ipaddr,
const u8 sam) const u8 sam)
{ {
switch (sam) { switch (sam) {
case LOWPAN_IPHC_ADDR_00: case LOWPAN_IPHC_ADDR_00:
...@@ -175,13 +172,13 @@ static int uncompress_context_based_src_addr(struct sk_buff *skb, ...@@ -175,13 +172,13 @@ static int uncompress_context_based_src_addr(struct sk_buff *skb,
} }
static int skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr, static int skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr,
struct net_device *dev, skb_delivery_cb deliver_skb) struct net_device *dev, skb_delivery_cb deliver_skb)
{ {
struct sk_buff *new; struct sk_buff *new;
int stat; int stat;
new = skb_copy_expand(skb, sizeof(struct ipv6hdr), skb_tailroom(skb), new = skb_copy_expand(skb, sizeof(struct ipv6hdr),
GFP_ATOMIC); skb_tailroom(skb), GFP_ATOMIC);
kfree_skb(skb); kfree_skb(skb);
if (!new) if (!new)
...@@ -196,7 +193,7 @@ static int skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr, ...@@ -196,7 +193,7 @@ static int skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr,
new->dev = dev; new->dev = dev;
raw_dump_table(__func__, "raw skb data dump before receiving", raw_dump_table(__func__, "raw skb data dump before receiving",
new->data, new->len); new->data, new->len);
stat = deliver_skb(new, dev); stat = deliver_skb(new, dev);
...@@ -210,8 +207,8 @@ static int skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr, ...@@ -210,8 +207,8 @@ static int skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr,
*/ */
static int static int
lowpan_uncompress_multicast_daddr(struct sk_buff *skb, lowpan_uncompress_multicast_daddr(struct sk_buff *skb,
struct in6_addr *ipaddr, struct in6_addr *ipaddr,
const u8 dam) const u8 dam)
{ {
bool fail; bool fail;
...@@ -314,8 +311,7 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh) ...@@ -314,8 +311,7 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
fail |= lowpan_fetch_skb(skb, &uh->check, 2); fail |= lowpan_fetch_skb(skb, &uh->check, 2);
} }
/* /* UDP lenght needs to be infered from the lower layers
* UDP lenght needs to be infered from the lower layers
* here, we obtain the hint from the remaining size of the * here, we obtain the hint from the remaining size of the
* frame * frame
*/ */
...@@ -338,16 +334,17 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh) ...@@ -338,16 +334,17 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
static const u8 lowpan_ttl_values[] = { 0, 1, 64, 255 }; static const u8 lowpan_ttl_values[] = { 0, 1, 64, 255 };
int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
const u8 *saddr, const u8 saddr_type, const u8 saddr_len, const u8 *saddr, const u8 saddr_type,
const u8 *daddr, const u8 daddr_type, const u8 daddr_len, const u8 saddr_len, const u8 *daddr,
u8 iphc0, u8 iphc1, skb_delivery_cb deliver_skb) const u8 daddr_type, const u8 daddr_len,
u8 iphc0, u8 iphc1, skb_delivery_cb deliver_skb)
{ {
struct ipv6hdr hdr = {}; struct ipv6hdr hdr = {};
u8 tmp, num_context = 0; u8 tmp, num_context = 0;
int err; int err;
raw_dump_table(__func__, "raw skb data dump uncompressed", raw_dump_table(__func__, "raw skb data dump uncompressed",
skb->data, skb->len); skb->data, skb->len);
/* another if the CID flag is set */ /* another if the CID flag is set */
if (iphc1 & LOWPAN_IPHC_CID) { if (iphc1 & LOWPAN_IPHC_CID) {
...@@ -360,8 +357,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, ...@@ -360,8 +357,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
/* Traffic Class and Flow Label */ /* Traffic Class and Flow Label */
switch ((iphc0 & LOWPAN_IPHC_TF) >> 3) { switch ((iphc0 & LOWPAN_IPHC_TF) >> 3) {
/* /* Traffic Class and FLow Label carried in-line
* Traffic Class and FLow Label carried in-line
* ECN + DSCP + 4-bit Pad + Flow Label (4 bytes) * ECN + DSCP + 4-bit Pad + Flow Label (4 bytes)
*/ */
case 0: /* 00b */ case 0: /* 00b */
...@@ -374,8 +370,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, ...@@ -374,8 +370,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
hdr.flow_lbl[0] = ((tmp >> 2) & 0x30) | (tmp << 6) | hdr.flow_lbl[0] = ((tmp >> 2) & 0x30) | (tmp << 6) |
(hdr.flow_lbl[0] & 0x0f); (hdr.flow_lbl[0] & 0x0f);
break; break;
/* /* Traffic class carried in-line
* Traffic class carried in-line
* ECN + DSCP (1 byte), Flow Label is elided * ECN + DSCP (1 byte), Flow Label is elided
*/ */
case 2: /* 10b */ case 2: /* 10b */
...@@ -385,8 +380,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, ...@@ -385,8 +380,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
hdr.priority = ((tmp >> 2) & 0x0f); hdr.priority = ((tmp >> 2) & 0x0f);
hdr.flow_lbl[0] = ((tmp << 6) & 0xC0) | ((tmp >> 2) & 0x30); hdr.flow_lbl[0] = ((tmp << 6) & 0xC0) | ((tmp >> 2) & 0x30);
break; break;
/* /* Flow Label carried in-line
* Flow Label carried in-line
* ECN + 2-bit Pad + Flow Label (3 bytes), DSCP is elided * ECN + 2-bit Pad + Flow Label (3 bytes), DSCP is elided
*/ */
case 1: /* 01b */ case 1: /* 01b */
...@@ -415,9 +409,9 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, ...@@ -415,9 +409,9 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
} }
/* Hop Limit */ /* Hop Limit */
if ((iphc0 & 0x03) != LOWPAN_IPHC_TTL_I) if ((iphc0 & 0x03) != LOWPAN_IPHC_TTL_I) {
hdr.hop_limit = lowpan_ttl_values[iphc0 & 0x03]; hdr.hop_limit = lowpan_ttl_values[iphc0 & 0x03];
else { } else {
if (lowpan_fetch_skb_u8(skb, &(hdr.hop_limit))) if (lowpan_fetch_skb_u8(skb, &(hdr.hop_limit)))
goto drop; goto drop;
} }
...@@ -429,12 +423,12 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, ...@@ -429,12 +423,12 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
/* Source address context based uncompression */ /* Source address context based uncompression */
pr_debug("SAC bit is set. Handle context based source address.\n"); pr_debug("SAC bit is set. Handle context based source address.\n");
err = uncompress_context_based_src_addr( err = uncompress_context_based_src_addr(
skb, &hdr.saddr, tmp); skb, &hdr.saddr, tmp);
} else { } else {
/* Source address uncompression */ /* Source address uncompression */
pr_debug("source address stateless compression\n"); pr_debug("source address stateless compression\n");
err = uncompress_addr(skb, &hdr.saddr, tmp, saddr, err = uncompress_addr(skb, &hdr.saddr, tmp, saddr,
saddr_type, saddr_len); saddr_type, saddr_len);
} }
/* Check on error of previous branch */ /* Check on error of previous branch */
...@@ -457,9 +451,9 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, ...@@ -457,9 +451,9 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
} }
} else { } else {
err = uncompress_addr(skb, &hdr.daddr, tmp, daddr, err = uncompress_addr(skb, &hdr.daddr, tmp, daddr,
daddr_type, daddr_len); daddr_type, daddr_len);
pr_debug("dest: stateless compression mode %d dest %pI6c\n", pr_debug("dest: stateless compression mode %d dest %pI6c\n",
tmp, &hdr.daddr); tmp, &hdr.daddr);
if (err) if (err)
goto drop; goto drop;
} }
...@@ -468,11 +462,11 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, ...@@ -468,11 +462,11 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
if (iphc0 & LOWPAN_IPHC_NH_C) { if (iphc0 & LOWPAN_IPHC_NH_C) {
struct udphdr uh; struct udphdr uh;
struct sk_buff *new; struct sk_buff *new;
if (uncompress_udp_header(skb, &uh)) if (uncompress_udp_header(skb, &uh))
goto drop; goto drop;
/* /* replace the compressed UDP head by the uncompressed UDP
* replace the compressed UDP head by the uncompressed UDP
* header * header
*/ */
new = skb_copy_expand(skb, sizeof(struct udphdr), new = skb_copy_expand(skb, sizeof(struct udphdr),
...@@ -489,7 +483,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, ...@@ -489,7 +483,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
skb_copy_to_linear_data(skb, &uh, sizeof(struct udphdr)); skb_copy_to_linear_data(skb, &uh, sizeof(struct udphdr));
raw_dump_table(__func__, "raw UDP header dump", raw_dump_table(__func__, "raw UDP header dump",
(u8 *)&uh, sizeof(uh)); (u8 *)&uh, sizeof(uh));
hdr.nexthdr = UIP_PROTO_UDP; hdr.nexthdr = UIP_PROTO_UDP;
} }
...@@ -504,8 +498,8 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, ...@@ -504,8 +498,8 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
hdr.version, ntohs(hdr.payload_len), hdr.nexthdr, hdr.version, ntohs(hdr.payload_len), hdr.nexthdr,
hdr.hop_limit, &hdr.daddr); hdr.hop_limit, &hdr.daddr);
raw_dump_table(__func__, "raw header dump", (u8 *)&hdr, raw_dump_table(__func__, "raw header dump",
sizeof(hdr)); (u8 *)&hdr, sizeof(hdr));
return skb_deliver(skb, &hdr, dev, deliver_skb); return skb_deliver(skb, &hdr, dev, deliver_skb);
...@@ -516,8 +510,8 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev, ...@@ -516,8 +510,8 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
EXPORT_SYMBOL_GPL(lowpan_process_data); EXPORT_SYMBOL_GPL(lowpan_process_data);
static u8 lowpan_compress_addr_64(u8 **hc06_ptr, u8 shift, static u8 lowpan_compress_addr_64(u8 **hc06_ptr, u8 shift,
const struct in6_addr *ipaddr, const struct in6_addr *ipaddr,
const unsigned char *lladdr) const unsigned char *lladdr)
{ {
u8 val = 0; u8 val = 0;
...@@ -530,14 +524,14 @@ static u8 lowpan_compress_addr_64(u8 **hc06_ptr, u8 shift, ...@@ -530,14 +524,14 @@ static u8 lowpan_compress_addr_64(u8 **hc06_ptr, u8 shift,
*hc06_ptr += 2; *hc06_ptr += 2;
val = 2; /* 16-bits */ val = 2; /* 16-bits */
raw_dump_inline(NULL, "Compressed ipv6 addr is (16 bits)", raw_dump_inline(NULL, "Compressed ipv6 addr is (16 bits)",
*hc06_ptr - 2, 2); *hc06_ptr - 2, 2);
} else { } else {
/* do not compress IID => xxxx::IID */ /* do not compress IID => xxxx::IID */
memcpy(*hc06_ptr, &ipaddr->s6_addr16[4], 8); memcpy(*hc06_ptr, &ipaddr->s6_addr16[4], 8);
*hc06_ptr += 8; *hc06_ptr += 8;
val = 1; /* 64-bits */ val = 1; /* 64-bits */
raw_dump_inline(NULL, "Compressed ipv6 addr is (64 bits)", raw_dump_inline(NULL, "Compressed ipv6 addr is (64 bits)",
*hc06_ptr - 8, 8); *hc06_ptr - 8, 8);
} }
return rol8(val, shift); return rol8(val, shift);
...@@ -601,8 +595,8 @@ static void compress_udp_header(u8 **hc06_ptr, struct sk_buff *skb) ...@@ -601,8 +595,8 @@ static void compress_udp_header(u8 **hc06_ptr, struct sk_buff *skb)
} }
int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
unsigned short type, const void *_daddr, unsigned short type, const void *_daddr,
const void *_saddr, unsigned int len) const void *_saddr, unsigned int len)
{ {
u8 tmp, iphc0, iphc1, *hc06_ptr; u8 tmp, iphc0, iphc1, *hc06_ptr;
struct ipv6hdr *hdr; struct ipv6hdr *hdr;
...@@ -616,14 +610,13 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, ...@@ -616,14 +610,13 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
pr_debug("IPv6 header dump:\n\tversion = %d\n\tlength = %d\n" pr_debug("IPv6 header dump:\n\tversion = %d\n\tlength = %d\n"
"\tnexthdr = 0x%02x\n\thop_lim = %d\n\tdest = %pI6c\n", "\tnexthdr = 0x%02x\n\thop_lim = %d\n\tdest = %pI6c\n",
hdr->version, ntohs(hdr->payload_len), hdr->nexthdr, hdr->version, ntohs(hdr->payload_len), hdr->nexthdr,
hdr->hop_limit, &hdr->daddr); hdr->hop_limit, &hdr->daddr);
raw_dump_table(__func__, "raw skb network header dump", raw_dump_table(__func__, "raw skb network header dump",
skb_network_header(skb), sizeof(struct ipv6hdr)); skb_network_header(skb), sizeof(struct ipv6hdr));
/* /* As we copy some bit-length fields, in the IPHC encoding bytes,
* As we copy some bit-length fields, in the IPHC encoding bytes,
* we sometimes use |= * we sometimes use |=
* If the field is 0, and the current bit value in memory is 1, * If the field is 0, and the current bit value in memory is 1,
* this does not work. We therefore reset the IPHC encoding here * this does not work. We therefore reset the IPHC encoding here
...@@ -639,11 +632,10 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, ...@@ -639,11 +632,10 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
(unsigned char *)_daddr, IEEE802154_ADDR_LEN); (unsigned char *)_daddr, IEEE802154_ADDR_LEN);
raw_dump_table(__func__, raw_dump_table(__func__,
"sending raw skb network uncompressed packet", "sending raw skb network uncompressed packet",
skb->data, skb->len); skb->data, skb->len);
/* /* Traffic class, flow label
* Traffic class, flow label
* If flow label is 0, compress it. If traffic class is 0, compress it * If flow label is 0, compress it. If traffic class is 0, compress it
* We have to process both in the same time as the offset of traffic * We have to process both in the same time as the offset of traffic
* class depends on the presence of version and flow label * class depends on the presence of version and flow label
...@@ -654,11 +646,11 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, ...@@ -654,11 +646,11 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
tmp = ((tmp & 0x03) << 6) | (tmp >> 2); tmp = ((tmp & 0x03) << 6) | (tmp >> 2);
if (((hdr->flow_lbl[0] & 0x0F) == 0) && if (((hdr->flow_lbl[0] & 0x0F) == 0) &&
(hdr->flow_lbl[1] == 0) && (hdr->flow_lbl[2] == 0)) { (hdr->flow_lbl[1] == 0) && (hdr->flow_lbl[2] == 0)) {
/* flow label can be compressed */ /* flow label can be compressed */
iphc0 |= LOWPAN_IPHC_FL_C; iphc0 |= LOWPAN_IPHC_FL_C;
if ((hdr->priority == 0) && if ((hdr->priority == 0) &&
((hdr->flow_lbl[0] & 0xF0) == 0)) { ((hdr->flow_lbl[0] & 0xF0) == 0)) {
/* compress (elide) all */ /* compress (elide) all */
iphc0 |= LOWPAN_IPHC_TC_C; iphc0 |= LOWPAN_IPHC_TC_C;
} else { } else {
...@@ -669,7 +661,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, ...@@ -669,7 +661,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
} else { } else {
/* Flow label cannot be compressed */ /* Flow label cannot be compressed */
if ((hdr->priority == 0) && if ((hdr->priority == 0) &&
((hdr->flow_lbl[0] & 0xF0) == 0)) { ((hdr->flow_lbl[0] & 0xF0) == 0)) {
/* compress only traffic class */ /* compress only traffic class */
iphc0 |= LOWPAN_IPHC_TC_C; iphc0 |= LOWPAN_IPHC_TC_C;
*hc06_ptr = (tmp & 0xc0) | (hdr->flow_lbl[0] & 0x0F); *hc06_ptr = (tmp & 0xc0) | (hdr->flow_lbl[0] & 0x0F);
...@@ -695,8 +687,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, ...@@ -695,8 +687,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
hc06_ptr += 1; hc06_ptr += 1;
} }
/* /* Hop limit
* Hop limit
* if 1: compress, encoding is 01 * if 1: compress, encoding is 01
* if 64: compress, encoding is 10 * if 64: compress, encoding is 10
* if 255: compress, encoding is 11 * if 255: compress, encoding is 11
...@@ -793,7 +784,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, ...@@ -793,7 +784,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
pr_debug("header len %d skb %u\n", (int)(hc06_ptr - head), skb->len); pr_debug("header len %d skb %u\n", (int)(hc06_ptr - head), skb->len);
raw_dump_table(__func__, "raw skb data dump compressed", raw_dump_table(__func__, "raw skb data dump compressed",
skb->data, skb->len); skb->data, skb->len);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(lowpan_header_compress); EXPORT_SYMBOL_GPL(lowpan_header_compress);
......
...@@ -80,14 +80,14 @@ lowpan_dev_info *lowpan_dev_info(const struct net_device *dev) ...@@ -80,14 +80,14 @@ lowpan_dev_info *lowpan_dev_info(const struct net_device *dev)
static inline void lowpan_address_flip(u8 *src, u8 *dest) static inline void lowpan_address_flip(u8 *src, u8 *dest)
{ {
int i; int i;
for (i = 0; i < IEEE802154_ADDR_LEN; i++) for (i = 0; i < IEEE802154_ADDR_LEN; i++)
(dest)[IEEE802154_ADDR_LEN - i - 1] = (src)[i]; (dest)[IEEE802154_ADDR_LEN - i - 1] = (src)[i];
} }
static int lowpan_header_create(struct sk_buff *skb, static int lowpan_header_create(struct sk_buff *skb, struct net_device *dev,
struct net_device *dev, unsigned short type, const void *_daddr,
unsigned short type, const void *_daddr, const void *_saddr, unsigned int len)
const void *_saddr, unsigned int len)
{ {
const u8 *saddr = _saddr; const u8 *saddr = _saddr;
const u8 *daddr = _daddr; const u8 *daddr = _daddr;
...@@ -144,7 +144,7 @@ static int lowpan_header_create(struct sk_buff *skb, ...@@ -144,7 +144,7 @@ static int lowpan_header_create(struct sk_buff *skb,
} }
static int lowpan_give_skb_to_devices(struct sk_buff *skb, static int lowpan_give_skb_to_devices(struct sk_buff *skb,
struct net_device *dev) struct net_device *dev)
{ {
struct lowpan_dev_record *entry; struct lowpan_dev_record *entry;
struct sk_buff *skb_cp; struct sk_buff *skb_cp;
...@@ -368,24 +368,28 @@ static netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -368,24 +368,28 @@ static netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev)
static struct wpan_phy *lowpan_get_phy(const struct net_device *dev) static struct wpan_phy *lowpan_get_phy(const struct net_device *dev)
{ {
struct net_device *real_dev = lowpan_dev_info(dev)->real_dev; struct net_device *real_dev = lowpan_dev_info(dev)->real_dev;
return ieee802154_mlme_ops(real_dev)->get_phy(real_dev); return ieee802154_mlme_ops(real_dev)->get_phy(real_dev);
} }
static __le16 lowpan_get_pan_id(const struct net_device *dev) static __le16 lowpan_get_pan_id(const struct net_device *dev)
{ {
struct net_device *real_dev = lowpan_dev_info(dev)->real_dev; struct net_device *real_dev = lowpan_dev_info(dev)->real_dev;
return ieee802154_mlme_ops(real_dev)->get_pan_id(real_dev); return ieee802154_mlme_ops(real_dev)->get_pan_id(real_dev);
} }
static __le16 lowpan_get_short_addr(const struct net_device *dev) static __le16 lowpan_get_short_addr(const struct net_device *dev)
{ {
struct net_device *real_dev = lowpan_dev_info(dev)->real_dev; struct net_device *real_dev = lowpan_dev_info(dev)->real_dev;
return ieee802154_mlme_ops(real_dev)->get_short_addr(real_dev); return ieee802154_mlme_ops(real_dev)->get_short_addr(real_dev);
} }
static u8 lowpan_get_dsn(const struct net_device *dev) static u8 lowpan_get_dsn(const struct net_device *dev)
{ {
struct net_device *real_dev = lowpan_dev_info(dev)->real_dev; struct net_device *real_dev = lowpan_dev_info(dev)->real_dev;
return ieee802154_mlme_ops(real_dev)->get_dsn(real_dev); return ieee802154_mlme_ops(real_dev)->get_dsn(real_dev);
} }
...@@ -454,7 +458,7 @@ static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[]) ...@@ -454,7 +458,7 @@ static int lowpan_validate(struct nlattr *tb[], struct nlattr *data[])
} }
static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev, static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev) struct packet_type *pt, struct net_device *orig_dev)
{ {
struct ieee802154_hdr hdr; struct ieee802154_hdr hdr;
int ret; int ret;
......
...@@ -40,9 +40,7 @@ ...@@ -40,9 +40,7 @@
#include "af802154.h" #include "af802154.h"
/* /* Utility function for families */
* Utility function for families
*/
struct net_device* struct net_device*
ieee802154_get_dev(struct net *net, const struct ieee802154_addr *addr) ieee802154_get_dev(struct net *net, const struct ieee802154_addr *addr)
{ {
...@@ -87,8 +85,8 @@ ieee802154_get_dev(struct net *net, const struct ieee802154_addr *addr) ...@@ -87,8 +85,8 @@ ieee802154_get_dev(struct net *net, const struct ieee802154_addr *addr)
rtnl_unlock(); rtnl_unlock();
break; break;
default: default:
pr_warning("Unsupported ieee802154 address type: %d\n", pr_warn("Unsupported ieee802154 address type: %d\n",
addr->mode); addr->mode);
break; break;
} }
...@@ -106,7 +104,7 @@ static int ieee802154_sock_release(struct socket *sock) ...@@ -106,7 +104,7 @@ static int ieee802154_sock_release(struct socket *sock)
return 0; return 0;
} }
static int ieee802154_sock_sendmsg(struct kiocb *iocb, struct socket *sock, static int ieee802154_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t len) struct msghdr *msg, size_t len)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
...@@ -114,7 +112,7 @@ static int ieee802154_sock_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -114,7 +112,7 @@ static int ieee802154_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
} }
static int ieee802154_sock_bind(struct socket *sock, struct sockaddr *uaddr, static int ieee802154_sock_bind(struct socket *sock, struct sockaddr *uaddr,
int addr_len) int addr_len)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
...@@ -125,7 +123,7 @@ static int ieee802154_sock_bind(struct socket *sock, struct sockaddr *uaddr, ...@@ -125,7 +123,7 @@ static int ieee802154_sock_bind(struct socket *sock, struct sockaddr *uaddr,
} }
static int ieee802154_sock_connect(struct socket *sock, struct sockaddr *uaddr, static int ieee802154_sock_connect(struct socket *sock, struct sockaddr *uaddr,
int addr_len, int flags) int addr_len, int flags)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
...@@ -139,7 +137,7 @@ static int ieee802154_sock_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -139,7 +137,7 @@ static int ieee802154_sock_connect(struct socket *sock, struct sockaddr *uaddr,
} }
static int ieee802154_dev_ioctl(struct sock *sk, struct ifreq __user *arg, static int ieee802154_dev_ioctl(struct sock *sk, struct ifreq __user *arg,
unsigned int cmd) unsigned int cmd)
{ {
struct ifreq ifr; struct ifreq ifr;
int ret = -ENOIOCTLCMD; int ret = -ENOIOCTLCMD;
...@@ -167,7 +165,7 @@ static int ieee802154_dev_ioctl(struct sock *sk, struct ifreq __user *arg, ...@@ -167,7 +165,7 @@ static int ieee802154_dev_ioctl(struct sock *sk, struct ifreq __user *arg,
} }
static int ieee802154_sock_ioctl(struct socket *sock, unsigned int cmd, static int ieee802154_sock_ioctl(struct socket *sock, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
...@@ -238,8 +236,7 @@ static const struct proto_ops ieee802154_dgram_ops = { ...@@ -238,8 +236,7 @@ static const struct proto_ops ieee802154_dgram_ops = {
}; };
/* /* Create a socket. Initialise the socket, blank the addresses
* Create a socket. Initialise the socket, blank the addresses
* set the state. * set the state.
*/ */
static int ieee802154_create(struct net *net, struct socket *sock, static int ieee802154_create(struct net *net, struct socket *sock,
...@@ -301,13 +298,14 @@ static const struct net_proto_family ieee802154_family_ops = { ...@@ -301,13 +298,14 @@ static const struct net_proto_family ieee802154_family_ops = {
}; };
static int ieee802154_rcv(struct sk_buff *skb, struct net_device *dev, static int ieee802154_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev) struct packet_type *pt, struct net_device *orig_dev)
{ {
if (!netif_running(dev)) if (!netif_running(dev))
goto drop; goto drop;
pr_debug("got frame, type %d, dev %p\n", dev->type, dev); pr_debug("got frame, type %d, dev %p\n", dev->type, dev);
#ifdef DEBUG #ifdef DEBUG
print_hex_dump_bytes("ieee802154_rcv ", DUMP_PREFIX_NONE, skb->data, skb->len); print_hex_dump_bytes("ieee802154_rcv ",
DUMP_PREFIX_NONE, skb->data, skb->len);
#endif #endif
if (!net_eq(dev_net(dev), &init_net)) if (!net_eq(dev_net(dev), &init_net))
......
...@@ -149,8 +149,7 @@ static int dgram_ioctl(struct sock *sk, int cmd, unsigned long arg) ...@@ -149,8 +149,7 @@ static int dgram_ioctl(struct sock *sk, int cmd, unsigned long arg)
spin_lock_bh(&sk->sk_receive_queue.lock); spin_lock_bh(&sk->sk_receive_queue.lock);
skb = skb_peek(&sk->sk_receive_queue); skb = skb_peek(&sk->sk_receive_queue);
if (skb != NULL) { if (skb != NULL) {
/* /* We will only return the amount
* We will only return the amount
* of this packet since that is all * of this packet since that is all
* that will be read. * that will be read.
*/ */
...@@ -161,12 +160,13 @@ static int dgram_ioctl(struct sock *sk, int cmd, unsigned long arg) ...@@ -161,12 +160,13 @@ static int dgram_ioctl(struct sock *sk, int cmd, unsigned long arg)
} }
} }
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
/* FIXME: autobind */ /* FIXME: autobind */
static int dgram_connect(struct sock *sk, struct sockaddr *uaddr, static int dgram_connect(struct sock *sk, struct sockaddr *uaddr,
int len) int len)
{ {
struct sockaddr_ieee802154 *addr = (struct sockaddr_ieee802154 *)uaddr; struct sockaddr_ieee802154 *addr = (struct sockaddr_ieee802154 *)uaddr;
struct dgram_sock *ro = dgram_sk(sk); struct dgram_sock *ro = dgram_sk(sk);
...@@ -205,7 +205,7 @@ static int dgram_disconnect(struct sock *sk, int flags) ...@@ -205,7 +205,7 @@ static int dgram_disconnect(struct sock *sk, int flags)
} }
static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk, static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, size_t size) struct msghdr *msg, size_t size)
{ {
struct net_device *dev; struct net_device *dev;
unsigned int mtu; unsigned int mtu;
...@@ -248,8 +248,8 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -248,8 +248,8 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
hlen = LL_RESERVED_SPACE(dev); hlen = LL_RESERVED_SPACE(dev);
tlen = dev->needed_tailroom; tlen = dev->needed_tailroom;
skb = sock_alloc_send_skb(sk, hlen + tlen + size, skb = sock_alloc_send_skb(sk, hlen + tlen + size,
msg->msg_flags & MSG_DONTWAIT, msg->msg_flags & MSG_DONTWAIT,
&err); &err);
if (!skb) if (!skb)
goto out_dev; goto out_dev;
...@@ -262,7 +262,8 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -262,7 +262,8 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
cb->ackreq = ro->want_ack; cb->ackreq = ro->want_ack;
if (msg->msg_name) { if (msg->msg_name) {
DECLARE_SOCKADDR(struct sockaddr_ieee802154*, daddr, msg->msg_name); DECLARE_SOCKADDR(struct sockaddr_ieee802154*,
daddr, msg->msg_name);
ieee802154_addr_from_sa(&dst_addr, &daddr->addr); ieee802154_addr_from_sa(&dst_addr, &daddr->addr);
} else { } else {
...@@ -304,8 +305,8 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -304,8 +305,8 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
} }
static int dgram_recvmsg(struct kiocb *iocb, struct sock *sk, static int dgram_recvmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, size_t len, int noblock, int flags, struct msghdr *msg, size_t len, int noblock,
int *addr_len) int flags, int *addr_len)
{ {
size_t copied = 0; size_t copied = 0;
int err = -EOPNOTSUPP; int err = -EOPNOTSUPP;
...@@ -398,6 +399,7 @@ int ieee802154_dgram_deliver(struct net_device *dev, struct sk_buff *skb) ...@@ -398,6 +399,7 @@ int ieee802154_dgram_deliver(struct net_device *dev, struct sk_buff *skb)
dgram_sk(sk))) { dgram_sk(sk))) {
if (prev) { if (prev) {
struct sk_buff *clone; struct sk_buff *clone;
clone = skb_clone(skb, GFP_ATOMIC); clone = skb_clone(skb, GFP_ATOMIC);
if (clone) if (clone)
dgram_rcv_skb(prev, clone); dgram_rcv_skb(prev, clone);
...@@ -407,9 +409,9 @@ int ieee802154_dgram_deliver(struct net_device *dev, struct sk_buff *skb) ...@@ -407,9 +409,9 @@ int ieee802154_dgram_deliver(struct net_device *dev, struct sk_buff *skb)
} }
} }
if (prev) if (prev) {
dgram_rcv_skb(prev, skb); dgram_rcv_skb(prev, skb);
else { } else {
kfree_skb(skb); kfree_skb(skb);
ret = NET_RX_DROP; ret = NET_RX_DROP;
} }
...@@ -419,7 +421,7 @@ int ieee802154_dgram_deliver(struct net_device *dev, struct sk_buff *skb) ...@@ -419,7 +421,7 @@ int ieee802154_dgram_deliver(struct net_device *dev, struct sk_buff *skb)
} }
static int dgram_getsockopt(struct sock *sk, int level, int optname, static int dgram_getsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user *optlen) char __user *optval, int __user *optlen)
{ {
struct dgram_sock *ro = dgram_sk(sk); struct dgram_sock *ro = dgram_sk(sk);
...@@ -463,7 +465,7 @@ static int dgram_getsockopt(struct sock *sk, int level, int optname, ...@@ -463,7 +465,7 @@ static int dgram_getsockopt(struct sock *sk, int level, int optname,
} }
static int dgram_setsockopt(struct sock *sk, int level, int optname, static int dgram_setsockopt(struct sock *sk, int level, int optname,
char __user *optval, unsigned int optlen) char __user *optval, unsigned int optlen)
{ {
struct dgram_sock *ro = dgram_sk(sk); struct dgram_sock *ro = dgram_sk(sk);
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
......
...@@ -43,7 +43,7 @@ struct genl_info; ...@@ -43,7 +43,7 @@ struct genl_info;
struct sk_buff *ieee802154_nl_create(int flags, u8 req); struct sk_buff *ieee802154_nl_create(int flags, u8 req);
int ieee802154_nl_mcast(struct sk_buff *msg, unsigned int group); int ieee802154_nl_mcast(struct sk_buff *msg, unsigned int group);
struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info, struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info,
int flags, u8 req); int flags, u8 req);
int ieee802154_nl_reply(struct sk_buff *msg, struct genl_info *info); int ieee802154_nl_reply(struct sk_buff *msg, struct genl_info *info);
extern struct genl_family nl802154_family; extern struct genl_family nl802154_family;
......
...@@ -52,7 +52,7 @@ struct sk_buff *ieee802154_nl_create(int flags, u8 req) ...@@ -52,7 +52,7 @@ struct sk_buff *ieee802154_nl_create(int flags, u8 req)
spin_lock_irqsave(&ieee802154_seq_lock, f); spin_lock_irqsave(&ieee802154_seq_lock, f);
hdr = genlmsg_put(msg, 0, ieee802154_seq_num++, hdr = genlmsg_put(msg, 0, ieee802154_seq_num++,
&nl802154_family, flags, req); &nl802154_family, flags, req);
spin_unlock_irqrestore(&ieee802154_seq_lock, f); spin_unlock_irqrestore(&ieee802154_seq_lock, f);
if (!hdr) { if (!hdr) {
nlmsg_free(msg); nlmsg_free(msg);
...@@ -86,7 +86,7 @@ struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info, ...@@ -86,7 +86,7 @@ struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info,
return NULL; return NULL;
hdr = genlmsg_put_reply(msg, info, hdr = genlmsg_put_reply(msg, info,
&nl802154_family, flags, req); &nl802154_family, flags, req);
if (!hdr) { if (!hdr) {
nlmsg_free(msg); nlmsg_free(msg);
return NULL; return NULL;
......
...@@ -60,7 +60,8 @@ static __le16 nla_get_shortaddr(const struct nlattr *nla) ...@@ -60,7 +60,8 @@ static __le16 nla_get_shortaddr(const struct nlattr *nla)
} }
int ieee802154_nl_assoc_indic(struct net_device *dev, int ieee802154_nl_assoc_indic(struct net_device *dev,
struct ieee802154_addr *addr, u8 cap) struct ieee802154_addr *addr,
u8 cap)
{ {
struct sk_buff *msg; struct sk_buff *msg;
...@@ -93,7 +94,7 @@ int ieee802154_nl_assoc_indic(struct net_device *dev, ...@@ -93,7 +94,7 @@ int ieee802154_nl_assoc_indic(struct net_device *dev,
EXPORT_SYMBOL(ieee802154_nl_assoc_indic); EXPORT_SYMBOL(ieee802154_nl_assoc_indic);
int ieee802154_nl_assoc_confirm(struct net_device *dev, __le16 short_addr, int ieee802154_nl_assoc_confirm(struct net_device *dev, __le16 short_addr,
u8 status) u8 status)
{ {
struct sk_buff *msg; struct sk_buff *msg;
...@@ -119,7 +120,8 @@ int ieee802154_nl_assoc_confirm(struct net_device *dev, __le16 short_addr, ...@@ -119,7 +120,8 @@ int ieee802154_nl_assoc_confirm(struct net_device *dev, __le16 short_addr,
EXPORT_SYMBOL(ieee802154_nl_assoc_confirm); EXPORT_SYMBOL(ieee802154_nl_assoc_confirm);
int ieee802154_nl_disassoc_indic(struct net_device *dev, int ieee802154_nl_disassoc_indic(struct net_device *dev,
struct ieee802154_addr *addr, u8 reason) struct ieee802154_addr *addr,
u8 reason)
{ {
struct sk_buff *msg; struct sk_buff *msg;
...@@ -205,8 +207,9 @@ int ieee802154_nl_beacon_indic(struct net_device *dev, __le16 panid, ...@@ -205,8 +207,9 @@ int ieee802154_nl_beacon_indic(struct net_device *dev, __le16 panid,
EXPORT_SYMBOL(ieee802154_nl_beacon_indic); EXPORT_SYMBOL(ieee802154_nl_beacon_indic);
int ieee802154_nl_scan_confirm(struct net_device *dev, int ieee802154_nl_scan_confirm(struct net_device *dev,
u8 status, u8 scan_type, u32 unscanned, u8 page, u8 status, u8 scan_type,
u8 *edl/* , struct list_head *pan_desc_list */) u32 unscanned, u8 page,
u8 *edl/* , struct list_head *pan_desc_list */)
{ {
struct sk_buff *msg; struct sk_buff *msg;
...@@ -260,7 +263,7 @@ int ieee802154_nl_start_confirm(struct net_device *dev, u8 status) ...@@ -260,7 +263,7 @@ int ieee802154_nl_start_confirm(struct net_device *dev, u8 status)
EXPORT_SYMBOL(ieee802154_nl_start_confirm); EXPORT_SYMBOL(ieee802154_nl_start_confirm);
static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid, static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid,
u32 seq, int flags, struct net_device *dev) u32 seq, int flags, struct net_device *dev)
{ {
void *hdr; void *hdr;
struct wpan_phy *phy; struct wpan_phy *phy;
...@@ -270,7 +273,7 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid, ...@@ -270,7 +273,7 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid,
pr_debug("%s\n", __func__); pr_debug("%s\n", __func__);
hdr = genlmsg_put(msg, 0, seq, &nl802154_family, flags, hdr = genlmsg_put(msg, 0, seq, &nl802154_family, flags,
IEEE802154_LIST_IFACE); IEEE802154_LIST_IFACE);
if (!hdr) if (!hdr)
goto out; goto out;
...@@ -330,14 +333,16 @@ static struct net_device *ieee802154_nl_get_dev(struct genl_info *info) ...@@ -330,14 +333,16 @@ static struct net_device *ieee802154_nl_get_dev(struct genl_info *info)
if (info->attrs[IEEE802154_ATTR_DEV_NAME]) { if (info->attrs[IEEE802154_ATTR_DEV_NAME]) {
char name[IFNAMSIZ + 1]; char name[IFNAMSIZ + 1];
nla_strlcpy(name, info->attrs[IEEE802154_ATTR_DEV_NAME], nla_strlcpy(name, info->attrs[IEEE802154_ATTR_DEV_NAME],
sizeof(name)); sizeof(name));
dev = dev_get_by_name(&init_net, name); dev = dev_get_by_name(&init_net, name);
} else if (info->attrs[IEEE802154_ATTR_DEV_INDEX]) } else if (info->attrs[IEEE802154_ATTR_DEV_INDEX]) {
dev = dev_get_by_index(&init_net, dev = dev_get_by_index(&init_net,
nla_get_u32(info->attrs[IEEE802154_ATTR_DEV_INDEX])); nla_get_u32(info->attrs[IEEE802154_ATTR_DEV_INDEX]));
else } else {
return NULL; return NULL;
}
if (!dev) if (!dev)
return NULL; return NULL;
...@@ -435,7 +440,7 @@ int ieee802154_disassociate_req(struct sk_buff *skb, struct genl_info *info) ...@@ -435,7 +440,7 @@ int ieee802154_disassociate_req(struct sk_buff *skb, struct genl_info *info)
int ret = -EOPNOTSUPP; int ret = -EOPNOTSUPP;
if ((!info->attrs[IEEE802154_ATTR_DEST_HW_ADDR] && if ((!info->attrs[IEEE802154_ATTR_DEST_HW_ADDR] &&
!info->attrs[IEEE802154_ATTR_DEST_SHORT_ADDR]) || !info->attrs[IEEE802154_ATTR_DEST_SHORT_ADDR]) ||
!info->attrs[IEEE802154_ATTR_REASON]) !info->attrs[IEEE802154_ATTR_REASON])
return -EINVAL; return -EINVAL;
...@@ -464,8 +469,7 @@ int ieee802154_disassociate_req(struct sk_buff *skb, struct genl_info *info) ...@@ -464,8 +469,7 @@ int ieee802154_disassociate_req(struct sk_buff *skb, struct genl_info *info)
return ret; return ret;
} }
/* /* PANid, channel, beacon_order = 15, superframe_order = 15,
* PANid, channel, beacon_order = 15, superframe_order = 15,
* PAN_coordinator, battery_life_extension = 0, * PAN_coordinator, battery_life_extension = 0,
* coord_realignment = 0, security_enable = 0 * coord_realignment = 0, security_enable = 0
*/ */
...@@ -559,8 +563,8 @@ int ieee802154_scan_req(struct sk_buff *skb, struct genl_info *info) ...@@ -559,8 +563,8 @@ int ieee802154_scan_req(struct sk_buff *skb, struct genl_info *info)
page = 0; page = 0;
ret = ieee802154_mlme_ops(dev)->scan_req(dev, type, channels, page, ret = ieee802154_mlme_ops(dev)->scan_req(dev, type, channels,
duration); page, duration);
out: out:
dev_put(dev); dev_put(dev);
...@@ -570,7 +574,8 @@ int ieee802154_scan_req(struct sk_buff *skb, struct genl_info *info) ...@@ -570,7 +574,8 @@ int ieee802154_scan_req(struct sk_buff *skb, struct genl_info *info)
int ieee802154_list_iface(struct sk_buff *skb, struct genl_info *info) int ieee802154_list_iface(struct sk_buff *skb, struct genl_info *info)
{ {
/* Request for interface name, index, type, IEEE address, /* Request for interface name, index, type, IEEE address,
PAN Id, short address */ * PAN Id, short address
*/
struct sk_buff *msg; struct sk_buff *msg;
struct net_device *dev = NULL; struct net_device *dev = NULL;
int rc = -ENOBUFS; int rc = -ENOBUFS;
...@@ -586,7 +591,7 @@ int ieee802154_list_iface(struct sk_buff *skb, struct genl_info *info) ...@@ -586,7 +591,7 @@ int ieee802154_list_iface(struct sk_buff *skb, struct genl_info *info)
goto out_dev; goto out_dev;
rc = ieee802154_nl_fill_iface(msg, info->snd_portid, info->snd_seq, rc = ieee802154_nl_fill_iface(msg, info->snd_portid, info->snd_seq,
0, dev); 0, dev);
if (rc < 0) if (rc < 0)
goto out_free; goto out_free;
...@@ -598,7 +603,6 @@ int ieee802154_list_iface(struct sk_buff *skb, struct genl_info *info) ...@@ -598,7 +603,6 @@ int ieee802154_list_iface(struct sk_buff *skb, struct genl_info *info)
out_dev: out_dev:
dev_put(dev); dev_put(dev);
return rc; return rc;
} }
int ieee802154_dump_iface(struct sk_buff *skb, struct netlink_callback *cb) int ieee802154_dump_iface(struct sk_buff *skb, struct netlink_callback *cb)
...@@ -616,7 +620,8 @@ int ieee802154_dump_iface(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -616,7 +620,8 @@ int ieee802154_dump_iface(struct sk_buff *skb, struct netlink_callback *cb)
goto cont; goto cont;
if (ieee802154_nl_fill_iface(skb, NETLINK_CB(cb->skb).portid, if (ieee802154_nl_fill_iface(skb, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI, dev) < 0) cb->nlh->nlmsg_seq,
NLM_F_MULTI, dev) < 0)
break; break;
cont: cont:
idx++; idx++;
...@@ -765,6 +770,7 @@ ieee802154_llsec_parse_key_id(struct genl_info *info, ...@@ -765,6 +770,7 @@ ieee802154_llsec_parse_key_id(struct genl_info *info,
case IEEE802154_SCF_KEY_SHORT_INDEX: case IEEE802154_SCF_KEY_SHORT_INDEX:
{ {
u32 source = nla_get_u32(info->attrs[IEEE802154_ATTR_LLSEC_KEY_SOURCE_SHORT]); u32 source = nla_get_u32(info->attrs[IEEE802154_ATTR_LLSEC_KEY_SOURCE_SHORT]);
desc->short_source = cpu_to_le32(source); desc->short_source = cpu_to_le32(source);
break; break;
} }
...@@ -842,7 +848,7 @@ int ieee802154_llsec_getparams(struct sk_buff *skb, struct genl_info *info) ...@@ -842,7 +848,7 @@ int ieee802154_llsec_getparams(struct sk_buff *skb, struct genl_info *info)
goto out_dev; goto out_dev;
hdr = genlmsg_put(msg, 0, info->snd_seq, &nl802154_family, 0, hdr = genlmsg_put(msg, 0, info->snd_seq, &nl802154_family, 0,
IEEE802154_LLSEC_GETPARAMS); IEEE802154_LLSEC_GETPARAMS);
if (!hdr) if (!hdr)
goto out_free; goto out_free;
...@@ -946,7 +952,7 @@ struct llsec_dump_data { ...@@ -946,7 +952,7 @@ struct llsec_dump_data {
static int static int
ieee802154_llsec_dump_table(struct sk_buff *skb, struct netlink_callback *cb, ieee802154_llsec_dump_table(struct sk_buff *skb, struct netlink_callback *cb,
int (*step)(struct llsec_dump_data*)) int (*step)(struct llsec_dump_data *))
{ {
struct net *net = sock_net(skb->sk); struct net *net = sock_net(skb->sk);
struct net_device *dev; struct net_device *dev;
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "ieee802154.h" #include "ieee802154.h"
static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid, static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
u32 seq, int flags, struct wpan_phy *phy) u32 seq, int flags, struct wpan_phy *phy)
{ {
void *hdr; void *hdr;
int i, pages = 0; int i, pages = 0;
...@@ -48,7 +48,7 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid, ...@@ -48,7 +48,7 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
return -EMSGSIZE; return -EMSGSIZE;
hdr = genlmsg_put(msg, 0, seq, &nl802154_family, flags, hdr = genlmsg_put(msg, 0, seq, &nl802154_family, flags,
IEEE802154_LIST_PHY); IEEE802154_LIST_PHY);
if (!hdr) if (!hdr)
goto out; goto out;
...@@ -80,7 +80,8 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid, ...@@ -80,7 +80,8 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
int ieee802154_list_phy(struct sk_buff *skb, struct genl_info *info) int ieee802154_list_phy(struct sk_buff *skb, struct genl_info *info)
{ {
/* Request for interface name, index, type, IEEE address, /* Request for interface name, index, type, IEEE address,
PAN Id, short address */ * PAN Id, short address
*/
struct sk_buff *msg; struct sk_buff *msg;
struct wpan_phy *phy; struct wpan_phy *phy;
const char *name; const char *name;
...@@ -105,7 +106,7 @@ int ieee802154_list_phy(struct sk_buff *skb, struct genl_info *info) ...@@ -105,7 +106,7 @@ int ieee802154_list_phy(struct sk_buff *skb, struct genl_info *info)
goto out_dev; goto out_dev;
rc = ieee802154_nl_fill_phy(msg, info->snd_portid, info->snd_seq, rc = ieee802154_nl_fill_phy(msg, info->snd_portid, info->snd_seq,
0, phy); 0, phy);
if (rc < 0) if (rc < 0)
goto out_free; goto out_free;
...@@ -117,7 +118,6 @@ int ieee802154_list_phy(struct sk_buff *skb, struct genl_info *info) ...@@ -117,7 +118,6 @@ int ieee802154_list_phy(struct sk_buff *skb, struct genl_info *info)
out_dev: out_dev:
wpan_phy_put(phy); wpan_phy_put(phy);
return rc; return rc;
} }
struct dump_phy_data { struct dump_phy_data {
...@@ -137,10 +137,10 @@ static int ieee802154_dump_phy_iter(struct wpan_phy *phy, void *_data) ...@@ -137,10 +137,10 @@ static int ieee802154_dump_phy_iter(struct wpan_phy *phy, void *_data)
return 0; return 0;
rc = ieee802154_nl_fill_phy(data->skb, rc = ieee802154_nl_fill_phy(data->skb,
NETLINK_CB(data->cb->skb).portid, NETLINK_CB(data->cb->skb).portid,
data->cb->nlh->nlmsg_seq, data->cb->nlh->nlmsg_seq,
NLM_F_MULTI, NLM_F_MULTI,
phy); phy);
if (rc < 0) { if (rc < 0) {
data->idx--; data->idx--;
...@@ -238,10 +238,9 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) ...@@ -238,10 +238,9 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
addr.sa_family = ARPHRD_IEEE802154; addr.sa_family = ARPHRD_IEEE802154;
nla_memcpy(&addr.sa_data, info->attrs[IEEE802154_ATTR_HW_ADDR], nla_memcpy(&addr.sa_data, info->attrs[IEEE802154_ATTR_HW_ADDR],
IEEE802154_ADDR_LEN); IEEE802154_ADDR_LEN);
/* /* strangely enough, some callbacks (inetdev_event) from
* strangely enough, some callbacks (inetdev_event) from
* dev_set_mac_address require RTNL_LOCK * dev_set_mac_address require RTNL_LOCK
*/ */
rtnl_lock(); rtnl_lock();
......
...@@ -96,7 +96,7 @@ static int raw_bind(struct sock *sk, struct sockaddr *_uaddr, int len) ...@@ -96,7 +96,7 @@ static int raw_bind(struct sock *sk, struct sockaddr *_uaddr, int len)
} }
static int raw_connect(struct sock *sk, struct sockaddr *uaddr, static int raw_connect(struct sock *sk, struct sockaddr *uaddr,
int addr_len) int addr_len)
{ {
return -ENOTSUPP; return -ENOTSUPP;
} }
...@@ -106,8 +106,8 @@ static int raw_disconnect(struct sock *sk, int flags) ...@@ -106,8 +106,8 @@ static int raw_disconnect(struct sock *sk, int flags)
return 0; return 0;
} }
static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, static int raw_sendmsg(struct kiocb *iocb, struct sock *sk,
size_t size) struct msghdr *msg, size_t size)
{ {
struct net_device *dev; struct net_device *dev;
unsigned int mtu; unsigned int mtu;
...@@ -145,7 +145,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -145,7 +145,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
hlen = LL_RESERVED_SPACE(dev); hlen = LL_RESERVED_SPACE(dev);
tlen = dev->needed_tailroom; tlen = dev->needed_tailroom;
skb = sock_alloc_send_skb(sk, hlen + tlen + size, skb = sock_alloc_send_skb(sk, hlen + tlen + size,
msg->msg_flags & MSG_DONTWAIT, &err); msg->msg_flags & MSG_DONTWAIT, &err);
if (!skb) if (!skb)
goto out_dev; goto out_dev;
...@@ -235,7 +235,6 @@ void ieee802154_raw_deliver(struct net_device *dev, struct sk_buff *skb) ...@@ -235,7 +235,6 @@ void ieee802154_raw_deliver(struct net_device *dev, struct sk_buff *skb)
bh_lock_sock(sk); bh_lock_sock(sk);
if (!sk->sk_bound_dev_if || if (!sk->sk_bound_dev_if ||
sk->sk_bound_dev_if == dev->ifindex) { sk->sk_bound_dev_if == dev->ifindex) {
struct sk_buff *clone; struct sk_buff *clone;
clone = skb_clone(skb, GFP_ATOMIC); clone = skb_clone(skb, GFP_ATOMIC);
...@@ -248,13 +247,13 @@ void ieee802154_raw_deliver(struct net_device *dev, struct sk_buff *skb) ...@@ -248,13 +247,13 @@ void ieee802154_raw_deliver(struct net_device *dev, struct sk_buff *skb)
} }
static int raw_getsockopt(struct sock *sk, int level, int optname, static int raw_getsockopt(struct sock *sk, int level, int optname,
char __user *optval, int __user *optlen) char __user *optval, int __user *optlen)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static int raw_setsockopt(struct sock *sk, int level, int optname, static int raw_setsockopt(struct sock *sk, int level, int optname,
char __user *optval, unsigned int optlen) char __user *optval, unsigned int optlen)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -274,4 +273,3 @@ struct proto ieee802154_raw_prot = { ...@@ -274,4 +273,3 @@ struct proto ieee802154_raw_prot = {
.getsockopt = raw_getsockopt, .getsockopt = raw_getsockopt,
.setsockopt = raw_setsockopt, .setsockopt = raw_setsockopt,
}; };
...@@ -378,6 +378,7 @@ int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type) ...@@ -378,6 +378,7 @@ int lowpan_frag_rcv(struct sk_buff *skb, const u8 frag_type)
fq = fq_find(net, frag_info, &source, &dest); fq = fq_find(net, frag_info, &source, &dest);
if (fq != NULL) { if (fq != NULL) {
int ret; int ret;
spin_lock(&fq->q.lock); spin_lock(&fq->q.lock);
ret = lowpan_frag_queue(fq, skb, frag_type); ret = lowpan_frag_queue(fq, skb, frag_type);
spin_unlock(&fq->q.lock); spin_unlock(&fq->q.lock);
......
...@@ -48,7 +48,8 @@ MASTER_SHOW(transmit_power, "%d +- 1 dB"); ...@@ -48,7 +48,8 @@ MASTER_SHOW(transmit_power, "%d +- 1 dB");
MASTER_SHOW(cca_mode, "%d"); MASTER_SHOW(cca_mode, "%d");
static ssize_t channels_supported_show(struct device *dev, static ssize_t channels_supported_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr,
char *buf)
{ {
struct wpan_phy *phy = container_of(dev, struct wpan_phy, dev); struct wpan_phy *phy = container_of(dev, struct wpan_phy, dev);
int ret; int ret;
...@@ -57,7 +58,7 @@ static ssize_t channels_supported_show(struct device *dev, ...@@ -57,7 +58,7 @@ static ssize_t channels_supported_show(struct device *dev,
mutex_lock(&phy->pib_lock); mutex_lock(&phy->pib_lock);
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
ret = snprintf(buf + len, PAGE_SIZE - len, ret = snprintf(buf + len, PAGE_SIZE - len,
"%#09x\n", phy->channels_supported[i]); "%#09x\n", phy->channels_supported[i]);
if (ret < 0) if (ret < 0)
break; break;
len += ret; len += ret;
...@@ -80,6 +81,7 @@ ATTRIBUTE_GROUPS(pmib); ...@@ -80,6 +81,7 @@ ATTRIBUTE_GROUPS(pmib);
static void wpan_phy_release(struct device *d) static void wpan_phy_release(struct device *d)
{ {
struct wpan_phy *phy = container_of(d, struct wpan_phy, dev); struct wpan_phy *phy = container_of(d, struct wpan_phy, dev);
kfree(phy); kfree(phy);
} }
...@@ -121,11 +123,12 @@ static int wpan_phy_iter(struct device *dev, void *_data) ...@@ -121,11 +123,12 @@ static int wpan_phy_iter(struct device *dev, void *_data)
{ {
struct wpan_phy_iter_data *wpid = _data; struct wpan_phy_iter_data *wpid = _data;
struct wpan_phy *phy = container_of(dev, struct wpan_phy, dev); struct wpan_phy *phy = container_of(dev, struct wpan_phy, dev);
return wpid->fn(phy, wpid->data); return wpid->fn(phy, wpid->data);
} }
int wpan_phy_for_each(int (*fn)(struct wpan_phy *phy, void *data), int wpan_phy_for_each(int (*fn)(struct wpan_phy *phy, void *data),
void *data) void *data)
{ {
struct wpan_phy_iter_data wpid = { struct wpan_phy_iter_data wpid = {
.fn = fn, .fn = fn,
...@@ -197,6 +200,7 @@ EXPORT_SYMBOL(wpan_phy_free); ...@@ -197,6 +200,7 @@ EXPORT_SYMBOL(wpan_phy_free);
static int __init wpan_phy_class_init(void) static int __init wpan_phy_class_init(void)
{ {
int rc; int rc;
rc = class_register(&wpan_phy_class); rc = class_register(&wpan_phy_class);
if (rc) if (rc)
goto err; goto err;
......
...@@ -143,6 +143,7 @@ static void ...@@ -143,6 +143,7 @@ static void
mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev) mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev)
{ {
struct mac802154_sub_if_data *sdata; struct mac802154_sub_if_data *sdata;
ASSERT_RTNL(); ASSERT_RTNL();
sdata = netdev_priv(dev); sdata = netdev_priv(dev);
...@@ -276,7 +277,8 @@ ieee802154_alloc_device(size_t priv_data_len, struct ieee802154_ops *ops) ...@@ -276,7 +277,8 @@ ieee802154_alloc_device(size_t priv_data_len, struct ieee802154_ops *ops)
} }
priv = wpan_phy_priv(phy); priv = wpan_phy_priv(phy);
priv->hw.phy = priv->phy = phy; priv->phy = phy;
priv->hw.phy = priv->phy;
priv->hw.priv = (char *)priv + ALIGN(sizeof(*priv), NETDEV_ALIGN); priv->hw.priv = (char *)priv + ALIGN(sizeof(*priv), NETDEV_ALIGN);
priv->ops = ops; priv->ops = ops;
......
...@@ -538,6 +538,7 @@ static int llsec_recover_addr(struct mac802154_llsec *sec, ...@@ -538,6 +538,7 @@ static int llsec_recover_addr(struct mac802154_llsec *sec,
struct ieee802154_addr *addr) struct ieee802154_addr *addr)
{ {
__le16 caddr = sec->params.coord_shortaddr; __le16 caddr = sec->params.coord_shortaddr;
addr->pan_id = sec->params.pan_id; addr->pan_id = sec->params.pan_id;
if (caddr == cpu_to_le16(IEEE802154_ADDR_BROADCAST)) { if (caddr == cpu_to_le16(IEEE802154_ADDR_BROADCAST)) {
......
...@@ -175,9 +175,9 @@ static void phy_chan_notify(struct work_struct *work) ...@@ -175,9 +175,9 @@ static void phy_chan_notify(struct work_struct *work)
mutex_lock(&priv->hw->phy->pib_lock); mutex_lock(&priv->hw->phy->pib_lock);
res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan); res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan);
if (res) if (res) {
pr_debug("set_channel failed\n"); pr_debug("set_channel failed\n");
else { } else {
priv->hw->phy->current_channel = priv->chan; priv->hw->phy->current_channel = priv->chan;
priv->hw->phy->current_page = priv->page; priv->hw->phy->current_page = priv->page;
} }
...@@ -210,8 +210,9 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan) ...@@ -210,8 +210,9 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
INIT_WORK(&work->work, phy_chan_notify); INIT_WORK(&work->work, phy_chan_notify);
work->dev = dev; work->dev = dev;
queue_work(priv->hw->dev_workqueue, &work->work); queue_work(priv->hw->dev_workqueue, &work->work);
} else } else {
mutex_unlock(&priv->hw->phy->pib_lock); mutex_unlock(&priv->hw->phy->pib_lock);
}
} }
......
...@@ -98,6 +98,7 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb, ...@@ -98,6 +98,7 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
if (!(priv->hw.flags & IEEE802154_HW_OMIT_CKSUM)) { if (!(priv->hw.flags & IEEE802154_HW_OMIT_CKSUM)) {
u16 crc = crc_ccitt(0, skb->data, skb->len); u16 crc = crc_ccitt(0, skb->data, skb->len);
u8 *data = skb_put(skb, 2); u8 *data = skb_put(skb, 2);
data[0] = crc & 0xff; data[0] = crc & 0xff;
data[1] = crc >> 8; data[1] = crc >> 8;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment