Lines Matching +full:channel +full:- +full:0
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()
36 for (i = 0; i < len; i++) { in p2p_random()
42 buf[i] = 'a' + (val - letters); in p2p_random()
44 buf[i] = '0' + (val - 2 * letters); in p2p_random()
47 return 0; 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()
75 return 0; 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
117 os_memset(res, 0, sizeof(*res)); in p2p_channels_intersect()
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
219 o = 0; in p2p_channels_remove_freqs()
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()
223 c = 0; 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()
227 if (freq > 0 && freq_range_list_includes(list, freq)) { 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()
267 return 0; 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()
283 return 0; in p2p_channels_includes_freq()
290 if (p2p_freq_to_channel(freq, &op_reg_class, &op_channel) < 0) in p2p_supported_freq()
291 return 0; in p2p_supported_freq()
292 return p2p_channels_includes(&p2p->cfg->channels, op_reg_class, in p2p_supported_freq()
300 if (p2p_freq_to_channel(freq, &op_reg_class, &op_channel) < 0) in p2p_supported_freq_go()
301 return 0; in p2p_supported_freq_go()
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()
311 if (p2p_freq_to_channel(freq, &op_reg_class, &op_channel) < 0) in p2p_supported_freq_cli()
312 return 0; in p2p_supported_freq_cli()
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()
324 int freq = 0; in p2p_get_pref_freq()
326 channels : &p2p->cfg->channels; in p2p_get_pref_freq()
329 return 0; 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()
337 return 0; 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()
361 j == 0 ? "" : ",", in p2p_channels_dump()
362 c->channel[j]); in p2p_channels_dump()
363 if (os_snprintf_error(end - pos, ret)) in p2p_channels_dump()
368 *pos = '\0'; in p2p_channels_dump()
377 if (os_get_random((u8 *) &r, sizeof(r)) < 0) in p2p_channel_pick_random()
378 r = 0; in p2p_channel_pick_random()
389 for (j = 0; classes == NULL || classes[j]; j++) { in p2p_channel_select()
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()
404 return 0; in p2p_channel_select()
411 return -1; in p2p_channel_select()
421 unsigned int num_channels = 0; in p2p_channel_random_social()
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()
446 if (num_channels == 0) in p2p_channel_random_social()
447 return -1; in p2p_channel_random_social()
455 return 0; in p2p_channel_random_social()
464 if (!channels || max_len == 0) in p2p_channels_to_freqs()
465 return 0; in p2p_channels_to_freqs()
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()
473 for (j = 0; j < c->channels; j++) { 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()
481 if (freq < 0) in p2p_channels_to_freqs()
484 for (k = 0; k < idx; k++) { in p2p_channels_to_freqs()
495 freq_list[idx] = 0; 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()
526 for (i = 0; i < size; i++) { in p2p_remove_6ghz_channels()
528 wpa_printf(MSG_DEBUG, "P2P: Remove 6 GHz channel %d", in p2p_remove_6ghz_channels()
530 size--; 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()
568 for (i = 0; i < num_channels; i++) { 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()
577 return 0; in p2p_check_pref_channel()
588 os_memset(res, 0, sizeof(*res)); in p2p_pref_channel_filter()
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()
594 if (num_channels > 0) { 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()
600 go) < 0) 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()