diff options
author | Andrew Zaborowski <andrew.zaborowski@intel.com> | 2020-02-15 01:17:46 +0100 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2020-02-17 12:27:54 -0600 |
commit | dd2677402a04f4c663ea916eea712241d1255f86 (patch) | |
tree | 88b3b1c297457bd990395d13ac351779d7c60120 | |
parent | 87a198111af1ea67053895f7435fb99e3cdd2159 (diff) | |
download | iwd-dd2677402a04f4c663ea916eea712241d1255f86.tar.gz |
ap: React to NL80211_CMD_STOP_AP events
These events will tell use when our AP gets stopped without our request,
for example due to suspend/resume.
-rw-r--r-- | src/ap.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -57,6 +57,7 @@ struct ap_state { struct l_uintset *rates; uint8_t pmk[32]; uint32_t start_stop_cmd_id; + uint32_t mlme_watch; uint8_t gtk[CRYPTO_MAX_GTK_LEN]; uint8_t gtk_index; @@ -1393,6 +1394,26 @@ static struct l_genl_msg *ap_build_cmd_start_ap(struct ap_state *ap) return cmd; } +static void ap_mlme_notify(struct l_genl_msg *msg, void *user_data) +{ + struct ap_state *ap = user_data; + uint32_t ifindex; + + if (nl80211_parse_attrs(msg, NL80211_ATTR_IFINDEX, &ifindex, + NL80211_ATTR_UNSPEC) < 0 || + ifindex != netdev_get_ifindex(ap->netdev)) + return; + + switch (l_genl_msg_get_command(msg)) { + case NL80211_CMD_STOP_AP: + if (ap->start_stop_cmd_id) + break; + + ap_reset(ap); + break; + } +} + static int ap_start(struct ap_state *ap, const char *ssid, const char *psk, struct l_dbus_message *message) { @@ -1448,6 +1469,11 @@ static int ap_start(struct ap_state *ap, const char *ssid, const char *psk, NULL, 0, ap_deauth_cb, ap, NULL)) goto error; + ap->mlme_watch = l_genl_family_register(ap->nl80211, "mlme", + ap_mlme_notify, ap, NULL); + if (!ap->mlme_watch) + l_error("Registering for MLME notification failed"); + cmd = ap_build_cmd_start_ap(ap); if (!cmd) goto error; @@ -1514,6 +1540,9 @@ static int ap_stop(struct ap_state *ap, struct l_dbus_message *message) if (ap->start_stop_cmd_id) l_genl_family_cancel(ap->nl80211, ap->start_stop_cmd_id); + if (ap->mlme_watch) + l_genl_family_unregister(ap->nl80211, ap->mlme_watch); + ap->start_stop_cmd_id = l_genl_family_send(ap->nl80211, cmd, ap_stop_cb, ap, NULL); if (!ap->start_stop_cmd_id) { |