Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Nov 2004 04:56:09 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 64077 for review
Message-ID:  <200411020456.iA24u9eV093105@repoman.freebsd.org>

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

Change 64077 by sam@sam_ebb on 2004/11/02 04:55:18

	o bssid - removes any specfied bssid
	o accept -, any, or off for removing previous specifications
	  (the latter two for compatibility with linux)

Affected files ...

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

Differences ...

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

@@ -97,6 +97,13 @@
     u_int8_t *buf, int *lenp);
 static void print_string(const u_int8_t *buf, int len);
 
+static int
+isanyarg(const char *arg)
+{
+	return (strcmp(arg, "-") == 0 ||
+	    strcasecmp(arg, "any") == 0 || strcasecmp(arg, "off") == 0);
+}
+
 static void
 set80211ssid(const char *val, int d, int s, const struct afswtch *rafp)
 {
@@ -164,7 +171,7 @@
 static void
 set80211channel(const char *val, int d, int s, const struct afswtch *rafp)
 {
-	if (strcmp(val, "-") != 0) {
+	if (!isanyarg(val)) {
 		int v = atoi(val);
 		if (v > 255)		/* treat as frequency */
 			v = ieee80211_mhz2ieee(v);
@@ -449,20 +456,29 @@
 static void
 set80211bssid(const char *val, int d, int s, const struct afswtch *rafp)
 {
-	char *temp;
-	struct sockaddr_dl sdl;
+
+	if (!isanyarg(val)) {
+		char *temp;
+		struct sockaddr_dl sdl;
 
-	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");
-	set80211(s, IEEE80211_IOC_BSSID, 0, IEEE80211_ADDR_LEN, LLADDR(&sdl));
+		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");
+		set80211(s, IEEE80211_IOC_BSSID, 0,
+			IEEE80211_ADDR_LEN, LLADDR(&sdl));
+	} else {
+		uint8_t zerobssid[IEEE80211_ADDR_LEN];
+		memset(zerobssid, 0, sizeof(zerobssid));
+		set80211(s, IEEE80211_IOC_BSSID, 0,
+			IEEE80211_ADDR_LEN, zerobssid);
+	}
 }
 
 static void



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