mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-25 17:49:37 +01:00
netdev: Move CMD_DEL_STATION builder to nl80211util
While here, also get rid of netdev_del_station. The only user of this function was in ap.c and it could easily be replaced by invoking the new nl80211_build_del_station function. The callback used by netdev_build_del_station only printed an error and didn't do anything useful. Get rid of it for now.
This commit is contained in:
parent
904373eee7
commit
1aa83722a0
9
src/ap.c
9
src/ap.c
@ -392,10 +392,17 @@ static void ap_del_station(struct sta_state *sta, uint16_t reason,
|
|||||||
bool disassociate)
|
bool disassociate)
|
||||||
{
|
{
|
||||||
struct ap_state *ap = sta->ap;
|
struct ap_state *ap = sta->ap;
|
||||||
|
uint32_t ifindex = netdev_get_ifindex(ap->netdev);
|
||||||
struct ap_event_station_removed_data event_data;
|
struct ap_event_station_removed_data event_data;
|
||||||
bool send_event = false;
|
bool send_event = false;
|
||||||
|
struct l_genl_msg *msg;
|
||||||
|
uint8_t subtype = disassociate ?
|
||||||
|
MPDU_MANAGEMENT_SUBTYPE_DISASSOCIATION :
|
||||||
|
MPDU_MANAGEMENT_SUBTYPE_DEAUTHENTICATION;
|
||||||
|
|
||||||
|
msg = nl80211_build_del_station(ifindex, sta->addr, reason, subtype);
|
||||||
|
l_genl_family_send(ap->nl80211, msg, NULL, NULL, NULL);
|
||||||
|
|
||||||
netdev_del_station(ap->netdev, sta->addr, reason, disassociate);
|
|
||||||
sta->associated = false;
|
sta->associated = false;
|
||||||
|
|
||||||
if (sta->rsna) {
|
if (sta->rsna) {
|
||||||
|
56
src/netdev.c
56
src/netdev.c
@ -1298,52 +1298,6 @@ static void netdev_deauthenticate_event(struct l_genl_msg *msg,
|
|||||||
MMPDU_STATUS_CODE_UNSPECIFIED);
|
MMPDU_STATUS_CODE_UNSPECIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct l_genl_msg *netdev_build_cmd_del_station(struct netdev *netdev,
|
|
||||||
const uint8_t *sta,
|
|
||||||
uint16_t reason_code,
|
|
||||||
bool disassociate)
|
|
||||||
{
|
|
||||||
struct l_genl_msg *msg;
|
|
||||||
uint8_t subtype = disassociate ?
|
|
||||||
MPDU_MANAGEMENT_SUBTYPE_DISASSOCIATION :
|
|
||||||
MPDU_MANAGEMENT_SUBTYPE_DEAUTHENTICATION;
|
|
||||||
|
|
||||||
msg = l_genl_msg_new_sized(NL80211_CMD_DEL_STATION, 64);
|
|
||||||
l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index);
|
|
||||||
l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, 6, sta);
|
|
||||||
l_genl_msg_append_attr(msg, NL80211_ATTR_MGMT_SUBTYPE, 1, &subtype);
|
|
||||||
l_genl_msg_append_attr(msg, NL80211_ATTR_REASON_CODE, 2, &reason_code);
|
|
||||||
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void netdev_del_sta_cb(struct l_genl_msg *msg, void *user_data)
|
|
||||||
{
|
|
||||||
int err = l_genl_msg_get_error(msg);
|
|
||||||
const char *ext_error;
|
|
||||||
|
|
||||||
if (err >= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ext_error = l_genl_msg_get_extended_error(msg);
|
|
||||||
l_error("DEL_STATION failed: %s",
|
|
||||||
ext_error ? ext_error : strerror(-err));
|
|
||||||
}
|
|
||||||
|
|
||||||
int netdev_del_station(struct netdev *netdev, const uint8_t *sta,
|
|
||||||
uint16_t reason_code, bool disassociate)
|
|
||||||
{
|
|
||||||
struct l_genl_msg *msg;
|
|
||||||
|
|
||||||
msg = netdev_build_cmd_del_station(netdev, sta, reason_code,
|
|
||||||
disassociate);
|
|
||||||
|
|
||||||
if (!l_genl_family_send(nl80211, msg, netdev_del_sta_cb, NULL, NULL))
|
|
||||||
return -EIO;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void netdev_operstate_cb(int error, uint16_t type,
|
static void netdev_operstate_cb(int error, uint16_t type,
|
||||||
const void *data,
|
const void *data,
|
||||||
uint32_t len, void *user_data)
|
uint32_t len, void *user_data)
|
||||||
@ -1444,8 +1398,9 @@ static void netdev_setting_keys_failed(struct netdev_handshake_state *nhs,
|
|||||||
if (err == -ENETDOWN)
|
if (err == -ENETDOWN)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
msg = netdev_build_cmd_del_station(netdev, nhs->super.spa,
|
msg = nl80211_build_del_station(netdev->index,
|
||||||
MMPDU_REASON_CODE_UNSPECIFIED, false);
|
nhs->super.spa, MMPDU_REASON_CODE_UNSPECIFIED,
|
||||||
|
MPDU_MANAGEMENT_SUBTYPE_DEAUTHENTICATION);
|
||||||
if (!l_genl_family_send(nl80211, msg, NULL, NULL, NULL))
|
if (!l_genl_family_send(nl80211, msg, NULL, NULL, NULL))
|
||||||
l_error("error sending DEL_STATION");
|
l_error("error sending DEL_STATION");
|
||||||
|
|
||||||
@ -2227,8 +2182,9 @@ void netdev_handshake_failed(struct handshake_state *hs, uint16_t reason_code)
|
|||||||
break;
|
break;
|
||||||
case NL80211_IFTYPE_AP:
|
case NL80211_IFTYPE_AP:
|
||||||
case NL80211_IFTYPE_P2P_GO:
|
case NL80211_IFTYPE_P2P_GO:
|
||||||
msg = netdev_build_cmd_del_station(netdev, nhs->super.spa,
|
msg = nl80211_build_del_station(netdev->index, nhs->super.spa,
|
||||||
reason_code, false);
|
reason_code,
|
||||||
|
MPDU_MANAGEMENT_SUBTYPE_DEAUTHENTICATION);
|
||||||
if (!l_genl_family_send(nl80211, msg, NULL, NULL, NULL))
|
if (!l_genl_family_send(nl80211, msg, NULL, NULL, NULL))
|
||||||
l_error("error sending DEL_STATION");
|
l_error("error sending DEL_STATION");
|
||||||
}
|
}
|
||||||
|
@ -310,6 +310,22 @@ struct l_genl_msg *nl80211_build_disconnect(uint32_t ifindex,
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct l_genl_msg *nl80211_build_del_station(uint32_t ifindex,
|
||||||
|
const uint8_t addr[static 6],
|
||||||
|
uint16_t reason_code,
|
||||||
|
uint8_t subtype)
|
||||||
|
{
|
||||||
|
struct l_genl_msg *msg;
|
||||||
|
|
||||||
|
msg = l_genl_msg_new_sized(NL80211_CMD_DEL_STATION, 64);
|
||||||
|
l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &ifindex);
|
||||||
|
l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, 6, addr);
|
||||||
|
l_genl_msg_append_attr(msg, NL80211_ATTR_MGMT_SUBTYPE, 1, &subtype);
|
||||||
|
l_genl_msg_append_attr(msg, NL80211_ATTR_REASON_CODE, 2, &reason_code);
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex, uint32_t cipher,
|
struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex, uint32_t cipher,
|
||||||
uint8_t key_id, const uint8_t *key,
|
uint8_t key_id, const uint8_t *key,
|
||||||
size_t key_len, const uint8_t *ctr,
|
size_t key_len, const uint8_t *ctr,
|
||||||
|
@ -34,6 +34,11 @@ struct l_genl_msg *nl80211_build_deauthenticate(uint32_t ifindex,
|
|||||||
struct l_genl_msg *nl80211_build_disconnect(uint32_t ifindex,
|
struct l_genl_msg *nl80211_build_disconnect(uint32_t ifindex,
|
||||||
uint16_t reason_code);
|
uint16_t reason_code);
|
||||||
|
|
||||||
|
struct l_genl_msg *nl80211_build_del_station(uint32_t ifindex,
|
||||||
|
const uint8_t addr[static 6],
|
||||||
|
uint16_t reason_code,
|
||||||
|
uint8_t subtype);
|
||||||
|
|
||||||
struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex,
|
struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex,
|
||||||
uint32_t cipher, uint8_t key_id,
|
uint32_t cipher, uint8_t key_id,
|
||||||
const uint8_t *key, size_t key_len,
|
const uint8_t *key, size_t key_len,
|
||||||
|
Loading…
Reference in New Issue
Block a user