PERFORCE change 117753 for review
Sam Leffler
sam at FreeBSD.org
Mon Apr 9 16:45:29 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=117753
Change 117753 by sam at sam_ebb on 2007/04/09 16:44:47
update for v0.5.7
Affected files ...
.. //depot/projects/wifi/usr.sbin/wpa/hostapd/Makefile#3 edit
.. //depot/projects/wifi/usr.sbin/wpa/hostapd/driver_freebsd.c#4 edit
.. //depot/projects/wifi/usr.sbin/wpa/hostapd_cli/Makefile#4 edit
Differences ...
==== //depot/projects/wifi/usr.sbin/wpa/hostapd/Makefile#3 (text+ko) ====
@@ -7,13 +7,20 @@
SRCS= hostapd.c eloop.c ieee802_1x.c eapol_sm.c radius.c md5.c rc4.c \
common.c ieee802_11.c config.c ieee802_11_auth.c accounting.c \
sta_info.c radius_client.c sha1.c wpa.c aes_wrap.c tls_none.c \
- ctrl_iface.c driver_conf.c l2_packet.c driver_freebsd.c
+ ctrl_iface.c driver_conf.c os_unix.c preauth.c pmksa_cache.c \
+ beacon.c hw_features.c wme.c ap_list.c reconfig.c mlme.c \
+ vlan_init.c ieee802_11h.c l2_packet.c driver_freebsd.c
CLEANFILES=driver_conf.c
MAN= hostapd.8 hostapd.conf.5
CFLAGS+= -I${.CURDIR} -I${HOSTAPD_DISTDIR}
CFLAGS+= -DCONFIG_DRIVER_BSD
+CFLAGS+= -DCONFIG_CTRL_IFACE
+CFLAGS+= -DCONFIG_CTRL_IFACE_UNIX
+CFLAGS+= -DINTERNAL_AES
+CFLAGS+= -DINTERNAL_SHA1
+CFLAGS+= -DINTERNAL_MD5
DPADD+= ${LIBPCAP}
LDADD+= -lpcap
==== //depot/projects/wifi/usr.sbin/wpa/hostapd/driver_freebsd.c#4 (text+ko) ====
@@ -55,7 +55,7 @@
static const struct driver_ops bsd_driver_ops;
-static int bsd_sta_deauth(void *priv, u8 *addr, int reason_code);
+static int bsd_sta_deauth(void *priv, const u8 *addr, int reason_code);
static int
set80211var(struct bsd_driver_data *drv, int op, const void *arg, int arg_len)
@@ -130,8 +130,8 @@
{
static const char *ciphernames[] =
{ "WEP", "TKIP", "AES-OCB", "AES-CCM", "*BAD*", "CKIP", "NONE" };
- hostapd *hapd = drv->hapd;
- struct hostapd_config *conf = hapd->conf;
+ struct hostapd_data *hapd = drv->hapd;
+ struct hostapd_bss_config *conf = hapd->conf;
int v;
switch (conf->wpa_group) {
@@ -218,7 +218,7 @@
bsd_set_iface_flags(void *priv, int dev_up)
{
struct bsd_driver_data *drv = priv;
- hostapd *hapd = drv->hapd;
+ struct hostapd_data *hapd = drv->hapd;
struct ifreq ifr;
HOSTAPD_DEBUG(HOSTAPD_DEBUG_VERBOSE,
@@ -260,11 +260,11 @@
}
static int
-bsd_set_ieee8021x(void *priv, int enabled)
+bsd_set_ieee8021x(const char *ifname, void *priv, int enabled)
{
struct bsd_driver_data *drv = priv;
- hostapd *hapd = drv->hapd;
- struct hostapd_config *conf = hapd->conf;
+ struct hostapd_data *hapd = drv->hapd;
+ struct hostapd_bss_config *conf = hapd->conf;
HOSTAPD_DEBUG(HOSTAPD_DEBUG_VERBOSE,
"%s: enabled=%d\n", __func__, enabled);
@@ -294,23 +294,22 @@
}
static int
-bsd_set_privacy(void *priv, int enabled)
+bsd_set_privacy(const char *ifname, void *priv, int enabled)
{
struct bsd_driver_data *drv = priv;
- hostapd *hapd = drv->hapd;
+ struct hostapd_data *hapd = drv->hapd;
HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL,
"%s: enabled=%d\n", __func__, enabled);
- return set80211param(priv, IEEE80211_IOC_PRIVACY, enabled) &&
- set80211param(priv, IEEE80211_IOC_DROPUNENCRYPTED, enabled);
+ return set80211param(priv, IEEE80211_IOC_PRIVACY, enabled);
}
static int
-bsd_set_sta_authorized(void *priv, u8 *addr, int authorized)
+bsd_set_sta_authorized(void *priv, const u8 *addr, int authorized)
{
struct bsd_driver_data *drv = priv;
- hostapd *hapd = drv->hapd;
+ struct hostapd_data *hapd = drv->hapd;
struct ieee80211req_mlme mlme;
HOSTAPD_DEBUG(HOSTAPD_DEBUG_VERBOSE,
@@ -327,10 +326,21 @@
}
static int
-bsd_del_key(void *priv, unsigned char *addr, int key_idx)
+bsd_sta_set_flags(void *priv, const u8 *addr, int flags_or, int flags_and)
+{
+ /* For now, only support setting Authorized flag */
+ if (flags_or & WLAN_STA_AUTHORIZED)
+ return bsd_set_sta_authorized(priv, addr, 1);
+ if (!(flags_and & WLAN_STA_AUTHORIZED))
+ return bsd_set_sta_authorized(priv, addr, 0);
+ return 0;
+}
+
+static int
+bsd_del_key(void *priv, const unsigned char *addr, int key_idx)
{
struct bsd_driver_data *drv = priv;
- hostapd *hapd = drv->hapd;
+ struct hostapd_data *hapd = drv->hapd;
struct ieee80211req_del_key wk;
HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL,
@@ -349,12 +359,12 @@
}
static int
-bsd_set_key(void *priv, const char *alg,
- unsigned char *addr, int key_idx,
- u8 *key, size_t key_len)
+bsd_set_key(const char *ifname, void *priv, const char *alg,
+ const u8 *addr, int key_idx,
+ const u8 *key, size_t key_len, int txkey)
{
struct bsd_driver_data *drv = priv;
- hostapd *hapd = drv->hapd;
+ struct hostapd_data *hapd = drv->hapd;
struct ieee80211req_key wk;
u_int8_t cipher;
@@ -401,10 +411,11 @@
static int
-bsd_get_seqnum(void *priv, u8 *addr, int idx, u8 *seq)
+bsd_get_seqnum(const char *ifname, void *priv, const u8 *addr, int idx,
+ u8 *seq)
{
struct bsd_driver_data *drv = priv;
- hostapd *hapd = drv->hapd;
+ struct hostapd_data *hapd = drv->hapd;
struct ieee80211req_key wk;
HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL,
@@ -441,7 +452,7 @@
static int
bsd_read_sta_driver_data(void *priv, struct hostap_sta_driver_data *data,
- u8 *addr)
+ const u8 *addr)
{
struct bsd_driver_data *drv = priv;
struct ieee80211req_sta_stats stats;
@@ -458,10 +469,10 @@
}
static int
-bsd_sta_clear_stats(void *priv, u8 *addr)
+bsd_sta_clear_stats(void *priv, const u8 *addr)
{
struct bsd_driver_data *drv = priv;
- hostapd *hapd = drv->hapd;
+ struct hostapd_data *hapd = drv->hapd;
struct ieee80211req_sta_stats stats;
HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "%s: addr=%s\n",
@@ -474,7 +485,7 @@
}
static int
-bsd_set_opt_ie(void *priv, const u8 *ie, size_t ie_len)
+bsd_set_opt_ie(const char *ifname, void *priv, const u8 *ie, size_t ie_len)
{
/*
* Do nothing; we setup parameters at startup that define the
@@ -484,10 +495,10 @@
}
static int
-bsd_sta_deauth(void *priv, u8 *addr, int reason_code)
+bsd_sta_deauth(void *priv, const u8 *addr, int reason_code)
{
struct bsd_driver_data *drv = priv;
- hostapd *hapd = drv->hapd;
+ struct hostapd_data *hapd = drv->hapd;
struct ieee80211req_mlme mlme;
HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL,
@@ -501,10 +512,10 @@
}
static int
-bsd_sta_disassoc(void *priv, u8 *addr, int reason_code)
+bsd_sta_disassoc(void *priv, const u8 *addr, int reason_code)
{
struct bsd_driver_data *drv = priv;
- hostapd *hapd = drv->hapd;
+ struct hostapd_data *hapd = drv->hapd;
struct ieee80211req_mlme mlme;
HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL,
@@ -520,7 +531,7 @@
bsd_del_sta(struct bsd_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
{
struct hostapd_data *hapd = drv->hapd;
- struct hostapd_config *conf = hapd->conf;
+ struct hostapd_bss_config *conf = hapd->conf;
struct sta_info *sta;
hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
@@ -528,11 +539,11 @@
sta = ap_get_sta(hapd, addr);
if (sta != NULL) {
- sta->flags &= ~WLAN_STA_ASSOC;
+ sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
if (conf->wpa)
- wpa_sm_event(hapd, sta, WPA_DISASSOC);
+ wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
- ieee802_1x_set_port_enabled(hapd, sta, 0);
+ ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
ap_free_sta(hapd, sta);
}
return 0;
@@ -542,7 +553,7 @@
bsd_new_sta(struct bsd_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
{
struct hostapd_data *hapd = drv->hapd;
- struct hostapd_config *conf = hapd->conf;
+ struct hostapd_bss_config *conf = hapd->conf;
struct sta_info *sta;
struct ieee80211req_wpaie ie;
int new_assoc, ielen, res;
@@ -563,35 +574,25 @@
printf("Failed to get WPA/RSN information element.\n");
return -1; /* XXX not right */
}
- ielen = ie.wpa_ie[1];
- if (ielen == 0) {
+ if (ie.wpa_ie[1] == 0) {
printf("No WPA/RSN information element for station!\n");
return -1; /* XXX not right */
}
- ielen += 2;
- res = wpa_validate_wpa_ie(hapd, sta, ie.wpa_ie, ielen,
- ie.wpa_ie[0] == WLAN_EID_RSN ?
- HOSTAPD_WPA_VERSION_WPA2 :
- HOSTAPD_WPA_VERSION_WPA);
+ if (sta->wpa_sm == NULL)
+ sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth,
+ sta->addr);
+ if (sta->wpa_sm == NULL) {
+ printf("Failed to initialize WPA state machine\n");
+ return -1;
+ }
+ ielen = 2 + ie.wpa_ie[1];
+ res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm,
+ ie.wpa_ie, ielen);
if (res != WPA_IE_OK) {
printf("WPA/RSN information element rejected? "
"(res %u)\n", res);
return -1;
}
- if (sta->wpa_ie != NULL)
- free(sta->wpa_ie);
- sta->wpa_ie = malloc(ielen);
- if (sta->wpa_ie == NULL) {
- printf("No memory for WPA/RSN information element!\n");
- return -1;
- }
- memcpy(sta->wpa_ie, ie.wpa_ie, ielen);
- sta->wpa_ie_len = ielen;
- } else {
- if (sta->wpa_ie != NULL)
- free(sta->wpa_ie);
- sta->wpa_ie = NULL;
- sta->wpa_ie_len = 0;
}
/*
@@ -599,16 +600,11 @@
* kick the authenticator into action.
*/
new_assoc = (sta->flags & WLAN_STA_ASSOC) == 0;
- sta->flags |= WLAN_STA_ASSOC;
- if (new_assoc) {
- if (conf->wpa)
- wpa_sm_event(hapd, sta, WPA_ASSOC);
- hostapd_new_assoc_sta(hapd, sta, !new_assoc);
- } else {
- if (conf->wpa)
- wpa_sm_event(hapd, sta, WPA_REAUTH);
- }
+ sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC;
+ wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC);
+ hostapd_new_assoc_sta(hapd, sta, !new_assoc);
ieee802_1x_notify_port_enabled(sta->eapol_sm, 1);
+
return 0;
}
@@ -711,10 +707,11 @@
static int
-bsd_send_eapol(void *priv, u8 *addr, u8 *data, size_t data_len, int encrypt)
+bsd_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
+ int encrypt, const u8 *own_addr)
{
struct bsd_driver_data *drv = priv;
- hostapd *hapd = drv->hapd;
+ struct hostapd_data *hapd = drv->hapd;
unsigned char buf[3000];
unsigned char *bp = buf;
struct l2_ethhdr *eth;
@@ -738,12 +735,11 @@
}
eth = (struct l2_ethhdr *) bp;
memcpy(eth->h_dest, addr, ETH_ALEN);
- memcpy(eth->h_source, drv->hapd->own_addr, ETH_ALEN);
+ memcpy(eth->h_source, own_addr, ETH_ALEN);
eth->h_proto = htons(ETH_P_EAPOL);
memcpy(eth+1, data, data_len);
- if (HOSTAPD_DEBUG_COND(HOSTAPD_DEBUG_MSGDUMPS))
- hostapd_hexdump("TX EAPOL", bp, len);
+ wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", bp, len);
status = l2_packet_send(drv->sock_xmit, addr, ETH_P_EAPOL, bp, len);
@@ -756,7 +752,7 @@
handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
{
struct bsd_driver_data *drv = ctx;
- hostapd *hapd = drv->hapd;
+ struct hostapd_data *hapd = drv->hapd;
struct sta_info *sta;
sta = ap_get_sta(hapd, src_addr);
@@ -771,10 +767,10 @@
}
static int
-bsd_get_ssid(void *priv, u8 *buf, int len)
+bsd_get_ssid(const char *ifname, void *priv, u8 *buf, int len)
{
struct bsd_driver_data *drv = priv;
- hostapd *hapd = drv->hapd;
+ struct hostapd_data *hapd = drv->hapd;
int ssid_len = get80211var(priv, IEEE80211_IOC_SSID, buf, len);
HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "%s: ssid=\"%.*s\"\n",
@@ -784,10 +780,10 @@
}
static int
-bsd_set_ssid(void *priv, u8 *buf, int len)
+bsd_set_ssid(const char *ifname, void *priv, const u8 *buf, int len)
{
struct bsd_driver_data *drv = priv;
- hostapd *hapd = drv->hapd;
+ struct hostapd_data *hapd = drv->hapd;
HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "%s: ssid=\"%.*s\"\n",
__func__, len, buf);
@@ -875,7 +871,7 @@
.set_generic_elem = bsd_set_opt_ie,
.wireless_event_init = bsd_wireless_event_init,
.wireless_event_deinit = bsd_wireless_event_deinit,
- .set_sta_authorized = bsd_set_sta_authorized,
+ .sta_set_flags = bsd_sta_set_flags,
.read_sta_data = bsd_read_sta_driver_data,
.send_eapol = bsd_send_eapol,
.sta_disassoc = bsd_sta_disassoc,
==== //depot/projects/wifi/usr.sbin/wpa/hostapd_cli/Makefile#4 (text+ko) ====
@@ -9,6 +9,9 @@
PROG= hostapd_cli
SRCS= hostapd_cli.c wpa_ctrl.c
+CFLAGS+= -DCONFIG_CTRL_IFACE
+CFLAGS+= -DCONFIG_CTRL_IFACE_UNIX
+
MAN= hostapd_cli.8
.include <bsd.prog.mk>
More information about the p4-projects
mailing list