Date: Tue, 23 Nov 2004 22:44:11 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 65734 for review Message-ID: <200411232244.iANMiBMj078040@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=65734 Change 65734 by sam@sam_ebb on 2004/11/23 22:43:12 o redo callback decls+definitions using macros o add basic wme parameters Affected files ... .. //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#16 edit Differences ... ==== //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#16 (text+ko) ==== @@ -481,40 +481,82 @@ } } -static void -set80211cwmin(const char *val, int d, int s, const struct afswtch *rafp) +static int +getac(const char *ac) +{ + if (strcasecmp(ac, "ac_be") == 0 || strcasecmp(ac, "be") == 0) + return WME_AC_BE; + if (strcasecmp(ac, "ac_bk") == 0 || strcasecmp(ac, "bk") == 0) + return WME_AC_BK; + if (strcasecmp(ac, "ac_vi") == 0 || strcasecmp(ac, "vi") == 0) + return WME_AC_VI; + if (strcasecmp(ac, "ac_vo") == 0 || strcasecmp(ac, "vo") == 0) + return WME_AC_VO; + errx(1, "unknown wme access class %s", ac); +} + +static +DECL_CMD_FUNC2(set80211cwmin, ac, val) +{ + set80211(s, IEEE80211_IOC_WME_CWMIN, atoi(val), getac(ac), NULL); +} + +static +DECL_CMD_FUNC2(set80211cwmax, ac, val) +{ + set80211(s, IEEE80211_IOC_WME_CWMAX, atoi(val), getac(ac), NULL); +} + +static +DECL_CMD_FUNC2(set80211aifs, ac, val) +{ + set80211(s, IEEE80211_IOC_WME_AIFS, atoi(val), getac(ac), NULL); +} + +static +DECL_CMD_FUNC2(set80211txoplimit, ac, val) +{ + set80211(s, IEEE80211_IOC_WME_TXOPLIMIT, atoi(val), getac(ac), NULL); +} + +static +DECL_CMD_FUNC(set80211acm, val, d) { - set80211(s, IEEE80211_IOC_WME_CWMIN, atoi(val), 0, NULL); + set80211(s, IEEE80211_IOC_WME_ACM, d, WME_AC_BE, NULL); } -static void -set80211cwmax(const char *val, int d, int s, const struct afswtch *rafp) +static +DECL_CMD_FUNC(set80211ackpolicy, val, d) { - set80211(s, IEEE80211_IOC_WME_CWMAX, atoi(val), 0, NULL); + set80211(s, IEEE80211_IOC_WME_ACKPOLICY, d, WME_AC_BE, NULL); } -static void -set80211aifs(const char *val, int d, int s, const struct afswtch *rafp) +static +DECL_CMD_FUNC2(set80211bsscwmin, ac, val) { - set80211(s, IEEE80211_IOC_WME_AIFS, atoi(val), 0, NULL); + set80211(s, IEEE80211_IOC_WME_CWMIN, atoi(val), + getac(ac)|IEEE80211_WMEPARAM_BSS, NULL); } -static void -set80211txoplimit(const char *val, int d, int s, const struct afswtch *rafp) +static +DECL_CMD_FUNC2(set80211bsscwmax, ac, val) { - set80211(s, IEEE80211_IOC_WME_TXOPLIMIT, atoi(val), 0, NULL); + set80211(s, IEEE80211_IOC_WME_CWMAX, atoi(val), + getac(ac)|IEEE80211_WMEPARAM_BSS, NULL); } -static void -set80211acm(const char *val, int d, int s, const struct afswtch *rafp) +static +DECL_CMD_FUNC2(set80211bssaifs, ac, val) { - set80211(s, IEEE80211_IOC_WME_ACM, atoi(val), 0, NULL); + set80211(s, IEEE80211_IOC_WME_AIFS, atoi(val), + getac(ac)|IEEE80211_WMEPARAM_BSS, NULL); } -static void -set80211ackpolicy(const char *val, int d, int s, const struct afswtch *rafp) +static +DECL_CMD_FUNC2(set80211bsstxoplimit, ac, val) { - set80211(s, IEEE80211_IOC_WME_ACKPOLICY, d, 0, NULL); + set80211(s, IEEE80211_IOC_WME_TXOPLIMIT, atoi(val), + getac(ac)|IEEE80211_WMEPARAM_BSS, NULL); } static int @@ -726,8 +768,8 @@ close(sroute); } -static void -set80211scan(const char *val, int d, int s, const struct afswtch *rafp) +static +DECL_CMD_FUNC(set80211scan, val, d) { scan_and_wait(s); list_scan(s); @@ -914,7 +956,65 @@ } static void -set80211list(const char *arg, int d, int s, const struct afswtch *rafp) +list_wme(int s) +{ + static const char *acnames[] = { "AC_BE", "AC_BK", "AC_VI", "AC_VO" }; + struct ieee80211req ireq; + int ac; + + (void) memset(&ireq, 0, sizeof(ireq)); + (void) strncpy(ireq.i_name, name, sizeof(ireq.i_name)); + ireq.i_len = 0; + for (ac = WME_AC_BE; ac <= WME_AC_VO; ac++) { +again: + if (ireq.i_len & IEEE80211_WMEPARAM_BSS) + printf("\t%s", " "); + else + printf("\t%s", acnames[ac]); + + ireq.i_len = (ireq.i_len & IEEE80211_WMEPARAM_BSS) | ac; + + /* show WME BSS parameters */ + ireq.i_type = IEEE80211_IOC_WME_CWMIN; + if (ioctl(s, SIOCG80211, &ireq) != -1) + printf(" cwmin %2u", ireq.i_val); + ireq.i_type = IEEE80211_IOC_WME_CWMAX; + if (ioctl(s, SIOCG80211, &ireq) != -1) + printf(" cwmax %2u", ireq.i_val); + ireq.i_type = IEEE80211_IOC_WME_AIFS; + if (ioctl(s, SIOCG80211, &ireq) != -1) + printf(" aifs %2u", ireq.i_val); + ireq.i_type = IEEE80211_IOC_WME_TXOPLIMIT; + if (ioctl(s, SIOCG80211, &ireq) != -1) + printf(" txopLimit %3u", ireq.i_val); + ireq.i_type = IEEE80211_IOC_WME_ACM; + if (ioctl(s, SIOCG80211, &ireq) != -1) { + if (ireq.i_val) + printf(" acm"); + else if (verbose) + printf(" -acm"); + } + /* !BSS only */ + if ((ireq.i_len & IEEE80211_WMEPARAM_BSS) == 0) { + ireq.i_type = IEEE80211_IOC_WME_ACKPOLICY; + if (ioctl(s, SIOCG80211, &ireq) != -1) { + if (!ireq.i_val) + printf(" -ack"); + else if (verbose) + printf(" ack"); + } + } + printf("\n"); + if ((ireq.i_len & IEEE80211_WMEPARAM_BSS) == 0) { + ireq.i_len |= IEEE80211_WMEPARAM_BSS; + goto again; + } else + ireq.i_len &= ~IEEE80211_WMEPARAM_BSS; + } +} + +static +DECL_CMD_FUNC(set80211list, arg, d) { #define iseq(a,b) (strncasecmp(a,b,sizeof(b)-1) == 0) @@ -928,6 +1028,8 @@ list_keys(s); else if (iseq(arg, "caps")) list_capabilities(s); + else if (iseq(arg, "wme")) + list_wme(s); else errx(1, "Don't know how to list %s for %s", arg, name); #undef iseq @@ -1054,7 +1156,7 @@ { static const uint8_t zerobssid[IEEE80211_ADDR_LEN]; enum ieee80211_opmode opmode = get80211opmode(s); - int i, num, wpa; + int i, num, wpa, wme; struct ieee80211req ireq; u_int8_t data[32]; char spacer; @@ -1302,14 +1404,16 @@ ireq.i_type = IEEE80211_IOC_WME; if (ioctl(s, SIOCG80211, &ireq) != -1) { - if (ireq.i_val) { + wme = ireq.i_val; + if (wme) { printf("%cwme", spacer); spacer = ' '; } else if (verbose) { printf("%c-wme", spacer); spacer = ' '; } - } + } else + wme = 0; if (opmode == IEEE80211_M_HOSTAP) { ireq.i_type = IEEE80211_IOC_HIDESSID; @@ -1359,6 +1463,9 @@ printf("\n"); spacer = '\t'; + if (wme && verbose) + list_wme(s); + if (wpa) { spacer = '\t'; ireq.i_type = IEEE80211_IOC_COUNTERMEASURES; @@ -1507,45 +1614,50 @@ } static struct cmd ieee80211_cmds[] = { - { "ssid", NEXTARG, set80211ssid }, - { "nwid", NEXTARG, set80211ssid }, - { "stationname", NEXTARG, set80211stationname }, - { "station", NEXTARG, set80211stationname }, /* BSD/OS */ - { "channel", NEXTARG, set80211channel }, - { "authmode", NEXTARG, set80211authmode }, - { "powersavemode", NEXTARG, set80211powersavemode }, - { "powersave", 1, set80211powersave }, - { "-powersave", 0, set80211powersave }, - { "powersavesleep", NEXTARG, set80211powersavesleep }, - { "wepmode", NEXTARG, set80211wepmode }, - { "wep", 1, set80211wep }, - { "-wep", 0, set80211wep }, - { "weptxkey", NEXTARG, set80211weptxkey }, - { "wepkey", NEXTARG, set80211wepkey }, - { "nwkey", NEXTARG, set80211nwkey }, /* NetBSD */ - { "-nwkey", 0, set80211wep }, /* NetBSD */ - { "rtsthreshold",NEXTARG, set80211rtsthreshold }, - { "protmode", NEXTARG, set80211protmode }, - { "txpower", NEXTARG, set80211txpower }, - { "roaming", NEXTARG, set80211roaming }, - { "wme", 1, set80211wme }, - { "-wme", 0, set80211wme }, - { "hidessid", 1, set80211hidessid }, - { "-hidessid", 0, set80211hidessid }, - { "apbridge", 1, set80211apbridge }, - { "-apbridge", 0, set80211apbridge }, - { "chanlist", NEXTARG, set80211chanlist }, - { "bssid", NEXTARG, set80211bssid }, - { "ap", NEXTARG, set80211bssid }, - { "scan", 0, set80211scan }, - { "list", NEXTARG, set80211list }, - { "cwmin", NEXTARG, set80211cwmin }, - { "cwmax", NEXTARG, set80211cwmax }, - { "aifs", NEXTARG, set80211aifs }, - { "txoplimit", NEXTARG, set80211txoplimit }, - { "acm", NEXTARG, set80211acm }, - { "ack", 1, set80211ackpolicy }, - { "-ack", 0, set80211ackpolicy }, + DEF_CMD_ARG("ssid", set80211ssid), + DEF_CMD_ARG("nwid", set80211ssid), + DEF_CMD_ARG("stationname", set80211stationname), + DEF_CMD_ARG("station", set80211stationname), /* BSD/OS */ + DEF_CMD_ARG("channel", set80211channel), + DEF_CMD_ARG("authmode", set80211authmode), + DEF_CMD_ARG("powersavemode", set80211powersavemode), + DEF_CMD("powersave", 1, set80211powersave), + DEF_CMD("-powersave", 0, set80211powersave), + DEF_CMD_ARG("powersavesleep", set80211powersavesleep), + DEF_CMD_ARG("wepmode", set80211wepmode), + DEF_CMD("wep", 1, set80211wep), + DEF_CMD("-wep", 0, set80211wep), + DEF_CMD_ARG("weptxkey", set80211weptxkey), + DEF_CMD_ARG("wepkey", set80211wepkey), + DEF_CMD_ARG("nwkey", set80211nwkey), /* NetBSD */ + DEF_CMD("-nwkey", 0, set80211wep), /* NetBSD */ + DEF_CMD_ARG("rtsthreshold", set80211rtsthreshold), + DEF_CMD_ARG("protmode", set80211protmode), + DEF_CMD_ARG("txpower", set80211txpower), + DEF_CMD_ARG("roaming", set80211roaming), + DEF_CMD("wme", 1, set80211wme), + DEF_CMD("-wme", 0, set80211wme), + DEF_CMD("hidessid", 1, set80211hidessid), + DEF_CMD("-hidessid", 0, set80211hidessid), + DEF_CMD("apbridge", 1, set80211apbridge), + DEF_CMD("-apbridge", 0, set80211apbridge), + DEF_CMD_ARG("chanlist", set80211chanlist), + DEF_CMD_ARG("bssid", set80211bssid), + DEF_CMD_ARG("ap", set80211bssid), + DEF_CMD("scan", 0, set80211scan), + DEF_CMD_ARG("list", set80211list), + DEF_CMD_ARG2("cwmin", set80211cwmin), + DEF_CMD_ARG2("cwmax", set80211cwmax), + DEF_CMD_ARG2("aifs", set80211aifs), + DEF_CMD_ARG2("txoplimit", set80211txoplimit), + DEF_CMD("acm", 1, set80211acm), + DEF_CMD("-acm", 0, set80211acm), + DEF_CMD("ack", 1, set80211ackpolicy), + DEF_CMD("-ack", 0, set80211ackpolicy), + DEF_CMD_ARG2("bss:cwmin", set80211bsscwmin), + DEF_CMD_ARG2("bss:cwmax", set80211bsscwmax), + DEF_CMD_ARG2("bss:aifs", set80211bssaifs), + DEF_CMD_ARG2("bss:txoplimit", set80211bsstxoplimit), }; static struct afswtch af_ieee80211 = { .af_name = "ieee80211",
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200411232244.iANMiBMj078040>