From f57ba702355e1fe4ed81081d4f619fa136972479 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Fri, 12 Jul 2019 14:00:01 -0700 Subject: [PATCH] netdev: Allow to send extra vendor IEs when connecting --- src/netdev.c | 21 ++++++++++++++++----- src/netdev.h | 2 ++ src/station.c | 5 +++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 1082d028..aa2bbc3b 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -2221,11 +2221,13 @@ static void netdev_fils_tx_associate(struct iovec *iov, size_t iov_len, static struct l_genl_msg *netdev_build_cmd_connect(struct netdev *netdev, struct scan_bss *bss, struct handshake_state *hs, - const uint8_t *prev_bssid) + const uint8_t *prev_bssid, + struct iovec *vendor_ies, + size_t num_vendor_ies) { uint32_t auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM; struct l_genl_msg *msg; - struct iovec iov[4]; + struct iovec iov[4 + num_vendor_ies]; int iov_elems = 0; bool is_rsn = hs->supplicant_ie != NULL; const uint8_t *extended_capabilities; @@ -2329,6 +2331,12 @@ static struct l_genl_msg *netdev_build_cmd_connect(struct netdev *netdev, iov[iov_elems].iov_len = extended_capabilities[1] + 2; iov_elems += 1; + if (vendor_ies) { + memcpy(iov + iov_elems, vendor_ies, + sizeof(*vendor_ies) * num_vendor_ies); + iov_elems += num_vendor_ies; + } + if (iov_elems) l_genl_msg_append_attrv(msg, NL80211_ATTR_IE, iov, iov_elems); @@ -2379,6 +2387,8 @@ static int netdev_connect_common(struct netdev *netdev, int netdev_connect(struct netdev *netdev, struct scan_bss *bss, struct handshake_state *hs, + struct iovec *vendor_ies, + size_t num_vendor_ies, netdev_event_func_t event_filter, netdev_connect_cb_t cb, void *user_data) { @@ -2413,7 +2423,8 @@ int netdev_connect(struct netdev *netdev, struct scan_bss *bss, netdev); break; default: - cmd_connect = netdev_build_cmd_connect(netdev, bss, hs, NULL); + cmd_connect = netdev_build_cmd_connect(netdev, bss, hs, + NULL, vendor_ies, num_vendor_ies); if (!cmd_connect) return -EINVAL; @@ -2447,7 +2458,7 @@ int netdev_connect_wsc(struct netdev *netdev, struct scan_bss *bss, if (netdev->connected) return -EISCONN; - cmd_connect = netdev_build_cmd_connect(netdev, bss, hs, NULL); + cmd_connect = netdev_build_cmd_connect(netdev, bss, hs, NULL, NULL, 0); if (!cmd_connect) return -EINVAL; @@ -2536,7 +2547,7 @@ int netdev_reassociate(struct netdev *netdev, struct scan_bss *target_bss, int err; cmd_connect = netdev_build_cmd_connect(netdev, target_bss, hs, - orig_bss->addr); + orig_bss->addr, NULL, 0); if (!cmd_connect) return -EINVAL; diff --git a/src/netdev.h b/src/netdev.h index 6f39f441..2d699c60 100644 --- a/src/netdev.h +++ b/src/netdev.h @@ -146,6 +146,8 @@ struct handshake_state *netdev_get_handshake(struct netdev *netdev); int netdev_connect(struct netdev *netdev, struct scan_bss *bss, struct handshake_state *hs, + struct iovec *vendor_ies, + size_t num_vendor_ies, 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, diff --git a/src/station.c b/src/station.c index 187f1d0d..b341acf7 100644 --- a/src/station.c +++ b/src/station.c @@ -2160,8 +2160,9 @@ int __station_connect_network(struct station *station, struct network *network, if (!hs) return -ENOTSUP; - r = netdev_connect(station->netdev, bss, hs, station_netdev_event, - station_connect_cb, station); + r = netdev_connect(station->netdev, bss, hs, NULL, 0, + station_netdev_event, station_connect_cb, + station); if (r < 0) { handshake_state_free(hs); return r;