From 051cc9f6f7bff4d2d1b611fce1ece2b58978af6f Mon Sep 17 00:00:00 2001 From: brian Date: Tue, 7 May 2002 10:47:18 +0000 Subject: Add support for vendor specific RADIUS extensions. Only the extensions from rfc2548 are specified for now. --- lib/libradius/radlib.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'lib/libradius/radlib.c') diff --git a/lib/libradius/radlib.c b/lib/libradius/radlib.c index 0b1299b..c94481e 100644 --- a/lib/libradius/radlib.c +++ b/lib/libradius/radlib.c @@ -864,3 +864,54 @@ split(char *str, char *fields[], int maxfields, char *msg, size_t msglen) } return i; } + +int +rad_put_vendor_addr(struct rad_handle *h, int vendor, int type, + struct in_addr addr) +{ + return (rad_put_vendor_attr(h, vendor, type, &addr.s_addr, + sizeof addr.s_addr)); +} + +int +rad_put_vendor_attr(struct rad_handle *h, int vendor, int type, + const void *value, size_t len) +{ + struct vendor_attribute *attr; + int res; + + if ((attr = malloc(len + 6)) == NULL) { + generr(h, "malloc failure (%d bytes)", len + 6); + return -1; + } + + attr->vendor_value = htonl(vendor); + attr->attrib_type = type; + attr->attrib_len = len + 2; + memcpy(attr->attrib_data, value, len); + + res = put_raw_attr(h, RAD_VENDOR_SPECIFIC, attr, len + 6); + free(attr); + if (res == 0 && vendor == RAD_VENDOR_MICROSOFT + && (type == RAD_MICROSOFT_MS_CHAP_RESPONSE + || type == RAD_MICROSOFT_MS_CHAP2_RESPONSE)) { + h->chap_pass = 1; + } + return (res); +} + +int +rad_put_vendor_int(struct rad_handle *h, int vendor, int type, u_int32_t i) +{ + u_int32_t value; + + value = htonl(i); + return (rad_put_vendor_attr(h, vendor, type, &value, sizeof value)); +} + +int +rad_put_vendor_string(struct rad_handle *h, int vendor, int type, + const char *str) +{ + return (rad_put_vendor_attr(h, vendor, type, str, strlen(str))); +} -- cgit v1.1