Lines Matching +full:channel +full:- +full:1

2  * P2P - generic helper functions
18 * p2p_random - Generate random string for SSID and passphrase
21 * Returns: 0 on success, -1 on failure
24 * 'A'-'Z', 'a'-'z', '0'-'9'.
30 u8 letters = 'Z' - 'A' + 1; in p2p_random()
34 return -1; in p2p_random()
35 /* Character set: 'A'-'Z', 'a'-'z', '0'-'9' */ in p2p_random()
42 buf[i] = 'a' + (val - letters); in p2p_random()
44 buf[i] = '0' + (val - 2 * letters); in p2p_random()
52 * p2p_channel_to_freq - Convert channel info to frequency
54 * @channel: Channel number
55 * Returns: Frequency in MHz or -1 if the specified channel is unknown
57 int p2p_channel_to_freq(int op_class, int channel) in p2p_channel_to_freq() argument
59 return ieee80211_chan_to_freq(NULL, op_class, channel); in p2p_channel_to_freq()
64 * p2p_freq_to_channel - Convert frequency into channel info
66 * @channel: Buffer for returning channel number
67 * Returns: 0 on success, -1 if the specified frequency is unknown
69 int p2p_freq_to_channel(unsigned int freq, u8 *op_class, u8 *channel) in p2p_freq_to_channel() argument
71 if (ieee80211_freq_to_channel_ext(freq, 0, 0, op_class, channel) == in p2p_freq_to_channel()
73 return -1; in p2p_freq_to_channel()
85 res->reg_class = a->reg_class; in p2p_reg_class_intersect()
87 for (i = 0; i < a->channels; i++) { in p2p_reg_class_intersect()
88 for (j = 0; j < b->channels; j++) { in p2p_reg_class_intersect()
89 if (a->channel[i] != b->channel[j]) in p2p_reg_class_intersect()
91 res->channel[res->channels] = a->channel[i]; in p2p_reg_class_intersect()
92 res->channels++; in p2p_reg_class_intersect()
93 if (res->channels == P2P_MAX_REG_CLASS_CHANNELS) in p2p_reg_class_intersect()
101 * p2p_channels_intersect - Intersection of supported channel lists
119 for (i = 0; i < a->reg_classes; i++) { in p2p_channels_intersect()
120 const struct p2p_reg_class *a_reg = &a->reg_class[i]; in p2p_channels_intersect()
121 for (j = 0; j < b->reg_classes; j++) { in p2p_channels_intersect()
122 const struct p2p_reg_class *b_reg = &b->reg_class[j]; in p2p_channels_intersect()
123 if (a_reg->reg_class != b_reg->reg_class) in p2p_channels_intersect()
127 &res->reg_class[res->reg_classes]); in p2p_channels_intersect()
128 if (res->reg_class[res->reg_classes].channels) { in p2p_channels_intersect()
129 res->reg_classes++; in p2p_channels_intersect()
130 if (res->reg_classes == P2P_MAX_REG_CLASSES) in p2p_channels_intersect()
143 for (i = 0; i < b_cl->channels; i++) { in p2p_op_class_union()
144 for (j = 0; j < cl->channels; j++) { in p2p_op_class_union()
145 if (b_cl->channel[i] == cl->channel[j]) in p2p_op_class_union()
148 if (j == cl->channels) { in p2p_op_class_union()
149 if (cl->channels == P2P_MAX_REG_CLASS_CHANNELS) in p2p_op_class_union()
151 cl->channel[cl->channels++] = b_cl->channel[i]; in p2p_op_class_union()
158 * p2p_channels_union_inplace - Inplace union of channel lists
159 * @res: Input data and place for returning union of the channel sets
167 for (i = 0; i < res->reg_classes; i++) { in p2p_channels_union_inplace()
168 struct p2p_reg_class *cl = &res->reg_class[i]; in p2p_channels_union_inplace()
169 for (j = 0; j < b->reg_classes; j++) { in p2p_channels_union_inplace()
170 const struct p2p_reg_class *b_cl = &b->reg_class[j]; in p2p_channels_union_inplace()
171 if (cl->reg_class != b_cl->reg_class) in p2p_channels_union_inplace()
177 for (j = 0; j < b->reg_classes; j++) { in p2p_channels_union_inplace()
178 const struct p2p_reg_class *b_cl = &b->reg_class[j]; in p2p_channels_union_inplace()
180 for (i = 0; i < res->reg_classes; i++) { in p2p_channels_union_inplace()
181 struct p2p_reg_class *cl = &res->reg_class[i]; in p2p_channels_union_inplace()
182 if (cl->reg_class == b_cl->reg_class) in p2p_channels_union_inplace()
186 if (i == res->reg_classes) { in p2p_channels_union_inplace()
187 if (res->reg_classes == P2P_MAX_REG_CLASSES) in p2p_channels_union_inplace()
189 os_memcpy(&res->reg_class[res->reg_classes++], in p2p_channels_union_inplace()
197 * p2p_channels_union - Union of channel lists
220 while (o < chan->reg_classes) { in p2p_channels_remove_freqs()
221 struct p2p_reg_class *op = &chan->reg_class[o]; in p2p_channels_remove_freqs()
224 while (c < op->channels) { in p2p_channels_remove_freqs()
225 int freq = p2p_channel_to_freq(op->reg_class, in p2p_channels_remove_freqs()
226 op->channel[c]); in p2p_channels_remove_freqs()
228 op->channels--; in p2p_channels_remove_freqs()
229 os_memmove(&op->channel[c], in p2p_channels_remove_freqs()
230 &op->channel[c + 1], in p2p_channels_remove_freqs()
231 op->channels - c); in p2p_channels_remove_freqs()
236 if (op->channels == 0) { in p2p_channels_remove_freqs()
237 chan->reg_classes--; in p2p_channels_remove_freqs()
238 os_memmove(&chan->reg_class[o], &chan->reg_class[o + 1], in p2p_channels_remove_freqs()
239 (chan->reg_classes - o) * in p2p_channels_remove_freqs()
248 * p2p_channels_includes - Check whether a channel is included in the list
250 * @reg_class: Regulatory class of the channel to search
251 * @channel: Channel number of the channel to search
252 * Returns: 1 if channel was found or 0 if not
255 u8 channel) in p2p_channels_includes() argument
258 for (i = 0; i < channels->reg_classes; i++) { in p2p_channels_includes()
259 const struct p2p_reg_class *reg = &channels->reg_class[i]; in p2p_channels_includes()
260 if (reg->reg_class != reg_class) in p2p_channels_includes()
262 for (j = 0; j < reg->channels; j++) { in p2p_channels_includes()
263 if (reg->channel[j] == channel) in p2p_channels_includes()
264 return 1; in p2p_channels_includes()
275 for (i = 0; i < channels->reg_classes; i++) { in p2p_channels_includes_freq()
276 const struct p2p_reg_class *reg = &channels->reg_class[i]; in p2p_channels_includes_freq()
277 for (j = 0; j < reg->channels; j++) { in p2p_channels_includes_freq()
278 if (p2p_channel_to_freq(reg->reg_class, in p2p_channels_includes_freq()
279 reg->channel[j]) == (int) freq) in p2p_channels_includes_freq()
280 return 1; in p2p_channels_includes_freq()
292 return p2p_channels_includes(&p2p->cfg->channels, op_reg_class, in p2p_supported_freq()
302 return p2p_channels_includes(&p2p->cfg->channels, op_reg_class, in p2p_supported_freq_go()
304 !freq_range_list_includes(&p2p->no_go_freq, freq); in p2p_supported_freq_go()
313 return p2p_channels_includes(&p2p->cfg->channels, op_reg_class, in p2p_supported_freq_cli()
315 p2p_channels_includes(&p2p->cfg->cli_channels, op_reg_class, in p2p_supported_freq_cli()
326 channels : &p2p->cfg->channels; in p2p_get_pref_freq()
331 for (i = 0; p2p->cfg->pref_chan && i < p2p->cfg->num_pref_chan; i++) { in p2p_get_pref_freq()
332 freq = p2p_channel_to_freq(p2p->cfg->pref_chan[i].op_class, in p2p_get_pref_freq()
333 p2p->cfg->pref_chan[i].chan); in p2p_get_pref_freq()
351 for (i = 0; i < chan->reg_classes; i++) { in p2p_channels_dump()
353 c = &chan->reg_class[i]; in p2p_channels_dump()
354 ret = os_snprintf(pos, end - pos, " %u:", c->reg_class); in p2p_channels_dump()
355 if (os_snprintf_error(end - pos, ret)) in p2p_channels_dump()
359 for (j = 0; j < c->channels; j++) { in p2p_channels_dump()
360 ret = os_snprintf(pos, end - pos, "%s%u", in p2p_channels_dump()
362 c->channel[j]); in p2p_channels_dump()
363 if (os_snprintf_error(end - pos, ret)) in p2p_channels_dump()
390 for (i = 0; i < chans->reg_classes; i++) { in p2p_channel_select()
391 struct p2p_reg_class *c = &chans->reg_class[i]; in p2p_channel_select()
393 if (c->channels == 0) in p2p_channel_select()
396 if (classes == NULL || c->reg_class == classes[j]) { in p2p_channel_select()
401 *op_class = c->reg_class; in p2p_channel_select()
403 c->channel, c->channels); in p2p_channel_select()
411 return -1; in p2p_channel_select()
425 * channel is not allowed by p2p_channels_includes() rules. However, it in p2p_channel_random_social()
427 * here for social channel selection unless explicitly disallowed in the in p2p_channel_random_social()
429 if (p2p_channels_includes(chans, 81, 1) || in p2p_channel_random_social()
432 chan[num_channels++] = 1; in p2p_channel_random_social()
447 return -1; in p2p_channel_random_social()
467 for (i = 0, idx = 0; i < channels->reg_classes; i++) { in p2p_channels_to_freqs()
468 const struct p2p_reg_class *c = &channels->reg_class[i]; in p2p_channels_to_freqs()
471 if (idx + 1 == max_len) in p2p_channels_to_freqs()
473 for (j = 0; j < c->channels; j++) { in p2p_channels_to_freqs()
477 if (idx + 1 == max_len) in p2p_channels_to_freqs()
479 freq = p2p_channel_to_freq(c->reg_class, in p2p_channels_to_freqs()
480 c->channel[j]); in p2p_channels_to_freqs()
511 for (i = 0, j = 0; i < src->reg_classes; i++) { in p2p_copy_channels()
512 if (is_6ghz_op_class(src->reg_class[i].reg_class)) in p2p_copy_channels()
514 os_memcpy(&dst->reg_class[j], &src->reg_class[i], in p2p_copy_channels()
518 dst->reg_classes = j; in p2p_copy_channels()
528 wpa_printf(MSG_DEBUG, "P2P: Remove 6 GHz channel %d", in p2p_remove_6ghz_channels()
530 size--; in p2p_remove_6ghz_channels()
531 os_memmove(&pref_freq_list[i], &pref_freq_list[i + 1], in p2p_remove_6ghz_channels()
532 (size - i) * sizeof(pref_freq_list[0])); in p2p_remove_6ghz_channels()
533 i--; in p2p_remove_6ghz_channels()
541 * p2p_pref_freq_allowed - Based on the flags set, check if the preferred
543 * @freq_list: Weighted preferred channel list
549 if (freq_list->flag & WEIGHTED_PCL_EXCLUDE) in p2p_pref_freq_allowed()
551 if (!(freq_list->flag & WEIGHTED_PCL_CLI) && !go) in p2p_pref_freq_allowed()
553 if (!(freq_list->flag & WEIGHTED_PCL_GO) && go) in p2p_pref_freq_allowed()
559 static int p2p_check_pref_channel(int channel, u8 op_class, in p2p_check_pref_channel() argument
565 /* If the channel is present in the preferred channel list, check if it in p2p_check_pref_channel()
569 if (p2p_channel_to_freq(op_class, channel) != in p2p_check_pref_channel()
573 return -1; in p2p_check_pref_channel()
590 for (i = 0; i < p2p_chan->reg_classes; i++) { in p2p_pref_channel_filter()
591 const struct p2p_reg_class *reg = &p2p_chan->reg_class[i]; in p2p_pref_channel_filter()
592 struct p2p_reg_class *res_reg = &res->reg_class[i]; in p2p_pref_channel_filter()
595 for (j = 0; j < reg->channels; j++) { in p2p_pref_channel_filter()
596 if (p2p_check_pref_channel(reg->channel[j], in p2p_pref_channel_filter()
597 reg->reg_class, in p2p_pref_channel_filter()
603 res_reg->channel[res_reg->channels++] = in p2p_pref_channel_filter()
604 reg->channel[j]; in p2p_pref_channel_filter()
608 if (res_reg->channels == 0) in p2p_pref_channel_filter()
610 res->reg_classes++; in p2p_pref_channel_filter()
611 res_reg->reg_class = reg->reg_class; in p2p_pref_channel_filter()