Date: Mon, 16 Apr 2012 23:45:17 -0700 From: Adrian Chadd <adrian@freebsd.org> To: freebsd-wireless@freebsd.org Subject: [patch] ifconfig: fix rate printing Message-ID: <CAJ-VmonxR28sb%2B52PwXwBDtAswjD%2BCy2c84vht6eBo4t_ZgP3A@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hi,
This patch should fix the rate print logic in ifconfig.
Thanks,
Adrian
[-- Attachment #2 --]
Index: sbin/ifconfig/ifieee80211.c
===================================================================
--- sbin/ifconfig/ifieee80211.c (revision 234019)
+++ sbin/ifconfig/ifieee80211.c (working copy)
@@ -3808,6 +3808,25 @@
}
}
+/* XXX would these be good to have in a library? */
+static const char *
+rate2str(int rate)
+{
+ if (rate & IEEE80211_RATE_MCS)
+ return ("MCS ");
+ else
+ return ("Mb/s");
+}
+
+static int
+rate2speed(int rate)
+{
+ if (IEEE80211_RATE_MCS)
+ return (rate &~ IEEE80211_RATE_MCS);
+ else
+ return (rate / 2);
+}
+
static void
list_txparams(int s)
{
@@ -3819,36 +3838,21 @@
tp = &txparams.params[mode];
if (tp->mgmtrate == 0 && tp->mcastrate == 0)
continue;
- if (mode == IEEE80211_MODE_11NA || mode == IEEE80211_MODE_11NG) {
- if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE)
- LINE_CHECK("%-7.7s ucast NONE mgmt %2u MCS "
- "mcast %2u MCS maxretry %u",
- modename[mode],
- tp->mgmtrate &~ IEEE80211_RATE_MCS,
- tp->mcastrate &~ IEEE80211_RATE_MCS,
- tp->maxretry);
- else
- LINE_CHECK("%-7.7s ucast %2u MCS mgmt %2u MCS "
- "mcast %2u MCS maxretry %u",
- modename[mode],
- tp->ucastrate &~ IEEE80211_RATE_MCS,
- tp->mgmtrate &~ IEEE80211_RATE_MCS,
- tp->mcastrate &~ IEEE80211_RATE_MCS,
- tp->maxretry);
- } else {
- if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE)
- LINE_CHECK("%-7.7s ucast NONE mgmt %2u Mb/s "
- "mcast %2u Mb/s maxretry %u",
- modename[mode],
- tp->mgmtrate/2,
- tp->mcastrate/2, tp->maxretry);
- else
- LINE_CHECK("%-7.7s ucast %2u Mb/s mgmt %2u Mb/s "
- "mcast %2u Mb/s maxretry %u",
- modename[mode],
- tp->ucastrate/2, tp->mgmtrate/2,
- tp->mcastrate/2, tp->maxretry);
- }
+ if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE)
+ LINE_CHECK("%-7.7s ucast NONE mgmt %2u %s "
+ "mcast %2u %s maxretry %u",
+ modename[mode],
+ rate2speed(tp->mgmtrate), rate2str(tp->mgmtrate),
+ rate2speed(tp->mcastrate), rate2str(tp->mcastrate),
+ tp->maxretry);
+ else
+ LINE_CHECK("%-7.7s ucast %2u %s mgmt %2u %s "
+ "mcast %2u %s maxretry %u",
+ modename[mode],
+ rate2speed(tp->ucastrate), rate2str(tp->ucastrate),
+ rate2speed(tp->mgmtrate), rate2str(tp->mgmtrate),
+ rate2speed(tp->mcastrate), rate2str(tp->mcastrate),
+ tp->maxretry);
}
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-VmonxR28sb%2B52PwXwBDtAswjD%2BCy2c84vht6eBo4t_ZgP3A>
