]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Move nl80211_put_freq_params()
authorAndrei Otcheretianski <andrei.otcheretianski@intel.com>
Mon, 22 May 2023 19:33:35 +0000 (22:33 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 6 Jun 2023 17:52:46 +0000 (20:52 +0300)
Move this static function to an earlier place within the file.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
src/drivers/driver_nl80211.c

index 2df140cb1ab9c922d956430bafa00bad84bb6e43..3607317243027000b9055c11a5bb86c0cef36b12 100644 (file)
@@ -173,8 +173,6 @@ static int nl80211_send_frame_cmd(struct i802_bss *bss,
                                  const u16 *csa_offs, size_t csa_offs_len);
 static int wpa_driver_nl80211_probe_req_report(struct i802_bss *bss,
                                               int report);
-static int nl80211_put_freq_params(struct nl_msg *msg,
-                                  const struct hostapd_freq_params *freq);
 
 #define IFIDX_ANY -1
 
@@ -4826,6 +4824,112 @@ err:
 #endif /* CONFIG_DRIVER_NL80211_QCA */
 
 
+static int nl80211_put_freq_params(struct nl_msg *msg,
+                                  const struct hostapd_freq_params *freq)
+{
+       enum hostapd_hw_mode hw_mode;
+       int is_24ghz;
+       u8 channel;
+
+       wpa_printf(MSG_DEBUG, "  * freq=%d", freq->freq);
+       if (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq->freq))
+               return -ENOBUFS;
+
+       wpa_printf(MSG_DEBUG, "  * eht_enabled=%d", freq->eht_enabled);
+       wpa_printf(MSG_DEBUG, "  * he_enabled=%d", freq->he_enabled);
+       wpa_printf(MSG_DEBUG, "  * vht_enabled=%d", freq->vht_enabled);
+       wpa_printf(MSG_DEBUG, "  * ht_enabled=%d", freq->ht_enabled);
+       wpa_printf(MSG_DEBUG, "  * radar_background=%d",
+                  freq->radar_background);
+
+       hw_mode = ieee80211_freq_to_chan(freq->freq, &channel);
+       is_24ghz = hw_mode == HOSTAPD_MODE_IEEE80211G ||
+               hw_mode == HOSTAPD_MODE_IEEE80211B;
+
+       if (freq->vht_enabled ||
+           ((freq->he_enabled || freq->eht_enabled) && !is_24ghz)) {
+               enum nl80211_chan_width cw;
+
+               wpa_printf(MSG_DEBUG, "  * bandwidth=%d", freq->bandwidth);
+               switch (freq->bandwidth) {
+               case 20:
+                       cw = NL80211_CHAN_WIDTH_20;
+                       break;
+               case 40:
+                       cw = NL80211_CHAN_WIDTH_40;
+                       break;
+               case 80:
+                       if (freq->center_freq2)
+                               cw = NL80211_CHAN_WIDTH_80P80;
+                       else
+                               cw = NL80211_CHAN_WIDTH_80;
+                       break;
+               case 160:
+                       cw = NL80211_CHAN_WIDTH_160;
+                       break;
+               case 320:
+                       cw = NL80211_CHAN_WIDTH_320;
+                       break;
+               default:
+                       return -EINVAL;
+               }
+
+               wpa_printf(MSG_DEBUG, "  * channel_width=%d", cw);
+               wpa_printf(MSG_DEBUG, "  * center_freq1=%d",
+                          freq->center_freq1);
+               wpa_printf(MSG_DEBUG, "  * center_freq2=%d",
+                          freq->center_freq2);
+               if (nla_put_u32(msg, NL80211_ATTR_CHANNEL_WIDTH, cw) ||
+                   nla_put_u32(msg, NL80211_ATTR_CENTER_FREQ1,
+                               freq->center_freq1) ||
+                   (freq->center_freq2 &&
+                    nla_put_u32(msg, NL80211_ATTR_CENTER_FREQ2,
+                                freq->center_freq2)))
+                       return -ENOBUFS;
+       } else if (freq->ht_enabled) {
+               enum nl80211_channel_type ct;
+
+               wpa_printf(MSG_DEBUG, "  * sec_channel_offset=%d",
+                          freq->sec_channel_offset);
+               switch (freq->sec_channel_offset) {
+               case -1:
+                       ct = NL80211_CHAN_HT40MINUS;
+                       break;
+               case 1:
+                       ct = NL80211_CHAN_HT40PLUS;
+                       break;
+               default:
+                       ct = NL80211_CHAN_HT20;
+                       break;
+               }
+
+               wpa_printf(MSG_DEBUG, "  * channel_type=%d", ct);
+               if (nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, ct))
+                       return -ENOBUFS;
+       } else if (freq->edmg.channels && freq->edmg.bw_config) {
+               wpa_printf(MSG_DEBUG,
+                          "  * EDMG configuration: channels=0x%x bw_config=%d",
+                          freq->edmg.channels, freq->edmg.bw_config);
+               if (nla_put_u8(msg, NL80211_ATTR_WIPHY_EDMG_CHANNELS,
+                              freq->edmg.channels) ||
+                   nla_put_u8(msg, NL80211_ATTR_WIPHY_EDMG_BW_CONFIG,
+                              freq->edmg.bw_config))
+                       return -1;
+       } else {
+               wpa_printf(MSG_DEBUG, "  * channel_type=%d",
+                          NL80211_CHAN_NO_HT);
+               if (nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
+                               NL80211_CHAN_NO_HT))
+                       return -ENOBUFS;
+       }
+       if (freq->radar_background &&
+           nla_put_flag(msg, NL80211_ATTR_RADAR_BACKGROUND))
+               return -ENOBUFS;
+
+       return 0;
+}
+
+
 static int wpa_driver_nl80211_set_ap(void *priv,
                                     struct wpa_driver_ap_params *params)
 {
@@ -5209,112 +5313,6 @@ fail:
 }
 
 
