]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Prefer U-NII-3 over U-NII-1 during channel selection
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 19 Nov 2013 11:04:21 +0000 (13:04 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 19 Nov 2013 11:04:21 +0000 (13:04 +0200)
Some devices disable use of U-NII-1 (channels 36-48) for P2P due to it
being indoor use only in number of locations. If U-NII-3 (channels
149-161) is available, try to pick a channel from that range first
during random channel selection to reduce likelihood of interoperability
issues.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/p2p/p2p.c
src/p2p/p2p_go_neg.c
src/p2p/p2p_utils.c

index ee25bbc4cf124ef82f32adc9d58bcc1935683bfa..e52822de5224cb15751da7531ccf67808f86e712 100644 (file)
@@ -1180,8 +1180,8 @@ static int p2p_prepare_channel_pref(struct p2p_data *p2p,
 static void p2p_prepare_channel_best(struct p2p_data *p2p)
 {
        u8 op_class, op_channel;
-       const int op_classes_5ghz[] = { 115, 124, 0 };
-       const int op_classes_ht40[] = { 116, 117, 126, 127, 0 };
+       const int op_classes_5ghz[] = { 124, 115, 0 };
+       const int op_classes_ht40[] = { 126, 127, 116, 117, 0 };
        const int op_classes_vht[] = { 128, 0 };
 
        p2p_dbg(p2p, "Prepare channel best");
index 325b8325622dfe8f11790685e1ef59cfdd784991..008651e472b2b5bd9ac5c4565848dc82c8f481a1 100644 (file)
@@ -348,8 +348,8 @@ void p2p_reselect_channel(struct p2p_data *p2p,
        int freq;
        u8 op_reg_class, op_channel;
        unsigned int i;
-       const int op_classes_5ghz[] = { 115, 124, 0 };
-       const int op_classes_ht40[] = { 116, 117, 126, 127, 0 };
+       const int op_classes_5ghz[] = { 124, 115, 0 };
+       const int op_classes_ht40[] = { 126, 127, 116, 117, 0 };
        const int op_classes_vht[] = { 128, 0 };
 
        if (p2p->own_freq_preference > 0 &&
index a579509aea8a19acc3d2410b649b56117fc11b42..161a402ef3838bda95982f8ddc3b0ed514ea989c 100644 (file)
@@ -446,28 +446,25 @@ int p2p_channel_select(struct p2p_channels *chans, const int *classes,
 {
        unsigned int i, j, r;
 
-       for (i = 0; i < chans->reg_classes; i++) {
-               struct p2p_reg_class *c = &chans->reg_class[i];
+       for (j = 0; classes[j]; j++) {
+               for (i = 0; i < chans->reg_classes; i++) {
+                       struct p2p_reg_class *c = &chans->reg_class[i];
 
-               if (c->channels == 0)
-                       continue;
+                       if (c->channels == 0)
+                               continue;
 
-               for (j = 0; classes[j]; j++) {
-                       if (c->reg_class == classes[j])
-                               break;
+                       if (c->reg_class == classes[j]) {
+                               /*
+                                * Pick one of the available channels in the
+                                * operating class at random.
+                                */
+                               os_get_random((u8 *) &r, sizeof(r));
+                               r %= c->channels;
+                               *op_class = c->reg_class;
+                               *op_channel = c->channel[r];
+                               return 0;
+                       }
                }
-               if (!classes[j])
-                       continue;
-
-               /*
-                * Pick one of the available channels in the operating class at
-                * random.
-                */
-               os_get_random((u8 *) &r, sizeof(r));
-               r %= c->channels;
-               *op_class = c->reg_class;
-               *op_channel = c->channel[r];
-               return 0;
        }
 
        return -1;