diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c index aa8bf279b..2811b9d6c 100644 --- a/src/ap/ap_drv_ops.c +++ b/src/ap/ap_drv_ops.c @@ -41,7 +41,7 @@ static int hostapd_sta_flags_to_drv(int flags) } -static int hostapd_set_ap_wps_ie(struct hostapd_data *hapd) +int hostapd_set_ap_wps_ie(struct hostapd_data *hapd) { struct wpabuf *beacon, *proberesp, *assocresp = NULL; int ret; @@ -157,8 +157,8 @@ static int hostapd_set_ap_wps_ie(struct hostapd_data *hapd) } -static int hostapd_set_authorized(struct hostapd_data *hapd, - struct sta_info *sta, int authorized) +int hostapd_set_authorized(struct hostapd_data *hapd, + struct sta_info *sta, int authorized) { if (authorized) { return hostapd_sta_set_flags(hapd, sta->addr, @@ -173,8 +173,7 @@ static int hostapd_set_authorized(struct hostapd_data *hapd, } -static int hostapd_set_sta_flags(struct hostapd_data *hapd, - struct sta_info *sta) +int hostapd_set_sta_flags(struct hostapd_data *hapd, struct sta_info *sta) { int set_flags, total_flags, flags_and, flags_or; total_flags = hostapd_sta_flags_to_drv(sta->flags); @@ -190,8 +189,8 @@ static int hostapd_set_sta_flags(struct hostapd_data *hapd, } -static int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, - const char *ifname, int enabled) +int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname, + int enabled) { struct wpa_bss_params params; os_memset(¶ms, 0, sizeof(params)); @@ -217,8 +216,7 @@ static int hostapd_set_ap_isolate(struct hostapd_data *hapd, int value) } -static int hostapd_set_bss_params(struct hostapd_data *hapd, - int use_protection) +int hostapd_set_bss_params(struct hostapd_data *hapd, int use_protection) { int ret = 0; int preamble; @@ -278,7 +276,7 @@ static int hostapd_set_bss_params(struct hostapd_data *hapd, } -static int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname) +int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname) { char force_ifname[IFNAMSIZ]; u8 if_addr[ETH_ALEN]; @@ -286,15 +284,15 @@ static int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname) force_ifname, if_addr); } -static int hostapd_vlan_if_remove(struct hostapd_data *hapd, - const char *ifname) + +int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname) { return hostapd_if_remove(hapd, WPA_IF_AP_VLAN, ifname); } -static int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, - int aid, int val) +int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, int aid, + int val) { const char *bridge = NULL; @@ -304,15 +302,16 @@ static int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, bridge = hapd->conf->wds_bridge; else if (hapd->conf->bridge[0]) bridge = hapd->conf->bridge; - return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val, bridge); + return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val, + bridge); } -static int hostapd_sta_add(struct hostapd_data *hapd, - const u8 *addr, u16 aid, u16 capability, - const u8 *supp_rates, size_t supp_rates_len, - u16 listen_interval, - const struct ieee80211_ht_capabilities *ht_capab) +int hostapd_sta_add(struct hostapd_data *hapd, + const u8 *addr, u16 aid, u16 capability, + const u8 *supp_rates, size_t supp_rates_len, + u16 listen_interval, + const struct ieee80211_ht_capabilities *ht_capab) { struct hostapd_sta_add_params params; @@ -333,20 +332,6 @@ static int hostapd_sta_add(struct hostapd_data *hapd, } -void hostapd_set_driver_ops(struct hostapd_driver_ops *ops) -{ - ops->set_ap_wps_ie = hostapd_set_ap_wps_ie; - ops->set_authorized = hostapd_set_authorized; - ops->set_sta_flags = hostapd_set_sta_flags; - ops->set_drv_ieee8021x = hostapd_set_drv_ieee8021x; - ops->set_bss_params = hostapd_set_bss_params; - ops->vlan_if_add = hostapd_vlan_if_add; - ops->vlan_if_remove = hostapd_vlan_if_remove; - ops->set_wds_sta = hostapd_set_wds_sta; - ops->sta_add = hostapd_sta_add; -} - - int hostapd_set_privacy(struct hostapd_data *hapd, int enabled) { if (hapd->driver == NULL || hapd->driver->set_privacy == NULL) diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h index 9fd5588cd..431e18aa7 100644 --- a/src/ap/ap_drv_ops.h +++ b/src/ap/ap_drv_ops.h @@ -18,8 +18,24 @@ enum wpa_driver_if_type; struct wpa_bss_params; struct wpa_driver_scan_params; +struct ieee80211_ht_capabilities; -void hostapd_set_driver_ops(struct hostapd_driver_ops *ops); +int hostapd_set_ap_wps_ie(struct hostapd_data *hapd); +int hostapd_set_authorized(struct hostapd_data *hapd, + struct sta_info *sta, int authorized); +int hostapd_set_sta_flags(struct hostapd_data *hapd, struct sta_info *sta); +int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname, + int enabled); +int hostapd_set_bss_params(struct hostapd_data *hapd, int use_protection); +int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname); +int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname); +int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, int aid, + int val); +int hostapd_sta_add(struct hostapd_data *hapd, + const u8 *addr, u16 aid, u16 capability, + const u8 *supp_rates, size_t supp_rates_len, + u16 listen_interval, + const struct ieee80211_ht_capabilities *ht_capab); int hostapd_set_privacy(struct hostapd_data *hapd, int enabled); int hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem, size_t elem_len); diff --git a/src/ap/beacon.c b/src/ap/beacon.c index 077178f20..55c065403 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -514,8 +514,8 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd) #ifdef CONFIG_P2P no_beacon: #endif /* CONFIG_P2P */ - hapd->drv.set_bss_params(hapd, !!(ieee802_11_erp_info(hapd) & - ERP_INFO_USE_PROTECTION)); + hostapd_set_bss_params(hapd, !!(ieee802_11_erp_info(hapd) & + ERP_INFO_USE_PROTECTION)); } diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 127454deb..b39a9d549 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -52,9 +52,9 @@ static void hostapd_reload_bss(struct hostapd_data *hapd) } if (hapd->conf->ieee802_1x || hapd->conf->wpa) - hapd->drv.set_drv_ieee8021x(hapd, hapd->conf->iface, 1); + hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 1); else - hapd->drv.set_drv_ieee8021x(hapd, hapd->conf->iface, 0); + hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 0); if (hapd->conf->wpa && hapd->wpa_auth == NULL) hostapd_setup_wpa(hapd); @@ -839,7 +839,6 @@ hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface, if (hapd == NULL) return NULL; - hostapd_set_driver_ops(&hapd->drv); hapd->new_assoc_sta_cb = hostapd_new_assoc_sta; hapd->iconf = conf; hapd->conf = bss; diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index 5d78c7a15..e2182cc0c 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -49,25 +49,6 @@ struct hostapd_frame_info { }; -struct hostapd_driver_ops { - int (*set_ap_wps_ie)(struct hostapd_data *hapd); - int (*set_authorized)(struct hostapd_data *hapd, struct sta_info *sta, - int authorized); - int (*set_sta_flags)(struct hostapd_data *hapd, struct sta_info *sta); - int (*set_drv_ieee8021x)(struct hostapd_data *hapd, const char *ifname, - int enabled); - int (*set_bss_params)(struct hostapd_data *hapd, int use_protection); - int (*vlan_if_add)(struct hostapd_data *hapd, const char *ifname); - int (*vlan_if_remove)(struct hostapd_data *hapd, const char *ifname); - int (*set_wds_sta)(struct hostapd_data *hapd, const u8 *addr, int aid, - int val); - int (*sta_add)(struct hostapd_data *hapd, - const u8 *addr, u16 aid, u16 capability, - const u8 *supp_rates, size_t supp_rates_len, - u16 listen_interval, - const struct ieee80211_ht_capabilities *ht_capab); -}; - /** * struct hostapd_data - hostapd per-BSS data structure */ @@ -95,7 +76,6 @@ struct hostapd_data { const struct wpa_driver_ops *driver; void *drv_priv; - struct hostapd_driver_ops drv; void (*new_assoc_sta_cb)(struct hostapd_data *hapd, struct sta_info *sta, int reassoc); diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index b2e0a4101..ae71524df 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -1651,17 +1651,17 @@ static void handle_assoc_cb(struct hostapd_data *hapd, hostapd_get_ht_capab(hapd, sta->ht_capabilities, &ht_cap); #endif /* CONFIG_IEEE80211N */ - if (hapd->drv.sta_add(hapd, sta->addr, sta->aid, sta->capability, - sta->supported_rates, sta->supported_rates_len, - sta->listen_interval, - sta->flags & WLAN_STA_HT ? &ht_cap : NULL)) { + if (hostapd_sta_add(hapd, sta->addr, sta->aid, sta->capability, + sta->supported_rates, sta->supported_rates_len, + sta->listen_interval, + sta->flags & WLAN_STA_HT ? &ht_cap : NULL)) { hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_NOTICE, "Could not add STA to kernel driver"); } if (sta->flags & WLAN_STA_WDS) - hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 1); + hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 1); if (sta->eapol_sm == NULL) { /* @@ -1677,7 +1677,7 @@ static void handle_assoc_cb(struct hostapd_data *hapd, goto fail; } - hapd->drv.set_sta_flags(hapd, sta); + hostapd_set_sta_flags(hapd, sta); if (sta->auth_alg == WLAN_AUTH_FT) wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC_FT); @@ -1797,7 +1797,7 @@ void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src, "STA " MACSTR " (aid %u)", MAC2STR(sta->addr), sta->aid); sta->flags |= WLAN_STA_WDS; - hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 1); + hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 1); } return; } diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c index c359a399c..4e84c16a7 100644 --- a/src/ap/ieee802_1x.c +++ b/src/ap/ieee802_1x.c @@ -93,7 +93,7 @@ void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd, wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED MACSTR, MAC2STR(sta->addr)); sta->flags |= WLAN_STA_AUTHORIZED; - res = hapd->drv.set_authorized(hapd, sta, 1); + res = hostapd_set_authorized(hapd, sta, 1); hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X, HOSTAPD_LEVEL_DEBUG, "authorizing port"); } else { @@ -103,7 +103,7 @@ void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd, AP_STA_DISCONNECTED MACSTR, MAC2STR(sta->addr)); sta->flags &= ~WLAN_STA_AUTHORIZED; - res = hapd->drv.set_authorized(hapd, sta, 0); + res = hostapd_set_authorized(hapd, sta, 0); hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X, HOSTAPD_LEVEL_DEBUG, "unauthorizing port"); } @@ -237,7 +237,7 @@ ieee802_1x_group_alloc(struct hostapd_data *hapd, const char *ifname) key->len[key->idx])) printf("Could not set dynamic VLAN WEP encryption key.\n"); - hapd->drv.set_drv_ieee8021x(hapd, ifname, 1); + hostapd_set_drv_ieee8021x(hapd, ifname, 1); return key; } @@ -1680,7 +1680,7 @@ int ieee802_1x_init(struct hostapd_data *hapd) return -1; if ((hapd->conf->ieee802_1x || hapd->conf->wpa) && - hapd->drv.set_drv_ieee8021x(hapd, hapd->conf->iface, 1)) + hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 1)) return -1; #ifndef CONFIG_NO_RADIUS @@ -1711,7 +1711,7 @@ void ieee802_1x_deinit(struct hostapd_data *hapd) if (hapd->driver != NULL && (hapd->conf->ieee802_1x || hapd->conf->wpa)) - hapd->drv.set_drv_ieee8021x(hapd, hapd->conf->iface, 0); + hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 0); eapol_auth_deinit(hapd->eapol_auth); hapd->eapol_auth = NULL; diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c index 330bd663a..07de0343d 100644 --- a/src/ap/sta_info.c +++ b/src/ap/sta_info.c @@ -125,7 +125,7 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta) accounting_sta_stop(hapd, sta); if (sta->flags & WLAN_STA_WDS) - hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 0); + hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 0); if (!(sta->flags & WLAN_STA_PREAUTH)) hostapd_drv_sta_remove(hapd, sta->addr); diff --git a/src/ap/vlan_init.c b/src/ap/vlan_init.c index 91249759e..f2f766f22 100644 --- a/src/ap/vlan_init.c +++ b/src/ap/vlan_init.c @@ -757,7 +757,7 @@ static int vlan_dynamic_add(struct hostapd_data *hapd, { while (vlan) { if (vlan->vlan_id != VLAN_ID_WILDCARD) { - if (hapd->drv.vlan_if_add(hapd, vlan->ifname)) { + if (hostapd_vlan_if_add(hapd, vlan->ifname)) { if (errno != EEXIST) { wpa_printf(MSG_ERROR, "VLAN: Could " "not add VLAN %s: %s", @@ -787,7 +787,7 @@ static void vlan_dynamic_remove(struct hostapd_data *hapd, next = vlan->next; if (vlan->vlan_id != VLAN_ID_WILDCARD && - hapd->drv.vlan_if_remove(hapd, vlan->ifname)) { + hostapd_vlan_if_remove(hapd, vlan->ifname)) { wpa_printf(MSG_ERROR, "VLAN: Could not remove VLAN " "iface: %s: %s", vlan->ifname, strerror(errno)); @@ -861,7 +861,7 @@ struct hostapd_vlan * vlan_add_dynamic(struct hostapd_data *hapd, pos); os_free(ifname); - if (hapd->drv.vlan_if_add(hapd, n->ifname)) { + if (hostapd_vlan_if_add(hapd, n->ifname)) { os_free(n); return NULL; } @@ -899,7 +899,7 @@ int vlan_remove_dynamic(struct hostapd_data *hapd, int vlan_id) return 1; if (vlan->dynamic_vlan == 0) - hapd->drv.vlan_if_remove(hapd, vlan->ifname); + hostapd_vlan_if_remove(hapd, vlan->ifname); return 0; } diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c index 126655917..b5cd5a847 100644 --- a/src/ap/wps_hostapd.c +++ b/src/ap/wps_hostapd.c @@ -28,6 +28,7 @@ #include "wps/wps_dev_attr.h" #include "hostapd.h" #include "ap_config.h" +#include "ap_drv_ops.h" #include "beacon.h" #include "sta_info.h" #include "wps_hostapd.h" @@ -140,7 +141,7 @@ static int hostapd_wps_set_ie_cb(void *ctx, struct wpabuf *beacon_ie, wpabuf_free(hapd->wps_probe_resp_ie); hapd->wps_probe_resp_ie = probe_resp_ie; ieee802_11_set_beacon(hapd); - return hapd->drv.set_ap_wps_ie(hapd); + return hostapd_set_ap_wps_ie(hapd); } @@ -589,7 +590,7 @@ static void hostapd_wps_clear_ies(struct hostapd_data *hapd) wpabuf_free(hapd->wps_probe_resp_ie); hapd->wps_probe_resp_ie = NULL; - hapd->drv.set_ap_wps_ie(hapd); + hostapd_set_ap_wps_ie(hapd); }