Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Sep 2005 21:24:04 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 83712 for review
Message-ID:  <200509152124.j8FLO42I025246@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=83712

Change 83712 by sam@sam_ebb on 2005/09/15 21:23:52

	IFC and list caps fixup

Affected files ...

.. //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#46 edit

Differences ...

==== //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#46 (text+ko) ====

@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sbin/ifconfig/ifieee80211.c,v 1.23 2005/08/01 16:34:41 sam Exp $
+ * $FreeBSD: src/sbin/ifconfig/ifieee80211.c,v 1.24 2005/08/03 20:57:33 stefanf Exp $
  */
 
 /*-
@@ -301,8 +301,8 @@
 }
 
 /*
- * This function is purly a NetBSD compatability interface.  The NetBSD
- * iterface is too inflexable, but it's there so we'll support it since
+ * This function is purely a NetBSD compatability interface.  The NetBSD
+ * interface is too inflexible, but it's there so we'll support it since
  * it's not all that hard.
  */
 static void
@@ -636,6 +636,30 @@
 }
 
 static
+DECL_CMD_FUNC(set80211kickmac, val, d)
+{
+	char *temp;
+	struct sockaddr_dl sdl;
+	struct ieee80211req_mlme mlme;
+
+	temp = malloc(strlen(val) + 1);
+	if (temp == NULL)
+		errx(1, "malloc failed");
+	temp[0] = ':';
+	strcpy(temp + 1, val);
+	sdl.sdl_len = sizeof(sdl);
+	link_addr(temp, &sdl);
+	free(temp);
+	if (sdl.sdl_alen != IEEE80211_ADDR_LEN)
+		errx(1, "malformed link-level address");
+	memset(&mlme, 0, sizeof(mlme));
+	mlme.im_op = IEEE80211_MLME_DEAUTH;
+	mlme.im_reason = IEEE80211_REASON_AUTH_EXPIRE;
+	memcpy(mlme.im_macaddr, LLADDR(&sdl), IEEE80211_ADDR_LEN);
+	set80211(s, IEEE80211_IOC_MLME, 0, sizeof(mlme), (u_int8_t *) &mlme);
+}
+
+static
 DECL_CMD_FUNC(set80211maccmd, val, d)
 {
 	set80211(s, IEEE80211_IOC_MACCMD, d, 0, NULL);
@@ -827,7 +851,7 @@
 	return maxlen;
 }
 
-/* unalligned little endian access */     
+/* unaligned little endian access */     
 #define LE_READ_4(p)					\
 	((u_int32_t)					\
 	 ((((const u_int8_t *)(p))[0]      ) |		\
@@ -1109,7 +1133,7 @@
 }
 
 #define	IEEE80211_C_BITS \
-"\020\1WEP\2TKIP\3AES\4AES_CCM\6CKIP\11IBSS\12PMGT\13HOSTAP\14AHDEMO" \
+"\020\1WEP\2TKIP\3AES\4AES_CCM\6CKIP\7FF\10TURBOP\11IBSS\12PMGT\13HOSTAP\14AHDEMO" \
 "\15SWRETRY\16TXPMGT\17SHSLOT\20SHPREAMBLE\21MONITOR\22TKIPMIC\30WPA1" \
 "\31WPA2\32BURST\33WME\34WDS\36BGSCAN\37TXFRAG"
 
@@ -1187,6 +1211,63 @@
 	}
 }
 
+static void
+list_mac(int s)
+{
+	struct ieee80211req ireq;
+	struct ieee80211req_maclist *acllist;
+	int i, nacls, policy;
+	char c;
+
+	(void) memset(&ireq, 0, sizeof(ireq));
+	(void) strncpy(ireq.i_name, name, sizeof(ireq.i_name)); /* XXX ?? */
+	ireq.i_type = IEEE80211_IOC_MACCMD;
+	ireq.i_val = IEEE80211_MACCMD_POLICY;
+	if (ioctl(s, SIOCG80211, &ireq) < 0) {
+		if (errno == EINVAL) {
+			printf("No acl policy loaded\n");
+			return;
+		}
+		err(1, "unable to get mac policy");
+	}
+	policy = ireq.i_val;
+
+	ireq.i_val = IEEE80211_MACCMD_LIST;
+	ireq.i_len = 0;
+	if (ioctl(s, SIOCG80211, &ireq) < 0)
+		err(1, "unable to get mac acl list size");
+	if (ireq.i_len == 0)		/* NB: no acls */
+		return;
+
+	ireq.i_data = malloc(ireq.i_len);
+	if (ireq.i_data == NULL)
+		err(1, "out of memory for acl list");
+
+	if (ioctl(s, SIOCG80211, &ireq) < 0)
+		err(1, "unable to get mac acl list");
+	if (policy == IEEE80211_MACCMD_POLICY_OPEN) {
+		if (verbose)
+			printf("policy: open\n");
+		c = '*';
+	} else if (policy == IEEE80211_MACCMD_POLICY_ALLOW) {
+		if (verbose)
+			printf("policy: allow\n");
+		c = '+';
+	} else if (policy == IEEE80211_MACCMD_POLICY_DENY) {
+		if (verbose)
+			printf("policy: deny\n");
+		c = '-';
+	} else {
+		printf("policy: unknown (%u)\n", policy);
+		c = '?';
+	}
+	nacls = ireq.i_len / sizeof(*acllist);
+	acllist = (struct ieee80211req_maclist *) ireq.i_data;
+	for (i = 0; i < nacls; i++)
+		printf("%c%s\n", c, ether_ntoa(
+			(const struct ether_addr *) acllist[i].ml_macaddr));
+}
+
 static
 DECL_CMD_FUNC(set80211list, arg, d)
 {
@@ -1206,6 +1287,8 @@
 		list_capabilities(s);
 	else if (iseq(arg, "wme"))
 		list_wme(s);
+	else if (iseq(arg, "mac"))
+		list_mac(s);
 	else
 		errx(1, "Don't know how to list %s for %s", arg, name);
 #undef iseq
@@ -1404,7 +1487,7 @@
 	ireq.i_type = IEEE80211_IOC_SSID;
 	ireq.i_val = -1;
 	if (ioctl(s, SIOCG80211, &ireq) < 0) {
-		/* If we can't get the SSID, the this isn't an 802.11 device. */
+		/* If we can't get the SSID, this isn't an 802.11 device. */
 		return;
 	}
 	num = 0;
@@ -1970,9 +2053,7 @@
 	DEF_CMD("mac:detach",	IEEE80211_MACCMD_DETACH,	set80211maccmd),
 	DEF_CMD_ARG("mac:add",		set80211addmac),
 	DEF_CMD_ARG("mac:del",		set80211delmac),
-#if 0
 	DEF_CMD_ARG("mac:kick",		set80211kickmac),
-#endif
 	DEF_CMD("pureg",	1,	set80211pureg),
 	DEF_CMD("-pureg",	0,	set80211pureg),
 	DEF_CMD("ff",		1,	set80211fastframes),



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200509152124.j8FLO42I025246>