PERFORCE change 64077 for review

Sam Leffler sam at FreeBSD.org
Mon Nov 1 20:56:10 PST 2004


http://perforce.freebsd.org/chv.cgi?CH=64077

Change 64077 by sam at 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


More information about the p4-projects mailing list