5 * libradius.h Structures and prototypes
6 * for the radius library.
13 #include <sys/types.h>
19 typedef unsigned char u_char;
20 typedef unsigned short u_short;
21 typedef unsigned int u_int;
24 #define AUTH_VECTOR_LEN 16
25 #define MAX_STRING_LEN 254 /* RFC2138: string 0-253 octets */
27 #define PW_AUTH_UDP_PORT 1645
28 #define PW_ACCT_UDP_PORT 1646
31 # define AUTH_HDR_LEN 20
32 # define VENDORPEC_USR 429
33 # define VENDOR(x) (x >> 16)
34 # define DEBUG if (librad_debug) printf
35 # define debug_pair(vp) do { if (librad_debug) { \
37 vp_print(stdout, vp); \
43 typedef unsigned int UINT4;
45 typedef struct dict_attr {
50 struct dict_attr *next;
53 typedef struct dict_value {
58 struct dict_value *next;
61 typedef struct dict_vendor {
65 struct dict_vendor *next;
68 typedef struct value_pair {
72 int length; /* of strvalue */
76 u_char strvalue[MAX_STRING_LEN];
77 struct value_pair *next;
81 * vector: Request authenticator from access-request packet
82 * Put in there by rad_decode, and must be put in the
83 * response RADIUS_PACKET as well before calling rad_send
85 * verified: Filled in by rad_decode for accounting-request packets
87 * data,data_len: Used between rad_recv and rad_decode.
89 typedef struct radius_packet {
106 * Printing functions.
108 void librad_safeprint(char *in, int inlen, char *out, int outlen);
109 int vp_prints_value(char *out, int outlen, VALUE_PAIR *vp,int delimitst);
110 int vp_prints(char *out, int outlen, VALUE_PAIR *vp);
111 void vp_print(FILE *, VALUE_PAIR *);
112 void vp_printlist(FILE *, VALUE_PAIR *);
113 #define fprint_attr_val vp_print
116 * Dictionary functions.
118 int dict_addvendor(char *name, int value);
119 int dict_addattr(char *name, int vendor, int type, int value);
120 int dict_addvalue(char *namestr, char *attrstr, int value);
121 int dict_init(char *dir, char *fn);
122 DICT_ATTR *dict_attrbyvalue(int attr);
123 DICT_ATTR *dict_attrbyname(char *attr);
124 DICT_VALUE *dict_valbyattr(int attr, int val);
125 DICT_VALUE *dict_valbyname(char *val);
126 int dict_vendorcode(int);
127 int dict_vendorpec(int);
128 int dict_vendorname(char *name);
130 #if 1 /* FIXME: compat */
131 #define dict_attrget dict_attrbyvalue
132 #define dict_attrfind dict_attrbyname
133 #define dict_valfind dict_valbyname
134 /*#define dict_valget dict_valbyattr almost but not quite*/
139 void librad_md5_calc(u_char *, u_char *, u_int);
142 int rad_send(RADIUS_PACKET *, char *secret);
143 RADIUS_PACKET *rad_recv(int fd);
144 int rad_decode(RADIUS_PACKET *packet, char *secret);
145 RADIUS_PACKET *rad_alloc(int newvector);
146 void rad_free(RADIUS_PACKET *);
147 int rad_pwencode(char *encpw, int *len, char *secret, char *vector);
148 int rad_pwdecode(char *encpw, int len, char *secret, char *vector);
149 int calc_digest (RADIUS_PACKET *packet, char *secret);
150 int calc_acctdigest(RADIUS_PACKET *packet, char *secret,
151 char *data, int len);
154 VALUE_PAIR *paircreate(int attr, int type);
155 void pairfree(VALUE_PAIR *);
156 VALUE_PAIR *pairfind(VALUE_PAIR *, int);
157 void pairdelete(VALUE_PAIR **, int);
158 void pairadd(VALUE_PAIR **, VALUE_PAIR *);
159 VALUE_PAIR *paircopy(VALUE_PAIR *vp);
160 VALUE_PAIR *paircopy2(VALUE_PAIR *vp, int attr);
161 void pairmove(VALUE_PAIR **to, VALUE_PAIR **from);
162 void pairmove2(VALUE_PAIR **to, VALUE_PAIR **from, int attr);
163 VALUE_PAIR *pairmake(char *attribute, char *value, int operator);
164 VALUE_PAIR *pairread(char **ptr, int *eol);
165 int userparse(char *buffer, VALUE_PAIR **first_pair);
171 void librad_log(char *, ...);
173 void librad_perror(char *, ...);
174 extern char librad_errstr[];
175 extern int librad_dodns;
176 extern int librad_debug;
179 * Several handy miscellaneous functions.
181 char * ip_hostname (UINT4);
182 UINT4 ip_getaddr (char *);
183 char * ip_ntoa(char *, UINT4);
184 UINT4 ip_addr(char *);
185 char *strNcpy(char *dest, char *src, int n);
189 int filterBinary(VALUE_PAIR *pair, char *valstr);
190 void print_abinary(VALUE_PAIR *vp, u_char *buffer, int len);