manager: Split up new_wiphy dumps & events

Separate out the two types of NEW_WIPHY handlers into separate paths and
factor out the common code into a utility function.

Dumps of CMD_NEW_WIPHY can be split up over several messages, while
CMD_NEW_WIPHY events (generated when a new card is plugged in) are
stuffed into a single message.

This also prepares ground for follow-on commits where we will handle the
two types of events differently.
This commit is contained in:
Denis Kenzior 2019-04-16 16:52:15 -05:00
parent 1b08602727
commit d99242846c
1 changed files with 31 additions and 18 deletions

View File

@ -381,30 +381,20 @@ static void manager_wiphy_dump_interfaces(struct wiphy_setup_state *state)
state->use_default = true;
}
static void manager_wiphy_setup_timeout(struct l_timeout *timeout,
void *user_data)
static struct wiphy_setup_state *manager_rx_cmd_new_wiphy(
struct l_genl_msg *msg)
{
struct wiphy_setup_state *state = user_data;
manager_wiphy_dump_interfaces(state);
}
static void manager_new_wiphy_event(struct l_genl_msg *msg)
{
struct wiphy_setup_state *state;
struct wiphy_setup_state *state = NULL;
struct wiphy *wiphy;
struct l_genl_attr attr;
uint32_t id;
const char *name;
if (!pending_wiphys)
return;
if (!l_genl_attr_init(&attr, msg))
return;
return NULL;
if (!wiphy_parse_id_and_name(&attr, &id, &name))
return;
return NULL;
/*
* A Wiphy split dump can generate many (6+) NEW_WIPHY messages
@ -417,7 +407,7 @@ static void manager_new_wiphy_event(struct l_genl_msg *msg)
wiphy = wiphy_create(id, name);
if (!wiphy)
return;
return NULL;
/*
* We've got a new wiphy, flag it as new and wait for a
@ -433,12 +423,35 @@ static void manager_new_wiphy_event(struct l_genl_msg *msg)
state = l_new(struct wiphy_setup_state, 1);
state->id = id;
state->wiphy = wiphy;
state->setup_timeout = l_timeout_create(1, manager_wiphy_setup_timeout,
state, NULL);
l_queue_push_tail(pending_wiphys, state);
done:
wiphy_update_from_genl(wiphy, msg);
return state;
}
static void manager_wiphy_setup_timeout(struct l_timeout *timeout,
void *user_data)
{
struct wiphy_setup_state *state = user_data;
manager_wiphy_dump_interfaces(state);
}
static void manager_new_wiphy_event(struct l_genl_msg *msg)
{
struct wiphy_setup_state *state;
if (!pending_wiphys)
return;
state = manager_rx_cmd_new_wiphy(msg);
if (!state)
return;
/* Setup a timer just in case a default interface is not created */
state->setup_timeout = l_timeout_create(1, manager_wiphy_setup_timeout,
state, NULL);
}
static bool manager_wiphy_state_match(const void *a, const void *b)