P2P: Fix channel forcing for p2p_connect auth
authorJouni Malinen <jouni.malinen@atheros.com>
Fri, 2 Jul 2010 15:27:00 +0000 (08:27 -0700)
committerJouni Malinen <j@w1.fi>
Thu, 9 Sep 2010 14:17:19 +0000 (07:17 -0700)
src/p2p/p2p.c
src/p2p/p2p_go_neg.c
src/p2p/p2p_i.h

index be223d7..ed2152e 100644 (file)
@@ -881,6 +881,12 @@ int p2p_connect(struct p2p_data *p2p, const u8 *peer_addr,
 
        dev->wps_method = wps_method;
        dev->status = P2P_SC_SUCCESS;
+
+       if (force_freq)
+               dev->flags |= P2P_DEV_FORCE_FREQ;
+       else
+               dev->flags &= ~P2P_DEV_FORCE_FREQ;
+
        if (p2p->p2p_scan_running) {
                wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
                        "P2P: p2p_scan running - delay connect send");
@@ -955,6 +961,11 @@ int p2p_authorize(struct p2p_data *p2p, const u8 *peer_addr,
        dev->wps_method = wps_method;
        dev->status = P2P_SC_SUCCESS;
 
+       if (force_freq)
+               dev->flags |= P2P_DEV_FORCE_FREQ;
+       else
+               dev->flags &= ~P2P_DEV_FORCE_FREQ;
+
        return 0;
 }
 
@@ -2457,7 +2468,7 @@ int p2p_get_peer_info(struct p2p_data *p2p, const u8 *addr, int next,
                          "country=%c%c\n"
                          "oper_freq=%d\n"
                          "req_config_methods=0x%x\n"
-                         "flags=%s%s%s%s%s%s%s%s%s%s%s%s%s\n"
+                         "flags=%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n"
                          "status=%d\n"
                          "wait_count=%u\n"
                          "invitation_reqs=%u\n",
@@ -2506,6 +2517,8 @@ int p2p_get_peer_info(struct p2p_data *p2p, const u8 *addr, int next,
                          "[WAIT_GO_NEG_CONFIRM]" : "",
                          dev->flags & P2P_DEV_GROUP_CLIENT_ONLY ?
                          "[GROUP_CLIENT_ONLY]" : "",
+                         dev->flags & P2P_DEV_FORCE_FREQ ?
+                         "[FORCE_FREQ" : "",
                          dev->status,
                          dev->wait_count,
                          dev->invitation_reqs);
index f0d8f14..4686007 100644 (file)
@@ -401,11 +401,18 @@ void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
                        wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Starting "
                                "GO Negotiation with previously authorized "
                                "peer");
-                       /* TODO: check if force_freq is needed */
-                       p2p->op_reg_class = p2p->cfg->op_reg_class;
-                       p2p->op_channel = p2p->cfg->op_channel;
-                       os_memcpy(&p2p->channels, &p2p->cfg->channels,
-                                 sizeof(struct p2p_channels));
+                       if (!(dev->flags & P2P_DEV_FORCE_FREQ)) {
+                               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
+                                       "P2P: Use default channel settings");
+                               p2p->op_reg_class = p2p->cfg->op_reg_class;
+                               p2p->op_channel = p2p->cfg->op_channel;
+                               os_memcpy(&p2p->channels, &p2p->cfg->channels,
+                                         sizeof(struct p2p_channels));
+                       } else {
+                               wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
+                                       "P2P: Use previously configured "
+                                       "forced channel settings");
+                       }
                }
 
                dev->flags &= ~P2P_DEV_NOT_YET_READY;
index 150a1f5..5c9d0eb 100644 (file)
@@ -92,6 +92,7 @@ struct p2p_device {
 #define P2P_DEV_WAIT_GO_NEG_RESPONSE BIT(10)
 #define P2P_DEV_WAIT_GO_NEG_CONFIRM BIT(11)
 #define P2P_DEV_GROUP_CLIENT_ONLY BIT(12)
+#define P2P_DEV_FORCE_FREQ BIT(13)
        unsigned int flags;
 
        int status; /* enum p2p_status_code */