cfg80211: Fix sanity check on 5 GHz when processing country IE
authorLuis R. Rodriguez <lrodriguez@atheros.com>
Thu, 22 Jan 2009 23:05:46 +0000 (15:05 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 29 Jan 2009 20:46:43 +0000 (15:46 -0500)
This fixes two issues with the sanity check loop when processing
the country IE:

1. Do not use frequency for the current subband channel check,
   this was a big fat typo.
2. Apply the 5 GHz 4-channel steps when considering max channel
   on each subband as was done with a recent patch.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/wireless/reg.c

index bc494ce..6169809 100644 (file)
@@ -498,6 +498,7 @@ static struct ieee80211_regdomain *country_ie_2_rd(
         * calculate the number of reg rules we will need. We will need one
         * for each channel subband */
        while (country_ie_len >= 3) {
+               int end_channel = 0;
                struct ieee80211_country_ie_triplet *triplet =
                        (struct ieee80211_country_ie_triplet *) country_ie;
                int cur_sub_max_channel = 0, cur_channel = 0;
@@ -509,9 +510,25 @@ static struct ieee80211_regdomain *country_ie_2_rd(
                        continue;
                }
 
+               /* 2 GHz */
+               if (triplet->chans.first_channel <= 14)
+                       end_channel = triplet->chans.first_channel +
+                               triplet->chans.num_channels;
+               else
+                       /*
+                        * 5 GHz -- For example in country IEs if the first
+                        * channel given is 36 and the number of channels is 4
+                        * then the individual channel numbers defined for the
+                        * 5 GHz PHY by these parameters are: 36, 40, 44, and 48
+                        * and not 36, 37, 38, 39.
+                        *
+                        * See: http://tinyurl.com/11d-clarification
+                        */
+                       end_channel =  triplet->chans.first_channel +
+                               (4 * (triplet->chans.num_channels - 1));
+
                cur_channel = triplet->chans.first_channel;
-               cur_sub_max_channel = ieee80211_channel_to_frequency(
-                       cur_channel + triplet->chans.num_channels);
+               cur_sub_max_channel = end_channel;
 
                /* Basic sanity check */
                if (cur_sub_max_channel < cur_channel)
@@ -590,15 +607,6 @@ static struct ieee80211_regdomain *country_ie_2_rd(
                        end_channel = triplet->chans.first_channel +
                                triplet->chans.num_channels;
                else
-                       /*
-                        * 5 GHz -- For example in country IEs if the first
-                        * channel given is 36 and the number of channels is 4
-                        * then the individual channel numbers defined for the
-                        * 5 GHz PHY by these parameters are: 36, 40, 44, and 48
-                        * and not 36, 37, 38, 39.
-                        *
-                        * See: http://tinyurl.com/11d-clarification
-                        */
                        end_channel =  triplet->chans.first_channel +
                                (4 * (triplet->chans.num_channels - 1));