aboutsummaryrefslogtreecommitdiffstats
path: root/src/radius/radius.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-01-13 18:01:29 (GMT)
committerJouni Malinen <j@w1.fi>2009-01-13 18:01:29 (GMT)
commit010dc0685377d8f96b3d8d320275579cc087713d (patch)
treec508bc25fb60d6abbcda80e83d83029df801180e /src/radius/radius.c
parent93ea8ed0346ab9eb2b9f1c37aa8dd3660fd265bb (diff)
downloadhostap-010dc0685377d8f96b3d8d320275579cc087713d.zip
hostap-010dc0685377d8f96b3d8d320275579cc087713d.tar.gz
hostap-010dc0685377d8f96b3d8d320275579cc087713d.tar.bz2
Moved RADIUS Class attribute helpers into RADIUS module
Diffstat (limited to 'src/radius/radius.c')
-rw-r--r--src/radius/radius.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/radius/radius.c b/src/radius/radius.c
index 71bbfb5..1d96499 100644
--- a/src/radius/radius.c
+++ b/src/radius/radius.c
@@ -1232,3 +1232,44 @@ int radius_msg_get_vlanid(struct radius_msg *msg)
return -1;
}
+
+
+void radius_free_class(struct radius_class_data *c)
+{
+ size_t i;
+ if (c == NULL)
+ return;
+ for (i = 0; i < c->count; i++)
+ os_free(c->attr[i].data);
+ os_free(c->attr);
+ c->attr = NULL;
+ c->count = 0;
+}
+
+
+int radius_copy_class(struct radius_class_data *dst,
+ const struct radius_class_data *src)
+{
+ size_t i;
+
+ if (src->attr == NULL)
+ return 0;
+
+ dst->attr = os_zalloc(src->count * sizeof(struct radius_attr_data));
+ if (dst->attr == NULL)
+ return -1;
+
+ dst->count = 0;
+
+ for (i = 0; i < src->count; i++) {
+ dst->attr[i].data = os_malloc(src->attr[i].len);
+ if (dst->attr[i].data == NULL)
+ break;
+ dst->count++;
+ os_memcpy(dst->attr[i].data, src->attr[i].data,
+ src->attr[i].len);
+ dst->attr[i].len = src->attr[i].len;
+ }
+
+ return 0;
+}