Interworking: Add GAS server support for AP mode

This adds GAS/ANQP implementation into hostapd. This commit brings in
the basic GAS/ANQP functionality, but only the ANQP Capability List
element is supported.

For testing purposes, hostapd control interface SET command can be used
to set the gas_frag_limit parameter dynamically.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jay Katabathuni 2012-02-26 22:34:19 +02:00 committed by Jouni Malinen
parent fb80e86e7d
commit dca30c3fb7
10 changed files with 722 additions and 1 deletions

View file

@ -759,6 +759,8 @@ endif
ifdef CONFIG_INTERWORKING ifdef CONFIG_INTERWORKING
CFLAGS += -DCONFIG_INTERWORKING CFLAGS += -DCONFIG_INTERWORKING
OBJS += ../src/common/gas.o
OBJS += ../src/ap/gas_serv.o
endif endif
OBJS += ../src/drivers/driver_common.o OBJS += ../src/drivers/driver_common.o

View file

@ -2113,6 +2113,10 @@ static int hostapd_config_fill(struct hostapd_config *conf,
} else if (os_strcmp(buf, "roaming_consortium") == 0) { } else if (os_strcmp(buf, "roaming_consortium") == 0) {
if (parse_roaming_consortium(bss, pos, line) < 0) if (parse_roaming_consortium(bss, pos, line) < 0)
errors++; errors++;
} else if (os_strcmp(buf, "gas_frag_limit") == 0) {
bss->gas_frag_limit = atoi(pos);
} else if (os_strcmp(buf, "gas_comeback_delay") == 0) {
bss->gas_comeback_delay = atoi(pos);
#endif /* CONFIG_INTERWORKING */ #endif /* CONFIG_INTERWORKING */
#ifdef CONFIG_RADIUS_TEST #ifdef CONFIG_RADIUS_TEST
} else if (os_strcmp(buf, "dump_msk_file") == 0) { } else if (os_strcmp(buf, "dump_msk_file") == 0) {

View file

@ -607,6 +607,14 @@ static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd)
wpa_printf(MSG_DEBUG, "WPS: Testing - dummy_cred=%d", wpa_printf(MSG_DEBUG, "WPS: Testing - dummy_cred=%d",
wps_testing_dummy_cred); wps_testing_dummy_cred);
#endif /* CONFIG_WPS_TESTING */ #endif /* CONFIG_WPS_TESTING */
#ifdef CONFIG_INTERWORKING
} else if (os_strcasecmp(cmd, "gas_frag_limit") == 0) {
int val = atoi(value);
if (val <= 0)
ret = -1;
else
hapd->gas_frag_limit = val;
#endif /* CONFIG_INTERWORKING */
} else { } else {
ret = hostapd_set_iface(hapd->iconf, hapd->conf, cmd, value); ret = hostapd_set_iface(hapd->iconf, hapd->conf, cmd, value);
} }

View file

