Add rad_get_vendor_attr() for deciphering vendor attributes received

from the RADIUS server.
This commit is contained in:
Brian Somers 2002-05-10 02:40:23 +00:00
parent 4c04f5d447
commit fc3f62faaa
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=96322
2 changed files with 34 additions and 1 deletions

View File

@ -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

View File

@ -865,6 +865,19 @@ split(char *str, char *fields[], int maxfields, char *msg, size_t msglen)
return i;
}
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)