aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTerry Burton <tez@terryburton.co.uk>2019-07-21 12:05:55 (GMT)
committerJouni Malinen <j@w1.fi>2019-07-30 16:42:48 (GMT)
commit74707def8f1b8cdb1755f4f5698bb52b9c8a5442 (patch)
tree76aceb6afefbb2952fc5580d09f31b8581b1b61c /src
parent1e5ea68d1f33226aabba7c788808de2db212b79c (diff)
downloadhostap-74707def8f1b8cdb1755f4f5698bb52b9c8a5442.zip
hostap-74707def8f1b8cdb1755f4f5698bb52b9c8a5442.tar.gz
hostap-74707def8f1b8cdb1755f4f5698bb52b9c8a5442.tar.bz2
Move hostapd_parse_radius_attr() into ap_config.c
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>
Diffstat (limited to 'src')
-rw-r--r--src/ap/ap_config.c69
-rw-r--r--src/ap/ap_config.h1
2 files changed, 70 insertions, 0 deletions
diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c
index a061bd8..258a205 100644
--- a/src/ap/ap_config.c
+++ b/src/ap/ap_config.c
@@ -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;
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index eebf898..f42505e 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -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);