FreeBSD/sbin/ifconfig/ifieee80211.c
/*
 * 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 with a media request that constrains the available
 * channe list (e.g. mode 11a); we want to honor that to avoid
 * confusing behaviour.
 */
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.
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 .
static int
promote(int i)
{
	int chanmode = ifmr != NULL ? IFM_MODE(ifmr->ifm_current) : IFM_AUTO;
	if (chanmode != IFM_IEEE80211_11B)
		i = canpromote(i, IEEE80211_CHAN_B, IEEE80211_CHAN_G);
	if (chanmode != IFM_IEEE80211_11G && (htconf & 1)) {
		i = canpromote(i, IEEE80211_CHAN_G,
			IEEE80211_CHAN_G | IEEE80211_CHAN_HT20);
		if (htconf & 2) {
			i = canpromote(i, IEEE80211_CHAN_G,
				IEEE80211_CHAN_G | IEEE80211_CHAN_HT40D);
			i = canpromote(i, IEEE80211_CHAN_G,
				IEEE80211_CHAN_G | IEEE80211_CHAN_HT40U);
		}
	}
	if (chanmode != IFM_IEEE80211_11A && (htconf & 1)) {
		i = canpromote(i, IEEE80211_CHAN_A,
			IEEE80211_CHAN_A | IEEE80211_CHAN_HT20);
		if (htconf & 2) {
			i = canpromote(i, IEEE80211_CHAN_A,
				IEEE80211_CHAN_A | IEEE80211_CHAN_HT40D);
			i = canpromote(i, IEEE80211_CHAN_A,
				IEEE80211_CHAN_A | IEEE80211_CHAN_HT40U);
		}
	}
	return i;
}
static int promote ( int i ) { int chanmode = ifmr != NULL ? IFM_MODE ( ifmr -> ifm_current ) : IFM_AUTO ; if ( chanmode != IFM_IEEE80211_11B ) i = canpromote ( i , IEEE80211_CHAN_B , IEEE80211_CHAN_G ) ; if ( chanmode != IFM_IEEE80211_11G && ( htconf & 1 ) ) { i = canpromote ( i , IEEE80211_CHAN_G , IEEE80211_CHAN_G | IEEE80211_CHAN_HT20 ) ; if ( htconf & 2 ) { i = canpromote ( i , IEEE80211_CHAN_G , IEEE80211_CHAN_G | IEEE80211_CHAN_HT40D ) ; i = canpromote ( i , IEEE80211_CHAN_G , IEEE80211_CHAN_G | IEEE80211_CHAN_HT40U ) ; } } if ( chanmode != IFM_IEEE80211_11A && ( htconf & 1 ) ) { i = canpromote ( i , IEEE80211_CHAN_A , IEEE80211_CHAN_A | IEEE80211_CHAN_HT20 ) ; if ( htconf & 2 ) { i = canpromote ( i , IEEE80211_CHAN_A , IEEE80211_CHAN_A | IEEE80211_CHAN_HT40D ) ; i = canpromote ( i , IEEE80211_CHAN_A , IEEE80211_CHAN_A | IEEE80211_CHAN_HT40U ) ; } } return i ; }
Handle channel promotion.
Handle channel promotion .
/*
	 * Query the current mode of the interface in case it's
	 * constrained (e.g. to 11a).  We must do this carefully
	 * as there may be a pending ifmedia request in which case
	 * asking the kernel will give us the wrong answer.  This
	 * is an unfortunate side-effect of the way ifconfig is
	 * structure for modularity (yech).
	 *
	 * NB: ifmr is actually setup in getchaninfo (above); we
	 *     assume it's called coincident with to this call so
	 *     we have a ``current setting''; otherwise we must pass
	 *     the socket descriptor down to here so we can make
	 *     the ifmedia_getstate call ourselves.
	 */ /* when ambiguous promote to ``best'' */ /* NB: we abitrarily pick HT40+ over HT40- */