summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzf162725 <none@none>2008-04-10 21:10:35 -0700
committerzf162725 <none@none>2008-04-10 21:10:35 -0700
commitfb91fd8a302dfb13e250bbefb6a3970c2edc3ae3 (patch)
tree056a7b71d18d0805d7be769a77664bb410550e8e
parent22dc213396fdd861beeb93f8cb17eaaeb9960cf4 (diff)
downloadillumos-joyent-fb91fd8a302dfb13e250bbefb6a3970c2edc3ae3.tar.gz
6564957 WPA_STRSIZE needs to go
6564958 formatting glitches in <net/wpa.h> 6564959 unused structures adrift in <net/wpa.h> 6566819 IEEE802.11 header definitions should be centralized 6673764 wpad(1M) usage message incorrectly references wpa_supplicant 6673772 Additional instances of wpad(1M) dump core at startup 6685997 kstat -m opackets is zero of ral driver 6685998 net80211 header files hdrchk warnings
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c7
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h3
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c47
-rw-r--r--usr/src/pkgdefs/etc/exception_list_i3864
-rw-r--r--usr/src/pkgdefs/etc/exception_list_sparc4
-rw-r--r--usr/src/uts/common/io/ral/rt2560.c8
-rw-r--r--usr/src/uts/common/net/wpa.h127
-rw-r--r--usr/src/uts/common/sys/Makefile3
-rw-r--r--usr/src/uts/common/sys/net80211.h6
-rw-r--r--usr/src/uts/common/sys/net80211_crypto.h22
-rw-r--r--usr/src/uts/common/sys/net80211_proto.h6
11 files changed, 107 insertions, 130 deletions
diff --git a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c
index 999e80cfb1..75fff828e2 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c
+++ b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c
@@ -32,8 +32,7 @@ static void pmksa_cache_set_expiration(struct wpa_supplicant *);
* IEEE 802.11i/D3.0
*/
static const int WPA_SELECTOR_LEN = 4;
-static const uint8_t WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 };
-static const uint16_t WPA_VERSION = 1;
+static const uint8_t WPA_OUI_AND_TYPE[] = { 0x00, 0x50, 0xf2, 1 };
static const uint8_t
WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x50, 0xf2, 1 };
static const uint8_t
@@ -361,7 +360,7 @@ wpa_parse_wpa_ie_wpa(struct wpa_supplicant *wpa_s, uint8_t *wpa_ie,
if (hdr->elem_id != GENERIC_INFO_ELEM ||
hdr->len != wpa_ie_len - 2 ||
- memcmp(&hdr->oui, WPA_OUI_TYPE, WPA_SELECTOR_LEN) != 0 ||
+ memcmp(&hdr->oui, WPA_OUI_AND_TYPE, WPA_SELECTOR_LEN) != 0 ||
LE_16(hdr->version) != WPA_VERSION) {
wpa_printf(MSG_DEBUG, "%s: malformed ie or unknown version",
"wpa_parse_wpa_ie_wpa");
@@ -570,7 +569,7 @@ wpa_gen_wpa_ie_wpa(struct wpa_supplicant *wpa_s, uint8_t *wpa_ie)
hdr = (struct wpa_ie_hdr *)wpa_ie;
hdr->elem_id = GENERIC_INFO_ELEM;
- (void) memcpy(&hdr->oui, WPA_OUI_TYPE, WPA_SELECTOR_LEN);
+ (void) memcpy(&hdr->oui, WPA_OUI_AND_TYPE, WPA_SELECTOR_LEN);
hdr->version = LE_16(WPA_VERSION);
pos = (uint8_t *)(hdr + 1);
diff --git a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h
index 7745ec1c7f..2e043e6a37 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h
+++ b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h
@@ -15,6 +15,7 @@
#include <net/wpa.h>
#include <libdladm.h>
+#include <libdllink.h>
#ifdef __cplusplus
extern "C" {
@@ -166,7 +167,7 @@ struct wpa_supplicant {
unsigned char own_addr[IEEE80211_ADDR_LEN];
datalink_id_t linkid;
- char kname[WPA_STRSIZE];
+ char kname[DLADM_SECOBJ_NAME_MAX];
uint8_t pmk[PMK_LEN];
diff --git a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c
index 06663383f7..889d671b48 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c
+++ b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c
@@ -22,6 +22,7 @@
#include <signal.h>
#include <fcntl.h>
#include <door.h>
+#include <libscf.h>
#include <libdladm.h>
#include <libdllink.h>
#include <sys/ethernet.h>
@@ -32,9 +33,6 @@
#include "eloop.h"
#include "l2_packet.h"
-static const char *wpa_supplicant_version =
-"wpa_supplicant v1.0";
-
extern struct wpa_driver_ops wpa_driver_wifi_ops;
int wpa_debug_level = MSG_ERROR;
@@ -799,16 +797,16 @@ daemon(boolean_t nochdir, boolean_t noclose)
return (0);
}
-static void
-usage(void)
+/*
+ * make sure wpad is running under SMF context.
+ */
+static boolean_t
+is_smf_context(void)
{
- (void) printf("%s\n\n"
- "usage:\n"
- " wpa_supplicant [-hv] -i<ifname> -k<keyname>\n"
- "options:\n"
- " -h = show this help text\n"
- " -v = show version\n",
- wpa_supplicant_version);
+ char *fmri;
+
+ return (((fmri = getenv("SMF_FMRI")) != NULL) &&
+ (strstr(fmri, SERVICE_NAME) != NULL));
}
int
@@ -822,31 +820,28 @@ main(int argc, char *argv[])
dladm_phys_attr_t dpa;
int c;
int exitcode;
- char door_file[WPA_STRSIZE];
+ char door_file[MAXPATHLEN];
+
+ if (!is_smf_context()) {
+ (void) fprintf(stderr,
+ "wpad is an smf(5) managed service and cannot be run from "
+ "the command line; please use dladm(1M).\n");
+ return (SMF_EXIT_ERR_NOSMF);
+ }
for (;;) {
- c = getopt(argc, argv, "Dk:hi:v");
+ c = getopt(argc, argv, "i:k:");
if (c < 0)
break;
switch (c) {
- case 'D':
- wpa_debug_level = MSG_DEBUG;
- break;
- case 'h':
- usage();
- return (-1);
case 'i':
link = optarg;
break;
case 'k':
key = optarg;
break;
- case 'v':
- (void) printf("%s\n", wpa_supplicant_version);
- return (-1);
default:
- usage();
- return (-1);
+ return (SMF_EXIT_ERR_CONFIG);
}
}
@@ -895,7 +890,7 @@ main(int argc, char *argv[])
dlpi_close(dh);
return (-1);
}
- (void) snprintf(door_file, WPA_STRSIZE, "%s_%s", WPA_DOOR, dpa.dp_dev);
+ (void) snprintf(door_file, MAXPATHLEN, "%s_%s", WPA_DOOR, dpa.dp_dev);
(void) memset(&wpa_s, 0, sizeof (wpa_s));
wpa_s.driver = &wpa_driver_wifi_ops;
diff --git a/usr/src/pkgdefs/etc/exception_list_i386 b/usr/src/pkgdefs/etc/exception_list_i386
index a947259b21..02ef16aa77 100644
--- a/usr/src/pkgdefs/etc/exception_list_i386
+++ b/usr/src/pkgdefs/etc/exception_list_i386
@@ -627,6 +627,10 @@ usr/lib/devfsadm/linkmod/SUNW_ieee1394_link.so i386
usr/include/sys/1394/ieee1212.h i386
usr/include/sys/1394/t1394.h i386
usr/include/sys/1394/id1394.h i386
+# Private net80211 headers
+usr/include/sys/net80211.h i386
+usr/include/sys/net80211_proto.h i386
+usr/include/sys/net80211_crypto.h i386
#
# PPPoE files not delivered to customers.
usr/include/net/pppoe.h i386
diff --git a/usr/src/pkgdefs/etc/exception_list_sparc b/usr/src/pkgdefs/etc/exception_list_sparc
index 942e27489b..4f281fada4 100644
--- a/usr/src/pkgdefs/etc/exception_list_sparc
+++ b/usr/src/pkgdefs/etc/exception_list_sparc
@@ -633,6 +633,10 @@ usr/platform/sun4u/include/sys/fcode.h sparc
usr/include/net/pppoe.h sparc
usr/include/net/sppptun.h sparc
usr/include/net/wpa.h sparc
+# Private net80211 headers
+usr/include/sys/net80211.h sparc
+usr/include/sys/net80211_proto.h sparc
+usr/include/sys/net80211_crypto.h sparc
#
# User<->kernel interface used by cfgadm/USB only
#
diff --git a/usr/src/uts/common/io/ral/rt2560.c b/usr/src/uts/common/io/ral/rt2560.c
index 84e7f8139e..6790f76016 100644
--- a/usr/src/uts/common/io/ral/rt2560.c
+++ b/usr/src/uts/common/io/ral/rt2560.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -1544,6 +1544,9 @@ rt2560_mgmt_send(ieee80211com_t *ic, mblk_t *mp, uint8_t type)
sc->sc_tx_timer = 5;
+ ic->ic_stats.is_tx_frags++;
+ ic->ic_stats.is_tx_bytes += pktlen;
+
fail3:
ieee80211_free_node(ni);
fail2:
@@ -1694,6 +1697,9 @@ rt2560_send(ieee80211com_t *ic, mblk_t *mp)
sc->sc_tx_timer = 5;
+ ic->ic_stats.is_tx_frags++;
+ ic->ic_stats.is_tx_bytes += pktlen;
+
freemsg(mp);
fail3:
ieee80211_free_node(ni);
diff --git a/usr/src/uts/common/net/wpa.h b/usr/src/uts/common/net/wpa.h
index 08e8342744..f57c0ab9de 100644
--- a/usr/src/uts/common/net/wpa.h
+++ b/usr/src/uts/common/net/wpa.h
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -32,103 +32,72 @@
#pragma ident "%Z%%M% %I% %E% SMI"
-#include <sys/types.h>
#include <inet/wifi_ioctl.h>
+#include <sys/net80211_crypto.h>
#ifdef __cplusplus
extern "C" {
#endif
-#define SERVICE_NAME "network/wpa"
-#define WPA_DOOR "/var/run/wpa_door"
-#define SVC_METHOD "/usr/lib/inet/wpad"
-
-#define IEEE80211_ADDR_LEN 6
-#define IEEE80211_MAX_WPA_IE 40 /* IEEE802.11i */
-#define WPA_STRSIZE 256
-/*
- * Max size of optional information elements. We artificially
- * constrain this; it's limited only by the max frame size (and
- * the max parameter size of the wireless extensions).
- */
-#define IEEE80211_MAX_OPT_IE 256
+#define SERVICE_NAME "network/wpa"
+#define WPA_DOOR "/var/run/wpa_door"
+#define SVC_METHOD "/usr/lib/inet/wpad"
/*
* Parameters.
- * WL_WPA_BASE + 0x1, 5, 6 reserved to be compatible with FreeBSD.
*/
-#define WL_WPA_BASE (WL_PARAMETERS_BASE + 0x500)
-#define WL_SETOPTIE (WL_WPA_BASE + 0x0)
-#define WL_WPA (WL_WPA_BASE + 0x2)
-#define WL_KEY (WL_WPA_BASE + 0x3)
-#define WL_DELKEY (WL_WPA_BASE + 0x4)
-#define WL_SCANRESULTS (WL_WPA_BASE + 0x7)
-#define WL_MLME (WL_WPA_BASE + 0x8)
-#define WL_CAPABILITY (WL_WPA_BASE + 0x9)
+#define WL_WPA_BASE (WL_PARAMETERS_BASE + 0x500)
+#define WL_SETOPTIE (WL_WPA_BASE + 0x0)
+#define WL_WPA (WL_WPA_BASE + 0x2)
+#define WL_KEY (WL_WPA_BASE + 0x3)
+#define WL_DELKEY (WL_WPA_BASE + 0x4)
+#define WL_SCANRESULTS (WL_WPA_BASE + 0x7)
+#define WL_MLME (WL_WPA_BASE + 0x8)
+#define WL_CAPABILITY (WL_WPA_BASE + 0x9)
typedef struct wl_wpa_ie {
- uint32_t wpa_ie_len;
- char wpa_ie[1]; /* it's the head of wpa_ie */
+ uint32_t wpa_ie_len;
+ char wpa_ie[1]; /* it's the head of wpa_ie */
} wl_wpa_ie_t;
typedef struct wl_wpa {
- uint32_t wpa_flag;
+ uint32_t wpa_flag;
} wl_wpa_t;
typedef struct wl_capability {
- uint32_t caps;
+ uint32_t caps;
} wl_capability_t;
-#define IEEE80211_KEYBUF_SIZE 16 /* 128-bit TKIP & CCMP key */
-#define IEEE80211_MICBUF_SIZE (8+8) /* 8 byte tx, 8 byte rx */
-
-/*
- * NB: these values are ordered carefully; there are lots of
- * of implications in any reordering. In particular beware
- * that 4 is not used to avoid conflicting with IEEE80211_F_PRIVACY.
- */
-#define IEEE80211_CIPHER_WEP 0
-#define IEEE80211_CIPHER_TKIP 1
-#define IEEE80211_CIPHER_AES_OCB 2
-#define IEEE80211_CIPHER_AES_CCM 3
-#define IEEE80211_CIPHER_CKIP 4
-#define IEEE80211_CIPHER_NONE 5 /* pseudo value */
-
-#define IEEE80211_CIPHER_MAX (IEEE80211_CIPHER_NONE+1)
-
-/* Key Flags */
-#define IEEE80211_KEY_XMIT 0x01 /* key used for xmit */
-#define IEEE80211_KEY_RECV 0x02 /* key used for recv */
-
-#define IEEE80211_KEY_DEFAULT 0x80 /* default xmit key */
-
/*
- * WPA/RSN get/set key request. Specify the key/cipher
- * type and whether the key is to be used for sending and/or
- * receiving. The key index should be set only when working
- * with global keys (use IEEE80211_KEYIX_NONE for ``no index'').
- * Otherwise a unicast/pairwise key is specified by the bssid
- * (on a station) or mac address (on an ap). They key length
- * must include any MIC key data; otherwise it should be no
- * more than IEEE80211_KEYBUF_SIZE.
+ * WPA/RSN get/set key request.
+ * ik_type : wep/tkip/aes
+ * ik_keyix : should be between 0 and 3, 0 will be used as default key.
+ * ik_keylen: key length in bytes.
+ * ik_keydata and ik_keylen include the DATA key and MIC key.
+ * ik_keyrsc/ik_keytsc: rx/tx seq number.
*/
#pragma pack(1)
typedef struct wl_key {
- uint8_t ik_type; /* key/cipher type */
+ uint8_t ik_type;
uint8_t ik_pad;
- uint16_t ik_keyix; /* key index */
- uint8_t ik_keylen; /* key length in bytes */
+ uint16_t ik_keyix;
+ uint8_t ik_keylen;
uint8_t ik_flags;
uint8_t ik_macaddr[IEEE80211_ADDR_LEN];
- uint64_t ik_keyrsc; /* key receive sequence counter */
- uint64_t ik_keytsc; /* key transmit sequence counter */
+ uint64_t ik_keyrsc;
+ uint64_t ik_keytsc;
uint8_t ik_keydata[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
} wl_key_t;
#pragma pack()
+typedef struct wl_del_key {
+ uint8_t idk_keyix;
+ uint8_t idk_macaddr[IEEE80211_ADDR_LEN];
+} wl_del_key_t;
+
struct wpa_ess {
uint8_t bssid[IEEE80211_ADDR_LEN];
uint8_t ssid[MAX_ESSID_LENGTH];
@@ -139,39 +108,19 @@ struct wpa_ess {
int freq;
};
-typedef struct wl_del_key {
- uint8_t idk_keyix; /* key index */
- uint8_t idk_macaddr[IEEE80211_ADDR_LEN];
-}wl_del_key_t;
-
-typedef struct wl_countermeasures {
- uint32_t cm_flag;
-} wl_countermeasures_t;
-
-typedef struct wl_drop_unenc {
- uint32_t drop_flag;
-} wl_drop_unenc_t;
-
typedef struct wl_wpa_ess {
uint32_t count;
struct wpa_ess ess[1];
} wl_wpa_ess_t;
-#define IEEE80211_MLME_ASSOC 1 /* associate station */
-#define IEEE80211_MLME_DISASSOC 2 /* disassociate station */
-#define IEEE80211_MLME_DEAUTH 3 /* deauthenticate station */
-#define IEEE80211_MLME_AUTHORIZE 4 /* authorize station */
-#define IEEE80211_MLME_UNAUTHORIZE 5 /* unauthorize station */
-
/*
- * * MLME state manipulation request. IEEE80211_MLME_ASSOC
- * * only makes sense when operating as a station. The other
- * * requests can be used when operating as a station or an
- * * ap (to effect a station).
+ * structure for WL_MLME state manipulation request.
+ * im_op: operations include auth/deauth/assoc/disassoc,
+ * im_reason: 802.11 reason code
*/
typedef struct wl_mlme {
- uint8_t im_op; /* operation to perform */
- uint16_t im_reason; /* 802.11 reason code */
+ uint8_t im_op;
+ uint16_t im_reason;
uint8_t im_macaddr[IEEE80211_ADDR_LEN];
} wl_mlme_t;
diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile
index 9ec961664f..d0d531088f 100644
--- a/usr/src/uts/common/sys/Makefile
+++ b/usr/src/uts/common/sys/Makefile
@@ -383,6 +383,9 @@ CHKHDRS= \
nbmlock.h \
ndifm.h \
ndi_impldefs.h \
+ net80211.h \
+ net80211_crypto.h \
+ net80211_proto.h \
netconfig.h \
neti.h \
netstack.h \
diff --git a/usr/src/uts/common/sys/net80211.h b/usr/src/uts/common/sys/net80211.h
index 27bc20522a..39d6abdf6f 100644
--- a/usr/src/uts/common/sys/net80211.h
+++ b/usr/src/uts/common/sys/net80211.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -35,11 +35,11 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifndef _SYS_NET80211_H
#define _SYS_NET80211_H
+#pragma ident "%Z%%M% %I% %E% SMI"
+
#include <sys/mac.h>
#include <sys/ethernet.h>
#include <sys/net80211_proto.h>
diff --git a/usr/src/uts/common/sys/net80211_crypto.h b/usr/src/uts/common/sys/net80211_crypto.h
index 1d0bf250ec..b1c7d149df 100644
--- a/usr/src/uts/common/sys/net80211_crypto.h
+++ b/usr/src/uts/common/sys/net80211_crypto.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -35,11 +35,11 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifndef _SYS_NET80211_CRYPTO_H
#define _SYS_NET80211_CRYPTO_H
+#pragma ident "%Z%%M% %I% %E% SMI"
+
#include <sys/types.h>
#include <sys/mac.h>
#include <sys/net80211_proto.h>
@@ -52,6 +52,20 @@
extern "C" {
#endif
+#define IEEE80211_MAX_WPA_IE 40 /* IEEE802.11i */
+/*
+ * Max size of optional information elements. We artificially
+ * constrain this; it's limited only by the max frame size (and
+ * the max parameter size of the wireless extensions).
+ */
+#define IEEE80211_MAX_OPT_IE 256
+
+#define IEEE80211_MLME_ASSOC 1 /* associate station */
+#define IEEE80211_MLME_DISASSOC 2 /* disassociate station */
+#define IEEE80211_MLME_DEAUTH 3 /* deauthenticate station */
+#define IEEE80211_MLME_AUTHORIZE 4 /* authorize station */
+#define IEEE80211_MLME_UNAUTHORIZE 5 /* unauthorize station */
+
/*
* NB: these values are ordered carefully; there are lots of
* of implications in any reordering.
@@ -84,6 +98,8 @@ extern "C" {
#define IEEE80211_KEY_COMMON /* common flags passed in by apps */ \
(IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV | IEEE80211_KEY_GROUP)
+#define IEEE80211_KEY_DEFAULT 0x80 /* default xmit key */
+
/* WEP */
#define IEEE80211_WEP_KEYLEN 5 /* 40bit */
#define IEEE80211_WEP_IVLEN 3 /* 24bit */
diff --git a/usr/src/uts/common/sys/net80211_proto.h b/usr/src/uts/common/sys/net80211_proto.h
index 8d053fcd42..5df0c7aafa 100644
--- a/usr/src/uts/common/sys/net80211_proto.h
+++ b/usr/src/uts/common/sys/net80211_proto.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -35,11 +35,11 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifndef _SYS_NET80211_PROTO_H
#define _SYS_NET80211_PROTO_H
+#pragma ident "%Z%%M% %I% %E% SMI"
+
/*
* 802.11 protocol definitions
*/