3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-29 05:39:24 +01:00

ap: Move sending CMD_START_AP to common function

This commit is contained in:
Andrew Zaborowski 2021-05-10 10:57:56 +02:00 committed by Denis Kenzior
parent f9c2fa7bb2
commit c0a1760f46

View File

@ -2260,34 +2260,41 @@ static struct l_genl_msg *ap_build_cmd_start_ap(struct ap_state *ap)
return cmd; return cmd;
} }
static bool ap_start_send(struct ap_state *ap)
{
struct l_genl_msg *cmd = ap_build_cmd_start_ap(ap);
if (!cmd) {
l_error("ap_build_cmd_start_ap failed");
return false;
}
ap->start_stop_cmd_id = l_genl_family_send(ap->nl80211, cmd,
ap_start_cb, ap, NULL);
if (!ap->start_stop_cmd_id) {
l_error("AP_START l_genl_family_send failed");
l_genl_msg_unref(cmd);
return false;
}
return true;
}
static void ap_ifaddr4_added_cb(int error, uint16_t type, const void *data, static void ap_ifaddr4_added_cb(int error, uint16_t type, const void *data,
uint32_t len, void *user_data) uint32_t len, void *user_data)
{ {
struct ap_state *ap = user_data; struct ap_state *ap = user_data;
struct l_genl_msg *cmd;
ap->rtnl_add_cmd = 0; ap->rtnl_add_cmd = 0;
if (error) { if (error) {
l_error("Failed to set IP address"); l_error("Failed to set IP address");
goto error; ap_start_failed(ap);
return;
} }
cmd = ap_build_cmd_start_ap(ap); if (!ap_start_send(ap))
if (!cmd) ap_start_failed(ap);
goto error;
ap->start_stop_cmd_id = l_genl_family_send(ap->nl80211, cmd,
ap_start_cb, ap, NULL);
if (!ap->start_stop_cmd_id) {
l_genl_msg_unref(cmd);
goto error;
}
return;
error:
ap_start_failed(ap);
} }
static bool ap_parse_new_station_ies(const void *data, uint16_t len, static bool ap_parse_new_station_ies(const void *data, uint16_t len,
@ -2858,7 +2865,6 @@ struct ap_state *ap_start(struct netdev *netdev, struct l_settings *config,
{ {
struct ap_state *ap; struct ap_state *ap;
struct wiphy *wiphy = netdev_get_wiphy(netdev); struct wiphy *wiphy = netdev_get_wiphy(netdev);
struct l_genl_msg *cmd;
uint64_t wdev_id = netdev_get_wdev_id(netdev); uint64_t wdev_id = netdev_get_wdev_id(netdev);
int err = -EINVAL; int err = -EINVAL;
bool wait_on_address = false; bool wait_on_address = false;
@ -2949,22 +2955,13 @@ struct ap_state *ap_start(struct netdev *netdev, struct l_settings *config,
return ap; return ap;
} }
cmd = ap_build_cmd_start_ap(ap); if (ap_start_send(ap)) {
if (!cmd) if (err_out)
goto error; *err_out = 0;
ap->start_stop_cmd_id = l_genl_family_send(ap->nl80211, cmd, return ap;
ap_start_cb, ap, NULL);
if (!ap->start_stop_cmd_id) {
l_genl_msg_unref(cmd);
goto error;
} }
if (err_out)
*err_out = 0;
return ap;
error: error:
if (err_out) if (err_out)
*err_out = err; *err_out = err;