mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 04:32:37 +01:00
netdev: Act on NEW_INTERFACE & DEL_INTERFACE cmds
This commit is contained in:
parent
37ea99d09e
commit
94f204b994
41
src/netdev.c
41
src/netdev.c
@ -1334,8 +1334,7 @@ check_blacklist:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void netdev_get_interface_callback(struct l_genl_msg *msg,
|
static void netdev_create_from_genl(struct l_genl_msg *msg)
|
||||||
void *user_data)
|
|
||||||
{
|
{
|
||||||
struct l_genl_attr attr;
|
struct l_genl_attr attr;
|
||||||
uint16_t type, len;
|
uint16_t type, len;
|
||||||
@ -1432,7 +1431,7 @@ static void netdev_get_interface_callback(struct l_genl_msg *msg,
|
|||||||
|
|
||||||
l_queue_push_tail(netdev_list, netdev);
|
l_queue_push_tail(netdev_list, netdev);
|
||||||
|
|
||||||
l_debug("Found interface %s[%d]", netdev->name, netdev->index);
|
l_debug("Created interface %s[%d]", netdev->name, netdev->index);
|
||||||
|
|
||||||
/* Query interface flags */
|
/* Query interface flags */
|
||||||
bufsize = NLMSG_LENGTH(sizeof(struct ifinfomsg));
|
bufsize = NLMSG_LENGTH(sizeof(struct ifinfomsg));
|
||||||
@ -1448,27 +1447,35 @@ static void netdev_get_interface_callback(struct l_genl_msg *msg,
|
|||||||
l_free(rtmmsg);
|
l_free(rtmmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void netdev_get_interface_callback(struct l_genl_msg *msg,
|
||||||
|
void *user_data)
|
||||||
|
{
|
||||||
|
netdev_create_from_genl(msg);
|
||||||
|
}
|
||||||
|
|
||||||
static void netdev_config_notify(struct l_genl_msg *msg, void *user_data)
|
static void netdev_config_notify(struct l_genl_msg *msg, void *user_data)
|
||||||
{
|
{
|
||||||
struct l_genl_attr attr;
|
struct l_genl_attr attr;
|
||||||
uint16_t type, len;
|
uint16_t type, len;
|
||||||
const void *data;
|
const void *data;
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
|
const uint32_t *wiphy_id = NULL;
|
||||||
|
const uint32_t *ifindex = NULL;
|
||||||
|
struct netdev *netdev;
|
||||||
|
|
||||||
cmd = l_genl_msg_get_command(msg);
|
cmd = l_genl_msg_get_command(msg);
|
||||||
|
|
||||||
l_debug("Notification of command %u", cmd);
|
if (cmd == NL80211_CMD_NEW_INTERFACE) {
|
||||||
|
netdev_create_from_genl(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd != NL80211_CMD_DEL_INTERFACE)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!l_genl_attr_init(&attr, msg))
|
if (!l_genl_attr_init(&attr, msg))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (cmd) {
|
|
||||||
case NL80211_CMD_NEW_INTERFACE:
|
|
||||||
case NL80211_CMD_DEL_INTERFACE:
|
|
||||||
{
|
|
||||||
const uint32_t *wiphy_id = NULL;
|
|
||||||
const uint32_t *ifindex = NULL;
|
|
||||||
|
|
||||||
while (l_genl_attr_next(&attr, &type, &len, &data)) {
|
while (l_genl_attr_next(&attr, &type, &len, &data)) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NL80211_ATTR_WIPHY:
|
case NL80211_ATTR_WIPHY:
|
||||||
@ -1494,14 +1501,12 @@ static void netdev_config_notify(struct l_genl_msg *msg, void *user_data)
|
|||||||
if (!wiphy_id || !ifindex)
|
if (!wiphy_id || !ifindex)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cmd == NL80211_CMD_NEW_INTERFACE)
|
netdev = l_queue_remove_if(netdev_list, netdev_match,
|
||||||
l_info("New interface %d added", *ifindex);
|
L_UINT_TO_PTR(*ifindex));
|
||||||
else
|
if (!netdev)
|
||||||
l_info("Interface %d removed", *ifindex);
|
return;
|
||||||
|
|
||||||
break;
|
netdev_free(netdev);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void netdev_link_notify(uint16_t type, const void *data, uint32_t len,
|
static void netdev_link_notify(uint16_t type, const void *data, uint32_t len,
|
||||||
|
Loading…
Reference in New Issue
Block a user