]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Move WMM AC parameter parser into a common file
authorYoni Divinsky <yoni.divinsky@ti.com>
Sun, 12 Aug 2012 08:33:00 +0000 (11:33 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 12 Aug 2012 08:33:00 +0000 (11:33 +0300)
This allows the same implementation to be used for wpa_supplicant, too.

Signed-hostap: Yoni Divinsky <yoni.divinsky@ti.com>

hostapd/config_file.c
src/ap/ap_config.h
src/common/ieee802_11_common.c
src/common/ieee802_11_common.h

index 1bc0d4dd5c6d8e4057db08e0407c33eb61b7d1a9..0c1b6be82a1efb6feab55f12611a16833f65f798 100644 (file)
@@ -909,78 +909,6 @@ static int hostapd_config_tx_queue(struct hostapd_config *conf, char *name,
 }
 
 
-static int hostapd_config_wmm_ac(struct hostapd_config *conf, char *name,
-                                char *val)
-{
-       int num, v;
-       char *pos;
-       struct hostapd_wmm_ac_params *ac;
-
-       /* skip 'wme_ac_' or 'wmm_ac_' prefix */
-       pos = name + 7;
-       if (os_strncmp(pos, "be_", 3) == 0) {
-               num = 0;
-               pos += 3;
-       } else if (os_strncmp(pos, "bk_", 3) == 0) {
-               num = 1;
-               pos += 3;
-       } else if (os_strncmp(pos, "vi_", 3) == 0) {
-               num = 2;
-               pos += 3;
-       } else if (os_strncmp(pos, "vo_", 3) == 0) {
-               num = 3;
-               pos += 3;
-       } else {
-               wpa_printf(MSG_ERROR, "Unknown WMM name '%s'", pos);
-               return -1;
-       }
-
-       ac = &conf->wmm_ac_params[num];
-
-       if (os_strcmp(pos, "aifs") == 0) {
-               v = atoi(val);
-               if (v < 1 || v > 255) {
-                       wpa_printf(MSG_ERROR, "Invalid AIFS value %d", v);
-                       return -1;
-               }
-               ac->aifs = v;
-       } else if (os_strcmp(pos, "cwmin") == 0) {
-               v = atoi(val);
-               if (v < 0 || v > 12) {
-                       wpa_printf(MSG_ERROR, "Invalid cwMin value %d", v);
-                       return -1;
-               }
-               ac->cwmin = v;
-       } else if (os_strcmp(pos, "cwmax") == 0) {
-               v = atoi(val);
-               if (v < 0 || v > 12) {
-                       wpa_printf(MSG_ERROR, "Invalid cwMax value %d", v);
-                       return -1;
-               }
-               ac->cwmax = v;
-       } else if (os_strcmp(pos, "txop_limit") == 0) {
-               v = atoi(val);
-               if (v < 0 || v > 0xffff) {
-                       wpa_printf(MSG_ERROR, "Invalid txop value %d", v);
-                       return -1;
-               }
-               ac->txop_limit = v;
-       } else if (os_strcmp(pos, "acm") == 0) {
-               v = atoi(val);
-               if (v < 0 || v > 1) {
-                       wpa_printf(MSG_ERROR, "Invalid acm value %d", v);
-                       return -1;
-               }
-               ac->admission_control_mandatory = v;
-       } else {
-               wpa_printf(MSG_ERROR, "Unknown wmm_ac_ field '%s'", pos);
-               return -1;
-       }
-
-       return 0;
-}
-
-
 #ifdef CONFIG_IEEE80211R
 static int add_r0kh(struct hostapd_bss_config *bss, char *value)
 {
@@ -2164,7 +2092,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                        bss->wmm_uapsd = atoi(pos);
                } else if (os_strncmp(buf, "wme_ac_", 7) == 0 ||
                           os_strncmp(buf, "wmm_ac_", 7) == 0) {
-                       if (hostapd_config_wmm_ac(conf, buf, pos)) {
+                       if (hostapd_config_wmm_ac(conf->wmm_ac_params, buf,
+                                                 pos)) {
                                wpa_printf(MSG_ERROR, "Line %d: invalid WMM "
                                           "ac item", line);
                                errors++;
index 5dc310ebf9a2cfa2bfe7a72f30ea4502a8bc2835..6a8174dd9b312f2bae721f6325351907841ccec8 100644 (file)
@@ -12,6 +12,7 @@
 #include "common/defs.h"
 #include "ip_addr.h"
 #include "common/wpa_common.h"
+#include "common/ieee802_11_common.h"
 #include "wps/wps.h"
 
 #define MAX_STA_COUNT 2007
@@ -136,14 +137,6 @@ struct hostapd_tx_queue_params {
        int burst; /* maximum burst time in 0.1 ms, i.e., 10 = 1 ms */
 };
 
-struct hostapd_wmm_ac_params {
-       int cwmin;
-       int cwmax;
-       int aifs;
-       int txop_limit; /* in units of 32us */
-       int admission_control_mandatory;
-};
-
 
 #define MAX_ROAMING_CONSORTIUM_LEN 15
 
index 72dff2fb19555f5f3b995e4e63b8852015b9bd11..0f50c179fe610d01a97107776fd8e72c19788ca7 100644 (file)
@@ -405,3 +405,75 @@ const u8 * get_hdr_bssid(const struct ieee80211_hdr *hdr, size_t len)
                return NULL;
        }
 }
+
+
+int hostapd_config_wmm_ac(struct hostapd_wmm_ac_params wmm_ac_params[],
+                         const char *name, const char *val)
+{
+       int num, v;
+       const char *pos;
+       struct hostapd_wmm_ac_params *ac;
+
+       /* skip 'wme_ac_' or 'wmm_ac_' prefix */
+       pos = name + 7;
+       if (os_strncmp(pos, "be_", 3) == 0) {
+               num = 0;
+               pos += 3;
+       } else if (os_strncmp(pos, "bk_", 3) == 0) {
+               num = 1;
+               pos += 3;
+       } else if (os_strncmp(pos, "vi_", 3) == 0) {
+               num = 2;
+               pos += 3;
+       } else if (os_strncmp(pos, "vo_", 3) == 0) {
+               num = 3;
+               pos += 3;
+       } else {
+               wpa_printf(MSG_ERROR, "Unknown WMM name '%s'", pos);
+               return -1;
+       }
+
+       ac = &wmm_ac_params[num];
+
+       if (os_strcmp(pos, "aifs") == 0) {
+               v = atoi(val);
+               if (v < 1 || v > 255) {
+                       wpa_printf(MSG_ERROR, "Invalid AIFS value %d", v);
+                       return -1;
+               }
+               ac->aifs = v;
+       } else if (os_strcmp(pos, "cwmin") == 0) {
+               v = atoi(val);
+               if (v < 0 || v > 12) {
+                       wpa_printf(MSG_ERROR, "Invalid cwMin value %d", v);
+                       return -1;
+               }
+               ac->cwmin = v;
+       } else if (os_strcmp(pos, "cwmax") == 0) {
+               v = atoi(val);
+               if (v < 0 || v > 12) {
+                       wpa_printf(MSG_ERROR, "Invalid cwMax value %d", v);
+                       return -1;
+               }
+               ac->cwmax = v;
+       } else if (os_strcmp(pos, "txop_limit") == 0) {
+               v = atoi(val);
+               if (v < 0 || v > 0xffff) {
+                       wpa_printf(MSG_ERROR, "Invalid txop value %d", v);
+                       return -1;
+               }
+               ac->txop_limit = v;
+       } else if (os_strcmp(pos, "acm") == 0) {
+               v = atoi(val);
+               if (v < 0 || v > 1) {
+                       wpa_printf(MSG_ERROR, "Invalid acm value %d", v);
+                       return -1;
+               }
+               ac->admission_control_mandatory = v;
+       } else {
+               wpa_printf(MSG_ERROR, "Unknown wmm_ac_ field '%s'", pos);
+               return -1;
+       }
+
+       return 0;
+}
index 5ff74295bf53f2a59c8d48a27e57a0ad43a0226b..ac0843a600a991accccf93633f70a5d52c517394 100644 (file)
@@ -85,4 +85,15 @@ struct wpabuf * ieee802_11_vendor_ie_concat(const u8 *ies, size_t ies_len,
 struct ieee80211_hdr;
 const u8 * get_hdr_bssid(const struct ieee80211_hdr *hdr, size_t len);
 
+struct hostapd_wmm_ac_params {
+       int cwmin;
+       int cwmax;
+       int aifs;
+       int txop_limit; /* in units of 32us */
+       int admission_control_mandatory;
+};
+
+int hostapd_config_wmm_ac(struct hostapd_wmm_ac_params wmm_ac_params[],
+                         const char *name, const char *val);
+
 #endif /* IEEE802_11_COMMON_H */