From 19a8ad99443decc37b1729f0b309b2becbf7e36d Mon Sep 17 00:00:00 2001 From: Jay Katabathuni Date: Thu, 8 Sep 2011 20:52:23 +0300 Subject: [PATCH] HS 2.0: Add Hotspot 2.0 Indication for AP Signed-hostap: Jouni Malinen --- hostapd/Makefile | 1 + src/ap/ap_drv_ops.c | 15 +++++++++++++++ src/ap/beacon.c | 9 +++++++++ src/ap/hs20.c | 30 ++++++++++++++++++++++++++++++ src/ap/hs20.h | 16 ++++++++++++++++ wpa_supplicant/Makefile | 3 +++ 6 files changed, 74 insertions(+) create mode 100644 src/ap/hs20.c create mode 100644 src/ap/hs20.h diff --git a/hostapd/Makefile b/hostapd/Makefile index aed4b8905..d33a9a774 100644 --- a/hostapd/Makefile +++ b/hostapd/Makefile @@ -772,6 +772,7 @@ endif ifdef CONFIG_HS20 CFLAGS += -DCONFIG_HS20 +OBJS += ../src/ap/hs20.o CONFIG_INTERWORKING=y endif diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c index 859b529b4..36c000b86 100644 --- a/src/ap/ap_drv_ops.c +++ b/src/ap/ap_drv_ops.c @@ -17,6 +17,7 @@ #include "sta_info.h" #include "ap_config.h" #include "p2p_hostapd.h" +#include "hs20.h" #include "ap_drv_ops.h" @@ -147,6 +148,20 @@ int hostapd_build_ap_extra_ies(struct hostapd_data *hapd, } #endif /* CONFIG_P2P_MANAGER */ +#ifdef CONFIG_HS20 + pos = buf; + pos = hostapd_eid_hs20_indication(hapd, pos); + if (pos != buf) { + if (wpabuf_resize(&beacon, pos - buf) != 0) + goto fail; + wpabuf_put_data(beacon, buf, pos - buf); + + if (wpabuf_resize(&proberesp, pos - buf) != 0) + goto fail; + wpabuf_put_data(proberesp, buf, pos - buf); + } +#endif /* CONFIG_HS20 */ + *beacon_ret = beacon; *proberesp_ret = proberesp; *assocresp_ret = assocresp; diff --git a/src/ap/beacon.c b/src/ap/beacon.c index 0f29ccdb8..31dbcff0a 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -33,6 +33,7 @@ #include "p2p_hostapd.h" #include "ap_drv_ops.h" #include "beacon.h" +#include "hs20.h" #ifdef NEED_AP_MLME @@ -292,6 +293,10 @@ static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd, pos = hostapd_eid_p2p_manage(hapd, pos); #endif /* CONFIG_P2P_MANAGER */ +#ifdef CONFIG_HS20 + pos = hostapd_eid_hs20_indication(hapd, pos); +#endif /* CONFIG_HS20 */ + *resp_len = pos - (u8 *) resp; return (u8 *) resp; } @@ -629,6 +634,10 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd) tailpos = hostapd_eid_p2p_manage(hapd, tailpos); #endif /* CONFIG_P2P_MANAGER */ +#ifdef CONFIG_HS20 + tailpos = hostapd_eid_hs20_indication(hapd, tailpos); +#endif /* CONFIG_HS20 */ + tail_len = tailpos > tail ? tailpos - tail : 0; resp = hostapd_probe_resp_offloads(hapd, &resp_len); diff --git a/src/ap/hs20.c b/src/ap/hs20.c new file mode 100644 index 000000000..c99db5809 --- /dev/null +++ b/src/ap/hs20.c @@ -0,0 +1,30 @@ +/* + * Hotspot 2.0 AP ANQP processing + * Copyright (c) 2009, Atheros Communications, Inc. + * Copyright (c) 2011-2012, Qualcomm Atheros, Inc. + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#include "includes.h" + +#include "common.h" +#include "common/ieee802_11_defs.h" +#include "hostapd.h" +#include "ap_config.h" +#include "hs20.h" + + +u8 * hostapd_eid_hs20_indication(struct hostapd_data *hapd, u8 *eid) +{ + if (!hapd->conf->hs20) + return eid; + *eid++ = WLAN_EID_VENDOR_SPECIFIC; + *eid++ = 5; + WPA_PUT_BE24(eid, OUI_WFA); + eid += 3; + *eid++ = HS20_INDICATION_OUI_TYPE; + *eid++ = 0x00; /* Hotspot Configuration: DGAF Enabled */ + return eid; +} diff --git a/src/ap/hs20.h b/src/ap/hs20.h new file mode 100644 index 000000000..98698ce2f --- /dev/null +++ b/src/ap/hs20.h @@ -0,0 +1,16 @@ +/* + * Hotspot 2.0 AP ANQP processing + * Copyright (c) 2011-2012, Qualcomm Atheros, Inc. + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#ifndef HS20_H +#define HS20_H + +struct hostapd_data; + +u8 * hostapd_eid_hs20_indication(struct hostapd_data *hapd, u8 *eid); + +#endif /* HS20_H */ diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile index 6756e54ef..73a339d16 100644 --- a/wpa_supplicant/Makefile +++ b/wpa_supplicant/Makefile @@ -741,6 +741,9 @@ endif ifdef CONFIG_INTERWORKING OBJS += ../src/ap/gas_serv.o endif +ifdef CONFIG_HS20 +OBJS += ../src/ap/hs20.o +endif endif ifdef NEED_RSN_AUTHENTICATOR