3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-20 04:19:25 +01:00

netdev: Move CQM event handling out of wiphy.c

This commit is contained in:
Denis Kenzior 2016-06-16 11:06:17 -05:00
parent d526dbc175
commit 0eeb71e4eb
3 changed files with 55 additions and 44 deletions

View File

@ -181,6 +181,17 @@ void device_disassociated(struct device *device)
IWD_NETWORK_INTERFACE, "Connected");
}
static void device_lost_beacon(struct device *device)
{
l_debug("%d", device->index);
if (device->connect_pending)
dbus_pending_reply(&device->connect_pending,
dbus_error_failed(device->connect_pending));
device_disassociated(device);
}
static void device_connect_cb(struct netdev *netdev, enum netdev_result result,
void *user_data)
{
@ -211,6 +222,8 @@ static void device_connect_cb(struct netdev *netdev, enum netdev_result result,
static void device_netdev_event(struct netdev *netdev, enum netdev_event event,
void *user_data)
{
struct device *device = user_data;
switch (event) {
case NETDEV_EVENT_AUTHENTICATING:
l_debug("Authenticating");
@ -225,7 +238,7 @@ static void device_netdev_event(struct netdev *netdev, enum netdev_event event,
l_debug("Setting keys");
break;
case NETDEV_EVENT_LOST_BEACON:
l_debug("Beacon lost");
device_lost_beacon(device);
break;
};
}

View File

@ -187,6 +187,44 @@ struct netdev *netdev_find(int ifindex)
return l_queue_find(netdev_list, netdev_match, L_UINT_TO_PTR(ifindex));
}
static void netdev_lost_beacon(struct netdev *netdev)
{
if (!netdev->event_filter)
return;
netdev->event_filter(netdev, NETDEV_EVENT_LOST_BEACON,
netdev->user_data);
}
static void netdev_cqm_event(struct l_genl_msg *msg, struct netdev *netdev)
{
struct l_genl_attr attr;
struct l_genl_attr nested;
uint16_t type, len;
const void *data;
if (!l_genl_attr_init(&attr, msg))
return;
while (l_genl_attr_next(&attr, &type, &len, &data)) {
switch (type) {
case NL80211_ATTR_CQM:
if (!l_genl_attr_recurse(&attr, &nested))
return;
while (l_genl_attr_next(&nested, &type, &len, &data)) {
switch (type) {
case NL80211_ATTR_CQM_BEACON_LOSS_EVENT:
netdev_lost_beacon(netdev);
break;
}
}
break;
}
}
}
static void netdev_deauthenticate_event(struct l_genl_msg *msg,
struct netdev *netdev)
{
@ -498,6 +536,9 @@ static void netdev_mlme_notify(struct l_genl_msg *msg, void *user_data)
case NL80211_CMD_ASSOCIATE:
netdev_associate_event(msg, netdev);
break;
case NL80211_CMD_NOTIFY_CQM:
netdev_cqm_event(msg, netdev);
break;
}
}

View File

@ -165,15 +165,6 @@ void device_enter_state(struct device *device, enum device_state state)
device->state = state;
}
static void device_lost_beacon(struct device *device)
{
if (device->connect_pending)
dbus_pending_reply(&device->connect_pending,
dbus_error_failed(device->connect_pending));
device_disassociated(device);
}
enum ie_rsn_cipher_suite wiphy_select_cipher(struct wiphy *wiphy, uint16_t mask)
{
mask &= wiphy->pairwise_ciphers;
@ -864,37 +855,6 @@ static void mlme_disconnect_event(struct l_genl_msg *msg,
device_disassociated(device);
}
static void mlme_cqm_event(struct l_genl_msg *msg, struct device *device)
{
struct l_genl_attr attr;
struct l_genl_attr nested;
uint16_t type, len;
const void *data;
l_debug("");
if (!l_genl_attr_init(&attr, msg))
return;
while (l_genl_attr_next(&attr, &type, &len, &data)) {
switch (type) {
case NL80211_ATTR_CQM:
if (!l_genl_attr_recurse(&attr, &nested))
return;
while (l_genl_attr_next(&nested, &type, &len, &data)) {
switch (type) {
case NL80211_ATTR_CQM_BEACON_LOSS_EVENT:
device_lost_beacon(device);
break;
}
}
break;
}
}
}
static bool process_network(const void *key, void *data, void *user_data)
{
struct network *network = data;
@ -1512,9 +1472,6 @@ static void wiphy_mlme_notify(struct l_genl_msg *msg, void *user_data)
case NL80211_CMD_DISCONNECT:
mlme_disconnect_event(msg, device);
break;
case NL80211_CMD_NOTIFY_CQM:
mlme_cqm_event(msg, device);
break;
}
}