Recognize IW_AUTH_CIPHER_GROUP_MGMT and IW_AUTH_MFP
[madwifi/.git] / tools / wlanconfig.c
index 3a08ee3199817d95fc637cf704b272ce817fc7cb..1c0ff913feb6b9e7965286fb1d34e1c640f1e38e 100644 (file)
@@ -66,7 +66,7 @@
  * These are taken from ieee80211_node.h
  */
 #define IEEE80211_NODE_TURBOP  0x0001          /* Turbo prime enable */
-#define IEEE80211_NODE_COMP    0x0002          /* Compresssion enable */
+#define IEEE80211_NODE_COMP    0x0002          /* Compression enable */
 #define IEEE80211_NODE_FF      0x0004          /* Fast Frame capable */
 #define IEEE80211_NODE_XR      0x0008          /* Atheros WME enable */
 #define IEEE80211_NODE_AR      0x0010          /* AR capable */
@@ -74,6 +74,9 @@
 
 #define        streq(a,b)      (strncasecmp(a, b, sizeof(b) - 1) == 0)
 
+#undef ARRAY_SIZE
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
 static int if_split_name(const char *, char **, unsigned int *);
 static void vap_create(struct ifreq *);
 static void vap_destroy(const char *);
@@ -143,7 +146,7 @@ main(int argc, char *argv[])
                                strncpy(ifr.ifr_name, argv[4], IFNAMSIZ);
                                argc--;
                                argv++;