@ -361,6 +361,9 @@ struct hostapd_bss_config {
unsigned int roaming_consortium_count; unsigned int roaming_consortium_count;
struct hostapd_roaming_consortium *roaming_consortium; struct hostapd_roaming_consortium *roaming_consortium;
u16 gas_comeback_delay;
int gas_frag_limit;
u8 wps_rf_bands; /* RF bands for WPS (WPS_RF_*) */ u8 wps_rf_bands; /* RF bands for WPS (WPS_RF_*) */
#ifdef CONFIG_RADIUS_TEST #ifdef CONFIG_RADIUS_TEST

621
src/ap/gas_serv.c Normal file
View file

@ -0,0 +1,621 @@
/*
* Generic advertisement service (GAS) server
* 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 "common/gas.h"
#include "utils/eloop.h"
#include "hostapd.h"
#include "ap_config.h"
#include "ap_drv_ops.h"
#include "sta_info.h"
#include "gas_serv.h"
static struct gas_dialog_info *
gas_dialog_create(struct hostapd_data *hapd, const u8 *addr, u8 dialog_token)
{
struct sta_info *sta;
struct gas_dialog_info *dia = NULL;
int i, j;
sta = ap_get_sta(hapd, addr);
if (!sta) {
/*
* We need a STA entry to be able to maintain state for
* the GAS query.
*/
wpa_printf(MSG_DEBUG, "ANQP: Add a temporary STA entry for "
"GAS query");
sta = ap_sta_add(hapd, addr);
if (!sta) {
wpa_printf(MSG_DEBUG, "Failed to add STA " MACSTR
" for GAS query", MAC2STR(addr));
return NULL;
}
sta->flags |= WLAN_STA_GAS;
/*
* The default inactivity is 300 seconds. We don't need
* it to be that long.
*/
ap_sta_session_timeout(hapd, sta, 5);
}
if (sta->gas_dialog == NULL) {
sta->gas_dialog = os_zalloc(GAS_DIALOG_MAX *
sizeof(struct gas_dialog_info));
if (sta->gas_dialog == NULL)
return NULL;
}
for (i = sta->gas_dialog_next, j = 0; j < GAS_DIALOG_MAX; i++, j++) {
if (i == GAS_DIALOG_MAX)
i = 0;
if (sta->gas_dialog[i].valid)
continue;
dia = &sta->gas_dialog[i];
dia->valid = 1;
dia->index = i;
dia->dialog_token = dialog_token;
sta->gas_dialog_next = (++i == GAS_DIALOG_MAX) ? 0 : i;
return dia;
}
wpa_msg(hapd->msg_ctx, MSG_ERROR, "ANQP: Could not create dialog for "
MACSTR " dialog_token %u. Consider increasing "
"GAS_DIALOG_MAX.", MAC2STR(addr), dialog_token);
return NULL;
}
struct gas_dialog_info *
gas_serv_dialog_find(struct hostapd_data *hapd, const u8 *addr,
u8 dialog_token)
{
struct sta_info *sta;
int i;
sta = ap_get_sta(hapd, addr);
if (!sta) {
wpa_printf(MSG_DEBUG, "ANQP: could not find STA " MACSTR,
MAC2STR(addr));
return NULL;
}
for (i = 0; sta->gas_dialog && i < GAS_DIALOG_MAX; i++) {
if (sta->gas_dialog[i].dialog_token != dialog_token ||
!sta->gas_dialog[i].valid)
continue;
return &sta->gas_dialog[i];
}
wpa_printf(MSG_DEBUG, "ANQP: Could not find dialog for "
MACSTR " dialog_token %u", MAC2STR(addr), dialog_token);
return NULL;
}
void gas_serv_dialog_clear(struct gas_dialog_info *dia)
{
wpabuf_free(dia->sd_resp);
os_memset(dia, 0, sizeof(*dia));
}
static void gas_serv_free_dialogs(struct hostapd_data *hapd,
const u8 *sta_addr)
{
struct sta_info *sta;
int i;
sta = ap_get_sta(hapd, sta_addr);
if (sta == NULL || sta->gas_dialog == NULL)
return;
for (i = 0; i < GAS_DIALOG_MAX; i++) {
if (sta->gas_dialog[i].valid)
return;
}
os_free(sta->gas_dialog);
sta->gas_dialog = NULL;
}
static void anqp_add_capab_list(struct hostapd_data *hapd,
struct wpabuf *buf)
{
u8 *len;
len = gas_anqp_add_element(buf, ANQP_CAPABILITY_LIST);
wpabuf_put_le16(buf, ANQP_CAPABILITY_LIST);
gas_anqp_set_element_len(buf, len);
}
static struct wpabuf *
gas_serv_build_gas_resp_payload(struct hostapd_data *hapd,
unsigned int request,
struct gas_dialog_info *di)
{
struct wpabuf *buf;
buf = wpabuf_alloc(1400);
if (buf == NULL)
return NULL;
if (request & ANQP_REQ_CAPABILITY_LIST)
anqp_add_capab_list(hapd, buf);
return buf;
}
static void gas_serv_clear_cached_ies(void *eloop_data, void *user_ctx)
{
struct gas_dialog_info *dia = eloop_data;
wpa_printf(MSG_DEBUG, "GAS: Timeout triggered, clearing dialog for "
"dialog token %d", dia->dialog_token);
gas_serv_dialog_clear(dia);
}
struct anqp_query_info {
unsigned int request;
unsigned int remote_request;
const void *param;
u32 param_arg;
u16 remote_delay;
};
static void set_anqp_req(unsigned int bit, const char *name, int local,
unsigned int remote, u16 remote_delay,
struct anqp_query_info *qi)
{
qi->request |= bit;
if (local) {
wpa_printf(MSG_DEBUG, "ANQP: %s (local)", name);
} else if (bit & remote) {
wpa_printf(MSG_DEBUG, "ANQP: %s (remote)", name);
qi->remote_request |= bit;
if (remote_delay > qi->remote_delay)
qi->remote_delay = remote_delay;
} else {
wpa_printf(MSG_DEBUG, "ANQP: %s not available", name);
}
}
static void rx_anqp_query_list_id(struct hostapd_data *hapd, u16 info_id,
struct anqp_query_info *qi)
{
switch (info_id) {
case ANQP_CAPABILITY_LIST:
set_anqp_req(ANQP_REQ_CAPABILITY_LIST, "Capability List", 1, 0,
0, qi);
break;
default:
wpa_printf(MSG_DEBUG, "ANQP: Unsupported Info Id %u",
info_id);
break;
}
}
static void rx_anqp_query_list(struct hostapd_data *hapd,
const u8 *pos, const u8 *end,
struct anqp_query_info *qi)
{
wpa_printf(MSG_DEBUG, "ANQP: %u Info IDs requested in Query list",
(unsigned int) (end - pos) / 2);
while (pos + 2 <= end) {
rx_anqp_query_list_id(hapd, WPA_GET_LE16(pos), qi);
pos += 2;
}
}
static void gas_serv_req_local_processing(struct hostapd_data *hapd,
const u8 *sa, u8 dialog_token,
struct anqp_query_info *qi)
{
struct wpabuf *buf, *tx_buf;
buf = gas_serv_build_gas_resp_payload(hapd, qi->request, NULL);
wpa_hexdump_buf(MSG_MSGDUMP, "ANQP: Locally generated ANQP responses",
buf);
if (!buf)
return;
if (wpabuf_len(buf) > hapd->gas_frag_limit ||
hapd->conf->gas_comeback_delay) {
struct gas_dialog_info *di;
u16 comeback_delay = 1;
if (hapd->conf->gas_comeback_delay) {
/* Testing - allow overriding of the delay value */
comeback_delay = hapd->conf->gas_comeback_delay;
}
wpa_printf(MSG_DEBUG, "ANQP: Too long response to fit in "
"initial response - use GAS comeback");
di = gas_dialog_create(hapd, sa, dialog_token);
if (!di) {
wpa_printf(MSG_INFO, "ANQP: Could not create dialog "
"for " MACSTR " (dialog token %u)",
MAC2STR(sa), dialog_token);
wpabuf_free(buf);
return;
}
di->sd_resp = buf;
di->sd_resp_pos = 0;
tx_buf = gas_anqp_build_initial_resp_buf(
dialog_token, WLAN_STATUS_SUCCESS, comeback_delay,
NULL);
} else {
wpa_printf(MSG_DEBUG, "ANQP: Initial response (no comeback)");
tx_buf = gas_anqp_build_initial_resp_buf(
dialog_token, WLAN_STATUS_SUCCESS, 0, buf);
wpabuf_free(buf);
}
if (!tx_buf)
return;
hostapd_drv_send_action(hapd, hapd->iface->freq, 0, sa,
wpabuf_head(tx_buf), wpabuf_len(tx_buf));
wpabuf_free(tx_buf);
}
static void gas_serv_rx_gas_initial_req(struct hostapd_data *hapd,
const u8 *sa,
const u8 *data, size_t len)
{
const u8 *pos = data;
const u8 *end = data + len;
const u8 *next;
u8 dialog_token;
u16 slen;
struct anqp_query_info qi;
const u8 *adv_proto;
if (len < 1 + 2)
return;
os_memset(&qi, 0, sizeof(qi));
dialog_token = *pos++;
wpa_msg(hapd->msg_ctx, MSG_DEBUG,
"GAS: GAS Initial Request from " MACSTR " (dialog token %u) ",
MAC2STR(sa), dialog_token);
if (*pos != WLAN_EID_ADV_PROTO) {
wpa_msg(hapd->msg_ctx, MSG_DEBUG,
"GAS: Unexpected IE in GAS Initial Request: %u", *pos);
return;
}
adv_proto = pos++;
slen = *pos++;
next = pos + slen;
if (next > end || slen < 2) {
wpa_msg(hapd->msg_ctx, MSG_DEBUG,
"GAS: Invalid IE in GAS Initial Request");
return;
}
pos++; /* skip QueryRespLenLimit and PAME-BI */
if (*pos != ACCESS_NETWORK_QUERY_PROTOCOL) {
struct wpabuf *buf;
wpa_msg(hapd->msg_ctx, MSG_DEBUG,
"GAS: Unsupported GAS advertisement protocol id %u",
*pos);
if (sa[0] & 0x01)
return; /* Invalid source address - drop silently */
buf = gas_build_initial_resp(
dialog_token, WLAN_STATUS_GAS_ADV_PROTO_NOT_SUPPORTED,
0, 2 + slen + 2);
if (buf == NULL)
return;
wpabuf_put_data(buf, adv_proto, 2 + slen);
wpabuf_put_le16(buf, 0); /* Query Response Length */
hostapd_drv_send_action(hapd, hapd->iface->freq, 0, sa,
wpabuf_head(buf), wpabuf_len(buf));
wpabuf_free(buf);
return;
}
pos = next;
/* Query Request */
if (pos + 2 > end)
return;
slen = WPA_GET_LE16(pos);
pos += 2;
if (pos + slen > end)
return;
end = pos + slen;
/* ANQP Query Request */
while (pos < end) {
u16 info_id, elen;
if (pos + 4 > end)
return;
info_id = WPA_GET_LE16(pos);
pos += 2;
elen = WPA_GET_LE16(pos);
pos += 2;
if (pos + elen > end) {
wpa_printf(MSG_DEBUG, "ANQP: Invalid Query Request");
return;
}
switch (info_id) {
case ANQP_QUERY_LIST:
rx_anqp_query_list(hapd, pos, pos + elen, &qi);
break;
default:
wpa_printf(MSG_DEBUG, "ANQP: Unsupported Query "
"Request element %u", info_id);
break;
}
pos += elen;
}
gas_serv_req_local_processing(hapd, sa, dialog_token, &qi);
}
void gas_serv_tx_gas_response(struct hostapd_data *hapd, const u8 *dst,
struct gas_dialog_info *dialog)
{
struct wpabuf *buf, *tx_buf;
u8 dialog_token = dialog->dialog_token;
size_t frag_len;
if (dialog->sd_resp == NULL) {
buf = gas_serv_build_gas_resp_payload(hapd,
dialog->all_requested,
dialog);
wpa_hexdump_buf(MSG_MSGDUMP, "ANQP: Generated ANQP responses",
buf);
if (!buf)
goto tx_gas_response_done;
dialog->sd_resp = buf;
dialog->sd_resp_pos = 0;
}
frag_len = wpabuf_len(dialog->sd_resp) - dialog->sd_resp_pos;
if (frag_len > hapd->gas_frag_limit || dialog->comeback_delay ||
hapd->conf->gas_comeback_delay) {
u16 comeback_delay_tus = dialog->comeback_delay +
GAS_SERV_COMEBACK_DELAY_FUDGE;
u32 comeback_delay_secs, comeback_delay_usecs;
if (hapd->conf->gas_comeback_delay) {
/* Testing - allow overriding of the delay value */
comeback_delay_tus = hapd->conf->gas_comeback_delay;
}
wpa_printf(MSG_DEBUG, "GAS: Response frag_len %u (frag limit "
"%u) and comeback delay %u, "
"requesting comebacks", (unsigned int) frag_len,
(unsigned int) hapd->gas_frag_limit,
dialog->comeback_delay);
tx_buf = gas_anqp_build_initial_resp_buf(dialog_token,
WLAN_STATUS_SUCCESS,
comeback_delay_tus,
NULL);
if (tx_buf) {
wpa_msg(hapd->msg_ctx, MSG_DEBUG,
"GAS: Tx GAS Initial Resp (comeback = 10TU)");
hostapd_drv_send_action(hapd, hapd->iface->freq, 0,
dst,
wpabuf_head(tx_buf),
wpabuf_len(tx_buf));
}
wpabuf_free(tx_buf);
/* start a timer of 1.5 * comeback-delay */
comeback_delay_tus = comeback_delay_tus +
(comeback_delay_tus / 2);
comeback_delay_secs = (comeback_delay_tus * 1024) / 1000000;
comeback_delay_usecs = (comeback_delay_tus * 1024) -
(comeback_delay_secs * 1000000);
eloop_register_timeout(comeback_delay_secs,
comeback_delay_usecs,
gas_serv_clear_cached_ies, dialog,
NULL);
goto tx_gas_response_done;
}
buf = wpabuf_alloc_copy(wpabuf_head_u8(dialog->sd_resp) +
dialog->sd_resp_pos, frag_len);
if (buf == NULL) {
wpa_msg(hapd->msg_ctx, MSG_DEBUG, "GAS: Buffer allocation "
"failed");
goto tx_gas_response_done;
}
tx_buf = gas_anqp_build_initial_resp_buf(dialog_token,
WLAN_STATUS_SUCCESS, 0, buf);
wpabuf_free(buf);
if (tx_buf == NULL)
goto tx_gas_response_done;
wpa_msg(hapd->msg_ctx, MSG_DEBUG, "GAS: Tx GAS Initial "
"Response (frag_id %d frag_len %d)",
dialog->sd_frag_id, (int) frag_len);
dialog->sd_frag_id++;
hostapd_drv_send_action(hapd, hapd->iface->freq, 0, dst,
wpabuf_head(tx_buf), wpabuf_len(tx_buf));
wpabuf_free(tx_buf);
tx_gas_response_done:
gas_serv_clear_cached_ies(dialog, NULL);
}
static void gas_serv_rx_gas_comeback_req(struct hostapd_data *hapd,
const u8 *sa,
const u8 *data, size_t len)
{
struct gas_dialog_info *dialog;
struct wpabuf *buf, *tx_buf;
u8 dialog_token;
size_t frag_len;
int more = 0;
wpa_hexdump(MSG_DEBUG, "GAS: RX GAS Comeback Request", data, len);
if (len < 1)
return;
dialog_token = *data;
wpa_msg(hapd->msg_ctx, MSG_DEBUG, "GAS: Dialog Token: %u",
dialog_token);
dialog = gas_serv_dialog_find(hapd, sa, dialog_token);
if (!dialog) {
wpa_msg(hapd->msg_ctx, MSG_DEBUG, "GAS: No pending SD "
"response fragment for " MACSTR " dialog token %u",
MAC2STR(sa), dialog_token);
if (sa[0] & 0x01)
return; /* Invalid source address - drop silently */
tx_buf = gas_anqp_build_comeback_resp_buf(
dialog_token, WLAN_STATUS_NO_OUTSTANDING_GAS_REQ, 0, 0,
0, NULL);
if (tx_buf == NULL)
return;
goto send_resp;
}
if (dialog->sd_resp == NULL) {
wpa_printf(MSG_DEBUG, "GAS: Remote request 0x%x received 0x%x",
dialog->requested, dialog->received);
if ((dialog->requested & dialog->received) !=
dialog->requested) {
wpa_printf(MSG_DEBUG, "GAS: Did not receive response "
"from remote processing");
gas_serv_dialog_clear(dialog);
tx_buf = gas_anqp_build_comeback_resp_buf(
dialog_token,
WLAN_STATUS_GAS_RESP_NOT_RECEIVED, 0, 0, 0,
NULL);
if (tx_buf == NULL)
return;
goto send_resp;
}
buf = gas_serv_build_gas_resp_payload(hapd,
dialog->all_requested,
dialog);
wpa_hexdump_buf(MSG_MSGDUMP, "ANQP: Generated ANQP responses",
buf);
if (!buf)
goto rx_gas_comeback_req_done;
dialog->sd_resp = buf;
dialog->sd_resp_pos = 0;
}
frag_len = wpabuf_len(dialog->sd_resp) - dialog->sd_resp_pos;
if (frag_len > hapd->gas_frag_limit) {
frag_len = hapd->gas_frag_limit;
more = 1;
}
wpa_msg(hapd->msg_ctx, MSG_DEBUG, "GAS: resp frag_len %u",
(unsigned int) frag_len);
buf = wpabuf_alloc_copy(wpabuf_head_u8(dialog->sd_resp) +
dialog->sd_resp_pos, frag_len);
if (buf == NULL) {
wpa_msg(hapd->msg_ctx, MSG_DEBUG, "GAS: Failed to allocate "
"buffer");
goto rx_gas_comeback_req_done;
}
tx_buf = gas_anqp_build_comeback_resp_buf(dialog_token,
WLAN_STATUS_SUCCESS,
dialog->sd_frag_id,
more, 0, buf);
wpabuf_free(buf);
if (tx_buf == NULL)
goto rx_gas_comeback_req_done;
wpa_msg(hapd->msg_ctx, MSG_DEBUG, "GAS: Tx GAS Comeback Response "
"(frag_id %d more=%d frag_len=%d)",
dialog->sd_frag_id, more, (int) frag_len);
dialog->sd_frag_id++;
dialog->sd_resp_pos += frag_len;
if (more) {
wpa_msg(hapd->msg_ctx, MSG_DEBUG, "GAS: %d more bytes remain "
"to be sent",
(int) (wpabuf_len(dialog->sd_resp) -
dialog->sd_resp_pos));
} else {
wpa_msg(hapd->msg_ctx, MSG_DEBUG, "GAS: All fragments of "
"SD response sent");
gas_serv_dialog_clear(dialog);
gas_serv_free_dialogs(hapd, sa);
}
send_resp:
hostapd_drv_send_action(hapd, hapd->iface->freq, 0, sa,
wpabuf_head(tx_buf), wpabuf_len(tx_buf));
wpabuf_free(tx_buf);
return;
rx_gas_comeback_req_done:
gas_serv_clear_cached_ies(dialog, NULL);
}
static void gas_serv_rx_public_action(void *ctx, const u8 *buf, size_t len,
int freq)
{
struct hostapd_data *hapd = ctx;
const struct ieee80211_mgmt *mgmt;
size_t hdr_len;
const u8 *sa, *bssid, *data;
mgmt = (const struct ieee80211_mgmt *) buf;
hdr_len = (const u8 *) &mgmt->u.action.u.vs_public_action.action - buf;
if (hdr_len > len)
return;
if (mgmt->u.action.category != WLAN_ACTION_PUBLIC)
return;
sa = mgmt->sa;
bssid = mgmt->bssid;
len -= hdr_len;
data = &mgmt->u.action.u.public_action.action;
switch (data[0]) {
case WLAN_PA_GAS_INITIAL_REQ:
gas_serv_rx_gas_initial_req(hapd, sa, data + 1, len - 1);
break;
case WLAN_PA_GAS_COMEBACK_REQ:
gas_serv_rx_gas_comeback_req(hapd, sa, data + 1, len - 1);
break;
}
}
int gas_serv_init(struct hostapd_data *hapd)
{
hapd->public_action_cb = gas_serv_rx_public_action;
hapd->public_action_cb_ctx = hapd;
hapd->gas_frag_limit = 1400;
if (hapd->conf->gas_frag_limit > 0)
hapd->gas_frag_limit = hapd->conf->gas_frag_limit;
return 0;
}
void gas_serv_deinit(struct hostapd_data *hapd)
{
}

