summaryrefslogtreecommitdiffstats
path: root/net/ieee802154/af_ieee802154.c
diff options
context:
space:
mode:
authorPhoebe Buckheister2014-03-14 21:24:01 +0100
committerDavid S. Miller2014-03-15 03:15:26 +0100
commite6278d92005e9d6e374f269b4ce39c908a68ad5d (patch)
tree4991dd3441843d55104c0fdba78cf36ed5d75034 /net/ieee802154/af_ieee802154.c
parentieee802154: add header structs with endiannes and operations (diff)
downloadkernel-qcow2-linux-e6278d92005e9d6e374f269b4ce39c908a68ad5d.tar.gz
kernel-qcow2-linux-e6278d92005e9d6e374f269b4ce39c908a68ad5d.tar.xz
kernel-qcow2-linux-e6278d92005e9d6e374f269b4ce39c908a68ad5d.zip
mac802154: use header operations to create/parse headers
Use the operations on 802.15.4 header structs introduced in a previous patch to create and parse all headers in the mac802154 stack. This patch reduces code duplication between different parts of the mac802154 stack that needed information from headers, and also fixes a few bugs that seem to have gone unnoticed until now: * 802.15.4 dgram sockets would return a slightly incorrect value for the SIOCINQ ioctl * mac802154 would not drop frames with the "security enabled" bit set, even though it does not support security, in violation of the standard Signed-off-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ieee802154/af_ieee802154.c')
-rw-r--r--net/ieee802154/af_ieee802154.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/net/ieee802154/af_ieee802154.c b/net/ieee802154/af_ieee802154.c
index 973cb11da42b..be44a86751aa 100644
--- a/net/ieee802154/af_ieee802154.c
+++ b/net/ieee802154/af_ieee802154.c
@@ -43,25 +43,27 @@
/*
* Utility function for families
*/
-struct net_device *ieee802154_get_dev(struct net *net,
- struct ieee802154_addr_sa *addr)
+struct net_device*
+ieee802154_get_dev(struct net *net, const struct ieee802154_addr *addr)
{
struct net_device *dev = NULL;
struct net_device *tmp;
__le16 pan_id, short_addr;
+ u8 hwaddr[IEEE802154_ADDR_LEN];
- switch (addr->addr_type) {
+ switch (addr->mode) {
case IEEE802154_ADDR_LONG:
+ ieee802154_devaddr_to_raw(hwaddr, addr->extended_addr);
rcu_read_lock();
- dev = dev_getbyhwaddr_rcu(net, ARPHRD_IEEE802154, addr->hwaddr);
+ dev = dev_getbyhwaddr_rcu(net, ARPHRD_IEEE802154, hwaddr);
if (dev)
dev_hold(dev);
rcu_read_unlock();
break;
case IEEE802154_ADDR_SHORT:
- if (addr->pan_id == IEEE802154_PANID_BROADCAST ||
- addr->short_addr == IEEE802154_ADDR_UNDEF ||
- addr->short_addr == IEEE802154_ADDR_UNDEF)
+ if (addr->pan_id == cpu_to_le16(IEEE802154_PANID_BROADCAST) ||
+ addr->short_addr == cpu_to_le16(IEEE802154_ADDR_UNDEF) ||
+ addr->short_addr == cpu_to_le16(IEEE802154_ADDR_UNDEF))
break;
rtnl_lock();
@@ -74,8 +76,8 @@ struct net_device *ieee802154_get_dev(struct net *net,
short_addr =
ieee802154_mlme_ops(tmp)->get_short_addr(tmp);
- if (le16_to_cpu(pan_id) == addr->pan_id &&
- le16_to_cpu(short_addr) == addr->short_addr) {
+ if (pan_id == addr->pan_id &&
+ short_addr == addr->short_addr) {
dev = tmp;
dev_hold(dev);
break;
@@ -86,7 +88,7 @@ struct net_device *ieee802154_get_dev(struct net *net,
break;
default:
pr_warning("Unsupported ieee802154 address type: %d\n",
- addr->addr_type);
+ addr->mode);
break;
}