Android: P2P: Fix restriction of GO channels on A-band
Bug: 11105901
Change-Id: Ibe8e85f47e95177700deedccb408f1eec85b8f3d
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/src/p2p/p2p_go_neg.c b/src/p2p/p2p_go_neg.c
index 17fb329..bd583be 100644
--- a/src/p2p/p2p_go_neg.c
+++ b/src/p2p/p2p_go_neg.c
@@ -418,7 +418,13 @@
/* Prefer a 5 GHz channel */
for (i = 0; i < intersection->reg_classes; i++) {
+#ifdef ANDROID_P2P
+ struct p2p_reg_class prc;
+ struct p2p_reg_class *c = &prc;
+ p2p_copy_reg_class(c, &intersection->reg_class[i]);
+#else
struct p2p_reg_class *c = &intersection->reg_class[i];
+#endif
if ((c->reg_class == 115 || c->reg_class == 124) &&
c->channels) {
unsigned int r;
diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h
index d28aae9..81e521e 100644
--- a/src/p2p/p2p_i.h
+++ b/src/p2p/p2p_i.h
@@ -572,6 +572,9 @@
struct p2p_channels *res);
int p2p_channels_includes(const struct p2p_channels *channels, u8 reg_class,
u8 channel);
+#ifdef ANDROID_P2P
+size_t p2p_copy_reg_class(struct p2p_reg_class *dc, struct p2p_reg_class *sc);
+#endif
/* p2p_parse.c */
int p2p_parse_p2p_ie(const struct wpabuf *buf, struct p2p_message *msg);
diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c
index 0769ede..a4c48f6 100644
--- a/src/p2p/p2p_utils.c
+++ b/src/p2p/p2p_utils.c
@@ -244,12 +244,37 @@
}
+#ifdef ANDROID_P2P
+static int p2p_block_op_freq(unsigned int freq)
+{
+ return (freq >= 5170 && freq < 5745);
+}
+
+
+size_t p2p_copy_reg_class(struct p2p_reg_class *dc, struct p2p_reg_class *sc)
+{
+ unsigned int i;
+
+ dc->reg_class = sc->reg_class;
+ dc->channels = 0;
+ for (i=0; i < sc->channels; i++) {
+ if (!p2p_block_op_freq(p2p_channel_to_freq(sc->reg_class,
+ sc->channel[i]))) {
+ dc->channel[dc->channels] = sc->channel[i];
+ dc->channels++;
+ }
+ }
+ return dc->channels;
+}
+#endif
+
+
int p2p_supported_freq(struct p2p_data *p2p, unsigned int freq)
{
u8 op_reg_class, op_channel;
#ifdef ANDROID_P2P
- if (freq >= 5170 && freq < 5745)
+ if (p2p_block_op_freq(freq))
return 0;
#endif
if (p2p_freq_to_channel(freq, &op_reg_class, &op_channel) < 0)