1082bfe67SJohn Polstra.\" Copyright 1998 Juniper Networks, Inc. 2082bfe67SJohn Polstra.\" All rights reserved. 3082bfe67SJohn Polstra.\" 4082bfe67SJohn Polstra.\" Redistribution and use in source and binary forms, with or without 5082bfe67SJohn Polstra.\" modification, are permitted provided that the following conditions 6082bfe67SJohn Polstra.\" are met: 7082bfe67SJohn Polstra.\" 1. Redistributions of source code must retain the above copyright 8082bfe67SJohn Polstra.\" notice, this list of conditions and the following disclaimer. 9082bfe67SJohn Polstra.\" 2. Redistributions in binary form must reproduce the above copyright 10082bfe67SJohn Polstra.\" notice, this list of conditions and the following disclaimer in the 11082bfe67SJohn Polstra.\" documentation and/or other materials provided with the distribution. 12082bfe67SJohn Polstra.\" 13082bfe67SJohn Polstra.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14082bfe67SJohn Polstra.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15082bfe67SJohn Polstra.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16082bfe67SJohn Polstra.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17082bfe67SJohn Polstra.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18082bfe67SJohn Polstra.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19082bfe67SJohn Polstra.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20082bfe67SJohn Polstra.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21082bfe67SJohn Polstra.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22082bfe67SJohn Polstra.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23082bfe67SJohn Polstra.\" SUCH DAMAGE. 24082bfe67SJohn Polstra.\" 257f3dea24SPeter Wemm.\" $FreeBSD$ 26082bfe67SJohn Polstra.\" 27b4b831efSRuslan Ermilov.Dd April 27, 2004 28082bfe67SJohn Polstra.Dt LIBRADIUS 3 29a307d598SRuslan Ermilov.Os 30082bfe67SJohn Polstra.Sh NAME 31082bfe67SJohn Polstra.Nm libradius 32082bfe67SJohn Polstra.Nd RADIUS client library 33082bfe67SJohn Polstra.Sh SYNOPSIS 3432eef9aeSRuslan Ermilov.In radlib.h 3581b380a8SRuslan Ermilov.Ft "struct rad_handle *" 360981dfefSJohn Polstra.Fn rad_acct_open "void" 37082bfe67SJohn Polstra.Ft int 38082bfe67SJohn Polstra.Fn rad_add_server "struct rad_handle *h" "const char *host" "int port" "const char *secret" "int timeout" "int max_tries" 3981b380a8SRuslan Ermilov.Ft "struct rad_handle *" 400981dfefSJohn Polstra.Fn rad_auth_open "void" 41082bfe67SJohn Polstra.Ft void 42082bfe67SJohn Polstra.Fn rad_close "struct rad_handle *h" 43082bfe67SJohn Polstra.Ft int 44082bfe67SJohn Polstra.Fn rad_config "struct rad_handle *h" "const char *file" 45082bfe67SJohn Polstra.Ft int 4648caee2aSBrian Somers.Fn rad_continue_send_request "struct rad_handle *h" "int selected" "int *fd" "struct timeval *tv" 4748caee2aSBrian Somers.Ft int 48082bfe67SJohn Polstra.Fn rad_create_request "struct rad_handle *h" "int code" 4981b380a8SRuslan Ermilov.Ft "struct in_addr" 50082bfe67SJohn Polstra.Fn rad_cvt_addr "const void *data" 51082bfe67SJohn Polstra.Ft u_int32_t 52082bfe67SJohn Polstra.Fn rad_cvt_int "const void *data" 53082bfe67SJohn Polstra.Ft char * 54082bfe67SJohn Polstra.Fn rad_cvt_string "const void *data" "size_t len" 55082bfe67SJohn Polstra.Ft int 56082bfe67SJohn Polstra.Fn rad_get_attr "struct rad_handle *h" "const void **data" "size_t *len" 5748caee2aSBrian Somers.Ft int 58fc3f62faSBrian Somers.Fn rad_get_vendor_attr "u_int32_t *vendor" "const void **data" "size_t *len" 59fc3f62faSBrian Somers.Ft int 6048caee2aSBrian Somers.Fn rad_init_send_request "struct rad_handle *h" "int *fd" "struct timeval *tv" 61082bfe67SJohn Polstra.Ft int 62082bfe67SJohn Polstra.Fn rad_put_addr "struct rad_handle *h" "int type" "struct in_addr addr" 63082bfe67SJohn Polstra.Ft int 64082bfe67SJohn Polstra.Fn rad_put_attr "struct rad_handle *h" "int type" "const void *data" "size_t len" 65082bfe67SJohn Polstra.Ft int 66082bfe67SJohn Polstra.Fn rad_put_int "struct rad_handle *h" "int type" "u_int32_t value" 67082bfe67SJohn Polstra.Ft int 68082bfe67SJohn Polstra.Fn rad_put_string "struct rad_handle *h" "int type" "const char *str" 69082bfe67SJohn Polstra.Ft int 70b4b831efSRuslan Ermilov.Fn rad_put_message_authentic "struct rad_handle *h" 71b4b831efSRuslan Ermilov.Ft int 72b49a88f6SBrian Somers.Fn rad_put_vendor_addr "struct rad_handle *h" "int vendor" "int type" "struct in_addr addr" 73b49a88f6SBrian Somers.Ft int 74b49a88f6SBrian Somers.Fn rad_put_vendor_attr "struct rad_handle *h" "int vendor" "int type" "const void *data" "size_t len" 75b49a88f6SBrian Somers.Ft int 76b49a88f6SBrian Somers.Fn rad_put_vendor_int "struct rad_handle *h" "int vendor" "int type" "u_int32_t value" 77b49a88f6SBrian Somers.Ft int 78b49a88f6SBrian Somers.Fn rad_put_vendor_string "struct rad_handle *h" "int vendor" "int type" "const char *str" 79628e6cd4SBrian Somers.Ft ssize_t 80628e6cd4SBrian Somers.Fn rad_request_authenticator "struct rad_handle *h" "char *buf" "size_t len" 81b49a88f6SBrian Somers.Ft int 82082bfe67SJohn Polstra.Fn rad_send_request "struct rad_handle *h" 8381b380a8SRuslan Ermilov.Ft "const char *" 84628e6cd4SBrian Somers.Fn rad_server_secret "struct rad_handle *h" 85b4b831efSRuslan Ermilov.Ft u_char * 86b4b831efSRuslan Ermilov.Fn rad_demangle "struct rad_handle *h" "const void *mangled" "size_t mlen" 87b4b831efSRuslan Ermilov.Ft u_char * 88b4b831efSRuslan Ermilov.Fn rad_demangle_mppe_key "struct rad_handle *h" "const void *mangled" "size_t mlen" "size_t *len" 8981b380a8SRuslan Ermilov.Ft "const char *" 90082bfe67SJohn Polstra.Fn rad_strerror "struct rad_handle *h" 91082bfe67SJohn Polstra.Sh DESCRIPTION 92082bfe67SJohn PolstraThe 93082bfe67SJohn Polstra.Nm 940981dfefSJohn Polstralibrary implements the client side of the Remote Authentication Dial 9581b380a8SRuslan ErmilovIn User Service (RADIUS). 96b4b831efSRuslan ErmilovRADIUS, defined in RFCs 2865 and 2866, 970981dfefSJohn Polstraallows clients to perform authentication and accounting by means of 980981dfefSJohn Polstranetwork requests to remote servers. 9981b380a8SRuslan Ermilov.Ss Initialization 100082bfe67SJohn PolstraTo use the library, an application must first call 1010981dfefSJohn Polstra.Fn rad_auth_open 1020981dfefSJohn Polstraor 1030981dfefSJohn Polstra.Fn rad_acct_open 104082bfe67SJohn Polstrato obtain a 10581b380a8SRuslan Ermilov.Vt "struct rad_handle *" , 106082bfe67SJohn Polstrawhich provides the context for subsequent operations. 1070981dfefSJohn PolstraThe former function is used for RADIUS authentication and the 1080981dfefSJohn Polstralatter is used for RADIUS accounting. 109082bfe67SJohn PolstraCalls to 1100981dfefSJohn Polstra.Fn rad_auth_open 1110981dfefSJohn Polstraand 1120981dfefSJohn Polstra.Fn rad_acct_open 11381b380a8SRuslan Ermilovalways succeed unless insufficient virtual memory is available. 11481b380a8SRuslan ErmilovIf 1150981dfefSJohn Polstrathe necessary memory cannot be allocated, the functions return 116082bfe67SJohn Polstra.Dv NULL . 1170981dfefSJohn PolstraFor compatibility with earlier versions of this library, 1180981dfefSJohn Polstra.Fn rad_open 1190981dfefSJohn Polstrais provided as a synonym for 1200981dfefSJohn Polstra.Fn rad_auth_open . 121082bfe67SJohn Polstra.Pp 122082bfe67SJohn PolstraBefore issuing any RADIUS requests, the library must be made aware 12381b380a8SRuslan Ermilovof the servers it can contact. 12481b380a8SRuslan ErmilovThe easiest way to configure the 125082bfe67SJohn Polstralibrary is to call 126082bfe67SJohn Polstra.Fn rad_config . 127082bfe67SJohn Polstra.Fn rad_config 128082bfe67SJohn Polstracauses the library to read a configuration file whose format is 129082bfe67SJohn Polstradescribed in 130082bfe67SJohn Polstra.Xr radius.conf 5 . 131082bfe67SJohn PolstraThe pathname of the configuration file is passed as the 13281b380a8SRuslan Ermilov.Fa file 133082bfe67SJohn Polstraargument to 134082bfe67SJohn Polstra.Fn rad_config . 135082bfe67SJohn PolstraThis argument may also be given as 136082bfe67SJohn Polstra.Dv NULL , 137082bfe67SJohn Polstrain which case the standard configuration file 138082bfe67SJohn Polstra.Pa /etc/radius.conf 139082bfe67SJohn Polstrais used. 140082bfe67SJohn Polstra.Fn rad_config 14181b380a8SRuslan Ermilovreturns 0 on success, or \-1 if an error occurs. 142082bfe67SJohn Polstra.Pp 143082bfe67SJohn PolstraThe library can also be configured programmatically by calls to 144082bfe67SJohn Polstra.Fn rad_add_server . 145082bfe67SJohn PolstraThe 14681b380a8SRuslan Ermilov.Fa host 147082bfe67SJohn Polstraparameter specifies the server host, either as a fully qualified 148082bfe67SJohn Polstradomain name or as a dotted-quad IP address in text form. 149082bfe67SJohn PolstraThe 15081b380a8SRuslan Ermilov.Fa port 15181b380a8SRuslan Ermilovparameter specifies the UDP port to contact on the server. 15281b380a8SRuslan ErmilovIf 15381b380a8SRuslan Ermilov.Fa port 154082bfe67SJohn Polstrais given as 0, the library looks up the 155082bfe67SJohn Polstra.Ql radius/udp 1560981dfefSJohn Polstraor 1570981dfefSJohn Polstra.Ql radacct/udp 15881b380a8SRuslan Ermilovservice in the network 15981b380a8SRuslan Ermilov.Xr services 5 16081b380a8SRuslan Ermilovdatabase, and uses the port found 16181b380a8SRuslan Ermilovthere. 16281b380a8SRuslan ErmilovIf no entry is found, the library uses the standard RADIUS 1630981dfefSJohn Polstraports, 1812 for authentication and 1813 for accounting. 1640981dfefSJohn PolstraThe shared secret for the server host is passed to the 16581b380a8SRuslan Ermilov.Fa secret 166082bfe67SJohn Polstraparameter. 16781b380a8SRuslan ErmilovIt may be any 16881b380a8SRuslan Ermilov.Dv NUL Ns -terminated 16981b380a8SRuslan Ermilovstring of bytes. 17081b380a8SRuslan ErmilovThe RADIUS protocol 171082bfe67SJohn Polstraignores all but the leading 128 bytes of the shared secret. 172082bfe67SJohn PolstraThe timeout for receiving replies from the server is passed to the 17381b380a8SRuslan Ermilov.Fa timeout 17481b380a8SRuslan Ermilovparameter, in units of seconds. 17581b380a8SRuslan ErmilovThe maximum number of repeated 176082bfe67SJohn Polstrarequests to make before giving up is passed into the 17781b380a8SRuslan Ermilov.Fa max_tries 178082bfe67SJohn Polstraparameter. 179082bfe67SJohn Polstra.Fn rad_add_server 18081b380a8SRuslan Ermilovreturns 0 on success, or \-1 if an error occurs. 181082bfe67SJohn Polstra.Pp 182082bfe67SJohn Polstra.Fn rad_add_server 183082bfe67SJohn Polstramay be called multiple times, and it may be used together with 184082bfe67SJohn Polstra.Fn rad_config . 185082bfe67SJohn PolstraAt most 10 servers may be specified. 186082bfe67SJohn PolstraWhen multiple servers are given, they are tried in round-robin 187082bfe67SJohn Polstrafashion until a valid response is received, or until each server's 18881b380a8SRuslan Ermilov.Fa max_tries 189082bfe67SJohn Polstralimit has been reached. 19081b380a8SRuslan Ermilov.Ss Creating a RADIUS Request 191082bfe67SJohn PolstraA RADIUS request consists of a code specifying the kind of request, 19281b380a8SRuslan Ermilovand zero or more attributes which provide additional information. 19381b380a8SRuslan ErmilovTo 194082bfe67SJohn Polstrabegin constructing a new request, call 195082bfe67SJohn Polstra.Fn rad_create_request . 196082bfe67SJohn PolstraIn addition to the usual 19781b380a8SRuslan Ermilov.Vt "struct rad_handle *" , 198082bfe67SJohn Polstrathis function takes a 19981b380a8SRuslan Ermilov.Fa code 20081b380a8SRuslan Ermilovparameter which specifies the type of the request. 20181b380a8SRuslan ErmilovMost often this 202082bfe67SJohn Polstrawill be 203082bfe67SJohn Polstra.Dv RAD_ACCESS_REQUEST . 204082bfe67SJohn Polstra.Fn rad_create_request 20581b380a8SRuslan Ermilovreturns 0 on success, or \-1 on if an error occurs. 206082bfe67SJohn Polstra.Pp 207082bfe67SJohn PolstraAfter the request has been created with 208abac9a9eSBrian Somers.Fn rad_create_request , 20981b380a8SRuslan Ermilovattributes can be attached to it. 21081b380a8SRuslan ErmilovThis is done through calls to 211082bfe67SJohn Polstra.Fn rad_put_addr , 212082bfe67SJohn Polstra.Fn rad_put_int , 213082bfe67SJohn Polstraand 214082bfe67SJohn Polstra.Fn rad_put_string . 215082bfe67SJohn PolstraEach accepts a 21681b380a8SRuslan Ermilov.Fa type 217082bfe67SJohn Polstraparameter identifying the attribute, and a value which may be 21881b380a8SRuslan Ermilovan Internet address, an integer, or a 21981b380a8SRuslan Ermilov.Dv NUL Ns -terminated 22081b380a8SRuslan Ermilovstring, 221082bfe67SJohn Polstrarespectively. 222b49a88f6SBrian SomersAlternatively, 223b49a88f6SBrian Somers.Fn rad_put_vendor_addr , 224b49a88f6SBrian Somers.Fn rad_put_vendor_int 225b49a88f6SBrian Somersor 226b49a88f6SBrian Somers.Fn rad_put_vendor_string 22781b380a8SRuslan Ermilovmay be used to specify vendor specific attributes. 22881b380a8SRuslan ErmilovVendor specific 229b49a88f6SBrian Somersdefinitions may be found in 230fe08efe6SRuslan Ermilov.In radlib_vs.h 231082bfe67SJohn Polstra.Pp 232082bfe67SJohn PolstraThe library also provides a function 233082bfe67SJohn Polstra.Fn rad_put_attr 23481b380a8SRuslan Ermilovwhich can be used to supply a raw, uninterpreted attribute. 23581b380a8SRuslan ErmilovThe 23681b380a8SRuslan Ermilov.Fa data 237082bfe67SJohn Polstraargument points to an array of bytes, and the 23881b380a8SRuslan Ermilov.Fa len 239082bfe67SJohn Polstraargument specifies its length. 240082bfe67SJohn Polstra.Pp 241b4b831efSRuslan ErmilovIt is possible adding the Message-Authenticator to the request. 242b4b831efSRuslan ErmilovThis is an HMAC-MD5 hash of the entire Access-Request packet (see RFC 3579). 243b4b831efSRuslan ErmilovThis attribute must be present in any packet that includes an EAP-Message 244b4b831efSRuslan Ermilovattribute. 245b4b831efSRuslan ErmilovIt can be added by using the 246b4b831efSRuslan Ermilov.Fn rad_put_message_authentic 247b4b831efSRuslan Ermilovfunction. 248b4b831efSRuslan ErmilovThe 249b4b831efSRuslan Ermilov.Nm 250b4b831efSRuslan Ermilovlibrary 251b4b831efSRuslan Ermilovcalculates the HMAC-MD5 hash implicitly before sending the request. 252b4b831efSRuslan ErmilovIf the Message-Authenticator was found inside the response packet, 253b4b831efSRuslan Ermilovthen the packet is silently dropped, if the validation failed. 254b4b831efSRuslan ErmilovIn order to get this feature, the library should be compiled with 255b4b831efSRuslan ErmilovOpenSSL support. 256b4b831efSRuslan Ermilov.Pp 257082bfe67SJohn PolstraThe 258082bfe67SJohn Polstra.Fn rad_put_X 25981b380a8SRuslan Ermilovfunctions return 0 on success, or \-1 if an error occurs. 26081b380a8SRuslan Ermilov.Ss Sending the Request and Receiving the Response 26148caee2aSBrian SomersAfter the RADIUS request has been constructed, it is sent either by means of 26248caee2aSBrian Somers.Fn rad_send_request 26348caee2aSBrian Somersor by a combination of calls to 26448caee2aSBrian Somers.Fn rad_init_send_request 26548caee2aSBrian Somersand 26648caee2aSBrian Somers.Fn rad_continue_send_request . 26748caee2aSBrian Somers.Pp 26848caee2aSBrian SomersThe 26948caee2aSBrian Somers.Fn rad_send_request 27048caee2aSBrian Somersfunction sends the request and waits for a valid reply, 271082bfe67SJohn Polstraretrying the defined servers in round-robin fashion as necessary. 272082bfe67SJohn PolstraIf a valid response is received, 273082bfe67SJohn Polstra.Fn rad_send_request 274082bfe67SJohn Polstrareturns the RADIUS code which specifies the type of the response. 275082bfe67SJohn PolstraThis will typically be 276082bfe67SJohn Polstra.Dv RAD_ACCESS_ACCEPT , 277082bfe67SJohn Polstra.Dv RAD_ACCESS_REJECT , 278082bfe67SJohn Polstraor 279082bfe67SJohn Polstra.Dv RAD_ACCESS_CHALLENGE . 280082bfe67SJohn PolstraIf no valid response is received, 281082bfe67SJohn Polstra.Fn rad_send_request 28281b380a8SRuslan Ermilovreturns \-1. 283082bfe67SJohn Polstra.Pp 28448caee2aSBrian SomersAs an alternative, if you do not wish to block waiting for a response, 28548caee2aSBrian Somers.Fn rad_init_send_request 28648caee2aSBrian Somersand 28748caee2aSBrian Somers.Fn rad_continue_send_request 28881b380a8SRuslan Ermilovmay be used instead. 28981b380a8SRuslan ErmilovIf a reply is received from the RADIUS server or a 29048caee2aSBrian Somerstimeout occurs, these functions return a value as described for 29148caee2aSBrian Somers.Fn rad_send_request . 29248caee2aSBrian SomersOtherwise, a value of zero is returned and the values pointed to by 29381b380a8SRuslan Ermilov.Fa fd 29448caee2aSBrian Somersand 29581b380a8SRuslan Ermilov.Fa tv 29648caee2aSBrian Somersare set to the descriptor and timeout that should be passed to 29748caee2aSBrian Somers.Xr select 2 . 29848caee2aSBrian Somers.Pp 29948caee2aSBrian Somers.Fn rad_init_send_request 30048caee2aSBrian Somersmust be called first, followed by repeated calls to 30148caee2aSBrian Somers.Fn rad_continue_send_request 30248caee2aSBrian Somersas long as a return value of zero is given. 30348caee2aSBrian SomersBetween each call, the application should call 30448caee2aSBrian Somers.Xr select 2 , 30548caee2aSBrian Somerspassing 30681b380a8SRuslan Ermilov.Fa *fd 30748caee2aSBrian Somersas a read descriptor and timing out after the interval specified by 30881b380a8SRuslan Ermilov.Fa tv . 30981b380a8SRuslan ErmilovWhen 31081b380a8SRuslan Ermilov.Xr select 2 31181b380a8SRuslan Ermilovreturns, 31248caee2aSBrian Somers.Fn rad_continue_send_request 31348caee2aSBrian Somersshould be called with 31481b380a8SRuslan Ermilov.Fa selected 31548caee2aSBrian Somersset to a non-zero value if 31648caee2aSBrian Somers.Xr select 2 31748caee2aSBrian Somersindicated that the descriptor is readable. 31848caee2aSBrian Somers.Pp 319082bfe67SJohn PolstraLike RADIUS requests, each response may contain zero or more 32081b380a8SRuslan Ermilovattributes. 32181b380a8SRuslan ErmilovAfter a response has been received successfully by 32248caee2aSBrian Somers.Fn rad_send_request 32348caee2aSBrian Somersor 32448caee2aSBrian Somers.Fn rad_continue_send_request , 325082bfe67SJohn Polstraits attributes can be extracted one by one using 326082bfe67SJohn Polstra.Fn rad_get_attr . 327082bfe67SJohn PolstraEach time 328082bfe67SJohn Polstra.Fn rad_get_attr 329082bfe67SJohn Polstrais called, it gets the next attribute from the current response, and 330082bfe67SJohn Polstrastores a pointer to the data and the length of the data via the 331082bfe67SJohn Polstrareference parameters 33281b380a8SRuslan Ermilov.Fa data 333082bfe67SJohn Polstraand 33481b380a8SRuslan Ermilov.Fa len , 33581b380a8SRuslan Ermilovrespectively. 33681b380a8SRuslan ErmilovNote that the data resides in the response itself, 337082bfe67SJohn Polstraand must not be modified. 338082bfe67SJohn PolstraA successful call to 339082bfe67SJohn Polstra.Fn rad_get_attr 340082bfe67SJohn Polstrareturns the RADIUS attribute type. 341082bfe67SJohn PolstraIf no more attributes remain in the current response, 342082bfe67SJohn Polstra.Fn rad_get_attr 343082bfe67SJohn Polstrareturns 0. 34481b380a8SRuslan ErmilovIf an error such as a malformed attribute is detected, \-1 is 345082bfe67SJohn Polstrareturned. 346082bfe67SJohn Polstra.Pp 347fc3f62faSBrian SomersIf 348fc3f62faSBrian Somers.Fn rad_get_attr 349fc3f62faSBrian Somersreturns 350fc3f62faSBrian Somers.Dv RAD_VENDOR_SPECIFIC , 351fc3f62faSBrian Somers.Fn rad_get_vendor_attr 352fc3f62faSBrian Somersmay be called to determine the vendor. 353fc3f62faSBrian SomersThe vendor specific RADIUS attribute type is returned. 354fc3f62faSBrian SomersThe reference parameters 35581b380a8SRuslan Ermilov.Fa data 356fc3f62faSBrian Somersand 35781b380a8SRuslan Ermilov.Fa len 35848091bb0SRuslan Ermilov(as returned from 35948091bb0SRuslan Ermilov.Fn rad_get_attr ) 360fc3f62faSBrian Somersare passed to 361fc3f62faSBrian Somers.Fn rad_get_vendor_attr , 362fc3f62faSBrian Somersand are adjusted to point to the vendor specific attribute data. 363fc3f62faSBrian Somers.Pp 364082bfe67SJohn PolstraThe common types of attributes can be decoded using 365082bfe67SJohn Polstra.Fn rad_cvt_addr , 366082bfe67SJohn Polstra.Fn rad_cvt_int , 367082bfe67SJohn Polstraand 368082bfe67SJohn Polstra.Fn rad_cvt_string . 369082bfe67SJohn PolstraThese functions accept a pointer to the attribute data, which should 370082bfe67SJohn Polstrahave been obtained using 371fc3f62faSBrian Somers.Fn rad_get_attr 372fc3f62faSBrian Somersand optionally 373fc3f62faSBrian Somers.Fn rad_get_vendor_attr . 374082bfe67SJohn PolstraIn the case of 375082bfe67SJohn Polstra.Fn rad_cvt_string , 376082bfe67SJohn Polstrathe length 37781b380a8SRuslan Ermilov.Fa len 37881b380a8SRuslan Ermilovmust also be given. 37981b380a8SRuslan ErmilovThese functions interpret the attribute as an 380082bfe67SJohn PolstraInternet address, an integer, or a string, respectively, and return 381082bfe67SJohn Polstraits value. 382082bfe67SJohn Polstra.Fn rad_cvt_string 38381b380a8SRuslan Ermilovreturns its value as a 38481b380a8SRuslan Ermilov.Dv NUL Ns -terminated 38581b380a8SRuslan Ermilovstring in dynamically 38681b380a8SRuslan Ermilovallocated memory. 38781b380a8SRuslan ErmilovThe application should free the string using 388082bfe67SJohn Polstra.Xr free 3 389082bfe67SJohn Polstrawhen it is no longer needed. 390082bfe67SJohn Polstra.Pp 391082bfe67SJohn PolstraIf insufficient virtual memory is available, 392082bfe67SJohn Polstra.Fn rad_cvt_string 393082bfe67SJohn Polstrareturns 394082bfe67SJohn Polstra.Dv NULL . 395082bfe67SJohn Polstra.Fn rad_cvt_addr 396082bfe67SJohn Polstraand 397082bfe67SJohn Polstra.Fn rad_cvt_int 398082bfe67SJohn Polstracannot fail. 399628e6cd4SBrian Somers.Pp 400628e6cd4SBrian SomersThe 401628e6cd4SBrian Somers.Fn rad_request_authenticator 402628e6cd4SBrian Somersfunction may be used to obtain the Request-Authenticator attribute value 403628e6cd4SBrian Somersassociated with the current RADIUS server according to the supplied 404628e6cd4SBrian Somersrad_handle. 405628e6cd4SBrian SomersThe target buffer 40681b380a8SRuslan Ermilov.Fa buf 407628e6cd4SBrian Somersof length 40881b380a8SRuslan Ermilov.Fa len 409628e6cd4SBrian Somersmust be supplied and should be at least 16 bytes. 410628e6cd4SBrian SomersThe return value is the number of bytes written to 41181b380a8SRuslan Ermilov.Fa buf 41281b380a8SRuslan Ermilovor \-1 to indicate that 41381b380a8SRuslan Ermilov.Fa len 414628e6cd4SBrian Somerswas not large enough. 415628e6cd4SBrian Somers.Pp 416628e6cd4SBrian SomersThe 417628e6cd4SBrian Somers.Fn rad_server_secret 418628e6cd4SBrian Somersreturns the secret shared with the current RADIUS server according to the 419628e6cd4SBrian Somerssupplied rad_handle. 420b4b831efSRuslan Ermilov.Pp 421b4b831efSRuslan ErmilovThe 422b4b831efSRuslan Ermilov.Fn rad_demangle 423b4b831efSRuslan Ermilovfunction demangles attributes containing passwords and MS-CHAPv1 MPPE-Keys. 424b4b831efSRuslan ErmilovThe return value is 425b4b831efSRuslan Ermilov.Dv NULL 426b4b831efSRuslan Ermilovon failure, or the plaintext attribute. 427b4b831efSRuslan ErmilovThis value should be freed using 428b4b831efSRuslan Ermilov.Xr free 3 429b4b831efSRuslan Ermilovwhen it is no longer needed. 430b4b831efSRuslan Ermilov.Pp 431b4b831efSRuslan ErmilovThe 432b4b831efSRuslan Ermilov.Fn rad_demangle_mppe_key 433b4b831efSRuslan Ermilovfunction demangles the send- and recv-keys when using MPPE (see RFC 2548). 434b4b831efSRuslan ErmilovThe return value is 435b4b831efSRuslan Ermilov.Dv NULL 436b4b831efSRuslan Ermilovon failure, or the plaintext attribute. 437b4b831efSRuslan ErmilovThis value should be freed using 438b4b831efSRuslan Ermilov.Xr free 3 439b4b831efSRuslan Ermilovwhen it is no longer needed. 44081b380a8SRuslan Ermilov.Ss Obtaining Error Messages 441082bfe67SJohn PolstraThose functions which accept a 44281b380a8SRuslan Ermilov.Vt "struct rad_handle *" 44381b380a8SRuslan Ermilovargument record an error message if they fail. 44481b380a8SRuslan ErmilovThe error message 445082bfe67SJohn Polstracan be retrieved by calling 446082bfe67SJohn Polstra.Fn rad_strerror . 447082bfe67SJohn PolstraThe message text is overwritten on each new error for the given 44881b380a8SRuslan Ermilov.Vt "struct rad_handle *" . 449082bfe67SJohn PolstraThus the message must be copied if it is to be preserved through 450082bfe67SJohn Polstrasubsequent library calls using the same handle. 45181b380a8SRuslan Ermilov.Ss Cleanup 452082bfe67SJohn PolstraTo free the resources used by the RADIUS library, call 453082bfe67SJohn Polstra.Fn rad_close . 454082bfe67SJohn Polstra.Sh RETURN VALUES 45581b380a8SRuslan ErmilovThe following functions return a non-negative value on success. 45681b380a8SRuslan ErmilovIf 45781b380a8SRuslan Ermilovthey detect an error, they return \-1 and record an error message 458082bfe67SJohn Polstrawhich can be retrieved using 459082bfe67SJohn Polstra.Fn rad_strerror . 460082bfe67SJohn Polstra.Pp 461082bfe67SJohn Polstra.Bl -item -offset indent -compact 462082bfe67SJohn Polstra.It 463082bfe67SJohn Polstra.Fn rad_add_server 464082bfe67SJohn Polstra.It 465082bfe67SJohn Polstra.Fn rad_config 466082bfe67SJohn Polstra.It 467082bfe67SJohn Polstra.Fn rad_create_request 468082bfe67SJohn Polstra.It 469082bfe67SJohn Polstra.Fn rad_get_attr 470082bfe67SJohn Polstra.It 471082bfe67SJohn Polstra.Fn rad_put_addr 472082bfe67SJohn Polstra.It 473082bfe67SJohn Polstra.Fn rad_put_attr 474082bfe67SJohn Polstra.It 475082bfe67SJohn Polstra.Fn rad_put_int 476082bfe67SJohn Polstra.It 477082bfe67SJohn Polstra.Fn rad_put_string 478082bfe67SJohn Polstra.It 479b4b831efSRuslan Ermilov.Fn rad_put_message_authentic 480b4b831efSRuslan Ermilov.It 48148caee2aSBrian Somers.Fn rad_init_send_request 48248caee2aSBrian Somers.It 48348caee2aSBrian Somers.Fn rad_continue_send_request 48448caee2aSBrian Somers.It 485082bfe67SJohn Polstra.Fn rad_send_request 486082bfe67SJohn Polstra.El 487082bfe67SJohn Polstra.Pp 488082bfe67SJohn PolstraThe following functions return a 489082bfe67SJohn Polstra.No non- Ns Dv NULL 49081b380a8SRuslan Ermilovpointer on success. 49181b380a8SRuslan ErmilovIf they are unable to allocate sufficient 492082bfe67SJohn Polstravirtual memory, they return 493082bfe67SJohn Polstra.Dv NULL , 494082bfe67SJohn Polstrawithout recording an error message. 495082bfe67SJohn Polstra.Pp 496082bfe67SJohn Polstra.Bl -item -offset indent -compact 497082bfe67SJohn Polstra.It 4980981dfefSJohn Polstra.Fn rad_acct_open 499082bfe67SJohn Polstra.It 5000981dfefSJohn Polstra.Fn rad_auth_open 5010981dfefSJohn Polstra.It 5020981dfefSJohn Polstra.Fn rad_cvt_string 503082bfe67SJohn Polstra.El 504b4b831efSRuslan Ermilov.Pp 505b4b831efSRuslan ErmilovThe following functions return a 506b4b831efSRuslan Ermilov.No non- Ns Dv NULL 507b4b831efSRuslan Ermilovpointer on success. 508b4b831efSRuslan ErmilovIf they fail, they return 509b4b831efSRuslan Ermilov.Dv NULL , 510b4b831efSRuslan Ermilovwith recording an error message. 511b4b831efSRuslan Ermilov.Pp 512b4b831efSRuslan Ermilov.Bl -item -offset indent -compact 513b4b831efSRuslan Ermilov.It 514b4b831efSRuslan Ermilov.Fn rad_demangle 515b4b831efSRuslan Ermilov.It 516b4b831efSRuslan Ermilov.Fn rad_demangle_mppe_key 517b4b831efSRuslan Ermilov.El 518082bfe67SJohn Polstra.Sh FILES 51981b380a8SRuslan Ermilov.Bl -tag -width indent 52081b380a8SRuslan Ermilov.It Pa /etc/radius.conf 52181b380a8SRuslan Ermilov.El 522082bfe67SJohn Polstra.Sh SEE ALSO 523082bfe67SJohn Polstra.Xr radius.conf 5 524082bfe67SJohn Polstra.Rs 52581b380a8SRuslan Ermilov.%A "C. Rigney, et al" 52642635956SRuslan Ermilov.%T "Remote Authentication Dial In User Service (RADIUS)" 527b4b831efSRuslan Ermilov.%O "RFC 2865" 528082bfe67SJohn Polstra.Re 5290981dfefSJohn Polstra.Rs 53081b380a8SRuslan Ermilov.%A "C. Rigney" 53181b380a8SRuslan Ermilov.%T "RADIUS Accounting" 532b4b831efSRuslan Ermilov.%O "RFC 2866" 533b4b831efSRuslan Ermilov.Re 534b4b831efSRuslan Ermilov.Rs 535b4b831efSRuslan Ermilov.%A G. Zorn 536b4b831efSRuslan Ermilov.%T "Microsoft Vendor-specific RADIUS attributes" 537b4b831efSRuslan Ermilov.%O RFC 2548 538b4b831efSRuslan Ermilov.Re 539b4b831efSRuslan Ermilov.Rs 540b4b831efSRuslan Ermilov.%A C. Rigney, et al 541b4b831efSRuslan Ermilov.%T "RADIUS extensions" 542b4b831efSRuslan Ermilov.%O RFC 2869 5430981dfefSJohn Polstra.Re 544082bfe67SJohn Polstra.Sh AUTHORS 54581b380a8SRuslan Ermilov.An -nosplit 5460981dfefSJohn PolstraThis software was originally written by 547082bfe67SJohn Polstra.An John Polstra , 548b5c508fbSRuslan Ermilovand donated to the 549b5c508fbSRuslan Ermilov.Fx 550b5c508fbSRuslan Ermilovproject by Juniper Networks, Inc. 55181b380a8SRuslan Ermilov.An Oleg Semyonov 55281b380a8SRuslan Ermilovsubsequently added the ability to perform RADIUS 5530981dfefSJohn Polstraaccounting. 554b4b831efSRuslan ErmilovLater additions and changes by 555b4b831efSRuslan Ermilov.An Michael Bretterklieber . 556