mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-30 06:02:39 +01:00
wsc: Move eapol_sm creation to netdev_connect_wsc
This commit is contained in:
parent
c9ee5b8e7f
commit
d93a44a3f0
24
src/netdev.c
24
src/netdev.c
@ -1230,12 +1230,8 @@ static void netdev_cmd_connect_cb(struct l_genl_msg *msg, void *user_data)
|
||||
* events can be reversed (e.g. connect_event, then PAE data)
|
||||
* due to scheduling
|
||||
*/
|
||||
if (netdev->handshake) {
|
||||
if (!netdev->sm)
|
||||
netdev->sm = eapol_sm_new(netdev->handshake);
|
||||
|
||||
if (netdev->sm)
|
||||
eapol_register(netdev->sm);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1396,6 +1392,8 @@ int netdev_connect(struct netdev *netdev, struct scan_bss *bss,
|
||||
netdev_connect_cb_t cb, void *user_data)
|
||||
{
|
||||
struct l_genl_msg *cmd_connect;
|
||||
struct eapol_sm *sm = NULL;
|
||||
bool is_rsn = hs != NULL;
|
||||
|
||||
if (netdev->connected)
|
||||
return -EISCONN;
|
||||
@ -1404,14 +1402,19 @@ int netdev_connect(struct netdev *netdev, struct scan_bss *bss,
|
||||
if (!cmd_connect)
|
||||
return -EINVAL;
|
||||
|
||||
return netdev_connect_common(netdev, cmd_connect, bss, hs, NULL, mde,
|
||||
if (is_rsn)
|
||||
sm = eapol_sm_new(hs);
|
||||
|
||||
return netdev_connect_common(netdev, cmd_connect, bss, hs, sm, mde,
|
||||
event_filter, cb, user_data);
|
||||
}
|
||||
|
||||
int netdev_connect_wsc(struct netdev *netdev, struct scan_bss *bss,
|
||||
struct handshake_state *hs, struct eapol_sm *sm,
|
||||
struct handshake_state *hs,
|
||||
netdev_event_func_t event_filter,
|
||||
netdev_connect_cb_t cb, void *user_data)
|
||||
netdev_connect_cb_t cb,
|
||||
netdev_eapol_event_func_t eapol_cb,
|
||||
void *user_data)
|
||||
{
|
||||
struct l_genl_msg *cmd_connect;
|
||||
struct wsc_association_request request;
|
||||
@ -1419,6 +1422,7 @@ int netdev_connect_wsc(struct netdev *netdev, struct scan_bss *bss,
|
||||
size_t pdu_len;
|
||||
void *ie;
|
||||
size_t ie_len;
|
||||
struct eapol_sm *sm;
|
||||
|
||||
if (netdev->connected)
|
||||
return -EISCONN;
|
||||
@ -1443,6 +1447,10 @@ int netdev_connect_wsc(struct netdev *netdev, struct scan_bss *bss,
|
||||
l_genl_msg_append_attr(cmd_connect, NL80211_ATTR_IE, ie_len, ie);
|
||||
l_free(ie);
|
||||
|
||||
sm = eapol_sm_new(hs);
|
||||
eapol_sm_set_user_data(sm, user_data);
|
||||
eapol_sm_set_event_func(sm, eapol_cb);
|
||||
|
||||
return netdev_connect_common(netdev, cmd_connect, bss, hs, sm, NULL,
|
||||
event_filter, cb, user_data);
|
||||
|
||||
|
@ -66,6 +66,9 @@ typedef void (*netdev_watch_func_t)(struct netdev *netdev,
|
||||
typedef void (*netdev_set_powered_cb_t)(struct netdev *netdev, int result,
|
||||
void *user_data);
|
||||
typedef void (*netdev_destroy_func_t)(void *user_data);
|
||||
typedef void (*netdev_eapol_event_func_t)(unsigned int event,
|
||||
const void *event_data,
|
||||
void *user_data);
|
||||
|
||||
const uint8_t *netdev_get_address(struct netdev *netdev);
|
||||
uint32_t netdev_get_ifindex(struct netdev *netdev);
|
||||
@ -78,9 +81,11 @@ int netdev_connect(struct netdev *netdev, struct scan_bss *bss,
|
||||
netdev_event_func_t event_filter,
|
||||
netdev_connect_cb_t cb, void *user_data);
|
||||
int netdev_connect_wsc(struct netdev *netdev, struct scan_bss *bss,
|
||||
struct handshake_state *hs, struct eapol_sm *sm,
|
||||
struct handshake_state *hs,
|
||||
netdev_event_func_t event_filter,
|
||||
netdev_connect_cb_t cb, void *user_data);
|
||||
netdev_connect_cb_t cb,
|
||||
netdev_eapol_event_func_t eapol_cb,
|
||||
void *user_data);
|
||||
int netdev_disconnect(struct netdev *netdev,
|
||||
netdev_disconnect_cb_t cb, void *user_data);
|
||||
|
||||
|
16
src/wsc.c
16
src/wsc.c
@ -37,7 +37,6 @@
|
||||
#include "src/util.h"
|
||||
#include "src/wsc.h"
|
||||
#include "src/handshake.h"
|
||||
#include "src/eapol.h"
|
||||
#include "src/eap-wsc.h"
|
||||
#include "src/crypto.h"
|
||||
#include "src/common.h"
|
||||
@ -396,7 +395,6 @@ static inline enum wsc_rf_band freq_to_rf_band(uint32_t freq)
|
||||
static void wsc_connect(struct wsc *wsc)
|
||||
{
|
||||
struct handshake_state *hs;
|
||||
struct eapol_sm *sm;
|
||||
struct l_settings *settings = l_settings_new();
|
||||
struct scan_bss *bss = wsc->target;
|
||||
uint32_t ifindex = netdev_get_ifindex(device_get_netdev(wsc->device));
|
||||
@ -405,11 +403,6 @@ static void wsc_connect(struct wsc *wsc)
|
||||
|
||||
hs = handshake_state_new(ifindex);
|
||||
|
||||
sm = eapol_sm_new(hs);
|
||||
|
||||
eapol_sm_set_user_data(sm, wsc);
|
||||
eapol_sm_set_event_func(sm, wsc_eapol_event);
|
||||
|
||||
l_settings_set_string(settings, "Security", "EAP-Identity",
|
||||
"WFA-SimpleConfig-Enrollee-1-0");
|
||||
l_settings_set_string(settings, "Security", "EAP-Method", "WSC");
|
||||
@ -428,12 +421,9 @@ static void wsc_connect(struct wsc *wsc)
|
||||
handshake_state_set_8021x_config(hs, settings);
|
||||
wsc->eap_settings = settings;
|
||||
|
||||
eapol_sm_set_use_eapol_start(sm, true);
|
||||
|
||||
if (netdev_connect_wsc(device_get_netdev(wsc->device), bss, hs, sm,
|
||||
wsc_netdev_event,
|
||||
wsc_connect_cb, wsc) < 0) {
|
||||
eapol_sm_free(sm);
|
||||
if (netdev_connect_wsc(device_get_netdev(wsc->device), bss, hs,
|
||||
wsc_netdev_event, wsc_connect_cb,
|
||||
wsc_eapol_event, wsc) < 0) {
|
||||
dbus_pending_reply(&wsc->pending,
|
||||
dbus_error_failed(wsc->pending));
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user