-static int nl80211_put_freq_params(struct nl_msg *msg,
-                                  const struct hostapd_freq_params *freq)
-{
-       enum hostapd_hw_mode hw_mode;
-       int is_24ghz;
-       u8 channel;
-
-       wpa_printf(MSG_DEBUG, "  * freq=%d", freq->freq);
-       if (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq->freq))
-               return -ENOBUFS;
-
-       wpa_printf(MSG_DEBUG, "  * eht_enabled=%d", freq->eht_enabled);
-       wpa_printf(MSG_DEBUG, "  * he_enabled=%d", freq->he_enabled);
-       wpa_printf(MSG_DEBUG, "  * vht_enabled=%d", freq->vht_enabled);
-       wpa_printf(MSG_DEBUG, "  * ht_enabled=%d", freq->ht_enabled);
-       wpa_printf(MSG_DEBUG, "  * radar_background=%d",
-                  freq->radar_background);
-
-       hw_mode = ieee80211_freq_to_chan(freq->freq, &channel);
-       is_24ghz = hw_mode == HOSTAPD_MODE_IEEE80211G ||
-               hw_mode == HOSTAPD_MODE_IEEE80211B;
-
-       if (freq->vht_enabled ||
-           ((freq->he_enabled || freq->eht_enabled) && !is_24ghz)) {
-               enum nl80211_chan_width cw;
-
-               wpa_printf(MSG_DEBUG, "  * bandwidth=%d", freq->bandwidth);
-               switch (freq->bandwidth) {
-               case 20:
-                       cw = NL80211_CHAN_WIDTH_20;
-                       break;
-               case 40:
-                       cw = NL80211_CHAN_WIDTH_40;
-                       break;
-               case 80:
-                       if (freq->center_freq2)
-                               cw = NL80211_CHAN_WIDTH_80P80;
-                       else
-                               cw = NL80211_CHAN_WIDTH_80;
-                       break;
-               case 160:
-                       cw = NL80211_CHAN_WIDTH_160;
-                       break;
-               case 320:
-                       cw = NL80211_CHAN_WIDTH_320;
-                       break;
-               default:
-                       return -EINVAL;
-               }
-
-               wpa_printf(MSG_DEBUG, "  * channel_width=%d", cw);
-               wpa_printf(MSG_DEBUG, "  * center_freq1=%d",
-                          freq->center_freq1);
-               wpa_printf(MSG_DEBUG, "  * center_freq2=%d",
-                          freq->center_freq2);
-               if (nla_put_u32(msg, NL80211_ATTR_CHANNEL_WIDTH, cw) ||
-                   nla_put_u32(msg, NL80211_ATTR_CENTER_FREQ1,
-                               freq->center_freq1) ||
-                   (freq->center_freq2 &&
-                    nla_put_u32(msg, NL80211_ATTR_CENTER_FREQ2,
-                                freq->center_freq2)))
-                       return -ENOBUFS;
-       } else if (freq->ht_enabled) {
-               enum nl80211_channel_type ct;
-
-               wpa_printf(MSG_DEBUG, "  * sec_channel_offset=%d",
-                          freq->sec_channel_offset);
-               switch (freq->sec_channel_offset) {
-               case -1:
-                       ct = NL80211_CHAN_HT40MINUS;
-                       break;
-               case 1:
-                       ct = NL80211_CHAN_HT40PLUS;
-                       break;
-               default:
-                       ct = NL80211_CHAN_HT20;
-                       break;
-               }
-
-               wpa_printf(MSG_DEBUG, "  * channel_type=%d", ct);
-               if (nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, ct))
-                       return -ENOBUFS;
-       } else if (freq->edmg.channels && freq->edmg.bw_config) {
-               wpa_printf(MSG_DEBUG,
-                          "  * EDMG configuration: channels=0x%x bw_config=%d",
-                          freq->edmg.channels, freq->edmg.bw_config);
-               if (nla_put_u8(msg, NL80211_ATTR_WIPHY_EDMG_CHANNELS,
-                              freq->edmg.channels) ||
-                   nla_put_u8(msg, NL80211_ATTR_WIPHY_EDMG_BW_CONFIG,
-                              freq->edmg.bw_config))
-                       return -1;
-       } else {
-               wpa_printf(MSG_DEBUG, "  * channel_type=%d",
-                          NL80211_CHAN_NO_HT);
-               if (nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
-                               NL80211_CHAN_NO_HT))
-                       return -ENOBUFS;
-       }
-       if (freq->radar_background &&
-           nla_put_flag(msg, NL80211_ATTR_RADAR_BACKGROUND))
-               return -ENOBUFS;
-
-       return 0;
-}
-
-
 static bool nl80211_link_valid(struct i802_bss *bss, s8 link_id)
 {
        unsigned int i;