bool channel_auto_change(void) { int new_idx; bool ret = true; int start_idx; if (conf.channel_idx == -1) return false; /* The current channel is still unknown for some * reason (mac80211 bug, busy physical interface, * etc.), it will be fixed when the first packet * arrives, see fixup_packet_channel(). * * Without this return, horst would busy-loop forever * (making the ui totally unresponsive) in the channel * changing code below because start_idx would be -1 * as well. Short-circuit exiting here is quite * logical though: it does not make any sense to scan * channels as long as the channel module is not * initialized properly. */ if (channel_get_remaining_dwell_time() > 0) return false; /* too early */ if (conf.do_change_channel) { start_idx = new_idx = conf.channel_idx; do { enum chan_width max_width = channel_get_band_from_idx(new_idx).max_chan_width; /* * For HT40 we visit the same channel twice, once with HT40+ * and once with HT40-. This is necessary to see the HT40+/- * data packets */ if (max_width == CHAN_WIDTH_40) { if (conf.channel_ht40plus) new_idx++; conf.channel_ht40plus = !conf.channel_ht40plus; // toggle } else { new_idx++; } if (new_idx >= channels.num_channels || new_idx >= MAX_CHANNELS || (conf.channel_max && channel_get_chan(new_idx) > conf.channel_max)) new_idx = 0; ret = channel_change(new_idx, max_width, conf.channel_ht40plus); /* try setting different channels in case we get errors only * on some channels (e.g. ipw2200 reports channel 14 but cannot * be set to use it). stop if we tried all channels */ } while (ret != 1 && new_idx != start_idx); } return ret; }
bool channel_auto_change(void) { int new_idx; bool ret = true; int start_idx; if (conf.channel_idx == -1) return false; /* The current channel is still unknown for some * reason (mac80211 bug, busy physical interface, * etc.), it will be fixed when the first packet * arrives, see fixup_packet_channel(). * * Without this return, horst would busy-loop forever * (making the ui totally unresponsive) in the channel * changing code below because start_idx would be -1 * as well. Short-circuit exiting here is quite * logical though: it does not make any sense to scan * channels as long as the channel module is not * initialized properly. */ if (channel_get_remaining_dwell_time() > 0) return false; /* too early */ if (conf.do_change_channel) { start_idx = new_idx = conf.channel_idx; do { new_idx = new_idx + 1; if (new_idx >= conf.num_channels || new_idx >= MAX_CHANNELS || (conf.channel_max && channel_get_chan_from_idx(new_idx) > conf.channel_max)) new_idx = 0; ret = channel_change(new_idx); /* try setting different channels in case we get errors only * on some channels (e.g. ipw2200 reports channel 14 but cannot * be set to use it). stop if we tried all channels */ } while (ret != 1 && new_idx != start_idx); } return ret; }