2 * libradius.h Structures and prototypes
3 * for the radius library.
5 * Version: @(#)libradius.h 1.00 19-Jul-1999 miquels@cistron.nl
12 #define AUTH_VECTOR_LEN 16
13 #define MAX_STRING_LEN 254 /* RFC2138: string 0-253 octets */
16 # define AUTH_HDR_LEN 20
17 # define VENDORPEC_USR 429
18 # define VENDOR(x) (x >> 16)
19 # define DEBUG if (librad_debug) printf
20 # define debug_pair(vp) do { if (librad_debug) { \
22 vp_print(stdout, vp); \
28 typedef unsigned int UINT4;
30 typedef struct dict_attr {
35 struct dict_attr *next;
38 typedef struct dict_value {
43 struct dict_value *next;
46 typedef struct dict_vendor {
50 struct dict_vendor *next;
53 typedef struct value_pair {
57 int length; /* of strvalue */
61 char strvalue[MAX_STRING_LEN];
62 struct value_pair *next;
66 * vector: Request authenticator from access-request packet
67 * Put in there by rad_decode, and must be put in the
68 * response RADIUS_PACKET as well before calling rad_send
70 * verified: Filled in by rad_decode for accounting-request packets
72 * data,data_len: Used between rad_recv and rad_decode.
74 typedef struct radius_packet {
92 void vp_prints(char *out, int outlen, VALUE_PAIR *vp);
93 void vp_print(FILE *, VALUE_PAIR *);
94 void vp_printlist(FILE *, VALUE_PAIR *);
95 #define fprint_attr_val vp_print
98 * Dictionary functions.
100 int dict_init(char *dir, char *fn);
101 DICT_ATTR *dict_attrbyvalue(int attr);
102 DICT_ATTR *dict_attrbyname(char *attr);
103 DICT_VALUE *dict_valbyattr(int attr, int val);
104 DICT_VALUE *dict_valbyname(char *val);
105 int dict_vendorcode(int);
106 int dict_vendorpec(int);
108 #if 1 /* FIXME: compat */
109 #define dict_attrget dict_attrbyvalue
110 #define dict_attrfind dict_attrbyname
111 #define dict_valfind dict_valbyname
112 /*#define dict_valget dict_valbyattr almost but not quite*/
117 void librad_md5_calc(u_char *, u_char *, u_int);
120 int rad_send(RADIUS_PACKET *, int fd, char *secret);
121 RADIUS_PACKET *rad_recv(int fd);
122 int rad_decode(RADIUS_PACKET *packet, char *secret);
123 RADIUS_PACKET *rad_alloc(int newvector);
124 void rad_free(RADIUS_PACKET *);
125 int rad_pwencode(char *encpw, int *len, char *secret, char *vector);
126 int rad_pwdecode(char *encpw, int len, char *secret, char *vector);
127 int calc_digest (RADIUS_PACKET *packet, char *secret);
128 int calc_acctdigest(RADIUS_PACKET *packet, char *secret,
129 char *data, int len);
132 VALUE_PAIR *paircreate(int attr, int type);
133 void pairfree(VALUE_PAIR *);
134 VALUE_PAIR *pairfind(VALUE_PAIR *, int);
135 void pairdelete(VALUE_PAIR **, int);
136 void pairadd(VALUE_PAIR **, VALUE_PAIR *);
137 VALUE_PAIR *paircopy(VALUE_PAIR *vp);
138 VALUE_PAIR *paircopy2(VALUE_PAIR *vp, int attr);
139 void pairmove(VALUE_PAIR **to, VALUE_PAIR **from);
140 void pairmove2(VALUE_PAIR **to, VALUE_PAIR **from, int attr);
141 VALUE_PAIR *pairread(char **ptr, int *eol);
142 int userparse(char *buffer, VALUE_PAIR **first_pair);
148 void librad_log(char *, ...);
150 void librad_perror(char *, ...);
151 extern char *librad_errstr;
152 extern int librad_dodns;
153 extern int librad_debug;
156 * Several handy miscellaneous functions.
158 char * ip_hostname (UINT4);
159 UINT4 ip_getaddr (char *);
160 char * ip_ntoa(char *, UINT4);
161 UINT4 ip_addr(char *);