]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Move hostapd_parse_radius_attr() into ap_config.c
authorTerry Burton <tez@terryburton.co.uk>
Sun, 21 Jul 2019 12:05:55 +0000 (13:05 +0100)
committerJouni Malinen <j@w1.fi>
Tue, 30 Jul 2019 16:42:48 +0000 (19:42 +0300)
We will want to parse RADIUS attributes in config file format when
retrieving them from an SQLite database.

Signed-off-by: Terry Burton <tez@terryburton.co.uk>
hostapd/config_file.c
src/ap/ap_config.c
src/ap/ap_config.h

index df41f142434a97157c406c90fe37eb081f8aa0e7..29ea92e0d35e721c47e06d982360c28f19ca71b3 100644 (file)
 #include "config_file.h"
 
 
-#ifndef CONFIG_NO_RADIUS
-#ifdef EAP_SERVER
-static struct hostapd_radius_attr *
-hostapd_parse_radius_attr(const char *value);
-#endif /* EAP_SERVER */
-#endif /* CONFIG_NO_RADIUS */
-
-
 #ifndef CONFIG_NO_VLAN
 static int hostapd_config_read_vlan_file(struct hostapd_bss_config *bss,
                                         const char *fname)
@@ -660,75 +652,6 @@ hostapd_config_read_radius_addr(struct hostapd_radius_server **server,
 }
 
 
-static struct hostapd_radius_attr *
-hostapd_parse_radius_attr(const char *value)
-{
-       const char *pos;
-       char syntax;
-       struct hostapd_radius_attr *attr;
-       size_t len;
-
-       attr = os_zalloc(sizeof(*attr));
-       if (attr == NULL)
-               return NULL;
-
-       attr->type = atoi(value);
-
-       pos = os_strchr(value, ':');
-       if (pos == NULL) {
-               attr->val = wpabuf_alloc(1);
-               if (attr->val == NULL) {
-                       os_free(attr);
-                       return NULL;
-               }
-               wpabuf_put_u8(attr->val, 0);
-               return attr;
-       }
-
-       pos++;
-       if (pos[0] == '\0' || pos[1] != ':') {
-               os_free(attr);
-               return NULL;
-       }
-       syntax = *pos++;
-       pos++;
-
-       switch (syntax) {
-       case 's':
-               attr->val = wpabuf_alloc_copy(pos, os_strlen(pos));
-               break;
-       case 'x':
-               len = os_strlen(pos);
-               if (len & 1)
-                       break;
-               len /= 2;
-               attr->val = wpabuf_alloc(len);
-               if (attr->val == NULL)
-                       break;
-               if (hexstr2bin(pos, wpabuf_put(attr->val, len), len) < 0) {
-                       wpabuf_free(attr->val);
-                       os_free(attr);
-                       return NULL;
-               }
-               break;
-       case 'd':
-               attr->val = wpabuf_alloc(4);
-               if (attr->val)
-                       wpabuf_put_be32(attr->val, atoi(pos));
-               break;
-       default:
-               os_free(attr);
-               return NULL;
-       }
-
-       if (attr->val == NULL) {
-               os_free(attr);
-               return NULL;
-       }
-
-       return attr;
-}
-
 
 static int hostapd_parse_das_client(struct hostapd_bss_config *bss, char *val)
 {
index a061bd863e118b2f3166a97779dfc8c4784b0847..258a20572650a5abb5b99160c62a406ab2cb71bb 100644 (file)
@@ -476,6 +476,75 @@ hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type)
 }
 
 
+struct hostapd_radius_attr * hostapd_parse_radius_attr(const char *value)
+{
+       const char *pos;
+       char syntax;
+       struct hostapd_radius_attr *attr;
+       size_t len;
+
+       attr = os_zalloc(sizeof(*attr));
+       if (!attr)
+               return NULL;
+
+       attr->type = atoi(value);
+
+       pos = os_strchr(value, ':');
+       if (!pos) {
+               attr->val = wpabuf_alloc(1);
+               if (!attr->val) {
+                       os_free(attr);
+                       return NULL;
+               }
+               wpabuf_put_u8(attr->val, 0);
+               return attr;
+       }
+
+       pos++;
+       if (pos[0] == '\0' || pos[1] != ':') {
+               os_free(attr);
+               return NULL;
+       }
+       syntax = *pos++;
+       pos++;
+
+       switch (syntax) {
+       case 's':
+               attr->val = wpabuf_alloc_copy(pos, os_strlen(pos));
+               break;
+       case 'x':
+               len = os_strlen(pos);
+               if (len & 1)
+                       break;
+               len /= 2;
+               attr->val = wpabuf_alloc(len);
+               if (!attr->val)
+                       break;
+               if (hexstr2bin(pos, wpabuf_put(attr->val, len), len) < 0) {
+                       wpabuf_free(attr->val);
+                       os_free(attr);
+                       return NULL;
+               }
+               break;
+       case 'd':
+               attr->val = wpabuf_alloc(4);
+               if (attr->val)
+                       wpabuf_put_be32(attr->val, atoi(pos));
+               break;
+       default:
+               os_free(attr);
+               return NULL;
+       }
+
+       if (!attr->val) {
+               os_free(attr);
+               return NULL;
+       }
+
+       return attr;
+}
+
+
 static void hostapd_config_free_radius_attr(struct hostapd_radius_attr *attr)
 {
        struct hostapd_radius_attr *prev;
index eebf8981db82994e286683148867e4d71d0c6a5c..f42505e447d5fb3ff3c027b39d60f3f4aad7502d 100644 (file)
@@ -1092,6 +1092,7 @@ const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan,
                                        int vlan_id);
 struct hostapd_radius_attr *
 hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type);
+struct hostapd_radius_attr * hostapd_parse_radius_attr(const char *value);
 int hostapd_config_check(struct hostapd_config *conf, int full_config);
 void hostapd_set_security_params(struct hostapd_bss_config *bss,
                                 int full_config);