From 5e3286e5ff91985bec5a70b2953122f336338da6 Mon Sep 17 00:00:00 2001 From: sephe Date: Tue, 7 Aug 2007 11:25:37 +0000 Subject: [PATCH] Hook {wpa_supplicant, hostapd} 0.5.8 into building. Thank swildner@ for reviewing the modification to the manual pages. Obtained-from: FreeBSD (sam@freebsd.org) w/ modification # wpa_supplicant 0.5.8 is supposed to support 802.1X on wired devices. --- usr.sbin/802_11/hostapd/Makefile | 20 +- usr.sbin/802_11/hostapd/driver_dragonfly.c | 147 +++++----- usr.sbin/802_11/hostapd/hostapd.conf.5 | 13 +- usr.sbin/802_11/hostapd_cli/Makefile | 11 +- usr.sbin/802_11/l2_packet.c | 26 +- usr.sbin/802_11/os_unix.c.patch | 13 + usr.sbin/802_11/wpa_cli/Makefile | 28 +- usr.sbin/802_11/wpa_supplicant/Makefile | 26 +- usr.sbin/802_11/wpa_supplicant/Packet32.c | 34 ++- usr.sbin/802_11/wpa_supplicant/common.h | 295 --------------------- usr.sbin/802_11/wpa_supplicant/driver_dragonfly.c | 36 +-- .../802_11/wpa_supplicant/driver_wired.c.patch | 34 +++ usr.sbin/802_11/wpa_supplicant/events.c.patch | 35 +++ usr.sbin/802_11/wpa_supplicant/wpa_supplicant.8 | 8 +- .../802_11/wpa_supplicant/wpa_supplicant.conf.5 | 13 +- 15 files changed, 293 insertions(+), 446 deletions(-) create mode 100644 usr.sbin/802_11/os_unix.c.patch rewrite usr.sbin/802_11/wpa_cli/Makefile (81%) delete mode 100644 usr.sbin/802_11/wpa_supplicant/common.h create mode 100644 usr.sbin/802_11/wpa_supplicant/driver_wired.c.patch create mode 100644 usr.sbin/802_11/wpa_supplicant/events.c.patch diff --git a/usr.sbin/802_11/hostapd/Makefile b/usr.sbin/802_11/hostapd/Makefile index 51f59ad122..70eb5a7ec5 100644 --- a/usr.sbin/802_11/hostapd/Makefile +++ b/usr.sbin/802_11/hostapd/Makefile @@ -1,20 +1,28 @@ -# $FreeBSD: src/usr.sbin/wpa/hostapd/Makefile,v 1.2 2005/06/17 05:37:08 sam Exp $ -# $DragonFly: src/usr.sbin/802_11/hostapd/Makefile,v 1.1 2006/09/02 05:40:35 sephe Exp $ +# $FreeBSD: src/usr.sbin/wpa/hostapd/Makefile,v 1.3 2007/07/09 16:26:48 sam Exp $ +# $DragonFly: src/usr.sbin/802_11/hostapd/Makefile,v 1.2 2007/08/07 11:25:36 sephe Exp $ -SRCDIR= ${.CURDIR}/../../../contrib/hostapd-0.4.9 -.PATH: ${.CURDIR}/.. ${SRCDIR} +CONTRIBDIR= ${.CURDIR}/../../../contrib/hostapd-0.5.8 +.PATH: ${.CURDIR}/.. ${CONTRIBDIR} PROG= hostapd 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_dragonfly.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_dragonfly.c +SRCS+= os_unix.c.patch CLEANFILES=driver_conf.c MAN= hostapd.8 hostapd.conf.5 -CFLAGS+= -I${.CURDIR} -I${SRCDIR} +CFLAGS+= -I${CONTRIBDIR} 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 diff --git a/usr.sbin/802_11/hostapd/driver_dragonfly.c b/usr.sbin/802_11/hostapd/driver_dragonfly.c index b1a3fd400d..dc401bc5c5 100644 --- a/usr.sbin/802_11/hostapd/driver_dragonfly.c +++ b/usr.sbin/802_11/hostapd/driver_dragonfly.c @@ -12,8 +12,8 @@ * * See README and COPYING for more details. * - * $FreeBSD: src/usr.sbin/wpa/hostapd/driver_freebsd.c,v 1.2.2.2 2006/09/02 17:31:08 sam Exp $ - * $DragonFly: src/usr.sbin/802_11/hostapd/driver_dragonfly.c,v 1.2 2006/09/03 02:24:45 sephe Exp $ + * $FreeBSD: src/usr.sbin/wpa/hostapd/driver_freebsd.c,v 1.6 2007/07/09 16:26:48 sam Exp $ + * $DragonFly: src/usr.sbin/802_11/hostapd/driver_dragonfly.c,v 1.3 2007/08/07 11:25:36 sephe Exp $ */ #include #include @@ -57,7 +57,7 @@ struct bsd_driver_data { 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) @@ -132,8 +132,8 @@ bsd_configure_wpa(struct bsd_driver_data *drv) { 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) { @@ -220,7 +220,7 @@ static int 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, @@ -262,11 +262,11 @@ bsd_set_iface_flags(void *priv, int dev_up) } 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); @@ -296,10 +296,10 @@ bsd_set_ieee8021x(void *priv, int enabled) } 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); @@ -308,10 +308,10 @@ bsd_set_privacy(void *priv, int 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, @@ -328,10 +328,21 @@ bsd_set_sta_authorized(void *priv, u8 *addr, int authorized) } 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, @@ -350,12 +361,12 @@ bsd_del_key(void *priv, unsigned char *addr, int key_idx) } 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; @@ -402,10 +413,11 @@ bsd_set_key(void *priv, const char *alg, 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, @@ -442,7 +454,7 @@ bsd_flush(void *priv) 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; @@ -459,10 +471,10 @@ bsd_read_sta_driver_data(void *priv, struct hostap_sta_driver_data *data, } 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", @@ -475,7 +487,7 @@ bsd_sta_clear_stats(void *priv, u8 *addr) } 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 @@ -485,10 +497,10 @@ bsd_set_opt_ie(void *priv, const u8 *ie, size_t ie_len) } 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, @@ -502,10 +514,10 @@ bsd_sta_deauth(void *priv, u8 *addr, int reason_code) } 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, @@ -521,7 +533,7 @@ static int 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, @@ -529,11 +541,11 @@ bsd_del_sta(struct bsd_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN]) 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; @@ -543,7 +555,7 @@ static int 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; @@ -564,35 +576,25 @@ bsd_new_sta(struct bsd_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN]) 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; } /* @@ -600,16 +602,11 @@ bsd_new_sta(struct bsd_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN]) * 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; } @@ -712,10 +709,11 @@ bsd_wireless_event_deinit(void *priv) 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; @@ -739,12 +737,11 @@ bsd_send_eapol(void *priv, u8 *addr, u8 *data, size_t data_len, int encrypt) } 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); @@ -757,7 +754,7 @@ static void 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); @@ -772,10 +769,10 @@ handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len) } 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", @@ -785,10 +782,10 @@ bsd_get_ssid(void *priv, u8 *buf, int len) } 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); @@ -876,7 +873,7 @@ static const struct driver_ops bsd_driver_ops = { .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, diff --git a/usr.sbin/802_11/hostapd/hostapd.conf.5 b/usr.sbin/802_11/hostapd/hostapd.conf.5 index b22ea1b700..5251fd392e 100644 --- a/usr.sbin/802_11/hostapd/hostapd.conf.5 +++ b/usr.sbin/802_11/hostapd/hostapd.conf.5 @@ -23,10 +23,10 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/usr.sbin/wpa/hostapd/hostapd.conf.5,v 1.3 2006/09/02 17:56:24 sam Exp $ -.\" $DragonFly: src/usr.sbin/802_11/hostapd/hostapd.conf.5,v 1.2 2006/09/03 01:58:43 sephe Exp $ +.\" $FreeBSD: src/usr.sbin/wpa/hostapd/hostapd.conf.5,v 1.4 2006/09/29 17:57:04 ru Exp $ +.\" $DragonFly: src/usr.sbin/802_11/hostapd/hostapd.conf.5,v 1.3 2007/08/07 11:25:36 sephe Exp $ .\" -.Dd September 2, 2006 +.Dd July 22, 2007 .Dt HOSTAPD.CONF 5 .Os .Sh NAME @@ -73,7 +73,8 @@ mode. Debugging mode: 0 = no, 1 = minimal, 2 = verbose, 3 = msg dumps, 4 = excessive. .It Va dump_file -Dump file for state information (on SIGUSR1). +Dump file for state information (on +.Dv SIGUSR1 ) . .It Va ctrl_interface The pathname of the directory in which .Xr hostapd 8 @@ -186,8 +187,8 @@ seconds. Rekey GTK when any STA that possesses the current GTK is leaving the BSS. .It Va wpa_gmk_rekey -Time interval for rekeying GMK (master key used internally to generate GTKs -(in seconds). +Time interval for rekeying GMK (master key used internally to generate GTKs), +in seconds. .El .Sh SEE ALSO .Xr hostapd 8 , diff --git a/usr.sbin/802_11/hostapd_cli/Makefile b/usr.sbin/802_11/hostapd_cli/Makefile index 5d91703884..cad83c7796 100644 --- a/usr.sbin/802_11/hostapd_cli/Makefile +++ b/usr.sbin/802_11/hostapd_cli/Makefile @@ -1,13 +1,14 @@ -# $FreeBSD: src/usr.sbin/wpa/hostapd_cli/Makefile,v 1.2.2.1 2006/03/24 01:43:18 sam Exp $ -# $DragonFly: src/usr.sbin/802_11/hostapd_cli/Makefile,v 1.1 2006/09/02 05:40:35 sephe Exp $ +# $FreeBSD: src/usr.sbin/wpa/hostapd_cli/Makefile,v 1.4 2007/07/09 16:26:48 sam Exp $ +# $DragonFly: src/usr.sbin/802_11/hostapd_cli/Makefile,v 1.2 2007/08/07 11:25:36 sephe Exp $ -SRCDIR= ${.CURDIR}/../../../contrib/hostapd-0.4.9 - -.PATH: ${SRCDIR} +.PATH: ${.CURDIR}/../../../contrib/hostapd-0.5.8 PROG= hostapd_cli SRCS= hostapd_cli.c wpa_ctrl.c +CFLAGS+= -DCONFIG_CTRL_IFACE +CFLAGS+= -DCONFIG_CTRL_IFACE_UNIX + MAN= hostapd_cli.8 .include diff --git a/usr.sbin/802_11/l2_packet.c b/usr.sbin/802_11/l2_packet.c index 51b15b47f8..c8a3432190 100644 --- a/usr.sbin/802_11/l2_packet.c +++ b/usr.sbin/802_11/l2_packet.c @@ -12,36 +12,38 @@ * * See README and COPYING for more details. * - * $FreeBSD: src/usr.sbin/wpa/l2_packet.c,v 1.1.2.2 2006/03/24 01:43:17 sam Exp $ - * $DragonFly: src/usr.sbin/802_11/l2_packet.c,v 1.3 2007/01/01 01:45:40 sephe Exp $ + * $FreeBSD: src/usr.sbin/wpa/l2_packet.c,v 1.4 2007/07/09 15:57:10 sam Exp $ + * $DragonFly: src/usr.sbin/802_11/l2_packet.c,v 1.4 2007/08/07 11:25:36 sephe Exp $ */ /* - * FreeBSD-specific implementation. + * DragonFlyBSD-specific implementation. */ #include #include #include #include -#include #include #include -#include #include +#include #include #include +#include #include #include #include -#include #include #include "common.h" #include "eloop.h" #include "l2_packet.h" +static const u8 pae_group_addr[ETH_ALEN] = + { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x03 }; + struct l2_packet_data { pcap_t *pcap; char ifname[100]; @@ -153,7 +155,7 @@ static int l2_packet_init_libpcap(struct l2_packet_data *l2, unsigned short protocol) { bpf_u_int32 pcap_maskp, pcap_netp; - char pcap_filter[100], pcap_err[PCAP_ERRBUF_SIZE]; + char pcap_filter[200], pcap_err[PCAP_ERRBUF_SIZE]; struct bpf_program pcap_fp; pcap_lookupnet(l2->ifname, &pcap_netp, &pcap_maskp, pcap_err); @@ -165,13 +167,17 @@ l2_packet_init_libpcap(struct l2_packet_data *l2, unsigned short protocol) } if (pcap_datalink(l2->pcap) != DLT_EN10MB && pcap_set_datalink(l2->pcap, DLT_EN10MB) < 0) { - fprintf(stderr, "pcap_set_datalinke(DLT_EN10MB): %s\n", + fprintf(stderr, "pcap_set_datalink(DLT_EN10MB): %s\n", pcap_geterr(l2->pcap)); return -1; } snprintf(pcap_filter, sizeof(pcap_filter), - "ether dst " MACSTR " and ether proto 0x%x", - MAC2STR(l2->own_addr), protocol); + "not ether src " MACSTR " and " + "( ether dst " MACSTR " or ether dst " MACSTR " ) and " + "ether proto 0x%x", + MAC2STR(l2->own_addr), /* do not receive own packets */ + MAC2STR(l2->own_addr), MAC2STR(pae_group_addr), + protocol); if (pcap_compile(l2->pcap, &pcap_fp, pcap_filter, 1, pcap_netp) < 0) { fprintf(stderr, "pcap_compile: %s\n", pcap_geterr(l2->pcap)); return -1; diff --git a/usr.sbin/802_11/os_unix.c.patch b/usr.sbin/802_11/os_unix.c.patch new file mode 100644 index 0000000000..137117ce82 --- /dev/null +++ b/usr.sbin/802_11/os_unix.c.patch @@ -0,0 +1,13 @@ +$DragonFly: src/usr.sbin/802_11/os_unix.c.patch,v 1.1 2007/08/07 11:25:36 sephe Exp $ +diff -urp hostapd-0.5.8/os_unix.c /usr/src/contrib/hostapd-0.5.8/os_unix.c +--- os_unix.c 2007-03-25 10:09:43.000000000 +0800 ++++ os_unix.c 2007-07-22 12:17:04.000000000 +0800 +@@ -171,7 +171,7 @@ int os_setenv(const char *name, const ch + + int os_unsetenv(const char *name) + { +-#if defined(__FreeBSD__) || defined(__NetBSD__) ++#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) + unsetenv(name); + return 0; + #else diff --git a/usr.sbin/802_11/wpa_cli/Makefile b/usr.sbin/802_11/wpa_cli/Makefile dissimilarity index 81% index 87b18e9450..be4506b493 100644 --- a/usr.sbin/802_11/wpa_cli/Makefile +++ b/usr.sbin/802_11/wpa_cli/Makefile @@ -1,11 +1,17 @@ -# $FreeBSD: src/usr.sbin/wpa/wpa_cli/Makefile,v 1.2 2005/06/17 03:08:59 sam Exp $ -# $DragonFly: src/usr.sbin/802_11/wpa_cli/Makefile,v 1.1 2006/07/07 15:05:18 sephe Exp $ - -.PATH: ${.CURDIR}/../../../contrib/wpa_supplicant-0.4.9 - -PROG= wpa_cli -SRCS= wpa_cli.c wpa_ctrl.c - -MAN= wpa_cli.8 - -.include +# $FreeBSD: src/usr.sbin/wpa/wpa_cli/Makefile,v 1.3 2007/07/11 16:04:07 sam Exp $ +# $DragonFly: src/usr.sbin/802_11/wpa_cli/Makefile,v 1.2 2007/08/07 11:25:36 sephe Exp $ + +CONTRIBDIR= ${.CURDIR}/../../../contrib/wpa_supplicant-0.5.8 +.PATH: ${.CURDIR}/.. ${CONTRIBDIR} + +PROG= wpa_cli +SRCS= wpa_cli.c wpa_ctrl.c os_unix.c +SRCS+= os_unix.c.patch + +CFLAGS+= -I${CONTRIBDIR} +CFLAGS+= -DCONFIG_CTRL_IFACE +CFLAGS+= -DCONFIG_CTRL_IFACE_UNIX + +MAN= wpa_cli.8 + +.include diff --git a/usr.sbin/802_11/wpa_supplicant/Makefile b/usr.sbin/802_11/wpa_supplicant/Makefile index 019f1a50b5..115e0713dd 100644 --- a/usr.sbin/802_11/wpa_supplicant/Makefile +++ b/usr.sbin/802_11/wpa_supplicant/Makefile @@ -1,22 +1,26 @@ -# $FreeBSD: src/usr.sbin/wpa/wpa_supplicant/Makefile,v 1.3.2.3 2006/03/24 01:43:18 sam Exp $ -# $DragonFly: src/usr.sbin/802_11/wpa_supplicant/Makefile,v 1.1 2006/06/24 07:29:44 sephe Exp $ +# $FreeBSD: src/usr.sbin/wpa/wpa_supplicant/Makefile,v 1.9 2007/07/11 16:04:08 sam Exp $ +# $DragonFly: src/usr.sbin/802_11/wpa_supplicant/Makefile,v 1.2 2007/08/07 11:25:36 sephe Exp $ -SRCDIR= ${.CURDIR}/../../../contrib/wpa_supplicant-0.4.9 - -.PATH: ${.CURDIR}/.. ${SRCDIR} +CONTRIBDIR= ${.CURDIR}/../../../contrib/wpa_supplicant-0.5.8 +.PATH: ${.CURDIR}/.. ${CONTRIBDIR} PROG= wpa_supplicant SRCS= config.c eloop.c common.c md5.c rc4.c sha1.c aes_wrap.c \ - wpa_supplicant.c events.c wpa.c preauth.c \ - ctrl_iface.c l2_packet.c main.c drivers.c driver_dragonfly.c \ - driver_ndis.c driver_ndis_.c Packet32.c + wpa_supplicant.c events.c wpa.c preauth.c pmksa_cache.c \ + ctrl_iface.c ctrl_iface_unix.c l2_packet.c main.c drivers.c \ + Packet32.c os_unix.c +SRCS+= driver_dragonfly.c driver_wired.c driver_ndis.c +SRCS+= os_unix.c.patch driver_wired.c.patch events.c.patch MAN= wpa_supplicant.8 wpa_supplicant.conf.5 -CFLAGS+= -I${.CURDIR} -I${SRCDIR} +CFLAGS+= -I${.CURDIR} -I${CONTRIBDIR} CFLAGS+= -DCONFIG_DRIVER_BSD CFLAGS+= -DCONFIG_DRIVER_NDIS +CFLAGS+= -DCONFIG_DRIVER_WIRED CFLAGS+= -DCONFIG_CTRL_IFACE +CFLAGS+= -DCONFIG_CTRL_IFACE_UNIX +CFLAGS+= -DCONFIG_TERMINATE_ONLASTIF CFLAGS+= -g DPADD+= ${LIBPCAP} LDADD+= -lpcap @@ -26,7 +30,7 @@ SRCS+= config_file.c base64.c CFLAGS+=-DCONFIG_BACKEND_FILE .if !defined(NO_WPA_SUPPLICANT_EAPOL) -SRCS+= eapol_sm.c eap.c +SRCS+= eapol_sm.c eap.c eap_methods.c CFLAGS+= -DIEEE8021X_EAPOL .if !defined(NO_CRYPT) && !defined(NO_OPENSSL) && !defined(RELEASE_CRUNCH) @@ -43,7 +47,7 @@ SRCS+= eap_ttls.c eap_md5.c #CFLAGS+= -DEAP_FAST #SRCS+= eap_fast.c -DPADD+= ${LIBCRYPTO} +DPADD+= ${LIBSSL} ${LIBCRYPTO} LDADD+= -lssl -lcrypto .else SRCS+= tls_none.c diff --git a/usr.sbin/802_11/wpa_supplicant/Packet32.c b/usr.sbin/802_11/wpa_supplicant/Packet32.c index 577733905e..0727565ae4 100644 --- a/usr.sbin/802_11/wpa_supplicant/Packet32.c +++ b/usr.sbin/802_11/wpa_supplicant/Packet32.c @@ -29,8 +29,8 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/usr.sbin/wpa/wpa_supplicant/Packet32.c,v 1.2.2.2 2006/04/12 17:21:08 sam Exp $ - * $DragonFly: src/usr.sbin/802_11/wpa_supplicant/Packet32.c,v 1.2 2006/09/02 05:40:35 sephe Exp $ + * $FreeBSD: src/usr.sbin/wpa/wpa_supplicant/Packet32.c,v 1.4 2007/07/11 16:04:08 sam Exp $ + * $DragonFly: src/usr.sbin/802_11/wpa_supplicant/Packet32.c,v 1.3 2007/08/07 11:25:37 sephe Exp $ */ /* @@ -48,9 +48,7 @@ #include #include #include -#include -#include #include #include #include @@ -60,6 +58,8 @@ #include #include +#include + #include #include #include @@ -100,6 +100,7 @@ typedef struct NDIS_802_11_KEY_COMPAT { struct adapter { int socket; char name[IFNAMSIZ]; + int prev_roaming; }; PCHAR @@ -116,6 +117,7 @@ PacketOpenAdapter(iface) int s; int ifflags; struct ifreq ifr; + struct ieee80211req ireq; s = socket(PF_INET, SOCK_DGRAM, 0); @@ -127,8 +129,24 @@ PacketOpenAdapter(iface) return(NULL); a->socket = s; + if (strncmp(iface, "\\Device\\NPF_", 12) == 0) + iface += 12; + else if (strncmp(iface, "\\DEVICE\\", 8) == 0) + iface += 8; snprintf(a->name, IFNAMSIZ, "%s", iface); + /* Turn off net80211 roaming */ + bzero((char *)&ireq, sizeof(ireq)); + strncpy(ireq.i_name, iface, sizeof (ifr.ifr_name)); + ireq.i_type = IEEE80211_IOC_ROAMING; + if (ioctl(a->socket, SIOCG80211, &ireq) == 0) { + a->prev_roaming = ireq.i_val; + ireq.i_val = IEEE80211_ROAMING_MANUAL; + if (ioctl(a->socket, SIOCS80211, &ireq) < 0) + fprintf(stderr, + "Could not set IEEE80211_ROAMING_MANUAL\n"); + } + bzero((char *)&ifr, sizeof(ifr)); strncpy(ifr.ifr_name, iface, sizeof (ifr.ifr_name)); if (ioctl(a->socket, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) { @@ -329,12 +347,20 @@ PacketCloseAdapter(iface) { struct adapter *a; struct ifreq ifr; + struct ieee80211req ireq; if (iface == NULL) return; a = iface; + /* Reset net80211 roaming */ + bzero((char *)&ireq, sizeof(ireq)); + strncpy(ireq.i_name, a->name, sizeof (ifr.ifr_name)); + ireq.i_type = IEEE80211_IOC_ROAMING; + ireq.i_val = a->prev_roaming; + ioctl(a->socket, SIOCS80211, &ireq); + bzero((char *)&ifr, sizeof(ifr)); strncpy(ifr.ifr_name, a->name, sizeof (ifr.ifr_name)); ioctl(a->socket, SIOCGIFFLAGS, (caddr_t)&ifr); diff --git a/usr.sbin/802_11/wpa_supplicant/common.h b/usr.sbin/802_11/wpa_supplicant/common.h deleted file mode 100644 index 3bae3dd3ae..0000000000 --- a/usr.sbin/802_11/wpa_supplicant/common.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - * wpa_supplicant/hostapd / common helper functions, etc. - * Copyright (c) 2002-2005, Jouni Malinen - * - * 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 - * published by the Free Software Foundation. - * - * Alternatively, this software may be distributed under the terms of BSD - * license. - * - * See README and COPYING for more details. - * - * $DragonFly: src/usr.sbin/802_11/wpa_supplicant/Attic/common.h,v 1.1 2006/06/24 07:29:44 sephe Exp $ - */ - -#ifndef COMMON_H -#define COMMON_H - -#ifdef __linux__ -#include -#include -#endif /* __linux__ */ - -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) -#include -#include -#define __BYTE_ORDER _BYTE_ORDER -#define __LITTLE_ENDIAN _LITTLE_ENDIAN -#define __BIG_ENDIAN _BIG_ENDIAN -#define bswap_16 bswap16 -#define bswap_32 bswap32 -#define bswap_64 bswap64 -#endif /* defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) */ - -#ifdef CONFIG_NATIVE_WINDOWS -#include - -static inline int daemon(int nochdir, int noclose) -{ - printf("Windows - daemon() not supported yet\n"); - return -1; -} - -static inline void sleep(int seconds) -{ - Sleep(seconds * 1000); -} - -static inline void usleep(unsigned long usec) -{ - Sleep(usec / 1000); -} - -#ifndef timersub -#define timersub(a, b, res) do { \ - (res)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ - (res)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ - if ((res)->tv_usec < 0) { \ - (res)->tv_sec--; \ - (res)->tv_usec += 1000000; \ - } \ -} while (0) -#endif - -struct timezone { - int tz_minuteswest; - int tz_dsttime; -}; - -int gettimeofday(struct timeval *tv, struct timezone *tz); - -static inline long int random(void) -{ - return rand(); -} - -typedef int gid_t; -typedef int socklen_t; - -#ifndef MSG_DONTWAIT -#define MSG_DONTWAIT 0 /* not supported */ -#endif - -#endif /* CONFIG_NATIVE_WINDOWS */ - -#if defined(__CYGWIN__) || defined(CONFIG_NATIVE_WINDOWS) - -static inline unsigned short wpa_swap_16(unsigned short v) -{ - return ((v & 0xff) << 8) | (v >> 8); -} - -static inline unsigned int wpa_swap_32(unsigned int v) -{ - return ((v & 0xff) << 24) | ((v & 0xff00) << 8) | - ((v & 0xff0000) >> 8) | (v >> 24); -} - -#define le_to_host16(n) (n) -#define host_to_le16(n) (n) -#define be_to_host16(n) wpa_swap_16(n) -#define host_to_be16(n) wpa_swap_16(n) -#define le_to_host32(n) (n) -#define be_to_host32(n) wpa_swap_32(n) -#define host_to_be32(n) wpa_swap_32(n) - -#else /* __CYGWIN__ */ - -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define le_to_host16(n) (n) -#define host_to_le16(n) (n) -#define be_to_host16(n) bswap_16(n) -#define host_to_be16(n) bswap_16(n) -#define le_to_host32(n) (n) -#define be_to_host32(n) bswap_32(n) -#define host_to_be32(n) bswap_32(n) -#elif __BYTE_ORDER == __BIG_ENDIAN -#define le_to_host16(n) bswap_16(n) -#define host_to_le16(n) bswap_16(n) -#define be_to_host16(n) (n) -#define host_to_be16(n) (n) -#define le_to_host32(n) bswap_32(n) -#define be_to_host32(n) (n) -#define host_to_be32(n) (n) -#ifndef WORDS_BIGENDIAN -#define WORDS_BIGENDIAN -#endif -#else -#error Could not determine CPU byte order -#endif - -#endif /* __CYGWIN__ */ - -/* Macros for handling unaligned 16-bit variables */ -#define WPA_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1])) -#define WPA_PUT_BE16(a, val) \ - do { \ - (a)[0] = ((u16) (val)) >> 8; \ - (a)[1] = ((u16) (val)) & 0xff; \ - } while (0) - -#define WPA_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0])) -#define WPA_PUT_LE16(a, val) \ - do { \ - (a)[1] = ((u16) (val)) >> 8; \ - (a)[0] = ((u16) (val)) & 0xff; \ - } while (0) - -#define WPA_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \ - (((u32) (a)[2]) << 8) | ((u32) (a)[3])) - - -#ifndef ETH_ALEN -#define ETH_ALEN 6 -#endif - -#include -typedef uint64_t u64; -typedef uint32_t u32; -typedef uint16_t u16; -typedef uint8_t u8; -typedef int64_t s64; -typedef int32_t s32; -typedef int16_t s16; -typedef int8_t s8; - -int hostapd_get_rand(u8 *buf, size_t len); -void hostapd_hexdump(const char *title, const u8 *buf, size_t len); -int hwaddr_aton(const char *txt, u8 *addr); -int hexstr2bin(const char *hex, u8 *buf, size_t len); -char * rel2abs_path(const char *rel_path); -void inc_byte_array(u8 *counter, size_t len); -void print_char(char c); -void fprint_char(FILE *f, char c); - - -/* Debugging function - conditional printf and hex dump. Driver wrappers can - * use these for debugging purposes. */ - -enum { MSG_MSGDUMP, MSG_DEBUG, MSG_INFO, MSG_WARNING, MSG_ERROR }; - -#ifdef CONFIG_NO_STDOUT_DEBUG - -#define wpa_debug_print_timestamp() do { } while (0) -#define wpa_printf(args...) do { } while (0) -#define wpa_hexdump(args...) do { } while (0) -#define wpa_hexdump_key(args...) do { } while (0) -#define wpa_hexdump_ascii(args...) do { } while (0) -#define wpa_hexdump_ascii_key(args...) do { } while (0) - -#else /* CONFIG_NO_STDOUT_DEBUG */ - -/** - * wpa_debug_printf_timestamp - Print timestamp for debug output - * - * This function prints a timestamp in . - * format if debug output has been configured to include timestamps in debug - * messages. - */ -void wpa_debug_print_timestamp(void); - -/** - * wpa_printf - conditional printf - * @level: priority level (MSG_*) of the message - * @fmt: printf format string, followed by optional arguments - * - * This function is used to print conditional debugging and error messages. The - * output may be directed to stdout, stderr, and/or syslog based on - * configuration. - * - * Note: New line '\n' is added to the end of the text when printing to stdout. - */ -void wpa_printf(int level, char *fmt, ...) -__attribute__ ((format (printf, 2, 3))); - -/** - * wpa_hexdump - conditional hex dump - * @level: priority level (MSG_*) of the message - * @title: title of for the message - * @buf: data buffer to be dumped - * @len: length of the buf - * - * This function is used to print conditional debugging and error messages. The - * output may be directed to stdout, stderr, and/or syslog based on - * configuration. The contents of buf is printed out has hex dump. - */ -void wpa_hexdump(int level, const char *title, const u8 *buf, size_t len); - -/** - * wpa_hexdump_key - conditional hex dump, hide keys - * @level: priority level (MSG_*) of the message - * @title: title of for the message - * @buf: data buffer to be dumped - * @len: length of the buf - * - * This function is used to print conditional debugging and error messages. The - * output may be directed to stdout, stderr, and/or syslog based on - * configuration. The contents of buf is printed out has hex dump. This works - * like wpa_hexdump(), but by default, does not include secret keys (passwords, - * etc.) in debug output. - */ -void wpa_hexdump_key(int level, const char *title, const u8 *buf, size_t len); - -/** - * wpa_hexdump_ascii - conditional hex dump - * @level: priority level (MSG_*) of the message - * @title: title of for the message - * @buf: data buffer to be dumped - * @len: length of the buf - * - * This function is used to print conditional debugging and error messages. The - * output may be directed to stdout, stderr, and/or syslog based on - * configuration. The contents of buf is printed out has hex dump with both - * the hex numbers and ASCII characters (for printable range) are shown. 16 - * bytes per line will be shown. - */ -void wpa_hexdump_ascii(int level, const char *title, const u8 *buf, - size_t len); - -/** - * wpa_hexdump_ascii_key - conditional hex dump, hide keys - * @level: priority level (MSG_*) of the message - * @title: title of for the message - * @buf: data buffer to be dumped - * @len: length of the buf - * - * This function is used to print conditional debugging and error messages. The - * output may be directed to stdout, stderr, and/or syslog based on - * configuration. The contents of buf is printed out has hex dump with both - * the hex numbers and ASCII characters (for printable range) are shown. 16 - * bytes per line will be shown. This works like wpa_hexdump_ascii(), but by - * default, does not include secret keys (passwords, etc.) in debug output. - */ -void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf, - size_t len); - -#endif /* CONFIG_NO_STDOUT_DEBUG */ - - -#ifdef EAPOL_TEST -#define WPA_ASSERT(a) \ - do { \ - if (!(a)) { \ - printf("WPA_ASSERT FAILED '" #a "' " \ - "%s %s:%d\n", \ - __FUNCTION__, __FILE__, __LINE__); \ - exit(1); \ - } \ - } while (0) -#else -#define WPA_ASSERT(a) do { } while (0) -#endif - -#endif /* COMMON_H */ diff --git a/usr.sbin/802_11/wpa_supplicant/driver_dragonfly.c b/usr.sbin/802_11/wpa_supplicant/driver_dragonfly.c index b84c2ca988..77661d7b74 100644 --- a/usr.sbin/802_11/wpa_supplicant/driver_dragonfly.c +++ b/usr.sbin/802_11/wpa_supplicant/driver_dragonfly.c @@ -11,8 +11,8 @@ * * See README and COPYING for more details. * - * $FreeBSD: src/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c,v 1.5.2.4 2006/03/24 01:43:18 sam Exp $ - * $DragonFly: src/usr.sbin/802_11/wpa_supplicant/driver_dragonfly.c,v 1.1 2006/06/24 07:29:44 sephe Exp $ + * $FreeBSD: src/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c,v 1.14 2007/06/11 03:57:46 sam Exp $ + * $DragonFly: src/usr.sbin/802_11/wpa_supplicant/driver_dragonfly.c,v 1.2 2007/08/07 11:25:37 sephe Exp $ */ #include @@ -97,7 +97,6 @@ set80211param(struct wpa_driver_bsd_data *drv, int op, int arg) ireq.i_val = arg; if (ioctl(drv->sock, SIOCS80211, &ireq) < 0) { - perror("ioctl[SIOCS80211]"); fprintf(stderr, "ioctl[SIOCS80211, op %u, arg 0x%x]: %s\n", op, arg, strerror(errno)); return -1; @@ -115,7 +114,6 @@ get80211param(struct wpa_driver_bsd_data *drv, int op) ireq.i_type = op; if (ioctl(drv->sock, SIOCG80211, &ireq) < 0) { - perror("ioctl[SIOCG80211]"); fprintf(stderr, "ioctl[SIOCG80211, op %u]: %s\n", op, strerror(errno)); return -1; @@ -258,7 +256,7 @@ wpa_driver_bsd_set_key(void *priv, wpa_alg alg, struct ieee80211req_key wk; struct ether_addr ea; char *alg_name; - u_int8_t cipher; + uint8_t cipher; if (alg == WPA_ALG_NONE) return wpa_driver_bsd_del_key(drv, key_idx, addr); @@ -288,7 +286,7 @@ wpa_driver_bsd_set_key(void *priv, wpa_alg alg, __func__, alg_name, ether_ntoa(&ea), key_idx, set_tx, seq_len, key_len); - if (seq_len > sizeof(u_int64_t)) { + if (seq_len > sizeof(uint64_t)) { wpa_printf(MSG_DEBUG, "%s: seq_len %zu too big", __func__, seq_len); return -2; @@ -320,6 +318,7 @@ wpa_driver_bsd_set_key(void *priv, wpa_alg alg, wk.ik_flags |= IEEE80211_KEY_DEFAULT; wk.ik_keylen = key_len; memcpy(&wk.ik_keyrsc, seq, seq_len); + wk.ik_keyrsc = le64toh(wk.ik_keyrsc); memcpy(wk.ik_keydata, key, key_len); return set80211var(drv, IEEE80211_IOC_WPAKEY, &wk, sizeof(wk)); @@ -433,6 +432,9 @@ wpa_driver_bsd_set_auth_alg(void *priv, int auth_alg) else authmode = IEEE80211_AUTH_OPEN; + wpa_printf(MSG_DEBUG, "%s alg 0x%x authmode %u", + __func__, auth_alg, authmode); + return set80211param(drv, IEEE80211_IOC_AUTHMODE, authmode); } @@ -586,7 +588,7 @@ wpa_scan_result_compar(const void *a, const void *b) } static int -getmaxrate(uint8_t rates[15], uint8_t nrates) +getmaxrate(const uint8_t rates[15], uint8_t nrates) { int i, maxrate = -1; @@ -600,14 +602,14 @@ getmaxrate(uint8_t rates[15], uint8_t nrates) /* unalligned little endian access */ #define LE_READ_4(p) \ - ((u_int32_t) \ - ((((const u_int8_t *)(p))[0] ) | \ - (((const u_int8_t *)(p))[1] << 8) | \ - (((const u_int8_t *)(p))[2] << 16) | \ - (((const u_int8_t *)(p))[3] << 24))) + ((uint32_t) \ + ((((const uint8_t *)(p))[0] ) | \ + (((const uint8_t *)(p))[1] << 8) | \ + (((const uint8_t *)(p))[2] << 16) | \ + (((const uint8_t *)(p))[3] << 24))) static int __inline -iswpaoui(const u_int8_t *frm) +iswpaoui(const uint8_t *frm) { return frm[1] > 3 && LE_READ_4(frm+2) == ((WPA_OUI_TYPE<<24)|WPA_OUI); } @@ -620,8 +622,8 @@ wpa_driver_bsd_get_scan_results(void *priv, #define min(a,b) ((a)>(b)?(b):(a)) struct wpa_driver_bsd_data *drv = priv; uint8_t buf[24*1024]; - uint8_t *cp, *vp; - struct ieee80211req_scan_result *sr; + const uint8_t *cp, *vp; + const struct ieee80211req_scan_result *sr; struct wpa_scan_result *wsr; int len, ielen; @@ -633,7 +635,7 @@ wpa_driver_bsd_get_scan_results(void *priv, cp = buf; wsr = results; while (len >= sizeof(struct ieee80211req_scan_result)) { - sr = (struct ieee80211req_scan_result *) cp; + sr = (const struct ieee80211req_scan_result *) cp; memcpy(wsr->bssid, sr->isr_bssid, IEEE80211_ADDR_LEN); wsr->ssid_len = sr->isr_ssid_len; wsr->freq = sr->isr_freq; @@ -642,7 +644,7 @@ wpa_driver_bsd_get_scan_results(void *priv, wsr->level = 0; /* XXX? */ wsr->caps = sr->isr_capinfo; wsr->maxrate = getmaxrate(sr->isr_rates, sr->isr_nrates); - vp = (u_int8_t *)(sr+1); + vp = (uint8_t *)(sr+1); memcpy(wsr->ssid, vp, sr->isr_ssid_len); if (sr->isr_ie_len > 0) { vp += sr->isr_ssid_len; diff --git a/usr.sbin/802_11/wpa_supplicant/driver_wired.c.patch b/usr.sbin/802_11/wpa_supplicant/driver_wired.c.patch new file mode 100644 index 0000000000..b816b827e8 --- /dev/null +++ b/usr.sbin/802_11/wpa_supplicant/driver_wired.c.patch @@ -0,0 +1,34 @@ +$DragonFly: src/usr.sbin/802_11/wpa_supplicant/driver_wired.c.patch,v 1.1 2007/08/07 11:25:37 sephe Exp $ +diff -urp wpa_supplicant-0.5.8/driver_wired.c /usr/src/contrib/wpa_supplicant-0.5.8/driver_wired.c +--- driver_wired.c 2007-05-29 08:41:52.000000000 +0800 ++++ driver_wired.c 2007-07-22 11:35:36.000000000 +0800 +@@ -18,9 +18,9 @@ + #ifdef __linux__ + #include + #endif /* __linux__ */ +-#ifdef __FreeBSD__ ++#if defined(__FreeBSD__) || defined(__DragonFly__) + #include +-#endif /* __FreeBSD__ */ ++#endif /* __FreeBSD__ || __DragonFly__ */ + + #include "common.h" + #include "driver.h" +@@ -119,7 +119,7 @@ static int wpa_driver_wired_multi(const + ifr.ifr_hwaddr.sa_family = AF_UNSPEC; + os_memcpy(ifr.ifr_hwaddr.sa_data, addr, ETH_ALEN); + #endif /* __linux__ */ +-#ifdef __FreeBSD__ ++#if defined(__FreeBSD__) || defined(__DragonFly__) + { + struct sockaddr_dl *dlp; + dlp = (struct sockaddr_dl *) &ifr.ifr_addr; +@@ -131,7 +131,7 @@ static int wpa_driver_wired_multi(const + dlp->sdl_slen = 0; + os_memcpy(LLADDR(dlp), addr, ETH_ALEN); + } +-#endif /* __FreeBSD__ */ ++#endif /* __FreeBSD__ || __DragonFly__ */ + + if (ioctl(s, add ? SIOCADDMULTI : SIOCDELMULTI, (caddr_t) &ifr) < 0) { + perror("ioctl[SIOC{ADD/DEL}MULTI]"); diff --git a/usr.sbin/802_11/wpa_supplicant/events.c.patch b/usr.sbin/802_11/wpa_supplicant/events.c.patch new file mode 100644 index 0000000000..2eb4914059 --- /dev/null +++ b/usr.sbin/802_11/wpa_supplicant/events.c.patch @@ -0,0 +1,35 @@ +$DragonFly: src/usr.sbin/802_11/wpa_supplicant/events.c.patch,v 1.1 2007/08/07 11:25:37 sephe Exp $ +diff -urp wpa_supplicant-0.5.8/events.c /usr/src/contrib/wpa_supplicant-0.5.8/events.c +--- events.c 2007-05-29 08:39:51.000000000 +0800 ++++ events.c 2007-07-22 12:50:20.000000000 +0800 +@@ -802,6 +802,18 @@ wpa_supplicant_event_michael_mic_failure + } + + ++#ifdef CONFIG_TERMINATE_ONLASTIF ++static int any_interfaces(struct wpa_supplicant *head) ++{ ++ struct wpa_supplicant *wpa_s; ++ ++ for (wpa_s = head; wpa_s != NULL; wpa_s = wpa_s->next) ++ if (!wpa_s->interface_removed) ++ return 1; ++ return 0; ++} ++#endif /* CONFIG_TERMINATE_ONLASTIF */ ++ + static void + wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s, + union wpa_event_data *data) +@@ -826,6 +838,11 @@ wpa_supplicant_event_interface_status(st + wpa_supplicant_mark_disassoc(wpa_s); + l2_packet_deinit(wpa_s->l2); + wpa_s->l2 = NULL; ++#ifdef CONFIG_TERMINATE_ONLASTIF ++ /* check if last interface */ ++ if (!any_interfaces(wpa_s->global->ifaces)) ++ eloop_terminate(); ++#endif /* CONFIG_TERMINATE_ONLASTIF */ + break; + } + } diff --git a/usr.sbin/802_11/wpa_supplicant/wpa_supplicant.8 b/usr.sbin/802_11/wpa_supplicant/wpa_supplicant.8 index b497034341..92c108350b 100644 --- a/usr.sbin/802_11/wpa_supplicant/wpa_supplicant.8 +++ b/usr.sbin/802_11/wpa_supplicant/wpa_supplicant.8 @@ -23,9 +23,9 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD: src/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.8,v 1.2 2005/06/27 06:40:43 ru Exp $ -.\" $DragonFly: src/usr.sbin/802_11/wpa_supplicant/wpa_supplicant.8,v 1.4 2006/07/07 17:14:34 swildner Exp $ +.\" $DragonFly: src/usr.sbin/802_11/wpa_supplicant/wpa_supplicant.8,v 1.5 2007/08/07 11:25:37 sephe Exp $ .\" -.Dd June 24, 2006 +.Dd July 22, 2007 .Dt WPA_SUPPLICANT 8 .Os .Sh NAME @@ -122,9 +122,13 @@ If multiple interfaces are specified then will manage them all with a single process. .El .Sh SEE ALSO +.Xr acx 4 , +.Xr ath 4 , .Xr ipw 4 , .Xr iwi 4 , .Xr ral 4 , +.Xr rum 4 , +.Xr ural 4 , .Xr wi 4 , .Xr wlan 4 , .Xr wpa_supplicant.conf 5 , diff --git a/usr.sbin/802_11/wpa_supplicant/wpa_supplicant.conf.5 b/usr.sbin/802_11/wpa_supplicant/wpa_supplicant.conf.5 index 1500887ec3..7e6fadb356 100644 --- a/usr.sbin/802_11/wpa_supplicant/wpa_supplicant.conf.5 +++ b/usr.sbin/802_11/wpa_supplicant/wpa_supplicant.conf.5 @@ -22,10 +22,10 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.conf.5,v 1.3.2.4 2006/02/21 17:19:54 sam Exp $ -.\" $DragonFly: src/usr.sbin/802_11/wpa_supplicant/wpa_supplicant.conf.5,v 1.3 2007/05/17 08:19:03 swildner Exp $ +.\" $FreeBSD: src/usr.sbin/wpa/wpa_supplicant/wpa_supplicant.conf.5,v 1.9 2007/07/11 16:04:08 sam Exp $ +.\" $DragonFly: src/usr.sbin/802_11/wpa_supplicant/wpa_supplicant.conf.5,v 1.4 2007/08/07 11:25:37 sephe Exp $ .\" -.Dd June 24, 2006 +.Dd July 22, 2007 .Dt WPA_SUPPLICANT.CONF 5 .Os .Sh NAME @@ -219,7 +219,8 @@ an 8-63 character .Tn ASCII passphrase. .Tn ASCII -passphrases are converted to a 256-bit key using the network SSID. +passphrases are dynamically converted to a 256-bit key at runtime +using the network SSID. .It Va eapol_flags Dynamic WEP key usage for non-WPA mode, specified as a bit field. Bit 0 (1) forces dynamically generated unicast WEP keys to be used. @@ -259,6 +260,10 @@ Identity string for EAP. .It Va anonymous_identity Anonymous identity string for EAP (to be used as the unencrypted identity with EAP types that support different tunneled identities; e.g.\& EAP-TTLS). +.It Va mixed_cell +Configure whether networks that allow both plaintext and encryption +are allowed when selecting a BSS from the scan results. +By default this is set to 0 (disabled). .It Va password Password string for EAP. .It Va ca_cert -- 2.11.4.GIT