Add rad_get_vendor_attr() for deciphering vendor attributes received
from the RADIUS server.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user