netdev: Add netdev_get_wdev_id

This commit is contained in:
Andrew Zaborowski 2019-07-08 16:02:58 +02:00 committed by Denis Kenzior
parent bc45f98f36
commit 8cada9d1fc
2 changed files with 21 additions and 2 deletions

View File

@ -83,6 +83,7 @@ struct netdev_handshake_state {
struct netdev {
uint32_t index;
uint64_t wdev_id;
char name[IFNAMSIZ];
uint32_t type;
uint8_t addr[ETH_ALEN];
@ -259,6 +260,11 @@ uint32_t netdev_get_ifindex(struct netdev *netdev)
return netdev->index;
}
uint64_t netdev_get_wdev_id(struct netdev *netdev)
{
return netdev->wdev_id;
}
enum netdev_iftype netdev_get_iftype(struct netdev *netdev)
{
switch (netdev->type) {
@ -4385,6 +4391,7 @@ struct netdev *netdev_create_from_genl(struct l_genl_msg *msg, bool random_mac)
uint16_t ifname_len = 0;
const uint8_t *ifaddr = NULL;
const uint32_t *ifindex = NULL, *iftype = NULL;
const uint64_t *wdev = NULL;
struct netdev *netdev;
struct wiphy *wiphy = NULL;
struct ifinfomsg *rtmmsg;
@ -4411,6 +4418,15 @@ struct netdev *netdev_create_from_genl(struct l_genl_msg *msg, bool random_mac)
ifindex = data;
break;
case NL80211_ATTR_WDEV:
if (len != sizeof(uint64_t)) {
l_warn("Invalid wdev attribute");
return NULL;
}
wdev = data;
break;
case NL80211_ATTR_IFNAME:
if (len > IFNAMSIZ) {
l_warn("Invalid interface name attribute");
@ -4455,7 +4471,7 @@ struct netdev *netdev_create_from_genl(struct l_genl_msg *msg, bool random_mac)
return NULL;
}
if (!wiphy || !ifindex || !ifaddr || !ifname) {
if (!wiphy || !ifindex || !wdev || !ifaddr || !ifname) {
l_warn("Unable to parse interface information");
return NULL;
}
@ -4489,6 +4505,7 @@ struct netdev *netdev_create_from_genl(struct l_genl_msg *msg, bool random_mac)
netdev = l_new(struct netdev, 1);
netdev->index = *ifindex;
netdev->wdev_id = *wdev;
netdev->type = *iftype;
netdev->rekey_offload_support = true;
memcpy(netdev->addr, ifaddr, sizeof(netdev->addr));
@ -4508,7 +4525,8 @@ struct netdev *netdev_create_from_genl(struct l_genl_msg *msg, bool random_mac)
l_queue_push_tail(netdev_list, netdev);
l_debug("Created interface %s[%d]", netdev->name, netdev->index);
l_debug("Created interface %s[%d %" PRIx64 "]", netdev->name,
netdev->index, netdev->wdev_id);
/* Query interface flags */
bufsize = NLMSG_ALIGN(sizeof(struct ifinfomsg));

View File

@ -127,6 +127,7 @@ typedef void (*netdev_station_watch_func_t)(struct netdev *netdev,
struct wiphy *netdev_get_wiphy(struct netdev *netdev);
const uint8_t *netdev_get_address(struct netdev *netdev);
uint32_t netdev_get_ifindex(struct netdev *netdev);
uint64_t netdev_get_wdev_id(struct netdev *netdev);
enum netdev_iftype netdev_get_iftype(struct netdev *netdev);
int netdev_set_iftype(struct netdev *netdev, enum netdev_iftype type,
netdev_command_cb_t cb, void *user_data,