* Handle channel promotion. When a channel is specified with * only a frequency we want to promote it to the ``best'' channel * available. The channel list has separate entries for 11b, 11g, * 11a, and 11n[ga] channels so specifying a frequency w/o any * attributes requires we upgrade, e.g. from 11b -> 11g. This * gets complicated when the channel is specified on the same * command line w
| 301 | * XXX VHT |
| 302 | */ |
| 303 | static int |
| 304 | promote(int i) |
| 305 | { |
| 306 | /* |
| 307 | * Query the current mode of the interface in case it's |
| 308 | * constrained (e.g. to 11a). We must do this carefully |
| 309 | * as there may be a pending ifmedia request in which case |
| 310 | * asking the kernel will give us the wrong answer. This |
| 311 | * is an unfortunate side-effect of the way ifconfig is |
| 312 | * structure for modularity (yech). |
| 313 | * |
| 314 | * NB: ifmr is actually setup in getchaninfo (above); we |
| 315 | * assume it's called coincident with to this call so |
| 316 | * we have a ``current setting''; otherwise we must pass |
| 317 | * the socket descriptor down to here so we can make |
| 318 | * the ifmedia_getstate call ourselves. |
| 319 | */ |
| 320 | int chanmode = ifmr != NULL ? IFM_MODE(ifmr->ifm_current) : IFM_AUTO; |
| 321 | |
| 322 | /* when ambiguous promote to ``best'' */ |
| 323 | /* NB: we abitrarily pick HT40+ over HT40- */ |
| 324 | if (chanmode != IFM_IEEE80211_11B) |
| 325 | i = canpromote(i, IEEE80211_CHAN_B, IEEE80211_CHAN_G); |
| 326 | if (chanmode != IFM_IEEE80211_11G && (htconf & 1)) { |
| 327 | i = canpromote(i, IEEE80211_CHAN_G, |
| 328 | IEEE80211_CHAN_G | IEEE80211_CHAN_HT20); |
| 329 | if (htconf & 2) { |
| 330 | i = canpromote(i, IEEE80211_CHAN_G, |
| 331 | IEEE80211_CHAN_G | IEEE80211_CHAN_HT40D); |
| 332 | i = canpromote(i, IEEE80211_CHAN_G, |
| 333 | IEEE80211_CHAN_G | IEEE80211_CHAN_HT40U); |
| 334 | } |
| 335 | } |
| 336 | if (chanmode != IFM_IEEE80211_11A && (htconf & 1)) { |
| 337 | i = canpromote(i, IEEE80211_CHAN_A, |
| 338 | IEEE80211_CHAN_A | IEEE80211_CHAN_HT20); |
| 339 | if (htconf & 2) { |
| 340 | i = canpromote(i, IEEE80211_CHAN_A, |
| 341 | IEEE80211_CHAN_A | IEEE80211_CHAN_HT40D); |
| 342 | i = canpromote(i, IEEE80211_CHAN_A, |
| 343 | IEEE80211_CHAN_A | IEEE80211_CHAN_HT40U); |
| 344 | } |
| 345 | } |
| 346 | return i; |
| 347 | } |
| 348 | |
| 349 | static void |
| 350 | mapfreq(struct ieee80211_channel *chan, int freq, int flags) |
no test coverage detected