]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Add P2P_SET override_pref_op_chan to allow overriding preference
authorJouni Malinen <jouni@qca.qualcomm.com>
Wed, 15 Feb 2017 14:07:13 +0000 (16:07 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 16 Feb 2017 10:08:22 +0000 (12:08 +0200)
This new P2P_SET parameter uses <op_class>:<channel> format and is used
mainly for testing purposes to allow overriding the value of the GO
Negotiation Response frame Operating Channel attribute.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/p2p/p2p.c
src/p2p/p2p.h
src/p2p/p2p_go_neg.c
src/p2p/p2p_i.h
wpa_supplicant/ctrl_iface.c

index 65dd1a32d210be8c4f575e12c14b0b0bf593363d..14d6279981afa14d82dc759980e238cfc0074e8a 100644 (file)
@@ -3034,6 +3034,8 @@ void p2p_flush(struct p2p_data *p2p)
        p2p->ssid_set = 0;
        p2ps_prov_free(p2p);
        p2p_reset_pending_pd(p2p);
+       p2p->override_pref_op_class = 0;
+       p2p->override_pref_channel = 0;
 }
 
 
@@ -5522,6 +5524,14 @@ void p2p_set_own_pref_freq_list(struct p2p_data *p2p,
 }
 
 
+void p2p_set_override_pref_op_chan(struct p2p_data *p2p, u8 op_class,
+                                  u8 chan)
+{
+       p2p->override_pref_op_class = op_class;
+       p2p->override_pref_channel = chan;
+}
+
+
 struct wpabuf * p2p_build_probe_resp_template(struct p2p_data *p2p,
                                              unsigned int freq)
 {
index 7b18dcfc3ff3a2a8af1f704b62f4f18e810e34cc..70d3a907e2ceb646d1ae741d7244d1a500e94765 100644 (file)
@@ -2373,6 +2373,8 @@ void p2p_expire_peers(struct p2p_data *p2p);
 void p2p_set_own_pref_freq_list(struct p2p_data *p2p,
                                const unsigned int *pref_freq_list,
                                unsigned int size);
+void p2p_set_override_pref_op_chan(struct p2p_data *p2p, u8 op_class,
+                                  u8 chan);
 
 /**
  * p2p_group_get_common_freqs - Get the group common frequencies
index 9f0b3f3d37a44799eca35514c7c90fa109f0fd05..67c4b0d3fe9b73dcab826d9d974a861c5240bee1 100644 (file)
@@ -315,7 +315,12 @@ static struct wpabuf * p2p_build_go_neg_resp(struct p2p_data *p2p,
                               group_capab);
        p2p_buf_add_go_intent(buf, (p2p->go_intent << 1) | tie_breaker);
        p2p_buf_add_config_timeout(buf, p2p->go_timeout, p2p->client_timeout);
-       if (peer && peer->go_state == REMOTE_GO && !p2p->num_pref_freq) {
+       if (p2p->override_pref_op_class) {
+               p2p_dbg(p2p, "Override operating channel preference");
+               p2p_buf_add_operating_channel(buf, p2p->cfg->country,
+                                             p2p->override_pref_op_class,
+                                             p2p->override_pref_channel);
+       } else if (peer && peer->go_state == REMOTE_GO && !p2p->num_pref_freq) {
                p2p_dbg(p2p, "Omit Operating Channel attribute");
        } else {
                p2p_buf_add_operating_channel(buf, p2p->cfg->country,
index 47524d4991a5ab3dd4a0353b2ad105016ef4a3eb..ce699329cb247132909713903da0367966bfc5dd 100644 (file)
@@ -553,6 +553,10 @@ struct p2p_data {
 
        unsigned int pref_freq_list[P2P_MAX_PREF_CHANNELS];
        unsigned int num_pref_freq;
+
+       /* Override option for preferred operating channel in GO Negotiation */
+       u8 override_pref_op_class;
+       u8 override_pref_channel;
 };
 
 /**
index 40380fa18ba988aa77488ae93145ae019c3aca97..f9163169665557c76bba05b2b864d0582ace7a10 100644 (file)
@@ -6457,6 +6457,20 @@ static int p2p_ctrl_set(struct wpa_supplicant *wpa_s, char *cmd)
                return 0;
        }
 
+       if (os_strcmp(cmd, "override_pref_op_chan") == 0) {
+               int op_class, chan;
+
+               op_class = atoi(param);
+               param = os_strchr(param, ':');
+               if (!param)
+                       return -1;
+               param++;
+               chan = atoi(param);
+               p2p_set_override_pref_op_chan(wpa_s->global->p2p, op_class,
+                                             chan);
+               return 0;
+       }
+
        wpa_printf(MSG_DEBUG, "CTRL_IFACE: Unknown P2P_SET field value '%s'",
                   cmd);