PERFORCE change 147167 for review
Sam Leffler
sam at FreeBSD.org
Mon Aug 11 18:34:49 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=147167
Change 147167 by sam at sam_ebb on 2008/08/11 18:34:26
consolidate channel parsing and fix strol use when the channel
string has trailing flags (e.g. 36:ht/20); not sure how this
worked before but it definitely did
Affected files ...
.. //depot/projects/vap/sbin/ifconfig/ifieee80211.c#25 edit
Differences ...
==== //depot/projects/vap/sbin/ifconfig/ifieee80211.c#25 (text+ko) ====
@@ -659,28 +659,36 @@
}
static void
+getchannel(int s, struct ieee80211_channel *chan, const char *val)
+{
+ int v, flags;
+ char *eptr;
+
+ memset(chan, 0, sizeof(*chan));
+ if (isanyarg(val)) {
+ chan->ic_freq = IEEE80211_CHAN_ANY;
+ return;
+ }
+ getchaninfo(s);
+ errno = 0;
+ v = strtol(val, &eptr, 10);
+ if (v == 0 && errno != 0)
+ errx(1, "invalid channel number%s",
+ errno == ERANGE ? " (out of range)" : "");
+ flags = getchannelflags(val, v);
+ if (v > 255) { /* treat as frequency */
+ mapfreq(chan, v, flags);
+ } else {
+ mapchan(chan, v, flags);
+ }
+}
+
+static void
set80211channel(const char *val, int d, int s, const struct afswtch *rafp)
{
struct ieee80211_channel chan;
- memset(&chan, 0, sizeof(chan));
- if (!isanyarg(val)) {
- int v, flags;
- char *ep;
-
- getchaninfo(s);
- v = strtol(val, &ep, 10);
- if (val[0] == '\0' || ep[0] != '\0' || errno == ERANGE)
- errx(1, "invalid channel number");
- flags = getchannelflags(val, v);
- if (v > 255) { /* treat as frequency */
- mapfreq(&chan, v, flags);
- } else {
- mapchan(&chan, v, flags);
- }
- } else {
- chan.ic_freq = IEEE80211_CHAN_ANY;
- }
+ getchannel(s, &chan, val);
set80211(s, IEEE80211_IOC_CURCHAN, 0, sizeof(chan), &chan);
}
@@ -688,17 +696,8 @@
set80211chanswitch(const char *val, int d, int s, const struct afswtch *rafp)
{
struct ieee80211_chanswitch_req csr;
- int v, flags;
- memset(&csr, 0, sizeof(csr));
- getchaninfo(s);
- v = atoi(val);
- flags = getchannelflags(val, v);
- if (v > 255) { /* treat as frequency */
- mapfreq(&csr.csa_chan, v, flags);
- } else {
- mapchan(&csr.csa_chan, v, flags);
- }
+ getchannel(s, &csr.csa_chan, val);
csr.csa_mode = 1;
csr.csa_count = 5;
set80211(s, IEEE80211_IOC_CHANSWITCH, 0, sizeof(csr), &csr);
More information about the p4-projects
mailing list