Skip to contentSkip to conversation

ap: add DEL_STATION path to fullmac AP handling

PATCH Applied James Prestwood 2 participants 2 messages Jan 29, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ap: add DEL_STATION path to fullmac AP handling

This is how a fullmac card tells userspace that a station has left. This fixes the issue where the same client cannot re-connect to the same AP multiple times. ap_new_station was renamed to ap_handle_new_station for consistency.

---
 src/ap.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 42 insertions(+), 2 deletions(-)
src/ap.c +42 -2
index 5768233b..7ff15097 100644
@@ -2238,7 +2238,7 @@ parse_error:
 	return false;
 }
 
-static void ap_new_station(struct ap_state *ap, struct l_genl_msg *msg)
+static void ap_handle_new_station(struct ap_state *ap, struct l_genl_msg *msg)
 {
 	struct sta_state *sta;
 	struct l_genl_attr attr;
@@ -2306,6 +2306,43 @@ static void ap_new_station(struct ap_state *ap, struct l_genl_msg *msg)
 	}
 }
 
+static void ap_handle_del_station(struct ap_state *ap, struct l_genl_msg *msg)
+{
+	struct sta_state *sta;
+	struct l_genl_attr attr;
+	uint16_t type;
+	uint16_t len;
+	const void *data;
+	uint8_t mac[6];
+	uint16_t reason = MMPDU_REASON_CODE_UNSPECIFIED;
+
+	if (!l_genl_attr_init(&attr, msg))
+		return;
+
+	while (l_genl_attr_next(&attr, &type, &len, &data)) {
+		switch (type) {
+		case NL80211_ATTR_MAC:
+			if (len != 6)
+				return;
+
+			memcpy(mac, data, 6);
+			break;
+		case NL80211_ATTR_REASON_CODE:
+			if (len != 2)
+				return;
+
+			reason = l_get_u16(data);
+		}
+	}
+
+	sta = l_queue_find(ap->sta_states, ap_sta_match_addr, mac);
+	if (!sta)
+		return;
+
+	ap_del_station(sta, reason, true);
+	ap_remove_sta(sta);
+}
+
 static void ap_mlme_notify(struct l_genl_msg *msg, void *user_data)
 {
 	struct ap_state *ap = user_data;
@@ -2335,7 +2372,10 @@ static void ap_mlme_notify(struct l_genl_msg *msg, void *user_data)
 		l_free(ap);
 		break;
 	case NL80211_CMD_NEW_STATION:
-		ap_new_station(ap, msg);
+		ap_handle_new_station(ap, msg);
+		break;
+	case NL80211_CMD_DEL_STATION:
+		ap_handle_del_station(ap, msg);
 		break;
 	}
 }
Signature · 1 line
2.26.2
#1 lore raw

Hi James,

Quoted 8 lines · James Prestwood

This is how a fullmac card tells userspace that a station has left. This fixes the issue where the same client cannot re-connect to the same AP multiple times. ap_new_station was renamed to ap_handle_new_station for consistency.

---
  src/ap.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
  1 file changed, 42 insertions(+), 2 deletions(-)

Applied, thanks.

Regards,
-Denis