summaryrefslogtreecommitdiffstats
path: root/net/mac802154/iface.c
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2014-11-17 08:20:52 +0100
committerMarcel Holtmann <marcel@holtmann.org>2014-11-17 09:49:16 +0100
commit0e57547eb7f0aa99aba32b50c49dbd722a80d6fb (patch)
treeca66721d651bfa5ca441546976a83dc2b88af86b /net/mac802154/iface.c
parentieee802154: add new interface command (diff)
downloadlinux-0e57547eb7f0aa99aba32b50c49dbd722a80d6fb.tar.xz
linux-0e57547eb7f0aa99aba32b50c49dbd722a80d6fb.zip
ieee802154: setting extended address while iface add
This patch adds support for setting an extended address while registration a new interface. If ieee802154_is_valid_extended_addr getting as parameter and invalid extended address then the perm address is fallback. This is useful to make some default handling while for example default registration of a wpan interface while phy registration. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/mac802154/iface.c')
-rw-r--r--net/mac802154/iface.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c
index ba63ac93ae90..38dfc72d24b6 100644
--- a/net/mac802154/iface.c
+++ b/net/mac802154/iface.c
@@ -458,7 +458,7 @@ ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata,
struct net_device *
ieee802154_if_add(struct ieee802154_local *local, const char *name,
- enum nl802154_iftype type)
+ enum nl802154_iftype type, __le64 extended_addr)
{
struct net_device *ndev = NULL;
struct ieee802154_sub_if_data *sdata = NULL;
@@ -477,9 +477,16 @@ ieee802154_if_add(struct ieee802154_local *local, const char *name,
if (ret < 0)
goto err;
+ ieee802154_le64_to_be64(ndev->perm_addr,
+ &local->hw.phy->perm_extended_addr);
switch (type) {
case NL802154_IFTYPE_NODE:
ndev->type = ARPHRD_IEEE802154;
+ if (ieee802154_is_valid_extended_addr(extended_addr))
+ ieee802154_le64_to_be64(ndev->dev_addr, &extended_addr);
+ else
+ memcpy(ndev->dev_addr, ndev->perm_addr,
+ IEEE802154_EXTENDED_ADDR_LEN);
break;
case NL802154_IFTYPE_MONITOR:
ndev->type = ARPHRD_IEEE802154_MONITOR;
@@ -489,9 +496,6 @@ ieee802154_if_add(struct ieee802154_local *local, const char *name,
goto err;
}
- ieee802154_le64_to_be64(ndev->perm_addr,
- &local->hw.phy->perm_extended_addr);
- memcpy(ndev->dev_addr, ndev->perm_addr, IEEE802154_EXTENDED_ADDR_LEN);
/* TODO check this */
SET_NETDEV_DEV(ndev, &local->phy->dev);
sdata = netdev_priv(ndev);