2 * Hotspot 2.0 AP ANQP processing
3 * Copyright (c) 2009, Atheros Communications, Inc.
4 * Copyright (c) 2011-2013, Qualcomm Atheros, Inc.
6 * This software may be distributed under the terms of the BSD license.
7 * See README for more details.
13 #include "common/ieee802_11_defs.h"
14 #include "common/wpa_ctrl.h"
16 #include "ap_config.h"
17 #include "ap_drv_ops.h"
22 u8 * hostapd_eid_hs20_indication(struct hostapd_data *hapd, u8 *eid)
25 if (!hapd->conf->hs20)
27 *eid++ = WLAN_EID_VENDOR_SPECIFIC;
28 *eid++ = hapd->conf->hs20_release < 2 ? 5 : 7;
29 WPA_PUT_BE24(eid, OUI_WFA);
31 *eid++ = HS20_INDICATION_OUI_TYPE;
32 conf = (hapd->conf->hs20_release - 1) << 4; /* Release Number */
33 if (hapd->conf->hs20_release >= 2)
34 conf |= HS20_ANQP_DOMAIN_ID_PRESENT;
35 if (hapd->conf->disable_dgaf)
36 conf |= HS20_DGAF_DISABLED;
38 if (hapd->conf->hs20_release >= 2) {
39 WPA_PUT_LE16(eid, hapd->conf->anqp_domain_id);
47 u8 * hostapd_eid_osen(struct hostapd_data *hapd, u8 *eid)
52 if (!hapd->conf->osen)
55 *eid++ = WLAN_EID_VENDOR_SPECIFIC;
56 len = eid++; /* to be filled */
57 WPA_PUT_BE24(eid, OUI_WFA);
59 *eid++ = HS20_OSEN_OUI_TYPE;
61 /* Group Data Cipher Suite */
62 RSN_SELECTOR_PUT(eid, RSN_CIPHER_SUITE_NO_GROUP_ADDRESSED);
63 eid += RSN_SELECTOR_LEN;
65 /* Pairwise Cipher Suite Count and List */
68 RSN_SELECTOR_PUT(eid, RSN_CIPHER_SUITE_CCMP);
69 eid += RSN_SELECTOR_LEN;
71 /* AKM Suite Count and List */
74 RSN_SELECTOR_PUT(eid, RSN_AUTH_KEY_MGMT_OSEN);
75 eid += RSN_SELECTOR_LEN;
77 /* RSN Capabilities */
79 if (hapd->conf->wmm_enabled) {
80 /* 4 PTKSA replay counters when using WMM */
81 capab |= (RSN_NUM_REPLAY_COUNTERS_16 << 2);
83 #ifdef CONFIG_IEEE80211W
84 if (hapd->conf->ieee80211w != NO_MGMT_FRAME_PROTECTION) {
85 capab |= WPA_CAPABILITY_MFPC;
86 if (hapd->conf->ieee80211w == MGMT_FRAME_PROTECTION_REQUIRED)
87 capab |= WPA_CAPABILITY_MFPR;
89 #endif /* CONFIG_IEEE80211W */
92 capab |= WPA_CAPABILITY_OCVC;
93 #endif /* CONFIG_OCV */
94 WPA_PUT_LE16(eid, capab);
103 int hs20_send_wnm_notification(struct hostapd_data *hapd, const u8 *addr,
104 u8 osu_method, const char *url)
110 /* TODO: should refuse to send notification if the STA is not associated
111 * or if the STA did not indicate support for WNM-Notification */
114 len = 1 + os_strlen(url);
116 wpa_printf(MSG_INFO, "HS 2.0: Too long URL for "
117 "WNM-Notification: '%s'", url);
122 buf = wpabuf_alloc(4 + 7 + len);
126 wpabuf_put_u8(buf, WLAN_ACTION_WNM);
127 wpabuf_put_u8(buf, WNM_NOTIFICATION_REQ);
128 wpabuf_put_u8(buf, 1); /* Dialog token */
129 wpabuf_put_u8(buf, 1); /* Type - 1 reserved for WFA */
131 /* Subscription Remediation subelement */
132 wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
133 wpabuf_put_u8(buf, 5 + len);
134 wpabuf_put_be24(buf, OUI_WFA);
135 wpabuf_put_u8(buf, HS20_WNM_SUB_REM_NEEDED);
137 wpabuf_put_u8(buf, len - 1);
138 wpabuf_put_data(buf, url, len - 1);
139 wpabuf_put_u8(buf, osu_method);
141 /* Server URL and Server Method fields not included */
142 wpabuf_put_u8(buf, 0);
145 ret = hostapd_drv_send_action(hapd, hapd->iface->freq, 0, addr,
146 wpabuf_head(buf), wpabuf_len(buf));
154 int hs20_send_wnm_notification_deauth_req(struct hostapd_data *hapd,
156 const struct wpabuf *payload)
161 /* TODO: should refuse to send notification if the STA is not associated
162 * or if the STA did not indicate support for WNM-Notification */
164 buf = wpabuf_alloc(4 + 6 + wpabuf_len(payload));
168 wpabuf_put_u8(buf, WLAN_ACTION_WNM);
169 wpabuf_put_u8(buf, WNM_NOTIFICATION_REQ);
170 wpabuf_put_u8(buf, 1); /* Dialog token */
171 wpabuf_put_u8(buf, 1); /* Type - 1 reserved for WFA */
173 /* Deauthentication Imminent Notice subelement */
174 wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
175 wpabuf_put_u8(buf, 4 + wpabuf_len(payload));
176 wpabuf_put_be24(buf, OUI_WFA);
177 wpabuf_put_u8(buf, HS20_WNM_DEAUTH_IMMINENT_NOTICE);
178 wpabuf_put_buf(buf, payload);
180 ret = hostapd_drv_send_action(hapd, hapd->iface->freq, 0, addr,
181 wpabuf_head(buf), wpabuf_len(buf));
189 int hs20_send_wnm_notification_t_c(struct hostapd_data *hapd,
190 const u8 *addr, const char *url)
197 wpa_printf(MSG_INFO, "HS 2.0: No T&C Server URL available");
201 url_len = os_strlen(url);
202 if (5 + url_len > 255) {
204 "HS 2.0: Too long T&C Server URL for WNM-Notification: '%s'",
209 buf = wpabuf_alloc(4 + 7 + url_len);
213 wpabuf_put_u8(buf, WLAN_ACTION_WNM);
214 wpabuf_put_u8(buf, WNM_NOTIFICATION_REQ);
215 wpabuf_put_u8(buf, 1); /* Dialog token */
216 wpabuf_put_u8(buf, 1); /* Type - 1 reserved for WFA */
218 /* Terms and Conditions Acceptance subelement */
219 wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
220 wpabuf_put_u8(buf, 4 + 1 + url_len);
221 wpabuf_put_be24(buf, OUI_WFA);
222 wpabuf_put_u8(buf, HS20_WNM_T_C_ACCEPTANCE);
223 wpabuf_put_u8(buf, url_len);
224 wpabuf_put_str(buf, url);
226 ret = hostapd_drv_send_action(hapd, hapd->iface->freq, 0, addr,
227 wpabuf_head(buf), wpabuf_len(buf));
235 void hs20_t_c_filtering(struct hostapd_data *hapd, struct sta_info *sta,
239 wpa_printf(MSG_DEBUG,
240 "HS 2.0: Terms and Conditions filtering required for "
241 MACSTR, MAC2STR(sta->addr));
242 sta->hs20_t_c_filtering = 1;
243 /* TODO: Enable firewall filtering for the STA */
244 wpa_msg(hapd->msg_ctx, MSG_INFO, HS20_T_C_FILTERING_ADD MACSTR,
247 wpa_printf(MSG_DEBUG,
248 "HS 2.0: Terms and Conditions filtering not required for "
249 MACSTR, MAC2STR(sta->addr));
250 sta->hs20_t_c_filtering = 0;
251 /* TODO: Disable firewall filtering for the STA */
252 wpa_msg(hapd->msg_ctx, MSG_INFO,
253 HS20_T_C_FILTERING_REMOVE MACSTR, MAC2STR(sta->addr));