const unsigned int *pref_freq_list,
unsigned int size);
+/**
+ * p2p_group_get_common_freqs - Get the group common frequencies
+ * @group: P2P group context from p2p_group_init()
+ * @common_freqs: On return will hold the group common frequencies
+ * @num: On return will hold the number of group common frequencies
+ * Returns: 0 on success, -1 otherwise
+ */
+int p2p_group_get_common_freqs(struct p2p_group *group, int *common_freqs,
+ unsigned int *num);
+
#endif /* P2P_H */
break;
}
}
+
+
+int p2p_group_get_common_freqs(struct p2p_group *group, int *common_freqs,
+ unsigned int *num)
+
+{
+ struct p2p_channels intersect, res;
+ struct p2p_group_member *m;
+
+ if (!group || !common_freqs || !num)
+ return -1;
+
+ os_memset(&intersect, 0, sizeof(intersect));
+ os_memset(&res, 0, sizeof(res));
+
+ p2p_channels_union(&intersect, &group->p2p->cfg->channels,
+ &intersect);
+
+ p2p_channels_dump(group->p2p,
+ "Group common freqs before iterating members",
+ &intersect);
+
+ for (m = group->members; m; m = m->next) {
+ struct p2p_device *dev;
+
+ dev = p2p_get_device(group->p2p, m->dev_addr);
+ if (!dev)
+ continue;
+
+ p2p_channels_intersect(&intersect, &dev->channels, &res);
+ intersect = res;
+ }
+
+ p2p_channels_dump(group->p2p, "Group common channels", &intersect);
+
+ os_memset(common_freqs, 0, *num * sizeof(int));
+ *num = p2p_channels_to_freqs(&intersect, common_freqs, *num);
+
+ return 0;
+}
}
+static void wpas_p2p_go_update_common_freqs(struct wpa_supplicant *wpa_s)
+{
+ unsigned int num = P2P_MAX_CHANNELS;
+ int *common_freqs;
+ int ret;
+
+ p2p_go_dump_common_freqs(wpa_s);
+ common_freqs = os_calloc(num, sizeof(int));
+ if (!common_freqs)
+ return;
+
+ ret = p2p_group_get_common_freqs(wpa_s->p2p_group, common_freqs, &num);
+ if (ret < 0) {
+ wpa_dbg(wpa_s, MSG_DEBUG,
+ "P2P: Failed to get group common freqs");
+ os_free(common_freqs);
+ return;
+ }
+
+ os_free(wpa_s->p2p_group_common_freqs);
+ wpa_s->p2p_group_common_freqs = common_freqs;
+ wpa_s->p2p_group_common_freqs_num = num;
+ p2p_go_dump_common_freqs(wpa_s);
+}
+
+
/*
* Check if the given frequency is one of the possible operating frequencies
* set after the completion of the GO Negotiation.
if (!wpa_s->ap_iface || !wpa_s->current_ssid)
return;
+ wpas_p2p_go_update_common_freqs(wpa_s);
+
/*
* First, try a channel switch flow. If it is not supported or fails,
* take down the GO and bring it up again.
unsigned int timeout;
int freq;
+ wpas_p2p_go_update_common_freqs(wpa_s);
+
freq = wpa_s->current_ssid->frequency;
for (i = 0, invalid_freq = 0; i < num; i++) {
if (freqs[i].freq == freq) {