mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 17:42:41 +00:00
Compare commits
2 Commits
staging-pk
...
v3.1.0-rc3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e04833e902 | ||
|
|
21cb4de975 |
11
.github/workflows/build-dev.yml
vendored
Executable file → Normal file
11
.github/workflows/build-dev.yml
vendored
Executable file → Normal file
@@ -15,20 +15,21 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
x64_vm_image_name: ${{ steps.package_and_upload_image.outputs.x64_vm_image_name }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target: [ 'cig_wf189h', 'cig_wf189w', 'cig_wf660a', 'cig_wf672', 'cig_wf186h', 'cig_wf186w', 'cig_wf188n', 'cig_wf189', 'cig_wf196', 'cig_wf196', 'cybertan_eww631-a1', 'cybertan_eww631-b1', 'sonicfi_rap630w-312g', 'sonicfi_rap63xc-211g', 'sonicfi_rap630c-311g', 'sonicfi_rap630w-311g', 'sonicfi_rap630w-211g', 'sonicfi_rap650c', 'sonicfi_rap7110c-341x', 'sonicfi_rap750e-h', 'sonicfi_rap750e-s', 'sonicfi_rap750w-311a', 'edgecore_eap101', 'edgecore_eap102', 'edgecore_eap104', 'edgecore_eap105', 'edgecore_eap111', 'edgecore_eap112', 'edgecore_oap101', 'edgecore_oap101-6e', 'edgecore_oap101e', 'edgecore_oap101e-6e', 'edgecore_oap103', 'hfcl_ion4xe', 'hfcl_ion4xi', 'hfcl_ion4x', 'hfcl_ion4x_2', 'hfcl_ion4x_3', 'hfcl_ion4xi_w', 'hfcl_ion4x_w', 'indio_um-305ax', 'senao_iap4300m', 'senao_iap2300m', 'senao_jeap6500', 'udaya_a6-id2', 'udaya_a6-od2', 'yuncore_ax820', 'yuncore_ax840', 'yuncore_fap640', 'yuncore_fap650', 'yuncore_fap655', 'emplus_wap588m', 'zyxel_nwa130be', 'sercomm_ap72tip-v4' ]
|
||||
target: [ 'cig_wf186h', 'cig_wf186w', 'cig_wf188n', 'cig_wf196', 'cig_wf189', 'cybertan_eww631-a1', 'cybertan_eww631-b1', 'edgecore_eap101', 'edgecore_eap102', 'edgecore_eap104', 'edgecore_eap111', 'edgecore_ecw5211', 'edgecore_oap101', 'edgecore_oap101-6e', 'edgecore_oap101e', 'edgecore_oap101e-6e', 'hfcl_ion4', 'hfcl_ion4xe', 'hfcl_ion4xi', 'hfcl_ion4x', 'hfcl_ion4x_2', 'hfcl_ion4x_3', 'hfcl_ion4xi_w', 'hfcl_ion4x_w', 'indio_um-305ax', 'indio_um-325ac', 'indio_um-510ac-v3', 'indio_um-550ac', 'sercomm_ap72tip', 'udaya_a5-id2', 'udaya_a6-id2', 'wallys_dr40x9', 'wallys_dr6018', 'wallys_dr6018-v4', 'yuncore_ax820', 'yuncore_ax840', 'yuncore_fap640', 'yuncore_fap650', 'yuncore_fap655' ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
# Clean unnecessary files to save disk space
|
||||
- name: clean unncessary files to save space
|
||||
run: |
|
||||
docker rmi `docker images -q` || true
|
||||
docker rmi `docker images -q`
|
||||
|
||||
- name: Build image for ${{ matrix.target }}
|
||||
id: build
|
||||
@@ -80,7 +81,7 @@ jobs:
|
||||
fi
|
||||
|
||||
trigger-testing:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
steps:
|
||||
@@ -93,7 +94,7 @@ jobs:
|
||||
client-payload: '{"ref": "${GITHUB_REF#refs/tags/}", "sha": "${{ github.sha }}"}'
|
||||
|
||||
create-x64_vm-ami:
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
steps:
|
||||
|
||||
@@ -6,8 +6,7 @@ boot() {
|
||||
. /lib/functions/system.sh
|
||||
case $(board_name) in
|
||||
edgecore,eap102|\
|
||||
edgecore,oap102|\
|
||||
edgecore,oap103)
|
||||
edgecore,oap102)
|
||||
echo 54 > /sys/class/gpio/export
|
||||
echo out > /sys/class/gpio/gpio54/direction
|
||||
echo 0 > /sys/class/gpio/gpio54/value
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,738 +0,0 @@
|
||||
--- a/hostapd/Makefile
|
||||
+++ b/hostapd/Makefile
|
||||
@@ -166,6 +166,12 @@ OBJS += ../src/common/hw_features_common
|
||||
|
||||
OBJS += ../src/eapol_auth/eapol_auth_sm.o
|
||||
|
||||
+ifdef CONFIG_UBUS
|
||||
+CFLAGS += -DUBUS_SUPPORT
|
||||
+OBJS += ../src/utils/uloop.o
|
||||
+OBJS += ../src/ap/ubus.o
|
||||
+LIBS += -lubox -lubus
|
||||
+endif
|
||||
|
||||
ifdef CONFIG_CODE_COVERAGE
|
||||
CFLAGS += -O0 -fprofile-arcs -ftest-coverage
|
||||
--- a/src/ap/hostapd.h
|
||||
+++ b/src/ap/hostapd.h
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "utils/list.h"
|
||||
#include "ap_config.h"
|
||||
#include "drivers/driver.h"
|
||||
+#include "ubus.h"
|
||||
|
||||
#define OCE_STA_CFON_ENABLED(hapd) \
|
||||
((hapd->conf->oce & OCE_STA_CFON) && \
|
||||
@@ -184,6 +185,7 @@ struct hostapd_data {
|
||||
struct hostapd_iface *iface;
|
||||
struct hostapd_config *iconf;
|
||||
struct hostapd_bss_config *conf;
|
||||
+ struct hostapd_ubus_bss ubus;
|
||||
int interface_added; /* virtual interface added for this BSS */
|
||||
unsigned int started:1;
|
||||
unsigned int disabled:1;
|
||||
@@ -695,6 +697,7 @@ hostapd_alloc_bss_data(struct hostapd_if
|
||||
struct hostapd_bss_config *bss);
|
||||
int hostapd_setup_interface(struct hostapd_iface *iface);
|
||||
int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
|
||||
+void hostapd_set_own_neighbor_report(struct hostapd_data *hapd);
|
||||
void hostapd_interface_deinit(struct hostapd_iface *iface);
|
||||
void hostapd_interface_free(struct hostapd_iface *iface);
|
||||
struct hostapd_iface * hostapd_alloc_iface(void);
|
||||
--- a/src/ap/hostapd.c
|
||||
+++ b/src/ap/hostapd.c
|
||||
@@ -435,6 +435,7 @@ void hostapd_free_hapd_data(struct hosta
|
||||
hapd->beacon_set_done = 0;
|
||||
|
||||
wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
|
||||
+ hostapd_ubus_free_bss(hapd);
|
||||
accounting_deinit(hapd);
|
||||
hostapd_deinit_wpa(hapd);
|
||||
vlan_deinit(hapd);
|
||||
@@ -1187,6 +1188,8 @@ static int hostapd_start_beacon(struct h
|
||||
if (hapd->driver && hapd->driver->set_operstate)
|
||||
hapd->driver->set_operstate(hapd->drv_priv, 1);
|
||||
|
||||
+ hostapd_ubus_add_bss(hapd);
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2275,6 +2278,7 @@ static int hostapd_setup_interface_compl
|
||||
if (err)
|
||||
goto fail;
|
||||
|
||||
+ hostapd_ubus_add_iface(iface);
|
||||
wpa_printf(MSG_DEBUG, "Completing interface initialization");
|
||||
if (iface->freq) {
|
||||
#ifdef NEED_AP_MLME
|
||||
@@ -2494,6 +2498,7 @@ dfs_offload:
|
||||
|
||||
fail:
|
||||
wpa_printf(MSG_ERROR, "Interface initialization failed");
|
||||
+ hostapd_ubus_free_iface(iface);
|
||||
|
||||
if (iface->is_no_ir) {
|
||||
hostapd_set_state(iface, HAPD_IFACE_NO_IR);
|
||||
@@ -2984,6 +2989,7 @@ void hostapd_interface_deinit_free(struc
|
||||
(unsigned int) iface->conf->num_bss);
|
||||
driver = iface->bss[0]->driver;
|
||||
drv_priv = iface->bss[0]->drv_priv;
|
||||
+ hostapd_ubus_free_iface(iface);
|
||||
hostapd_interface_deinit(iface);
|
||||
wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit",
|
||||
__func__, driver, drv_priv);
|
||||
--- a/src/ap/ieee802_11.c
|
||||
+++ b/src/ap/ieee802_11.c
|
||||
@@ -2786,7 +2786,7 @@ static void handle_auth(struct hostapd_d
|
||||
u16 auth_alg, auth_transaction, status_code;
|
||||
u16 resp = WLAN_STATUS_SUCCESS;
|
||||
struct sta_info *sta = NULL;
|
||||
- int res, reply_res;
|
||||
+ int res, reply_res, ubus_resp;
|
||||
u16 fc;
|
||||
const u8 *challenge = NULL;
|
||||
u8 resp_ies[2 + WLAN_AUTH_CHALLENGE_LEN];
|
||||
@@ -2795,6 +2795,11 @@ static void handle_auth(struct hostapd_d
|
||||
struct radius_sta rad_info;
|
||||
const u8 *dst, *sa, *bssid;
|
||||
bool mld_sta = false;
|
||||
+ struct hostapd_ubus_request req = {
|
||||
+ .type = HOSTAPD_UBUS_AUTH_REQ,
|
||||
+ .mgmt_frame = mgmt,
|
||||
+ .ssi_signal = rssi,
|
||||
+ };
|
||||
|
||||
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.auth)) {
|
||||
wpa_printf(MSG_INFO, "handle_auth - too short payload (len=%lu)",
|
||||
@@ -2986,6 +2991,13 @@ static void handle_auth(struct hostapd_d
|
||||
resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
+ ubus_resp = hostapd_ubus_handle_event(hapd, &req);
|
||||
+ if (0 && ubus_resp) {
|
||||
+ wpa_printf(MSG_DEBUG, "Station " MACSTR " rejected by ubus handler.\n",
|
||||
+ MAC2STR(mgmt->sa));
|
||||
+ resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||
+ goto fail;
|
||||
+ }
|
||||
if (res == HOSTAPD_ACL_PENDING)
|
||||
return;
|
||||
|
||||
@@ -5161,7 +5173,7 @@ static void handle_assoc(struct hostapd_
|
||||
int resp = WLAN_STATUS_SUCCESS;
|
||||
u16 reply_res = WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||
const u8 *pos;
|
||||
- int left, i;
|
||||
+ int left, i, ubus_resp;
|
||||
struct sta_info *sta;
|
||||
u8 *tmp = NULL;
|
||||
#ifdef CONFIG_FILS
|
||||
@@ -5374,6 +5386,11 @@ static void handle_assoc(struct hostapd_
|
||||
left = res;
|
||||
}
|
||||
#endif /* CONFIG_FILS */
|
||||
+ struct hostapd_ubus_request req = {
|
||||
+ .type = HOSTAPD_UBUS_ASSOC_REQ,
|
||||
+ .mgmt_frame = mgmt,
|
||||
+ .ssi_signal = rssi,
|
||||
+ };
|
||||
|
||||
/* followed by SSID and Supported rates; and HT capabilities if 802.11n
|
||||
* is used */
|
||||
@@ -5472,6 +5489,13 @@ static void handle_assoc(struct hostapd_
|
||||
}
|
||||
#endif /* CONFIG_FILS */
|
||||
|
||||
+ ubus_resp = hostapd_ubus_handle_event(hapd, &req);
|
||||
+ if (0 && ubus_resp) {
|
||||
+ wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
|
||||
+ MAC2STR(mgmt->sa));
|
||||
+ resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||
+ goto fail;
|
||||
+ }
|
||||
fail:
|
||||
|
||||
/*
|
||||
@@ -5753,6 +5777,7 @@ static void handle_disassoc(struct hosta
|
||||
(unsigned long) len);
|
||||
return;
|
||||
}
|
||||
+ hostapd_ubus_notify(hapd, "disassoc", mgmt->sa);
|
||||
|
||||
sta = ap_get_sta(hapd, mgmt->sa);
|
||||
if (!sta) {
|
||||
@@ -5784,6 +5809,8 @@ static void handle_deauth(struct hostapd
|
||||
/* Clear the PTKSA cache entries for PASN */
|
||||
ptksa_cache_flush(hapd->ptksa, mgmt->sa, WPA_CIPHER_NONE);
|
||||
|
||||
+ hostapd_ubus_notify(hapd, "deauth", mgmt->sa);
|
||||
+
|
||||
sta = ap_get_sta(hapd, mgmt->sa);
|
||||
if (!sta) {
|
||||
wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR
|
||||
--- a/src/ap/beacon.c
|
||||
+++ b/src/ap/beacon.c
|
||||
@@ -1036,6 +1036,12 @@ void handle_probe_req(struct hostapd_dat
|
||||
u16 csa_offs[2];
|
||||
size_t csa_offs_len;
|
||||
struct radius_sta rad_info;
|
||||
+ struct hostapd_ubus_request req = {
|
||||
+ .type = HOSTAPD_UBUS_PROBE_REQ,
|
||||
+ .mgmt_frame = mgmt,
|
||||
+ .ssi_signal = ssi_signal,
|
||||
+ .elems = &elems,
|
||||
+ };
|
||||
|
||||
if (hapd->iconf->rssi_ignore_probe_request && ssi_signal &&
|
||||
ssi_signal < hapd->iconf->rssi_ignore_probe_request)
|
||||
@@ -1222,6 +1228,12 @@ void handle_probe_req(struct hostapd_dat
|
||||
}
|
||||
#endif /* CONFIG_P2P */
|
||||
|
||||
+ if (hostapd_ubus_handle_event(hapd, &req)) {
|
||||
+ wpa_printf(MSG_DEBUG, "Probe request for " MACSTR " rejected by ubus handler.\n",
|
||||
+ MAC2STR(mgmt->sa));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
/* TODO: verify that supp_rates contains at least one matching rate
|
||||
* with AP configuration */
|
||||
|
||||
--- a/src/ap/drv_callbacks.c
|
||||
+++ b/src/ap/drv_callbacks.c
|
||||
@@ -260,6 +260,10 @@ int hostapd_notif_assoc(struct hostapd_d
|
||||
u16 reason = WLAN_REASON_UNSPECIFIED;
|
||||
int status = WLAN_STATUS_SUCCESS;
|
||||
const u8 *p2p_dev_addr = NULL;
|
||||
+ struct hostapd_ubus_request req = {
|
||||
+ .type = HOSTAPD_UBUS_ASSOC_REQ,
|
||||
+ .addr = addr,
|
||||
+ };
|
||||
|
||||
if (addr == NULL) {
|
||||
/*
|
||||
@@ -396,6 +400,12 @@ int hostapd_notif_assoc(struct hostapd_d
|
||||
goto fail;
|
||||
}
|
||||
|
||||
+ if (hostapd_ubus_handle_event(hapd, &req)) {
|
||||
+ wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
|
||||
+ MAC2STR(req.addr));
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
#ifdef CONFIG_P2P
|
||||
if (elems.p2p) {
|
||||
wpabuf_free(sta->p2p_ie);
|
||||
--- a/src/ap/sta_info.c
|
||||
+++ b/src/ap/sta_info.c
|
||||
@@ -471,6 +471,7 @@ void ap_handle_timer(void *eloop_ctx, vo
|
||||
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
|
||||
HOSTAPD_LEVEL_INFO, "deauthenticated due to "
|
||||
"local deauth request");
|
||||
+ hostapd_ubus_notify(hapd, "local-deauth", sta->addr);
|
||||
ap_free_sta(hapd, sta);
|
||||
return;
|
||||
}
|
||||
@@ -626,6 +627,7 @@ skip_poll:
|
||||
mlme_deauthenticate_indication(
|
||||
hapd, sta,
|
||||
WLAN_REASON_PREV_AUTH_NOT_VALID);
|
||||
+ hostapd_ubus_notify(hapd, "inactive-deauth", sta->addr);
|
||||
ap_free_sta(hapd, sta);
|
||||
break;
|
||||
}
|
||||
@@ -1344,15 +1346,28 @@ void ap_sta_set_authorized(struct hostap
|
||||
sta->addr, authorized, dev_addr);
|
||||
|
||||
if (authorized) {
|
||||
+ static const char * const auth_algs[] = {
|
||||
+ [WLAN_AUTH_OPEN] = "open",
|
||||
+ [WLAN_AUTH_SHARED_KEY] = "shared",
|
||||
+ [WLAN_AUTH_FT] = "ft",
|
||||
+ [WLAN_AUTH_SAE] = "sae",
|
||||
+ [WLAN_AUTH_FILS_SK] = "fils-sk",
|
||||
+ [WLAN_AUTH_FILS_SK_PFS] = "fils-sk-pfs",
|
||||
+ [WLAN_AUTH_FILS_PK] = "fils-pk",
|
||||
+ [WLAN_AUTH_PASN] = "pasn",
|
||||
+ };
|
||||
+ const char *auth_alg = NULL;
|
||||
const u8 *dpp_pkhash;
|
||||
const char *keyid;
|
||||
char dpp_pkhash_buf[100];
|
||||
char keyid_buf[100];
|
||||
char ip_addr[100];
|
||||
+ char alg_buf[100];
|
||||
|
||||
dpp_pkhash_buf[0] = '\0';
|
||||
keyid_buf[0] = '\0';
|
||||
ip_addr[0] = '\0';
|
||||
+ alg_buf[0] = '\0';
|
||||
#ifdef CONFIG_P2P
|
||||
if (wpa_auth_get_ip_addr(sta->wpa_sm, ip_addr_buf) == 0) {
|
||||
os_snprintf(ip_addr, sizeof(ip_addr),
|
||||
@@ -1362,6 +1377,13 @@ void ap_sta_set_authorized(struct hostap
|
||||
}
|
||||
#endif /* CONFIG_P2P */
|
||||
|
||||
+ if (sta->auth_alg < ARRAY_SIZE(auth_algs))
|
||||
+ auth_alg = auth_algs[sta->auth_alg];
|
||||
+
|
||||
+ if (auth_alg)
|
||||
+ os_snprintf(alg_buf, sizeof(alg_buf),
|
||||
+ " auth_alg=%s", auth_alg);
|
||||
+
|
||||
keyid = ap_sta_wpa_get_keyid(hapd, sta);
|
||||
if (keyid) {
|
||||
os_snprintf(keyid_buf, sizeof(keyid_buf),
|
||||
@@ -1380,17 +1402,19 @@ void ap_sta_set_authorized(struct hostap
|
||||
dpp_pkhash, SHA256_MAC_LEN);
|
||||
}
|
||||
|
||||
- wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s%s",
|
||||
- buf, ip_addr, keyid_buf, dpp_pkhash_buf);
|
||||
+ hostapd_ubus_notify_authorized(hapd, sta);
|
||||
+ wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s%s%s",
|
||||
+ buf, ip_addr, keyid_buf, dpp_pkhash_buf, alg_buf);
|
||||
|
||||
if (hapd->msg_ctx_parent &&
|
||||
hapd->msg_ctx_parent != hapd->msg_ctx)
|
||||
wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO,
|
||||
- AP_STA_CONNECTED "%s%s%s%s",
|
||||
+ AP_STA_CONNECTED "%s%s%s%s%s",
|
||||
buf, ip_addr, keyid_buf,
|
||||
- dpp_pkhash_buf);
|
||||
+ dpp_pkhash_buf, alg_buf);
|
||||
} else {
|
||||
wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED "%s", buf);
|
||||
+ hostapd_ubus_notify(hapd, "disassoc", sta->addr);
|
||||
|
||||
if (hapd->msg_ctx_parent &&
|
||||
hapd->msg_ctx_parent != hapd->msg_ctx)
|
||||
--- a/src/ap/wpa_auth_glue.c
|
||||
+++ b/src/ap/wpa_auth_glue.c
|
||||
@@ -269,6 +269,7 @@ static void hostapd_wpa_auth_psk_failure
|
||||
struct hostapd_data *hapd = ctx;
|
||||
wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_POSSIBLE_PSK_MISMATCH MACSTR,
|
||||
MAC2STR(addr));
|
||||
+ hostapd_ubus_notify(hapd, "key-mismatch", addr);
|
||||
}
|
||||
|
||||
|
||||
--- a/wpa_supplicant/Makefile
|
||||
+++ b/wpa_supplicant/Makefile
|
||||
@@ -192,6 +192,13 @@ ifdef CONFIG_EAPOL_TEST
|
||||
CFLAGS += -Werror -DEAPOL_TEST
|
||||
endif
|
||||
|
||||
+ifdef CONFIG_UBUS
|
||||
+CFLAGS += -DUBUS_SUPPORT
|
||||
+OBJS += ubus.o
|
||||
+OBJS += ../src/utils/uloop.o
|
||||
+LIBS += -lubox -lubus
|
||||
+endif
|
||||
+
|
||||
ifdef CONFIG_CODE_COVERAGE
|
||||
CFLAGS += -O0 -fprofile-arcs -ftest-coverage
|
||||
LIBS += -lgcov
|
||||
@@ -987,6 +994,9 @@ ifdef CONFIG_CTRL_IFACE_MIB
|
||||
CFLAGS += -DCONFIG_CTRL_IFACE_MIB
|
||||
endif
|
||||
OBJS += ../src/ap/ctrl_iface_ap.o
|
||||
+ifdef CONFIG_UBUS
|
||||
+OBJS += ../src/ap/ubus.o
|
||||
+endif
|
||||
endif
|
||||
|
||||
CFLAGS += -DEAP_SERVER -DEAP_SERVER_IDENTITY
|
||||
--- a/wpa_supplicant/wpa_supplicant.c
|
||||
+++ b/wpa_supplicant/wpa_supplicant.c
|
||||
@@ -7593,6 +7593,8 @@ struct wpa_supplicant * wpa_supplicant_a
|
||||
}
|
||||
#endif /* CONFIG_P2P */
|
||||
|
||||
+ wpas_ubus_add_bss(wpa_s);
|
||||
+
|
||||
return wpa_s;
|
||||
}
|
||||
|
||||
@@ -7619,6 +7621,8 @@ int wpa_supplicant_remove_iface(struct w
|
||||
struct wpa_supplicant *parent = wpa_s->parent;
|
||||
#endif /* CONFIG_MESH */
|
||||
|
||||
+ wpas_ubus_free_bss(wpa_s);
|
||||
+
|
||||
/* Remove interface from the global list of interfaces */
|
||||
prev = global->ifaces;
|
||||
if (prev == wpa_s) {
|
||||
@@ -7965,8 +7969,12 @@ int wpa_supplicant_run(struct wpa_global
|
||||
eloop_register_signal_terminate(wpa_supplicant_terminate, global);
|
||||
eloop_register_signal_reconfig(wpa_supplicant_reconfig, global);
|
||||
|
||||
+ wpas_ubus_add(global);
|
||||
+
|
||||
eloop_run();
|
||||
|
||||
+ wpas_ubus_free(global);
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
--- a/wpa_supplicant/wpa_supplicant_i.h
|
||||
+++ b/wpa_supplicant/wpa_supplicant_i.h
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "config_ssid.h"
|
||||
#include "wmm_ac.h"
|
||||
#include "pasn/pasn_common.h"
|
||||
+#include "ubus.h"
|
||||
|
||||
extern const char *const wpa_supplicant_version;
|
||||
extern const char *const wpa_supplicant_license;
|
||||
@@ -319,6 +320,8 @@ struct wpa_global {
|
||||
#endif /* CONFIG_WIFI_DISPLAY */
|
||||
|
||||
struct psk_list_entry *add_psk; /* From group formation */
|
||||
+
|
||||
+ struct ubus_object ubus_global;
|
||||
};
|
||||
|
||||
|
||||
@@ -685,6 +688,7 @@ struct wpa_supplicant {
|
||||
unsigned char own_addr[ETH_ALEN];
|
||||
unsigned char perm_addr[ETH_ALEN];
|
||||
char ifname[100];
|
||||
+ struct wpas_ubus_bss ubus;
|
||||
#ifdef CONFIG_MATCH_IFACE
|
||||
int matched;
|
||||
#endif /* CONFIG_MATCH_IFACE */
|
||||
--- a/wpa_supplicant/wps_supplicant.c
|
||||
+++ b/wpa_supplicant/wps_supplicant.c
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "p2p/p2p.h"
|
||||
#include "p2p_supplicant.h"
|
||||
#include "wps_supplicant.h"
|
||||
+#include "ubus.h"
|
||||
|
||||
|
||||
#ifndef WPS_PIN_SCAN_IGNORE_SEL_REG
|
||||
@@ -402,6 +403,8 @@ static int wpa_supplicant_wps_cred(void
|
||||
wpa_hexdump_key(MSG_DEBUG, "WPS: Received Credential attribute",
|
||||
cred->cred_attr, cred->cred_attr_len);
|
||||
|
||||
+ wpas_ubus_notify(wpa_s, cred);
|
||||
+
|
||||
if (wpa_s->conf->wps_cred_processing == 1)
|
||||
return 0;
|
||||
|
||||
--- a/wpa_supplicant/main.c
|
||||
+++ b/wpa_supplicant/main.c
|
||||
@@ -203,7 +203,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (;;) {
|
||||
c = getopt(argc, argv,
|
||||
- "b:Bc:C:D:de:f:g:G:hi:I:KLMm:No:O:p:P:qsTtuv::W");
|
||||
+ "b:Bc:C:D:de:f:g:G:hi:I:KLMm:nNo:O:p:P:qsTtuv::W");
|
||||
if (c < 0)
|
||||
break;
|
||||
switch (c) {
|
||||
@@ -268,6 +268,9 @@ int main(int argc, char *argv[])
|
||||
params.conf_p2p_dev = optarg;
|
||||
break;
|
||||
#endif /* CONFIG_P2P */
|
||||
+ case 'n':
|
||||
+ iface_count = 0;
|
||||
+ break;
|
||||
case 'o':
|
||||
params.override_driver = optarg;
|
||||
break;
|
||||
--- a/src/ap/rrm.c
|
||||
+++ b/src/ap/rrm.c
|
||||
@@ -89,6 +89,9 @@ static void hostapd_handle_beacon_report
|
||||
return;
|
||||
wpa_msg(hapd->msg_ctx, MSG_INFO, BEACON_RESP_RX MACSTR " %u %02x %s",
|
||||
MAC2STR(addr), token, rep_mode, report);
|
||||
+ if (len < sizeof(struct rrm_measurement_beacon_report))
|
||||
+ return;
|
||||
+ hostapd_ubus_notify_beacon_report(hapd, addr, token, rep_mode, (struct rrm_measurement_beacon_report*) pos, len);
|
||||
}
|
||||
|
||||
|
||||
--- a/src/ap/vlan_init.c
|
||||
+++ b/src/ap/vlan_init.c
|
||||
@@ -22,6 +22,7 @@
|
||||
static int vlan_if_add(struct hostapd_data *hapd, struct hostapd_vlan *vlan,
|
||||
int existsok)
|
||||
{
|
||||
+ bool vlan_exists = iface_exists(vlan->ifname);
|
||||
int ret;
|
||||
#ifdef CONFIG_WEP
|
||||
int i;
|
||||
@@ -36,7 +37,7 @@ static int vlan_if_add(struct hostapd_da
|
||||
}
|
||||
#endif /* CONFIG_WEP */
|
||||
|
||||
- if (!iface_exists(vlan->ifname))
|
||||
+ if (!vlan_exists)
|
||||
ret = hostapd_vlan_if_add(hapd, vlan->ifname);
|
||||
else if (!existsok)
|
||||
return -1;
|
||||
@@ -51,6 +52,9 @@ static int vlan_if_add(struct hostapd_da
|
||||
if (hapd->wpa_auth)
|
||||
ret = wpa_auth_ensure_group(hapd->wpa_auth, vlan->vlan_id);
|
||||
|
||||
+ if (!ret && !vlan_exists)
|
||||
+ hostapd_ubus_add_vlan(hapd, vlan);
|
||||
+
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
|
||||
@@ -77,6 +81,8 @@ int vlan_if_remove(struct hostapd_data *
|
||||
"WPA deinitialization for VLAN %d failed (%d)",
|
||||
vlan->vlan_id, ret);
|
||||
|
||||
+ hostapd_ubus_remove_vlan(hapd, vlan);
|
||||
+
|
||||
return hostapd_vlan_if_remove(hapd, vlan->ifname);
|
||||
}
|
||||
|
||||
--- a/src/ap/dfs.c
|
||||
+++ b/src/ap/dfs.c
|
||||
@@ -1216,6 +1216,8 @@ int hostapd_dfs_pre_cac_expired(struct h
|
||||
"freq=%d ht_enabled=%d chan_offset=%d chan_width=%d cf1=%d cf2=%d",
|
||||
freq, ht_enabled, chan_offset, chan_width, cf1, cf2);
|
||||
|
||||
+ hostapd_ubus_notify_radar_detected(iface, freq, chan_width, cf1, cf2);
|
||||
+
|
||||
/* Proceed only if DFS is not offloaded to the driver */
|
||||
if (iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)
|
||||
return 0;
|
||||
--- a/src/ap/airtime_policy.c
|
||||
+++ b/src/ap/airtime_policy.c
|
||||
@@ -112,8 +112,14 @@ static void set_sta_weights(struct hosta
|
||||
{
|
||||
struct sta_info *sta;
|
||||
|
||||
- for (sta = hapd->sta_list; sta; sta = sta->next)
|
||||
- sta_set_airtime_weight(hapd, sta, weight);
|
||||
+ for (sta = hapd->sta_list; sta; sta = sta->next) {
|
||||
+ unsigned int sta_weight = weight;
|
||||
+
|
||||
+ if (sta->dyn_airtime_weight)
|
||||
+ sta_weight = (weight * sta->dyn_airtime_weight) / 256;
|
||||
+
|
||||
+ sta_set_airtime_weight(hapd, sta, sta_weight);
|
||||
+ }
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +250,10 @@ int airtime_policy_new_sta(struct hostap
|
||||
unsigned int weight;
|
||||
|
||||
if (hapd->iconf->airtime_mode == AIRTIME_MODE_STATIC) {
|
||||
- weight = get_weight_for_sta(hapd, sta->addr);
|
||||
+ if (sta->dyn_airtime_weight)
|
||||
+ weight = sta->dyn_airtime_weight;
|
||||
+ else
|
||||
+ weight = get_weight_for_sta(hapd, sta->addr);
|
||||
if (weight)
|
||||
return sta_set_airtime_weight(hapd, sta, weight);
|
||||
}
|
||||
--- a/src/ap/sta_info.h
|
||||
+++ b/src/ap/sta_info.h
|
||||
@@ -322,6 +322,7 @@ struct sta_info {
|
||||
#endif /* CONFIG_TESTING_OPTIONS */
|
||||
#ifdef CONFIG_AIRTIME_POLICY
|
||||
unsigned int airtime_weight;
|
||||
+ unsigned int dyn_airtime_weight;
|
||||
struct os_reltime backlogged_until;
|
||||
#endif /* CONFIG_AIRTIME_POLICY */
|
||||
|
||||
--- a/src/ap/wnm_ap.c
|
||||
+++ b/src/ap/wnm_ap.c
|
||||
@@ -455,7 +455,8 @@ static void ieee802_11_rx_bss_trans_mgmt
|
||||
MAC2STR(addr), reason, hex ? " neighbor=" : "", hex);
|
||||
os_free(hex);
|
||||
|
||||
- ieee802_11_send_bss_trans_mgmt_request(hapd, addr, dialog_token);
|
||||
+ if (!hostapd_ubus_notify_bss_transition_query(hapd, addr, dialog_token, reason, pos, end - pos))
|
||||
+ ieee802_11_send_bss_trans_mgmt_request(hapd, addr, dialog_token);
|
||||
}
|
||||
|
||||
|
||||
@@ -477,7 +478,7 @@ static void ieee802_11_rx_bss_trans_mgmt
|
||||
size_t len)
|
||||
{
|
||||
u8 dialog_token, status_code, bss_termination_delay;
|
||||
- const u8 *pos, *end;
|
||||
+ const u8 *pos, *end, *target_bssid = NULL;
|
||||
int enabled = hapd->conf->bss_transition;
|
||||
struct sta_info *sta;
|
||||
|
||||
@@ -524,6 +525,7 @@ static void ieee802_11_rx_bss_trans_mgmt
|
||||
wpa_printf(MSG_DEBUG, "WNM: not enough room for Target BSSID field");
|
||||
return;
|
||||
}
|
||||
+ target_bssid = pos;
|
||||
sta->agreed_to_steer = 1;
|
||||
eloop_cancel_timeout(ap_sta_reset_steer_flag_timer, hapd, sta);
|
||||
eloop_register_timeout(2, 0, ap_sta_reset_steer_flag_timer,
|
||||
@@ -543,6 +545,10 @@ static void ieee802_11_rx_bss_trans_mgmt
|
||||
MAC2STR(addr), status_code, bss_termination_delay);
|
||||
}
|
||||
|
||||
+ hostapd_ubus_notify_bss_transition_response(hapd, sta->addr, dialog_token,
|
||||
+ status_code, bss_termination_delay,
|
||||
+ target_bssid, pos, end - pos);
|
||||
+
|
||||
wpa_hexdump(MSG_DEBUG, "WNM: BSS Transition Candidate List Entries",
|
||||
pos, end - pos);
|
||||
}
|
||||
--- a/src/utils/eloop.c
|
||||
+++ b/src/utils/eloop.c
|
||||
@@ -77,6 +77,9 @@ struct eloop_sock_table {
|
||||
struct eloop_data {
|
||||
int max_sock;
|
||||
|
||||
+ eloop_timeout_poll_handler timeout_poll_cb;
|
||||
+ eloop_poll_handler poll_cb;
|
||||
+
|
||||
size_t count; /* sum of all table counts */
|
||||
#ifdef CONFIG_ELOOP_POLL
|
||||
size_t max_pollfd_map; /* number of pollfds_map currently allocated */
|
||||
@@ -1121,6 +1124,12 @@ void eloop_run(void)
|
||||
os_reltime_sub(&timeout->time, &now, &tv);
|
||||
else
|
||||
tv.sec = tv.usec = 0;
|
||||
+ }
|
||||
+
|
||||
+ if (eloop.timeout_poll_cb && eloop.timeout_poll_cb(&tv, !!timeout))
|
||||
+ timeout = (void *)1;
|
||||
+
|
||||
+ if (timeout) {
|
||||
#if defined(CONFIG_ELOOP_POLL) || defined(CONFIG_ELOOP_EPOLL)
|
||||
timeout_ms = tv.sec * 1000 + tv.usec / 1000;
|
||||
#endif /* defined(CONFIG_ELOOP_POLL) || defined(CONFIG_ELOOP_EPOLL) */
|
||||
@@ -1190,7 +1199,8 @@ void eloop_run(void)
|
||||
eloop.exceptions.changed = 0;
|
||||
|
||||
eloop_process_pending_signals();
|
||||
-
|
||||
+ if (eloop.poll_cb)
|
||||
+ eloop.poll_cb();
|
||||
|
||||
/* check if some registered timeouts have occurred */
|
||||
timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
|
||||
@@ -1252,6 +1262,14 @@ out:
|
||||
return;
|
||||
}
|
||||
|
||||
+int eloop_register_cb(eloop_poll_handler poll_cb,
|
||||
+ eloop_timeout_poll_handler timeout_cb)
|
||||
+{
|
||||
+ eloop.poll_cb = poll_cb;
|
||||
+ eloop.timeout_poll_cb = timeout_cb;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
|
||||
void eloop_terminate(void)
|
||||
{
|
||||
--- a/src/utils/eloop.h
|
||||
+++ b/src/utils/eloop.h
|
||||
@@ -65,6 +65,9 @@ typedef void (*eloop_timeout_handler)(vo
|
||||
*/
|
||||
typedef void (*eloop_signal_handler)(int sig, void *signal_ctx);
|
||||
|
||||
+typedef bool (*eloop_timeout_poll_handler)(struct os_reltime *tv, bool tv_set);
|
||||
+typedef void (*eloop_poll_handler)(void);
|
||||
+
|
||||
/**
|
||||
* eloop_init() - Initialize global event loop data
|
||||
* Returns: 0 on success, -1 on failure
|
||||
@@ -73,6 +76,9 @@ typedef void (*eloop_signal_handler)(int
|
||||
*/
|
||||
int eloop_init(void);
|
||||
|
||||
+int eloop_register_cb(eloop_poll_handler poll_cb,
|
||||
+ eloop_timeout_poll_handler timeout_cb);
|
||||
+
|
||||
/**
|
||||
* eloop_register_read_sock - Register handler for read events
|
||||
* @sock: File descriptor number for the socket
|
||||
@@ -320,6 +326,8 @@ int eloop_register_signal_reconfig(eloop
|
||||
*/
|
||||
int eloop_sock_requeue(void);
|
||||
|
||||
+void eloop_add_uloop(void);
|
||||
+
|
||||
/**
|
||||
* eloop_run - Start the event loop
|
||||
*
|
||||
--- /dev/null
|
||||
+++ b/src/utils/uloop.c
|
||||
@@ -0,0 +1,64 @@
|
||||
+#include <libubox/uloop.h>
|
||||
+#include "includes.h"
|
||||
+#include "common.h"
|
||||
+#include "eloop.h"
|
||||
+
|
||||
+static void eloop_uloop_event_cb(int sock, void *eloop_ctx, void *sock_ctx)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static void eloop_uloop_fd_cb(struct uloop_fd *fd, unsigned int events)
|
||||
+{
|
||||
+ unsigned int changed = events ^ fd->flags;
|
||||
+
|
||||
+ if (changed & ULOOP_READ) {
|
||||
+ if (events & ULOOP_READ)
|
||||
+ eloop_register_sock(fd->fd, EVENT_TYPE_READ, eloop_uloop_event_cb, fd, fd);
|
||||
+ else
|
||||
+ eloop_unregister_sock(fd->fd, EVENT_TYPE_READ);
|
||||
+ }
|
||||
+
|
||||
+ if (changed & ULOOP_WRITE) {
|
||||
+ if (events & ULOOP_WRITE)
|
||||
+ eloop_register_sock(fd->fd, EVENT_TYPE_WRITE, eloop_uloop_event_cb, fd, fd);
|
||||
+ else
|
||||
+ eloop_unregister_sock(fd->fd, EVENT_TYPE_WRITE);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static bool uloop_timeout_poll_handler(struct os_reltime *tv, bool tv_set)
|
||||
+{
|
||||
+ struct os_reltime tv_uloop;
|
||||
+ int timeout_ms = uloop_get_next_timeout();
|
||||
+
|
||||
+ if (timeout_ms < 0)
|
||||
+ return false;
|
||||
+
|
||||
+ tv_uloop.sec = timeout_ms / 1000;
|
||||
+ tv_uloop.usec = (timeout_ms % 1000) * 1000;
|
||||
+
|
||||
+ if (!tv_set || os_reltime_before(&tv_uloop, tv)) {
|
||||
+ *tv = tv_uloop;
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static void uloop_poll_handler(void)
|
||||
+{
|
||||
+ uloop_run_timeout(0);
|
||||
+}
|
||||
+
|
||||
+void eloop_add_uloop(void)
|
||||
+{
|
||||
+ static bool init_done = false;
|
||||
+
|
||||
+ if (!init_done) {
|
||||
+ uloop_init();
|
||||
+ uloop_fd_set_cb = eloop_uloop_fd_cb;
|
||||
+ init_done = true;
|
||||
+ }
|
||||
+
|
||||
+ eloop_register_cb(uloop_poll_handler, uloop_timeout_poll_handler);
|
||||
+}
|
||||
@@ -1,723 +0,0 @@
|
||||
--- a/hostapd/Makefile
|
||||
+++ b/hostapd/Makefile
|
||||
@@ -168,9 +168,21 @@ OBJS += ../src/eapol_auth/eapol_auth_sm.
|
||||
|
||||
ifdef CONFIG_UBUS
|
||||
CFLAGS += -DUBUS_SUPPORT
|
||||
-OBJS += ../src/utils/uloop.o
|
||||
OBJS += ../src/ap/ubus.o
|
||||
-LIBS += -lubox -lubus
|
||||
+LIBS += -lubus
|
||||
+NEED_ULOOP:=y
|
||||
+endif
|
||||
+
|
||||
+ifdef CONFIG_UCODE
|
||||
+CFLAGS += -DUCODE_SUPPORT
|
||||
+OBJS += ../src/utils/ucode.o
|
||||
+OBJS += ../src/ap/ucode.o
|
||||
+NEED_ULOOP:=y
|
||||
+endif
|
||||
+
|
||||
+ifdef NEED_ULOOP
|
||||
+OBJS += ../src/utils/uloop.o
|
||||
+LIBS += -lubox
|
||||
endif
|
||||
|
||||
ifdef CONFIG_CODE_COVERAGE
|
||||
--- a/hostapd/main.c
|
||||
+++ b/hostapd/main.c
|
||||
@@ -1007,6 +1007,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
hostapd_global_ctrl_iface_init(&interfaces);
|
||||
+ hostapd_ucode_init(&interfaces);
|
||||
|
||||
if (hostapd_global_run(&interfaces, daemonize, pid_file)) {
|
||||
wpa_printf(MSG_ERROR, "Failed to start eloop");
|
||||
@@ -1016,6 +1017,7 @@ int main(int argc, char *argv[])
|
||||
ret = 0;
|
||||
|
||||
out:
|
||||
+ hostapd_ucode_free();
|
||||
hostapd_global_ctrl_iface_deinit(&interfaces);
|
||||
/* Deinitialize all interfaces */
|
||||
for (i = 0; i < interfaces.count; i++) {
|
||||
--- a/src/ap/hostapd.h
|
||||
+++ b/src/ap/hostapd.h
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "ap_config.h"
|
||||
#include "drivers/driver.h"
|
||||
#include "ubus.h"
|
||||
+#include "ucode.h"
|
||||
|
||||
#define OCE_STA_CFON_ENABLED(hapd) \
|
||||
((hapd->conf->oce & OCE_STA_CFON) && \
|
||||
@@ -51,6 +52,10 @@ struct hapd_interfaces {
|
||||
struct hostapd_config * (*config_read_cb)(const char *config_fname);
|
||||
int (*ctrl_iface_init)(struct hostapd_data *hapd);
|
||||
void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
|
||||
+ int (*ctrl_iface_recv)(struct hostapd_data *hapd,
|
||||
+ char *buf, char *reply, int reply_size,
|
||||
+ struct sockaddr_storage *from,
|
||||
+ socklen_t fromlen);
|
||||
int (*for_each_interface)(struct hapd_interfaces *interfaces,
|
||||
int (*cb)(struct hostapd_iface *iface,
|
||||
void *ctx), void *ctx);
|
||||
@@ -186,6 +191,7 @@ struct hostapd_data {
|
||||
struct hostapd_config *iconf;
|
||||
struct hostapd_bss_config *conf;
|
||||
struct hostapd_ubus_bss ubus;
|
||||
+ struct hostapd_ucode_bss ucode;
|
||||
int interface_added; /* virtual interface added for this BSS */
|
||||
unsigned int started:1;
|
||||
unsigned int disabled:1;
|
||||
@@ -506,6 +512,7 @@ struct hostapd_sta_info {
|
||||
*/
|
||||
struct hostapd_iface {
|
||||
struct hapd_interfaces *interfaces;
|
||||
+ struct hostapd_ucode_iface ucode;
|
||||
void *owner;
|
||||
char *config_fname;
|
||||
struct hostapd_config *conf;
|
||||
@@ -706,6 +713,8 @@ struct hostapd_iface * hostapd_init(stru
|
||||
struct hostapd_iface *
|
||||
hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy,
|
||||
const char *config_fname, int debug);
|
||||
+int hostapd_setup_bss(struct hostapd_data *hapd, int first, bool start_beacon);
|
||||
+void hostapd_bss_deinit(struct hostapd_data *hapd);
|
||||
void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
int reassoc);
|
||||
void hostapd_interface_deinit_free(struct hostapd_iface *iface);
|
||||
@@ -732,6 +741,7 @@ hostapd_switch_channel_fallback(struct h
|
||||
void hostapd_cleanup_cs_params(struct hostapd_data *hapd);
|
||||
void hostapd_periodic_iface(struct hostapd_iface *iface);
|
||||
int hostapd_owe_trans_get_info(struct hostapd_data *hapd);
|
||||
+void hostapd_owe_update_trans(struct hostapd_iface *iface);
|
||||
void hostapd_ocv_check_csa_sa_query(void *eloop_ctx, void *timeout_ctx);
|
||||
|
||||
void hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap);
|
||||
--- a/src/ap/hostapd.c
|
||||
+++ b/src/ap/hostapd.c
|
||||
@@ -252,6 +252,8 @@ int hostapd_reload_config(struct hostapd
|
||||
struct hostapd_config *newconf, *oldconf;
|
||||
size_t j;
|
||||
|
||||
+ hostapd_ucode_reload_bss(hapd);
|
||||
+
|
||||
if (iface->config_fname == NULL) {
|
||||
/* Only in-memory config in use - assume it has been updated */
|
||||
hostapd_clear_old(iface);
|
||||
@@ -435,6 +437,7 @@ void hostapd_free_hapd_data(struct hosta
|
||||
hapd->beacon_set_done = 0;
|
||||
|
||||
wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
|
||||
+ hostapd_ucode_free_bss(hapd);
|
||||
hostapd_ubus_free_bss(hapd);
|
||||
accounting_deinit(hapd);
|
||||
hostapd_deinit_wpa(hapd);
|
||||
@@ -538,7 +541,7 @@ void hostapd_free_hapd_data(struct hosta
|
||||
* Most of the modules that are initialized in hostapd_setup_bss() are
|
||||
* deinitialized here.
|
||||
*/
|
||||
-static void hostapd_cleanup(struct hostapd_data *hapd)
|
||||
+void hostapd_cleanup(struct hostapd_data *hapd)
|
||||
{
|
||||
wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s))", __func__, hapd,
|
||||
hapd->conf ? hapd->conf->iface : "N/A");
|
||||
@@ -600,6 +603,7 @@ void hostapd_cleanup_iface_partial(struc
|
||||
static void hostapd_cleanup_iface(struct hostapd_iface *iface)
|
||||
{
|
||||
wpa_printf(MSG_DEBUG, "%s(%p)", __func__, iface);
|
||||
+ hostapd_ucode_free_iface(iface);
|
||||
eloop_cancel_timeout(hostapd_interface_setup_failure_handler, iface,
|
||||
NULL);
|
||||
|
||||
@@ -1189,6 +1193,7 @@ static int hostapd_start_beacon(struct h
|
||||
hapd->driver->set_operstate(hapd->drv_priv, 1);
|
||||
|
||||
hostapd_ubus_add_bss(hapd);
|
||||
+ hostapd_ucode_add_bss(hapd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1211,7 +1216,7 @@ static int hostapd_start_beacon(struct h
|
||||
* initialized. Most of the modules that are initialized here will be
|
||||
* deinitialized in hostapd_cleanup().
|
||||
*/
|
||||
-static int hostapd_setup_bss(struct hostapd_data *hapd, int first,
|
||||
+int hostapd_setup_bss(struct hostapd_data *hapd, int first,
|
||||
bool start_beacon)
|
||||
{
|
||||
struct hostapd_bss_config *conf = hapd->conf;
|
||||
@@ -2237,7 +2242,7 @@ static int hostapd_owe_iface_iter2(struc
|
||||
#endif /* CONFIG_OWE */
|
||||
|
||||
|
||||
-static void hostapd_owe_update_trans(struct hostapd_iface *iface)
|
||||
+void hostapd_owe_update_trans(struct hostapd_iface *iface)
|
||||
{
|
||||
#ifdef CONFIG_OWE
|
||||
/* Check whether the enabled BSS can complete OWE transition mode
|
||||
@@ -2698,7 +2703,7 @@ hostapd_alloc_bss_data(struct hostapd_if
|
||||
}
|
||||
|
||||
|
||||
-static void hostapd_bss_deinit(struct hostapd_data *hapd)
|
||||
+void hostapd_bss_deinit(struct hostapd_data *hapd)
|
||||
{
|
||||
if (!hapd)
|
||||
return;
|
||||
@@ -3491,7 +3496,8 @@ int hostapd_remove_iface(struct hapd_int
|
||||
hapd_iface = interfaces->iface[i];
|
||||
if (hapd_iface == NULL)
|
||||
return -1;
|
||||
- if (!os_strcmp(hapd_iface->conf->bss[0]->iface, buf)) {
|
||||
+ if (!os_strcmp(hapd_iface->phy, buf) ||
|
||||
+ !os_strcmp(hapd_iface->conf->bss[0]->iface, buf)) {
|
||||
wpa_printf(MSG_INFO, "Remove interface '%s'", buf);
|
||||
hapd_iface->driver_ap_teardown =
|
||||
!!(hapd_iface->drv_flags &
|
||||
--- a/wpa_supplicant/Makefile
|
||||
+++ b/wpa_supplicant/Makefile
|
||||
@@ -195,8 +195,20 @@ endif
|
||||
ifdef CONFIG_UBUS
|
||||
CFLAGS += -DUBUS_SUPPORT
|
||||
OBJS += ubus.o
|
||||
+LIBS += -lubus
|
||||
+NEED_ULOOP:=y
|
||||
+endif
|
||||
+
|
||||
+ifdef CONFIG_UCODE
|
||||
+CFLAGS += -DUCODE_SUPPORT
|
||||
+OBJS += ../src/utils/ucode.o
|
||||
+OBJS += ucode.o
|
||||
+NEED_ULOOP:=y
|
||||
+endif
|
||||
+
|
||||
+ifdef NEED_ULOOP
|
||||
OBJS += ../src/utils/uloop.o
|
||||
-LIBS += -lubox -lubus
|
||||
+LIBS += -lubox
|
||||
endif
|
||||
|
||||
ifdef CONFIG_CODE_COVERAGE
|
||||
@@ -997,6 +1009,9 @@ OBJS += ../src/ap/ctrl_iface_ap.o
|
||||
ifdef CONFIG_UBUS
|
||||
OBJS += ../src/ap/ubus.o
|
||||
endif
|
||||
+ifdef CONFIG_UCODE
|
||||
+OBJS += ../src/ap/ucode.o
|
||||
+endif
|
||||
endif
|
||||
|
||||
CFLAGS += -DEAP_SERVER -DEAP_SERVER_IDENTITY
|
||||
--- a/wpa_supplicant/wpa_supplicant.c
|
||||
+++ b/wpa_supplicant/wpa_supplicant.c
|
||||
@@ -1044,6 +1044,7 @@ void wpa_supplicant_set_state(struct wpa
|
||||
sme_sched_obss_scan(wpa_s, 0);
|
||||
}
|
||||
wpa_s->wpa_state = state;
|
||||
+ wpas_ucode_update_state(wpa_s);
|
||||
|
||||
#ifdef CONFIG_BGSCAN
|
||||
if (state == WPA_COMPLETED && wpa_s->current_ssid != wpa_s->bgscan_ssid)
|
||||
@@ -7594,6 +7595,7 @@ struct wpa_supplicant * wpa_supplicant_a
|
||||
#endif /* CONFIG_P2P */
|
||||
|
||||
wpas_ubus_add_bss(wpa_s);
|
||||
+ wpas_ucode_add_bss(wpa_s);
|
||||
|
||||
return wpa_s;
|
||||
}
|
||||
@@ -7621,6 +7623,7 @@ int wpa_supplicant_remove_iface(struct w
|
||||
struct wpa_supplicant *parent = wpa_s->parent;
|
||||
#endif /* CONFIG_MESH */
|
||||
|
||||
+ wpas_ucode_free_bss(wpa_s);
|
||||
wpas_ubus_free_bss(wpa_s);
|
||||
|
||||
/* Remove interface from the global list of interfaces */
|
||||
@@ -7931,6 +7934,7 @@ struct wpa_global * wpa_supplicant_init(
|
||||
|
||||
eloop_register_timeout(WPA_SUPPLICANT_CLEANUP_INTERVAL, 0,
|
||||
wpas_periodic, global, NULL);
|
||||
+ wpas_ucode_init(global);
|
||||
|
||||
return global;
|
||||
}
|
||||
@@ -7969,12 +7973,8 @@ int wpa_supplicant_run(struct wpa_global
|
||||
eloop_register_signal_terminate(wpa_supplicant_terminate, global);
|
||||
eloop_register_signal_reconfig(wpa_supplicant_reconfig, global);
|
||||
|
||||
- wpas_ubus_add(global);
|
||||
-
|
||||
eloop_run();
|
||||
|
||||
- wpas_ubus_free(global);
|
||||
-
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8007,6 +8007,8 @@ void wpa_supplicant_deinit(struct wpa_gl
|
||||
|
||||
wpas_notify_supplicant_deinitialized(global);
|
||||
|
||||
+ wpas_ucode_free();
|
||||
+
|
||||
eap_peer_unregister_methods();
|
||||
#ifdef CONFIG_AP
|
||||
eap_server_unregister_methods();
|
||||
--- a/wpa_supplicant/wpa_supplicant_i.h
|
||||
+++ b/wpa_supplicant/wpa_supplicant_i.h
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "wmm_ac.h"
|
||||
#include "pasn/pasn_common.h"
|
||||
#include "ubus.h"
|
||||
+#include "ucode.h"
|
||||
|
||||
extern const char *const wpa_supplicant_version;
|
||||
extern const char *const wpa_supplicant_license;
|
||||
@@ -689,6 +690,7 @@ struct wpa_supplicant {
|
||||
unsigned char perm_addr[ETH_ALEN];
|
||||
char ifname[100];
|
||||
struct wpas_ubus_bss ubus;
|
||||
+ struct wpas_ucode_bss ucode;
|
||||
#ifdef CONFIG_MATCH_IFACE
|
||||
int matched;
|
||||
#endif /* CONFIG_MATCH_IFACE */
|
||||
--- a/hostapd/ctrl_iface.c
|
||||
+++ b/hostapd/ctrl_iface.c
|
||||
@@ -4856,6 +4856,7 @@ try_again:
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ interface->ctrl_iface_recv = hostapd_ctrl_iface_receive_process;
|
||||
wpa_msg_register_cb(hostapd_ctrl_iface_msg_cb);
|
||||
|
||||
return 0;
|
||||
@@ -4957,6 +4958,7 @@ fail:
|
||||
os_free(fname);
|
||||
|
||||
interface->global_ctrl_sock = s;
|
||||
+ interface->ctrl_iface_recv = hostapd_ctrl_iface_receive_process;
|
||||
eloop_register_read_sock(s, hostapd_global_ctrl_iface_receive,
|
||||
interface, NULL);
|
||||
|
||||
--- a/src/drivers/driver.h
|
||||
+++ b/src/drivers/driver.h
|
||||
@@ -3787,6 +3787,25 @@ struct wpa_driver_ops {
|
||||
const char *ifname);
|
||||
|
||||
/**
|
||||
+ * if_rename - Rename a virtual interface
|
||||
+ * @priv: Private driver interface data
|
||||
+ * @type: Interface type
|
||||
+ * @ifname: Interface name of the virtual interface to be renamed
|
||||
+ * (NULL when renaming the AP BSS interface)
|
||||
+ * @new_name: New interface name of the virtual interface
|
||||
+ * Returns: 0 on success, -1 on failure
|
||||
+ */
|
||||
+ int (*if_rename)(void *priv, enum wpa_driver_if_type type,
|
||||
+ const char *ifname, const char *new_name);
|
||||
+
|
||||
+ /**
|
||||
+ * set_first_bss - Make a virtual interface the first (primary) bss
|
||||
+ * @priv: Private driver interface data
|
||||
+ * Returns: 0 on success, -1 on failure
|
||||
+ */
|
||||
+ int (*set_first_bss)(void *priv);
|
||||
+
|
||||
+ /**
|
||||
* set_sta_vlan - Bind a station into a specific interface (AP only)
|
||||
* @priv: Private driver interface data
|
||||
* @ifname: Interface (main or virtual BSS or VLAN)
|
||||
@@ -6440,6 +6459,7 @@ union wpa_event_data {
|
||||
|
||||
/**
|
||||
* struct ch_switch
|
||||
+ * @count: Count until channel switch activates
|
||||
* @freq: Frequency of new channel in MHz
|
||||
* @ht_enabled: Whether this is an HT channel
|
||||
* @ch_offset: Secondary channel offset
|
||||
@@ -6450,6 +6470,7 @@ union wpa_event_data {
|
||||
* @punct_bitmap: Puncturing bitmap
|
||||
*/
|
||||
struct ch_switch {
|
||||
+ int count;
|
||||
int freq;
|
||||
int ht_enabled;
|
||||
int ch_offset;
|
||||
--- a/src/drivers/driver_nl80211_event.c
|
||||
+++ b/src/drivers/driver_nl80211_event.c
|
||||
@@ -1202,6 +1202,7 @@ static void mlme_event_ch_switch(struct
|
||||
struct nlattr *bw, struct nlattr *cf1,
|
||||
struct nlattr *cf2,
|
||||
struct nlattr *punct_bitmap,
|
||||
+ struct nlattr *count,
|
||||
int finished)
|
||||
{
|
||||
struct i802_bss *bss;
|
||||
@@ -1265,6 +1266,8 @@ static void mlme_event_ch_switch(struct
|
||||
data.ch_switch.cf1 = nla_get_u32(cf1);
|
||||
if (cf2)
|
||||
data.ch_switch.cf2 = nla_get_u32(cf2);
|
||||
+ if (count)
|
||||
+ data.ch_switch.count = nla_get_u32(count);
|
||||
|
||||
if (finished)
|
||||
bss->flink->freq = data.ch_switch.freq;
|
||||
@@ -3912,6 +3915,7 @@ static void do_process_drv_event(struct
|
||||
tb[NL80211_ATTR_CENTER_FREQ1],
|
||||
tb[NL80211_ATTR_CENTER_FREQ2],
|
||||
tb[NL80211_ATTR_PUNCT_BITMAP],
|
||||
+ tb[NL80211_ATTR_CH_SWITCH_COUNT],
|
||||
0);
|
||||
break;
|
||||
case NL80211_CMD_CH_SWITCH_NOTIFY:
|
||||
@@ -3924,6 +3928,7 @@ static void do_process_drv_event(struct
|
||||
tb[NL80211_ATTR_CENTER_FREQ1],
|
||||
tb[NL80211_ATTR_CENTER_FREQ2],
|
||||
tb[NL80211_ATTR_PUNCT_BITMAP],
|
||||
+ NULL,
|
||||
1);
|
||||
break;
|
||||
case NL80211_CMD_DISCONNECT:
|
||||
--- a/wpa_supplicant/events.c
|
||||
+++ b/wpa_supplicant/events.c
|
||||
@@ -5389,6 +5389,7 @@ void supplicant_event(void *ctx, enum wp
|
||||
event_to_string(event), event);
|
||||
#endif /* CONFIG_NO_STDOUT_DEBUG */
|
||||
|
||||
+ wpas_ucode_event(wpa_s, event, data);
|
||||
switch (event) {
|
||||
case EVENT_AUTH:
|
||||
#ifdef CONFIG_FST
|
||||
--- a/src/ap/ap_drv_ops.h
|
||||
+++ b/src/ap/ap_drv_ops.h
|
||||
@@ -393,6 +393,23 @@ static inline int hostapd_drv_stop_ap(st
|
||||
return hapd->driver->stop_ap(hapd->drv_priv);
|
||||
}
|
||||
|
||||
+static inline int hostapd_drv_if_rename(struct hostapd_data *hapd,
|
||||
+ enum wpa_driver_if_type type,
|
||||
+ const char *ifname,
|
||||
+ const char *new_name)
|
||||
+{
|
||||
+ if (!hapd->driver || !hapd->driver->if_rename || !hapd->drv_priv)
|
||||
+ return -1;
|
||||
+ return hapd->driver->if_rename(hapd->drv_priv, type, ifname, new_name);
|
||||
+}
|
||||
+
|
||||
+static inline int hostapd_drv_set_first_bss(struct hostapd_data *hapd)
|
||||
+{
|
||||
+ if (!hapd->driver || !hapd->driver->set_first_bss || !hapd->drv_priv)
|
||||
+ return 0;
|
||||
+ return hapd->driver->set_first_bss(hapd->drv_priv);
|
||||
+}
|
||||
+
|
||||
static inline int hostapd_drv_channel_info(struct hostapd_data *hapd,
|
||||
struct wpa_channel_info *ci)
|
||||
{
|
||||
--- a/src/drivers/driver_nl80211.c
|
||||
+++ b/src/drivers/driver_nl80211.c
|
||||
@@ -1333,7 +1333,7 @@ static void wpa_driver_nl80211_event_rtm
|
||||
}
|
||||
wpa_printf(MSG_DEBUG, "nl80211: Interface down (%s/%s)",
|
||||
namebuf, ifname);
|
||||
- if (os_strcmp(drv->first_bss->ifname, ifname) != 0) {
|
||||
+ if (drv->first_bss->ifindex != ifi->ifi_index) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"nl80211: Not the main interface (%s) - do not indicate interface down",
|
||||
drv->first_bss->ifname);
|
||||
@@ -1369,7 +1369,7 @@ static void wpa_driver_nl80211_event_rtm
|
||||
}
|
||||
wpa_printf(MSG_DEBUG, "nl80211: Interface up (%s/%s)",
|
||||
namebuf, ifname);
|
||||
- if (os_strcmp(drv->first_bss->ifname, ifname) != 0) {
|
||||
+ if (drv->first_bss->ifindex != ifi->ifi_index) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"nl80211: Not the main interface (%s) - do not indicate interface up",
|
||||
drv->first_bss->ifname);
|
||||
@@ -8432,6 +8432,7 @@ static void *i802_init(struct hostapd_da
|
||||
char master_ifname[IFNAMSIZ];
|
||||
int ifindex, br_ifindex = 0;
|
||||
int br_added = 0;
|
||||
+ int err;
|
||||
|
||||
bss = wpa_driver_nl80211_drv_init(hapd, params->ifname,
|
||||
params->global_priv, 1,
|
||||
@@ -8491,21 +8492,17 @@ static void *i802_init(struct hostapd_da
|
||||
(params->num_bridge == 0 || !params->bridge[0]))
|
||||
add_ifidx(drv, br_ifindex, drv->ifindex);
|
||||
|
||||
- if (bss->added_if_into_bridge || bss->already_in_bridge) {
|
||||
- int err;
|
||||
-
|
||||
- drv->rtnl_sk = nl_socket_alloc();
|
||||
- if (drv->rtnl_sk == NULL) {
|
||||
- wpa_printf(MSG_ERROR, "nl80211: Failed to allocate nl_sock");
|
||||
- goto failed;
|
||||
- }
|
||||
+ drv->rtnl_sk = nl_socket_alloc();
|
||||
+ if (drv->rtnl_sk == NULL) {
|
||||
+ wpa_printf(MSG_ERROR, "nl80211: Failed to allocate nl_sock");
|
||||
+ goto failed;
|
||||
+ }
|
||||
|
||||
- err = nl_connect(drv->rtnl_sk, NETLINK_ROUTE);
|
||||
- if (err) {
|
||||
- wpa_printf(MSG_ERROR, "nl80211: Failed to connect nl_sock to NETLINK_ROUTE: %s",
|
||||
- nl_geterror(err));
|
||||
- goto failed;
|
||||
- }
|
||||
+ err = nl_connect(drv->rtnl_sk, NETLINK_ROUTE);
|
||||
+ if (err) {
|
||||
+ wpa_printf(MSG_ERROR, "nl80211: Failed to connect nl_sock to NETLINK_ROUTE: %s",
|
||||
+ nl_geterror(err));
|
||||
+ goto failed;
|
||||
}
|
||||
|
||||
if (drv->capa.flags2 & WPA_DRIVER_FLAGS2_CONTROL_PORT_RX) {
|
||||
@@ -8875,6 +8872,50 @@ static int wpa_driver_nl80211_if_remove(
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int wpa_driver_nl80211_if_rename(struct i802_bss *bss,
|
||||
+ enum wpa_driver_if_type type,
|
||||
+ const char *ifname, const char *new_name)
|
||||
+{
|
||||
+ struct wpa_driver_nl80211_data *drv = bss->drv;
|
||||
+ struct ifinfomsg ifi = {
|
||||
+ .ifi_family = AF_UNSPEC,
|
||||
+ .ifi_index = bss->ifindex,
|
||||
+ };
|
||||
+ struct nl_msg *msg;
|
||||
+ int res = -ENOMEM;
|
||||
+
|
||||
+ if (ifname)
|
||||
+ ifi.ifi_index = if_nametoindex(ifname);
|
||||
+
|
||||
+ msg = nlmsg_alloc_simple(RTM_SETLINK, 0);
|
||||
+ if (!msg)
|
||||
+ return res;
|
||||
+
|
||||
+ if (nlmsg_append(msg, &ifi, sizeof(ifi), NLMSG_ALIGNTO) < 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ if (nla_put_string(msg, IFLA_IFNAME, new_name))
|
||||
+ goto out;
|
||||
+
|
||||
+ res = nl_send_auto_complete(drv->rtnl_sk, msg);
|
||||
+ if (res < 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ res = nl_wait_for_ack(drv->rtnl_sk);
|
||||
+ if (res) {
|
||||
+ wpa_printf(MSG_INFO,
|
||||
+ "nl80211: Renaming device %s to %s failed: %s",
|
||||
+ ifname ? ifname : bss->ifname, new_name, nl_geterror(res));
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ if (type == WPA_IF_AP_BSS && !ifname)
|
||||
+ os_strlcpy(bss->ifname, new_name, sizeof(bss->ifname));
|
||||
+
|
||||
+out:
|
||||
+ nlmsg_free(msg);
|
||||
+ return res;
|
||||
+}
|
||||
|
||||
static int cookie_handler(struct nl_msg *msg, void *arg)
|
||||
{
|
||||
@@ -10513,6 +10554,37 @@ static int driver_nl80211_if_remove(void
|
||||
}
|
||||
|
||||
|
||||
+static int driver_nl80211_if_rename(void *priv, enum wpa_driver_if_type type,
|
||||
+ const char *ifname, const char *new_name)
|
||||
+{
|
||||
+ struct i802_bss *bss = priv;
|
||||
+ return wpa_driver_nl80211_if_rename(bss, type, ifname, new_name);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int driver_nl80211_set_first_bss(void *priv)
|
||||
+{
|
||||
+ struct i802_bss *bss = priv, *tbss;
|
||||
+ struct wpa_driver_nl80211_data *drv = bss->drv;
|
||||
+
|
||||
+ if (drv->first_bss == bss)
|
||||
+ return 0;
|
||||
+
|
||||
+ for (tbss = drv->first_bss; tbss; tbss = tbss->next) {
|
||||
+ if (tbss->next != bss)
|
||||
+ continue;
|
||||
+
|
||||
+ tbss->next = bss->next;
|
||||
+ bss->next = drv->first_bss;
|
||||
+ drv->first_bss = bss;
|
||||
+ drv->ctx = bss->ctx;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
static int driver_nl80211_send_mlme(void *priv, const u8 *data,
|
||||
size_t data_len, int noack,
|
||||
unsigned int freq,
|
||||
@@ -13697,6 +13769,8 @@ const struct wpa_driver_ops wpa_driver_n
|
||||
.set_acl = wpa_driver_nl80211_set_acl,
|
||||
.if_add = wpa_driver_nl80211_if_add,
|
||||
.if_remove = driver_nl80211_if_remove,
|
||||
+ .if_rename = driver_nl80211_if_rename,
|
||||
+ .set_first_bss = driver_nl80211_set_first_bss,
|
||||
.send_mlme = driver_nl80211_send_mlme,
|
||||
.get_hw_feature_data = nl80211_get_hw_feature_data,
|
||||
.sta_add = wpa_driver_nl80211_sta_add,
|
||||
--- a/src/ap/ieee802_11.c
|
||||
+++ b/src/ap/ieee802_11.c
|
||||
@@ -547,11 +547,16 @@ static const char * sae_get_password(str
|
||||
struct sae_pt **s_pt,
|
||||
const struct sae_pk **s_pk)
|
||||
{
|
||||
+ struct hostapd_bss_config *conf = hapd->conf;
|
||||
+ struct hostapd_ssid *ssid = &conf->ssid;
|
||||
+ struct hostapd_sta_wpa_psk_short *psk;
|
||||
const char *password = NULL;
|
||||
- struct sae_password_entry *pw;
|
||||
- struct sae_pt *pt = NULL;
|
||||
- const struct sae_pk *pk = NULL;
|
||||
- struct hostapd_sta_wpa_psk_short *psk = NULL;
|
||||
+ struct sae_password_entry *pw = NULL;
|
||||
+ struct sae_pt *pt = NULL;
|
||||
+ const struct sae_pk *pk = NULL;
|
||||
+
|
||||
+ if (sta && sta->use_sta_psk)
|
||||
+ goto use_sta_psk;
|
||||
|
||||
for (pw = hapd->conf->sae_passwords; pw; pw = pw->next) {
|
||||
if (!is_broadcast_ether_addr(pw->peer_addr) &&
|
||||
@@ -582,6 +587,31 @@ static const char * sae_get_password(str
|
||||
}
|
||||
}
|
||||
|
||||
+use_sta_psk:
|
||||
+ if (!password && sta) {
|
||||
+ for (psk = sta->psk; psk; psk = psk->next) {
|
||||
+ if (!psk->is_passphrase)
|
||||
+ continue;
|
||||
+
|
||||
+ password = psk->passphrase;
|
||||
+ if (!sta->use_sta_psk)
|
||||
+ break;
|
||||
+
|
||||
+ if (sta->sae_pt) {
|
||||
+ pt = sta->sae_pt;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ pt = sae_derive_pt(conf->sae_groups, ssid->ssid,
|
||||
+ ssid->ssid_len,
|
||||
+ (const u8 *) password,
|
||||
+ os_strlen(password),
|
||||
+ NULL);
|
||||
+ sta->sae_pt = pt;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (pw_entry)
|
||||
*pw_entry = pw;
|
||||
if (s_pt)
|
||||
@@ -3105,6 +3135,12 @@ static void handle_auth(struct hostapd_d
|
||||
goto fail;
|
||||
}
|
||||
|
||||
+ res = hostapd_ucode_sta_auth(hapd, sta);
|
||||
+ if (res) {
|
||||
+ resp = res;
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
sta->flags &= ~WLAN_STA_PREAUTH;
|
||||
ieee802_1x_notify_pre_auth(sta->eapol_sm, 0);
|
||||
|
||||
--- a/src/ap/sta_info.c
|
||||
+++ b/src/ap/sta_info.c
|
||||
@@ -425,6 +425,9 @@ void ap_free_sta(struct hostapd_data *ha
|
||||
forced_memzero(sta->last_tk, WPA_TK_MAX_LEN);
|
||||
#endif /* CONFIG_TESTING_OPTIONS */
|
||||
|
||||
+ if (sta->sae_pt)
|
||||
+ sae_deinit_pt(sta->sae_pt);
|
||||
+
|
||||
os_free(sta);
|
||||
}
|
||||
|
||||
@@ -1326,6 +1329,8 @@ void ap_sta_set_authorized(struct hostap
|
||||
sta->flags &= ~WLAN_STA_AUTHORIZED;
|
||||
}
|
||||
|
||||
+ if (authorized)
|
||||
+ hostapd_ucode_sta_connected(hapd, sta);
|
||||
#ifdef CONFIG_P2P
|
||||
if (hapd->p2p_group == NULL) {
|
||||
if (sta->p2p_ie != NULL &&
|
||||
--- a/src/ap/sta_info.h
|
||||
+++ b/src/ap/sta_info.h
|
||||
@@ -198,6 +198,9 @@ struct sta_info {
|
||||
int vlan_id_bound; /* updated by ap_sta_bind_vlan() */
|
||||
/* PSKs from RADIUS authentication server */
|
||||
struct hostapd_sta_wpa_psk_short *psk;
|
||||
+ struct sae_pt *sae_pt;
|
||||
+ int use_sta_psk;
|
||||
+ int psk_idx;
|
||||
|
||||
char *identity; /* User-Name from RADIUS */
|
||||
char *radius_cui; /* Chargeable-User-Identity from RADIUS */
|
||||
--- a/src/ap/wpa_auth_glue.c
|
||||
+++ b/src/ap/wpa_auth_glue.c
|
||||
@@ -341,6 +341,7 @@ static const u8 * hostapd_wpa_auth_get_p
|
||||
struct sta_info *sta = ap_get_sta(hapd, addr);
|
||||
const u8 *psk;
|
||||
|
||||
+ sta->psk_idx = 0;
|
||||
if (vlan_id)
|
||||
*vlan_id = 0;
|
||||
if (psk_len)
|
||||
@@ -387,13 +388,18 @@ static const u8 * hostapd_wpa_auth_get_p
|
||||
* returned psk which should not be returned again.
|
||||
* logic list (all hostapd_get_psk; all sta->psk)
|
||||
*/
|
||||
+ if (sta && sta->use_sta_psk)
|
||||
+ psk = NULL;
|
||||
if (sta && sta->psk && !psk) {
|
||||
struct hostapd_sta_wpa_psk_short *pos;
|
||||
+ int psk_idx;
|
||||
|
||||
if (vlan_id)
|
||||
*vlan_id = 0;
|
||||
psk = sta->psk->psk;
|
||||
+ sta->psk_idx = psk_idx = 1;
|
||||
for (pos = sta->psk; pos; pos = pos->next) {
|
||||
+ psk_idx++;
|
||||
if (pos->is_passphrase) {
|
||||
if (pbkdf2_sha1(pos->passphrase,
|
||||
hapd->conf->ssid.ssid,
|
||||
@@ -406,10 +412,14 @@ static const u8 * hostapd_wpa_auth_get_p
|
||||
pos->is_passphrase = 0;
|
||||
}
|
||||
if (pos->psk == prev_psk) {
|
||||
+ sta->psk_idx = psk_idx;
|
||||
psk = pos->next ? pos->next->psk : NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ if (!psk)
|
||||
+ sta->psk_idx = 0;
|
||||
}
|
||||
return psk;
|
||||
}
|
||||
@@ -1,539 +0,0 @@
|
||||
--- a/src/ap/wpa_auth.h
|
||||
+++ b/src/ap/wpa_auth.h
|
||||
@@ -16,7 +16,11 @@
|
||||
|
||||
struct vlan_description;
|
||||
struct mld_info;
|
||||
-
|
||||
+struct rate_description {
|
||||
+ u32 rx;
|
||||
+ u32 tx;
|
||||
+};
|
||||
+
|
||||
#define MAX_OWN_IE_OVERRIDE 256
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@@ -88,6 +92,7 @@ struct ft_rrb_frame {
|
||||
#define FT_RRB_IDENTITY 15
|
||||
#define FT_RRB_RADIUS_CUI 16
|
||||
#define FT_RRB_SESSION_TIMEOUT 17 /* le32 seconds */
|
||||
+#define FT_RRB_RATE_LIMIT 18
|
||||
|
||||
struct ft_rrb_tlv {
|
||||
le16 type;
|
||||
@@ -368,6 +373,10 @@ struct wpa_auth_callbacks {
|
||||
struct vlan_description *vlan);
|
||||
int (*get_vlan)(void *ctx, const u8 *sta_addr,
|
||||
struct vlan_description *vlan);
|
||||
+ int (*set_rate_limit)(void *ctx, const u8 *sta_addr,
|
||||
+ struct rate_description *rate);
|
||||
+ int (*get_rate_limit)(void *ctx, const u8 *sta_addr,
|
||||
+ struct rate_description *rate);
|
||||
int (*set_identity)(void *ctx, const u8 *sta_addr,
|
||||
const u8 *identity, size_t identity_len);
|
||||
size_t (*get_identity)(void *ctx, const u8 *sta_addr, const u8 **buf);
|
||||
@@ -536,7 +545,7 @@ int wpa_ft_fetch_pmk_r1(struct wpa_authe
|
||||
struct vlan_description *vlan,
|
||||
const u8 **identity, size_t *identity_len,
|
||||
const u8 **radius_cui, size_t *radius_cui_len,
|
||||
- int *session_timeout);
|
||||
+ int *session_timeout, struct rate_description *rate);
|
||||
|
||||
#endif /* CONFIG_IEEE80211R_AP */
|
||||
|
||||
--- a/src/ap/wpa_auth_glue.c
|
||||
+++ b/src/ap/wpa_auth_glue.c
|
||||
@@ -1200,6 +1200,40 @@ static int hostapd_wpa_auth_get_vlan(voi
|
||||
}
|
||||
|
||||
|
||||
+static int hostapd_wpa_auth_set_rate_limit(void *ctx, const u8 *sta_addr,
|
||||
+ struct rate_description *rate)
|
||||
+{
|
||||
+ struct hostapd_data *hapd = ctx;
|
||||
+ struct sta_info *sta;
|
||||
+
|
||||
+ sta = ap_get_sta(hapd, sta_addr);
|
||||
+ if (!sta || !sta->wpa_sm)
|
||||
+ return -1;
|
||||
+
|
||||
+ memcpy(sta->bandwidth, rate, sizeof(*rate));
|
||||
+ hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
|
||||
+ HOSTAPD_LEVEL_INFO, "rate-limit %d %d", sta->bandwidth[0], sta->bandwidth[1]);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int hostapd_wpa_auth_get_rate_limit(void *ctx, const u8 *sta_addr,
|
||||
+ struct rate_description *rate)
|
||||
+{
|
||||
+ struct hostapd_data *hapd = ctx;
|
||||
+ struct sta_info *sta;
|
||||
+
|
||||
+ sta = ap_get_sta(hapd, sta_addr);
|
||||
+ if (!sta)
|
||||
+ return -1;
|
||||
+
|
||||
+ memcpy(rate, sta->bandwidth, sizeof(*rate));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
static int
|
||||
hostapd_wpa_auth_set_identity(void *ctx, const u8 *sta_addr,
|
||||
const u8 *identity, size_t identity_len)
|
||||
@@ -1640,6 +1674,8 @@ int hostapd_setup_wpa(struct hostapd_dat
|
||||
.add_tspec = hostapd_wpa_auth_add_tspec,
|
||||
.set_vlan = hostapd_wpa_auth_set_vlan,
|
||||
.get_vlan = hostapd_wpa_auth_get_vlan,
|
||||
+ .set_rate_limit = hostapd_wpa_auth_set_rate_limit,
|
||||
+ .get_rate_limit = hostapd_wpa_auth_get_rate_limit,
|
||||
.set_identity = hostapd_wpa_auth_set_identity,
|
||||
.get_identity = hostapd_wpa_auth_get_identity,
|
||||
.set_radius_cui = hostapd_wpa_auth_set_radius_cui,
|
||||
--- a/src/ap/wpa_auth_ft.c
|
||||
+++ b/src/ap/wpa_auth_ft.c
|
||||
@@ -379,6 +379,14 @@ static size_t wpa_ft_vlan_len(const stru
|
||||
return tlv_len;
|
||||
}
|
||||
|
||||
+static size_t wpa_ft_rate_limit_len(const struct rate_description *rate)
|
||||
+{
|
||||
+ if (!rate || (!rate->rx && !rate->tx))
|
||||
+ return 0;
|
||||
+
|
||||
+ return (sizeof(struct ft_rrb_tlv) + 8);
|
||||
+}
|
||||
+
|
||||
|
||||
static size_t wpa_ft_vlan_lin(const struct vlan_description *vlan,
|
||||
u8 *start, u8 *endpos)
|
||||
@@ -434,10 +442,48 @@ static size_t wpa_ft_vlan_lin(const stru
|
||||
}
|
||||
|
||||
|
||||
+static size_t wpa_ft_rate_limit_lin(const struct rate_description *rate,
|
||||
+ u8 *start, u8 *endpos)
|
||||
+{
|
||||
+ size_t tlv_len;
|
||||
+ int i, len;
|
||||
+ struct ft_rrb_tlv *hdr;
|
||||
+ u8 *pos = start;
|
||||
+
|
||||
+ if (!rate)
|
||||
+ return 0;
|
||||
+
|
||||
+ tlv_len = 0;
|
||||
+ if (rate->rx || rate->tx) {
|
||||
+ tlv_len += sizeof(*hdr);
|
||||
+ if (start + tlv_len > endpos)
|
||||
+ return tlv_len;
|
||||
+ hdr = (struct ft_rrb_tlv *) pos;
|
||||
+ hdr->type = host_to_le16(FT_RRB_RATE_LIMIT);
|
||||
+ hdr->len = host_to_le16(2 * sizeof(le32));
|
||||
+ pos = start + tlv_len;
|
||||
+
|
||||
+ tlv_len += sizeof(u32);
|
||||
+ if (start + tlv_len > endpos)
|
||||
+ return tlv_len;
|
||||
+ WPA_PUT_LE32(pos, rate->rx);
|
||||
+ pos = start + tlv_len;
|
||||
+ tlv_len += sizeof(u32);
|
||||
+ if (start + tlv_len > endpos)
|
||||
+ return tlv_len;
|
||||
+ WPA_PUT_LE32(pos, rate->tx);
|
||||
+ pos = start + tlv_len;
|
||||
+ }
|
||||
+
|
||||
+ return tlv_len;
|
||||
+}
|
||||
+
|
||||
+
|
||||
static int wpa_ft_rrb_lin(const struct tlv_list *tlvs1,
|
||||
const struct tlv_list *tlvs2,
|
||||
const struct vlan_description *vlan,
|
||||
- u8 **plain, size_t *plain_len)
|
||||
+ u8 **plain, size_t *plain_len,
|
||||
+ const struct rate_description *rate)
|
||||
{
|
||||
u8 *pos, *endpos;
|
||||
size_t tlv_len;
|
||||
@@ -445,6 +491,7 @@ static int wpa_ft_rrb_lin(const struct t
|
||||
tlv_len = wpa_ft_tlv_len(tlvs1);
|
||||
tlv_len += wpa_ft_tlv_len(tlvs2);
|
||||
tlv_len += wpa_ft_vlan_len(vlan);
|
||||
+ tlv_len += wpa_ft_rate_limit_len(rate);
|
||||
|
||||
*plain_len = tlv_len;
|
||||
*plain = os_zalloc(tlv_len);
|
||||
@@ -458,6 +505,7 @@ static int wpa_ft_rrb_lin(const struct t
|
||||
pos += wpa_ft_tlv_lin(tlvs1, pos, endpos);
|
||||
pos += wpa_ft_tlv_lin(tlvs2, pos, endpos);
|
||||
pos += wpa_ft_vlan_lin(vlan, pos, endpos);
|
||||
+ pos += wpa_ft_rate_limit_lin(rate, pos, endpos);
|
||||
|
||||
/* validity check */
|
||||
if (pos != endpos) {
|
||||
@@ -526,7 +574,8 @@ static int wpa_ft_rrb_build(const u8 *ke
|
||||
const struct tlv_list *tlvs_auth,
|
||||
const struct vlan_description *vlan,
|
||||
const u8 *src_addr, u8 type,
|
||||
- u8 **packet, size_t *packet_len)
|
||||
+ u8 **packet, size_t *packet_len,
|
||||
+ const struct rate_description *rate)
|
||||
{
|
||||
u8 *plain = NULL, *auth = NULL, *pos, *tmp;
|
||||
size_t plain_len = 0, auth_len = 0;
|
||||
@@ -534,10 +583,10 @@ static int wpa_ft_rrb_build(const u8 *ke
|
||||
size_t pad_len = 0;
|
||||
|
||||
*packet = NULL;
|
||||
- if (wpa_ft_rrb_lin(tlvs_enc0, tlvs_enc1, vlan, &plain, &plain_len) < 0)
|
||||
+ if (wpa_ft_rrb_lin(tlvs_enc0, tlvs_enc1, vlan, &plain, &plain_len, rate) < 0)
|
||||
goto out;
|
||||
|
||||
- if (wpa_ft_rrb_lin(tlvs_auth, NULL, NULL, &auth, &auth_len) < 0)
|
||||
+ if (wpa_ft_rrb_lin(tlvs_auth, NULL, NULL, &auth, &auth_len, NULL) < 0)
|
||||
goto out;
|
||||
|
||||
*packet_len = sizeof(u16) + auth_len + plain_len;
|
||||
@@ -700,6 +749,24 @@ static int wpa_ft_get_vlan(struct wpa_au
|
||||
}
|
||||
|
||||
|
||||
+static int wpa_ft_get_rate_limit(struct wpa_authenticator *wpa_auth,
|
||||
+ const u8 *sta_addr, struct rate_description *rate)
|
||||
+{
|
||||
+ if (!wpa_auth->cb->get_rate_limit)
|
||||
+ return -1;
|
||||
+ return wpa_auth->cb->get_rate_limit(wpa_auth->cb_ctx, sta_addr, rate);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int wpa_ft_set_rate_limit(struct wpa_authenticator *wpa_auth,
|
||||
+ const u8 *sta_addr, struct rate_description *rate)
|
||||
+{
|
||||
+ if (!wpa_auth->cb->set_rate_limit)
|
||||
+ return -1;
|
||||
+ return wpa_auth->cb->set_rate_limit(wpa_auth->cb_ctx, sta_addr, rate);
|
||||
+}
|
||||
+
|
||||
+
|
||||
static int
|
||||
wpa_ft_set_identity(struct wpa_authenticator *wpa_auth, const u8 *sta_addr,
|
||||
const u8 *identity, size_t identity_len)
|
||||
@@ -1025,7 +1092,7 @@ wpa_ft_rrb_seq_req(struct wpa_authentica
|
||||
|
||||
if (wpa_ft_rrb_build(key, key_len, NULL, NULL, seq_req_auth, NULL,
|
||||
wpa_auth->addr, FT_PACKET_R0KH_R1KH_SEQ_REQ,
|
||||
- &packet, &packet_len) < 0) {
|
||||
+ &packet, &packet_len, NULL) < 0) {
|
||||
item = NULL; /* some other seq resp might still accept this */
|
||||
goto err;
|
||||
}
|
||||
@@ -1208,6 +1275,7 @@ struct wpa_ft_pmk_r0_sa {
|
||||
u8 spa[ETH_ALEN];
|
||||
int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
|
||||
struct vlan_description *vlan;
|
||||
+ struct rate_description *rate;
|
||||
os_time_t expiration; /* 0 for no expiration */
|
||||
u8 *identity;
|
||||
size_t identity_len;
|
||||
@@ -1226,6 +1294,7 @@ struct wpa_ft_pmk_r1_sa {
|
||||
u8 spa[ETH_ALEN];
|
||||
int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
|
||||
struct vlan_description *vlan;
|
||||
+ struct rate_description *rate;
|
||||
u8 *identity;
|
||||
size_t identity_len;
|
||||
u8 *radius_cui;
|
||||
@@ -1254,6 +1323,7 @@ static void wpa_ft_free_pmk_r0(struct wp
|
||||
|
||||
os_memset(r0->pmk_r0, 0, PMK_LEN_MAX);
|
||||
os_free(r0->vlan);
|
||||
+ os_free(r0->rate);
|
||||
os_free(r0->identity);
|
||||
os_free(r0->radius_cui);
|
||||
os_free(r0);
|
||||
@@ -1307,6 +1377,7 @@ static void wpa_ft_free_pmk_r1(struct wp
|
||||
eloop_cancel_timeout(wpa_ft_expire_pmk_r1, r1, NULL);
|
||||
|
||||
os_memset(r1->pmk_r1, 0, PMK_LEN_MAX);
|
||||
+ os_free(r1->rate);
|
||||
os_free(r1->vlan);
|
||||
os_free(r1->identity);
|
||||
os_free(r1->radius_cui);
|
||||
@@ -1360,7 +1431,8 @@ static int wpa_ft_store_pmk_r0(struct wp
|
||||
const struct vlan_description *vlan,
|
||||
int expires_in, int session_timeout,
|
||||
const u8 *identity, size_t identity_len,
|
||||
- const u8 *radius_cui, size_t radius_cui_len)
|
||||
+ const u8 *radius_cui, size_t radius_cui_len,
|
||||
+ struct rate_description *rate)
|
||||
{
|
||||
struct wpa_ft_pmk_cache *cache = wpa_auth->ft_pmk_cache;
|
||||
struct wpa_ft_pmk_r0_sa *r0;
|
||||
@@ -1388,6 +1460,14 @@ static int wpa_ft_store_pmk_r0(struct wp
|
||||
}
|
||||
*r0->vlan = *vlan;
|
||||
}
|
||||
+ if (rate) {
|
||||
+ r0->rate = os_zalloc(sizeof(*rate));
|
||||
+ if (!r0->rate) {
|
||||
+ bin_clear_free(r0, sizeof(*r0));
|
||||
+ return -1;
|
||||
+ }
|
||||
+ *r0->rate = *rate;
|
||||
+ }
|
||||
if (identity) {
|
||||
r0->identity = os_malloc(identity_len);
|
||||
if (r0->identity) {
|
||||
@@ -1447,7 +1527,8 @@ static int wpa_ft_store_pmk_r1(struct wp
|
||||
const struct vlan_description *vlan,
|
||||
int expires_in, int session_timeout,
|
||||
const u8 *identity, size_t identity_len,
|
||||
- const u8 *radius_cui, size_t radius_cui_len)
|
||||
+ const u8 *radius_cui, size_t radius_cui_len,
|
||||
+ struct rate_description *rate)
|
||||
{
|
||||
struct wpa_ft_pmk_cache *cache = wpa_auth->ft_pmk_cache;
|
||||
int max_expires_in = wpa_auth->conf.r1_max_key_lifetime;
|
||||
@@ -1477,6 +1558,14 @@ static int wpa_ft_store_pmk_r1(struct wp
|
||||
}
|
||||
*r1->vlan = *vlan;
|
||||
}
|
||||
+ if (rate) {
|
||||
+ r1->rate = os_zalloc(sizeof(*rate));
|
||||
+ if (!r1->rate) {
|
||||
+ bin_clear_free(r1, sizeof(*r1));
|
||||
+ return -1;
|
||||
+ }
|
||||
+ *r1->rate = *rate;
|
||||
+ }
|
||||
if (identity) {
|
||||
r1->identity = os_malloc(identity_len);
|
||||
if (r1->identity) {
|
||||
@@ -1513,7 +1602,7 @@ int wpa_ft_fetch_pmk_r1(struct wpa_authe
|
||||
struct vlan_description *vlan,
|
||||
const u8 **identity, size_t *identity_len,
|
||||
const u8 **radius_cui, size_t *radius_cui_len,
|
||||
- int *session_timeout)
|
||||
+ int *session_timeout, struct rate_description *rate)
|
||||
{
|
||||
struct wpa_ft_pmk_cache *cache = wpa_auth->ft_pmk_cache;
|
||||
struct wpa_ft_pmk_r1_sa *r1;
|
||||
@@ -1533,6 +1622,12 @@ int wpa_ft_fetch_pmk_r1(struct wpa_authe
|
||||
*vlan = *r1->vlan;
|
||||
if (vlan && !r1->vlan)
|
||||
os_memset(vlan, 0, sizeof(*vlan));
|
||||
+ if (rate) {
|
||||
+ if (r1->rate)
|
||||
+ *rate = *r1->rate;
|
||||
+ else
|
||||
+ memset(rate, 0, sizeof(*rate));
|
||||
+ }
|
||||
if (identity && identity_len) {
|
||||
*identity = r1->identity;
|
||||
*identity_len = r1->identity_len;
|
||||
@@ -2059,7 +2154,7 @@ static int wpa_ft_pull_pmk_r1(struct wpa
|
||||
|
||||
if (wpa_ft_rrb_build(key, key_len, req_enc, NULL, req_auth, NULL,
|
||||
sm->wpa_auth->addr, FT_PACKET_R0KH_R1KH_PULL,
|
||||
- &packet, &packet_len) < 0)
|
||||
+ &packet, &packet_len, NULL) < 0)
|
||||
return -1;
|
||||
|
||||
ft_pending_req_ies = wpabuf_alloc_copy(ies, ies_len);
|
||||
@@ -2088,6 +2183,7 @@ int wpa_ft_store_pmk_fils(struct wpa_sta
|
||||
{
|
||||
int expires_in = sm->wpa_auth->conf.r0_key_lifetime;
|
||||
struct vlan_description vlan;
|
||||
+ struct rate_description rate;
|
||||
const u8 *identity, *radius_cui;
|
||||
size_t identity_len, radius_cui_len;
|
||||
int session_timeout;
|
||||
@@ -2099,6 +2195,7 @@ int wpa_ft_store_pmk_fils(struct wpa_sta
|
||||
MAC2STR(sm->addr));
|
||||
return -1;
|
||||
}
|
||||
+ wpa_ft_get_rate_limit(sm->wpa_auth, sm->addr, &rate);
|
||||
|
||||
identity_len = wpa_ft_get_identity(sm->wpa_auth, sm->addr, &identity);
|
||||
radius_cui_len = wpa_ft_get_radius_cui(sm->wpa_auth, sm->addr,
|
||||
@@ -2108,7 +2205,7 @@ int wpa_ft_store_pmk_fils(struct wpa_sta
|
||||
return wpa_ft_store_pmk_r0(sm->wpa_auth, sm->addr, pmk_r0, pmk_r0_len,
|
||||
pmk_r0_name, sm->pairwise, &vlan, expires_in,
|
||||
session_timeout, identity, identity_len,
|
||||
- radius_cui, radius_cui_len);
|
||||
+ radius_cui, radius_cui_len, &rate);
|
||||
}
|
||||
|
||||
|
||||
@@ -2172,6 +2269,7 @@ void wpa_auth_ft_store_keys(struct wpa_s
|
||||
int psk_local = sm->wpa_auth->conf.ft_psk_generate_local;
|
||||
int expires_in = sm->wpa_auth->conf.r0_key_lifetime;
|
||||
struct vlan_description vlan;
|
||||
+ struct rate_description rate;
|
||||
const u8 *identity, *radius_cui;
|
||||
size_t identity_len, radius_cui_len;
|
||||
int session_timeout;
|
||||
@@ -2185,6 +2283,8 @@ void wpa_auth_ft_store_keys(struct wpa_s
|
||||
return;
|
||||
}
|
||||
|
||||
+ wpa_ft_get_rate_limit(sm->wpa_auth, sm->addr, &rate);
|
||||
+
|
||||
identity_len = wpa_ft_get_identity(sm->wpa_auth, sm->addr, &identity);
|
||||
radius_cui_len = wpa_ft_get_radius_cui(sm->wpa_auth, sm->addr,
|
||||
&radius_cui);
|
||||
@@ -2195,11 +2295,12 @@ void wpa_auth_ft_store_keys(struct wpa_s
|
||||
pmk_r0_name,
|
||||
sm->pairwise, &vlan, expires_in,
|
||||
session_timeout, identity, identity_len,
|
||||
- radius_cui, radius_cui_len);
|
||||
+ radius_cui, radius_cui_len, &rate);
|
||||
wpa_ft_store_pmk_r1(sm->wpa_auth, sm->addr, pmk_r1, key_len,
|
||||
sm->pmk_r1_name, sm->pairwise, &vlan,
|
||||
expires_in, session_timeout, identity,
|
||||
- identity_len, radius_cui, radius_cui_len);
|
||||
+ identity_len, radius_cui, radius_cui_len,
|
||||
+ &rate);
|
||||
}
|
||||
|
||||
|
||||
@@ -3100,7 +3201,8 @@ static int wpa_ft_local_derive_pmk_r1(st
|
||||
const u8 **radius_cui,
|
||||
size_t *radius_cui_len,
|
||||
int *out_session_timeout,
|
||||
- size_t *pmk_r1_len)
|
||||
+ size_t *pmk_r1_len,
|
||||
+ struct rate_description *rate)
|
||||
{
|
||||
struct wpa_auth_config *conf = &wpa_auth->conf;
|
||||
const struct wpa_ft_pmk_r0_sa *r0;
|
||||
@@ -3136,7 +3238,8 @@ static int wpa_ft_local_derive_pmk_r1(st
|
||||
out_pmk_r1_name,
|
||||
sm->pairwise, r0->vlan, expires_in, session_timeout,
|
||||
r0->identity, r0->identity_len,
|
||||
- r0->radius_cui, r0->radius_cui_len);
|
||||
+ r0->radius_cui, r0->radius_cui_len,
|
||||
+ r0->rate);
|
||||
|
||||
*out_pairwise = sm->pairwise;
|
||||
if (vlan) {
|
||||
@@ -3146,6 +3249,13 @@ static int wpa_ft_local_derive_pmk_r1(st
|
||||
os_memset(vlan, 0, sizeof(*vlan));
|
||||
}
|
||||
|
||||
+ if (rate) {
|
||||
+ if (r0->rate)
|
||||
+ *rate = *r0->rate;
|
||||
+ else
|
||||
+ os_memset(rate, 0, sizeof(*rate));
|
||||
+ }
|
||||
+
|
||||
if (identity && identity_len) {
|
||||
*identity = r0->identity;
|
||||
*identity_len = r0->identity_len;
|
||||
@@ -3178,6 +3288,7 @@ static int wpa_ft_process_auth_req(struc
|
||||
u8 *pos, *end;
|
||||
int pairwise, session_timeout = 0;
|
||||
struct vlan_description vlan;
|
||||
+ struct rate_description rate = {};
|
||||
const u8 *identity, *radius_cui;
|
||||
size_t identity_len = 0, radius_cui_len = 0;
|
||||
size_t pmk_r1_len, kdk_len, len;
|
||||
@@ -3274,7 +3385,7 @@ static int wpa_ft_process_auth_req(struc
|
||||
pmk_r1, &pmk_r1_len, &pairwise, &vlan,
|
||||
&identity, &identity_len, &radius_cui,
|
||||
&radius_cui_len,
|
||||
- &session_timeout) == 0) {
|
||||
+ &session_timeout, &rate) == 0) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"FT: Found PMKR1Name (using SHA%zu) from local cache",
|
||||
pmk_r1_len * 8);
|
||||
@@ -3290,7 +3401,7 @@ static int wpa_ft_process_auth_req(struc
|
||||
pmk_r1_name, pmk_r1, &pairwise,
|
||||
&vlan, &identity, &identity_len,
|
||||
&radius_cui, &radius_cui_len,
|
||||
- &session_timeout, &pmk_r1_len) == 0) {
|
||||
+ &session_timeout, &pmk_r1_len, &rate) == 0) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"FT: Generated PMK-R1 based on local PMK-R0");
|
||||
goto pmk_r1_derived;
|
||||
@@ -3392,6 +3503,7 @@ pmk_r1_derived:
|
||||
wpa_printf(MSG_DEBUG, "FT: Failed to configure VLAN");
|
||||
goto out;
|
||||
}
|
||||
+ wpa_ft_set_rate_limit(sm->wpa_auth, sm->addr, &rate);
|
||||
if (wpa_ft_set_identity(sm->wpa_auth, sm->addr,
|
||||
identity, identity_len) < 0 ||
|
||||
wpa_ft_set_radius_cui(sm->wpa_auth, sm->addr,
|
||||
@@ -3973,7 +4085,7 @@ static int wpa_ft_rrb_build_r0(const u8
|
||||
|
||||
ret = wpa_ft_rrb_build(key, key_len, tlvs, sess_tlv, tlv_auth,
|
||||
pmk_r0->vlan, src_addr, type,
|
||||
- packet, packet_len);
|
||||
+ packet, packet_len, pmk_r0->rate);
|
||||
|
||||
forced_memzero(pmk_r1, sizeof(pmk_r1));
|
||||
|
||||
@@ -4113,7 +4225,7 @@ static int wpa_ft_rrb_rx_pull(struct wpa
|
||||
ret = wpa_ft_rrb_build(key, key_len, resp, NULL, resp_auth,
|
||||
NULL, wpa_auth->addr,
|
||||
FT_PACKET_R0KH_R1KH_RESP,
|
||||
- &packet, &packet_len);
|
||||
+ &packet, &packet_len, NULL);
|
||||
} else {
|
||||
ret = wpa_ft_rrb_build_r0(key, key_len, resp, r0, f_r1kh_id,
|
||||
f_s1kh_id, resp_auth, wpa_auth->addr,
|
||||
@@ -4165,11 +4277,15 @@ static int wpa_ft_rrb_rx_r1(struct wpa_a
|
||||
size_t f_expires_in_len;
|
||||
size_t f_identity_len, f_radius_cui_len;
|
||||
size_t f_session_timeout_len;
|
||||
+ size_t f_rate_len;
|
||||
+ const u8 *f_rate;
|
||||
int pairwise;
|
||||
int ret = -1;
|
||||
int expires_in;
|
||||
int session_timeout;
|
||||
struct vlan_description vlan;
|
||||
+ struct rate_description rate;
|
||||
+ int has_rate = 0;
|
||||
size_t pmk_r1_len;
|
||||
|
||||
RRB_GET_AUTH(FT_RRB_R0KH_ID, r0kh_id, msgtype, -1);
|
||||
@@ -4279,6 +4395,13 @@ static int wpa_ft_rrb_rx_r1(struct wpa_a
|
||||
wpa_printf(MSG_DEBUG, "FT: vlan %d%s",
|
||||
le_to_host16(vlan.untagged), vlan.tagged[0] ? "+" : "");
|
||||
|
||||
+ RRB_GET_OPTIONAL(FT_RRB_RATE_LIMIT, rate, msgtype, 2 * sizeof(le32));
|
||||
+ if (f_rate) {
|
||||
+ memcpy(&rate, f_rate, sizeof(rate));
|
||||
+ rate.rx = le_to_host32(rate.rx);
|
||||
+ rate.tx = le_to_host32(rate.tx);
|
||||
+ has_rate = 1;
|
||||
+ };
|
||||
RRB_GET_OPTIONAL(FT_RRB_IDENTITY, identity, msgtype, -1);
|
||||
if (f_identity)
|
||||
wpa_hexdump_ascii(MSG_DEBUG, "FT: Identity", f_identity,
|
||||
@@ -4301,7 +4424,7 @@ static int wpa_ft_rrb_rx_r1(struct wpa_a
|
||||
f_pmk_r1_name,
|
||||
pairwise, &vlan, expires_in, session_timeout,
|
||||
f_identity, f_identity_len, f_radius_cui,
|
||||
- f_radius_cui_len) < 0)
|
||||
+ f_radius_cui_len, has_rate ? &rate : 0) < 0)
|
||||
goto out;
|
||||
|
||||
ret = 0;
|
||||
@@ -4614,7 +4737,7 @@ static int wpa_ft_rrb_rx_seq_req(struct
|
||||
|
||||
if (wpa_ft_rrb_build(key, key_len, NULL, NULL, seq_resp_auth, NULL,
|
||||
wpa_auth->addr, FT_PACKET_R0KH_R1KH_SEQ_RESP,
|
||||
- &packet, &packet_len) < 0)
|
||||
+ &packet, &packet_len, NULL) < 0)
|
||||
goto out;
|
||||
|
||||
wpa_ft_rrb_oui_send(wpa_auth, src_addr,
|
||||
@@ -1,10 +0,0 @@
|
||||
--- a/src/ap/wpa_auth_i.h
|
||||
+++ b/src/ap/wpa_auth_i.h
|
||||
@@ -54,6 +54,7 @@ struct wpa_state_machine {
|
||||
bool MICVerified;
|
||||
bool GUpdateStationKeys;
|
||||
u8 ANonce[WPA_NONCE_LEN];
|
||||
+ struct os_reltime ANonce_time;
|
||||
u8 SNonce[WPA_NONCE_LEN];
|
||||
u8 alt_SNonce[WPA_NONCE_LEN];
|
||||
u8 alt_replay_counter[WPA_REPLAY_COUNTER_LEN];
|
||||
@@ -1,147 +0,0 @@
|
||||
--- a/src/ap/ieee802_11.c
|
||||
+++ b/src/ap/ieee802_11.c
|
||||
@@ -522,6 +522,7 @@ static void handle_auth_ft_finish(void *
|
||||
|
||||
hostapd_logger(hapd, dst, HOSTAPD_MODULE_IEEE80211,
|
||||
HOSTAPD_LEVEL_DEBUG, "authentication OK (FT)");
|
||||
+ hostapd_ubus_notify(hapd, "ft-finish", sta->addr);
|
||||
sta->flags |= WLAN_STA_AUTH;
|
||||
mlme_authenticate_indication(hapd, sta);
|
||||
}
|
||||
@@ -5273,6 +5274,8 @@ static void handle_assoc(struct hostapd_
|
||||
}
|
||||
|
||||
sta = ap_get_sta(hapd, mgmt->sa);
|
||||
+ if (sta && reassoc)
|
||||
+ memcpy(sta->origin_ap, mgmt->u.reassoc_req.current_ap, 6);
|
||||
#ifdef CONFIG_IEEE80211R_AP
|
||||
if (sta && sta->auth_alg == WLAN_AUTH_FT &&
|
||||
(sta->flags & WLAN_STA_AUTH) == 0) {
|
||||
@@ -5426,6 +5429,7 @@ static void handle_assoc(struct hostapd_
|
||||
.type = HOSTAPD_UBUS_ASSOC_REQ,
|
||||
.mgmt_frame = mgmt,
|
||||
.ssi_signal = rssi,
|
||||
+ .reassoc = reassoc,
|
||||
};
|
||||
|
||||
/* followed by SSID and Supported rates; and HT capabilities if 802.11n
|
||||
@@ -6496,7 +6500,7 @@ static void handle_assoc_cb(struct hosta
|
||||
* Open, static WEP, FT protocol, or FILS; no separate
|
||||
* authorization step.
|
||||
*/
|
||||
- ap_sta_set_authorized(hapd, sta, 1);
|
||||
+ _ap_sta_set_authorized(hapd, sta, 1, reassoc);
|
||||
}
|
||||
|
||||
if (reassoc)
|
||||
--- a/src/ap/ubus.c
|
||||
+++ b/src/ap/ubus.c
|
||||
@@ -1870,6 +1870,8 @@ int hostapd_ubus_handle_event(struct hos
|
||||
if (req->ssi_signal)
|
||||
blobmsg_add_u32(&b, "signal", req->ssi_signal);
|
||||
blobmsg_add_u32(&b, "freq", hapd->iface->freq);
|
||||
+ if (req->reassoc && req->mgmt_frame)
|
||||
+ blobmsg_add_macaddr(&b, "origin", req->mgmt_frame->u.reassoc_req.current_ap);
|
||||
|
||||
if (req->elems) {
|
||||
if(req->elems->ht_capabilities)
|
||||
@@ -1940,6 +1942,7 @@ void hostapd_ubus_notify(struct hostapd_
|
||||
blob_buf_init(&b, 0);
|
||||
blobmsg_add_macaddr(&b, "address", addr);
|
||||
blobmsg_add_string(&b, "ifname", hapd->conf->iface);
|
||||
+ blobmsg_printf(&b, "target", MACSTR, MAC2STR(hapd->conf->bssid));
|
||||
|
||||
ubus_notify(ctx, &hapd->ubus.obj, type, b.head, -1);
|
||||
}
|
||||
@@ -1958,7 +1961,7 @@ void hostapd_ubus_notify_csa(struct host
|
||||
}
|
||||
|
||||
|
||||
-void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta)
|
||||
+void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta, int reassoc)
|
||||
{
|
||||
if (!hapd->ubus.obj.has_subscribers)
|
||||
return;
|
||||
@@ -1975,6 +1978,9 @@ void hostapd_ubus_notify_authorized(stru
|
||||
blobmsg_add_u32(&b, "", sta->bandwidth[1]);
|
||||
blobmsg_close_array(&b, r);
|
||||
}
|
||||
+ if (reassoc)
|
||||
+ blobmsg_add_macaddr(&b, "origin", sta->origin_ap);
|
||||
+ blobmsg_printf(&b, "target", MACSTR, MAC2STR(hapd->conf->bssid));
|
||||
|
||||
ubus_notify(ctx, &hapd->ubus.obj, "sta-authorized", b.head, -1);
|
||||
}
|
||||
--- a/src/ap/ubus.h
|
||||
+++ b/src/ap/ubus.h
|
||||
@@ -22,6 +22,7 @@ struct hostapd_ubus_request {
|
||||
const struct ieee802_11_elems *elems;
|
||||
int ssi_signal; /* dBm */
|
||||
const u8 *addr;
|
||||
+ int reassoc;
|
||||
};
|
||||
|
||||
struct hostapd_iface;
|
||||
@@ -49,7 +50,7 @@ void hostapd_ubus_remove_vlan(struct hos
|
||||
|
||||
int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req);
|
||||
void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *mac);
|
||||
-void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
+void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta, int reassoc);
|
||||
void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
|
||||
const u8 *addr, u8 token, u8 rep_mode,
|
||||
struct rrm_measurement_beacon_report *rep,
|
||||
--- a/src/ap/sta_info.c
|
||||
+++ b/src/ap/sta_info.c
|
||||
@@ -1297,8 +1297,8 @@ const u8 * ap_sta_wpa_get_dpp_pkhash(str
|
||||
}
|
||||
|
||||
|
||||
-void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
- int authorized)
|
||||
+void _ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
+ int authorized, int reassoc)
|
||||
{
|
||||
const u8 *dev_addr = NULL;
|
||||
char buf[100];
|
||||
@@ -1404,7 +1404,7 @@ void ap_sta_set_authorized(struct hostap
|
||||
dpp_pkhash, SHA256_MAC_LEN);
|
||||
}
|
||||
|
||||
- hostapd_ubus_notify_authorized(hapd, sta);
|
||||
+ hostapd_ubus_notify_authorized(hapd, sta, reassoc);
|
||||
wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s%s%s",
|
||||
buf, ip_addr, keyid_buf, dpp_pkhash_buf, alg_buf);
|
||||
|
||||
@@ -1434,6 +1434,11 @@ void ap_sta_set_authorized(struct hostap
|
||||
}
|
||||
#endif /* CONFIG_FST */
|
||||
}
|
||||
+void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
+ int authorized)
|
||||
+{
|
||||
+ _ap_sta_set_authorized(hapd, sta, authorized, 0);
|
||||
+}
|
||||
|
||||
|
||||
void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
--- a/src/ap/sta_info.h
|
||||
+++ b/src/ap/sta_info.h
|
||||
@@ -102,6 +102,7 @@ struct sta_info {
|
||||
struct sta_info *next; /* next entry in sta list */
|
||||
struct sta_info *hnext; /* next entry in hash table list */
|
||||
u8 addr[6];
|
||||
+ u8 origin_ap[6];
|
||||
be32 ipaddr;
|
||||
struct dl_list ip6addr; /* list head for struct ip6addr */
|
||||
u16 aid; /* STA's unique AID (1 .. 2007) or 0 if not yet assigned */
|
||||
@@ -398,6 +399,9 @@ const u8 * ap_sta_wpa_get_dpp_pkhash(str
|
||||
void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
const u8 *addr, u16 reason);
|
||||
|
||||
+void _ap_sta_set_authorized(struct hostapd_data *hapd,
|
||||
+ struct sta_info *sta, int authorized,
|
||||
+ int reassoc);
|
||||
void ap_sta_set_authorized(struct hostapd_data *hapd,
|
||||
struct sta_info *sta, int authorized);
|
||||
static inline int ap_sta_is_authorized(struct sta_info *sta)
|
||||
@@ -1,86 +0,0 @@
|
||||
--- a/hostapd/config_file.c
|
||||
+++ b/hostapd/config_file.c
|
||||
@@ -3152,6 +3152,8 @@ static int hostapd_config_fill(struct ho
|
||||
bss->ft_over_ds = atoi(pos);
|
||||
} else if (os_strcmp(buf, "ft_psk_generate_local") == 0) {
|
||||
bss->ft_psk_generate_local = atoi(pos);
|
||||
+ } else if (os_strcmp(buf, "ft_l2_refresh") == 0) {
|
||||
+ bss->ft_l2_refresh = atoi(pos);
|
||||
#endif /* CONFIG_IEEE80211R_AP */
|
||||
#ifndef CONFIG_NO_CTRL_IFACE
|
||||
} else if (os_strcmp(buf, "ctrl_interface") == 0) {
|
||||
--- a/src/ap/ap_config.h
|
||||
+++ b/src/ap/ap_config.h
|
||||
@@ -401,6 +401,7 @@ struct hostapd_bss_config {
|
||||
int pmk_r1_push;
|
||||
int ft_over_ds;
|
||||
int ft_psk_generate_local;
|
||||
+ int ft_l2_refresh;
|
||||
int r1_max_key_lifetime;
|
||||
#endif /* CONFIG_IEEE80211R_AP */
|
||||
|
||||
--- a/src/ap/wpa_auth_glue.c
|
||||
+++ b/src/ap/wpa_auth_glue.c
|
||||
@@ -1495,6 +1495,28 @@ static void hostapd_request_radius_psk(v
|
||||
#endif /* CONFIG_NO_RADIUS */
|
||||
|
||||
|
||||
+static void wpa_ft_refresh(void *eloop_data, void *user_data)
|
||||
+{
|
||||
+ struct hostapd_data *hapd = eloop_data;
|
||||
+ struct ft_rrb_frame *frame;
|
||||
+ struct l2_ethhdr *buf;
|
||||
+ size_t len;
|
||||
+
|
||||
+ len = sizeof(*buf) + sizeof(*frame);
|
||||
+ buf = os_zalloc(len);
|
||||
+ frame = (struct ft_rrb_frame *)(buf + 1);
|
||||
+ frame->frame_type = RSN_REMOTE_FRAME_TYPE_FT_RRB;
|
||||
+ frame->packet_type = FT_PACKET_REQUEST;
|
||||
+ memset(buf->h_dest, 0xff, ETH_ALEN);
|
||||
+ os_memcpy(buf->h_source, hapd->own_addr, ETH_ALEN);
|
||||
+ buf->h_proto = host_to_be16(ETH_P_RRB);
|
||||
+ l2_packet_send(hapd->l2, buf->h_dest, ETH_P_RRB, (u8 *) buf, len);
|
||||
+ os_free(buf);
|
||||
+
|
||||
+ eloop_register_timeout(hapd->conf->ft_l2_refresh, 0, wpa_ft_refresh,
|
||||
+ hapd, NULL);
|
||||
+}
|
||||
+
|
||||
int hostapd_setup_wpa(struct hostapd_data *hapd)
|
||||
{
|
||||
struct wpa_auth_config _conf;
|
||||
@@ -1640,6 +1662,9 @@ int hostapd_setup_wpa(struct hostapd_dat
|
||||
"Failed to open ETH_P_OUI interface");
|
||||
return -1;
|
||||
}
|
||||
+
|
||||
+ if (hapd->conf->ft_l2_refresh)
|
||||
+ wpa_ft_refresh(hapd, NULL);
|
||||
}
|
||||
#endif /* CONFIG_IEEE80211R_AP */
|
||||
|
||||
@@ -1655,7 +1680,6 @@ void hostapd_reconfig_wpa(struct hostapd
|
||||
wpa_reconfig(hapd->wpa_auth, &wpa_auth_conf);
|
||||
}
|
||||
|
||||
-
|
||||
void hostapd_deinit_wpa(struct hostapd_data *hapd)
|
||||
{
|
||||
ieee80211_tkip_countermeasures_deinit(hapd);
|
||||
@@ -1679,6 +1703,7 @@ void hostapd_deinit_wpa(struct hostapd_d
|
||||
"information element from interface %s",
|
||||
hapd->conf->iface);
|
||||
}
|
||||
+
|
||||
}
|
||||
ieee802_1x_deinit(hapd);
|
||||
|
||||
@@ -1687,6 +1712,7 @@ void hostapd_deinit_wpa(struct hostapd_d
|
||||
hostapd_wpa_ft_rrb_rx_later(hapd, NULL); /* flush without delivering */
|
||||
eloop_cancel_timeout(hostapd_oui_deliver_later, hapd, ELOOP_ALL_CTX);
|
||||
hostapd_oui_deliver_later(hapd, NULL); /* flush without delivering */
|
||||
+ eloop_cancel_timeout(wpa_ft_refresh, hapd, ELOOP_ALL_CTX);
|
||||
l2_packet_deinit(hapd->l2);
|
||||
hapd->l2 = NULL;
|
||||
hostapd_wpa_unregister_ft_oui(hapd);
|
||||
@@ -1,27 +0,0 @@
|
||||
--- a/src/ap/hostapd.c
|
||||
+++ b/src/ap/hostapd.c
|
||||
@@ -1995,6 +1995,13 @@ static int hostapd_owe_iface_iter(struct
|
||||
is_zero_ether_addr(bss->own_addr))
|
||||
continue;
|
||||
|
||||
+ if (!os_memcmp(hapd->conf->owe_transition_bssid, bss->own_addr,
|
||||
+ ETH_ALEN) &&
|
||||
+ hapd->conf->owe_transition_ssid_len == bss->conf->ssid.ssid_len &&
|
||||
+ !os_memcmp(hapd->conf->owe_transition_ssid, bss->conf->ssid.ssid,
|
||||
+ bss->conf->ssid.ssid_len))
|
||||
+ return 0;
|
||||
+
|
||||
os_memcpy(hapd->conf->owe_transition_bssid, bss->own_addr,
|
||||
ETH_ALEN);
|
||||
os_memcpy(hapd->conf->owe_transition_ssid,
|
||||
@@ -2011,10 +2018,6 @@ static int hostapd_owe_iface_iter(struct
|
||||
|
||||
int hostapd_owe_trans_get_info(struct hostapd_data *hapd)
|
||||
{
|
||||
- if (hapd->conf->owe_transition_ssid_len > 0 &&
|
||||
- !is_zero_ether_addr(hapd->conf->owe_transition_bssid))
|
||||
- return 0;
|
||||
-
|
||||
/* Find transition mode SSID/BSSID information from a BSS operated by
|
||||
* this hostapd instance. */
|
||||
if (!hapd->iface->interfaces ||
|
||||
@@ -1,53 +0,0 @@
|
||||
From 98b6503b87bb36bf2f5ae16e52e230e8870c867f Mon Sep 17 00:00:00 2001
|
||||
From: Venkat Chimata <venkata@shasta.cloud>
|
||||
Date: Fri, 28 Jun 2024 14:39:31 +0530
|
||||
Subject: [PATCH] hostapd: Fix DVLAN + 802.1x issue
|
||||
|
||||
In case of swconfig switches, the basename of the interface should be based on the last dot.
|
||||
Earlier it was done based on the first dot, which would result in incorrect basename.
|
||||
For example if the interface name is eth0.4087 then the vlan->ifname would be eth0.4087. (A dot at the end) .
|
||||
Before this patch, the basename was returned as eth0. It should be eth0.4087
|
||||
|
||||
Also fixed the return code by adding a default value of 0 and removed an unncessary check
|
||||
for if_add before ubus add call.
|
||||
|
||||
Signed-off-by: Venkat Chimata <venkata@shasta.cloud>
|
||||
---
|
||||
src/ap/vlan_init.c | 7 ++++---
|
||||
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/ap/vlan_init.c b/src/ap/vlan_init.c
|
||||
index 3e27671..cfeb1e5 100644
|
||||
--- a/src/ap/vlan_init.c
|
||||
+++ b/src/ap/vlan_init.c
|
||||
@@ -23,7 +23,8 @@ static int vlan_if_add(struct hostapd_data *hapd, struct hostapd_vlan *vlan,
|
||||
int existsok)
|
||||
{
|
||||
bool vlan_exists = iface_exists(vlan->ifname);
|
||||
- int ret;
|
||||
+ int ret = 0;
|
||||
+
|
||||
#ifdef CONFIG_WEP
|
||||
int i;
|
||||
|
||||
@@ -38,7 +39,7 @@ static int vlan_if_add(struct hostapd_data *hapd, struct hostapd_vlan *vlan,
|
||||
#endif /* CONFIG_WEP */
|
||||
|
||||
if (!hapd->driver || !hapd->driver->if_add) {
|
||||
- char *dot = strstr(vlan->ifname, ".");
|
||||
+ char *dot = strrchr(vlan->ifname, '.');
|
||||
if (dot)
|
||||
*dot = '\0';
|
||||
ret = 0;
|
||||
@@ -59,7 +60,7 @@ static int vlan_if_add(struct hostapd_data *hapd, struct hostapd_vlan *vlan,
|
||||
if (hapd->wpa_auth)
|
||||
ret = wpa_auth_ensure_group(hapd->wpa_auth, vlan->vlan_id);
|
||||
|
||||
- if (!ret && !vlan_exists && hapd->driver->if_add)
|
||||
+ if (!ret && !vlan_exists)
|
||||
hostapd_ubus_add_vlan(hapd, vlan);
|
||||
|
||||
if (ret == 0)
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
--- a/src/ap/beacon.c
|
||||
+++ b/src/ap/beacon.c
|
||||
@@ -934,8 +934,10 @@ void handle_probe_req(struct hostapd_dat
|
||||
int ubus_response;
|
||||
|
||||
if (hapd->iconf->rssi_ignore_probe_request && ssi_signal &&
|
||||
- ssi_signal < hapd->iconf->rssi_ignore_probe_request)
|
||||
+ ssi_signal < hapd->iconf->rssi_ignore_probe_request) {
|
||||
+ hostapd_ubus_notify_rssi(hapd, "rssi-ignore-probe", mgmt->sa, ssi_signal);
|
||||
return;
|
||||
+ }
|
||||
|
||||
if (len < IEEE80211_HDRLEN)
|
||||
return;
|
||||
@@ -1,11 +0,0 @@
|
||||
--- a/src/radius/radius.c
|
||||
+++ b/src/radius/radius.c
|
||||
@@ -755,7 +755,7 @@ struct radius_attr_hdr * radius_msg_add_
|
||||
ext->length = sizeof(*ext) + 1 + alen;
|
||||
ext->ext_type = ext_type;
|
||||
wpabuf_put_u8(msg->buf, data_len > alen ? 0x80 : 0);
|
||||
- wpabuf_put_data(msg->buf, data, data_len);
|
||||
+ wpabuf_put_data(msg->buf, data, alen);
|
||||
data += alen;
|
||||
data_len -= alen;
|
||||
if (radius_msg_add_attr_to_array(
|
||||
@@ -1,69 +0,0 @@
|
||||
--- a/hostapd/config_file.c
|
||||
+++ b/hostapd/config_file.c
|
||||
@@ -3154,6 +3154,8 @@ static int hostapd_config_fill(struct ho
|
||||
bss->ft_psk_generate_local = atoi(pos);
|
||||
} else if (os_strcmp(buf, "ft_l2_refresh") == 0) {
|
||||
bss->ft_l2_refresh = atoi(pos);
|
||||
+ } else if (os_strcmp(buf, "ft_key") == 0) {
|
||||
+ strncpy(bss->ft_key, pos, sizeof(bss->ft_key));
|
||||
#endif /* CONFIG_IEEE80211R_AP */
|
||||
#ifndef CONFIG_NO_CTRL_IFACE
|
||||
} else if (os_strcmp(buf, "ctrl_interface") == 0) {
|
||||
@@ -4996,8 +4998,22 @@ struct hostapd_config * hostapd_config_r
|
||||
|
||||
fclose(f);
|
||||
|
||||
- for (i = 0; i < conf->num_bss; i++)
|
||||
+ for (i = 0; i < conf->num_bss; i++) {
|
||||
+ if (*conf->bss[i]->ft_key) {
|
||||
+ u8 buffer[128];
|
||||
+ sprintf(buffer, "%02X:%02X:%02X:%02X:%02X:%02X %02X%02X%02X%02X%02X%02X %s", MAC2STR(conf->bss[i]->bssid), MAC2STR(conf->bss[i]->bssid), conf->bss[i]->ft_key);
|
||||
+ add_r0kh(conf->bss[i], buffer);
|
||||
+ sprintf(buffer, "%02X:%02X:%02X:%02X:%02X:%02X %02X:%02X:%02X:%02X:%02X:%02X %s", MAC2STR(conf->bss[i]->bssid), MAC2STR(conf->bss[i]->bssid), conf->bss[i]->ft_key);
|
||||
+ add_r1kh(conf->bss[i], buffer);
|
||||
+ sprintf(buffer, "ff:ff:ff:ff:ff:ff * %s", conf->bss[i]->ft_key);
|
||||
+ add_r0kh(conf->bss[i], buffer);
|
||||
+ sprintf(buffer, "00:00:00:00:00:00 00:00:00:00:00:00 %s", conf->bss[i]->ft_key);
|
||||
+ add_r1kh(conf->bss[i], buffer);
|
||||
+ hexstr2bin(conf->bss[i]->bssid, conf->bss[i]->r1_key_holder, FT_R1KH_ID_LEN);
|
||||
+ conf->bss[i]->r0_key_holder_bssid = 1;
|
||||
+ }
|
||||
hostapd_set_security_params(conf->bss[i], 1);
|
||||
+ }
|
||||
|
||||
if (hostapd_config_check(conf, 1))
|
||||
errors++;
|
||||
--- a/src/ap/ap_config.h
|
||||
+++ b/src/ap/ap_config.h
|
||||
@@ -403,6 +403,7 @@ struct hostapd_bss_config {
|
||||
int ft_psk_generate_local;
|
||||
int ft_l2_refresh;
|
||||
int r1_max_key_lifetime;
|
||||
+ u8 ft_key[65];
|
||||
#endif /* CONFIG_IEEE80211R_AP */
|
||||
|
||||
char *ctrl_interface; /* directory for UNIX domain sockets */
|
||||
--- a/src/ap/ap_config.h
|
||||
+++ b/src/ap/ap_config.h
|
||||
@@ -390,6 +390,7 @@ struct hostapd_bss_config {
|
||||
/* IEEE 802.11r - Fast BSS Transition */
|
||||
u8 mobility_domain[MOBILITY_DOMAIN_ID_LEN];
|
||||
u8 r1_key_holder[FT_R1KH_ID_LEN];
|
||||
+ int r0_key_holder_bssid;
|
||||
u32 r0_key_lifetime; /* PMK-R0 lifetime seconds */
|
||||
int rkh_pos_timeout;
|
||||
int rkh_neg_timeout;
|
||||
--- a/src/ap/wpa_auth_glue.c
|
||||
+++ b/src/ap/wpa_auth_glue.c
|
||||
@@ -80,7 +80,10 @@ static void hostapd_wpa_auth_conf(struct
|
||||
os_memcpy(wconf->ssid, conf->ssid.ssid, wconf->ssid_len);
|
||||
os_memcpy(wconf->mobility_domain, conf->mobility_domain,
|
||||
MOBILITY_DOMAIN_ID_LEN);
|
||||
- if (conf->nas_identifier &&
|
||||
+ if (1 || conf->r0_key_holder_bssid) {
|
||||
+ sprintf(wconf->r0_key_holder, "%02X%02X%02X%02X%02X%02X", MAC2STR(conf->bssid));
|
||||
+ wconf->r0_key_holder_len = 12;
|
||||
+ } else if (conf->nas_identifier &&
|
||||
os_strlen(conf->nas_identifier) <= FT_R0KH_ID_MAX_LEN) {
|
||||
wconf->r0_key_holder_len = os_strlen(conf->nas_identifier);
|
||||
os_memcpy(wconf->r0_key_holder, conf->nas_identifier,
|
||||
@@ -1,46 +0,0 @@
|
||||
Index: hostapd-2023-09-08-e5ccbfc6/src/ap/wpa_auth_ft.c
|
||||
===================================================================
|
||||
--- hostapd-2023-09-08-e5ccbfc6.orig/src/ap/wpa_auth_ft.c
|
||||
+++ hostapd-2023-09-08-e5ccbfc6/src/ap/wpa_auth_ft.c
|
||||
@@ -3293,6 +3297,8 @@ static int wpa_ft_process_auth_req(struc
|
||||
size_t identity_len = 0, radius_cui_len = 0;
|
||||
size_t pmk_r1_len, kdk_len, len;
|
||||
int retval = WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||
+ struct os_reltime now;
|
||||
+ struct rsn_ftie *ftie;
|
||||
|
||||
*resp_ies = NULL;
|
||||
*resp_ies_len = 0;
|
||||
@@ -3324,6 +3330,9 @@ static int wpa_ft_process_auth_req(struc
|
||||
goto out;
|
||||
}
|
||||
|
||||
+ ftie = (struct rsn_ftie *) parse.ftie;
|
||||
+ os_memcpy(sm->SNonce, ftie->snonce, WPA_NONCE_LEN);
|
||||
+
|
||||
if (parse.r0kh_id == NULL) {
|
||||
wpa_printf(MSG_DEBUG, "FT: Invalid FTIE - no R0KH-ID");
|
||||
retval = WLAN_STATUS_INVALID_FTIE;
|
||||
@@ -3424,10 +3433,18 @@ pmk_r1_derived:
|
||||
os_memcpy(sm->pmk_r1, pmk_r1, pmk_r1_len);
|
||||
sm->pmk_r1_len = pmk_r1_len;
|
||||
|
||||
- if (random_get_bytes(sm->ANonce, WPA_NONCE_LEN)) {
|
||||
- wpa_printf(MSG_DEBUG, "FT: Failed to get random data for "
|
||||
- "ANonce");
|
||||
- goto out;
|
||||
+ if (os_get_reltime(&now) < 0 ||
|
||||
+ os_reltime_expired(&now, &sm->ANonce_time, 1)) {
|
||||
+ if (random_get_bytes(sm->ANonce, WPA_NONCE_LEN)) {
|
||||
+ wpa_printf(MSG_DEBUG, "FT: Failed to get random data for "
|
||||
+ "ANonce");
|
||||
+ return WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||
+ }
|
||||
+ sm->ANonce_time.sec = now.sec;
|
||||
+ sm->ANonce_time.usec = now.usec;
|
||||
+ wpa_printf(MSG_INFO, "FT: ANonce was randomized");
|
||||
+ } else {
|
||||
+ wpa_printf(MSG_INFO, "FT: ANonce has not expired");
|
||||
}
|
||||
|
||||
/* Now that we know the correct PMK-R1 length and as such, the length
|
||||
@@ -1,719 +0,0 @@
|
||||
#include "utils/includes.h"
|
||||
#include "utils/common.h"
|
||||
#include "utils/eloop.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include "crypto/tls.h"
|
||||
|
||||
#include "ap/ap_config.h"
|
||||
#include "eap_server/eap.h"
|
||||
#include "radius/radius.h"
|
||||
#include "radius/radius_server.h"
|
||||
#include "eap_register.h"
|
||||
|
||||
#include <libubox/blobmsg_json.h>
|
||||
#include <libubox/blobmsg.h>
|
||||
#include <libubox/avl.h>
|
||||
#include <libubox/avl-cmp.h>
|
||||
#include <libubox/kvlist.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <fnmatch.h>
|
||||
|
||||
#define VENDOR_ID_WISPR 14122
|
||||
#define VENDOR_ATTR_SIZE 6
|
||||
|
||||
struct radius_parse_attr_data {
|
||||
unsigned int vendor;
|
||||
u8 type;
|
||||
int size;
|
||||
char format;
|
||||
const char *data;
|
||||
};
|
||||
|
||||
struct radius_parse_attr_state {
|
||||
struct hostapd_radius_attr *prev;
|
||||
struct hostapd_radius_attr *attr;
|
||||
struct wpabuf *buf;
|
||||
void *attrdata;
|
||||
};
|
||||
|
||||
struct radius_user_state {
|
||||
struct avl_node node;
|
||||
struct eap_user data;
|
||||
};
|
||||
|
||||
struct radius_user_data {
|
||||
struct kvlist users;
|
||||
struct avl_tree user_state;
|
||||
struct blob_attr *wildcard;
|
||||
};
|
||||
|
||||
struct radius_state {
|
||||
struct radius_server_data *radius;
|
||||
struct eap_config eap;
|
||||
|
||||
struct radius_user_data phase1, phase2;
|
||||
const char *user_file;
|
||||
time_t user_file_ts;
|
||||
|
||||
int n_attrs;
|
||||
struct hostapd_radius_attr *attrs;
|
||||
};
|
||||
|
||||
struct radius_config {
|
||||
struct tls_connection_params tls;
|
||||
struct radius_server_conf radius;
|
||||
};
|
||||
|
||||
enum {
|
||||
USER_ATTR_PASSWORD,
|
||||
USER_ATTR_HASH,
|
||||
USER_ATTR_SALT,
|
||||
USER_ATTR_METHODS,
|
||||
USER_ATTR_RADIUS,
|
||||
USER_ATTR_VLAN,
|
||||
USER_ATTR_MAX_RATE_UP,
|
||||
USER_ATTR_MAX_RATE_DOWN,
|
||||
__USER_ATTR_MAX
|
||||
};
|
||||
|
||||
static void radius_tls_event(void *ctx, enum tls_event ev,
|
||||
union tls_event_data *data)
|
||||
{
|
||||
switch (ev) {
|
||||
case TLS_CERT_CHAIN_SUCCESS:
|
||||
wpa_printf(MSG_DEBUG, "radius: remote certificate verification success");
|
||||
break;
|
||||
case TLS_CERT_CHAIN_FAILURE:
|
||||
wpa_printf(MSG_INFO, "radius: certificate chain failure: reason=%d depth=%d subject='%s' err='%s'",
|
||||
data->cert_fail.reason,
|
||||
data->cert_fail.depth,
|
||||
data->cert_fail.subject,
|
||||
data->cert_fail.reason_txt);
|
||||
break;
|
||||
case TLS_PEER_CERTIFICATE:
|
||||
wpa_printf(MSG_DEBUG, "radius: peer certificate: depth=%d serial_num=%s subject=%s",
|
||||
data->peer_cert.depth,
|
||||
data->peer_cert.serial_num ? data->peer_cert.serial_num : "N/A",
|
||||
data->peer_cert.subject);
|
||||
break;
|
||||
case TLS_ALERT:
|
||||
if (data->alert.is_local)
|
||||
wpa_printf(MSG_DEBUG, "radius: local TLS alert: %s",
|
||||
data->alert.description);
|
||||
else
|
||||
wpa_printf(MSG_DEBUG, "radius: remote TLS alert: %s",
|
||||
data->alert.description);
|
||||
break;
|
||||
case TLS_UNSAFE_RENEGOTIATION_DISABLED:
|
||||
/* Not applicable to TLS server */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void radius_userdata_init(struct radius_user_data *u)
|
||||
{
|
||||
kvlist_init(&u->users, kvlist_blob_len);
|
||||
avl_init(&u->user_state, avl_strcmp, false, NULL);
|
||||
}
|
||||
|
||||
static void radius_userdata_free(struct radius_user_data *u)
|
||||
{
|
||||
struct radius_user_state *s, *tmp;
|
||||
|
||||
kvlist_free(&u->users);
|
||||
free(u->wildcard);
|
||||
u->wildcard = NULL;
|
||||
avl_remove_all_elements(&u->user_state, s, node, tmp)
|
||||
free(s);
|
||||
}
|
||||
|
||||
static void
|
||||
radius_userdata_load(struct radius_user_data *u, struct blob_attr *data)
|
||||
{
|
||||
enum {
|
||||
USERSTATE_USERS,
|
||||
USERSTATE_WILDCARD,
|
||||
__USERSTATE_MAX,
|
||||
};
|
||||
static const struct blobmsg_policy policy[__USERSTATE_MAX] = {
|
||||
[USERSTATE_USERS] = { "users", BLOBMSG_TYPE_TABLE },
|
||||
[USERSTATE_WILDCARD] = { "wildcard", BLOBMSG_TYPE_ARRAY },
|
||||
};
|
||||
struct blob_attr *tb[__USERSTATE_MAX], *cur;
|
||||
int rem;
|
||||
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
blobmsg_parse(policy, __USERSTATE_MAX, tb, blobmsg_data(data), blobmsg_len(data));
|
||||
|
||||
blobmsg_for_each_attr(cur, tb[USERSTATE_USERS], rem)
|
||||
kvlist_set(&u->users, blobmsg_name(cur), cur);
|
||||
|
||||
if (tb[USERSTATE_WILDCARD])
|
||||
u->wildcard = blob_memdup(tb[USERSTATE_WILDCARD]);
|
||||
}
|
||||
|
||||
static void
|
||||
load_userfile(struct radius_state *s)
|
||||
{
|
||||
enum {
|
||||
USERDATA_PHASE1,
|
||||
USERDATA_PHASE2,
|
||||
__USERDATA_MAX
|
||||
};
|
||||
static const struct blobmsg_policy policy[__USERDATA_MAX] = {
|
||||
[USERDATA_PHASE1] = { "phase1", BLOBMSG_TYPE_TABLE },
|
||||
[USERDATA_PHASE2] = { "phase2", BLOBMSG_TYPE_TABLE },
|
||||
};
|
||||
struct blob_attr *tb[__USERDATA_MAX], *cur;
|
||||
static struct blob_buf b;
|
||||
struct stat st;
|
||||
int rem;
|
||||
|
||||
if (stat(s->user_file, &st))
|
||||
return;
|
||||
|
||||
if (s->user_file_ts == st.st_mtime)
|
||||
return;
|
||||
|
||||
s->user_file_ts = st.st_mtime;
|
||||
radius_userdata_free(&s->phase1);
|
||||
radius_userdata_free(&s->phase2);
|
||||
|
||||
blob_buf_init(&b, 0);
|
||||
blobmsg_add_json_from_file(&b, s->user_file);
|
||||
blobmsg_parse(policy, __USERDATA_MAX, tb, blob_data(b.head), blob_len(b.head));
|
||||
radius_userdata_load(&s->phase1, tb[USERDATA_PHASE1]);
|
||||
radius_userdata_load(&s->phase2, tb[USERDATA_PHASE2]);
|
||||
|
||||
blob_buf_free(&b);
|
||||
}
|
||||
|
||||
static struct blob_attr *
|
||||
radius_user_get(struct radius_user_data *s, const char *name)
|
||||
{
|
||||
struct blob_attr *cur;
|
||||
int rem;
|
||||
|
||||
cur = kvlist_get(&s->users, name);
|
||||
if (cur)
|
||||
return cur;
|
||||
|
||||
blobmsg_for_each_attr(cur, s->wildcard, rem) {
|
||||
static const struct blobmsg_policy policy = {
|
||||
"name", BLOBMSG_TYPE_STRING
|
||||
};
|
||||
struct blob_attr *pattern;
|
||||
|
||||
if (blobmsg_type(cur) != BLOBMSG_TYPE_TABLE)
|
||||
continue;
|
||||
|
||||
blobmsg_parse(&policy, 1, &pattern, blobmsg_data(cur), blobmsg_len(cur));
|
||||
if (!name)
|
||||
continue;
|
||||
|
||||
if (!fnmatch(blobmsg_get_string(pattern), name, 0))
|
||||
return cur;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct radius_parse_attr_data *
|
||||
radius_parse_attr(struct blob_attr *attr)
|
||||
{
|
||||
static const struct blobmsg_policy policy[4] = {
|
||||
{ .type = BLOBMSG_TYPE_INT32 },
|
||||
{ .type = BLOBMSG_TYPE_INT32 },
|
||||
{ .type = BLOBMSG_TYPE_STRING },
|
||||
{ .type = BLOBMSG_TYPE_STRING },
|
||||
};
|
||||
static struct radius_parse_attr_data data;
|
||||
struct blob_attr *tb[4];
|
||||
const char *format;
|
||||
|
||||
blobmsg_parse_array(policy, ARRAY_SIZE(policy), tb, blobmsg_data(attr), blobmsg_len(attr));
|
||||
|
||||
if (!tb[0] || !tb[1] || !tb[2] || !tb[3])
|
||||
return NULL;
|
||||
|
||||
format = blobmsg_get_string(tb[2]);
|
||||
if (strlen(format) != 1)
|
||||
return NULL;
|
||||
|
||||
data.vendor = blobmsg_get_u32(tb[0]);
|
||||
data.type = blobmsg_get_u32(tb[1]);
|
||||
data.format = format[0];
|
||||
data.data = blobmsg_get_string(tb[3]);
|
||||
data.size = strlen(data.data);
|
||||
|
||||
switch (data.format) {
|
||||
case 's':
|
||||
break;
|
||||
case 'x':
|
||||
if (data.size & 1)
|
||||
return NULL;
|
||||
data.size /= 2;
|
||||
break;
|
||||
case 'd':
|
||||
data.size = 4;
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &data;
|
||||
}
|
||||
|
||||
static void
|
||||
radius_count_attrs(struct blob_attr **tb, int *n_attr, size_t *attr_size)
|
||||
{
|
||||
struct blob_attr *data = tb[USER_ATTR_RADIUS];
|
||||
struct blob_attr *cur;
|
||||
int rem;
|
||||
|
||||
blobmsg_for_each_attr(cur, data, rem) {
|
||||
struct radius_parse_attr_data *data;
|
||||
size_t prev = *attr_size;
|
||||
|
||||
data = radius_parse_attr(cur);
|
||||
if (!data)
|
||||
continue;
|
||||
|
||||
*attr_size += data->size;
|
||||
if (data->vendor)
|
||||
*attr_size += VENDOR_ATTR_SIZE;
|
||||
|
||||
(*n_attr)++;
|
||||
}
|
||||
|
||||
*n_attr += !!tb[USER_ATTR_VLAN] * 3 +
|
||||
!!tb[USER_ATTR_MAX_RATE_UP] +
|
||||
!!tb[USER_ATTR_MAX_RATE_DOWN];
|
||||
*attr_size += !!tb[USER_ATTR_VLAN] * (4 + 4 + 5) +
|
||||
!!tb[USER_ATTR_MAX_RATE_UP] * (4 + VENDOR_ATTR_SIZE) +
|
||||
!!tb[USER_ATTR_MAX_RATE_DOWN] * (4 + VENDOR_ATTR_SIZE);
|
||||
}
|
||||
|
||||
static void *
|
||||
radius_add_attr(struct radius_parse_attr_state *state,
|
||||
u32 vendor, u8 type, u8 len)
|
||||
{
|
||||
struct hostapd_radius_attr *attr;
|
||||
struct wpabuf *buf;
|
||||
void *val;
|
||||
|
||||
val = state->attrdata;
|
||||
|
||||
buf = state->buf++;
|
||||
buf->buf = val;
|
||||
|
||||
attr = state->attr++;
|
||||
attr->val = buf;
|
||||
attr->type = type;
|
||||
|
||||
if (state->prev)
|
||||
state->prev->next = attr;
|
||||
state->prev = attr;
|
||||
|
||||
if (vendor) {
|
||||
u8 *vendor_hdr = val + 4;
|
||||
|
||||
WPA_PUT_BE32(val, vendor);
|
||||
vendor_hdr[0] = type;
|
||||
vendor_hdr[1] = len + 2;
|
||||
|
||||
len += VENDOR_ATTR_SIZE;
|
||||
val += VENDOR_ATTR_SIZE;
|
||||
attr->type = RADIUS_ATTR_VENDOR_SPECIFIC;
|
||||
}
|
||||
|
||||
buf->size = buf->used = len;
|
||||
state->attrdata += len;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void
|
||||
radius_parse_attrs(struct blob_attr **tb, struct radius_parse_attr_state *state)
|
||||
{
|
||||
struct blob_attr *data = tb[USER_ATTR_RADIUS];
|
||||
struct hostapd_radius_attr *prev = NULL;
|
||||
struct blob_attr *cur;
|
||||
int len, rem;
|
||||
void *val;
|
||||
|
||||
if ((cur = tb[USER_ATTR_VLAN]) != NULL && blobmsg_get_u32(cur) < 4096) {
|
||||
char buf[5];
|
||||
|
||||
val = radius_add_attr(state, 0, RADIUS_ATTR_TUNNEL_TYPE, 4);
|
||||
WPA_PUT_BE32(val, RADIUS_TUNNEL_TYPE_VLAN);
|
||||
|
||||
val = radius_add_attr(state, 0, RADIUS_ATTR_TUNNEL_MEDIUM_TYPE, 4);
|
||||
WPA_PUT_BE32(val, RADIUS_TUNNEL_MEDIUM_TYPE_802);
|
||||
|
||||
len = snprintf(buf, sizeof(buf), "%d", blobmsg_get_u32(cur));
|
||||
val = radius_add_attr(state, 0, RADIUS_ATTR_TUNNEL_PRIVATE_GROUP_ID, len);
|
||||
memcpy(val, buf, len);
|
||||
}
|
||||
|
||||
if ((cur = tb[USER_ATTR_MAX_RATE_UP]) != NULL) {
|
||||
val = radius_add_attr(state, VENDOR_ID_WISPR, 7, 4);
|
||||
WPA_PUT_BE32(val, blobmsg_get_u32(cur));
|
||||
}
|
||||
|
||||
if ((cur = tb[USER_ATTR_MAX_RATE_DOWN]) != NULL) {
|
||||
val = radius_add_attr(state, VENDOR_ID_WISPR, 8, 4);
|
||||
WPA_PUT_BE32(val, blobmsg_get_u32(cur));
|
||||
}
|
||||
|
||||
blobmsg_for_each_attr(cur, data, rem) {
|
||||
struct radius_parse_attr_data *data;
|
||||
void *val;
|
||||
int size;
|
||||
|
||||
data = radius_parse_attr(cur);
|
||||
if (!data)
|
||||
continue;
|
||||
|
||||
val = radius_add_attr(state, data->vendor, data->type, data->size);
|
||||
switch (data->format) {
|
||||
case 's':
|
||||
memcpy(val, data->data, data->size);
|
||||
break;
|
||||
case 'x':
|
||||
hexstr2bin(data->data, val, data->size);
|
||||
break;
|
||||
case 'd':
|
||||
WPA_PUT_BE32(val, atoi(data->data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
radius_user_parse_methods(struct eap_user *eap, struct blob_attr *data)
|
||||
{
|
||||
struct blob_attr *cur;
|
||||
int rem, n = 0;
|
||||
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
blobmsg_for_each_attr(cur, data, rem) {
|
||||
const char *method;
|
||||
|
||||
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
|
||||
continue;
|
||||
|
||||
if (n == EAP_MAX_METHODS)
|
||||
break;
|
||||
|
||||
method = blobmsg_get_string(cur);
|
||||
eap->methods[n].method = eap_server_get_type(method, &eap->methods[n].vendor);
|
||||
if (eap->methods[n].vendor == EAP_VENDOR_IETF &&
|
||||
eap->methods[n].method == EAP_TYPE_NONE) {
|
||||
if (!strcmp(method, "TTLS-PAP")) {
|
||||
eap->ttls_auth |= EAP_TTLS_AUTH_PAP;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(method, "TTLS-CHAP")) {
|
||||
eap->ttls_auth |= EAP_TTLS_AUTH_CHAP;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(method, "TTLS-MSCHAP")) {
|
||||
eap->ttls_auth |= EAP_TTLS_AUTH_MSCHAP;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(method, "TTLS-MSCHAPV2")) {
|
||||
eap->ttls_auth |= EAP_TTLS_AUTH_MSCHAPV2;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(method, "MACACL")) {
|
||||
eap->macacl = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
static struct eap_user *
|
||||
radius_user_get_state(struct radius_user_data *u, struct blob_attr *data,
|
||||
const char *id)
|
||||
{
|
||||
static const struct blobmsg_policy policy[__USER_ATTR_MAX] = {
|
||||
[USER_ATTR_PASSWORD] = { "password", BLOBMSG_TYPE_STRING },
|
||||
[USER_ATTR_HASH] = { "hash", BLOBMSG_TYPE_STRING },
|
||||
[USER_ATTR_SALT] = { "salt", BLOBMSG_TYPE_STRING },
|
||||
[USER_ATTR_METHODS] = { "methods", BLOBMSG_TYPE_ARRAY },
|
||||
[USER_ATTR_RADIUS] = { "radius", BLOBMSG_TYPE_ARRAY },
|
||||
[USER_ATTR_VLAN] = { "vlan-id", BLOBMSG_TYPE_INT32 },
|
||||
[USER_ATTR_MAX_RATE_UP] = { "max-rate-up", BLOBMSG_TYPE_INT32 },
|
||||
[USER_ATTR_MAX_RATE_DOWN] = { "max-rate-down", BLOBMSG_TYPE_INT32 },
|
||||
};
|
||||
struct blob_attr *tb[__USER_ATTR_MAX], *cur;
|
||||
char *password_buf, *salt_buf, *name_buf;
|
||||
struct radius_parse_attr_state astate = {};
|
||||
struct hostapd_radius_attr *attr;
|
||||
struct radius_user_state *state;
|
||||
int pw_len = 0, salt_len = 0;
|
||||
struct eap_user *eap;
|
||||
struct wpabuf *val;
|
||||
size_t attrsize = 0;
|
||||
void *attrdata;
|
||||
int n_attr = 0;
|
||||
|
||||
state = avl_find_element(&u->user_state, id, state, node);
|
||||
if (state)
|
||||
return &state->data;
|
||||
|
||||
blobmsg_parse(policy, __USER_ATTR_MAX, tb, blobmsg_data(data), blobmsg_len(data));
|
||||
|
||||
if ((cur = tb[USER_ATTR_SALT]) != NULL)
|
||||
salt_len = strlen(blobmsg_get_string(cur)) / 2;
|
||||
if ((cur = tb[USER_ATTR_HASH]) != NULL)
|
||||
pw_len = strlen(blobmsg_get_string(cur)) / 2;
|
||||
else if ((cur = tb[USER_ATTR_PASSWORD]) != NULL)
|
||||
pw_len = blobmsg_len(cur) - 1;
|
||||
radius_count_attrs(tb, &n_attr, &attrsize);
|
||||
|
||||
state = calloc_a(sizeof(*state), &name_buf, strlen(id) + 1,
|
||||
&password_buf, pw_len,
|
||||
&salt_buf, salt_len,
|
||||
&astate.attr, n_attr * sizeof(*astate.attr),
|
||||
&astate.buf, n_attr * sizeof(*astate.buf),
|
||||
&astate.attrdata, attrsize);
|
||||
eap = &state->data;
|
||||
eap->salt = salt_len ? salt_buf : NULL;
|
||||
eap->salt_len = salt_len;
|
||||
eap->password = pw_len ? password_buf : NULL;
|
||||
eap->password_len = pw_len;
|
||||
eap->force_version = -1;
|
||||
|
||||
if ((cur = tb[USER_ATTR_SALT]) != NULL)
|
||||
hexstr2bin(blobmsg_get_string(cur), salt_buf, salt_len);
|
||||
if ((cur = tb[USER_ATTR_PASSWORD]) != NULL)
|
||||
memcpy(password_buf, blobmsg_get_string(cur), pw_len);
|
||||
else if ((cur = tb[USER_ATTR_HASH]) != NULL) {
|
||||
hexstr2bin(blobmsg_get_string(cur), password_buf, pw_len);
|
||||
eap->password_hash = 1;
|
||||
}
|
||||
radius_user_parse_methods(eap, tb[USER_ATTR_METHODS]);
|
||||
|
||||
if (n_attr > 0) {
|
||||
cur = tb[USER_ATTR_RADIUS];
|
||||
eap->accept_attr = astate.attr;
|
||||
radius_parse_attrs(tb, &astate);
|
||||
}
|
||||
|
||||
state->node.key = strcpy(name_buf, id);
|
||||
avl_insert(&u->user_state, &state->node);
|
||||
|
||||
return &state->data;
|
||||
|
||||
free:
|
||||
free(state);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int radius_get_eap_user(void *ctx, const u8 *identity,
|
||||
size_t identity_len, int phase2,
|
||||
struct eap_user *user)
|
||||
{
|
||||
struct radius_state *s = ctx;
|
||||
struct radius_user_data *u = phase2 ? &s->phase2 : &s->phase1;
|
||||
struct blob_attr *entry;
|
||||
struct eap_user *data;
|
||||
char *id;
|
||||
|
||||
if (identity_len > 512)
|
||||
return -1;
|
||||
|
||||
load_userfile(s);
|
||||
|
||||
id = alloca(identity_len + 1);
|
||||
memcpy(id, identity, identity_len);
|
||||
id[identity_len] = 0;
|
||||
|
||||
entry = radius_user_get(u, id);
|
||||
if (!entry)
|
||||
return -1;
|
||||
|
||||
if (!user)
|
||||
return 0;
|
||||
|
||||
data = radius_user_get_state(u, entry, id);
|
||||
if (!data)
|
||||
return -1;
|
||||
|
||||
*user = *data;
|
||||
if (user->password_len > 0)
|
||||
user->password = os_memdup(user->password, user->password_len);
|
||||
if (user->salt_len > 0)
|
||||
user->salt = os_memdup(user->salt, user->salt_len);
|
||||
user->phase2 = phase2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int radius_setup(struct radius_state *s, struct radius_config *c)
|
||||
{
|
||||
struct eap_config *eap = &s->eap;
|
||||
struct tls_config conf = {
|
||||
.event_cb = radius_tls_event,
|
||||
.tls_flags = TLS_CONN_DISABLE_TLSv1_3,
|
||||
.cb_ctx = s,
|
||||
};
|
||||
|
||||
eap->eap_server = 1;
|
||||
eap->max_auth_rounds = 100;
|
||||
eap->max_auth_rounds_short = 50;
|
||||
eap->ssl_ctx = tls_init(&conf);
|
||||
if (!eap->ssl_ctx) {
|
||||
wpa_printf(MSG_INFO, "TLS init failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (tls_global_set_params(eap->ssl_ctx, &c->tls)) {
|
||||
wpa_printf(MSG_INFO, "failed to set TLS parameters\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
c->radius.eap_cfg = eap;
|
||||
c->radius.conf_ctx = s;
|
||||
c->radius.get_eap_user = radius_get_eap_user;
|
||||
s->radius = radius_server_init(&c->radius);
|
||||
if (!s->radius) {
|
||||
wpa_printf(MSG_INFO, "failed to initialize radius server\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int radius_init(struct radius_state *s)
|
||||
{
|
||||
memset(s, 0, sizeof(*s));
|
||||
radius_userdata_init(&s->phase1);
|
||||
radius_userdata_init(&s->phase2);
|
||||
}
|
||||
|
||||
static void radius_deinit(struct radius_state *s)
|
||||
{
|
||||
if (s->radius)
|
||||
radius_server_deinit(s->radius);
|
||||
|
||||
if (s->eap.ssl_ctx)
|
||||
tls_deinit(s->eap.ssl_ctx);
|
||||
|
||||
radius_userdata_free(&s->phase1);
|
||||
radius_userdata_free(&s->phase2);
|
||||
}
|
||||
|
||||
static int usage(const char *progname)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s <options>\n",
|
||||
progname);
|
||||
}
|
||||
|
||||
int radius_main(int argc, char **argv)
|
||||
{
|
||||
static struct radius_state state = {};
|
||||
static struct radius_config config = {};
|
||||
const char *progname = argv[0];
|
||||
int ret = 0;
|
||||
int ch;
|
||||
|
||||
wpa_debug_setup_stdout();
|
||||
wpa_debug_level = 0;
|
||||
|
||||
if (eloop_init()) {
|
||||
wpa_printf(MSG_ERROR, "Failed to initialize event loop");
|
||||
return 1;
|
||||
}
|
||||
|
||||
eap_server_register_methods();
|
||||
radius_init(&state);
|
||||
|
||||
while ((ch = getopt(argc, argv, "6C:c:d:i:k:K:p:P:s:u:")) != -1) {
|
||||
switch (ch) {
|
||||
case '6':
|
||||
config.radius.ipv6 = 1;
|
||||
break;
|
||||
case 'C':
|
||||
config.tls.ca_cert = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
if (config.tls.client_cert2)
|
||||
return usage(progname);
|
||||
|
||||
if (config.tls.client_cert)
|
||||
config.tls.client_cert2 = optarg;
|
||||
else
|
||||
config.tls.client_cert = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
config.tls.dh_file = optarg;
|
||||
break;
|
||||
case 'i':
|
||||
state.eap.server_id = optarg;
|
||||
state.eap.server_id_len = strlen(optarg);
|
||||
break;
|
||||
case 'k':
|
||||
if (config.tls.private_key2)
|
||||
return usage(progname);
|
||||
|
||||
if (config.tls.private_key)
|
||||
config.tls.private_key2 = optarg;
|
||||
else
|
||||
config.tls.private_key = optarg;
|
||||
break;
|
||||
case 'K':
|
||||
if (config.tls.private_key_passwd2)
|
||||
return usage(progname);
|
||||
|
||||
if (config.tls.private_key_passwd)
|
||||
config.tls.private_key_passwd2 = optarg;
|
||||
else
|
||||
config.tls.private_key_passwd = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
config.radius.auth_port = atoi(optarg);
|
||||
break;
|
||||
case 'P':
|
||||
config.radius.acct_port = atoi(optarg);
|
||||
break;
|
||||
case 's':
|
||||
config.radius.client_file = optarg;
|
||||
break;
|
||||
case 'u':
|
||||
state.user_file = optarg;
|
||||
break;
|
||||
default:
|
||||
return usage(progname);
|
||||
}
|
||||
}
|
||||
|
||||
if (!config.tls.client_cert || !config.tls.private_key ||
|
||||
!config.radius.client_file || !state.eap.server_id ||
|
||||
!state.user_file) {
|
||||
wpa_printf(MSG_INFO, "missing options\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = radius_setup(&state, &config);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
load_userfile(&state);
|
||||
eloop_run();
|
||||
|
||||
out:
|
||||
radius_deinit(&state);
|
||||
os_program_deinit();
|
||||
|
||||
return ret;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
* hostapd / ubus support
|
||||
* Copyright (c) 2013, Felix Fietkau <nbd@nbd.name>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
#ifndef __HOSTAPD_UBUS_H
|
||||
#define __HOSTAPD_UBUS_H
|
||||
|
||||
enum hostapd_ubus_event_type {
|
||||
HOSTAPD_UBUS_PROBE_REQ,
|
||||
HOSTAPD_UBUS_AUTH_REQ,
|
||||
HOSTAPD_UBUS_ASSOC_REQ,
|
||||
HOSTAPD_UBUS_COA,
|
||||
HOSTAPD_UBUS_TYPE_MAX
|
||||
};
|
||||
|
||||
struct hostapd_ubus_request {
|
||||
enum hostapd_ubus_event_type type;
|
||||
const struct ieee80211_mgmt *mgmt_frame;
|
||||
const struct ieee802_11_elems *elems;
|
||||
int ssi_signal; /* dBm */
|
||||
const u8 *addr;
|
||||
};
|
||||
|
||||
struct hostapd_iface;
|
||||
struct hostapd_data;
|
||||
struct hapd_interfaces;
|
||||
struct rrm_measurement_beacon_report;
|
||||
|
||||
#ifdef UBUS_SUPPORT
|
||||
|
||||
#include <libubox/avl.h>
|
||||
#include <libubus.h>
|
||||
|
||||
struct hostapd_ubus_bss {
|
||||
struct ubus_object obj;
|
||||
struct avl_tree banned;
|
||||
int notify_response;
|
||||
};
|
||||
|
||||
void hostapd_ubus_add_iface(struct hostapd_iface *iface);
|
||||
void hostapd_ubus_free_iface(struct hostapd_iface *iface);
|
||||
void hostapd_ubus_add_bss(struct hostapd_data *hapd);
|
||||
void hostapd_ubus_free_bss(struct hostapd_data *hapd);
|
||||
void hostapd_ubus_add_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan);
|
||||
void hostapd_ubus_remove_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan);
|
||||
|
||||
int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req);
|
||||
void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *mac);
|
||||
void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
|
||||
const u8 *addr, u8 token, u8 rep_mode,
|
||||
struct rrm_measurement_beacon_report *rep,
|
||||
size_t len);
|
||||
void hostapd_ubus_notify_radar_detected(struct hostapd_iface *iface, int frequency,
|
||||
int chan_width, int cf1, int cf2);
|
||||
void hostapd_ubus_notify_rssi(struct hostapd_data *hapd, const char *type, const u8 *addr, int rssi);
|
||||
|
||||
void hostapd_ubus_notify_bss_transition_response(
|
||||
struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 status_code,
|
||||
u8 bss_termination_delay, const u8 *target_bssid,
|
||||
const u8 *candidate_list, u16 candidate_list_len);
|
||||
void hostapd_ubus_add(struct hapd_interfaces *interfaces);
|
||||
void hostapd_ubus_free(struct hapd_interfaces *interfaces);
|
||||
int hostapd_ubus_notify_bss_transition_query(
|
||||
struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 reason,
|
||||
const u8 *candidate_list, u16 candidate_list_len);
|
||||
void hostapd_ubus_notify_csa(struct hostapd_data *hapd, int freq);
|
||||
|
||||
#else
|
||||
|
||||
struct hostapd_ubus_bss {};
|
||||
|
||||
static inline void hostapd_ubus_add_iface(struct hostapd_iface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void hostapd_ubus_free_iface(struct hostapd_iface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void hostapd_ubus_add_bss(struct hostapd_data *hapd)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void hostapd_ubus_free_bss(struct hostapd_data *hapd)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void hostapd_ubus_add_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void hostapd_ubus_remove_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *mac)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
|
||||
const u8 *addr, u8 token,
|
||||
u8 rep_mode,
|
||||
struct rrm_measurement_beacon_report *rep,
|
||||
size_t len)
|
||||
{
|
||||
}
|
||||
static inline void hostapd_ubus_notify_radar_detected(struct hostapd_iface *iface, int frequency,
|
||||
int chan_width, int cf1, int cf2)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void hostapd_ubus_notify_bss_transition_response(
|
||||
struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 status_code,
|
||||
u8 bss_termination_delay, const u8 *target_bssid,
|
||||
const u8 *candidate_list, u16 candidate_list_len)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void hostapd_ubus_add(struct hapd_interfaces *interfaces)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void hostapd_ubus_free(struct hapd_interfaces *interfaces)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int hostapd_ubus_notify_bss_transition_query(
|
||||
struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 reason,
|
||||
const u8 *candidate_list, u16 candidate_list_len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,952 +0,0 @@
|
||||
#include <sys/un.h>
|
||||
|
||||
#include "utils/includes.h"
|
||||
#include "utils/common.h"
|
||||
#include "utils/ucode.h"
|
||||
#include "hostapd.h"
|
||||
#include "beacon.h"
|
||||
#include "hw_features.h"
|
||||
#include "ap_drv_ops.h"
|
||||
#include "dfs.h"
|
||||
#include "acs.h"
|
||||
#include "ieee802_11_auth.h"
|
||||
#include <libubox/uloop.h>
|
||||
|
||||
static uc_resource_type_t *global_type, *bss_type, *iface_type;
|
||||
static struct hapd_interfaces *interfaces;
|
||||
static uc_value_t *global, *bss_registry, *iface_registry;
|
||||
static uc_vm_t *vm;
|
||||
|
||||
static uc_value_t *
|
||||
hostapd_ucode_bss_get_uval(struct hostapd_data *hapd)
|
||||
{
|
||||
uc_value_t *val;
|
||||
|
||||
if (hapd->ucode.idx)
|
||||
return wpa_ucode_registry_get(bss_registry, hapd->ucode.idx);
|
||||
|
||||
val = uc_resource_new(bss_type, hapd);
|
||||
hapd->ucode.idx = wpa_ucode_registry_add(bss_registry, val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
hostapd_ucode_iface_get_uval(struct hostapd_iface *hapd)
|
||||
{
|
||||
uc_value_t *val;
|
||||
|
||||
if (hapd->ucode.idx)
|
||||
return wpa_ucode_registry_get(iface_registry, hapd->ucode.idx);
|
||||
|
||||
val = uc_resource_new(iface_type, hapd);
|
||||
hapd->ucode.idx = wpa_ucode_registry_add(iface_registry, val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void
|
||||
hostapd_ucode_update_bss_list(struct hostapd_iface *iface, uc_value_t *if_bss, uc_value_t *bss)
|
||||
{
|
||||
uc_value_t *list;
|
||||
int i;
|
||||
|
||||
list = ucv_array_new(vm);
|
||||
for (i = 0; iface->bss && i < iface->num_bss; i++) {
|
||||
struct hostapd_data *hapd = iface->bss[i];
|
||||
uc_value_t *val = hostapd_ucode_bss_get_uval(hapd);
|
||||
|
||||
ucv_array_set(list, i, ucv_get(ucv_string_new(hapd->conf->iface)));
|
||||
ucv_object_add(bss, hapd->conf->iface, ucv_get(val));
|
||||
}
|
||||
ucv_object_add(if_bss, iface->phy, ucv_get(list));
|
||||
}
|
||||
|
||||
static void
|
||||
hostapd_ucode_update_interfaces(void)
|
||||
{
|
||||
uc_value_t *ifs = ucv_object_new(vm);
|
||||
uc_value_t *if_bss = ucv_array_new(vm);
|
||||
uc_value_t *bss = ucv_object_new(vm);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < interfaces->count; i++) {
|
||||
struct hostapd_iface *iface = interfaces->iface[i];
|
||||
|
||||
ucv_object_add(ifs, iface->phy, ucv_get(hostapd_ucode_iface_get_uval(iface)));
|
||||
hostapd_ucode_update_bss_list(iface, if_bss, bss);
|
||||
}
|
||||
|
||||
ucv_object_add(ucv_prototype_get(global), "interfaces", ucv_get(ifs));
|
||||
ucv_object_add(ucv_prototype_get(global), "interface_bss", ucv_get(if_bss));
|
||||
ucv_object_add(ucv_prototype_get(global), "bss", ucv_get(bss));
|
||||
ucv_gc(vm);
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
uc_hostapd_add_iface(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
uc_value_t *iface = uc_fn_arg(0);
|
||||
int ret;
|
||||
|
||||
if (ucv_type(iface) != UC_STRING)
|
||||
return ucv_int64_new(-1);
|
||||
|
||||
ret = hostapd_add_iface(interfaces, ucv_string_get(iface));
|
||||
hostapd_ucode_update_interfaces();
|
||||
|
||||
return ucv_int64_new(ret);
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
uc_hostapd_remove_iface(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
uc_value_t *iface = uc_fn_arg(0);
|
||||
|
||||
if (ucv_type(iface) != UC_STRING)
|
||||
return NULL;
|
||||
|
||||
hostapd_remove_iface(interfaces, ucv_string_get(iface));
|
||||
hostapd_ucode_update_interfaces();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct hostapd_vlan *
|
||||
bss_conf_find_vlan(struct hostapd_bss_config *bss, int id)
|
||||
{
|
||||
struct hostapd_vlan *vlan;
|
||||
|
||||
for (vlan = bss->vlan; vlan; vlan = vlan->next)
|
||||
if (vlan->vlan_id == id)
|
||||
return vlan;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
bss_conf_rename_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan,
|
||||
const char *ifname)
|
||||
{
|
||||
if (!strcmp(ifname, vlan->ifname))
|
||||
return 0;
|
||||
|
||||
hostapd_drv_if_rename(hapd, WPA_IF_AP_VLAN, vlan->ifname, ifname);
|
||||
os_strlcpy(vlan->ifname, ifname, sizeof(vlan->ifname));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
bss_reload_vlans(struct hostapd_data *hapd, struct hostapd_bss_config *bss)
|
||||
{
|
||||
struct hostapd_bss_config *old_bss = hapd->conf;
|
||||
struct hostapd_vlan *vlan, *vlan_new, *wildcard;
|
||||
char ifname[IFNAMSIZ + 1], vlan_ifname[IFNAMSIZ + 1], *pos;
|
||||
int ret;
|
||||
|
||||
vlan = bss_conf_find_vlan(old_bss, VLAN_ID_WILDCARD);
|
||||
wildcard = bss_conf_find_vlan(bss, VLAN_ID_WILDCARD);
|
||||
if (!!vlan != !!wildcard)
|
||||
return -1;
|
||||
|
||||
if (vlan && wildcard && strcmp(vlan->ifname, wildcard->ifname) != 0)
|
||||
strcpy(vlan->ifname, wildcard->ifname);
|
||||
else
|
||||
wildcard = NULL;
|
||||
|
||||
for (vlan = bss->vlan; vlan; vlan = vlan->next) {
|
||||
if (vlan->vlan_id == VLAN_ID_WILDCARD ||
|
||||
vlan->dynamic_vlan > 0)
|
||||
continue;
|
||||
|
||||
if (!bss_conf_find_vlan(old_bss, vlan->vlan_id))
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (vlan = old_bss->vlan; vlan; vlan = vlan->next) {
|
||||
if (vlan->vlan_id == VLAN_ID_WILDCARD)
|
||||
continue;
|
||||
|
||||
if (vlan->dynamic_vlan == 0) {
|
||||
vlan_new = bss_conf_find_vlan(bss, vlan->vlan_id);
|
||||
if (!vlan_new)
|
||||
return -1;
|
||||
|
||||
if (bss_conf_rename_vlan(hapd, vlan, vlan_new->ifname))
|
||||
return -1;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!wildcard)
|
||||
continue;
|
||||
|
||||
os_strlcpy(ifname, wildcard->ifname, sizeof(ifname));
|
||||
pos = os_strchr(ifname, '#');
|
||||
if (!pos)
|
||||
return -1;
|
||||
|
||||
*pos++ = '\0';
|
||||
ret = os_snprintf(vlan_ifname, sizeof(vlan_ifname), "%s%d%s",
|
||||
ifname, vlan->vlan_id, pos);
|
||||
if (os_snprintf_error(sizeof(vlan_ifname), ret))
|
||||
return -1;
|
||||
|
||||
if (bss_conf_rename_vlan(hapd, vlan, vlan_ifname))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
uc_hostapd_bss_set_config(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
struct hostapd_data *hapd = uc_fn_thisval("hostapd.bss");
|
||||
struct hostapd_bss_config *old_bss;
|
||||
struct hostapd_iface *iface;
|
||||
struct hostapd_config *conf;
|
||||
uc_value_t *file = uc_fn_arg(0);
|
||||
uc_value_t *index = uc_fn_arg(1);
|
||||
uc_value_t *files_only = uc_fn_arg(2);
|
||||
unsigned int i, idx = 0;
|
||||
int ret = -1;
|
||||
|
||||
if (!hapd || ucv_type(file) != UC_STRING)
|
||||
goto out;
|
||||
|
||||
if (ucv_type(index) == UC_INTEGER)
|
||||
idx = ucv_int64_get(index);
|
||||
|
||||
iface = hapd->iface;
|
||||
conf = interfaces->config_read_cb(ucv_string_get(file));
|
||||
if (!conf)
|
||||
goto out;
|
||||
|
||||
if (idx > conf->num_bss || !conf->bss[idx])
|
||||
goto free;
|
||||
|
||||
if (ucv_boolean_get(files_only)) {
|
||||
struct hostapd_bss_config *bss = conf->bss[idx];
|
||||
struct hostapd_bss_config *old_bss = hapd->conf;
|
||||
|
||||
#define swap_field(name) \
|
||||
do { \
|
||||
void *ptr = old_bss->name; \
|
||||
old_bss->name = bss->name; \
|
||||
bss->name = ptr; \
|
||||
} while (0)
|
||||
|
||||
swap_field(ssid.wpa_psk_file);
|
||||
ret = bss_reload_vlans(hapd, bss);
|
||||
goto done;
|
||||
}
|
||||
|
||||
hostapd_bss_deinit_no_free(hapd);
|
||||
hostapd_drv_stop_ap(hapd);
|
||||
hostapd_free_hapd_data(hapd);
|
||||
|
||||
old_bss = hapd->conf;
|
||||
for (i = 0; i < iface->conf->num_bss; i++)
|
||||
if (iface->conf->bss[i] == hapd->conf)
|
||||
iface->conf->bss[i] = conf->bss[idx];
|
||||
hapd->conf = conf->bss[idx];
|
||||
conf->bss[idx] = old_bss;
|
||||
|
||||
hostapd_setup_bss(hapd, hapd == iface->bss[0], true);
|
||||
hostapd_ucode_update_interfaces();
|
||||
hostapd_owe_update_trans(iface);
|
||||
|
||||
done:
|
||||
ret = 0;
|
||||
free:
|
||||
hostapd_config_free(conf);
|
||||
out:
|
||||
return ucv_int64_new(ret);
|
||||
}
|
||||
|
||||
static void
|
||||
hostapd_remove_iface_bss_conf(struct hostapd_config *iconf,
|
||||
struct hostapd_bss_config *conf)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < iconf->num_bss; i++)
|
||||
if (iconf->bss[i] == conf)
|
||||
break;
|
||||
|
||||
if (i == iconf->num_bss)
|
||||
return;
|
||||
|
||||
for (i++; i < iconf->num_bss; i++)
|
||||
iconf->bss[i - 1] = iconf->bss[i];
|
||||
iconf->num_bss--;
|
||||
}
|
||||
|
||||
|
||||
static uc_value_t *
|
||||
uc_hostapd_bss_delete(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
struct hostapd_data *hapd = uc_fn_thisval("hostapd.bss");
|
||||
struct hostapd_iface *iface;
|
||||
int i, idx;
|
||||
|
||||
if (!hapd)
|
||||
return NULL;
|
||||
|
||||
iface = hapd->iface;
|
||||
if (iface->num_bss == 1) {
|
||||
wpa_printf(MSG_ERROR, "trying to delete last bss of an iface: %s\n", hapd->conf->iface);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (idx = 0; idx < iface->num_bss; idx++)
|
||||
if (iface->bss[idx] == hapd)
|
||||
break;
|
||||
|
||||
if (idx == iface->num_bss)
|
||||
return NULL;
|
||||
|
||||
for (i = idx + 1; i < iface->num_bss; i++)
|
||||
iface->bss[i - 1] = iface->bss[i];
|
||||
|
||||
iface->num_bss--;
|
||||
|
||||
iface->bss[0]->interface_added = 0;
|
||||
hostapd_drv_set_first_bss(iface->bss[0]);
|
||||
hapd->interface_added = 1;
|
||||
|
||||
hostapd_drv_stop_ap(hapd);
|
||||
hostapd_bss_deinit(hapd);
|
||||
hostapd_remove_iface_bss_conf(iface->conf, hapd->conf);
|
||||
hostapd_config_free_bss(hapd->conf);
|
||||
os_free(hapd);
|
||||
|
||||
hostapd_ucode_update_interfaces();
|
||||
ucv_gc(vm);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
uc_hostapd_iface_add_bss(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
struct hostapd_iface *iface = uc_fn_thisval("hostapd.iface");
|
||||
struct hostapd_bss_config *bss;
|
||||
struct hostapd_config *conf;
|
||||
struct hostapd_data *hapd;
|
||||
uc_value_t *file = uc_fn_arg(0);
|
||||
uc_value_t *index = uc_fn_arg(1);
|
||||
unsigned int idx = 0;
|
||||
uc_value_t *ret = NULL;
|
||||
|
||||
if (!iface || ucv_type(file) != UC_STRING)
|
||||
goto out;
|
||||
|
||||
if (ucv_type(index) == UC_INTEGER)
|
||||
idx = ucv_int64_get(index);
|
||||
|
||||
conf = interfaces->config_read_cb(ucv_string_get(file));
|
||||
if (!conf || idx > conf->num_bss || !conf->bss[idx])
|
||||
goto out;
|
||||
|
||||
bss = conf->bss[idx];
|
||||
hapd = hostapd_alloc_bss_data(iface, iface->conf, bss);
|
||||
if (!hapd)
|
||||
goto out;
|
||||
|
||||
hapd->driver = iface->bss[0]->driver;
|
||||
hapd->drv_priv = iface->bss[0]->drv_priv;
|
||||
if (interfaces->ctrl_iface_init &&
|
||||
interfaces->ctrl_iface_init(hapd) < 0)
|
||||
goto free_hapd;
|
||||
|
||||
if (iface->state == HAPD_IFACE_ENABLED &&
|
||||
hostapd_setup_bss(hapd, -1, true))
|
||||
goto deinit_ctrl;
|
||||
|
||||
iface->bss = os_realloc_array(iface->bss, iface->num_bss + 1,
|
||||
sizeof(*iface->bss));
|
||||
iface->bss[iface->num_bss++] = hapd;
|
||||
|
||||
iface->conf->bss = os_realloc_array(iface->conf->bss,
|
||||
iface->conf->num_bss + 1,
|
||||
sizeof(*iface->conf->bss));
|
||||
iface->conf->bss[iface->conf->num_bss] = bss;
|
||||
conf->bss[idx] = NULL;
|
||||
ret = hostapd_ucode_bss_get_uval(hapd);
|
||||
hostapd_ucode_update_interfaces();
|
||||
hostapd_owe_update_trans(iface);
|
||||
goto out;
|
||||
|
||||
deinit_ctrl:
|
||||
if (interfaces->ctrl_iface_deinit)
|
||||
interfaces->ctrl_iface_deinit(hapd);
|
||||
free_hapd:
|
||||
hostapd_free_hapd_data(hapd);
|
||||
os_free(hapd);
|
||||
out:
|
||||
hostapd_config_free(conf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
uc_hostapd_iface_set_bss_order(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
struct hostapd_iface *iface = uc_fn_thisval("hostapd.iface");
|
||||
uc_value_t *bss_list = uc_fn_arg(0);
|
||||
struct hostapd_data **new_bss;
|
||||
struct hostapd_bss_config **new_conf;
|
||||
|
||||
if (!iface)
|
||||
return NULL;
|
||||
|
||||
if (ucv_type(bss_list) != UC_ARRAY ||
|
||||
ucv_array_length(bss_list) != iface->num_bss)
|
||||
return NULL;
|
||||
|
||||
new_bss = calloc(iface->num_bss, sizeof(*new_bss));
|
||||
new_conf = calloc(iface->num_bss, sizeof(*new_conf));
|
||||
for (size_t i = 0; i < iface->num_bss; i++) {
|
||||
struct hostapd_data *bss;
|
||||
|
||||
bss = ucv_resource_data(ucv_array_get(bss_list, i), "hostapd.bss");
|
||||
if (bss->iface != iface)
|
||||
goto free;
|
||||
|
||||
for (size_t k = 0; k < i; k++)
|
||||
if (new_bss[k] == bss)
|
||||
goto free;
|
||||
|
||||
new_bss[i] = bss;
|
||||
new_conf[i] = bss->conf;
|
||||
}
|
||||
|
||||
new_bss[0]->interface_added = 0;
|
||||
for (size_t i = 1; i < iface->num_bss; i++)
|
||||
new_bss[i]->interface_added = 1;
|
||||
|
||||
free(iface->bss);
|
||||
iface->bss = new_bss;
|
||||
|
||||
free(iface->conf->bss);
|
||||
iface->conf->bss = new_conf;
|
||||
iface->conf->num_bss = iface->num_bss;
|
||||
hostapd_drv_set_first_bss(iface->bss[0]);
|
||||
|
||||
return ucv_boolean_new(true);
|
||||
|
||||
free:
|
||||
free(new_bss);
|
||||
free(new_conf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
uc_hostapd_bss_ctrl(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
struct hostapd_data *hapd = uc_fn_thisval("hostapd.bss");
|
||||
uc_value_t *arg = uc_fn_arg(0);
|
||||
struct sockaddr_storage from = {};
|
||||
static char reply[4096];
|
||||
int reply_len;
|
||||
|
||||
if (!hapd || !interfaces->ctrl_iface_recv ||
|
||||
ucv_type(arg) != UC_STRING)
|
||||
return NULL;
|
||||
|
||||
reply_len = interfaces->ctrl_iface_recv(hapd, ucv_string_get(arg),
|
||||
reply, sizeof(reply),
|
||||
&from, sizeof(from));
|
||||
if (reply_len < 0)
|
||||
return NULL;
|
||||
|
||||
if (reply_len && reply[reply_len - 1] == '\n')
|
||||
reply_len--;
|
||||
|
||||
return ucv_string_new_length(reply, reply_len);
|
||||
}
|
||||
|
||||
static void
|
||||
uc_hostapd_disable_iface(struct hostapd_iface *iface)
|
||||
{
|
||||
switch (iface->state) {
|
||||
case HAPD_IFACE_DISABLED:
|
||||
break;
|
||||
#ifdef CONFIG_ACS
|
||||
case HAPD_IFACE_ACS:
|
||||
acs_cleanup(iface);
|
||||
iface->scan_cb = NULL;
|
||||
/* fallthrough */
|
||||
#endif
|
||||
default:
|
||||
hostapd_disable_iface(iface);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
uc_hostapd_iface_stop(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
struct hostapd_iface *iface = uc_fn_thisval("hostapd.iface");
|
||||
int i;
|
||||
|
||||
if (!iface)
|
||||
return NULL;
|
||||
|
||||
if (iface->state != HAPD_IFACE_ENABLED)
|
||||
uc_hostapd_disable_iface(iface);
|
||||
|
||||
for (i = 0; i < iface->num_bss; i++) {
|
||||
struct hostapd_data *hapd = iface->bss[i];
|
||||
|
||||
hostapd_drv_stop_ap(hapd);
|
||||
hapd->beacon_set_done = 0;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
uc_hostapd_iface_start(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
struct hostapd_iface *iface = uc_fn_thisval("hostapd.iface");
|
||||
uc_value_t *info = uc_fn_arg(0);
|
||||
struct hostapd_config *conf;
|
||||
bool changed = false;
|
||||
uint64_t intval;
|
||||
int i;
|
||||
|
||||
if (!iface)
|
||||
return NULL;
|
||||
|
||||
if (!info) {
|
||||
iface->freq = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (ucv_type(info) != UC_OBJECT)
|
||||
return NULL;
|
||||
|
||||
#define UPDATE_VAL(field, name) \
|
||||
if ((intval = ucv_int64_get(ucv_object_get(info, name, NULL))) && \
|
||||
!errno && intval != conf->field) do { \
|
||||
conf->field = intval; \
|
||||
changed = true; \
|
||||
} while(0)
|
||||
|
||||
conf = iface->conf;
|
||||
UPDATE_VAL(op_class, "op_class");
|
||||
UPDATE_VAL(hw_mode, "hw_mode");
|
||||
UPDATE_VAL(channel, "channel");
|
||||
UPDATE_VAL(secondary_channel, "sec_channel");
|
||||
if (!changed &&
|
||||
(iface->bss[0]->beacon_set_done ||
|
||||
iface->state == HAPD_IFACE_DFS))
|
||||
return ucv_boolean_new(true);
|
||||
|
||||
intval = ucv_int64_get(ucv_object_get(info, "center_seg0_idx", NULL));
|
||||
if (!errno)
|
||||
hostapd_set_oper_centr_freq_seg0_idx(conf, intval);
|
||||
|
||||
intval = ucv_int64_get(ucv_object_get(info, "center_seg1_idx", NULL));
|
||||
if (!errno)
|
||||
hostapd_set_oper_centr_freq_seg1_idx(conf, intval);
|
||||
|
||||
intval = ucv_int64_get(ucv_object_get(info, "oper_chwidth", NULL));
|
||||
if (!errno)
|
||||
hostapd_set_oper_chwidth(conf, intval);
|
||||
|
||||
intval = ucv_int64_get(ucv_object_get(info, "frequency", NULL));
|
||||
if (!errno)
|
||||
iface->freq = intval;
|
||||
else
|
||||
iface->freq = 0;
|
||||
conf->acs = 0;
|
||||
|
||||
out:
|
||||
switch (iface->state) {
|
||||
case HAPD_IFACE_ENABLED:
|
||||
if (!hostapd_is_dfs_required(iface) ||
|
||||
hostapd_is_dfs_chan_available(iface))
|
||||
break;
|
||||
wpa_printf(MSG_INFO, "DFS CAC required on new channel, restart interface");
|
||||
/* fallthrough */
|
||||
default:
|
||||
uc_hostapd_disable_iface(iface);
|
||||
break;
|
||||
}
|
||||
|
||||
if (conf->channel && !iface->freq)
|
||||
iface->freq = hostapd_hw_get_freq(iface->bss[0], conf->channel);
|
||||
|
||||
if (iface->state != HAPD_IFACE_ENABLED) {
|
||||
hostapd_enable_iface(iface);
|
||||
return ucv_boolean_new(true);
|
||||
}
|
||||
|
||||
for (i = 0; i < iface->num_bss; i++) {
|
||||
struct hostapd_data *hapd = iface->bss[i];
|
||||
int ret;
|
||||
|
||||
hapd->conf->start_disabled = 0;
|
||||
hostapd_set_freq(hapd, conf->hw_mode, iface->freq,
|
||||
conf->channel,
|
||||
conf->enable_edmg,
|
||||
conf->edmg_channel,
|
||||
conf->ieee80211n,
|
||||
conf->ieee80211ac,
|
||||
conf->ieee80211ax,
|
||||
conf->ieee80211be,
|
||||
conf->secondary_channel,
|
||||
hostapd_get_oper_chwidth(conf),
|
||||
hostapd_get_oper_centr_freq_seg0_idx(conf),
|
||||
hostapd_get_oper_centr_freq_seg1_idx(conf));
|
||||
|
||||
ieee802_11_set_beacon(hapd);
|
||||
}
|
||||
hostapd_owe_update_trans(iface);
|
||||
|
||||
return ucv_boolean_new(true);
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
uc_hostapd_iface_switch_channel(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
struct hostapd_iface *iface = uc_fn_thisval("hostapd.iface");
|
||||
uc_value_t *info = uc_fn_arg(0);
|
||||
struct hostapd_config *conf;
|
||||
struct csa_settings csa = {};
|
||||
uint64_t intval;
|
||||
int i, ret = 0;
|
||||
|
||||
if (!iface || ucv_type(info) != UC_OBJECT)
|
||||
return NULL;
|
||||
|
||||
conf = iface->conf;
|
||||
if ((intval = ucv_int64_get(ucv_object_get(info, "csa_count", NULL))) && !errno)
|
||||
csa.cs_count = intval;
|
||||
if ((intval = ucv_int64_get(ucv_object_get(info, "sec_channel", NULL))) && !errno)
|
||||
csa.freq_params.sec_channel_offset = intval;
|
||||
|
||||
csa.freq_params.ht_enabled = conf->ieee80211n;
|
||||
csa.freq_params.vht_enabled = conf->ieee80211ac;
|
||||
csa.freq_params.he_enabled = conf->ieee80211ax;
|
||||
#ifdef CONFIG_IEEE80211BE
|
||||
csa.freq_params.eht_enabled = conf->ieee80211be;
|
||||
#endif
|
||||
intval = ucv_int64_get(ucv_object_get(info, "oper_chwidth", NULL));
|
||||
if (errno)
|
||||
intval = hostapd_get_oper_chwidth(conf);
|
||||
if (intval)
|
||||
csa.freq_params.bandwidth = 40 << intval;
|
||||
else
|
||||
csa.freq_params.bandwidth = csa.freq_params.sec_channel_offset ? 40 : 20;
|
||||
|
||||
if ((intval = ucv_int64_get(ucv_object_get(info, "frequency", NULL))) && !errno)
|
||||
csa.freq_params.freq = intval;
|
||||
if ((intval = ucv_int64_get(ucv_object_get(info, "center_freq1", NULL))) && !errno)
|
||||
csa.freq_params.center_freq1 = intval;
|
||||
if ((intval = ucv_int64_get(ucv_object_get(info, "center_freq2", NULL))) && !errno)
|
||||
csa.freq_params.center_freq2 = intval;
|
||||
|
||||
for (i = 0; i < iface->num_bss; i++)
|
||||
ret = hostapd_switch_channel(iface->bss[i], &csa);
|
||||
|
||||
return ucv_boolean_new(!ret);
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
uc_hostapd_bss_rename(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
struct hostapd_data *hapd = uc_fn_thisval("hostapd.bss");
|
||||
uc_value_t *ifname_arg = uc_fn_arg(0);
|
||||
char prev_ifname[IFNAMSIZ + 1];
|
||||
struct sta_info *sta;
|
||||
const char *ifname;
|
||||
int ret;
|
||||
|
||||
if (!hapd || ucv_type(ifname_arg) != UC_STRING)
|
||||
return NULL;
|
||||
|
||||
os_strlcpy(prev_ifname, hapd->conf->iface, sizeof(prev_ifname));
|
||||
ifname = ucv_string_get(ifname_arg);
|
||||
|
||||
hostapd_ubus_free_bss(hapd);
|
||||
if (interfaces->ctrl_iface_deinit)
|
||||
interfaces->ctrl_iface_deinit(hapd);
|
||||
|
||||
ret = hostapd_drv_if_rename(hapd, WPA_IF_AP_BSS, NULL, ifname);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
for (sta = hapd->sta_list; sta; sta = sta->next) {
|
||||
char cur_name[IFNAMSIZ + 1], new_name[IFNAMSIZ + 1];
|
||||
|
||||
if (!(sta->flags & WLAN_STA_WDS) || sta->pending_wds_enable)
|
||||
continue;
|
||||
|
||||
snprintf(cur_name, sizeof(cur_name), "%s.sta%d", prev_ifname, sta->aid);
|
||||
snprintf(new_name, sizeof(new_name), "%s.sta%d", ifname, sta->aid);
|
||||
hostapd_drv_if_rename(hapd, WPA_IF_AP_VLAN, cur_name, new_name);
|
||||
}
|
||||
|
||||
if (!strncmp(hapd->conf->ssid.vlan, hapd->conf->iface, sizeof(hapd->conf->ssid.vlan)))
|
||||
os_strlcpy(hapd->conf->ssid.vlan, ifname, sizeof(hapd->conf->ssid.vlan));
|
||||
os_strlcpy(hapd->conf->iface, ifname, sizeof(hapd->conf->iface));
|
||||
hostapd_ubus_add_bss(hapd);
|
||||
|
||||
hostapd_ucode_update_interfaces();
|
||||
hostapd_owe_update_trans(hapd->iface);
|
||||
out:
|
||||
if (interfaces->ctrl_iface_init)
|
||||
interfaces->ctrl_iface_init(hapd);
|
||||
|
||||
return ret ? NULL : ucv_boolean_new(true);
|
||||
}
|
||||
|
||||
int hostapd_ucode_sta_auth(struct hostapd_data *hapd, struct sta_info *sta)
|
||||
{
|
||||
char addr[sizeof(MACSTR)];
|
||||
uc_value_t *val, *cur;
|
||||
int ret = 0;
|
||||
|
||||
if (wpa_ucode_call_prepare("sta_auth"))
|
||||
return 0;
|
||||
|
||||
uc_value_push(ucv_get(ucv_string_new(hapd->conf->iface)));
|
||||
|
||||
snprintf(addr, sizeof(addr), MACSTR, MAC2STR(sta->addr));
|
||||
val = ucv_string_new(addr);
|
||||
uc_value_push(ucv_get(val));
|
||||
|
||||
val = wpa_ucode_call(2);
|
||||
|
||||
cur = ucv_object_get(val, "psk", NULL);
|
||||
if (ucv_type(cur) == UC_ARRAY) {
|
||||
struct hostapd_sta_wpa_psk_short *p, **next;
|
||||
size_t len = ucv_array_length(cur);
|
||||
|
||||
next = &sta->psk;
|
||||
hostapd_free_psk_list(*next);
|
||||
*next = NULL;
|
||||
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
uc_value_t *cur_psk;
|
||||
const char *str;
|
||||
size_t str_len;
|
||||
|
||||
cur_psk = ucv_array_get(cur, i);
|
||||
str = ucv_string_get(cur_psk);
|
||||
str_len = strlen(str);
|
||||
if (!str || str_len < 8 || str_len > 64)
|
||||
continue;
|
||||
|
||||
p = os_zalloc(sizeof(*p));
|
||||
if (len == 64) {
|
||||
if (hexstr2bin(str, p->psk, PMK_LEN) < 0) {
|
||||
free(p);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
p->is_passphrase = 1;
|
||||
memcpy(p->passphrase, str, str_len + 1);
|
||||
}
|
||||
|
||||
*next = p;
|
||||
next = &p->next;
|
||||
}
|
||||
}
|
||||
|
||||
cur = ucv_object_get(val, "force_psk", NULL);
|
||||
sta->use_sta_psk = ucv_is_truish(cur);
|
||||
|
||||
cur = ucv_object_get(val, "status", NULL);
|
||||
if (ucv_type(cur) == UC_INTEGER)
|
||||
ret = ucv_int64_get(cur);
|
||||
|
||||
ucv_put(val);
|
||||
ucv_gc(vm);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void hostapd_ucode_sta_connected(struct hostapd_data *hapd, struct sta_info *sta)
|
||||
{
|
||||
struct hostapd_sta_wpa_psk_short *psk = sta->psk;
|
||||
char addr[sizeof(MACSTR)];
|
||||
uc_value_t *val, *cur;
|
||||
int ret = 0;
|
||||
|
||||
if (wpa_ucode_call_prepare("sta_connected"))
|
||||
return;
|
||||
|
||||
uc_value_push(ucv_get(ucv_string_new(hapd->conf->iface)));
|
||||
|
||||
snprintf(addr, sizeof(addr), MACSTR, MAC2STR(sta->addr));
|
||||
val = ucv_string_new(addr);
|
||||
uc_value_push(ucv_get(val));
|
||||
|
||||
val = ucv_object_new(vm);
|
||||
if (sta->psk_idx)
|
||||
ucv_object_add(val, "psk_idx", ucv_int64_new(sta->psk_idx - 1));
|
||||
if (sta->psk)
|
||||
ucv_object_add(val, "psk", ucv_string_new(sta->psk->passphrase));
|
||||
uc_value_push(ucv_get(val));
|
||||
|
||||
val = wpa_ucode_call(3);
|
||||
if (ucv_type(val) != UC_OBJECT)
|
||||
goto out;
|
||||
|
||||
cur = ucv_object_get(val, "vlan", NULL);
|
||||
if (ucv_type(cur) == UC_INTEGER) {
|
||||
struct vlan_description vdesc = {
|
||||
.notempty = 1,
|
||||
.untagged = ucv_int64_get(cur),
|
||||
};
|
||||
|
||||
ap_sta_set_vlan(hapd, sta, &vdesc);
|
||||
ap_sta_bind_vlan(hapd, sta);
|
||||
}
|
||||
|
||||
out:
|
||||
ucv_put(val);
|
||||
}
|
||||
|
||||
int hostapd_ucode_init(struct hapd_interfaces *ifaces)
|
||||
{
|
||||
static const uc_function_list_t global_fns[] = {
|
||||
{ "printf", uc_wpa_printf },
|
||||
{ "getpid", uc_wpa_getpid },
|
||||
{ "sha1", uc_wpa_sha1 },
|
||||
{ "freq_info", uc_wpa_freq_info },
|
||||
{ "add_iface", uc_hostapd_add_iface },
|
||||
{ "remove_iface", uc_hostapd_remove_iface },
|
||||
};
|
||||
static const uc_function_list_t bss_fns[] = {
|
||||
{ "ctrl", uc_hostapd_bss_ctrl },
|
||||
{ "set_config", uc_hostapd_bss_set_config },
|
||||
{ "rename", uc_hostapd_bss_rename },
|
||||
{ "delete", uc_hostapd_bss_delete },
|
||||
};
|
||||
static const uc_function_list_t iface_fns[] = {
|
||||
{ "set_bss_order", uc_hostapd_iface_set_bss_order },
|
||||
{ "add_bss", uc_hostapd_iface_add_bss },
|
||||
{ "stop", uc_hostapd_iface_stop },
|
||||
{ "start", uc_hostapd_iface_start },
|
||||
{ "switch_channel", uc_hostapd_iface_switch_channel },
|
||||
};
|
||||
uc_value_t *data, *proto;
|
||||
|
||||
interfaces = ifaces;
|
||||
vm = wpa_ucode_create_vm();
|
||||
|
||||
global_type = uc_type_declare(vm, "hostapd.global", global_fns, NULL);
|
||||
bss_type = uc_type_declare(vm, "hostapd.bss", bss_fns, NULL);
|
||||
iface_type = uc_type_declare(vm, "hostapd.iface", iface_fns, NULL);
|
||||
|
||||
bss_registry = ucv_array_new(vm);
|
||||
uc_vm_registry_set(vm, "hostap.bss_registry", bss_registry);
|
||||
|
||||
iface_registry = ucv_array_new(vm);
|
||||
uc_vm_registry_set(vm, "hostap.iface_registry", iface_registry);
|
||||
|
||||
global = wpa_ucode_global_init("hostapd", global_type);
|
||||
|
||||
if (wpa_ucode_run(HOSTAPD_UC_PATH "hostapd.uc"))
|
||||
goto free_vm;
|
||||
ucv_gc(vm);
|
||||
|
||||
return 0;
|
||||
|
||||
free_vm:
|
||||
wpa_ucode_free_vm();
|
||||
return -1;
|
||||
}
|
||||
|
||||
void hostapd_ucode_free(void)
|
||||
{
|
||||
if (wpa_ucode_call_prepare("shutdown") == 0)
|
||||
ucv_put(wpa_ucode_call(0));
|
||||
wpa_ucode_free_vm();
|
||||
}
|
||||
|
||||
void hostapd_ucode_free_iface(struct hostapd_iface *iface)
|
||||
{
|
||||
wpa_ucode_registry_remove(iface_registry, iface->ucode.idx);
|
||||
}
|
||||
|
||||
int hostapd_ucode_afc_request(struct hostapd_iface *iface, const char *request,
|
||||
char *buf, size_t len)
|
||||
{
|
||||
uc_value_t *val;
|
||||
size_t ret_len;
|
||||
int ret = -1;
|
||||
|
||||
if (wpa_ucode_call_prepare("afc_request"))
|
||||
return -1;
|
||||
|
||||
uc_value_push(ucv_get(ucv_string_new(iface->phy)));
|
||||
uc_value_push(ucv_get(ucv_string_new(request)));
|
||||
val = wpa_ucode_call(2);
|
||||
if (ucv_type(val) != UC_STRING)
|
||||
goto out;
|
||||
|
||||
ret_len = ucv_string_length(val);
|
||||
if (ret_len >= len)
|
||||
goto out;
|
||||
|
||||
memcpy(buf, ucv_string_get(val), ret_len + 1);
|
||||
ret = (int)ret_len;
|
||||
|
||||
out:
|
||||
ucv_put(val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void hostapd_ucode_add_bss(struct hostapd_data *hapd)
|
||||
{
|
||||
uc_value_t *val;
|
||||
|
||||
if (wpa_ucode_call_prepare("bss_add"))
|
||||
return;
|
||||
|
||||
val = hostapd_ucode_bss_get_uval(hapd);
|
||||
uc_value_push(ucv_get(ucv_string_new(hapd->conf->iface)));
|
||||
uc_value_push(ucv_get(val));
|
||||
ucv_put(wpa_ucode_call(2));
|
||||
ucv_gc(vm);
|
||||
}
|
||||
|
||||
void hostapd_ucode_reload_bss(struct hostapd_data *hapd)
|
||||
{
|
||||
uc_value_t *val;
|
||||
|
||||
if (wpa_ucode_call_prepare("bss_reload"))
|
||||
return;
|
||||
|
||||
val = hostapd_ucode_bss_get_uval(hapd);
|
||||
uc_value_push(ucv_get(ucv_string_new(hapd->conf->iface)));
|
||||
uc_value_push(ucv_get(val));
|
||||
ucv_put(wpa_ucode_call(2));
|
||||
ucv_gc(vm);
|
||||
}
|
||||
|
||||
void hostapd_ucode_free_bss(struct hostapd_data *hapd)
|
||||
{
|
||||
uc_value_t *val;
|
||||
|
||||
val = wpa_ucode_registry_remove(bss_registry, hapd->ucode.idx);
|
||||
if (!val)
|
||||
return;
|
||||
|
||||
hapd->ucode.idx = 0;
|
||||
if (wpa_ucode_call_prepare("bss_remove"))
|
||||
return;
|
||||
|
||||
uc_value_push(ucv_string_new(hapd->conf->iface));
|
||||
uc_value_push(ucv_get(val));
|
||||
ucv_put(wpa_ucode_call(2));
|
||||
ucv_gc(vm);
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
#ifndef __HOSTAPD_AP_UCODE_H
|
||||
#define __HOSTAPD_AP_UCODE_H
|
||||
|
||||
#include "utils/ucode.h"
|
||||
|
||||
struct hostapd_data;
|
||||
|
||||
struct hostapd_ucode_bss {
|
||||
#ifdef UCODE_SUPPORT
|
||||
int idx;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct hostapd_ucode_iface {
|
||||
#ifdef UCODE_SUPPORT
|
||||
int idx;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef UCODE_SUPPORT
|
||||
|
||||
int hostapd_ucode_init(struct hapd_interfaces *ifaces);
|
||||
|
||||
void hostapd_ucode_free(void);
|
||||
void hostapd_ucode_free_iface(struct hostapd_iface *iface);
|
||||
int hostapd_ucode_sta_auth(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
void hostapd_ucode_sta_connected(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
void hostapd_ucode_add_bss(struct hostapd_data *hapd);
|
||||
void hostapd_ucode_free_bss(struct hostapd_data *hapd);
|
||||
void hostapd_ucode_reload_bss(struct hostapd_data *hapd);
|
||||
int hostapd_ucode_afc_request(struct hostapd_iface *iface, const char *request,
|
||||
char *buf, size_t len);
|
||||
|
||||
#else
|
||||
|
||||
static inline int hostapd_ucode_init(struct hapd_interfaces *ifaces)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
static inline void hostapd_ucode_free(void)
|
||||
{
|
||||
}
|
||||
static inline void hostapd_ucode_free_iface(struct hostapd_iface *iface)
|
||||
{
|
||||
}
|
||||
static inline void hostapd_ucode_reload_bss(struct hostapd_data *hapd)
|
||||
{
|
||||
}
|
||||
static inline int hostapd_ucode_sta_auth(struct hostapd_data *hapd, struct sta_info *sta)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline void hostapd_ucode_sta_connected(struct hostapd_data *hapd, struct sta_info *sta)
|
||||
{
|
||||
}
|
||||
static inline void hostapd_ucode_add_bss(struct hostapd_data *hapd)
|
||||
{
|
||||
}
|
||||
static inline void hostapd_ucode_free_bss(struct hostapd_data *hapd)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,335 +0,0 @@
|
||||
#include <unistd.h>
|
||||
#include "ucode.h"
|
||||
#include "utils/eloop.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include "crypto/sha1.h"
|
||||
#include "common/ieee802_11_common.h"
|
||||
#include <libubox/uloop.h>
|
||||
#include <ucode/compiler.h>
|
||||
|
||||
static uc_value_t *registry;
|
||||
static uc_vm_t vm;
|
||||
static struct uloop_timeout gc_timer;
|
||||
|
||||
static void uc_gc_timer(struct uloop_timeout *timeout)
|
||||
{
|
||||
ucv_gc(&vm);
|
||||
}
|
||||
|
||||
uc_value_t *uc_wpa_printf(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
uc_value_t *level = uc_fn_arg(0);
|
||||
uc_value_t *ret, **args;
|
||||
uc_cfn_ptr_t _sprintf;
|
||||
int l = MSG_INFO;
|
||||
int i, start = 0;
|
||||
|
||||
_sprintf = uc_stdlib_function("sprintf");
|
||||
if (!sprintf)
|
||||
return NULL;
|
||||
|
||||
if (ucv_type(level) == UC_INTEGER) {
|
||||
l = ucv_int64_get(level);
|
||||
start++;
|
||||
}
|
||||
|
||||
if (nargs <= start)
|
||||
return NULL;
|
||||
|
||||
ret = _sprintf(vm, nargs - start);
|
||||
if (ucv_type(ret) != UC_STRING)
|
||||
return NULL;
|
||||
|
||||
wpa_printf(l, "%s", ucv_string_get(ret));
|
||||
ucv_put(ret);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uc_value_t *uc_wpa_freq_info(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
uc_value_t *freq = uc_fn_arg(0);
|
||||
uc_value_t *sec = uc_fn_arg(1);
|
||||
int width = ucv_uint64_get(uc_fn_arg(2));
|
||||
int freq_val, center_idx, center_ofs;
|
||||
enum hostapd_hw_mode hw_mode;
|
||||
u8 op_class, channel, tmp_channel;
|
||||
const char *modestr;
|
||||
int sec_channel = 0;
|
||||
uc_value_t *ret;
|
||||
int chanwidth;
|
||||
|
||||
if (ucv_type(freq) != UC_INTEGER)
|
||||
return NULL;
|
||||
|
||||
freq_val = ucv_int64_get(freq);
|
||||
if (ucv_type(sec) == UC_INTEGER)
|
||||
sec_channel = ucv_int64_get(sec);
|
||||
else if (sec)
|
||||
return NULL;
|
||||
else if (freq_val > 4000)
|
||||
sec_channel = (freq_val / 20) & 1 ? 1 : -1;
|
||||
else
|
||||
sec_channel = freq_val < 2442 ? 1 : -1;
|
||||
|
||||
if (sec_channel != -1 && sec_channel != 1 && sec_channel != 0)
|
||||
return NULL;
|
||||
|
||||
switch (width) {
|
||||
case 0:
|
||||
chanwidth = CHANWIDTH_USE_HT;
|
||||
break;
|
||||
case 1:
|
||||
chanwidth = CHANWIDTH_80MHZ;
|
||||
break;
|
||||
case 2:
|
||||
chanwidth = CHANWIDTH_160MHZ;
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hw_mode = ieee80211_freq_to_channel_ext(freq_val, sec_channel,
|
||||
chanwidth, &op_class, &channel);
|
||||
switch (hw_mode) {
|
||||
case HOSTAPD_MODE_IEEE80211B:
|
||||
modestr = "b";
|
||||
break;
|
||||
case HOSTAPD_MODE_IEEE80211G:
|
||||
modestr = "g";
|
||||
break;
|
||||
case HOSTAPD_MODE_IEEE80211A:
|
||||
modestr = "a";
|
||||
break;
|
||||
case HOSTAPD_MODE_IEEE80211AD:
|
||||
modestr = "ad";
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = ucv_object_new(vm);
|
||||
ucv_object_add(ret, "op_class", ucv_int64_new(op_class));
|
||||
ucv_object_add(ret, "channel", ucv_int64_new(channel));
|
||||
ucv_object_add(ret, "hw_mode", ucv_int64_new(hw_mode));
|
||||
ucv_object_add(ret, "hw_mode_str", ucv_get(ucv_string_new(modestr)));
|
||||
ucv_object_add(ret, "sec_channel", ucv_int64_new(sec_channel));
|
||||
ucv_object_add(ret, "frequency", ucv_int64_new(freq_val));
|
||||
|
||||
if (!sec_channel)
|
||||
return ret;
|
||||
|
||||
if (freq_val >= 5900)
|
||||
center_ofs = 0;
|
||||
else if (freq_val >= 5745)
|
||||
center_ofs = 20;
|
||||
else
|
||||
center_ofs = 35;
|
||||
tmp_channel = channel - center_ofs;
|
||||
tmp_channel &= ~((8 << width) - 1);
|
||||
center_idx = tmp_channel + center_ofs + (4 << width) - 1;
|
||||
|
||||
if (freq_val < 3000)
|
||||
ucv_object_add(ret, "center_seg0_idx", ucv_int64_new(0));
|
||||
else
|
||||
ucv_object_add(ret, "center_seg0_idx", ucv_int64_new(center_idx));
|
||||
center_idx = (center_idx - channel) * 5 + freq_val;
|
||||
ucv_object_add(ret, "center_freq1", ucv_int64_new(center_idx));
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
uc_value_t *uc_wpa_getpid(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
return ucv_int64_new(getpid());
|
||||
}
|
||||
|
||||
uc_value_t *uc_wpa_sha1(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
u8 hash[SHA1_MAC_LEN];
|
||||
char hash_hex[2 * ARRAY_SIZE(hash) + 1];
|
||||
uc_value_t *val;
|
||||
size_t *lens;
|
||||
const u8 **args;
|
||||
int i;
|
||||
|
||||
if (!nargs)
|
||||
return NULL;
|
||||
|
||||
args = alloca(nargs * sizeof(*args));
|
||||
lens = alloca(nargs * sizeof(*lens));
|
||||
for (i = 0; i < nargs; i++) {
|
||||
val = uc_fn_arg(i);
|
||||
if (ucv_type(val) != UC_STRING)
|
||||
return NULL;
|
||||
|
||||
args[i] = ucv_string_get(val);
|
||||
lens[i] = ucv_string_length(val);
|
||||
}
|
||||
|
||||
if (sha1_vector(nargs, args, lens, hash))
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(hash); i++)
|
||||
sprintf(hash_hex + 2 * i, "%02x", hash[i]);
|
||||
|
||||
return ucv_string_new_length(hash_hex, 2 * ARRAY_SIZE(hash));
|
||||
}
|
||||
|
||||
uc_vm_t *wpa_ucode_create_vm(void)
|
||||
{
|
||||
static uc_parse_config_t config = {
|
||||
.strict_declarations = true,
|
||||
.lstrip_blocks = true,
|
||||
.trim_blocks = true,
|
||||
.raw_mode = true
|
||||
};
|
||||
|
||||
uc_search_path_init(&config.module_search_path);
|
||||
uc_search_path_add(&config.module_search_path, HOSTAPD_UC_PATH "*.so");
|
||||
uc_search_path_add(&config.module_search_path, HOSTAPD_UC_PATH "*.uc");
|
||||
|
||||
uc_vm_init(&vm, &config);
|
||||
|
||||
uc_stdlib_load(uc_vm_scope_get(&vm));
|
||||
eloop_add_uloop();
|
||||
gc_timer.cb = uc_gc_timer;
|
||||
|
||||
return &vm;
|
||||
}
|
||||
|
||||
int wpa_ucode_run(const char *script)
|
||||
{
|
||||
uc_source_t *source;
|
||||
uc_program_t *prog;
|
||||
uc_value_t *ops;
|
||||
char *err;
|
||||
int ret;
|
||||
|
||||
source = uc_source_new_file(script);
|
||||
if (!source)
|
||||
return -1;
|
||||
|
||||
prog = uc_compile(vm.config, source, &err);
|
||||
uc_source_put(source);
|
||||
if (!prog) {
|
||||
wpa_printf(MSG_ERROR, "Error loading ucode: %s\n", err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = uc_vm_execute(&vm, prog, &ops);
|
||||
uc_program_put(prog);
|
||||
if (ret || !ops)
|
||||
return -1;
|
||||
|
||||
registry = ucv_array_new(&vm);
|
||||
uc_vm_registry_set(&vm, "hostap.registry", registry);
|
||||
ucv_array_set(registry, 0, ucv_get(ops));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wpa_ucode_call_prepare(const char *fname)
|
||||
{
|
||||
uc_value_t *obj, *func;
|
||||
|
||||
if (!registry)
|
||||
return -1;
|
||||
|
||||
obj = ucv_array_get(registry, 0);
|
||||
if (!obj)
|
||||
return -1;
|
||||
|
||||
func = ucv_object_get(obj, fname, NULL);
|
||||
if (!ucv_is_callable(func))
|
||||
return -1;
|
||||
|
||||
uc_vm_stack_push(&vm, ucv_get(obj));
|
||||
uc_vm_stack_push(&vm, ucv_get(func));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uc_value_t *wpa_ucode_global_init(const char *name, uc_resource_type_t *global_type)
|
||||
{
|
||||
uc_value_t *global = uc_resource_new(global_type, NULL);
|
||||
uc_value_t *proto;
|
||||
|
||||
uc_vm_registry_set(&vm, "hostap.global", global);
|
||||
proto = ucv_prototype_get(global);
|
||||
ucv_object_add(proto, "data", ucv_get(ucv_object_new(&vm)));
|
||||
|
||||
#define ADD_CONST(x) ucv_object_add(proto, #x, ucv_int64_new(x))
|
||||
ADD_CONST(MSG_EXCESSIVE);
|
||||
ADD_CONST(MSG_MSGDUMP);
|
||||
ADD_CONST(MSG_DEBUG);
|
||||
ADD_CONST(MSG_INFO);
|
||||
ADD_CONST(MSG_WARNING);
|
||||
ADD_CONST(MSG_ERROR);
|
||||
#undef ADD_CONST
|
||||
|
||||
ucv_object_add(uc_vm_scope_get(&vm), name, ucv_get(global));
|
||||
|
||||
return global;
|
||||
}
|
||||
|
||||
int wpa_ucode_registry_add(uc_value_t *reg, uc_value_t *val)
|
||||
{
|
||||
uc_value_t *data;
|
||||
int i = 0;
|
||||
|
||||
while (ucv_array_get(reg, i))
|
||||
i++;
|
||||
|
||||
ucv_array_set(reg, i, ucv_get(val));
|
||||
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
uc_value_t *wpa_ucode_registry_get(uc_value_t *reg, int idx)
|
||||
{
|
||||
if (!idx)
|
||||
return NULL;
|
||||
|
||||
return ucv_array_get(reg, idx - 1);
|
||||
}
|
||||
|
||||
uc_value_t *wpa_ucode_registry_remove(uc_value_t *reg, int idx)
|
||||
{
|
||||
uc_value_t *val = wpa_ucode_registry_get(reg, idx);
|
||||
void **dataptr;
|
||||
|
||||
if (!val)
|
||||
return NULL;
|
||||
|
||||
ucv_array_set(reg, idx - 1, NULL);
|
||||
dataptr = ucv_resource_dataptr(val, NULL);
|
||||
if (dataptr)
|
||||
*dataptr = NULL;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
uc_value_t *wpa_ucode_call(size_t nargs)
|
||||
{
|
||||
if (uc_vm_call(&vm, true, nargs) != EXCEPTION_NONE)
|
||||
return NULL;
|
||||
|
||||
if (!gc_timer.pending)
|
||||
uloop_timeout_set(&gc_timer, 10);
|
||||
|
||||
return uc_vm_stack_pop(&vm);
|
||||
}
|
||||
|
||||
void wpa_ucode_free_vm(void)
|
||||
{
|
||||
if (!vm.config)
|
||||
return;
|
||||
|
||||
uc_search_path_free(&vm.config->module_search_path);
|
||||
uc_vm_free(&vm);
|
||||
registry = NULL;
|
||||
vm = (uc_vm_t){};
|
||||
}
|
||||
@@ -1,281 +0,0 @@
|
||||
#include "utils/includes.h"
|
||||
#include "utils/common.h"
|
||||
#include "utils/ucode.h"
|
||||
#include "drivers/driver.h"
|
||||
#include "ap/hostapd.h"
|
||||
#include "wpa_supplicant_i.h"
|
||||
#include "wps_supplicant.h"
|
||||
#include "bss.h"
|
||||
#include "ucode.h"
|
||||
|
||||
static struct wpa_global *wpa_global;
|
||||
static uc_resource_type_t *global_type, *iface_type;
|
||||
static uc_value_t *global, *iface_registry;
|
||||
static uc_vm_t *vm;
|
||||
|
||||
static uc_value_t *
|
||||
wpas_ucode_iface_get_uval(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
uc_value_t *val;
|
||||
|
||||
if (wpa_s->ucode.idx)
|
||||
return wpa_ucode_registry_get(iface_registry, wpa_s->ucode.idx);
|
||||
|
||||
val = uc_resource_new(iface_type, wpa_s);
|
||||
wpa_s->ucode.idx = wpa_ucode_registry_add(iface_registry, val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void
|
||||
wpas_ucode_update_interfaces(void)
|
||||
{
|
||||
uc_value_t *ifs = ucv_object_new(vm);
|
||||
struct wpa_supplicant *wpa_s;
|
||||
int i;
|
||||
|
||||
for (wpa_s = wpa_global->ifaces; wpa_s; wpa_s = wpa_s->next)
|
||||
ucv_object_add(ifs, wpa_s->ifname, ucv_get(wpas_ucode_iface_get_uval(wpa_s)));
|
||||
|
||||
ucv_object_add(ucv_prototype_get(global), "interfaces", ucv_get(ifs));
|
||||
ucv_gc(vm);
|
||||
}
|
||||
|
||||
void wpas_ucode_add_bss(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
uc_value_t *val;
|
||||
|
||||
if (wpa_ucode_call_prepare("iface_add"))
|
||||
return;
|
||||
|
||||
uc_value_push(ucv_get(ucv_string_new(wpa_s->ifname)));
|
||||
uc_value_push(ucv_get(wpas_ucode_iface_get_uval(wpa_s)));
|
||||
ucv_put(wpa_ucode_call(2));
|
||||
ucv_gc(vm);
|
||||
}
|
||||
|
||||
void wpas_ucode_free_bss(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
uc_value_t *val;
|
||||
|
||||
val = wpa_ucode_registry_remove(iface_registry, wpa_s->ucode.idx);
|
||||
if (!val)
|
||||
return;
|
||||
|
||||
wpa_s->ucode.idx = 0;
|
||||
if (wpa_ucode_call_prepare("iface_remove"))
|
||||
return;
|
||||
|
||||
uc_value_push(ucv_get(ucv_string_new(wpa_s->ifname)));
|
||||
uc_value_push(ucv_get(val));
|
||||
ucv_put(wpa_ucode_call(2));
|
||||
ucv_gc(vm);
|
||||
}
|
||||
|
||||
void wpas_ucode_update_state(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
const char *state;
|
||||
uc_value_t *val;
|
||||
|
||||
val = wpa_ucode_registry_get(iface_registry, wpa_s->ucode.idx);
|
||||
if (!val)
|
||||
return;
|
||||
|
||||
if (wpa_ucode_call_prepare("state"))
|
||||
return;
|
||||
|
||||
state = wpa_supplicant_state_txt(wpa_s->wpa_state);
|
||||
uc_value_push(ucv_get(ucv_string_new(wpa_s->ifname)));
|
||||
uc_value_push(ucv_get(val));
|
||||
uc_value_push(ucv_get(ucv_string_new(state)));
|
||||
ucv_put(wpa_ucode_call(3));
|
||||
ucv_gc(vm);
|
||||
}
|
||||
|
||||
void wpas_ucode_event(struct wpa_supplicant *wpa_s, int event, union wpa_event_data *data)
|
||||
{
|
||||
const char *state;
|
||||
uc_value_t *val;
|
||||
|
||||
if (event != EVENT_CH_SWITCH_STARTED)
|
||||
return;
|
||||
|
||||
val = wpa_ucode_registry_get(iface_registry, wpa_s->ucode.idx);
|
||||
if (!val)
|
||||
return;
|
||||
|
||||
if (wpa_ucode_call_prepare("event"))
|
||||
return;
|
||||
|
||||
uc_value_push(ucv_get(ucv_string_new(wpa_s->ifname)));
|
||||
uc_value_push(ucv_get(val));
|
||||
uc_value_push(ucv_get(ucv_string_new(event_to_string(event))));
|
||||
val = ucv_object_new(vm);
|
||||
uc_value_push(ucv_get(val));
|
||||
|
||||
if (event == EVENT_CH_SWITCH_STARTED) {
|
||||
ucv_object_add(val, "csa_count", ucv_int64_new(data->ch_switch.count));
|
||||
ucv_object_add(val, "frequency", ucv_int64_new(data->ch_switch.freq));
|
||||
ucv_object_add(val, "sec_chan_offset", ucv_int64_new(data->ch_switch.ch_offset));
|
||||
ucv_object_add(val, "center_freq1", ucv_int64_new(data->ch_switch.cf1));
|
||||
ucv_object_add(val, "center_freq2", ucv_int64_new(data->ch_switch.cf2));
|
||||
}
|
||||
|
||||
ucv_put(wpa_ucode_call(4));
|
||||
ucv_gc(vm);
|
||||
}
|
||||
|
||||
static const char *obj_stringval(uc_value_t *obj, const char *name)
|
||||
{
|
||||
uc_value_t *val = ucv_object_get(obj, name, NULL);
|
||||
|
||||
return ucv_string_get(val);
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
uc_wpas_add_iface(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
uc_value_t *info = uc_fn_arg(0);
|
||||
uc_value_t *ifname = ucv_object_get(info, "iface", NULL);
|
||||
uc_value_t *bridge = ucv_object_get(info, "bridge", NULL);
|
||||
uc_value_t *config = ucv_object_get(info, "config", NULL);
|
||||
uc_value_t *ctrl = ucv_object_get(info, "ctrl", NULL);
|
||||
struct wpa_interface iface;
|
||||
int ret = -1;
|
||||
|
||||
if (ucv_type(info) != UC_OBJECT)
|
||||
goto out;
|
||||
|
||||
iface = (struct wpa_interface){
|
||||
.driver = "nl80211",
|
||||
.ifname = ucv_string_get(ifname),
|
||||
.bridge_ifname = ucv_string_get(bridge),
|
||||
.confname = ucv_string_get(config),
|
||||
.ctrl_interface = ucv_string_get(ctrl),
|
||||
};
|
||||
|
||||
if (!iface.ifname || !iface.confname)
|
||||
goto out;
|
||||
|
||||
ret = wpa_supplicant_add_iface(wpa_global, &iface, 0) ? 0 : -1;
|
||||
wpas_ucode_update_interfaces();
|
||||
|
||||
out:
|
||||
return ucv_int64_new(ret);
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
uc_wpas_remove_iface(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
struct wpa_supplicant *wpa_s = NULL;
|
||||
uc_value_t *ifname_arg = uc_fn_arg(0);
|
||||
const char *ifname = ucv_string_get(ifname_arg);
|
||||
int ret = -1;
|
||||
|
||||
if (!ifname)
|
||||
goto out;
|
||||
|
||||
for (wpa_s = wpa_global->ifaces; wpa_s; wpa_s = wpa_s->next)
|
||||
if (!strcmp(wpa_s->ifname, ifname))
|
||||
break;
|
||||
|
||||
if (!wpa_s)
|
||||
goto out;
|
||||
|
||||
ret = wpa_supplicant_remove_iface(wpa_global, wpa_s, 0);
|
||||
wpas_ucode_update_interfaces();
|
||||
|
||||
out:
|
||||
return ucv_int64_new(ret);
|
||||
}
|
||||
|
||||
static uc_value_t *
|
||||
uc_wpas_iface_status(uc_vm_t *vm, size_t nargs)
|
||||
{
|
||||
struct wpa_supplicant *wpa_s = uc_fn_thisval("wpas.iface");
|
||||
struct wpa_bss *bss;
|
||||
uc_value_t *ret, *val;
|
||||
|
||||
if (!wpa_s)
|
||||
return NULL;
|
||||
|
||||
ret = ucv_object_new(vm);
|
||||
|
||||
val = ucv_string_new(wpa_supplicant_state_txt(wpa_s->wpa_state));
|
||||
ucv_object_add(ret, "state", ucv_get(val));
|
||||
|
||||
bss = wpa_s->current_bss;
|
||||
if (bss) {
|
||||
int sec_chan = 0;
|
||||
const u8 *ie;
|
||||
|
||||
ie = wpa_bss_get_ie(bss, WLAN_EID_HT_OPERATION);
|
||||
if (ie && ie[1] >= 2) {
|
||||
const struct ieee80211_ht_operation *ht_oper;
|
||||
int sec;
|
||||
|
||||
ht_oper = (const void *) (ie + 2);
|
||||
sec = ht_oper->ht_param & HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK;
|
||||
if (sec == HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE)
|
||||
sec_chan = 1;
|
||||
else if (sec == HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW)
|
||||
sec_chan = -1;
|
||||
}
|
||||
|
||||
ucv_object_add(ret, "sec_chan_offset", ucv_int64_new(sec_chan));
|
||||
ucv_object_add(ret, "frequency", ucv_int64_new(bss->freq));
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MESH
|
||||
if (wpa_s->ifmsh) {
|
||||
struct hostapd_iface *ifmsh = wpa_s->ifmsh;
|
||||
|
||||
ucv_object_add(ret, "sec_chan_offset", ucv_int64_new(ifmsh->conf->secondary_channel));
|
||||
ucv_object_add(ret, "frequency", ucv_int64_new(ifmsh->freq));
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wpas_ucode_init(struct wpa_global *gl)
|
||||
{
|
||||
static const uc_function_list_t global_fns[] = {
|
||||
{ "printf", uc_wpa_printf },
|
||||
{ "getpid", uc_wpa_getpid },
|
||||
{ "add_iface", uc_wpas_add_iface },
|
||||
{ "remove_iface", uc_wpas_remove_iface },
|
||||
};
|
||||
static const uc_function_list_t iface_fns[] = {
|
||||
{ "status", uc_wpas_iface_status },
|
||||
};
|
||||
uc_value_t *data, *proto;
|
||||
|
||||
wpa_global = gl;
|
||||
vm = wpa_ucode_create_vm();
|
||||
|
||||
global_type = uc_type_declare(vm, "wpas.global", global_fns, NULL);
|
||||
iface_type = uc_type_declare(vm, "wpas.iface", iface_fns, NULL);
|
||||
|
||||
iface_registry = ucv_array_new(vm);
|
||||
uc_vm_registry_set(vm, "wpas.iface_registry", iface_registry);
|
||||
|
||||
global = wpa_ucode_global_init("wpas", global_type);
|
||||
|
||||
if (wpa_ucode_run(HOSTAPD_UC_PATH "wpa_supplicant.uc"))
|
||||
goto free_vm;
|
||||
|
||||
ucv_gc(vm);
|
||||
return 0;
|
||||
|
||||
free_vm:
|
||||
wpa_ucode_free_vm();
|
||||
return -1;
|
||||
}
|
||||
|
||||
void wpas_ucode_free(void)
|
||||
{
|
||||
if (wpa_ucode_call_prepare("shutdown") == 0)
|
||||
ucv_put(wpa_ucode_call(0));
|
||||
wpa_ucode_free_vm();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
1
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ6018/fw_version.txt
Executable file
1
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ6018/fw_version.txt
Executable file
@@ -0,0 +1 @@
|
||||
WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 v1
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/fw_version.txt
Executable file
1
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/fw_version.txt
Executable file
@@ -0,0 +1 @@
|
||||
WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 v2
|
||||
0
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/m3_fw.b00
Normal file → Executable file
0
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/m3_fw.b00
Normal file → Executable file
0
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/m3_fw.b01
Normal file → Executable file
0
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/m3_fw.b01
Normal file → Executable file
0
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/m3_fw.b02
Normal file → Executable file
0
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/m3_fw.b02
Normal file → Executable file
0
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/m3_fw.flist
Normal file → Executable file
0
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/m3_fw.flist
Normal file → Executable file
0
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/m3_fw.mdt
Normal file → Executable file
0
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/m3_fw.mdt
Normal file → Executable file
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b00
Normal file → Executable file
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b00
Normal file → Executable file
Binary file not shown.
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b01
Normal file → Executable file
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b01
Normal file → Executable file
Binary file not shown.
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b02
Normal file → Executable file
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b02
Normal file → Executable file
Binary file not shown.
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b03
Normal file → Executable file
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b03
Normal file → Executable file
Binary file not shown.
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b04
Normal file → Executable file
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b04
Normal file → Executable file
Binary file not shown.
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b05
Normal file → Executable file
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b05
Normal file → Executable file
Binary file not shown.
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b07
Normal file → Executable file
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b07
Normal file → Executable file
Binary file not shown.
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b08
Normal file → Executable file
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.b08
Normal file → Executable file
Binary file not shown.
0
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.flist
Normal file → Executable file
0
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.flist
Normal file → Executable file
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.mdt
Normal file → Executable file
BIN
feeds/ipq807x_v5.4/ath11k-firmware/files/IPQ8074/q6_fw.mdt
Normal file → Executable file
Binary file not shown.
31
feeds/ipq807x_v5.4/ath11k-wifi/Makefile
Executable file → Normal file
31
feeds/ipq807x_v5.4/ath11k-wifi/Makefile
Executable file → Normal file
@@ -35,34 +35,24 @@ ALLWIFIBOARDS:= \
|
||||
edgecore-eap101 \
|
||||
gl-ax1800 \
|
||||
gl-axt1800 \
|
||||
gl-b3000 \
|
||||
sercomm-wallaby \
|
||||
edgecore-eap102 \
|
||||
edgecore-oap102 \
|
||||
edgecore-oap103 \
|
||||
edgecore-eap104 \
|
||||
emplus-wap385c \
|
||||
emplus-wap386v2 \
|
||||
liteon-wpx8324 \
|
||||
indio-um-310ax-v1 \
|
||||
indio-um-510axp-v1 \
|
||||
indio-um-510axm-v1 \
|
||||
muxi-ap3220l \
|
||||
plasmacloud-pax1800 \
|
||||
wallys-dr5018 \
|
||||
wallys-dr6018 \
|
||||
wallys-dr6018-v4 \
|
||||
sonicfi-rap630c-311g \
|
||||
sonicfi-rap630w-311g \
|
||||
sonicfi-rap630w-312g \
|
||||
sonicfi-rap650c \
|
||||
tplink-ex227 \
|
||||
tplink-ex447 \
|
||||
yuncore-ax840 \
|
||||
yuncore-fap650 \
|
||||
yuncore-fap655 \
|
||||
udaya-a6-id2 \
|
||||
udaya-a6-od2 \
|
||||
meshpp-s618
|
||||
|
||||
ALLWIFIPACKAGES:=$(foreach BOARD,$(ALLWIFIBOARDS),ath11k-wifi-$(BOARD))
|
||||
@@ -115,11 +105,6 @@ $(call Package/ath11k-wifi-default)
|
||||
TITLE:=gl-axt1800 bdf
|
||||
endef
|
||||
|
||||
define Package/ath11k-wifi-gl-b3000
|
||||
$(call Package/ath11k-wifi-default)
|
||||
TITLE:=gl-b3000 bdf
|
||||
endef
|
||||
|
||||
define Package/ath11k-wifi-motorola-q14
|
||||
$(call Package/ath11k-wifi-default)
|
||||
TITLE:=motorola q14 bdf
|
||||
@@ -305,13 +290,6 @@ define Package/ath11k-wifi-gl-axt1800/install
|
||||
$(INSTALL_DATA) ./board-gl-axt1800.bin.IPQ6018 $(1)/lib/firmware/ath11k/IPQ6018/hw1.0/board-2.bin
|
||||
endef
|
||||
|
||||
define Package/ath11k-wifi-gl-b3000/install
|
||||
$(INSTALL_DIR) $(1)/lib/firmware/ath11k/IPQ5018/hw1.0/
|
||||
$(INSTALL_DIR) $(1)/lib/firmware/ath11k/qcn6122/hw1.0/
|
||||
$(INSTALL_DATA) ./board-gl-b3000.bin.IPQ5018 $(1)/lib/firmware/ath11k/IPQ5018/hw1.0/board.bin
|
||||
$(INSTALL_DATA) ./board-gl-b3000.bin.QCN6122 $(1)/lib/firmware/ath11k/qcn6122/hw1.0/board.bin
|
||||
endef
|
||||
|
||||
define Package/ath11k-wifi-motorola-q14/install
|
||||
$(INSTALL_DIR) $(1)/lib/firmware/ath11k/IPQ5018/hw1.0/
|
||||
$(INSTALL_DIR) $(1)/lib/firmware/ath11k/qcn6122/hw1.0/
|
||||
@@ -404,18 +382,11 @@ $(eval $(call generate-ath11k-wifi-package,wallys-dr6018-v4,Wallys DR6018 V4))
|
||||
$(eval $(call generate-ath11k-wifi-package,edgecore-eap101,EdgeCore EAP101))
|
||||
$(eval $(call generate-ath11k-wifi-package,edgecore-eap102,Edgecore EAP102))
|
||||
$(eval $(call generate-ath11k-wifi-package,edgecore-oap102,Edgecore OAP102))
|
||||
$(eval $(call generate-ath11k-wifi-package,edgecore-oap103,Edgecore OAP103))
|
||||
$(eval $(call generate-ath11k-wifi-package,edgecore-eap104,Edgecore EAP104))
|
||||
$(eval $(call generate-ath11k-wifi-package,emplus-wap385c,Emplus WAP385C))
|
||||
$(eval $(call generate-ath11k-wifi-package,emplus-wap386v2,Emplus WAP386 V2))
|
||||
$(eval $(call generate-ath11k-wifi-package,liteon-wpx8324,Liteon WPX8324))
|
||||
$(eval $(call generate-ath11k-wifi-package,indio-um-310ax-v1,Indio UM-310AX V1))
|
||||
$(eval $(call generate-ath11k-wifi-package,indio-um-510axp-v1,Indio UM-510AXP V1))
|
||||
$(eval $(call generate-ath11k-wifi-package,indio-um-510axm-v1,Indio UM-510AXM V1))
|
||||
$(eval $(call generate-ath11k-wifi-package,sonicfi-rap630c-311g,Sonicfi RAP630C 311G))
|
||||
$(eval $(call generate-ath11k-wifi-package,sonicfi-rap630w-311g,Sonicfi RAP630W 311G))
|
||||
$(eval $(call generate-ath11k-wifi-package,sonicfi-rap630w-312g,Sonicfi RAP630W 312G))
|
||||
$(eval $(call generate-ath11k-wifi-package,sonicfi-rap650c,SonicFi RAP650C))
|
||||
$(eval $(call generate-ath11k-wifi-package,tplink-ex227,TP-Link EX227))
|
||||
$(eval $(call generate-ath11k-wifi-package,tplink-ex447,TP-Link EX447))
|
||||
$(eval $(call generate-ath11k-wifi-package,yuncore-ax840,YunCore AX840))
|
||||
@@ -424,8 +395,6 @@ $(eval $(call generate-ath11k-wifi-package,muxi-ap3220l,MUXI AP3220L))
|
||||
$(eval $(call generate-ath11k-wifi-package,yuncore-fap650,YunCore FAP650))
|
||||
$(eval $(call generate-ath11k-wifi-package,yuncore-fap655,YunCore FAP655))
|
||||
$(eval $(call generate-ath11k-wifi-package,udaya-a6-id2,Udaya A6-ID2))
|
||||
$(eval $(call generate-ath11k-wifi-package,udaya-a6-od2,Udaya A6-OD2))
|
||||
$(eval $(call generate-ath11k-wifi-package,wallys-dr5018,Wallys DR5018))
|
||||
|
||||
$(foreach PACKAGE,$(ALLWIFIPACKAGES),$(eval $(call BuildPackage,$(PACKAGE))))
|
||||
$(eval $(call BuildPackage,ath11k-wifi-qcom-ipq5018))
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,51 +0,0 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
#PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
PKG_NAME:=cooling
|
||||
PKG_RELEASE:=1
|
||||
|
||||
COOLING_MAKE_OPTS:= \
|
||||
CROSS=$(TARGET_CROSS) \
|
||||
COOLINGDIR=$(PKG_BUILD_DIR) \
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
||||
ifeq ($(CONFIG_TARGET_ipq50xx_generic_DEVICE_sonicfi_rap630c_311g),y)
|
||||
export TARGET_CFLAGS += -DPLATFORM_RAP630C_311G=1
|
||||
endif
|
||||
ifeq ($(CONFIG_TARGET_ipq50xx_generic_DEVICE_sonicfi_rap630w_311g),y)
|
||||
export TARGET_CFLAGS += -DPLATFORM_RAP630W_311G=1
|
||||
endif
|
||||
|
||||
define Package/cooling
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
MAINTAINER:=Sonicfi
|
||||
DEPENDS:=+libubox +libubus +libuci @TARGET_ipq50xx
|
||||
TITLE:=Wifi Thermal Mitigation daemon for QCA platform
|
||||
endef
|
||||
|
||||
define Package/cooling/description
|
||||
This package is wifi cooling mitigation daemon.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||
$(MAKE) -C $(PKG_BUILD_DIR) $(strip $(COOLING_MAKE_OPTS))
|
||||
endef
|
||||
|
||||
define Package/cooling/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cooling $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/cooling
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/sonicfi-rap630c-311g-cooling.conf $(1)/etc/cooling
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/sonicfi-rap630w-311g-cooling.conf $(1)/etc/cooling
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/cooling.init $(1)/etc/init.d/cooling
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_BIN) ./files/cooling.config $(1)/etc/config/cooling
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,cooling))
|
||||
@@ -1,2 +0,0 @@
|
||||
config cooling config
|
||||
option Enabled '1'
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=98
|
||||
|
||||
SERVICE_WRITE_PID=1
|
||||
SERVICE_DAEMONIZE=1
|
||||
|
||||
board=$(board_name)
|
||||
|
||||
start() {
|
||||
. /lib/functions.sh
|
||||
|
||||
local enabled
|
||||
|
||||
config_load 'cooling'
|
||||
config_get_bool enabled config 'Enabled' '0'
|
||||
|
||||
[ "$enabled" -gt 0 ] || return 1
|
||||
|
||||
case "$board" in
|
||||
sonicfi,rap630c-311g)
|
||||
service_start /usr/sbin/cooling -c /etc/cooling/sonicfi-rap630c-311g-cooling.conf
|
||||
;;
|
||||
sonicfi,rap630w-311g)
|
||||
service_start /usr/sbin/cooling -c /etc/cooling/sonicfi-rap630w-311g-cooling.conf
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop /usr/sbin/cooling
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
#****************************************************************************
|
||||
#
|
||||
# Copyright (c) 2024 Sonicfi, Inc.
|
||||
# All Rights Reserved.
|
||||
# Sonicfi Confidential and Proprietary.
|
||||
#
|
||||
#****************************************************************************/
|
||||
|
||||
ifneq ($(strip $(TOOLPREFIX)),)
|
||||
export CROSS:=$(TOOLPREFIX)
|
||||
endif
|
||||
|
||||
COOLING_INSTALL_ROOT := $(COOLINGDIR)/install
|
||||
|
||||
ifndef INSTALL_ROOT
|
||||
INSTALL_ROOT=$(COOLING_INSTALL_ROOT)
|
||||
endif
|
||||
|
||||
export CC = $(CROSS)gcc
|
||||
export CFLAGS += -O2 -Wall -c
|
||||
export STRIP = $(CROSS)strip
|
||||
export SOURCES= \
|
||||
cooling.c
|
||||
export OBJECTS=$(SOURCES:.c=.o)
|
||||
export EXECUTABLE=cooling
|
||||
|
||||
LIBS += -lubus -lubox
|
||||
CFLAGS += -L$(INSTALL_ROOT)/lib $(TARGET_CFLAGS) \
|
||||
-fstack-protector-all -fpie
|
||||
LDFLAGS += $(TARGET_LDFLAGS) -pie
|
||||
|
||||
# What we build by default:
|
||||
ALL = $(EXECUTABLE)
|
||||
|
||||
# RULES ---------------------------------------------------------------
|
||||
|
||||
# Making default targets:
|
||||
all: local
|
||||
@echo All done in `pwd`
|
||||
|
||||
$(EXECUTABLE): $(OBJECTS)
|
||||
$(CC) $(LIB_PATH) $(LIBS) $(LDFLAGS) $(OBJECTS) -o $@
|
||||
@echo Build $@ successufully...
|
||||
|
||||
.c.o:
|
||||
$(CC) $(INCLUDE) $(CFLAGS) $(LDFLAGS) $< -o $@
|
||||
|
||||
clean:
|
||||
rm -rf *.o *.d $(EXECUTABLE)
|
||||
|
||||
local: $(SOURCES) $(EXECUTABLE)
|
||||
@echo Build $@ successufully...
|
||||
|
||||
# Doing installation (see comments at top of this file)
|
||||
install: local
|
||||
mkdir -p $(INSTALL_ROOT)/usr/sbin/
|
||||
cp -a -f $(ALL) $(INSTALL_ROOT)/usr/sbin/
|
||||
mkdir -p $(INSTALL_ROOT)/etc/cooling
|
||||
cp -a -f sonicfi-rap630*-cooling.conf $(INSTALL_ROOT)/etc/cooling/
|
||||
@echo Installed outputs from `pwd`
|
||||
|
||||
# Remove all generated files
|
||||
#clean: default_clean # from Makefile.rules
|
||||
clean:
|
||||
rm -rf $(INSTALL_ROOT)/usr/sbin/cooling
|
||||
rm -rf ./$(ALL)
|
||||
|
||||
# END --------------------------------------------------------------------
|
||||
@@ -1,343 +0,0 @@
|
||||
/*===========================================================================
|
||||
|
||||
cooling.c
|
||||
|
||||
DESCRIPTION
|
||||
Thermal monitor and mitigation implementation functions.
|
||||
|
||||
===========================================================================*/
|
||||
#include <stdio.h> /* Standard input/output definitions */
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* String function definitions */
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <getopt.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <libubox/ustream.h>
|
||||
#include <libubox/uloop.h>
|
||||
#include <libubox/list.h>
|
||||
#include <libubox/ulog.h>
|
||||
#include <libubus.h>
|
||||
|
||||
|
||||
#define CUR_STATE_PATH "/sys/devices/virtual/thermal/cooling_device%i/cur_state"
|
||||
#define TEMPER_PATH "/sys/devices/virtual/thermal/thermal_zone%i/temp"
|
||||
#define CPU_FREQ_PATH "/sys/devices/system/cpu/cpu0/cpufreq/%s"
|
||||
|
||||
#define PATH_MAX 256
|
||||
#define BUF_MAX 32
|
||||
#define PHY0 0
|
||||
#define PHY1 1
|
||||
#define NUM_VALUES 4
|
||||
|
||||
int load_config_file=0;
|
||||
|
||||
//#define ULOG_INFO(fmt, ...) ulog(LOG_INFO, fmt, ## __VA_ARGS__)
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned long u32;
|
||||
|
||||
u8 w2g_threshold_level=0;
|
||||
u8 w5g_threshold_level=0;
|
||||
u8 w2g_cur_temper=0;
|
||||
u8 w5g_cur_temper=0;
|
||||
u32 level_cpu_freq=1008000;
|
||||
|
||||
/* default value of wifi thresholds*/
|
||||
#ifdef PLATFORM_RAP630C_311G
|
||||
u8 level_2g_high[4]={105, 110, 115, 120};
|
||||
u8 level_2g_low[4]={0, 105, 110, 115};
|
||||
u8 level_2g_mitigation[4]={0, 35, 50, 70};
|
||||
u8 level_5g_high[4]={105, 110, 115, 120};
|
||||
u8 level_5g_low[4]={0, 105, 110, 115};
|
||||
u8 level_5g_mitigation[4]={0, 20, 30, 50};
|
||||
u32 level_cpu_frequency[4]={1008000, 800000, 800000, 800000};
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_RAP630W_311G
|
||||
u8 level_2g_high[4]={105, 110, 115, 120};
|
||||
u8 level_2g_low[4]={0, 105, 110, 115};
|
||||
u8 level_2g_mitigation[4]={0, 20, 50, 70};
|
||||
u8 level_5g_high[4]={105, 110, 115, 120};
|
||||
u8 level_5g_low[4]={0, 105, 110, 115};
|
||||
u8 level_5g_mitigation[4]={0, 20, 50, 70};
|
||||
u32 level_cpu_frequency[4]={1008000, 800000, 800000, 800000};
|
||||
#endif
|
||||
|
||||
static char *config_file = NULL;
|
||||
|
||||
typedef struct {
|
||||
int thresholds_high[NUM_VALUES];
|
||||
int thresholds_low[NUM_VALUES];
|
||||
int mitigation[NUM_VALUES];
|
||||
int cpu_freq[NUM_VALUES];
|
||||
} WifiConfig;
|
||||
|
||||
WifiConfig wifi2g = {0}, wifi5g = {0};
|
||||
|
||||
static void set_cpu_freq (int freq) {
|
||||
FILE * fp;
|
||||
char filename[PATH_MAX];
|
||||
|
||||
snprintf(filename, PATH_MAX, CPU_FREQ_PATH, "scaling_governor");
|
||||
|
||||
fp = fopen(filename, "w");
|
||||
if (!fp) {
|
||||
ULOG_ERR("open scaling_governor error\n");
|
||||
}
|
||||
fprintf(fp, "%s", "userspace");
|
||||
fclose(fp);
|
||||
|
||||
snprintf(filename, PATH_MAX, CPU_FREQ_PATH, "scaling_setspeed");
|
||||
|
||||
fp = fopen(filename, "w");
|
||||
if (!fp) {
|
||||
ULOG_ERR("open scaling_setspeed error\n");
|
||||
}
|
||||
fprintf(fp, "%d", freq);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void parse_line(const char* line, const char* key, int* array) {
|
||||
char label[64];
|
||||
int values[NUM_VALUES];
|
||||
int i;
|
||||
|
||||
if (sscanf(line, "%s %d %d %d %d %d", label, &values[0], &values[1], &values[2], &values[3], &values[4]) == 5) {
|
||||
for (i = 0; i < NUM_VALUES; ++i) {
|
||||
array[i] = values[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int load_config() {
|
||||
FILE * fp = fopen(config_file, "r");
|
||||
if (!fp) {
|
||||
ULOG_ERR("open config file error\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
WifiConfig* current_config = NULL;
|
||||
char line[256];
|
||||
|
||||
while (fgets(line, sizeof(line), fp)) {
|
||||
if (strstr(line, "[wifi2g]")) {
|
||||
current_config = &wifi2g;
|
||||
} else if (strstr(line, "[wifi5g]")) {
|
||||
current_config = &wifi5g;
|
||||
} else if (current_config) {
|
||||
if (strstr(line, "thresholds_high")) {
|
||||
parse_line(line, "thresholds_high", current_config->thresholds_high);
|
||||
} else if (strstr(line, "thresholds_low")) {
|
||||
parse_line(line, "thresholds_low", current_config->thresholds_low);
|
||||
} else if (strstr(line, "mitigation")) {
|
||||
parse_line(line, "mitigation", current_config->mitigation);
|
||||
} else if (strstr(line, "CPU_freq")) {
|
||||
parse_line(line, "CPU_freq", current_config->cpu_freq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
set_cpu_freq(wifi5g.cpu_freq[0]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int load_default_config(){
|
||||
int i=0;
|
||||
|
||||
set_cpu_freq(1008000);
|
||||
for (i = 0; i < NUM_VALUES; i++) {
|
||||
wifi2g.thresholds_high[i]=level_2g_high[i];
|
||||
wifi2g.thresholds_low[i]=level_2g_low[i];
|
||||
wifi2g.mitigation[i]=level_2g_mitigation[i];
|
||||
wifi2g.cpu_freq[i]=level_cpu_frequency[i];
|
||||
wifi5g.thresholds_high[i]=level_5g_high[i];
|
||||
wifi5g.thresholds_low[i]=level_5g_low[i];
|
||||
wifi5g.mitigation[i]=level_5g_mitigation[i];
|
||||
wifi5g.cpu_freq[i]=level_cpu_frequency[i];
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static void write_cur_state (const char *filename, int state) {
|
||||
FILE * fp;
|
||||
|
||||
fp = fopen(filename, "w");
|
||||
if (!fp){
|
||||
ULOG_ERR("open %s file error\n",filename);
|
||||
}
|
||||
fprintf(fp, "%d", state);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
int read_cur_state(const char *filename, char *buf, size_t buffer) {
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen(filename, "r");
|
||||
if (!fp) {
|
||||
ULOG_ERR("open %s file error\n",filename);
|
||||
return -1;
|
||||
}
|
||||
if (!fgets(buf, buffer, fp)) {
|
||||
ULOG_ERR("Failed to read %s file\n", filename);
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void wifi_get_temperature() {
|
||||
char filename[PATH_MAX];
|
||||
char buffer[BUF_MAX];
|
||||
int i = 0;
|
||||
|
||||
// ULOG_INFO("=================================\n");
|
||||
|
||||
/* read cpuinfo_cur_freq*/
|
||||
snprintf(filename, PATH_MAX, CPU_FREQ_PATH, "cpuinfo_cur_freq");
|
||||
|
||||
memset(buffer, 0, BUF_MAX);
|
||||
read_cur_state(filename, buffer, sizeof(buffer));
|
||||
// ULOG_INFO("CPU current frequency: %s\n", buffer);
|
||||
|
||||
/* get current phy cooling state*/
|
||||
for (i=0; i <= 1; i++) {
|
||||
memset(buffer, 0, BUF_MAX);
|
||||
snprintf(filename, PATH_MAX, CUR_STATE_PATH, i);
|
||||
read_cur_state(filename, buffer, sizeof(buffer));
|
||||
// ULOG_INFO("Phy%i cur_state is: %s\n", i, buffer);
|
||||
}
|
||||
|
||||
for (i=0; i <= 3; i++) {
|
||||
memset(buffer, 0, BUF_MAX);
|
||||
snprintf(filename, PATH_MAX, TEMPER_PATH, i);
|
||||
read_cur_state(filename, buffer, sizeof(buffer));
|
||||
// ULOG_INFO("thermal_zone%i cur_temp is: %s\n", i, buffer);
|
||||
|
||||
if (i == 0)
|
||||
w2g_cur_temper=atoi(buffer);
|
||||
else if (i == 3)
|
||||
w5g_cur_temper=atoi(buffer);
|
||||
}
|
||||
|
||||
if (w5g_cur_temper >= 120)
|
||||
{
|
||||
ULOG_ERR("!! Temperature is over %d degree, system will reboot\n", w5g_cur_temper);
|
||||
sync();
|
||||
if ( -1 != system("reboot &") ){
|
||||
printf("sysyem reboot...\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void wifi_set_cooling() {
|
||||
char filename[PATH_MAX];
|
||||
int level;
|
||||
|
||||
for (level = 0; level <= 3; level++) {
|
||||
if (w2g_cur_temper >= wifi2g.thresholds_low[level] && w2g_cur_temper < wifi2g.thresholds_high[level]) {
|
||||
// ULOG_INFO("2G at level %d , %d degree\n" ,level, w2g_cur_temper);
|
||||
if (w2g_threshold_level != level) {
|
||||
// ULOG_INFO("setting 2G reduce %d percent\n" ,wifi2g.mitigation[level]);
|
||||
snprintf(filename, PATH_MAX, CUR_STATE_PATH, PHY0);
|
||||
write_cur_state(filename, wifi2g.mitigation[level]);
|
||||
w2g_threshold_level = level;
|
||||
}
|
||||
}
|
||||
if (w5g_cur_temper >= wifi5g.thresholds_low[level] && w5g_cur_temper < wifi5g.thresholds_high[level]) {
|
||||
// ULOG_INFO("5G at level %d , %d degree\n" ,level, w5g_cur_temper);
|
||||
if (w5g_threshold_level != level) {
|
||||
// ULOG_INFO("setting 5G reduce %d percent\n" ,wifi5g.mitigation[level]);
|
||||
snprintf(filename, PATH_MAX, CUR_STATE_PATH, PHY1);
|
||||
write_cur_state(filename, wifi5g.mitigation[level]);
|
||||
w5g_threshold_level = level;
|
||||
set_cpu_freq(wifi5g.cpu_freq[level]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void cooling_init() {
|
||||
char filename[PATH_MAX];
|
||||
int i,result=0;
|
||||
|
||||
for (i=0 ; i <= 1; i++) {
|
||||
snprintf(filename, PATH_MAX, CUR_STATE_PATH, i);
|
||||
write_cur_state(filename, 0);
|
||||
}
|
||||
|
||||
if(load_config_file)
|
||||
result = load_config();
|
||||
|
||||
if (result == 1 || load_config_file == 0)
|
||||
load_default_config();
|
||||
}
|
||||
|
||||
void print_usage(void)
|
||||
{
|
||||
printf("\nWifi-cooling daemon usage\n");
|
||||
printf("Optional arguments:\n");
|
||||
printf(" -c <file> setting with config file\n");
|
||||
printf(" -d default setting\n");
|
||||
printf(" -h this usage screen\n");
|
||||
}
|
||||
|
||||
static void state_timeout_cb(struct uloop_timeout *t)
|
||||
{
|
||||
wifi_get_temperature();
|
||||
wifi_set_cooling();
|
||||
uloop_timeout_set(t, 30 * 1000); // interval 30 seconds
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ch;
|
||||
struct uloop_timeout state_timeout = {
|
||||
.cb = state_timeout_cb,
|
||||
};
|
||||
|
||||
setpriority(PRIO_PROCESS, getpid(), -20);
|
||||
|
||||
ulog_open(ULOG_STDIO | ULOG_SYSLOG, LOG_DAEMON, "cooling");
|
||||
ulog_threshold(LOG_ERR);
|
||||
// ulog_threshold(LOG_INFO);
|
||||
|
||||
while ((ch = getopt(argc, argv, "c:dh")) != -1) {
|
||||
switch (ch) {
|
||||
case 'c':
|
||||
printf("wifi-cooling load configuration file %s\n", optarg);
|
||||
config_file = optarg;
|
||||
load_config_file=1;
|
||||
break;
|
||||
case 'd':
|
||||
printf("wifi-cooling set to default value\n");
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
print_usage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cooling_init();
|
||||
uloop_init();
|
||||
uloop_timeout_set(&state_timeout, 1000);
|
||||
uloop_run();
|
||||
uloop_done();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
[wifi2g]
|
||||
thresholds_high 105 110 115 120
|
||||
thresholds_low 0 105 110 115
|
||||
mitigation 0 35 50 70
|
||||
CPU_freq 1008000 800000 800000 800000
|
||||
|
||||
[wifi5g]
|
||||
thresholds_high 105 110 115 120
|
||||
thresholds_low 0 105 110 115
|
||||
mitigation 0 20 30 50
|
||||
CPU_freq 1008000 800000 800000 800000
|
||||
@@ -1,11 +0,0 @@
|
||||
[wifi2g]
|
||||
thresholds_high 105 110 115 120
|
||||
thresholds_low 0 105 110 115
|
||||
mitigation 0 20 50 70
|
||||
CPU_freq 1008000 800000 800000 800000
|
||||
|
||||
[wifi5g]
|
||||
thresholds_high 105 110 115 120
|
||||
thresholds_low 0 105 110 115
|
||||
mitigation 0 20 50 70
|
||||
CPU_freq 1008000 800000 800000 800000
|
||||
@@ -601,11 +601,10 @@ define Package/afcd/install
|
||||
$(INSTALL_DIR) $(1)/usr/share/hostap $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/afcd.init $(1)/etc/init.d/afcd
|
||||
$(INSTALL_DATA) ./files/afcd.uc $(1)/usr/share/hostap/
|
||||
$(INSTALL_DATA) ./files/afc_location.uc $(1)/usr/share/hostap/
|
||||
endef
|
||||
|
||||
define Install/hostapd
|
||||
$(INSTALL_DIR) $(1)/usr/sbin $(1)/usr/share/hostap $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/usr/sbin $(1)/usr/share/hostap
|
||||
$(INSTALL_DATA) ./files/hostapd.uc $(1)/usr/share/hostap/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d $(1)/etc/config $(1)/etc/radius
|
||||
ln -sf hostapd $(1)/usr/sbin/hostapd-radius
|
||||
@@ -613,8 +612,6 @@ define Install/hostapd
|
||||
$(INSTALL_DATA) ./files/radius.config $(1)/etc/config/radius
|
||||
$(INSTALL_DATA) ./files/radius.clients $(1)/etc/radius/clients
|
||||
$(INSTALL_DATA) ./files/radius.users $(1)/etc/radius/users
|
||||
$(INSTALL_BIN) ./files/mpskd $(1)/usr/share/hostap/
|
||||
$(INSTALL_BIN) ./files/mpskd.init $(1)/etc/init.d/mpskd
|
||||
endef
|
||||
|
||||
define Install/supplicant
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/usr/bin/env ucode
|
||||
'use strict';
|
||||
let fs = require("fs");
|
||||
let ubus = require('ubus').connect();
|
||||
|
||||
let gps_info = ubus.call('gps', 'info');
|
||||
let latitude = gps_info.latitude ?? 0;
|
||||
let longitude = gps_info.longitude ?? 0;
|
||||
|
||||
// afc-location.json file content
|
||||
let afc_location = {};
|
||||
afc_location.location_type = "ellipse";
|
||||
afc_location.location = longitude + ":" + latitude ;
|
||||
afc_location.height = gps_info.elevation ?? 0;
|
||||
afc_location.height_type = "AMSL";
|
||||
afc_location.major_axis = gps_info.major_axis ?? 0;
|
||||
afc_location.minor_axis = gps_info.minor_axis ?? 0;
|
||||
afc_location.orientation = gps_info.major_orientation ?? 0;
|
||||
afc_location.vertical_tolerance = gps_info.vdop ?? 0;
|
||||
|
||||
let afc_location_json = fs.open("/etc/ucentral/afc-location.json", "w");
|
||||
afc_location_json.write(afc_location);
|
||||
afc_location_json.close();
|
||||
@@ -4,7 +4,6 @@ START=19
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=afcd
|
||||
PROG=/usr/bin/ucode
|
||||
|
||||
add_afc() {
|
||||
config_get_bool disabled "$1" disabled 0
|
||||
@@ -15,26 +14,15 @@ add_afc() {
|
||||
[ -n "$url" ] || return
|
||||
|
||||
procd_open_instance afcd
|
||||
procd_set_param command "$PROG" /usr/share/hostap/afcd.uc -u "$url"
|
||||
[ -n "$cert" ] && procd_append_param command -c "$cert"
|
||||
procd_set_param command /usr/bin/ucode /usr/share/hostap/afcd.uc -u "$url"
|
||||
[ -n "$cert" ] && procd_append_param command -c "$cert"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
_afc_location() {
|
||||
# create afc-location.json
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG" /usr/share/hostap/afc_location.uc
|
||||
procd_set_param respawn 0 60 5
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load wireless
|
||||
config_foreach add_afc afc-server
|
||||
|
||||
local gps_disabled=$(uci get gps.@gps[-1].disabled)
|
||||
[ "$gps_disabled" -eq 0 ] && _afc_location
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
|
||||
@@ -72,7 +72,7 @@ function handle_request(req)
|
||||
|
||||
let cl = uclient.new(opts.url, null, cb);
|
||||
|
||||
if (!cl.ssl_init({ verify: !!opts.cert, ca_files: [ opts.cert ] })) {
|
||||
if (!cl.ssl_init({ verify: true, ca_files: [ opts.cert ] })) {
|
||||
warn(`Failed to initialize SSL\n`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ hostapd_append_wpa_key_mgmt() {
|
||||
[ "${ieee80211w:-0}" -gt 0 ] && append wpa_key_mgmt "WPA-${auth_type_l}-SHA256"
|
||||
;;
|
||||
eap192)
|
||||
[ "${ieee80211r:-0}" -gt 0 ] || append wpa_key_mgmt "WPA-EAP-SUITE-B-192"
|
||||
[ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-EAP-SHA384"
|
||||
append wpa_key_mgmt "WPA-EAP-SUITE-B-192"
|
||||
[ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-EAP"
|
||||
;;
|
||||
eap-eap2)
|
||||
append wpa_key_mgmt "WPA-EAP"
|
||||
@@ -73,10 +73,6 @@ hostapd_append_wpa_key_mgmt() {
|
||||
owe)
|
||||
append wpa_key_mgmt "OWE"
|
||||
;;
|
||||
psk2-radius)
|
||||
append wpa_key_mgmt "WPA-PSK"
|
||||
[ "${ieee80211r:-0}" -gt 0 ] && append wpa_key_mgmt "FT-PSK"
|
||||
;;
|
||||
esac
|
||||
|
||||
[ "$fils" -gt 0 ] && {
|
||||
@@ -117,6 +113,8 @@ hostapd_common_add_device_config() {
|
||||
config_add_boolean legacy_rates
|
||||
config_add_int cell_density
|
||||
config_add_int rts_threshold
|
||||
config_add_int rssi_reject_assoc_rssi
|
||||
config_add_int rssi_ignore_probe_request
|
||||
config_add_int maxassoc
|
||||
config_add_boolean maxassoc_ignore_probe
|
||||
|
||||
@@ -160,7 +158,7 @@ hostapd_prepare_device_config() {
|
||||
|
||||
json_get_vars country country3 country_ie beacon_int:100 dtim_period:2 doth require_mode legacy_rates \
|
||||
acs_chan_bias local_pwr_constraint spectrum_mgmt_required airtime_mode cell_density \
|
||||
rts_threshold beacon_rate maxassoc \
|
||||
rts_threshold beacon_rate rssi_reject_assoc_rssi rssi_ignore_probe_request maxassoc \
|
||||
multiple_bssid he_co_locate rnr_beacon ema acs_exclude_dfs \
|
||||
maxassoc_ignore_probe band
|
||||
|
||||
@@ -259,6 +257,8 @@ hostapd_prepare_device_config() {
|
||||
hostapd_add_rate brlist "$br"
|
||||
done
|
||||
|
||||
[ -n "$rssi_reject_assoc_rssi" ] && append base_cfg "rssi_reject_assoc_rssi=$rssi_reject_assoc_rssi" "$N"
|
||||
[ -n "$rssi_ignore_probe_request" ] && append base_cfg "rssi_ignore_probe_request=$rssi_ignore_probe_request" "$N"
|
||||
[ -n "$beacon_rate" ] && append base_cfg "beacon_rate=$beacon_rate" "$N"
|
||||
[ -n "$rlist" ] && append base_cfg "supported_rates=$rlist" "$N"
|
||||
[ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N"
|
||||
@@ -336,7 +336,6 @@ hostapd_common_add_bss_config() {
|
||||
wpa_group_rekey wpa_pair_rekey wpa_master_rekey
|
||||
config_add_boolean wpa_strict_rekey
|
||||
config_add_boolean wpa_disable_eapol_key_retries
|
||||
config_add_boolean multi_psk
|
||||
|
||||
config_add_boolean tdls_prohibit
|
||||
|
||||
@@ -406,7 +405,7 @@ hostapd_common_add_bss_config() {
|
||||
|
||||
config_add_boolean ieee80211r pmk_r1_push ft_psk_generate_local ft_over_ds
|
||||
config_add_int r0_key_lifetime reassociation_deadline ft_l2_refresh
|
||||
config_add_string mobility_domain r1_key_holder ft_key
|
||||
config_add_string mobility_domain r1_key_holder
|
||||
config_add_array r0kh r1kh
|
||||
|
||||
config_add_int ieee80211w_max_timeout ieee80211w_retry_timeout
|
||||
@@ -468,9 +467,6 @@ hostapd_common_add_bss_config() {
|
||||
config_add_string uci_section
|
||||
|
||||
config_add_boolean dynamic_probe_resp
|
||||
|
||||
config_add_int rssi_reject_assoc_rssi
|
||||
config_add_int rssi_ignore_probe_request
|
||||
}
|
||||
|
||||
hostapd_set_vlan_file() {
|
||||
@@ -724,8 +720,7 @@ hostapd_set_bss_options() {
|
||||
airtime_bss_weight airtime_bss_limit airtime_sta_weight \
|
||||
multicast_to_unicast_all proxy_arp per_sta_vif \
|
||||
eap_server eap_user_file ca_cert server_cert private_key private_key_passwd server_id \
|
||||
vendor_elements fils uci_section dynamic_probe_resp multi_psk \
|
||||
rssi_reject_assoc_rssi rssi_ignore_probe_request
|
||||
vendor_elements fils uci_section dynamic_probe_resp
|
||||
|
||||
set_default fils 0
|
||||
set_default isolate 0
|
||||
@@ -738,7 +733,6 @@ hostapd_set_bss_options() {
|
||||
set_default wmm 1
|
||||
set_default uapsd 1
|
||||
set_default wpa_disable_eapol_key_retries 0
|
||||
set_default multi_psk $multi_psk
|
||||
set_default tdls_prohibit 0
|
||||
set_default eapol_version $((wpa & 1))
|
||||
set_default acct_port 1813
|
||||
@@ -780,8 +774,6 @@ hostapd_set_bss_options() {
|
||||
append bss_conf "uapsd_advertisement_enabled=$uapsd" "$N"
|
||||
append bss_conf "utf8_ssid=$utf8_ssid" "$N"
|
||||
append bss_conf "multi_ap=$multi_ap" "$N"
|
||||
[ -n "$rssi_reject_assoc_rssi" ] && append bss_conf "rssi_reject_assoc_rssi=$rssi_reject_assoc_rssi" "$N"
|
||||
[ -n "$rssi_ignore_probe_request" ] && append bss_conf "rssi_ignore_probe_request=$rssi_ignore_probe_request" "$N"
|
||||
[ -n "$vendor_elements" ] && append bss_conf "vendor_elements=$vendor_elements" "$N"
|
||||
|
||||
[ "$tdls_prohibit" -gt 0 ] && append bss_conf "tdls_prohibit=$tdls_prohibit" "$N"
|
||||
@@ -1022,7 +1014,7 @@ hostapd_set_bss_options() {
|
||||
[ -n "$ft_l2_refresh" ] && append bss_conf "ft_l2_refresh=$ft_l2_refresh" "$N"
|
||||
|
||||
if [ "$skip_kh_setup" -eq "0" ]; then
|
||||
json_get_vars r0_key_lifetime r1_key_holder pmk_r1_push ft_key
|
||||
json_get_vars r0_key_lifetime r1_key_holder pmk_r1_push
|
||||
json_get_values r0kh r0kh
|
||||
json_get_values r1kh r1kh
|
||||
|
||||
@@ -1030,15 +1022,12 @@ hostapd_set_bss_options() {
|
||||
set_default pmk_r1_push 0
|
||||
|
||||
[ -n "$r0kh" -a -n "$r1kh" ] || {
|
||||
[ -z "$ft_key" ] && {
|
||||
key=`echo -n "$mobility_domain/$auth_secret" | md5sum | awk '{print $1}'`
|
||||
key=`echo -n "$mobility_domain/$auth_secret" | md5sum | awk '{print $1}'`
|
||||
|
||||
set_default r0kh "ff:ff:ff:ff:ff:ff,*,$key"
|
||||
set_default r1kh "00:00:00:00:00:00,00:00:00:00:00:00,$key"
|
||||
}
|
||||
set_default r0kh "ff:ff:ff:ff:ff:ff,*,$key"
|
||||
set_default r1kh "00:00:00:00:00:00,00:00:00:00:00:00,$key"
|
||||
}
|
||||
|
||||
[ -n "$ft_key" ] && append bss_conf "ft_key=$ft_key" "$N"
|
||||
[ -n "$r1_key_holder" ] && append bss_conf "r1_key_holder=$r1_key_holder" "$N"
|
||||
append bss_conf "r0_key_lifetime=$r0_key_lifetime" "$N"
|
||||
append bss_conf "pmk_r1_push=$pmk_r1_push" "$N"
|
||||
|
||||
@@ -833,8 +833,6 @@ let main_obj = {
|
||||
hostapd.printf(`Set new config for phy ${phy}: ${file}`);
|
||||
iface_set_config(phy, config);
|
||||
|
||||
hostapd.data.auth_obj.notify("reload", { phy });
|
||||
|
||||
return {
|
||||
pid: hostapd.getpid()
|
||||
};
|
||||
@@ -874,9 +872,6 @@ let main_obj = {
|
||||
hostapd.data.ubus = ubus;
|
||||
hostapd.data.obj = ubus.publish("hostapd", main_obj);
|
||||
|
||||
let auth_obj = {};
|
||||
hostapd.data.auth_obj = ubus.publish("hostapd-auth", auth_obj);
|
||||
|
||||
function bss_event(type, name, data) {
|
||||
let ubus = hostapd.data.ubus;
|
||||
|
||||
@@ -906,23 +901,5 @@ return {
|
||||
},
|
||||
bss_remove: function(name, obj) {
|
||||
bss_event("remove", name);
|
||||
},
|
||||
sta_auth: function(iface, sta) {
|
||||
let msg = { iface, sta };
|
||||
let ret = {};
|
||||
let data_cb = (type, data) => {
|
||||
ret = { ...ret, ...data };
|
||||
};
|
||||
hostapd.data.auth_obj.notify("sta_auth", msg, data_cb, null, null, 1000);
|
||||
return ret;
|
||||
},
|
||||
sta_connected: function(iface, sta, data) {
|
||||
let msg = { iface, sta, ...data };
|
||||
let ret = {};
|
||||
let data_cb = (type, data) => {
|
||||
ret = { ...ret, ...data };
|
||||
};
|
||||
hostapd.data.auth_obj.notify("sta_connected", msg, data_cb, null, null, 1000);
|
||||
return ret;
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,374 +0,0 @@
|
||||
#!/usr/bin/env ucode
|
||||
'use strict';
|
||||
import * as uloop from 'uloop';
|
||||
import * as libubus from 'ubus';
|
||||
|
||||
uloop.init();
|
||||
let ubus = libubus.connect();
|
||||
|
||||
let interfaces = {};
|
||||
let ssids = {};
|
||||
let cache = {};
|
||||
let subs_hapd = [];
|
||||
let reload_timer;
|
||||
let gc_timer;
|
||||
|
||||
let timeout = 48 * 60 * 60;
|
||||
|
||||
function event_cb_6g(req) {
|
||||
//printf('6g %s %.J\n', req.data, req.type);
|
||||
if (req.type != 'auth' && req.type != 'probe')
|
||||
return 0;
|
||||
|
||||
let addr = req.data.address;
|
||||
let iface = interfaces[req.data.ifname];
|
||||
if (!iface)
|
||||
return 0;
|
||||
|
||||
let ssid = iface.ssid;
|
||||
|
||||
if (!ssid || !ssids[ssid].mpsk)
|
||||
return 0;
|
||||
|
||||
let ssid_cache = cache[ssid];
|
||||
if (ssid_cache && addr in ssid_cache)
|
||||
return 0;
|
||||
|
||||
if (req.type == 'probe') {
|
||||
printf(`Ignore probe ${req.type} on ${req.data.ifname} from ${addr}\n`);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf(`reject ${req.type} on ${req.data.ifname} from ${addr}\n`);
|
||||
return 5;
|
||||
}
|
||||
|
||||
function event_cb(req) {
|
||||
//printf('normal %s %.J\n', req.data, req.type);
|
||||
if (req.type != 'probe')
|
||||
return 0;
|
||||
|
||||
let addr = req.data.address;
|
||||
let iface = interfaces[req.data.ifname];
|
||||
if (!iface)
|
||||
return 0;
|
||||
|
||||
let ssid = iface.ssid;
|
||||
if (!ssid || !ssids[ssid].mpsk)
|
||||
return 0;
|
||||
|
||||
let ssid_cache = cache[ssid];
|
||||
if (ssid_cache && addr in ssid_cache)
|
||||
return 0;
|
||||
|
||||
printf(`reply to ${req.type} on ${req.data.ifname} from ${addr} without 6G RNR\n`);
|
||||
return 2;
|
||||
}
|
||||
|
||||
function create_6g_subscriber() {
|
||||
for (let cur_sub in subs_hapd)
|
||||
cur_sub.remove();
|
||||
subs_hapd = [];
|
||||
for (let ifname, iface in interfaces) {
|
||||
let obj = 'hostapd.' + ifname;
|
||||
let cur_sub;
|
||||
if (iface.band == '6g')
|
||||
cur_sub = ubus.subscriber((req) => event_cb_6g(req));
|
||||
else
|
||||
cur_sub = ubus.subscriber((req) => event_cb(req));
|
||||
cur_sub.subscribe(obj);
|
||||
push(subs_hapd, cur_sub);
|
||||
printf(`subscribe ${ifname}\n`);
|
||||
ubus.call(obj, 'notify_response', { notify_response: 1 });
|
||||
}
|
||||
}
|
||||
|
||||
function cache_gc() {
|
||||
let ts = time();
|
||||
|
||||
for (let ssid in keys(cache)) {
|
||||
if (!ssids[ssid]) {
|
||||
delete cache[ssid];
|
||||
continue;
|
||||
}
|
||||
|
||||
let ssid_cache = cache[ssid];
|
||||
ssid = ssids[ssid];
|
||||
|
||||
for (let addr in keys(ssid_cache)) {
|
||||
let sta = ssid_cache[addr];
|
||||
let keep = ts < cache.timeout;
|
||||
|
||||
if (keep && !ssid.keys[sta.key])
|
||||
keep = false;
|
||||
if (keep)
|
||||
sta.keydata = ssid.keys[sta.key];
|
||||
if (!keep)
|
||||
delete cache[addr];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function netifd_reload() {
|
||||
let data = ubus.call('network.wireless', 'status');
|
||||
|
||||
ssids = {};
|
||||
interfaces = {};
|
||||
|
||||
for (let radio_name, radio in data) {
|
||||
if (!radio.up)
|
||||
continue;
|
||||
|
||||
for (let iface in radio.interfaces) {
|
||||
let config = iface.config;
|
||||
|
||||
if (config.mode != 'ap' || !iface.ifname)
|
||||
continue;
|
||||
|
||||
let band = radio.config.band;
|
||||
let nr_data = ubus.call('hostapd.' + iface.ifname, 'rrm_nr_get_own');
|
||||
let nr;
|
||||
if (nr_data && nr_data.value && nr_data.value[2])
|
||||
nr = nr_data.value[2];
|
||||
interfaces[iface.ifname] = {
|
||||
band, nr,
|
||||
ssid: config.ssid,
|
||||
};
|
||||
|
||||
ssids[config.ssid] ??= {
|
||||
interfaces: [],
|
||||
keys: {},
|
||||
bands: {},
|
||||
};
|
||||
let ssid = ssids[config.ssid];
|
||||
|
||||
push(ssid.interfaces, iface.ifname);
|
||||
ssid.bands[band] = iface.ifname;
|
||||
ssid.mpsk = ssid?.mpsk ? true : config.multi_psk;
|
||||
for (let sta in iface.stations) {
|
||||
let stacfg = sta.config;
|
||||
|
||||
let key = stacfg.key;
|
||||
if (!key)
|
||||
continue;
|
||||
|
||||
let keydata = {};
|
||||
let vid = stacfg.vid;
|
||||
if (vid)
|
||||
keydata.vlan = +vid;
|
||||
let mac = stacfg.mac;
|
||||
if (mac)
|
||||
keydata.mac = mac;
|
||||
ssid.keys[key] = keydata;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf('New config: %.J\n', { ssids, interfaces });
|
||||
cache_gc();
|
||||
create_6g_subscriber();
|
||||
}
|
||||
|
||||
function iface_ssid(ifname) {
|
||||
let iface = interfaces[ifname];
|
||||
if (!iface)
|
||||
return;
|
||||
|
||||
return iface.ssid;
|
||||
}
|
||||
|
||||
function is_ssid_mpsk(ifname) {
|
||||
let ssid = iface_ssid(ifname);
|
||||
if (!ssid)
|
||||
return false;
|
||||
|
||||
if (!ssids[ssid])
|
||||
return false;
|
||||
|
||||
if (!ssids[ssid]?.mpsk)
|
||||
return false;
|
||||
|
||||
return ssids[ssid].mpsk;
|
||||
}
|
||||
|
||||
function sta_cache_entry_get(ssid, addr) {
|
||||
let ssid_cache = cache[ssid] ?? {};
|
||||
|
||||
let entry = ssid_cache[addr];
|
||||
if (entry)
|
||||
entry.timeout = time() + timeout;
|
||||
|
||||
printf(`Get cache entry ssid=${ssid} addr=${addr}: ${entry}\n`);
|
||||
return entry;
|
||||
}
|
||||
|
||||
function sta_cache_entry_add(ssid, addr, key) {
|
||||
cache[ssid] ??= {};
|
||||
let ssid_cache = cache[ssid];
|
||||
let ssid_data = ssids[ssid];
|
||||
let keydata = ssid_data.keys[key];
|
||||
|
||||
let cache_data = {
|
||||
timeout: time() + timeout,
|
||||
ssid, key,
|
||||
data: keydata ?? {},
|
||||
};
|
||||
ssid_cache[addr] = cache_data;
|
||||
printf(`Added cache entry ssid=${ssid} addr=${addr}\n`);
|
||||
return cache_data;
|
||||
}
|
||||
|
||||
function ssid_psk(ssid, addr) {
|
||||
ssid = ssids[ssid];
|
||||
if (!ssid)
|
||||
return [];
|
||||
|
||||
let specific = [];
|
||||
let rest = [];
|
||||
for (let k, v in ssid.keys)
|
||||
if (v.mac == addr)
|
||||
push(specific, k);
|
||||
else if (!v.mac)
|
||||
push(rest, k);
|
||||
|
||||
if (length(specific))
|
||||
return specific;
|
||||
|
||||
return rest;
|
||||
}
|
||||
|
||||
function sta_auth_psk(ifname, addr) {
|
||||
let ssid = iface_ssid(ifname);
|
||||
if (!ssid)
|
||||
return;
|
||||
|
||||
if (interfaces[ifname]?.band == '6g') {
|
||||
let cache = sta_cache_entry_get(ssid, addr);
|
||||
if (cache)
|
||||
return [ cache.key ];
|
||||
} else if (cache[ssid]) {
|
||||
delete cache[ssid][addr];
|
||||
}
|
||||
|
||||
return ssid_psk(ssid, addr);
|
||||
}
|
||||
|
||||
function sta_auth_cache(ifname, addr, idx, phrase) {
|
||||
let ssid = iface_ssid(ifname);
|
||||
if (!ssid)
|
||||
return;
|
||||
|
||||
let cache = sta_cache_entry_get(ssid, addr);
|
||||
if (cache)
|
||||
return cache.data;
|
||||
|
||||
let psk = ssid_psk(ssid, addr);
|
||||
if (!psk)
|
||||
return;
|
||||
|
||||
psk = psk[idx];
|
||||
if (!psk)
|
||||
psk = phrase;
|
||||
|
||||
if (!psk)
|
||||
return;
|
||||
|
||||
cache = sta_cache_entry_add(ssid, addr, psk);
|
||||
if (!cache)
|
||||
return;
|
||||
|
||||
let ssid_data = ssids[ssid];
|
||||
if (!ssid_data)
|
||||
return cache.data;
|
||||
|
||||
let target_ifname = ssid_data.bands['6g'];
|
||||
if (!target_ifname)
|
||||
return cache.data;
|
||||
|
||||
let target_iface = interfaces[target_ifname];
|
||||
if (!target_iface)
|
||||
return cache.data;
|
||||
|
||||
cache.timer = uloop.timer(30 * 1000, () => {
|
||||
let msg = {
|
||||
addr,
|
||||
disassociation_imminent: false,
|
||||
neighbors: [
|
||||
target_iface.nr
|
||||
],
|
||||
abridged: false,
|
||||
};
|
||||
printf(`ubus call hostapd.${ifname} bss_transition_request '${msg}'\n`);
|
||||
ubus.call('hostapd.' + ifname, 'bss_transition_request', msg);
|
||||
delete cache.timer;
|
||||
});
|
||||
|
||||
return cache.data;
|
||||
}
|
||||
|
||||
function auth_cb(msg) {
|
||||
let data = msg.data;
|
||||
|
||||
printf(`Event ${msg.type}: ${msg.data}\n`);
|
||||
switch (msg.type) {
|
||||
case 'sta_auth':
|
||||
if (!is_ssid_mpsk(data.iface))
|
||||
return;
|
||||
|
||||
return {
|
||||
psk: sta_auth_psk(data.iface, data.sta),
|
||||
force_psk: true,
|
||||
};
|
||||
case 'sta_connected':
|
||||
if (data.psk_idx == null || !is_ssid_mpsk(data.iface))
|
||||
return;
|
||||
return sta_auth_cache(data.iface, data.sta, data.psk_idx, data.psk);
|
||||
case 'reload':
|
||||
netifd_reload();
|
||||
reload_timer.set(5000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let ubus_methods = {
|
||||
state: {
|
||||
call: function(req) {
|
||||
return {
|
||||
interfaces,
|
||||
ssids,
|
||||
cache,
|
||||
};
|
||||
},
|
||||
args: {
|
||||
}
|
||||
},
|
||||
flush: {
|
||||
call: function() {
|
||||
for (let ssid, data in ssids) {
|
||||
let band = '6g';
|
||||
let iface = data.bands[band];
|
||||
if (!iface)
|
||||
continue;
|
||||
let clients = ubus.call('hostapd.' + iface, 'get_clients');
|
||||
for (let addr, client in clients.clients) {
|
||||
if (!cache[ssid])
|
||||
continue;
|
||||
delete cache[ssid][addr];
|
||||
ubus.call('hostapd.' + iface, 'del_client', { addr });
|
||||
}
|
||||
}
|
||||
},
|
||||
args: {}
|
||||
},
|
||||
};
|
||||
|
||||
reload_timer = uloop.timer(-1, () => { netifd_reload(); });
|
||||
gc_timer = uloop.timer(1000, () => { gc_timer.set(30 * 1000); cache_gc(); });
|
||||
ubus.publish('mpsk', ubus_methods);
|
||||
let sub = ubus.subscriber(auth_cb);
|
||||
let listener = ubus.listener('ubus.object.add', (event, msg) => {
|
||||
if (msg.path == 'hostapd-auth')
|
||||
sub.subscribe(msg.path);
|
||||
});
|
||||
sub.subscribe('hostapd-auth');
|
||||
netifd_reload();
|
||||
uloop.run();
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=19
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=mpskd
|
||||
|
||||
start_service() {
|
||||
procd_open_instance mpskd
|
||||
procd_set_param command /usr/share/hostap/mpskd
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
@@ -14,6 +14,6 @@
|
||||
"methods": [ "request" ]
|
||||
}
|
||||
},
|
||||
"publish": [ "hostapd", "hostapd.*", "wpa_supplicant", "wpa_supplicant.*", "hostapd-auth" ],
|
||||
"publish": [ "hostapd", "hostapd.*", "wpa_supplicant", "wpa_supplicant.*" ],
|
||||
"send": [ "bss.*", "wps_credentials" ]
|
||||
}
|
||||
|
||||
@@ -585,146 +585,37 @@
|
||||
.send_mlme = driver_nl80211_send_mlme,
|
||||
.get_hw_feature_data = nl80211_get_hw_feature_data,
|
||||
.sta_add = wpa_driver_nl80211_sta_add,
|
||||
--- a/src/ap/ieee802_11.c
|
||||
+++ b/src/ap/ieee802_11.c
|
||||
@@ -494,11 +494,17 @@ static const char * sae_get_password(str
|
||||
struct sae_pt **s_pt,
|
||||
const struct sae_pk **s_pk)
|
||||
{
|
||||
+ struct hostapd_bss_config *conf = hapd->conf;
|
||||
+ struct hostapd_ssid *ssid = &conf->ssid;
|
||||
+ struct hostapd_sta_wpa_psk_short *psk;
|
||||
const char *password = NULL;
|
||||
- struct sae_password_entry *pw;
|
||||
+ struct sae_password_entry *pw = NULL;
|
||||
struct sae_pt *pt = NULL;
|
||||
const struct sae_pk *pk = NULL;
|
||||
--- a/src/ap/ucode.c
|
||||
+++ b/src/ap/ucode.c
|
||||
@@ -255,6 +255,7 @@ uc_hostapd_bss_set_config(uc_vm_t *vm, s
|
||||
|
||||
+ if (sta && sta->use_sta_psk)
|
||||
+ goto use_sta_psk;
|
||||
+
|
||||
for (pw = hapd->conf->sae_passwords; pw; pw = pw->next) {
|
||||
if (!is_broadcast_ether_addr(pw->peer_addr) &&
|
||||
os_memcmp(pw->peer_addr, sta->addr, ETH_ALEN) != 0)
|
||||
@@ -519,6 +525,33 @@ static const char * sae_get_password(str
|
||||
pt = hapd->conf->ssid.pt;
|
||||
hostapd_setup_bss(hapd, hapd == iface->bss[0], true);
|
||||
hostapd_ucode_update_interfaces();
|
||||
+ hostapd_owe_update_trans(iface);
|
||||
|
||||
done:
|
||||
ret = 0;
|
||||
@@ -375,6 +376,7 @@ uc_hostapd_iface_add_bss(uc_vm_t *vm, si
|
||||
conf->bss[idx] = NULL;
|
||||
ret = hostapd_ucode_bss_get_uval(hapd);
|
||||
hostapd_ucode_update_interfaces();
|
||||
+ hostapd_owe_update_trans(iface);
|
||||
goto out;
|
||||
|
||||
deinit_ctrl:
|
||||
@@ -602,6 +604,7 @@ out:
|
||||
|
||||
ieee802_11_set_beacon(hapd);
|
||||
}
|
||||
+ hostapd_owe_update_trans(iface);
|
||||
|
||||
+use_sta_psk:
|
||||
+ if (!password && sta) {
|
||||
+ sta->psk_idx = 0;
|
||||
+ for (psk = sta->psk; psk; psk = psk->next) {
|
||||
+ if (!psk->is_passphrase)
|
||||
+ continue;
|
||||
+
|
||||
+ password = psk->passphrase;
|
||||
+ if (!sta->use_sta_psk)
|
||||
+ break;
|
||||
+
|
||||
+ sta->psk_idx = 1;
|
||||
+ if (sta->sae_pt) {
|
||||
+ pt = sta->sae_pt;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ pt = sae_derive_pt(conf->sae_groups, ssid->ssid,
|
||||
+ ssid->ssid_len,
|
||||
+ (const u8 *) password,
|
||||
+ os_strlen(password),
|
||||
+ NULL);
|
||||
+ sta->sae_pt = pt;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (pw_entry)
|
||||
*pw_entry = pw;
|
||||
if (s_pt)
|
||||
@@ -3698,6 +3731,12 @@ static void handle_auth(struct hostapd_d
|
||||
goto fail;
|
||||
}
|
||||
|
||||
+ res = hostapd_ucode_sta_auth(hapd, sta);
|
||||
+ if (res) {
|
||||
+ resp = res;
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
sta->flags &= ~WLAN_STA_PREAUTH;
|
||||
ieee802_1x_notify_pre_auth(sta->eapol_sm, 0);
|
||||
|
||||
--- a/src/ap/sta_info.c
|
||||
+++ b/src/ap/sta_info.c
|
||||
@@ -412,6 +412,9 @@ void ap_free_sta(struct hostapd_data *ha
|
||||
os_free(sta->sae_postponed_commit);
|
||||
#endif /* CONFIG_TESTING_OPTIONS */
|
||||
|
||||
+ if (sta->sae_pt)
|
||||
+ sae_deinit_pt(sta->sae_pt);
|
||||
+
|
||||
os_free(sta);
|
||||
return ucv_boolean_new(true);
|
||||
}
|
||||
@@ -693,6 +696,7 @@ uc_hostapd_bss_rename(uc_vm_t *vm, size_
|
||||
hostapd_ubus_add_bss(hapd);
|
||||
|
||||
@@ -1280,6 +1283,8 @@ void ap_sta_set_authorized(struct hostap
|
||||
else
|
||||
sta->flags &= ~WLAN_STA_AUTHORIZED;
|
||||
|
||||
+ if (authorized)
|
||||
+ hostapd_ucode_sta_connected(hapd, sta);
|
||||
#ifdef CONFIG_P2P
|
||||
if (hapd->p2p_group == NULL) {
|
||||
if (sta->p2p_ie != NULL &&
|
||||
--- a/src/ap/sta_info.h
|
||||
+++ b/src/ap/sta_info.h
|
||||
@@ -201,6 +201,9 @@ struct sta_info {
|
||||
int vlan_id_bound; /* updated by ap_sta_bind_vlan() */
|
||||
/* PSKs from RADIUS authentication server */
|
||||
struct hostapd_sta_wpa_psk_short *psk;
|
||||
+ struct sae_pt *sae_pt;
|
||||
+ int use_sta_psk;
|
||||
+ int psk_idx;
|
||||
|
||||
char *identity; /* User-Name from RADIUS */
|
||||
char *radius_cui; /* Chargeable-User-Identity from RADIUS */
|
||||
--- a/src/ap/wpa_auth_glue.c
|
||||
+++ b/src/ap/wpa_auth_glue.c
|
||||
@@ -355,6 +355,7 @@ static const u8 * hostapd_wpa_auth_get_p
|
||||
}
|
||||
#endif /* CONFIG_SAE */
|
||||
|
||||
+ sta->psk_idx = 0;
|
||||
#ifdef CONFIG_OWE
|
||||
if ((hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_OWE) &&
|
||||
sta && sta->owe_pmk) {
|
||||
@@ -381,12 +382,17 @@ static const u8 * hostapd_wpa_auth_get_p
|
||||
* returned psk which should not be returned again.
|
||||
* logic list (all hostapd_get_psk; all sta->psk)
|
||||
*/
|
||||
+ if (sta && sta->use_sta_psk)
|
||||
+ psk = NULL;
|
||||
if (sta && sta->psk && !psk) {
|
||||
struct hostapd_sta_wpa_psk_short *pos;
|
||||
+ int psk_idx = 1;
|
||||
|
||||
if (vlan_id)
|
||||
*vlan_id = 0;
|
||||
psk = sta->psk->psk;
|
||||
+ if (vlan_id)
|
||||
+ sta->psk_idx = psk_idx;
|
||||
for (pos = sta->psk; pos; pos = pos->next) {
|
||||
if (pos->is_passphrase) {
|
||||
pbkdf2_sha1(pos->passphrase,
|
||||
@@ -397,9 +403,13 @@ static const u8 * hostapd_wpa_auth_get_p
|
||||
}
|
||||
if (pos->psk == prev_psk) {
|
||||
psk = pos->next ? pos->next->psk : NULL;
|
||||
+ if (vlan_id)
|
||||
+ sta->psk_idx = psk_idx + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
+ if (vlan_id && !psk)
|
||||
+ sta->psk_idx = 0;
|
||||
}
|
||||
return psk;
|
||||
}
|
||||
hostapd_ucode_update_interfaces();
|
||||
+ hostapd_owe_update_trans(hapd->iface);
|
||||
out:
|
||||
if (interfaces->ctrl_iface_init)
|
||||
interfaces->ctrl_iface_init(hapd);
|
||||
|
||||
@@ -1,552 +0,0 @@
|
||||
--- a/src/ap/wpa_auth.h
|
||||
+++ b/src/ap/wpa_auth.h
|
||||
@@ -15,6 +15,10 @@
|
||||
#include "common/ieee802_11_defs.h"
|
||||
|
||||
struct vlan_description;
|
||||
+struct rate_description {
|
||||
+ u32 rx;
|
||||
+ u32 tx;
|
||||
+};
|
||||
|
||||
#define MAX_OWN_IE_OVERRIDE 256
|
||||
|
||||
@@ -87,6 +91,7 @@ struct ft_rrb_frame {
|
||||
#define FT_RRB_IDENTITY 15
|
||||
#define FT_RRB_RADIUS_CUI 16
|
||||
#define FT_RRB_SESSION_TIMEOUT 17 /* le32 seconds */
|
||||
+#define FT_RRB_RATE_LIMIT 18
|
||||
|
||||
struct ft_rrb_tlv {
|
||||
le16 type;
|
||||
@@ -327,6 +332,10 @@ struct wpa_auth_callbacks {
|
||||
struct vlan_description *vlan);
|
||||
int (*get_vlan)(void *ctx, const u8 *sta_addr,
|
||||
struct vlan_description *vlan);
|
||||
+ int (*set_rate_limit)(void *ctx, const u8 *sta_addr,
|
||||
+ struct rate_description *rate);
|
||||
+ int (*get_rate_limit)(void *ctx, const u8 *sta_addr,
|
||||
+ struct rate_description *rate);
|
||||
int (*set_identity)(void *ctx, const u8 *sta_addr,
|
||||
const u8 *identity, size_t identity_len);
|
||||
size_t (*get_identity)(void *ctx, const u8 *sta_addr, const u8 **buf);
|
||||
@@ -479,7 +488,7 @@ int wpa_ft_fetch_pmk_r1(struct wpa_authe
|
||||
struct vlan_description *vlan,
|
||||
const u8 **identity, size_t *identity_len,
|
||||
const u8 **radius_cui, size_t *radius_cui_len,
|
||||
- int *session_timeout);
|
||||
+ int *session_timeout, struct rate_description *rate);
|
||||
|
||||
#endif /* CONFIG_IEEE80211R_AP */
|
||||
|
||||
--- a/src/ap/wpa_auth_glue.c
|
||||
+++ b/src/ap/wpa_auth_glue.c
|
||||
@@ -1172,6 +1172,40 @@ static int hostapd_wpa_auth_get_vlan(voi
|
||||
}
|
||||
|
||||
|
||||
+static int hostapd_wpa_auth_set_rate_limit(void *ctx, const u8 *sta_addr,
|
||||
+ struct rate_description *rate)
|
||||
+{
|
||||
+ struct hostapd_data *hapd = ctx;
|
||||
+ struct sta_info *sta;
|
||||
+
|
||||
+ sta = ap_get_sta(hapd, sta_addr);
|
||||
+ if (!sta || !sta->wpa_sm)
|
||||
+ return -1;
|
||||
+
|
||||
+ memcpy(sta->bandwidth, rate, sizeof(*rate));
|
||||
+ hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
|
||||
+ HOSTAPD_LEVEL_INFO, "rate-limit %d %d", sta->bandwidth[0], sta->bandwidth[1]);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int hostapd_wpa_auth_get_rate_limit(void *ctx, const u8 *sta_addr,
|
||||
+ struct rate_description *rate)
|
||||
+{
|
||||
+ struct hostapd_data *hapd = ctx;
|
||||
+ struct sta_info *sta;
|
||||
+
|
||||
+ sta = ap_get_sta(hapd, sta_addr);
|
||||
+ if (!sta)
|
||||
+ return -1;
|
||||
+
|
||||
+ memcpy(rate, sta->bandwidth, sizeof(*rate));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
static int
|
||||
hostapd_wpa_auth_set_identity(void *ctx, const u8 *sta_addr,
|
||||
const u8 *identity, size_t identity_len)
|
||||
@@ -1490,6 +1524,8 @@ int hostapd_setup_wpa(struct hostapd_dat
|
||||
.add_tspec = hostapd_wpa_auth_add_tspec,
|
||||
.set_vlan = hostapd_wpa_auth_set_vlan,
|
||||
.get_vlan = hostapd_wpa_auth_get_vlan,
|
||||
+ .set_rate_limit = hostapd_wpa_auth_set_rate_limit,
|
||||
+ .get_rate_limit = hostapd_wpa_auth_get_rate_limit,
|
||||
.set_identity = hostapd_wpa_auth_set_identity,
|
||||
.get_identity = hostapd_wpa_auth_get_identity,
|
||||
.set_radius_cui = hostapd_wpa_auth_set_radius_cui,
|
||||
--- a/src/ap/ieee802_11.c
|
||||
+++ b/src/ap/ieee802_11.c
|
||||
@@ -3215,7 +3215,7 @@ static void handle_auth_pasn_1(struct ho
|
||||
rsn_data.pmkid,
|
||||
pmk_r1, &pmk_r1_len, NULL,
|
||||
NULL, NULL, NULL,
|
||||
- NULL, NULL, NULL);
|
||||
+ NULL, NULL, NULL, NULL);
|
||||
if (ret) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"PASN: FT: Failed getting PMK-R1");
|
||||
--- a/src/ap/wpa_auth_ft.c
|
||||
+++ b/src/ap/wpa_auth_ft.c
|
||||
@@ -375,6 +375,14 @@ static size_t wpa_ft_vlan_len(const stru
|
||||
return tlv_len;
|
||||
}
|
||||
|
||||
+static size_t wpa_ft_rate_limit_len(const struct rate_description *rate)
|
||||
+{
|
||||
+ if (!rate || (!rate->rx && !rate->tx))
|
||||
+ return 0;
|
||||
+
|
||||
+ return (sizeof(struct ft_rrb_tlv) + 8);
|
||||
+}
|
||||
+
|
||||
|
||||
static size_t wpa_ft_vlan_lin(const struct vlan_description *vlan,
|
||||
u8 *start, u8 *endpos)
|
||||
@@ -430,10 +438,48 @@ static size_t wpa_ft_vlan_lin(const stru
|
||||
}
|
||||
|
||||
|
||||
+static size_t wpa_ft_rate_limit_lin(const struct rate_description *rate,
|
||||
+ u8 *start, u8 *endpos)
|
||||
+{
|
||||
+ size_t tlv_len;
|
||||
+ int i, len;
|
||||
+ struct ft_rrb_tlv *hdr;
|
||||
+ u8 *pos = start;
|
||||
+
|
||||
+ if (!rate)
|
||||
+ return 0;
|
||||
+
|
||||
+ tlv_len = 0;
|
||||
+ if (rate->rx || rate->tx) {
|
||||
+ tlv_len += sizeof(*hdr);
|
||||
+ if (start + tlv_len > endpos)
|
||||
+ return tlv_len;
|
||||
+ hdr = (struct ft_rrb_tlv *) pos;
|
||||
+ hdr->type = host_to_le16(FT_RRB_RATE_LIMIT);
|
||||
+ hdr->len = host_to_le16(2 * sizeof(le32));
|
||||
+ pos = start + tlv_len;
|
||||
+
|
||||
+ tlv_len += sizeof(u32);
|
||||
+ if (start + tlv_len > endpos)
|
||||
+ return tlv_len;
|
||||
+ WPA_PUT_LE32(pos, rate->rx);
|
||||
+ pos = start + tlv_len;
|
||||
+ tlv_len += sizeof(u32);
|
||||
+ if (start + tlv_len > endpos)
|
||||
+ return tlv_len;
|
||||
+ WPA_PUT_LE32(pos, rate->tx);
|
||||
+ pos = start + tlv_len;
|
||||
+ }
|
||||
+
|
||||
+ return tlv_len;
|
||||
+}
|
||||
+
|
||||
+
|
||||
static int wpa_ft_rrb_lin(const struct tlv_list *tlvs1,
|
||||
const struct tlv_list *tlvs2,
|
||||
const struct vlan_description *vlan,
|
||||
- u8 **plain, size_t *plain_len)
|
||||
+ u8 **plain, size_t *plain_len,
|
||||
+ const struct rate_description *rate)
|
||||
{
|
||||
u8 *pos, *endpos;
|
||||
size_t tlv_len;
|
||||
@@ -441,6 +487,7 @@ static int wpa_ft_rrb_lin(const struct t
|
||||
tlv_len = wpa_ft_tlv_len(tlvs1);
|
||||
tlv_len += wpa_ft_tlv_len(tlvs2);
|
||||
tlv_len += wpa_ft_vlan_len(vlan);
|
||||
+ tlv_len += wpa_ft_rate_limit_len(rate);
|
||||
|
||||
*plain_len = tlv_len;
|
||||
*plain = os_zalloc(tlv_len);
|
||||
@@ -454,6 +501,7 @@ static int wpa_ft_rrb_lin(const struct t
|
||||
pos += wpa_ft_tlv_lin(tlvs1, pos, endpos);
|
||||
pos += wpa_ft_tlv_lin(tlvs2, pos, endpos);
|
||||
pos += wpa_ft_vlan_lin(vlan, pos, endpos);
|
||||
+ pos += wpa_ft_rate_limit_lin(rate, pos, endpos);
|
||||
|
||||
/* sanity check */
|
||||
if (pos != endpos) {
|
||||
@@ -522,7 +570,8 @@ static int wpa_ft_rrb_build(const u8 *ke
|
||||
const struct tlv_list *tlvs_auth,
|
||||
const struct vlan_description *vlan,
|
||||
const u8 *src_addr, u8 type,
|
||||
- u8 **packet, size_t *packet_len)
|
||||
+ u8 **packet, size_t *packet_len,
|
||||
+ const struct rate_description *rate)
|
||||
{
|
||||
u8 *plain = NULL, *auth = NULL, *pos, *tmp;
|
||||
size_t plain_len = 0, auth_len = 0;
|
||||
@@ -530,10 +579,10 @@ static int wpa_ft_rrb_build(const u8 *ke
|
||||
size_t pad_len = 0;
|
||||
|
||||
*packet = NULL;
|
||||
- if (wpa_ft_rrb_lin(tlvs_enc0, tlvs_enc1, vlan, &plain, &plain_len) < 0)
|
||||
+ if (wpa_ft_rrb_lin(tlvs_enc0, tlvs_enc1, vlan, &plain, &plain_len, rate) < 0)
|
||||
goto out;
|
||||
|
||||
- if (wpa_ft_rrb_lin(tlvs_auth, NULL, NULL, &auth, &auth_len) < 0)
|
||||
+ if (wpa_ft_rrb_lin(tlvs_auth, NULL, NULL, &auth, &auth_len, NULL) < 0)
|
||||
goto out;
|
||||
|
||||
*packet_len = sizeof(u16) + auth_len + plain_len;
|
||||
@@ -696,6 +745,24 @@ static int wpa_ft_get_vlan(struct wpa_au
|
||||
}
|
||||
|
||||
|
||||
+static int wpa_ft_get_rate_limit(struct wpa_authenticator *wpa_auth,
|
||||
+ const u8 *sta_addr, struct rate_description *rate)
|
||||
+{
|
||||
+ if (!wpa_auth->cb->get_rate_limit)
|
||||
+ return -1;
|
||||
+ return wpa_auth->cb->get_rate_limit(wpa_auth->cb_ctx, sta_addr, rate);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int wpa_ft_set_rate_limit(struct wpa_authenticator *wpa_auth,
|
||||
+ const u8 *sta_addr, struct rate_description *rate)
|
||||
+{
|
||||
+ if (!wpa_auth->cb->set_rate_limit)
|
||||
+ return -1;
|
||||
+ return wpa_auth->cb->set_rate_limit(wpa_auth->cb_ctx, sta_addr, rate);
|
||||
+}
|
||||
+
|
||||
+
|
||||
static int
|
||||
wpa_ft_set_identity(struct wpa_authenticator *wpa_auth, const u8 *sta_addr,
|
||||
const u8 *identity, size_t identity_len)
|
||||
@@ -991,7 +1058,7 @@ wpa_ft_rrb_seq_req(struct wpa_authentica
|
||||
|
||||
if (wpa_ft_rrb_build(key, key_len, NULL, NULL, seq_req_auth, NULL,
|
||||
wpa_auth->addr, FT_PACKET_R0KH_R1KH_SEQ_REQ,
|
||||
- &packet, &packet_len) < 0) {
|
||||
+ &packet, &packet_len, NULL) < 0) {
|
||||
item = NULL; /* some other seq resp might still accept this */
|
||||
goto err;
|
||||
}
|
||||
@@ -1174,6 +1241,7 @@ struct wpa_ft_pmk_r0_sa {
|
||||
u8 spa[ETH_ALEN];
|
||||
int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
|
||||
struct vlan_description *vlan;
|
||||
+ struct rate_description *rate;
|
||||
os_time_t expiration; /* 0 for no expiration */
|
||||
u8 *identity;
|
||||
size_t identity_len;
|
||||
@@ -1192,6 +1260,7 @@ struct wpa_ft_pmk_r1_sa {
|
||||
u8 spa[ETH_ALEN];
|
||||
int pairwise; /* Pairwise cipher suite, WPA_CIPHER_* */
|
||||
struct vlan_description *vlan;
|
||||
+ struct rate_description *rate;
|
||||
u8 *identity;
|
||||
size_t identity_len;
|
||||
u8 *radius_cui;
|
||||
@@ -1220,6 +1289,7 @@ static void wpa_ft_free_pmk_r0(struct wp
|
||||
|
||||
os_memset(r0->pmk_r0, 0, PMK_LEN_MAX);
|
||||
os_free(r0->vlan);
|
||||
+ os_free(r0->rate);
|
||||
os_free(r0->identity);
|
||||
os_free(r0->radius_cui);
|
||||
os_free(r0);
|
||||
@@ -1273,6 +1343,7 @@ static void wpa_ft_free_pmk_r1(struct wp
|
||||
eloop_cancel_timeout(wpa_ft_expire_pmk_r1, r1, NULL);
|
||||
|
||||
os_memset(r1->pmk_r1, 0, PMK_LEN_MAX);
|
||||
+ os_free(r1->rate);
|
||||
os_free(r1->vlan);
|
||||
os_free(r1->identity);
|
||||
os_free(r1->radius_cui);
|
||||
@@ -1326,7 +1397,8 @@ static int wpa_ft_store_pmk_r0(struct wp
|
||||
const struct vlan_description *vlan,
|
||||
int expires_in, int session_timeout,
|
||||
const u8 *identity, size_t identity_len,
|
||||
- const u8 *radius_cui, size_t radius_cui_len)
|
||||
+ const u8 *radius_cui, size_t radius_cui_len,
|
||||
+ struct rate_description *rate)
|
||||
{
|
||||
struct wpa_ft_pmk_cache *cache = wpa_auth->ft_pmk_cache;
|
||||
struct wpa_ft_pmk_r0_sa *r0;
|
||||
@@ -1354,6 +1426,14 @@ static int wpa_ft_store_pmk_r0(struct wp
|
||||
}
|
||||
*r0->vlan = *vlan;
|
||||
}
|
||||
+ if (rate) {
|
||||
+ r0->rate = os_zalloc(sizeof(*rate));
|
||||
+ if (!r0->rate) {
|
||||
+ bin_clear_free(r0, sizeof(*r0));
|
||||
+ return -1;
|
||||
+ }
|
||||
+ *r0->rate = *rate;
|
||||
+ }
|
||||
if (identity) {
|
||||
r0->identity = os_malloc(identity_len);
|
||||
if (r0->identity) {
|
||||
@@ -1413,7 +1493,8 @@ static int wpa_ft_store_pmk_r1(struct wp
|
||||
const struct vlan_description *vlan,
|
||||
int expires_in, int session_timeout,
|
||||
const u8 *identity, size_t identity_len,
|
||||
- const u8 *radius_cui, size_t radius_cui_len)
|
||||
+ const u8 *radius_cui, size_t radius_cui_len,
|
||||
+ struct rate_description *rate)
|
||||
{
|
||||
struct wpa_ft_pmk_cache *cache = wpa_auth->ft_pmk_cache;
|
||||
int max_expires_in = wpa_auth->conf.r1_max_key_lifetime;
|
||||
@@ -1443,6 +1524,14 @@ static int wpa_ft_store_pmk_r1(struct wp
|
||||
}
|
||||
*r1->vlan = *vlan;
|
||||
}
|
||||
+ if (rate) {
|
||||
+ r1->rate = os_zalloc(sizeof(*rate));
|
||||
+ if (!r1->rate) {
|
||||
+ bin_clear_free(r1, sizeof(*r1));
|
||||
+ return -1;
|
||||
+ }
|
||||
+ *r1->rate = *rate;
|
||||
+ }
|
||||
if (identity) {
|
||||
r1->identity = os_malloc(identity_len);
|
||||
if (r1->identity) {
|
||||
@@ -1479,7 +1568,7 @@ int wpa_ft_fetch_pmk_r1(struct wpa_authe
|
||||
struct vlan_description *vlan,
|
||||
const u8 **identity, size_t *identity_len,
|
||||
const u8 **radius_cui, size_t *radius_cui_len,
|
||||
- int *session_timeout)
|
||||
+ int *session_timeout, struct rate_description *rate)
|
||||
{
|
||||
struct wpa_ft_pmk_cache *cache = wpa_auth->ft_pmk_cache;
|
||||
struct wpa_ft_pmk_r1_sa *r1;
|
||||
@@ -1499,6 +1588,12 @@ int wpa_ft_fetch_pmk_r1(struct wpa_authe
|
||||
*vlan = *r1->vlan;
|
||||
if (vlan && !r1->vlan)
|
||||
os_memset(vlan, 0, sizeof(*vlan));
|
||||
+ if (rate) {
|
||||
+ if (r1->rate)
|
||||
+ *rate = *r1->rate;
|
||||
+ else
|
||||
+ memset(rate, 0, sizeof(*rate));
|
||||
+ }
|
||||
if (identity && identity_len) {
|
||||
*identity = r1->identity;
|
||||
*identity_len = r1->identity_len;
|
||||
@@ -2025,7 +2120,7 @@ static int wpa_ft_pull_pmk_r1(struct wpa
|
||||
|
||||
if (wpa_ft_rrb_build(key, key_len, req_enc, NULL, req_auth, NULL,
|
||||
sm->wpa_auth->addr, FT_PACKET_R0KH_R1KH_PULL,
|
||||
- &packet, &packet_len) < 0)
|
||||
+ &packet, &packet_len, NULL) < 0)
|
||||
return -1;
|
||||
|
||||
ft_pending_req_ies = wpabuf_alloc_copy(ies, ies_len);
|
||||
@@ -2054,6 +2149,7 @@ int wpa_ft_store_pmk_fils(struct wpa_sta
|
||||
{
|
||||
int expires_in = sm->wpa_auth->conf.r0_key_lifetime;
|
||||
struct vlan_description vlan;
|
||||
+ struct rate_description rate;
|
||||
const u8 *identity, *radius_cui;
|
||||
size_t identity_len, radius_cui_len;
|
||||
int session_timeout;
|
||||
@@ -2065,6 +2161,7 @@ int wpa_ft_store_pmk_fils(struct wpa_sta
|
||||
MAC2STR(sm->addr));
|
||||
return -1;
|
||||
}
|
||||
+ wpa_ft_get_rate_limit(sm->wpa_auth, sm->addr, &rate);
|
||||
|
||||
identity_len = wpa_ft_get_identity(sm->wpa_auth, sm->addr, &identity);
|
||||
radius_cui_len = wpa_ft_get_radius_cui(sm->wpa_auth, sm->addr,
|
||||
@@ -2074,7 +2171,7 @@ int wpa_ft_store_pmk_fils(struct wpa_sta
|
||||
return wpa_ft_store_pmk_r0(sm->wpa_auth, sm->addr, pmk_r0, pmk_r0_len,
|
||||
pmk_r0_name, sm->pairwise, &vlan, expires_in,
|
||||
session_timeout, identity, identity_len,
|
||||
- radius_cui, radius_cui_len);
|
||||
+ radius_cui, radius_cui_len, &rate);
|
||||
}
|
||||
|
||||
|
||||
@@ -2095,6 +2192,7 @@ int wpa_auth_derive_ptk_ft(struct wpa_st
|
||||
int psk_local = sm->wpa_auth->conf.ft_psk_generate_local;
|
||||
int expires_in = sm->wpa_auth->conf.r0_key_lifetime;
|
||||
struct vlan_description vlan;
|
||||
+ struct rate_description rate;
|
||||
const u8 *identity, *radius_cui;
|
||||
size_t identity_len, radius_cui_len;
|
||||
int session_timeout;
|
||||
@@ -2119,6 +2217,8 @@ int wpa_auth_derive_ptk_ft(struct wpa_st
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ wpa_ft_get_rate_limit(sm->wpa_auth, sm->addr, &rate);
|
||||
+
|
||||
identity_len = wpa_ft_get_identity(sm->wpa_auth, sm->addr, &identity);
|
||||
radius_cui_len = wpa_ft_get_radius_cui(sm->wpa_auth, sm->addr,
|
||||
&radius_cui);
|
||||
@@ -2134,7 +2234,7 @@ int wpa_auth_derive_ptk_ft(struct wpa_st
|
||||
pmk_r0_name,
|
||||
sm->pairwise, &vlan, expires_in,
|
||||
session_timeout, identity, identity_len,
|
||||
- radius_cui, radius_cui_len);
|
||||
+ radius_cui, radius_cui_len, &rate);
|
||||
|
||||
if (wpa_derive_pmk_r1(pmk_r0, pmk_r0_len, pmk_r0_name, r1kh, sm->addr,
|
||||
pmk_r1, sm->pmk_r1_name) < 0)
|
||||
@@ -2143,7 +2243,8 @@ int wpa_auth_derive_ptk_ft(struct wpa_st
|
||||
wpa_ft_store_pmk_r1(sm->wpa_auth, sm->addr, pmk_r1, pmk_r1_len,
|
||||
sm->pmk_r1_name, sm->pairwise, &vlan,
|
||||
expires_in, session_timeout, identity,
|
||||
- identity_len, radius_cui, radius_cui_len);
|
||||
+ identity_len, radius_cui, radius_cui_len,
|
||||
+ &rate);
|
||||
|
||||
return wpa_pmk_r1_to_ptk(pmk_r1, pmk_r1_len, sm->SNonce, sm->ANonce,
|
||||
sm->addr, sm->wpa_auth->addr, sm->pmk_r1_name,
|
||||
@@ -2986,7 +3087,8 @@ static int wpa_ft_local_derive_pmk_r1(st
|
||||
const u8 **identity, size_t *identity_len,
|
||||
const u8 **radius_cui,
|
||||
size_t *radius_cui_len,
|
||||
- int *out_session_timeout)
|
||||
+ int *out_session_timeout,
|
||||
+ struct rate_description *rate)
|
||||
{
|
||||
struct wpa_auth_config *conf = &wpa_auth->conf;
|
||||
const struct wpa_ft_pmk_r0_sa *r0;
|
||||
@@ -3023,7 +3125,8 @@ static int wpa_ft_local_derive_pmk_r1(st
|
||||
pmk_r1_name,
|
||||
sm->pairwise, r0->vlan, expires_in, session_timeout,
|
||||
r0->identity, r0->identity_len,
|
||||
- r0->radius_cui, r0->radius_cui_len);
|
||||
+ r0->radius_cui, r0->radius_cui_len,
|
||||
+ r0->rate);
|
||||
|
||||
*out_pairwise = sm->pairwise;
|
||||
if (vlan) {
|
||||
@@ -3033,6 +3136,13 @@ static int wpa_ft_local_derive_pmk_r1(st
|
||||
os_memset(vlan, 0, sizeof(*vlan));
|
||||
}
|
||||
|
||||
+ if (rate) {
|
||||
+ if (r0->rate)
|
||||
+ *rate = *r0->rate;
|
||||
+ else
|
||||
+ os_memset(rate, 0, sizeof(*rate));
|
||||
+ }
|
||||
+
|
||||
if (identity && identity_len) {
|
||||
*identity = r0->identity;
|
||||
*identity_len = r0->identity_len;
|
||||
@@ -3063,6 +3173,7 @@ static int wpa_ft_process_auth_req(struc
|
||||
u8 *pos, *end;
|
||||
int pairwise, session_timeout = 0;
|
||||
struct vlan_description vlan;
|
||||
+ struct rate_description rate = {};
|
||||
const u8 *identity, *radius_cui;
|
||||
size_t identity_len = 0, radius_cui_len = 0;
|
||||
int use_sha384;
|
||||
@@ -3152,7 +3263,7 @@ static int wpa_ft_process_auth_req(struc
|
||||
} else if (wpa_ft_fetch_pmk_r1(sm->wpa_auth, sm->addr, pmk_r1_name,
|
||||
pmk_r1, &pmk_r1_len, &pairwise, &vlan,
|
||||
&identity, &identity_len, &radius_cui,
|
||||
- &radius_cui_len, &session_timeout) < 0) {
|
||||
+ &radius_cui_len, &session_timeout, &rate) < 0) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"FT: No PMK-R1 available in local cache for the requested PMKR1Name");
|
||||
if (wpa_ft_local_derive_pmk_r1(sm->wpa_auth, sm,
|
||||
@@ -3161,7 +3272,7 @@ static int wpa_ft_process_auth_req(struc
|
||||
pmk_r1_name, pmk_r1, &pairwise,
|
||||
&vlan, &identity, &identity_len,
|
||||
&radius_cui, &radius_cui_len,
|
||||
- &session_timeout) == 0) {
|
||||
+ &session_timeout, &rate) == 0) {
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"FT: Generated PMK-R1 based on local PMK-R0");
|
||||
goto pmk_r1_derived;
|
||||
@@ -3219,6 +3330,7 @@ pmk_r1_derived:
|
||||
wpa_printf(MSG_DEBUG, "FT: Failed to configure VLAN");
|
||||
return WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||
}
|
||||
+ wpa_ft_set_rate_limit(sm->wpa_auth, sm->addr, &rate);
|
||||
if (wpa_ft_set_identity(sm->wpa_auth, sm->addr,
|
||||
identity, identity_len) < 0 ||
|
||||
wpa_ft_set_radius_cui(sm->wpa_auth, sm->addr,
|
||||
@@ -3791,7 +3903,7 @@ static int wpa_ft_rrb_build_r0(const u8
|
||||
|
||||
ret = wpa_ft_rrb_build(key, key_len, tlvs, sess_tlv, tlv_auth,
|
||||
pmk_r0->vlan, src_addr, type,
|
||||
- packet, packet_len);
|
||||
+ packet, packet_len, pmk_r0->rate);
|
||||
|
||||
forced_memzero(pmk_r1, sizeof(pmk_r1));
|
||||
|
||||
@@ -3931,7 +4043,7 @@ static int wpa_ft_rrb_rx_pull(struct wpa
|
||||
ret = wpa_ft_rrb_build(key, key_len, resp, NULL, resp_auth,
|
||||
NULL, wpa_auth->addr,
|
||||
FT_PACKET_R0KH_R1KH_RESP,
|
||||
- &packet, &packet_len);
|
||||
+ &packet, &packet_len, NULL);
|
||||
} else {
|
||||
ret = wpa_ft_rrb_build_r0(key, key_len, resp, r0, f_r1kh_id,
|
||||
f_s1kh_id, resp_auth, wpa_auth->addr,
|
||||
@@ -3983,11 +4095,15 @@ static int wpa_ft_rrb_rx_r1(struct wpa_a
|
||||
size_t f_expires_in_len;
|
||||
size_t f_identity_len, f_radius_cui_len;
|
||||
size_t f_session_timeout_len;
|
||||
+ size_t f_rate_len;
|
||||
+ const u8 *f_rate;
|
||||
int pairwise;
|
||||
int ret = -1;
|
||||
int expires_in;
|
||||
int session_timeout;
|
||||
struct vlan_description vlan;
|
||||
+ struct rate_description rate;
|
||||
+ int has_rate = 0;
|
||||
size_t pmk_r1_len;
|
||||
|
||||
RRB_GET_AUTH(FT_RRB_R0KH_ID, r0kh_id, msgtype, -1);
|
||||
@@ -4096,6 +4212,13 @@ static int wpa_ft_rrb_rx_r1(struct wpa_a
|
||||
wpa_printf(MSG_DEBUG, "FT: vlan %d%s",
|
||||
le_to_host16(vlan.untagged), vlan.tagged[0] ? "+" : "");
|
||||
|
||||
+ RRB_GET_OPTIONAL(FT_RRB_RATE_LIMIT, rate, msgtype, 2 * sizeof(le32));
|
||||
+ if (f_rate) {
|
||||
+ memcpy(&rate, f_rate, sizeof(rate));
|
||||
+ rate.rx = le_to_host32(rate.rx);
|
||||
+ rate.tx = le_to_host32(rate.tx);
|
||||
+ has_rate = 1;
|
||||
+ };
|
||||
RRB_GET_OPTIONAL(FT_RRB_IDENTITY, identity, msgtype, -1);
|
||||
if (f_identity)
|
||||
wpa_hexdump_ascii(MSG_DEBUG, "FT: Identity", f_identity,
|
||||
@@ -4118,7 +4241,7 @@ static int wpa_ft_rrb_rx_r1(struct wpa_a
|
||||
f_pmk_r1_name,
|
||||
pairwise, &vlan, expires_in, session_timeout,
|
||||
f_identity, f_identity_len, f_radius_cui,
|
||||
- f_radius_cui_len) < 0)
|
||||
+ f_radius_cui_len, has_rate ? &rate : 0) < 0)
|
||||
goto out;
|
||||
|
||||
ret = 0;
|
||||
@@ -4431,7 +4554,7 @@ static int wpa_ft_rrb_rx_seq_req(struct
|
||||
|
||||
if (wpa_ft_rrb_build(key, key_len, NULL, NULL, seq_resp_auth, NULL,
|
||||
wpa_auth->addr, FT_PACKET_R0KH_R1KH_SEQ_RESP,
|
||||
- &packet, &packet_len) < 0)
|
||||
+ &packet, &packet_len, NULL) < 0)
|
||||
goto out;
|
||||
|
||||
wpa_ft_rrb_oui_send(wpa_auth, src_addr,
|
||||
@@ -1,147 +0,0 @@
|
||||
--- a/src/ap/ieee802_11.c
|
||||
+++ b/src/ap/ieee802_11.c
|
||||
@@ -469,6 +469,7 @@ static void handle_auth_ft_finish(void *
|
||||
|
||||
hostapd_logger(hapd, dst, HOSTAPD_MODULE_IEEE80211,
|
||||
HOSTAPD_LEVEL_DEBUG, "authentication OK (FT)");
|
||||
+ hostapd_ubus_notify(hapd, "ft-finish", sta->addr);
|
||||
sta->flags |= WLAN_STA_AUTH;
|
||||
mlme_authenticate_indication(hapd, sta);
|
||||
}
|
||||
@@ -5435,6 +5436,8 @@ static void handle_assoc(struct hostapd_
|
||||
}
|
||||
|
||||
sta = ap_get_sta(hapd, mgmt->sa);
|
||||
+ if (sta && reassoc)
|
||||
+ memcpy(sta->origin_ap, mgmt->u.reassoc_req.current_ap, 6);
|
||||
#ifdef CONFIG_IEEE80211R_AP
|
||||
if (sta && sta->auth_alg == WLAN_AUTH_FT &&
|
||||
(sta->flags & WLAN_STA_AUTH) == 0) {
|
||||
@@ -5588,6 +5591,7 @@ static void handle_assoc(struct hostapd_
|
||||
.type = HOSTAPD_UBUS_ASSOC_REQ,
|
||||
.mgmt_frame = mgmt,
|
||||
.ssi_signal = rssi,
|
||||
+ .reassoc = reassoc,
|
||||
};
|
||||
|
||||
/* followed by SSID and Supported rates; and HT capabilities if 802.11n
|
||||
@@ -6414,7 +6418,7 @@ static void handle_assoc_cb(struct hosta
|
||||
* Open, static WEP, FT protocol, or FILS; no separate
|
||||
* authorization step.
|
||||
*/
|
||||
- ap_sta_set_authorized(hapd, sta, 1);
|
||||
+ _ap_sta_set_authorized(hapd, sta, 1, reassoc);
|
||||
}
|
||||
|
||||
if (reassoc)
|
||||
--- a/src/ap/ubus.c
|
||||
+++ b/src/ap/ubus.c
|
||||
@@ -1870,6 +1870,8 @@ int hostapd_ubus_handle_event(struct hos
|
||||
if (req->ssi_signal)
|
||||
blobmsg_add_u32(&b, "signal", req->ssi_signal);
|
||||
blobmsg_add_u32(&b, "freq", hapd->iface->freq);
|
||||
+ if (req->reassoc && req->mgmt_frame)
|
||||
+ blobmsg_add_macaddr(&b, "origin", req->mgmt_frame->u.reassoc_req.current_ap);
|
||||
|
||||
if (req->elems) {
|
||||
if(req->elems->ht_capabilities)
|
||||
@@ -1940,6 +1942,7 @@ void hostapd_ubus_notify(struct hostapd_
|
||||
blob_buf_init(&b, 0);
|
||||
blobmsg_add_macaddr(&b, "address", addr);
|
||||
blobmsg_add_string(&b, "ifname", hapd->conf->iface);
|
||||
+ blobmsg_printf(&b, "target", MACSTR, MAC2STR(hapd->conf->bssid));
|
||||
|
||||
ubus_notify(ctx, &hapd->ubus.obj, type, b.head, -1);
|
||||
}
|
||||
@@ -1958,7 +1961,7 @@ void hostapd_ubus_notify_csa(struct host
|
||||
}
|
||||
|
||||
|
||||
-void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta)
|
||||
+void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta, int reassoc)
|
||||
{
|
||||
if (!hapd->ubus.obj.has_subscribers)
|
||||
return;
|
||||
@@ -1975,6 +1978,9 @@ void hostapd_ubus_notify_authorized(stru
|
||||
blobmsg_add_u32(&b, "", sta->bandwidth[1]);
|
||||
blobmsg_close_array(&b, r);
|
||||
}
|
||||
+ if (reassoc)
|
||||
+ blobmsg_add_macaddr(&b, "origin", sta->origin_ap);
|
||||
+ blobmsg_printf(&b, "target", MACSTR, MAC2STR(hapd->conf->bssid));
|
||||
|
||||
ubus_notify(ctx, &hapd->ubus.obj, "sta-authorized", b.head, -1);
|
||||
}
|
||||
--- a/src/ap/ubus.h
|
||||
+++ b/src/ap/ubus.h
|
||||
@@ -22,6 +22,7 @@ struct hostapd_ubus_request {
|
||||
const struct ieee802_11_elems *elems;
|
||||
int ssi_signal; /* dBm */
|
||||
const u8 *addr;
|
||||
+ int reassoc;
|
||||
};
|
||||
|
||||
struct hostapd_iface;
|
||||
@@ -49,7 +50,7 @@ void hostapd_ubus_remove_vlan(struct hos
|
||||
|
||||
int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req);
|
||||
void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *mac);
|
||||
-void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
+void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta, int reassoc);
|
||||
void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
|
||||
const u8 *addr, u8 token, u8 rep_mode,
|
||||
struct rrm_measurement_beacon_report *rep,
|
||||
--- a/src/ap/sta_info.c
|
||||
+++ b/src/ap/sta_info.c
|
||||
@@ -1265,8 +1265,8 @@ const char * ap_sta_wpa_get_keyid(struct
|
||||
}
|
||||
|
||||
|
||||
-void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
- int authorized)
|
||||
+void _ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
+ int authorized, int reassoc)
|
||||
{
|
||||
const u8 *dev_addr = NULL;
|
||||
char buf[100];
|
||||
@@ -1346,7 +1346,7 @@ void ap_sta_set_authorized(struct hostap
|
||||
" keyid=%s", keyid);
|
||||
}
|
||||
|
||||
- hostapd_ubus_notify_authorized(hapd, sta);
|
||||
+ hostapd_ubus_notify_authorized(hapd, sta, reassoc);
|
||||
wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s%s%s",
|
||||
buf, ip_addr, keyid_buf, alg_buf);
|
||||
|
||||
@@ -1375,6 +1375,11 @@ void ap_sta_set_authorized(struct hostap
|
||||
}
|
||||
#endif /* CONFIG_FST */
|
||||
}
|
||||
+void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
+ int authorized)
|
||||
+{
|
||||
+ _ap_sta_set_authorized(hapd, sta, authorized, 0);
|
||||
+}
|
||||
|
||||
|
||||
void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
--- a/src/ap/sta_info.h
|
||||
+++ b/src/ap/sta_info.h
|
||||
@@ -106,6 +106,7 @@ struct sta_info {
|
||||
struct sta_info *next; /* next entry in sta list */
|
||||
struct sta_info *hnext; /* next entry in hash table list */
|
||||
u8 addr[6];
|
||||
+ u8 origin_ap[6];
|
||||
be32 ipaddr;
|
||||
struct dl_list ip6addr; /* list head for struct ip6addr */
|
||||
u16 aid; /* STA's unique AID (1 .. 2007) or 0 if not yet assigned */
|
||||
@@ -392,6 +393,9 @@ const char * ap_sta_wpa_get_keyid(struct
|
||||
void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
const u8 *addr, u16 reason);
|
||||
|
||||
+void _ap_sta_set_authorized(struct hostapd_data *hapd,
|
||||
+ struct sta_info *sta, int authorized,
|
||||
+ int reassoc);
|
||||
void ap_sta_set_authorized(struct hostapd_data *hapd,
|
||||
struct sta_info *sta, int authorized);
|
||||
static inline int ap_sta_is_authorized(struct sta_info *sta)
|
||||
@@ -1,53 +0,0 @@
|
||||
From 98b6503b87bb36bf2f5ae16e52e230e8870c867f Mon Sep 17 00:00:00 2001
|
||||
From: Venkat Chimata <venkata@shasta.cloud>
|
||||
Date: Fri, 28 Jun 2024 14:39:31 +0530
|
||||
Subject: [PATCH] hostapd: Fix DVLAN + 802.1x issue
|
||||
|
||||
In case of swconfig switches, the basename of the interface should be based on the last dot.
|
||||
Earlier it was done based on the first dot, which would result in incorrect basename.
|
||||
For example if the interface name is eth0.4087 then the vlan->ifname would be eth0.4087. (A dot at the end) .
|
||||
Before this patch, the basename was returned as eth0. It should be eth0.4087
|
||||
|
||||
Also fixed the return code by adding a default value of 0 and removed an unncessary check
|
||||
for if_add before ubus add call.
|
||||
|
||||
Signed-off-by: Venkat Chimata <venkata@shasta.cloud>
|
||||
---
|
||||
src/ap/vlan_init.c | 7 ++++---
|
||||
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/ap/vlan_init.c b/src/ap/vlan_init.c
|
||||
index 3e27671..cfeb1e5 100644
|
||||
--- a/src/ap/vlan_init.c
|
||||
+++ b/src/ap/vlan_init.c
|
||||
@@ -23,7 +23,8 @@ static int vlan_if_add(struct hostapd_data *hapd, struct hostapd_vlan *vlan,
|
||||
int existsok)
|
||||
{
|
||||
bool vlan_exists = iface_exists(vlan->ifname);
|
||||
- int ret;
|
||||
+ int ret = 0;
|
||||
+
|
||||
#ifdef CONFIG_WEP
|
||||
int i;
|
||||
|
||||
@@ -38,7 +39,7 @@ static int vlan_if_add(struct hostapd_data *hapd, struct hostapd_vlan *vlan,
|
||||
#endif /* CONFIG_WEP */
|
||||
|
||||
if (!hapd->driver || !hapd->driver->if_add) {
|
||||
- char *dot = strstr(vlan->ifname, ".");
|
||||
+ char *dot = strrchr(vlan->ifname, '.');
|
||||
if (dot)
|
||||
*dot = '\0';
|
||||
ret = 0;
|
||||
@@ -59,7 +60,7 @@ static int vlan_if_add(struct hostapd_data *hapd, struct hostapd_vlan *vlan,
|
||||
if (hapd->wpa_auth)
|
||||
ret = wpa_auth_ensure_group(hapd->wpa_auth, vlan->vlan_id);
|
||||
|
||||
- if (!ret && !vlan_exists && hapd->driver->if_add)
|
||||
+ if (!ret && !vlan_exists)
|
||||
hostapd_ubus_add_vlan(hapd, vlan);
|
||||
|
||||
if (ret == 0)
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
--- a/src/ap/hostapd.c
|
||||
+++ b/src/ap/hostapd.c
|
||||
@@ -1527,19 +1527,15 @@ int hostapd_setup_bss(struct hostapd_dat
|
||||
if (x_snoop_init(hapd)) {
|
||||
wpa_printf(MSG_ERROR,
|
||||
"Generic snooping infrastructure initialization failed");
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- if (dhcp_snoop_init(hapd)) {
|
||||
+ conf->proxy_arp = 0;
|
||||
+ } else if (dhcp_snoop_init(hapd)) {
|
||||
wpa_printf(MSG_ERROR,
|
||||
"DHCP snooping initialization failed");
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- if (ndisc_snoop_init(hapd)) {
|
||||
+ conf->proxy_arp = 0;
|
||||
+ } else if (ndisc_snoop_init(hapd)) {
|
||||
wpa_printf(MSG_ERROR,
|
||||
"Neighbor Discovery snooping initialization failed");
|
||||
- return -1;
|
||||
+ conf->proxy_arp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user