45
src/ap/gas_serv.h Normal file
View file

@ -0,0 +1,45 @@
/*
* Generic advertisement service (GAS) server
* 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 GAS_SERV_H
#define GAS_SERV_H
#define ANQP_REQ_CAPABILITY_LIST \
(1 << (ANQP_CAPABILITY_LIST - ANQP_QUERY_LIST))
/* To account for latencies between hostapd and external ANQP processor */
#define GAS_SERV_COMEBACK_DELAY_FUDGE 10
#define GAS_SERV_MIN_COMEBACK_DELAY 100 /* in TU */
struct gas_dialog_info {
u8 valid;
u8 index;
struct wpabuf *sd_resp; /* Fragmented response */
u8 dialog_token;
size_t sd_resp_pos; /* Offset in sd_resp */
u8 sd_frag_id;
u16 comeback_delay;
unsigned int requested;
unsigned int received;
unsigned int all_requested;
};
struct hostapd_data;
void gas_serv_tx_gas_response(struct hostapd_data *hapd, const u8 *dst,
struct gas_dialog_info *dialog);
struct gas_dialog_info *
gas_serv_dialog_find(struct hostapd_data *hapd, const u8 *addr,
u8 dialog_token);
void gas_serv_dialog_clear(struct gas_dialog_info *dialog);
int gas_serv_init(struct hostapd_data *hapd);
void gas_serv_deinit(struct hostapd_data *hapd);
#endif /* GAS_SERV_H */

