ap_drv_ops.c revision b36ed7cd946148d829f311de8fe53ea3ffaaffe3
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * hostapd - Driver operations 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi> 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * This software may be distributed under the terms of the BSD license. 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * See README for more details. 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "utils/includes.h" 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "utils/common.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "common/ieee802_11_defs.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "wps/wps.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "p2p/p2p.h" 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "hostapd.h" 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ieee802_11.h" 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "sta_info.h" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ap_config.h" 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "p2p_hostapd.h" 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "hs20.h" 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ap_drv_ops.h" 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)u32 hostapd_sta_flags_to_drv(u32 flags) 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){ 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int res = 0; 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (flags & WLAN_STA_AUTHORIZED) 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) res |= WPA_STA_AUTHORIZED; 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (flags & WLAN_STA_WMM) 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) res |= WPA_STA_WMM; 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (flags & WLAN_STA_SHORT_PREAMBLE) 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) res |= WPA_STA_SHORT_PREAMBLE; 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (flags & WLAN_STA_MFP) 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) res |= WPA_STA_MFP; 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return res; 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)int hostapd_build_ap_extra_ies(struct hostapd_data *hapd, 402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) struct wpabuf **beacon_ret, 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) struct wpabuf **proberesp_ret, 42c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) struct wpabuf **assocresp_ret) 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){ 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) struct wpabuf *beacon = NULL, *proberesp = NULL, *assocresp = NULL; 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) u8 buf[200], *pos; 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *beacon_ret = *proberesp_ret = *assocresp_ret = NULL; 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pos = buf; 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pos = hostapd_eid_time_adv(hapd, pos); 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (pos != buf) { 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wpabuf_resize(&beacon, pos - buf) != 0) 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) goto fail; 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_data(beacon, buf, pos - buf); 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pos = hostapd_eid_time_zone(hapd, pos); 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (pos != buf) { 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wpabuf_resize(&proberesp, pos - buf) != 0) 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) goto fail; 602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) wpabuf_put_data(proberesp, buf, pos - buf); 612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) pos = buf; 642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) pos = hostapd_eid_ext_capab(hapd, pos); 652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (pos != buf) { 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (wpabuf_resize(&assocresp, pos - buf) != 0) 672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) goto fail; 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_data(assocresp, buf, pos - buf); 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pos = hostapd_eid_interworking(hapd, pos); 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pos = hostapd_eid_adv_proto(hapd, pos); 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pos = hostapd_eid_roaming_consortium(hapd, pos); 732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (pos != buf) { 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wpabuf_resize(&beacon, pos - buf) != 0) 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) goto fail; 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_data(beacon, buf, pos - buf); 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wpabuf_resize(&proberesp, pos - buf) != 0) 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) goto fail; 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_data(proberesp, buf, pos - buf); 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (hapd->wps_beacon_ie) { 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wpabuf_resize(&beacon, wpabuf_len(hapd->wps_beacon_ie)) < 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 0) 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) goto fail; 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_buf(beacon, hapd->wps_beacon_ie); 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (hapd->wps_probe_resp_ie) { 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wpabuf_resize(&proberesp, 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_len(hapd->wps_probe_resp_ie)) < 0) 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) goto fail; 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_buf(proberesp, hapd->wps_probe_resp_ie); 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef CONFIG_P2P 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (hapd->p2p_beacon_ie) { 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wpabuf_resize(&beacon, wpabuf_len(hapd->p2p_beacon_ie)) < 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 0) 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) goto fail; 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_buf(beacon, hapd->p2p_beacon_ie); 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (hapd->p2p_probe_resp_ie) { 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wpabuf_resize(&proberesp, 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_len(hapd->p2p_probe_resp_ie)) < 0) 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) goto fail; 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_buf(proberesp, hapd->p2p_probe_resp_ie); 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* CONFIG_P2P */ 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef CONFIG_P2P_MANAGER 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (hapd->conf->p2p & P2P_MANAGE) { 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wpabuf_resize(&beacon, 100) == 0) { 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) u8 *start, *p; 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) start = wpabuf_put(beacon, 0); 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) p = hostapd_eid_p2p_manage(hapd, start); 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put(beacon, p - start); 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wpabuf_resize(&proberesp, 100) == 0) { 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) u8 *start, *p; 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) start = wpabuf_put(proberesp, 0); 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) p = hostapd_eid_p2p_manage(hapd, start); 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put(proberesp, p - start); 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif /* CONFIG_P2P_MANAGER */ 1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifdef CONFIG_WPS2 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (hapd->conf->wps_state) { 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) struct wpabuf *a = wps_build_assoc_resp_ie(); 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (a && wpabuf_resize(&assocresp, wpabuf_len(a)) == 0) 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_buf(assocresp, a); 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_free(a); 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* CONFIG_WPS2 */ 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef CONFIG_P2P_MANAGER 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (hapd->conf->p2p & P2P_MANAGE) { 142a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) if (wpabuf_resize(&assocresp, 100) == 0) { 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) u8 *start, *p; 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) start = wpabuf_put(assocresp, 0); 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) p = hostapd_eid_p2p_manage(hapd, start); 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put(assocresp, p - start); 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* CONFIG_P2P_MANAGER */ 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef CONFIG_WIFI_DISPLAY 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (hapd->p2p_group) { 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) struct wpabuf *a; 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) a = p2p_group_assoc_resp_ie(hapd->p2p_group, P2P_SC_SUCCESS); 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (a && wpabuf_resize(&assocresp, wpabuf_len(a)) == 0) 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_buf(assocresp, a); 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_free(a); 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* CONFIG_WIFI_DISPLAY */ 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef CONFIG_HS20 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pos = buf; 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pos = hostapd_eid_hs20_indication(hapd, pos); 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (pos != buf) { 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wpabuf_resize(&beacon, pos - buf) != 0) 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) goto fail; 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_data(beacon, buf, pos - buf); 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wpabuf_resize(&proberesp, pos - buf) != 0) 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) goto fail; 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_data(proberesp, buf, pos - buf); 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) pos = hostapd_eid_osen(hapd, buf); 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (pos != buf) { 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wpabuf_resize(&beacon, pos - buf) != 0) 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) goto fail; 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_data(beacon, buf, pos - buf); 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (wpabuf_resize(&proberesp, pos - buf) != 0) 1811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) goto fail; 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_put_data(proberesp, buf, pos - buf); 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif /* CONFIG_HS20 */ 1851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (hapd->conf->vendor_elements) { 1875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) size_t add = wpabuf_len(hapd->conf->vendor_elements); 1881e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (wpabuf_resize(&beacon, add) == 0) 1891e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) wpabuf_put_buf(beacon, hapd->conf->vendor_elements); 1901e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (wpabuf_resize(&proberesp, add) == 0) 1911e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) wpabuf_put_buf(proberesp, hapd->conf->vendor_elements); 1921e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) } 1931e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *beacon_ret = beacon; 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *proberesp_ret = proberesp; 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *assocresp_ret = assocresp; 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return 0; 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)fail: 2011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) wpabuf_free(beacon); 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wpabuf_free(proberesp); 203c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) wpabuf_free(assocresp); 204c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return -1; 205c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 206c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 207c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 208c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void hostapd_free_ap_extra_ies(struct hostapd_data *hapd, 209c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) struct wpabuf *beacon, 2101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) struct wpabuf *proberesp, 2111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) struct wpabuf *assocresp) 2121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles){ 2131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) wpabuf_free(beacon); 214c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) wpabuf_free(proberesp); 215c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) wpabuf_free(assocresp); 216c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 217c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 218c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 2191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)int hostapd_set_ap_wps_ie(struct hostapd_data *hapd) 2201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles){ 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) struct wpabuf *beacon, *proberesp, *assocresp; 222c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) int ret; 223c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 224c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (hapd->driver == NULL || hapd->driver->set_ap_wps_ie == NULL) 225c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return 0; 226c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 227c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) < 228c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 0) 229c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return -1; 230c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 2311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) ret = hapd->driver->set_ap_wps_ie(hapd->drv_priv, beacon, proberesp, 2321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) assocresp); 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp); 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return ret; 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)int hostapd_set_authorized(struct hostapd_data *hapd, 2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) struct sta_info *sta, int authorized) 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){ 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (authorized) { 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return hostapd_sta_set_flags(hapd, sta->addr, 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) hostapd_sta_flags_to_drv( 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) sta->flags), 2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WPA_STA_AUTHORIZED, ~0); 2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return hostapd_sta_set_flags(hapd, sta->addr, 2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) hostapd_sta_flags_to_drv(sta->flags), 2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 0, ~WPA_STA_AUTHORIZED); 2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 256int hostapd_set_sta_flags(struct hostapd_data *hapd, struct sta_info *sta) 257{ 258 int set_flags, total_flags, flags_and, flags_or; 259 total_flags = hostapd_sta_flags_to_drv(sta->flags); 260 set_flags = WPA_STA_SHORT_PREAMBLE | WPA_STA_WMM | WPA_STA_MFP; 261 if (((!hapd->conf->ieee802_1x && !hapd->conf->wpa) || 262 sta->auth_alg == WLAN_AUTH_FT) && 263 sta->flags & WLAN_STA_AUTHORIZED) 264 set_flags |= WPA_STA_AUTHORIZED; 265 flags_or = total_flags & set_flags; 266 flags_and = total_flags | ~set_flags; 267 return hostapd_sta_set_flags(hapd, sta->addr, total_flags, 268 flags_or, flags_and); 269} 270 271 272int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname, 273 int enabled) 274{ 275 struct wpa_bss_params params; 276 os_memset(¶ms, 0, sizeof(params)); 277 params.ifname = ifname; 278 params.enabled = enabled; 279 if (enabled) { 280 params.wpa = hapd->conf->wpa; 281 params.ieee802_1x = hapd->conf->ieee802_1x; 282 params.wpa_group = hapd->conf->wpa_group; 283 params.wpa_pairwise = hapd->conf->wpa_pairwise; 284 params.wpa_key_mgmt = hapd->conf->wpa_key_mgmt; 285 params.rsn_preauth = hapd->conf->rsn_preauth; 286#ifdef CONFIG_IEEE80211W 287 params.ieee80211w = hapd->conf->ieee80211w; 288#endif /* CONFIG_IEEE80211W */ 289 } 290 return hostapd_set_ieee8021x(hapd, ¶ms); 291} 292 293 294int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname) 295{ 296 char force_ifname[IFNAMSIZ]; 297 u8 if_addr[ETH_ALEN]; 298 return hostapd_if_add(hapd, WPA_IF_AP_VLAN, ifname, hapd->own_addr, 299 NULL, NULL, force_ifname, if_addr, NULL, 0); 300} 301 302 303int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname) 304{ 305 return hostapd_if_remove(hapd, WPA_IF_AP_VLAN, ifname); 306} 307 308 309int hostapd_set_wds_sta(struct hostapd_data *hapd, char *ifname_wds, 310 const u8 *addr, int aid, int val) 311{ 312 const char *bridge = NULL; 313 314 if (hapd->driver == NULL || hapd->driver->set_wds_sta == NULL) 315 return -1; 316 if (hapd->conf->wds_bridge[0]) 317 bridge = hapd->conf->wds_bridge; 318 else if (hapd->conf->bridge[0]) 319 bridge = hapd->conf->bridge; 320 return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val, 321 bridge, ifname_wds); 322} 323 324 325int hostapd_add_sta_node(struct hostapd_data *hapd, const u8 *addr, 326 u16 auth_alg) 327{ 328 if (hapd->driver == NULL || hapd->driver->add_sta_node == NULL) 329 return 0; 330 return hapd->driver->add_sta_node(hapd->drv_priv, addr, auth_alg); 331} 332 333 334int hostapd_sta_auth(struct hostapd_data *hapd, const u8 *addr, 335 u16 seq, u16 status, const u8 *ie, size_t len) 336{ 337 if (hapd->driver == NULL || hapd->driver->sta_auth == NULL) 338 return 0; 339 return hapd->driver->sta_auth(hapd->drv_priv, hapd->own_addr, addr, 340 seq, status, ie, len); 341} 342 343 344int hostapd_sta_assoc(struct hostapd_data *hapd, const u8 *addr, 345 int reassoc, u16 status, const u8 *ie, size_t len) 346{ 347 if (hapd->driver == NULL || hapd->driver->sta_assoc == NULL) 348 return 0; 349 return hapd->driver->sta_assoc(hapd->drv_priv, hapd->own_addr, addr, 350 reassoc, status, ie, len); 351} 352 353 354int hostapd_sta_add(struct hostapd_data *hapd, 355 const u8 *addr, u16 aid, u16 capability, 356 const u8 *supp_rates, size_t supp_rates_len, 357 u16 listen_interval, 358 const struct ieee80211_ht_capabilities *ht_capab, 359 const struct ieee80211_vht_capabilities *vht_capab, 360 u32 flags, u8 qosinfo, u8 vht_opmode) 361{ 362 struct hostapd_sta_add_params params; 363 364 if (hapd->driver == NULL) 365 return 0; 366 if (hapd->driver->sta_add == NULL) 367 return 0; 368 369 os_memset(¶ms, 0, sizeof(params)); 370 params.addr = addr; 371 params.aid = aid; 372 params.capability = capability; 373 params.supp_rates = supp_rates; 374 params.supp_rates_len = supp_rates_len; 375 params.listen_interval = listen_interval; 376 params.ht_capabilities = ht_capab; 377 params.vht_capabilities = vht_capab; 378 params.vht_opmode_enabled = !!(flags & WLAN_STA_VHT_OPMODE_ENABLED); 379 params.vht_opmode = vht_opmode; 380 params.flags = hostapd_sta_flags_to_drv(flags); 381 params.qosinfo = qosinfo; 382 return hapd->driver->sta_add(hapd->drv_priv, ¶ms); 383} 384 385 386int hostapd_add_tspec(struct hostapd_data *hapd, const u8 *addr, 387 u8 *tspec_ie, size_t tspec_ielen) 388{ 389 if (hapd->driver == NULL || hapd->driver->add_tspec == NULL) 390 return 0; 391 return hapd->driver->add_tspec(hapd->drv_priv, addr, tspec_ie, 392 tspec_ielen); 393} 394 395 396int hostapd_set_privacy(struct hostapd_data *hapd, int enabled) 397{ 398 if (hapd->driver == NULL || hapd->driver->set_privacy == NULL) 399 return 0; 400 return hapd->driver->set_privacy(hapd->drv_priv, enabled); 401} 402 403 404int hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem, 405 size_t elem_len) 406{ 407 if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL) 408 return 0; 409 return hapd->driver->set_generic_elem(hapd->drv_priv, elem, elem_len); 410} 411 412 413int hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len) 414{ 415 if (hapd->driver == NULL || hapd->driver->hapd_get_ssid == NULL) 416 return 0; 417 return hapd->driver->hapd_get_ssid(hapd->drv_priv, buf, len); 418} 419 420 421int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len) 422{ 423 if (hapd->driver == NULL || hapd->driver->hapd_set_ssid == NULL) 424 return 0; 425 return hapd->driver->hapd_set_ssid(hapd->drv_priv, buf, len); 426} 427 428 429int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type, 430 const char *ifname, const u8 *addr, void *bss_ctx, 431 void **drv_priv, char *force_ifname, u8 *if_addr, 432 const char *bridge, int use_existing) 433{ 434 if (hapd->driver == NULL || hapd->driver->if_add == NULL) 435 return -1; 436 return hapd->driver->if_add(hapd->drv_priv, type, ifname, addr, 437 bss_ctx, drv_priv, force_ifname, if_addr, 438 bridge, use_existing); 439} 440 441 442int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type, 443 const char *ifname) 444{ 445 if (hapd->driver == NULL || hapd->drv_priv == NULL || 446 hapd->driver->if_remove == NULL) 447 return -1; 448 return hapd->driver->if_remove(hapd->drv_priv, type, ifname); 449} 450 451 452int hostapd_set_ieee8021x(struct hostapd_data *hapd, 453 struct wpa_bss_params *params) 454{ 455 if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL) 456 return 0; 457 return hapd->driver->set_ieee8021x(hapd->drv_priv, params); 458} 459 460 461int hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd, 462 const u8 *addr, int idx, u8 *seq) 463{ 464 if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL) 465 return 0; 466 return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx, 467 seq); 468} 469 470 471int hostapd_flush(struct hostapd_data *hapd) 472{ 473 if (hapd->driver == NULL || hapd->driver->flush == NULL) 474 return 0; 475 return hapd->driver->flush(hapd->drv_priv); 476} 477 478 479int hostapd_set_freq_params(struct hostapd_freq_params *data, int mode, 480 int freq, int channel, int ht_enabled, 481 int vht_enabled, int sec_channel_offset, 482 int vht_oper_chwidth, int center_segment0, 483 int center_segment1, u32 vht_caps) 484{ 485 int tmp; 486 487 os_memset(data, 0, sizeof(*data)); 488 data->mode = mode; 489 data->freq = freq; 490 data->channel = channel; 491 data->ht_enabled = ht_enabled; 492 data->vht_enabled = vht_enabled; 493 data->sec_channel_offset = sec_channel_offset; 494 data->center_freq1 = freq + sec_channel_offset * 10; 495 data->center_freq2 = 0; 496 data->bandwidth = sec_channel_offset ? 40 : 20; 497 498 /* 499 * This validation code is probably misplaced, maybe it should be 500 * in src/ap/hw_features.c and check the hardware support as well. 501 */ 502 if (data->vht_enabled) switch (vht_oper_chwidth) { 503 case VHT_CHANWIDTH_USE_HT: 504 if (center_segment1) 505 return -1; 506 if (center_segment0 != 0 && 507 5000 + center_segment0 * 5 != data->center_freq1 && 508 2407 + center_segment0 * 5 != data->center_freq1) 509 return -1; 510 break; 511 case VHT_CHANWIDTH_80P80MHZ: 512 if (!(vht_caps & VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ)) { 513 wpa_printf(MSG_ERROR, 514 "80+80 channel width is not supported!"); 515 return -1; 516 } 517 if (center_segment1 == center_segment0 + 4 || 518 center_segment1 == center_segment0 - 4) 519 return -1; 520 data->center_freq2 = 5000 + center_segment1 * 5; 521 /* fall through */ 522 case VHT_CHANWIDTH_80MHZ: 523 data->bandwidth = 80; 524 if (vht_oper_chwidth == 1 && center_segment1) 525 return -1; 526 if (vht_oper_chwidth == 3 && !center_segment1) 527 return -1; 528 if (!sec_channel_offset) 529 return -1; 530 /* primary 40 part must match the HT configuration */ 531 tmp = (30 + freq - 5000 - center_segment0 * 5)/20; 532 tmp /= 2; 533 if (data->center_freq1 != 5000 + 534 center_segment0 * 5 - 20 + 40 * tmp) 535 return -1; 536 data->center_freq1 = 5000 + center_segment0 * 5; 537 break; 538 case VHT_CHANWIDTH_160MHZ: 539 data->bandwidth = 160; 540 if (!(vht_caps & (VHT_CAP_SUPP_CHAN_WIDTH_160MHZ | 541 VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ))) { 542 wpa_printf(MSG_ERROR, 543 "160MHZ channel width is not supported!"); 544 return -1; 545 } 546 if (center_segment1) 547 return -1; 548 if (!sec_channel_offset) 549 return -1; 550 /* primary 40 part must match the HT configuration */ 551 tmp = (70 + freq - 5000 - center_segment0 * 5)/20; 552 tmp /= 2; 553 if (data->center_freq1 != 5000 + 554 center_segment0 * 5 - 60 + 40 * tmp) 555 return -1; 556 data->center_freq1 = 5000 + center_segment0 * 5; 557 break; 558 } 559 560 return 0; 561} 562 563 564int hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq, 565 int channel, int ht_enabled, int vht_enabled, 566 int sec_channel_offset, int vht_oper_chwidth, 567 int center_segment0, int center_segment1) 568{ 569 struct hostapd_freq_params data; 570 571 if (hostapd_set_freq_params(&data, mode, freq, channel, ht_enabled, 572 vht_enabled, sec_channel_offset, 573 vht_oper_chwidth, 574 center_segment0, center_segment1, 575 hapd->iface->current_mode->vht_capab)) 576 return -1; 577 578 if (hapd->driver == NULL) 579 return 0; 580 if (hapd->driver->set_freq == NULL) 581 return 0; 582 return hapd->driver->set_freq(hapd->drv_priv, &data); 583} 584 585int hostapd_set_rts(struct hostapd_data *hapd, int rts) 586{ 587 if (hapd->driver == NULL || hapd->driver->set_rts == NULL) 588 return 0; 589 return hapd->driver->set_rts(hapd->drv_priv, rts); 590} 591 592 593int hostapd_set_frag(struct hostapd_data *hapd, int frag) 594{ 595 if (hapd->driver == NULL || hapd->driver->set_frag == NULL) 596 return 0; 597 return hapd->driver->set_frag(hapd->drv_priv, frag); 598} 599 600 601int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr, 602 int total_flags, int flags_or, int flags_and) 603{ 604 if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL) 605 return 0; 606 return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags, 607 flags_or, flags_and); 608} 609 610 611int hostapd_set_country(struct hostapd_data *hapd, const char *country) 612{ 613 if (hapd->driver == NULL || 614 hapd->driver->set_country == NULL) 615 return 0; 616 return hapd->driver->set_country(hapd->drv_priv, country); 617} 618 619 620int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs, 621 int cw_min, int cw_max, int burst_time) 622{ 623 if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL) 624 return 0; 625 return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs, 626 cw_min, cw_max, burst_time); 627} 628 629 630struct hostapd_hw_modes * 631hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes, 632 u16 *flags) 633{ 634 if (hapd->driver == NULL || 635 hapd->driver->get_hw_feature_data == NULL) 636 return NULL; 637 return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes, 638 flags); 639} 640 641 642int hostapd_driver_commit(struct hostapd_data *hapd) 643{ 644 if (hapd->driver == NULL || hapd->driver->commit == NULL) 645 return 0; 646 return hapd->driver->commit(hapd->drv_priv); 647} 648 649 650int hostapd_drv_none(struct hostapd_data *hapd) 651{ 652 return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0; 653} 654 655 656int hostapd_driver_scan(struct hostapd_data *hapd, 657 struct wpa_driver_scan_params *params) 658{ 659 if (hapd->driver && hapd->driver->scan2) 660 return hapd->driver->scan2(hapd->drv_priv, params); 661 return -1; 662} 663 664 665struct wpa_scan_results * hostapd_driver_get_scan_results( 666 struct hostapd_data *hapd) 667{ 668 if (hapd->driver && hapd->driver->get_scan_results2) 669 return hapd->driver->get_scan_results2(hapd->drv_priv); 670 return NULL; 671} 672 673 674int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start, 675 int duration) 676{ 677 if (hapd->driver && hapd->driver->set_noa) 678 return hapd->driver->set_noa(hapd->drv_priv, count, start, 679 duration); 680 return -1; 681} 682 683 684int hostapd_drv_set_key(const char *ifname, struct hostapd_data *hapd, 685 enum wpa_alg alg, const u8 *addr, 686 int key_idx, int set_tx, 687 const u8 *seq, size_t seq_len, 688 const u8 *key, size_t key_len) 689{ 690 if (hapd->driver == NULL || hapd->driver->set_key == NULL) 691 return 0; 692 return hapd->driver->set_key(ifname, hapd->drv_priv, alg, addr, 693 key_idx, set_tx, seq, seq_len, key, 694 key_len); 695} 696 697 698int hostapd_drv_send_mlme(struct hostapd_data *hapd, 699 const void *msg, size_t len, int noack) 700{ 701 if (hapd->driver == NULL || hapd->driver->send_mlme == NULL) 702 return 0; 703 return hapd->driver->send_mlme(hapd->drv_priv, msg, len, noack); 704} 705 706 707int hostapd_drv_sta_deauth(struct hostapd_data *hapd, 708 const u8 *addr, int reason) 709{ 710 if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL) 711 return 0; 712 return hapd->driver->sta_deauth(hapd->drv_priv, hapd->own_addr, addr, 713 reason); 714} 715 716 717int hostapd_drv_sta_disassoc(struct hostapd_data *hapd, 718 const u8 *addr, int reason) 719{ 720 if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL) 721 return 0; 722 return hapd->driver->sta_disassoc(hapd->drv_priv, hapd->own_addr, addr, 723 reason); 724} 725 726 727int hostapd_drv_wnm_oper(struct hostapd_data *hapd, enum wnm_oper oper, 728 const u8 *peer, u8 *buf, u16 *buf_len) 729{ 730 if (hapd->driver == NULL || hapd->driver->wnm_oper == NULL) 731 return -1; 732 return hapd->driver->wnm_oper(hapd->drv_priv, oper, peer, buf, 733 buf_len); 734} 735 736 737int hostapd_drv_send_action(struct hostapd_data *hapd, unsigned int freq, 738 unsigned int wait, const u8 *dst, const u8 *data, 739 size_t len) 740{ 741 if (hapd->driver == NULL || hapd->driver->send_action == NULL) 742 return 0; 743 return hapd->driver->send_action(hapd->drv_priv, freq, wait, dst, 744 hapd->own_addr, hapd->own_addr, data, 745 len, 0); 746} 747 748 749int hostapd_start_dfs_cac(struct hostapd_iface *iface, int mode, int freq, 750 int channel, int ht_enabled, int vht_enabled, 751 int sec_channel_offset, int vht_oper_chwidth, 752 int center_segment0, int center_segment1) 753{ 754 struct hostapd_data *hapd = iface->bss[0]; 755 struct hostapd_freq_params data; 756 int res; 757 758 if (!hapd->driver || !hapd->driver->start_dfs_cac) 759 return 0; 760 761 if (!iface->conf->ieee80211h) { 762 wpa_printf(MSG_ERROR, "Can't start DFS CAC, DFS functionality " 763 "is not enabled"); 764 return -1; 765 } 766 767 if (hostapd_set_freq_params(&data, mode, freq, channel, ht_enabled, 768 vht_enabled, sec_channel_offset, 769 vht_oper_chwidth, center_segment0, 770 center_segment1, 771 iface->current_mode->vht_capab)) { 772 wpa_printf(MSG_ERROR, "Can't set freq params"); 773 return -1; 774 } 775 776 res = hapd->driver->start_dfs_cac(hapd->drv_priv, &data); 777 if (!res) 778 iface->cac_started = 1; 779 780 return res; 781} 782 783 784int hostapd_drv_set_qos_map(struct hostapd_data *hapd, 785 const u8 *qos_map_set, u8 qos_map_set_len) 786{ 787 if (hapd->driver == NULL || hapd->driver->set_qos_map == NULL) 788 return 0; 789 return hapd->driver->set_qos_map(hapd->drv_priv, qos_map_set, 790 qos_map_set_len); 791} 792