summaryrefslogtreecommitdiffstats
path: root/lib/libradius
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2002-05-10 02:40:23 +0000
committerbrian <brian@FreeBSD.org>2002-05-10 02:40:23 +0000
commit4d8198d74c4130fe8170db7d51dc0674790e0336 (patch)
tree41b9cc12992b2dc80fec6a896e452c373504328c /lib/libradius
parentddf552e1ed4f89696a2a8ad954a3918a9f2f8b94 (diff)
downloadFreeBSD-src-4d8198d74c4130fe8170db7d51dc0674790e0336.zip
FreeBSD-src-4d8198d74c4130fe8170db7d51dc0674790e0336.tar.gz
Add rad_get_vendor_attr() for deciphering vendor attributes received
from the RADIUS server.
Diffstat (limited to 'lib/libradius')
-rw-r--r--lib/libradius/libradius.322
-rw-r--r--lib/libradius/radlib.c13
2 files changed, 34 insertions, 1 deletions
diff --git a/lib/libradius/libradius.3 b/lib/libradius/libradius.3
index 2199d26..3ccd9e4 100644
--- a/lib/libradius/libradius.3
+++ b/lib/libradius/libradius.3
@@ -55,6 +55,8 @@
.Ft int
.Fn rad_get_attr "struct rad_handle *h" "const void **data" "size_t *len"
.Ft int
+.Fn rad_get_vendor_attr "u_int32_t *vendor" "const void **data" "size_t *len"
+.Ft int
.Fn rad_init_send_request "struct rad_handle *h" "int *fd" "struct timeval *tv"
.Ft int
.Fn rad_put_addr "struct rad_handle *h" "int type" "struct in_addr addr"
@@ -293,6 +295,22 @@ returns 0.
If an error such as a malformed attribute is detected, -1 is
returned.
.Pp
+If
+.Fn rad_get_attr
+returns
+.Dv RAD_VENDOR_SPECIFIC ,
+.Fn rad_get_vendor_attr
+may be called to determine the vendor.
+The vendor specific RADIUS attribute type is returned.
+The reference parameters
+.Va data
+and
+.Va len
+.Pq as returned from Fn rad_get_attr
+are passed to
+.Fn rad_get_vendor_attr ,
+and are adjusted to point to the vendor specific attribute data.
+.Pp
The common types of attributes can be decoded using
.Fn rad_cvt_addr ,
.Fn rad_cvt_int ,
@@ -300,7 +318,9 @@ and
.Fn rad_cvt_string .
These functions accept a pointer to the attribute data, which should
have been obtained using
-.Fn rad_get_attr .
+.Fn rad_get_attr
+and optionally
+.Fn rad_get_vendor_attr .
In the case of
.Fn rad_cvt_string ,
the length
diff --git a/lib/libradius/radlib.c b/lib/libradius/radlib.c
index c94481e..bc3679e 100644
--- a/lib/libradius/radlib.c
+++ b/lib/libradius/radlib.c
@@ -866,6 +866,19 @@ split(char *str, char *fields[], int maxfields, char *msg, size_t msglen)
}
int
+rad_get_vendor_attr(u_int32_t *vendor, const void **data, size_t *len)
+{
+ struct vendor_attribute *attr;
+
+ attr = (struct vendor_attribute *)*data;
+ *vendor = ntohl(attr->vendor_value);
+ *data = attr->attrib_data;
+ *len = attr->attrib_len - 2;
+
+ return (attr->attrib_type);
+}
+
+int
rad_put_vendor_addr(struct rad_handle *h, int vendor, int type,
struct in_addr addr)
{
OpenPOWER on IntegriCloud