MCPcopy Create free account
hub / github.com/F-Stack/f-stack / canpromote

Function canpromote

tools/ifconfig/ifieee80211.c:266–287  ·  view source on GitHub ↗

* Given the channel at index i with attributes from, * check if there is a channel with attributes to in * the channel table. With suitable attributes this * allows the caller to look for promotion; e.g. from * 11b > 11g. */

Source from the content-addressed store, hash-verified

264 * 11b > 11g.
265 */
266static int
267canpromote(int i, int from, int to)
268{
269 const struct ieee80211_channel *fc = &chaninfo->ic_chans[i];
270 u_int j;
271
272 if ((fc->ic_flags & from) != from)
273 return i;
274 /* NB: quick check exploiting ordering of chans w/ same frequency */
275 if (i+1 < chaninfo->ic_nchans &&
276 chaninfo->ic_chans[i+1].ic_freq == fc->ic_freq &&
277 (chaninfo->ic_chans[i+1].ic_flags & to) == to)
278 return i+1;
279 /* brute force search in case channel list is not ordered */
280 for (j = 0; j < chaninfo->ic_nchans; j++) {
281 const struct ieee80211_channel *tc = &chaninfo->ic_chans[j];
282 if (j != i &&
283 tc->ic_freq == fc->ic_freq && (tc->ic_flags & to) == to)
284 return j;
285 }
286 return i;
287}
288
289/*
290 * Handle channel promotion. When a channel is specified with

Callers 1

promoteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected