[PATCH 08/24] P2P: Save group common frequencies in invitation result
Ilan Peer
ilan.peer
Mon May 19 00:06:05 PDT 2014
Save the group common frequencies when starting a GO due to
an invitation signaling requesting to re-invoke a persistent GO.
To do so, move the code that handles the translation of p2p_channels
to frequency list into a public function so it can be
re-used both when GoN is done and invitation signaling is done.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/p2p/p2p.c | 20 +++-----------------
src/p2p/p2p.h | 2 ++
src/p2p/p2p_utils.c | 30 ++++++++++++++++++++++++++++++
wpa_supplicant/p2p_supplicant.c | 2 ++
4 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index 151b877..3ca5bc5 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -1557,8 +1557,6 @@ void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer)
struct p2p_go_neg_results res;
int go = peer->go_state == LOCAL_GO;
struct p2p_channels intersection;
- int freqs;
- size_t i, j;
p2p_dbg(p2p, "GO Negotiation with " MACSTR " completed (%s will be GO)",
MAC2STR(peer->info.p2p_device_addr), go ? "local end" : "peer");
@@ -1599,21 +1597,9 @@ void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer)
p2p_channels_dump(p2p, "intersection after no-GO removal",
&intersection);
}
- freqs = 0;
- for (i = 0; i < intersection.reg_classes; i++) {
- struct p2p_reg_class *c = &intersection.reg_class[i];
- if (freqs + 1 == P2P_MAX_CHANNELS)
- break;
- for (j = 0; j < c->channels; j++) {
- int freq;
- if (freqs + 1 == P2P_MAX_CHANNELS)
- break;
- freq = p2p_channel_to_freq(c->reg_class, c->channel[j]);
- if (freq < 0)
- continue;
- res.freq_list[freqs++] = freq;
- }
- }
+
+ p2p_channels_to_freqs(&intersection, res.freq_list,
+ P2P_MAX_CHANNELS);
res.peer_config_timeout = go ? peer->client_timeout : peer->go_timeout;
diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index 39691a8..2934bfa 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -1708,6 +1708,8 @@ void p2p_set_intra_bss_dist(struct p2p_data *p2p, int enabled);
int p2p_channels_includes_freq(const struct p2p_channels *channels,
unsigned int freq);
+int p2p_channels_to_freqs(const struct p2p_channels *channels,
+ int *freq_list, unsigned int num);
/**
* p2p_supported_freq - Check whether channel is supported for P2P
* @p2p: P2P module context from p2p_init()
diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c
index 68f4ba5..8cbbc95 100644
--- a/src/p2p/p2p_utils.c
+++ b/src/p2p/p2p_utils.c
@@ -427,3 +427,33 @@ int p2p_channel_random_social(struct p2p_channels *chans, u8 *op_class,
return 0;
}
+
+
+int p2p_channels_to_freqs(const struct p2p_channels *channels,
+ int *freq_list,
+ unsigned int num)
+{
+ unsigned int i, idx;
+
+ if (!channels || num == 0)
+ return 0;
+
+ for (i = 0, idx = 0; i < channels->reg_classes; i++) {
+ const struct p2p_reg_class *c = &channels->reg_class[i];
+ unsigned int j;
+
+ if (idx + 1 == num)
+ break;
+ for (j = 0; j < c->channels; j++) {
+ int freq;
+ if (idx + 1 == num)
+ break;
+ freq = ieee80211_channel_to_freq(c->channel[j],
+ c->reg_class);
+ if (freq < 0)
+ continue;
+ freq_list[idx++] = freq;
+ }
+ }
+ return idx;
+}
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 86beb90..bf416ea 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -5519,6 +5519,8 @@ int wpas_p2p_group_add_persistent(struct wpa_supplicant *wpa_s,
if (wpa_s == NULL)
return -1;
+ p2p_channels_to_freqs(channels, params.freq_list, P2P_MAX_CHANNELS);
+
wpa_s->p2p_first_connection_timeout = connection_timeout;
wpas_start_wps_go(wpa_s, ¶ms, 0);
--
1.7.10.4
More information about the Hostap
mailing list