View file

@ -30,6 +30,7 @@
#include "ap_drv_ops.h" #include "ap_drv_ops.h"
#include "ap_config.h" #include "ap_config.h"
#include "p2p_hostapd.h" #include "p2p_hostapd.h"
#include "gas_serv.h"
static int hostapd_flush_old_stations(struct hostapd_data *hapd); static int hostapd_flush_old_stations(struct hostapd_data *hapd);
@ -262,6 +263,10 @@ static void hostapd_free_hapd_data(struct hostapd_data *hapd)
#endif /* CONFIG_P2P */ #endif /* CONFIG_P2P */
wpabuf_free(hapd->time_adv); wpabuf_free(hapd->time_adv);
#ifdef CONFIG_INTERWORKING
gas_serv_deinit(hapd);
#endif /* CONFIG_INTERWORKING */
} }
@ -653,6 +658,13 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
return -1; return -1;
} }
#ifdef CONFIG_INTERWORKING
if (gas_serv_init(hapd)) {
wpa_printf(MSG_ERROR, "GAS server initialization failed");
return -1;
}
#endif /* CONFIG_INTERWORKING */
if (hapd->iface->ctrl_iface_init && if (hapd->iface->ctrl_iface_init &&
hapd->iface->ctrl_iface_init(hapd)) { hapd->iface->ctrl_iface_init(hapd)) {
wpa_printf(MSG_ERROR, "Failed to setup control interface"); wpa_printf(MSG_ERROR, "Failed to setup control interface");

View file

@ -169,6 +169,9 @@ struct hostapd_data {
int noa_start; int noa_start;
int noa_duration; int noa_duration;
#endif /* CONFIG_P2P */ #endif /* CONFIG_P2P */
#ifdef CONFIG_INTERWORKING
size_t gas_frag_limit;
#endif /* CONFIG_INTERWORKING */
}; };

View file

@ -28,6 +28,7 @@
#include "vlan_init.h" #include "vlan_init.h"
#include "p2p_hostapd.h" #include "p2p_hostapd.h"
#include "ap_drv_ops.h" #include "ap_drv_ops.h"
#include "gas_serv.h"
#include "sta_info.h" #include "sta_info.h"
static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd, static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd,
@ -218,6 +219,15 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
p2p_group_notif_disassoc(hapd->p2p_group, sta->addr); p2p_group_notif_disassoc(hapd->p2p_group, sta->addr);
#endif /* CONFIG_P2P */ #endif /* CONFIG_P2P */
#ifdef CONFIG_INTERWORKING
if (sta->gas_dialog) {
int i;
for (i = 0; i < GAS_DIALOG_MAX; i++)
gas_serv_dialog_clear(&sta->gas_dialog[i]);
os_free(sta->gas_dialog);
}
#endif /* CONFIG_INTERWORKING */
wpabuf_free(sta->wps_ie); wpabuf_free(sta->wps_ie);
wpabuf_free(sta->p2p_ie); wpabuf_free(sta->p2p_ie);
@ -397,8 +407,14 @@ static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx)
struct sta_info *sta = timeout_ctx; struct sta_info *sta = timeout_ctx;
u8 addr[ETH_ALEN]; u8 addr[ETH_ALEN];
if (!(sta->flags & WLAN_STA_AUTH)) if (!(sta->flags & WLAN_STA_AUTH)) {
if (sta->flags & WLAN_STA_GAS) {
wpa_printf(MSG_DEBUG, "GAS: Remove temporary STA "
"entry " MACSTR, MAC2STR(sta->addr));
ap_free_sta(hapd, sta);
}
return; return;
}
mlme_deauthenticate_indication(hapd, sta, mlme_deauthenticate_indication(hapd, sta,
WLAN_REASON_PREV_AUTH_NOT_VALID); WLAN_REASON_PREV_AUTH_NOT_VALID);

