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 if (hapd
->conf
->ieee80211w
!= NO_MGMT_FRAME_PROTECTION
) {
84 capab
|= WPA_CAPABILITY_MFPC
;
85 if (hapd
->conf
->ieee80211w
== MGMT_FRAME_PROTECTION_REQUIRED
)
86 capab
|= WPA_CAPABILITY_MFPR
;
90 capab
|= WPA_CAPABILITY_OCVC
;
91 #endif /* CONFIG_OCV */
92 WPA_PUT_LE16(eid
, capab
);
101 int hs20_send_wnm_notification(struct hostapd_data
*hapd
, const u8
*addr
,
102 u8 osu_method
, const char *url
)
108 /* TODO: should refuse to send notification if the STA is not associated
109 * or if the STA did not indicate support for WNM-Notification */
112 len
= 1 + os_strlen(url
);
114 wpa_printf(MSG_INFO
, "HS 2.0: Too long URL for "
115 "WNM-Notification: '%s'", url
);
120 buf
= wpabuf_alloc(4 + 7 + len
);
124 wpabuf_put_u8(buf
, WLAN_ACTION_WNM
);
125 wpabuf_put_u8(buf
, WNM_NOTIFICATION_REQ
);
126 wpabuf_put_u8(buf
, 1); /* Dialog token */
127 wpabuf_put_u8(buf
, 1); /* Type - 1 reserved for WFA */
129 /* Subscription Remediation subelement */
130 wpabuf_put_u8(buf
, WLAN_EID_VENDOR_SPECIFIC
);
131 wpabuf_put_u8(buf
, 5 + len
);
132 wpabuf_put_be24(buf
, OUI_WFA
);
133 wpabuf_put_u8(buf
, HS20_WNM_SUB_REM_NEEDED
);
135 wpabuf_put_u8(buf
, len
- 1);
136 wpabuf_put_data(buf
, url
, len
- 1);
137 wpabuf_put_u8(buf
, osu_method
);
139 /* Server URL and Server Method fields not included */
140 wpabuf_put_u8(buf
, 0);
143 ret
= hostapd_drv_send_action(hapd
, hapd
->iface
->freq
, 0, addr
,
144 wpabuf_head(buf
), wpabuf_len(buf
));
152 int hs20_send_wnm_notification_deauth_req(struct hostapd_data
*hapd
,
154 const struct wpabuf
*payload
)
159 /* TODO: should refuse to send notification if the STA is not associated
160 * or if the STA did not indicate support for WNM-Notification */
162 buf
= wpabuf_alloc(4 + 6 + wpabuf_len(payload
));
166 wpabuf_put_u8(buf
, WLAN_ACTION_WNM
);
167 wpabuf_put_u8(buf
, WNM_NOTIFICATION_REQ
);
168 wpabuf_put_u8(buf
, 1); /* Dialog token */
169 wpabuf_put_u8(buf
, 1); /* Type - 1 reserved for WFA */
171 /* Deauthentication Imminent Notice subelement */
172 wpabuf_put_u8(buf
, WLAN_EID_VENDOR_SPECIFIC
);
173 wpabuf_put_u8(buf
, 4 + wpabuf_len(payload
));
174 wpabuf_put_be24(buf
, OUI_WFA
);
175 wpabuf_put_u8(buf
, HS20_WNM_DEAUTH_IMMINENT_NOTICE
);
176 wpabuf_put_buf(buf
, payload
);
178 ret
= hostapd_drv_send_action(hapd
, hapd
->iface
->freq
, 0, addr
,
179 wpabuf_head(buf
), wpabuf_len(buf
));
187 int hs20_send_wnm_notification_t_c(struct hostapd_data
*hapd
,
188 const u8
*addr
, const char *url
)
195 wpa_printf(MSG_INFO
, "HS 2.0: No T&C Server URL available");
199 url_len
= os_strlen(url
);
200 if (5 + url_len
> 255) {
202 "HS 2.0: Too long T&C Server URL for WNM-Notification: '%s'",
207 buf
= wpabuf_alloc(4 + 7 + url_len
);
211 wpabuf_put_u8(buf
, WLAN_ACTION_WNM
);
212 wpabuf_put_u8(buf
, WNM_NOTIFICATION_REQ
);
213 wpabuf_put_u8(buf
, 1); /* Dialog token */
214 wpabuf_put_u8(buf
, 1); /* Type - 1 reserved for WFA */
216 /* Terms and Conditions Acceptance subelement */
217 wpabuf_put_u8(buf
, WLAN_EID_VENDOR_SPECIFIC
);
218 wpabuf_put_u8(buf
, 4 + 1 + url_len
);
219 wpabuf_put_be24(buf
, OUI_WFA
);
220 wpabuf_put_u8(buf
, HS20_WNM_T_C_ACCEPTANCE
);
221 wpabuf_put_u8(buf
, url_len
);
222 wpabuf_put_str(buf
, url
);
224 ret
= hostapd_drv_send_action(hapd
, hapd
->iface
->freq
, 0, addr
,
225 wpabuf_head(buf
), wpabuf_len(buf
));
233 void hs20_t_c_filtering(struct hostapd_data
*hapd
, struct sta_info
*sta
,
237 wpa_printf(MSG_DEBUG
,
238 "HS 2.0: Terms and Conditions filtering required for "
239 MACSTR
, MAC2STR(sta
->addr
));
240 sta
->hs20_t_c_filtering
= 1;
241 /* TODO: Enable firewall filtering for the STA */
242 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, HS20_T_C_FILTERING_ADD MACSTR
,
245 wpa_printf(MSG_DEBUG
,
246 "HS 2.0: Terms and Conditions filtering not required for "
247 MACSTR
, MAC2STR(sta
->addr
));
248 sta
->hs20_t_c_filtering
= 0;
249 /* TODO: Disable firewall filtering for the STA */
250 wpa_msg(hapd
->msg_ctx
, MSG_INFO
,
251 HS20_T_C_FILTERING_REMOVE MACSTR
, MAC2STR(sta
->addr
));