From patchwork Fri Apr 5 22:59:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 234294 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id D1D452C00F4 for ; Sat, 6 Apr 2013 10:00:17 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 3C6229D23D; Fri, 5 Apr 2013 19:00:14 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H8pRN8GP4NN6; Fri, 5 Apr 2013 19:00:13 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id D0AFE9D1FB; Fri, 5 Apr 2013 19:00:09 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 21F219D1FB for ; Fri, 5 Apr 2013 19:00:08 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yFLkeXh53K8K for ; Fri, 5 Apr 2013 19:00:03 -0400 (EDT) Received: from ns3.lanforge.com (mail.candelatech.com [208.74.158.172]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id B783D9D1E3 for ; Fri, 5 Apr 2013 19:00:03 -0400 (EDT) Received: from fs3.candelatech.com (firewall.candelatech.com [70.89.124.249]) by ns3.lanforge.com (8.14.2/8.14.2) with ESMTP id r35MxvIk008729 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 5 Apr 2013 15:59:57 -0700 From: greearb@candelatech.com To: hostap@lists.shmoo.com Subject: [PATCH] hostapd: Return code-17 on max-station limitation. Date: Fri, 5 Apr 2013 15:59:41 -0700 Message-Id: <1365202781-29759-1-git-send-email-greearb@candelatech.com> X-Mailer: git-send-email 1.7.3.4 Cc: Ben Greear X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Ben Greear I believe this is a more valid response code. Signed-hostap: Ben Greear --- hostapd/ctrl_iface.c | 3 ++- src/ap/drv_callbacks.c | 9 +++++---- src/ap/gas_serv.c | 3 ++- src/ap/ieee802_11.c | 3 +-- src/ap/preauth_auth.c | 3 ++- src/ap/sta_info.c | 5 ++++- src/ap/sta_info.h | 4 +++- src/ap/wpa_auth_glue.c | 3 ++- 8 files changed, 21 insertions(+), 12 deletions(-) diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 2153329..bf3984f 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -132,6 +132,7 @@ static int hostapd_ctrl_iface_new_sta(struct hostapd_data *hapd, { u8 addr[ETH_ALEN]; struct sta_info *sta; + u16 resp; wpa_printf(MSG_DEBUG, "CTRL_IFACE NEW_STA %s", txtaddr); @@ -144,7 +145,7 @@ static int hostapd_ctrl_iface_new_sta(struct hostapd_data *hapd, wpa_printf(MSG_DEBUG, "Add new STA " MACSTR " based on ctrl_iface " "notification", MAC2STR(addr)); - sta = ap_sta_add(hapd, addr); + sta = ap_sta_add(hapd, addr, resp); if (sta == NULL) return -1; diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index 6d22d49..a625f25 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -93,7 +93,8 @@ int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr, */ sta->timeout_next = STA_NULLFUNC; } else { - sta = ap_sta_add(hapd, addr); + u16 resp; + sta = ap_sta_add(hapd, addr, &resp); if (sta == NULL) { hostapd_drv_sta_disassoc(hapd, addr, WLAN_REASON_DISASSOC_AP_BUSY); @@ -467,9 +468,8 @@ static void hostapd_notif_auth(struct hostapd_data *hapd, sta = ap_get_sta(hapd, rx_auth->peer); if (!sta) { - sta = ap_sta_add(hapd, rx_auth->peer); + sta = ap_sta_add(hapd, rx_auth->peer, &status); if (sta == NULL) { - status = WLAN_STATUS_UNSPECIFIED_FAILURE; goto fail; } } @@ -675,13 +675,14 @@ static void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf, static int hostapd_event_new_sta(struct hostapd_data *hapd, const u8 *addr) { + u16 resp; struct sta_info *sta = ap_get_sta(hapd, addr); if (sta) return 0; wpa_printf(MSG_DEBUG, "Data frame from unknown STA " MACSTR " - adding a new STA", MAC2STR(addr)); - sta = ap_sta_add(hapd, addr); + sta = ap_sta_add(hapd, addr, &resp); if (sta) { hostapd_new_assoc_sta(hapd, sta, 0); } else { diff --git a/src/ap/gas_serv.c b/src/ap/gas_serv.c index b3574ba..6e3479e 100644 --- a/src/ap/gas_serv.c +++ b/src/ap/gas_serv.c @@ -28,13 +28,14 @@ gas_dialog_create(struct hostapd_data *hapd, const u8 *addr, u8 dialog_token) sta = ap_get_sta(hapd, addr); if (!sta) { + u16 resp; /* * 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); + sta = ap_sta_add(hapd, addr, &resp); if (!sta) { wpa_printf(MSG_DEBUG, "Failed to add STA " MACSTR " for GAS query", MAC2STR(addr)); diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 8baa15e..36b7f86 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -633,9 +633,8 @@ static void handle_auth(struct hostapd_data *hapd, return; } - sta = ap_sta_add(hapd, mgmt->sa); + sta = ap_sta_add(hapd, mgmt->sa, &resp); if (!sta) { - resp = WLAN_STATUS_UNSPECIFIED_FAILURE; goto fail; } diff --git a/src/ap/preauth_auth.c b/src/ap/preauth_auth.c index 3e0c800..28cd867 100644 --- a/src/ap/preauth_auth.c +++ b/src/ap/preauth_auth.c @@ -71,7 +71,8 @@ static void rsn_preauth_receive(void *ctx, const u8 *src_addr, return; } if (!sta && hdr->type == IEEE802_1X_TYPE_EAPOL_START) { - sta = ap_sta_add(hapd, ethhdr->h_source); + u16 resp; + sta = ap_sta_add(hapd, ethhdr->h_source, &resp); if (sta == NULL) return; sta->flags = WLAN_STA_PREAUTH; diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c index cbafb47..a8e4e56 100644 --- a/src/ap/sta_info.c +++ b/src/ap/sta_info.c @@ -477,7 +477,8 @@ void ap_sta_no_session_timeout(struct hostapd_data *hapd, struct sta_info *sta) } -struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr) +struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr, + u16* resp) { struct sta_info *sta; @@ -490,12 +491,14 @@ struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr) /* FIX: might try to remove some old STAs first? */ wpa_printf(MSG_DEBUG, "no more room for new STAs (%d/%d)", hapd->num_sta, hapd->conf->max_num_sta); + *resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; return NULL; } sta = os_zalloc(sizeof(struct sta_info)); if (sta == NULL) { wpa_printf(MSG_ERROR, "malloc failed"); + *resp = WLAN_STATUS_UNSPECIFIED_FAILURE; return NULL; } sta->acct_interim_interval = hapd->conf->acct_interim_interval; diff --git a/src/ap/sta_info.h b/src/ap/sta_info.h index 32ea46e..cd9c261 100644 --- a/src/ap/sta_info.h +++ b/src/ap/sta_info.h @@ -163,7 +163,9 @@ void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta, u32 session_timeout); void ap_sta_no_session_timeout(struct hostapd_data *hapd, struct sta_info *sta); -struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr); +/* If failure (NULL is returned), *resp will contain the error code. */ +struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr, + u16* resp); void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta, u16 reason); void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta, diff --git a/src/ap/wpa_auth_glue.c b/src/ap/wpa_auth_glue.c index fdaaaff..b8ab1bd 100644 --- a/src/ap/wpa_auth_glue.c +++ b/src/ap/wpa_auth_glue.c @@ -454,11 +454,12 @@ hostapd_wpa_auth_add_sta(void *ctx, const u8 *sta_addr) { struct hostapd_data *hapd = ctx; struct sta_info *sta; + u16 resp; if (hostapd_add_sta_node(hapd, sta_addr, WLAN_AUTH_FT) < 0) return NULL; - sta = ap_sta_add(hapd, sta_addr); + sta = ap_sta_add(hapd, sta_addr, resp); if (sta == NULL) return NULL; if (sta->wpa_sm) {