aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIlan Peer <ilan.peer@intel.com>2014-07-07 11:21:01 (GMT)
committerJouni Malinen <j@w1.fi>2014-10-25 22:24:28 (GMT)
commit1170239efa2c70cb345cec2d25bd5375cc591dca (patch)
tree5789e891f96e783622ac624ef68215bf97bf7b0f /src
parent20beb96ff994f286a59b8f09e587c7368d9cdbe6 (diff)
downloadhostap-1170239efa2c70cb345cec2d25bd5375cc591dca.zip
hostap-1170239efa2c70cb345cec2d25bd5375cc591dca.tar.gz
hostap-1170239efa2c70cb345cec2d25bd5375cc591dca.tar.bz2
P2P: Save group common frequencies in invitation result
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 GO Negotiation is done and invitation signaling is done. Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/p2p/p2p.c20
-rw-r--r--src/p2p/p2p.h3
-rw-r--r--src/p2p/p2p_utils.c32
3 files changed, 38 insertions, 17 deletions
diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index f28629e..394a00d 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -1639,8 +1639,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");
@@ -1681,21 +1679,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 076a2ac..9201d19 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -1738,6 +1738,9 @@ 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 max_len);
+
/**
* 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 23acce7..615cce4 100644
--- a/src/p2p/p2p_utils.c
+++ b/src/p2p/p2p_utils.c
@@ -517,3 +517,35 @@ 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 max_len)
+{
+ unsigned int i, idx;
+
+ if (!channels || max_len == 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 == max_len)
+ break;
+ for (j = 0; j < c->channels; j++) {
+ int freq;
+ if (idx + 1 == max_len)
+ break;
+ freq = p2p_channel_to_freq(c->reg_class,
+ c->channel[j]);
+ if (freq < 0)
+ continue;
+ freq_list[idx++] = freq;
+ }
+ }
+
+ freq_list[idx] = 0;
+
+ return idx;
+}