3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 17:59:25 +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,33 +2260,40 @@ static struct l_genl_msg *ap_build_cmd_start_ap(struct ap_state *ap)
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,
uint32_t len, void *user_data)
{
struct ap_state *ap = user_data;
struct l_genl_msg *cmd;
ap->rtnl_add_cmd = 0;
if (error) {
l_error("Failed to set IP address");
goto error;
}
cmd = ap_build_cmd_start_ap(ap);
if (!cmd)
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;
}
ap_start_failed(ap);
return;
}
error:
if (!ap_start_send(ap))
ap_start_failed(ap);
}
@ -2858,7 +2865,6 @@ struct ap_state *ap_start(struct netdev *netdev, struct l_settings *config,
{
struct ap_state *ap;
struct wiphy *wiphy = netdev_get_wiphy(netdev);
struct l_genl_msg *cmd;
uint64_t wdev_id = netdev_get_wdev_id(netdev);
int err = -EINVAL;
bool wait_on_address = false;
@ -2949,21 +2955,12 @@ struct ap_state *ap_start(struct netdev *netdev, struct l_settings *config,
return ap;
}
cmd = ap_build_cmd_start_ap(ap);
if (!cmd)
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;
}
if (ap_start_send(ap)) {
if (err_out)
*err_out = 0;
return ap;
}
error:
if (err_out)