-                       } else if (strcmp(argv[3], "nounit" ) == 0) {
+                       } else if (strcmp(argv[3], "nounit") == 0) {
                                bnounit = 1;
                        } else {
                                int flag = getflag(argv[3]);
@@ -170,7 +173,7 @@ main(int argc, char *argv[])
                free(if_base);
                if_base = NULL;
 
-               ifr.ifr_data = (void *) &cp;
+               ifr.ifr_data = (void *)&cp;
                vap_create(&ifr);
                printf("%s\n", ifr.ifr_name);
        } else if (streq(cmd, "destroy")) {
@@ -281,7 +284,7 @@ static void
 usage(void)
 {
        fprintf(stderr, "usage: wlanconfig athX create [nounit] wlandev wifiY\n");
-       fprintf(stderr, "            wlanmode [sta|adhoc|ap|monitor|wds|ahdemo] [bssid | -bssid] [nosbeacon]\n");
+       fprintf(stderr, "            wlanmode [sta|adhoc|ap|monitor|wds|ahdemo] [uniquebssid]\n");
        fprintf(stderr, "usage: wlanconfig athX destroy\n");
        fprintf(stderr, "usage: wlanconfig athX list [active|ap|caps|chan|freq|keys|scan|sta|wme]\n");
        exit(-1);
@@ -315,10 +318,16 @@ getflag(const char  *s)
        int flag = 0;
 
        cp = (s[0] == '-' ? s + 1 : s);
-       if (strcmp(cp, "bssid") == 0)
+       if (strcmp(cp, "bssid") == 0) {
+               printf("WARNING: the -bssid and bssid flags are deprecated.\n");
+               flag = IEEE80211_CLONE_BSSID;
+       }
+       if (strcmp(cp, "uniquebssid") == 0)
                flag = IEEE80211_CLONE_BSSID;
-       if (strcmp(cp, "nosbeacon") == 0)
-               flag |= IEEE80211_NO_STABEACONS;
+       if (strcmp(cp, "nosbeacon") == 0) {
+               printf("WARNING: the nosbeacon flag has been deprecated.\n");
+               return 0; /* deprecated but skip */
+       }
        if (flag == 0)
                errx(1, "unknown create option %s", s);
        return (s[0] == '-' ? -flag : flag);
@@ -425,12 +434,12 @@ getstamode(u_int8_t opmode)
 }
 
 static void
-printie(const chartag, const uint8_t *ie, size_t ielen, int maxlen)
+printie(const char *tag, const uint8_t *ie, size_t ielen, int maxlen)
 {
        printf("%s", tag);
        if (verbose) {
-               maxlen -= strlen(tag)+2;
-               if (2*ielen > maxlen)
+               maxlen -= strlen(tag) + 2;
+               if (2 * ielen > maxlen)
                        maxlen--;
                printf("<");
                for (; ielen > 0; ie++, ielen--) {
@@ -556,7 +565,7 @@ ieee80211_ntoa(const uint8_t mac[IEEE80211_ADDR_LEN])
 static void
 list_stations(const char *ifname)
 {
-       uint8_t buf[24*1024];
+       uint8_t buf[24 * 1024];
        struct iwreq iwr;
        uint8_t *cp;
        int s, len;
@@ -567,7 +576,7 @@ list_stations(const char *ifname)
 
        (void) memset(&iwr, 0, sizeof(iwr));
        (void) strncpy(iwr.ifr_name, ifname, sizeof(iwr.ifr_name));
-       iwr.u.data.pointer = (void *) buf;
+       iwr.u.data.pointer = (void *)buf;
        iwr.u.data.length = sizeof(buf);
        if (ioctl(s, IEEE80211_IOCTL_STA_INFO, &iwr) < 0)
                errx(1, "unable to get station information");
@@ -598,7 +607,7 @@ list_stations(const char *ifname)
                struct ieee80211req_sta_info *si;
                uint8_t *vp;
 
-               si = (struct ieee80211req_sta_info *) cp;
+               si = (struct ieee80211req_sta_info *)cp;
                vp = (u_int8_t *)(si+1);
                printf("%s %4u %4d %3dM %4d %4d %5d %6d %7d %6d %7d %-4.4s %-5.5s %3x %8x %8s",
                        ieee80211_ntoa(si->isi_macaddr),
@@ -674,8 +683,8 @@ list_scan(const char *ifname)
                struct ieee80211req_scan_result *sr;
                uint8_t *vp;
 
-               sr = (struct ieee80211req_scan_result *) cp;
-               vp = (u_int8_t *)(sr+1);
+               sr = (struct ieee80211req_scan_result *)cp;
+               vp = (u_int8_t *)(sr + 1);
                printf("%-14.*s  %s  %3d  %3dM %2d:%-2d  %3d %-4.4s",
                        copy_essid(ssid, sizeof(ssid), vp, sr->isr_ssid_len),
                        ssid,
@@ -694,8 +703,6 @@ list_scan(const char *ifname)
 static void
 print_chaninfo(const struct ieee80211_channel *c)
 {
-#define        IEEE80211_IS_CHAN_PASSIVE(_c) \
-       (((_c)->ic_flags & IEEE80211_CHAN_PASSIVE))
        char buf[14];
 
        buf[0] = '\0';
@@ -713,10 +720,15 @@ print_chaninfo(const struct ieee80211_channel *c)
                strlcat(buf, " Static", sizeof(buf));
        if (IEEE80211_IS_CHAN_DTURBO(c))
                strlcat(buf, " Dynamic", sizeof(buf));
-       printf("Channel %3u : %u%c Mhz%-14.14s",
+       if (IEEE80211_IS_CHAN_HALF(c))
+               strlcat(buf, " Half", sizeof(buf));
+       if (IEEE80211_IS_CHAN_QUARTER(c))
+               strlcat(buf, " Quarter", sizeof(buf));
+       printf("Channel %3u : %u%c%c Mhz%-14.14s",
                c->ic_ieee, c->ic_freq,
-               IEEE80211_IS_CHAN_PASSIVE(c) ? '*' : ' ', buf);
-#undef IEEE80211_IS_CHAN_PASSIVE
+               IEEE80211_IS_CHAN_PASSIVE(c) ? '*' : ' ', 
+               IEEE80211_IS_CHAN_RADAR(c) ? '!' : ' ', 
+              buf);
 }
 
 static void
@@ -922,8 +934,6 @@ get80211param(const char *ifname, int param, void *data, size_t len)
 static int
 do80211priv(struct iwreq *iwr, const char *ifname, int op, void *data, size_t len)
 {
-#define        N(a)    (sizeof(a)/sizeof(a[0]))
-
        memset(iwr, 0, sizeof(struct iwreq));
        strncpy(iwr->ifr_name, ifname, IFNAMSIZ);
        if (len < IFNAMSIZ) {
@@ -959,22 +969,20 @@ do80211priv(struct iwreq *iwr, const char *ifname, int op, void *data, size_t le
                        IOCTL_ERR(IEEE80211_IOCTL_RADAR),
                        IOCTL_ERR(IEEE80211_IOCTL_SETKEY),
                        IOCTL_ERR(IEEE80211_IOCTL_DELKEY),
+                       IOCTL_ERR(IEEE80211_IOCTL_HALMAP),
                        IOCTL_ERR(IEEE80211_IOCTL_ADDMAC),
                        IOCTL_ERR(IEEE80211_IOCTL_DELMAC),
                        IOCTL_ERR(IEEE80211_IOCTL_WDSADDMAC),
                        IOCTL_ERR(IEEE80211_IOCTL_WDSDELMAC),
-                       IOCTL_ERR(IEEE80211_IOCTL_READREG),
-                       IOCTL_ERR(IEEE80211_IOCTL_WRITEREG),
                };
                op -= SIOCIWFIRSTPRIV;
-               if (0 <= op && op < N(opnames))
+               if (0 <= op && op < ARRAY_SIZE(opnames))
                        perror(opnames[op]);
                else
                        perror("ioctl[unknown???]");
                return -1;
        }
        return 0;
-#undef N
 }
 
 static int