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;
29 WPA_PUT_BE24(eid, OUI_WFA);
31 *eid++ = HS20_INDICATION_OUI_TYPE;
32 conf = HS20_VERSION; /* Release Number */
33 conf |= HS20_ANQP_DOMAIN_ID_PRESENT;
34 if (hapd->conf->disable_dgaf)
35 conf |= HS20_DGAF_DISABLED;
37 WPA_PUT_LE16(eid, hapd->conf->anqp_domain_id);
44 u8 * hostapd_eid_osen(struct hostapd_data *hapd, u8 *eid)
49 if (!hapd->conf->osen)
52 *eid++ = WLAN_EID_VENDOR_SPECIFIC;
53 len = eid++; /* to be filled */
54 WPA_PUT_BE24(eid, OUI_WFA);
56 *eid++ = HS20_OSEN_OUI_TYPE;
58 /* Group Data Cipher Suite */
59 RSN_SELECTOR_PUT(eid, RSN_CIPHER_SUITE_NO_GROUP_ADDRESSED);
60 eid += RSN_SELECTOR_LEN;
62 /* Pairwise Cipher Suite Count and List */
65 RSN_SELECTOR_PUT(eid, RSN_CIPHER_SUITE_CCMP);
66 eid += RSN_SELECTOR_LEN;
68 /* AKM Suite Count and List */
71 RSN_SELECTOR_PUT(eid, RSN_AUTH_KEY_MGMT_OSEN);
72 eid += RSN_SELECTOR_LEN;
74 /* RSN Capabilities */
76 if (hapd->conf->wmm_enabled) {
77 /* 4 PTKSA replay counters when using WMM */
78 capab |= (RSN_NUM_REPLAY_COUNTERS_16 << 2);
80 #ifdef CONFIG_IEEE80211W
81 if (hapd->conf->ieee80211w != NO_MGMT_FRAME_PROTECTION) {
82 capab |= WPA_CAPABILITY_MFPC;
83 if (hapd->conf->ieee80211w == MGMT_FRAME_PROTECTION_REQUIRED)
84 capab |= WPA_CAPABILITY_MFPR;
86 #endif /* CONFIG_IEEE80211W */
87 WPA_PUT_LE16(eid, capab);
96 int hs20_send_wnm_notification(struct hostapd_data *hapd, const u8 *addr,
97 u8 osu_method, const char *url)
103 /* TODO: should refuse to send notification if the STA is not associated
104 * or if the STA did not indicate support for WNM-Notification */
107 len = 1 + os_strlen(url);
109 wpa_printf(MSG_INFO, "HS 2.0: Too long URL for "
110 "WNM-Notification: '%s'", url);
115 buf = wpabuf_alloc(4 + 7 + len);
119 wpabuf_put_u8(buf, WLAN_ACTION_WNM);
120 wpabuf_put_u8(buf, WNM_NOTIFICATION_REQ);
121 wpabuf_put_u8(buf, 1); /* Dialog token */
122 wpabuf_put_u8(buf, 1); /* Type - 1 reserved for WFA */
124 /* Subscription Remediation subelement */
125 wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
126 wpabuf_put_u8(buf, 5 + len);
127 wpabuf_put_be24(buf, OUI_WFA);
128 wpabuf_put_u8(buf, HS20_WNM_SUB_REM_NEEDED);
130 wpabuf_put_u8(buf, len - 1);
131 wpabuf_put_data(buf, url, len - 1);
132 wpabuf_put_u8(buf, osu_method);
134 /* Server URL and Server Method fields not included */
135 wpabuf_put_u8(buf, 0);
138 ret = hostapd_drv_send_action(hapd, hapd->iface->freq, 0, addr,
139 wpabuf_head(buf), wpabuf_len(buf));
147 int hs20_send_wnm_notification_deauth_req(struct hostapd_data *hapd,
149 const struct wpabuf *payload)
154 /* TODO: should refuse to send notification if the STA is not associated
155 * or if the STA did not indicate support for WNM-Notification */
157 buf = wpabuf_alloc(4 + 6 + wpabuf_len(payload));
161 wpabuf_put_u8(buf, WLAN_ACTION_WNM);
162 wpabuf_put_u8(buf, WNM_NOTIFICATION_REQ);
163 wpabuf_put_u8(buf, 1); /* Dialog token */
164 wpabuf_put_u8(buf, 1); /* Type - 1 reserved for WFA */
166 /* Deauthentication Imminent Notice subelement */
167 wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
168 wpabuf_put_u8(buf, 4 + wpabuf_len(payload));
169 wpabuf_put_be24(buf, OUI_WFA);
170 wpabuf_put_u8(buf, HS20_WNM_DEAUTH_IMMINENT_NOTICE);
171 wpabuf_put_buf(buf, payload);
173 ret = hostapd_drv_send_action(hapd, hapd->iface->freq, 0, addr,
174 wpabuf_head(buf), wpabuf_len(buf));
182 int hs20_send_wnm_notification_t_c(struct hostapd_data *hapd,
183 const u8 *addr, const char *url)
190 wpa_printf(MSG_INFO, "HS 2.0: No T&C Server URL available");
194 url_len = os_strlen(url);
195 if (5 + url_len > 255) {
197 "HS 2.0: Too long T&C Server URL for WNM-Notification: '%s'",
202 buf = wpabuf_alloc(4 + 7 + url_len);
206 wpabuf_put_u8(buf, WLAN_ACTION_WNM);
207 wpabuf_put_u8(buf, WNM_NOTIFICATION_REQ);
208 wpabuf_put_u8(buf, 1); /* Dialog token */
209 wpabuf_put_u8(buf, 1); /* Type - 1 reserved for WFA */
211 /* Terms and Conditions Acceptance subelement */
212 wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
213 wpabuf_put_u8(buf, 4 + 1 + url_len);
214 wpabuf_put_be24(buf, OUI_WFA);
215 wpabuf_put_u8(buf, HS20_WNM_T_C_ACCEPTANCE);
216 wpabuf_put_u8(buf, url_len);
217 wpabuf_put_str(buf, url);
219 ret = hostapd_drv_send_action(hapd, hapd->iface->freq, 0, addr,
220 wpabuf_head(buf), wpabuf_len(buf));
228 void hs20_t_c_filtering(struct hostapd_data *hapd, struct sta_info *sta,
232 wpa_printf(MSG_DEBUG,
233 "HS 2.0: Terms and Conditions filtering required for "
234 MACSTR, MAC2STR(sta->addr));
235 sta->hs20_t_c_filtering = 1;
236 /* TODO: Enable firewall filtering for the STA */
237 wpa_msg(hapd->msg_ctx, MSG_INFO, HS20_T_C_FILTERING_ADD MACSTR,
240 wpa_printf(MSG_DEBUG,
241 "HS 2.0: Terms and Conditions filtering not required for "
242 MACSTR, MAC2STR(sta->addr));
243 sta->hs20_t_c_filtering = 0;
244 /* TODO: Disable firewall filtering for the STA */
245 wpa_msg(hapd->msg_ctx, MSG_INFO,
246 HS20_T_C_FILTERING_REMOVE MACSTR, MAC2STR(sta->addr));