]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - util.c
iw: display 5/10 MHz channel widths
[thirdparty/iw.git] / util.c
diff --git a/util.c b/util.c
index 7b51b23910110c2d63a816ac4a9c59f9793dbfcb..dd960e0d27e70045a04c9e9f48aa1e490ad6b376 100644 (file)
--- a/util.c
+++ b/util.c
@@ -133,6 +133,7 @@ static const char *ifmodes[NL80211_IFTYPE_MAX + 1] = {
        "P2P-client",
        "P2P-GO",
        "P2P-device",
+       "outside context of a BSS",
 };
 
 static char modebuf[100];
@@ -147,7 +148,7 @@ const char *iftype_name(enum nl80211_iftype iftype)
 
 static const char *commands[NL80211_CMD_MAX + 1] = {
 /*
- * sed 's/^\tNL80211_CMD_//;t n;d;:n s%^\([^=]*\),.*%\t[NL80211_CMD_\1] = \"\L\1\",%;t;d' nl80211.h
+ * sed 's%^\tNL80211_CMD_%%;t n;d;:n s%^\([^=]*\),.*%\t[NL80211_CMD_\1] = \"\L\1\",%;t;d' nl80211.h | grep -v "reserved"
  */
        [NL80211_CMD_UNSPEC] = "unspec",
        [NL80211_CMD_GET_WIPHY] = "get_wiphy",
@@ -259,6 +260,10 @@ static const char *commands[NL80211_CMD_MAX + 1] = {
        [NL80211_CMD_JOIN_OCB] = "join_ocb",
        [NL80211_CMD_LEAVE_OCB] = "leave_ocb",
        [NL80211_CMD_CH_SWITCH_STARTED_NOTIFY] = "ch_switch_started_notify",
+       [NL80211_CMD_TDLS_CHANNEL_SWITCH] = "tdls_channel_switch",
+       [NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH] = "tdls_cancel_channel_switch",
+       [NL80211_CMD_WIPHY_REG_CHANGE] = "wiphy_reg_change",
+       [NL80211_CMD_ABORT_SCAN] = "abort_scan",
 };
 
 static char cmdbuf[100];
@@ -712,7 +717,7 @@ void print_vht_info(__u32 capa, const __u8 *mcs)
 
 void iw_hexdump(const char *prefix, const __u8 *buf, size_t size)
 {
-       int i;
+       size_t i;
 
        printf("%s: ", prefix);
        for (i = 0; i < size; i++) {
@@ -722,3 +727,29 @@ void iw_hexdump(const char *prefix, const __u8 *buf, size_t size)
        }
        printf("\n\n");
 }
+
+int get_cf1(const struct chanmode *chanmode, unsigned long freq)
+{
+       unsigned int cf1 = freq, j;
+       unsigned int vht80[] = { 5180, 5260, 5500, 5580, 5660, 5745 };
+
+       switch (chanmode->width) {
+       case NL80211_CHAN_WIDTH_80:
+               /* setup center_freq1 */
+               for (j = 0; j < ARRAY_SIZE(vht80); j++) {
+                       if (freq >= vht80[j] && freq < vht80[j] + 80)
+                               break;
+               }
+
+               if (j == ARRAY_SIZE(vht80))
+                       break;
+
+               cf1 = vht80[j] + 30;
+               break;
+       default:
+               cf1 = freq + chanmode->freq1_diff;
+               break;
+       }
+
+       return cf1;
+}