* 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. */
| 264 | * 11b > 11g. |
| 265 | */ |
| 266 | static int |
| 267 | canpromote(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 |