summaryrefslogtreecommitdiffstats
path: root/contrib/hostapd/ieee802_11_auth.c
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2007-07-09 16:15:06 +0000
committersam <sam@FreeBSD.org>2007-07-09 16:15:06 +0000
commit1bf2fd00c50865c26197a0fb9ce70f417b9fa121 (patch)
treec6f336fc28b042f00efc2373c71fceadfa394e52 /contrib/hostapd/ieee802_11_auth.c
parent620bfba12034be7d2ad4a357063d609ff5b6e63a (diff)
downloadFreeBSD-src-1bf2fd00c50865c26197a0fb9ce70f417b9fa121.zip
FreeBSD-src-1bf2fd00c50865c26197a0fb9ce70f417b9fa121.tar.gz
Import of hostapd 0.5.8
Diffstat (limited to 'contrib/hostapd/ieee802_11_auth.c')
-rw-r--r--contrib/hostapd/ieee802_11_auth.c73
1 files changed, 44 insertions, 29 deletions
diff --git a/contrib/hostapd/ieee802_11_auth.c b/contrib/hostapd/ieee802_11_auth.c
index 296c640..16a8517 100644
--- a/contrib/hostapd/ieee802_11_auth.c
+++ b/contrib/hostapd/ieee802_11_auth.c
@@ -1,7 +1,6 @@
/*
- * Host AP (software wireless LAN access point) user space daemon for
- * Host AP kernel driver / IEEE 802.11 authentication (ACL)
- * Copyright (c) 2003-2005, Jouni Malinen <jkmaline@cc.hut.fi>
+ * hostapd / IEEE 802.11 authentication (ACL)
+ * Copyright (c) 2003-2006, Jouni Malinen <j@w1.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -13,14 +12,9 @@
* See README and COPYING for more details.
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+#include "includes.h"
+
+#ifndef CONFIG_NATIVE_WINDOWS
#include "hostapd.h"
#include "ieee802_11.h"
@@ -28,7 +22,6 @@
#include "radius.h"
#include "radius_client.h"
#include "eloop.h"
-#include "hostap_common.h"
#define RADIUS_ACL_TIMEOUT 30
@@ -40,6 +33,7 @@ struct hostapd_cached_radius_acl {
struct hostapd_cached_radius_acl *next;
u32 session_timeout;
u32 acct_interim_interval;
+ int vlan_id;
};
@@ -65,9 +59,9 @@ static void hostapd_acl_cache_free(struct hostapd_cached_radius_acl *acl_cache)
}
-static int hostapd_acl_cache_get(struct hostapd_data *hapd, u8 *addr,
+static int hostapd_acl_cache_get(struct hostapd_data *hapd, const u8 *addr,
u32 *session_timeout,
- u32 *acct_interim_interval)
+ u32 *acct_interim_interval, int *vlan_id)
{
struct hostapd_cached_radius_acl *entry;
time_t now;
@@ -82,6 +76,8 @@ static int hostapd_acl_cache_get(struct hostapd_data *hapd, u8 *addr,
if (entry->accepted == HOSTAPD_ACL_ACCEPT_TIMEOUT)
*session_timeout = entry->session_timeout;
*acct_interim_interval = entry->acct_interim_interval;
+ if (vlan_id)
+ *vlan_id = entry->vlan_id;
return entry->accepted;
}
@@ -101,7 +97,7 @@ static void hostapd_acl_query_free(struct hostapd_acl_query_data *query)
}
-static int hostapd_radius_acl_query(hostapd *hapd, u8 *addr,
+static int hostapd_radius_acl_query(struct hostapd_data *hapd, const u8 *addr,
struct hostapd_acl_query_data *query)
{
struct radius_msg *msg;
@@ -154,7 +150,7 @@ static int hostapd_radius_acl_query(hostapd *hapd, u8 *addr,
}
snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT ":%s",
- MAC2STR(hapd->own_addr), hapd->conf->ssid);
+ MAC2STR(hapd->own_addr), hapd->conf->ssid.ssid);
if (!radius_msg_add_attr(msg, RADIUS_ATTR_CALLED_STATION_ID,
(u8 *) buf, strlen(buf))) {
printf("Could not add Called-Station-Id\n");
@@ -192,11 +188,14 @@ static int hostapd_radius_acl_query(hostapd *hapd, u8 *addr,
}
-int hostapd_allowed_address(hostapd *hapd, u8 *addr, u8 *msg, size_t len,
- u32 *session_timeout, u32 *acct_interim_interval)
+int hostapd_allowed_address(struct hostapd_data *hapd, const u8 *addr,
+ const u8 *msg, size_t len, u32 *session_timeout,
+ u32 *acct_interim_interval, int *vlan_id)
{
*session_timeout = 0;
*acct_interim_interval = 0;
+ if (vlan_id)
+ *vlan_id = 0;
if (hostapd_maclist_found(hapd->conf->accept_mac,
hapd->conf->num_accept_mac, addr))
@@ -216,7 +215,8 @@ int hostapd_allowed_address(hostapd *hapd, u8 *addr, u8 *msg, size_t len,
/* Check whether ACL cache has an entry for this station */
int res = hostapd_acl_cache_get(hapd, addr, session_timeout,
- acct_interim_interval);
+ acct_interim_interval,
+ vlan_id);
if (res == HOSTAPD_ACL_ACCEPT ||
res == HOSTAPD_ACL_ACCEPT_TIMEOUT)
return res;
@@ -237,12 +237,11 @@ int hostapd_allowed_address(hostapd *hapd, u8 *addr, u8 *msg, size_t len,
return HOSTAPD_ACL_REJECT;
/* No entry in the cache - query external RADIUS server */
- query = malloc(sizeof(*query));
+ query = wpa_zalloc(sizeof(*query));
if (query == NULL) {
printf("malloc for query data failed\n");
return HOSTAPD_ACL_REJECT;
}
- memset(query, 0, sizeof(*query));
time(&query->timestamp);
memcpy(query->addr, addr, ETH_ALEN);
if (hostapd_radius_acl_query(hapd, addr, query)) {
@@ -272,7 +271,7 @@ int hostapd_allowed_address(hostapd *hapd, u8 *addr, u8 *msg, size_t len,
}
-static void hostapd_acl_expire_cache(hostapd *hapd, time_t now)
+static void hostapd_acl_expire_cache(struct hostapd_data *hapd, time_t now)
{
struct hostapd_cached_radius_acl *prev, *entry, *tmp;
@@ -301,7 +300,7 @@ static void hostapd_acl_expire_cache(hostapd *hapd, time_t now)
}
-static void hostapd_acl_expire_queries(hostapd *hapd, time_t now)
+static void hostapd_acl_expire_queries(struct hostapd_data *hapd, time_t now)
{
struct hostapd_acl_query_data *prev, *entry, *tmp;
@@ -332,7 +331,7 @@ static void hostapd_acl_expire_queries(hostapd *hapd, time_t now)
static void hostapd_acl_expire(void *eloop_ctx, void *timeout_ctx)
{
- hostapd *hapd = eloop_ctx;
+ struct hostapd_data *hapd = eloop_ctx;
time_t now;
time(&now);
@@ -382,12 +381,11 @@ hostapd_acl_recv_radius(struct radius_msg *msg, struct radius_msg *req,
}
/* Insert Accept/Reject info into ACL cache */
- cache = malloc(sizeof(*cache));
+ cache = wpa_zalloc(sizeof(*cache));
if (cache == NULL) {
printf("Failed to add ACL cache entry\n");
goto done;
}
- memset(cache, 0, sizeof(*cache));
time(&cache->timestamp);
memcpy(cache->addr, query->addr, sizeof(cache->addr));
if (msg->hdr->code == RADIUS_CODE_ACCESS_ACCEPT) {
@@ -408,6 +406,8 @@ hostapd_acl_recv_radius(struct radius_msg *msg, struct radius_msg *req,
MAC2STR(query->addr));
cache->acct_interim_interval = 0;
}
+
+ cache->vlan_id = radius_msg_get_vlanid(msg);
} else
cache->accepted = HOSTAPD_ACL_REJECT;
cache->next = hapd->acl_cache;
@@ -417,7 +417,7 @@ hostapd_acl_recv_radius(struct radius_msg *msg, struct radius_msg *req,
HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "Re-sending authentication frame "
"after successful RADIUS ACL query\n");
ieee802_11_mgmt(hapd, query->auth_msg, query->auth_msg_len,
- WLAN_FC_STYPE_AUTH);
+ WLAN_FC_STYPE_AUTH, NULL);
done:
if (prev == NULL)
@@ -431,7 +431,7 @@ hostapd_acl_recv_radius(struct radius_msg *msg, struct radius_msg *req,
}
-int hostapd_acl_init(hostapd *hapd)
+int hostapd_acl_init(struct hostapd_data *hapd)
{
if (radius_client_register(hapd->radius, RADIUS_AUTH,
hostapd_acl_recv_radius, hapd))
@@ -443,10 +443,12 @@ int hostapd_acl_init(hostapd *hapd)
}
-void hostapd_acl_deinit(hostapd *hapd)
+void hostapd_acl_deinit(struct hostapd_data *hapd)
{
struct hostapd_acl_query_data *query, *prev;
+ eloop_cancel_timeout(hostapd_acl_expire, hapd, NULL);
+
hostapd_acl_cache_free(hapd->acl_cache);
query = hapd->acl_queries;
@@ -456,3 +458,16 @@ void hostapd_acl_deinit(hostapd *hapd)
hostapd_acl_query_free(prev);
}
}
+
+
+int hostapd_acl_reconfig(struct hostapd_data *hapd,
+ struct hostapd_config *oldconf)
+{
+ if (!hapd->radius_client_reconfigured)
+ return 0;
+
+ hostapd_acl_deinit(hapd);
+ return hostapd_acl_init(hapd);
+}
+
+#endif /* CONFIG_NATIVE_WINDOWS */
OpenPOWER on IntegriCloud