View file

@ -27,6 +27,7 @@
#define WLAN_STA_WDS BIT(14) #define WLAN_STA_WDS BIT(14)
#define WLAN_STA_ASSOC_REQ_OK BIT(15) #define WLAN_STA_ASSOC_REQ_OK BIT(15)
#define WLAN_STA_WPS2 BIT(16) #define WLAN_STA_WPS2 BIT(16)
#define WLAN_STA_GAS BIT(17)
#define WLAN_STA_PENDING_DISASSOC_CB BIT(29) #define WLAN_STA_PENDING_DISASSOC_CB BIT(29)
#define WLAN_STA_PENDING_DEAUTH_CB BIT(30) #define WLAN_STA_PENDING_DEAUTH_CB BIT(30)
#define WLAN_STA_NONERP BIT(31) #define WLAN_STA_NONERP BIT(31)
@ -107,6 +108,12 @@ struct sta_info {
struct os_time sa_query_start; struct os_time sa_query_start;
#endif /* CONFIG_IEEE80211W */ #endif /* CONFIG_IEEE80211W */
#ifdef CONFIG_INTERWORKING
#define GAS_DIALOG_MAX 8 /* Max concurrent dialog number */
struct gas_dialog_info *gas_dialog;
u8 gas_dialog_next;
#endif /* CONFIG_INTERWORKING */
struct wpabuf *wps_ie; /* WPS IE from (Re)Association Request */ struct wpabuf *wps_ie; /* WPS IE from (Re)Association Request */
struct wpabuf *p2p_ie; /* P2P IE from (Re)Association Request */ struct wpabuf *p2p_ie; /* P2P IE from (Re)Association Request */
}; };