mac802154: propagate device address changes to llsec
authorPhoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
Fri, 16 May 2014 15:46:43 +0000 (17:46 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 May 2014 21:23:41 +0000 (17:23 -0400)
Signed-off-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/mac802154/mac_cmd.c
net/mac802154/wpan.c

index afb4e2cbc00a16572ae51098791d85cd1be8d966..bf809131eef776209040a8496ed1e2214e6bdebe 100644 (file)
@@ -40,6 +40,9 @@ static int mac802154_mlme_start_req(struct net_device *dev,
                                    u8 pan_coord, u8 blx,
                                    u8 coord_realign)
 {
+       struct ieee802154_mlme_ops *ops = ieee802154_mlme_ops(dev);
+       int rc = 0;
+
        BUG_ON(addr->mode != IEEE802154_ADDR_SHORT);
 
        mac802154_dev_set_pan_id(dev, addr->pan_id);
@@ -47,12 +50,31 @@ static int mac802154_mlme_start_req(struct net_device *dev,
        mac802154_dev_set_ieee_addr(dev);
        mac802154_dev_set_page_channel(dev, page, channel);
 
+       if (ops->llsec) {
+               struct ieee802154_llsec_params params;
+               int changed = 0;
+
+               params.coord_shortaddr = addr->short_addr;
+               changed |= IEEE802154_LLSEC_PARAM_COORD_SHORTADDR;
+
+               params.pan_id = addr->pan_id;
+               changed |= IEEE802154_LLSEC_PARAM_PAN_ID;
+
+               params.hwaddr = ieee802154_devaddr_from_raw(dev->dev_addr);
+               changed |= IEEE802154_LLSEC_PARAM_HWADDR;
+
+               params.coord_hwaddr = params.hwaddr;
+               changed |= IEEE802154_LLSEC_PARAM_COORD_HWADDR;
+
+               rc = ops->llsec->set_params(dev, &params, changed);
+       }
+
        /* FIXME: add validation for unused parameters to be sane
         * for SoftMAC
         */
        ieee802154_nl_start_confirm(dev, IEEE802154_SUCCESS);
 
-       return 0;
+       return rc;
 }
 
 static struct wpan_phy *mac802154_get_phy(const struct net_device *dev)
index 00729ca1e30acaa5e37676b06b48c2f8e0b4319a..23bc91cf99c465232b0b2406f29a9bcd2b539b98 100644 (file)
 
 #include "mac802154.h"
 
+static int mac802154_wpan_update_llsec(struct net_device *dev)
+{
+       struct mac802154_sub_if_data *priv = netdev_priv(dev);
+       struct ieee802154_mlme_ops *ops = ieee802154_mlme_ops(dev);
+       int rc = 0;
+
+       if (ops->llsec) {
+               struct ieee802154_llsec_params params;
+               int changed = 0;
+
+               params.pan_id = priv->pan_id;
+               changed |= IEEE802154_LLSEC_PARAM_PAN_ID;
+
+               params.hwaddr = priv->extended_addr;
+               changed |= IEEE802154_LLSEC_PARAM_HWADDR;
+
+               rc = ops->llsec->set_params(dev, &params, changed);
+       }
+
+       return rc;
+}
+
 static int
 mac802154_wpan_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
@@ -81,7 +103,7 @@ mac802154_wpan_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                priv->pan_id = cpu_to_le16(sa->addr.pan_id);
                priv->short_addr = cpu_to_le16(sa->addr.short_addr);
 
-               err = 0;
+               err = mac802154_wpan_update_llsec(dev);
                break;
        }
 
@@ -99,7 +121,7 @@ static int mac802154_wpan_mac_addr(struct net_device *dev, void *p)
        /* FIXME: validate addr */
        memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
        mac802154_dev_set_ieee_addr(dev);
-       return 0;
+       return mac802154_wpan_update_llsec(dev);
 }
 
 int mac802154_set_mac_params(struct net_device *dev,