1 /* 2 * IEEE 802.11 Common routines 3 * Copyright (c) 2002-2012, Jouni Malinen <j@w1.fi> 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9 #ifndef IEEE802_11_COMMON_H 10 #define IEEE802_11_COMMON_H 11 12 #define MAX_NOF_MB_IES_SUPPORTED 5 13 14 struct mb_ies_info { 15 struct { 16 const u8 *ie; 17 u8 ie_len; 18 } ies[MAX_NOF_MB_IES_SUPPORTED]; 19 u8 nof_ies; 20 }; 21 22 /* Parsed Information Elements */ 23 struct ieee802_11_elems { 24 const u8 *ssid; 25 const u8 *supp_rates; 26 const u8 *ds_params; 27 const u8 *challenge; 28 const u8 *erp_info; 29 const u8 *ext_supp_rates; 30 const u8 *wpa_ie; 31 const u8 *rsn_ie; 32 const u8 *wmm; /* WMM Information or Parameter Element */ 33 const u8 *wmm_tspec; 34 const u8 *wps_ie; 35 const u8 *supp_channels; 36 const u8 *mdie; 37 const u8 *ftie; 38 const u8 *timeout_int; 39 const u8 *ht_capabilities; 40 const u8 *ht_operation; 41 const u8 *mesh_config; 42 const u8 *mesh_id; 43 const u8 *peer_mgmt; 44 const u8 *vht_capabilities; 45 const u8 *vht_operation; 46 const u8 *vht_opmode_notif; 47 const u8 *vendor_ht_cap; 48 const u8 *vendor_vht; 49 const u8 *p2p; 50 const u8 *wfd; 51 const u8 *link_id; 52 const u8 *interworking; 53 const u8 *qos_map_set; 54 const u8 *hs20; 55 const u8 *ext_capab; 56 const u8 *bss_max_idle_period; 57 const u8 *ssid_list; 58 const u8 *osen; 59 const u8 *ampe; 60 const u8 *mic; 61 const u8 *pref_freq_list; 62 63 u8 ssid_len; 64 u8 supp_rates_len; 65 u8 challenge_len; 66 u8 ext_supp_rates_len; 67 u8 wpa_ie_len; 68 u8 rsn_ie_len; 69 u8 wmm_len; /* 7 = WMM Information; 24 = WMM Parameter */ 70 u8 wmm_tspec_len; 71 u8 wps_ie_len; 72 u8 supp_channels_len; 73 u8 mdie_len; 74 u8 ftie_len; 75 u8 mesh_config_len; 76 u8 mesh_id_len; 77 u8 peer_mgmt_len; 78 u8 vendor_ht_cap_len; 79 u8 vendor_vht_len; 80 u8 p2p_len; 81 u8 wfd_len; 82 u8 interworking_len; 83 u8 qos_map_set_len; 84 u8 hs20_len; 85 u8 ext_capab_len; 86 u8 ssid_list_len; 87 u8 osen_len; 88 u8 ampe_len; 89 u8 mic_len; 90 u8 pref_freq_list_len; 91 struct mb_ies_info mb_ies; 92 }; 93 94 typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes; 95 96 ParseRes ieee802_11_parse_elems(const u8 *start, size_t len, 97 struct ieee802_11_elems *elems, 98 int show_errors); 99 int ieee802_11_ie_count(const u8 *ies, size_t ies_len); 100 struct wpabuf * ieee802_11_vendor_ie_concat(const u8 *ies, size_t ies_len, 101 u32 oui_type); 102 struct ieee80211_hdr; 103 const u8 * get_hdr_bssid(const struct ieee80211_hdr *hdr, size_t len); 104 105 struct hostapd_wmm_ac_params { 106 int cwmin; 107 int cwmax; 108 int aifs; 109 int txop_limit; /* in units of 32us */ 110 int admission_control_mandatory; 111 }; 112 113 int hostapd_config_wmm_ac(struct hostapd_wmm_ac_params wmm_ac_params[], 114 const char *name, const char *val); 115 enum hostapd_hw_mode ieee80211_freq_to_chan(int freq, u8 *channel); 116 int ieee80211_chan_to_freq(const char *country, u8 op_class, u8 chan); 117 enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq, 118 int sec_channel, int vht, 119 u8 *op_class, u8 *channel); 120 int ieee80211_is_dfs(int freq); 121 122 int supp_rates_11b_only(struct ieee802_11_elems *elems); 123 int mb_ies_info_by_ies(struct mb_ies_info *info, const u8 *ies_buf, 124 size_t ies_len); 125 struct wpabuf * mb_ies_by_info(struct mb_ies_info *info); 126 127 const char * fc2str(u16 fc); 128 #endif /* IEEE802_11_COMMON_H */ 129