summaryrefslogtreecommitdiffstats
path: root/web/attachments/140951-radiusclient.h
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/140951-radiusclient.h')
-rw-r--r--web/attachments/140951-radiusclient.h496
1 files changed, 496 insertions, 0 deletions
diff --git a/web/attachments/140951-radiusclient.h b/web/attachments/140951-radiusclient.h
new file mode 100644
index 0000000..9ce2a39
--- /dev/null
+++ b/web/attachments/140951-radiusclient.h
@@ -0,0 +1,496 @@
1/*
2 * $Id: radiusclient.h,v 1.9 2002/11/13 18:19:26 fcusack Exp $
3 *
4 * Copyright (C) 1995,1996,1997,1998 Lars Fenneberg
5 *
6 * Copyright 1992 Livingston Enterprises, Inc.
7 *
8 * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
9 * and Merit Network, Inc. All Rights Reserved
10 *
11 * See the file COPYRIGHT for the respective terms and conditions.
12 * If the file is missing contact me at lf@elemental.net
13 * and I'll send you a copy.
14 *
15 */
16
17#ifndef RADIUSCLIENT_H
18#define RADIUSCLIENT_H
19
20#include <sys/types.h>
21#include <stdio.h>
22#include <time.h>
23
24#undef __BEGIN_DECLS
25#undef __END_DECLS
26#ifdef __cplusplus
27# define __BEGIN_DECLS extern "C" {
28# define __END_DECLS }
29#else
30# define __BEGIN_DECLS /* empty */
31# define __END_DECLS /* empty */
32#endif
33
34#undef __P
35#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32) || defined(__cplusplus)
36# define __P(protos) protos
37#else
38# define __P(protos) ()
39#endif
40
41#ifndef _UINT4_T
42#ifdef _LP64
43typedef unsigned int UINT4;
44typedef int INT4;
45#else
46typedef unsigned long UINT4;
47typedef long INT4;
48#endif
49#endif
50
51#define AUTH_VECTOR_LEN 16
52#define AUTH_PASS_LEN (3 * 16) /* multiple of 16 */
53#define AUTH_ID_LEN 64
54#define AUTH_STRING_LEN 128 /* maximum of 253 */
55
56#define BUFFER_LEN 8192
57
58#define NAME_LENGTH 32
59#define GETSTR_LENGTH 128 /* must be bigger than AUTH_PASS_LEN */
60
61/* codes for radius_buildreq, radius_getport, etc. */
62#define AUTH 0
63#define ACCT 1
64
65/* defines for config.c */
66
67#define SERVER_MAX 8
68
69#define AUTH_LOCAL_FST (1<<0)
70#define AUTH_RADIUS_FST (1<<1)
71#define AUTH_LOCAL_SND (1<<2)
72#define AUTH_RADIUS_SND (1<<3)
73
74typedef struct server {
75 int max;
76 char *name[SERVER_MAX];
77 unsigned short port[SERVER_MAX];
78} SERVER;
79
80typedef struct pw_auth_hdr
81{
82 u_char code;
83 u_char id;
84 u_short length;
85 u_char vector[AUTH_VECTOR_LEN];
86 u_char data[2];
87} AUTH_HDR;
88
89#define AUTH_HDR_LEN 20
90#define MAX_SECRET_LENGTH (3 * 16) /* MUST be multiple of 16 */
91#define CHAP_VALUE_LENGTH 16
92
93#define PW_AUTH_UDP_PORT 1812
94#define PW_ACCT_UDP_PORT 1813
95
96#define PW_TYPE_STRING 0
97#define PW_TYPE_INTEGER 1
98#define PW_TYPE_IPADDR 2
99#define PW_TYPE_DATE 3
100
101/* standard RADIUS codes */
102
103#define PW_ACCESS_REQUEST 1
104#define PW_ACCESS_ACCEPT 2
105#define PW_ACCESS_REJECT 3
106#define PW_ACCOUNTING_REQUEST 4
107#define PW_ACCOUNTING_RESPONSE 5
108#define PW_ACCOUNTING_STATUS 6
109#define PW_PASSWORD_REQUEST 7
110#define PW_PASSWORD_ACK 8
111#define PW_PASSWORD_REJECT 9
112#define PW_ACCOUNTING_MESSAGE 10
113#define PW_ACCESS_CHALLENGE 11
114#define PW_STATUS_SERVER 12
115#define PW_STATUS_CLIENT 13
116
117
118/* standard RADIUS attribute-value pairs */
119
120#define PW_USER_NAME 1 /* string */
121#define PW_USER_PASSWORD 2 /* string */
122#define PW_CHAP_PASSWORD 3 /* string */
123#define PW_NAS_IP_ADDRESS 4 /* ipaddr */
124#define PW_NAS_PORT 5 /* integer */
125#define PW_SERVICE_TYPE 6 /* integer */
126#define PW_FRAMED_PROTOCOL 7 /* integer */
127#define PW_FRAMED_IP_ADDRESS 8 /* ipaddr */
128#define PW_FRAMED_IP_NETMASK 9 /* ipaddr */
129#define PW_FRAMED_ROUTING 10 /* integer */
130#define PW_FILTER_ID 11 /* string */
131#define PW_FRAMED_MTU 12 /* integer */
132#define PW_FRAMED_COMPRESSION 13 /* integer */
133#define PW_LOGIN_IP_HOST 14 /* ipaddr */
134#define PW_LOGIN_SERVICE 15 /* integer */
135#define PW_LOGIN_PORT 16 /* integer */
136#define PW_OLD_PASSWORD 17 /* string */ /* deprecated */
137#define PW_REPLY_MESSAGE 18 /* string */
138#define PW_LOGIN_CALLBACK_NUMBER 19 /* string */
139#define PW_FRAMED_CALLBACK_ID 20 /* string */
140#define PW_EXPIRATION 21 /* date */ /* deprecated */
141#define PW_FRAMED_ROUTE 22 /* string */
142#define PW_FRAMED_IPX_NETWORK 23 /* integer */
143#define PW_STATE 24 /* string */
144#define PW_CLASS 25 /* string */
145#define PW_VENDOR_SPECIFIC 26 /* string */
146#define PW_SESSION_TIMEOUT 27 /* integer */
147#define PW_IDLE_TIMEOUT 28 /* integer */
148#define PW_TERMINATION_ACTION 29 /* integer */
149#define PW_CALLED_STATION_ID 30 /* string */
150#define PW_CALLING_STATION_ID 31 /* string */
151#define PW_NAS_IDENTIFIER 32 /* string */
152#define PW_PROXY_STATE 33 /* string */
153#define PW_LOGIN_LAT_SERVICE 34 /* string */
154#define PW_LOGIN_LAT_NODE 35 /* string */
155#define PW_LOGIN_LAT_GROUP 36 /* string */
156#define PW_FRAMED_APPLETALK_LINK 37 /* integer */
157#define PW_FRAMED_APPLETALK_NETWORK 38 /* integer */
158#define PW_FRAMED_APPLETALK_ZONE 39 /* string */
159#define PW_CHAP_CHALLENGE 60 /* string */
160#define PW_NAS_PORT_TYPE 61 /* integer */
161#define PW_PORT_LIMIT 62 /* integer */
162#define PW_LOGIN_LAT_PORT 63 /* string */
163
164/* Vendor RADIUS attribute-value pairs */
165#define PW_MS_CHAP_CHALLENGE 11 /* string */
166#define PW_MS_CHAP_RESPONSE 1 /* string */
167#define PW_MS_CHAP2_RESPONSE 25 /* string */
168#define PW_MS_CHAP2_SUCCESS 26 /* string */
169#define PW_MS_MPPE_ENCRYPTION_POLICY 7 /* string */
170#define PW_MS_MPPE_ENCRYPTION_TYPE 8 /* string */
171#define PW_MS_MPPE_ENCRYPTION_TYPES PW_MS_MPPE_ENCRYPTION_TYPE
172#define PW_MS_CHAP_MPPE_KEYS 12 /* string */
173#define PW_MS_MPPE_SEND_KEY 16 /* string */
174#define PW_MS_MPPE_RECV_KEY 17 /* string */
175
176/* Accounting */
177
178#define PW_ACCT_STATUS_TYPE 40 /* integer */
179#define PW_ACCT_DELAY_TIME 41 /* integer */
180#define PW_ACCT_INPUT_OCTETS 42 /* integer */
181#define PW_ACCT_OUTPUT_OCTETS 43 /* integer */
182#define PW_ACCT_SESSION_ID 44 /* string */
183#define PW_ACCT_AUTHENTIC 45 /* integer */
184#define PW_ACCT_SESSION_TIME 46 /* integer */
185#define PW_ACCT_INPUT_PACKETS 47 /* integer */
186#define PW_ACCT_OUTPUT_PACKETS 48 /* integer */
187#define PW_ACCT_TERMINATE_CAUSE 49 /* integer */
188#define PW_ACCT_MULTI_SESSION_ID 50 /* string */
189#define PW_ACCT_LINK_COUNT 51 /* integer */
190
191/* From RFC 2869 */
192#define PW_ACCT_INTERIM_INTERVAL 85 /* integer */
193
194/* Merit Experimental Extensions */
195
196#define PW_USER_ID 222 /* string */
197#define PW_USER_REALM 223 /* string */
198
199
200/* Session limits */
201#define PW_SESSION_OCTETS_LIMIT 227 /* integer */
202#define PW_OCTETS_DIRECTION 228 /* integer */
203
204/* Integer Translations */
205
206/* SERVICE TYPES */
207
208#define PW_LOGIN 1
209#define PW_FRAMED 2
210#define PW_CALLBACK_LOGIN 3
211#define PW_CALLBACK_FRAMED 4
212#define PW_OUTBOUND 5
213#define PW_ADMINISTRATIVE 6
214#define PW_NAS_PROMPT 7
215#define PW_AUTHENTICATE_ONLY 8
216#define PW_CALLBACK_NAS_PROMPT 9
217
218/* FRAMED PROTOCOLS */
219
220#define PW_PPP 1
221#define PW_SLIP 2
222#define PW_ARA 3
223#define PW_GANDALF 4
224#define PW_XYLOGICS 5
225
226/* FRAMED ROUTING VALUES */
227
228#define PW_NONE 0
229#define PW_BROADCAST 1
230#define PW_LISTEN 2
231#define PW_BROADCAST_LISTEN 3
232
233/* FRAMED COMPRESSION TYPES */
234
235#define PW_VAN_JACOBSON_TCP_IP 1
236#define PW_IPX_HEADER_COMPRESSION 2
237
238/* LOGIN SERVICES */
239
240#define PW_TELNET 0
241#define PW_RLOGIN 1
242#define PW_TCP_CLEAR 2
243#define PW_PORTMASTER 3
244#define PW_LAT 4
245#define PW_X25_PAD 5
246#define PW_X25_T3POS 6
247
248/* TERMINATION ACTIONS */
249
250#define PW_DEFAULT 0
251#define PW_RADIUS_REQUEST 1
252
253/* PROHIBIT PROTOCOL */
254
255#define PW_DUMB 0 /* 1 and 2 are defined in FRAMED PROTOCOLS */
256#define PW_AUTH_ONLY 3
257#define PW_ALL 255
258
259/* ACCOUNTING STATUS TYPES */
260
261#define PW_STATUS_START 1
262#define PW_STATUS_STOP 2
263#define PW_STATUS_ALIVE 3
264#define PW_STATUS_MODEM_START 4
265#define PW_STATUS_MODEM_STOP 5
266#define PW_STATUS_CANCEL 6
267#define PW_ACCOUNTING_ON 7
268#define PW_ACCOUNTING_OFF 8
269
270/* ACCOUNTING TERMINATION CAUSES */
271
272#define PW_USER_REQUEST 1
273#define PW_LOST_CARRIER 2
274#define PW_LOST_SERVICE 3
275#define PW_ACCT_IDLE_TIMEOUT 4
276#define PW_ACCT_SESSION_TIMEOUT 5
277#define PW_ADMIN_RESET 6
278#define PW_ADMIN_REBOOT 7
279#define PW_PORT_ERROR 8
280#define PW_NAS_ERROR 9
281#define PW_NAS_REQUEST 10
282#define PW_NAS_REBOOT 11
283#define PW_PORT_UNNEEDED 12
284#define PW_PORT_PREEMPTED 13
285#define PW_PORT_SUSPENDED 14
286#define PW_SERVICE_UNAVAILABLE 15
287#define PW_CALLBACK 16
288#define PW_USER_ERROR 17
289#define PW_HOST_REQUEST 18
290
291/* NAS PORT TYPES */
292
293#define PW_ASYNC 0
294#define PW_SYNC 1
295#define PW_ISDN_SYNC 2
296#define PW_ISDN_SYNC_V120 3
297#define PW_ISDN_SYNC_V110 4
298#define PW_VIRTUAL 5
299
300/* AUTHENTIC TYPES */
301#define PW_RADIUS 1
302#define PW_LOCAL 2
303#define PW_REMOTE 3
304
305/* Session-Octets-Limit */
306#define PW_OCTETS_DIRECTION_SUM 0
307#define PW_OCTETS_DIRECTION_IN 1
308#define PW_OCTETS_DIRECTION_OUT 2
309#define PW_OCTETS_DIRECTION_MAX 3
310
311
312/* Vendor codes */
313#define VENDOR_NONE (-1)
314#define VENDOR_MICROSOFT 311
315
316/* Server data structures */
317
318typedef struct dict_attr
319{
320 char name[NAME_LENGTH + 1]; /* attribute name */
321 int value; /* attribute index */
322 int type; /* string, int, etc. */
323 int vendorcode; /* vendor code */
324 struct dict_attr *next;
325} DICT_ATTR;
326
327typedef struct dict_value
328{
329 char attrname[NAME_LENGTH +1];
330 char name[NAME_LENGTH + 1];
331 int value;
332 struct dict_value *next;
333} DICT_VALUE;
334
335typedef struct vendor_dict
336{
337 char vendorname[NAME_LENGTH + 1];
338 int vendorcode;
339 DICT_ATTR *attributes;
340 struct vendor_dict *next;
341} VENDOR_DICT;
342
343typedef struct value_pair
344{
345 char name[NAME_LENGTH + 1];
346 int attribute;
347 int vendorcode;
348 int type;
349 UINT4 lvalue;
350 u_char strvalue[AUTH_STRING_LEN + 1];
351 struct value_pair *next;
352} VALUE_PAIR;
353
354/* don't change this, as it has to be the same as in the Merit radiusd code */
355#define MGMT_POLL_SECRET "Hardlyasecret"
356
357/* Define return codes from "SendServer" utility */
358
359#define BADRESP_RC -2
360#define ERROR_RC -1
361#define OK_RC 0
362#define TIMEOUT_RC 1
363
364typedef struct send_data /* Used to pass information to sendserver() function */
365{
366 u_char code; /* RADIUS packet code */
367 u_char seq_nbr; /* Packet sequence number */
368 char *server; /* Name/addrress of RADIUS server */
369 int svc_port; /* RADIUS protocol destination port */
370 int timeout; /* Session timeout in seconds */
371 int retries;
372 VALUE_PAIR *send_pairs; /* More a/v pairs to send */
373 VALUE_PAIR *receive_pairs; /* Where to place received a/v pairs */
374} SEND_DATA;
375
376typedef struct request_info
377{
378 char secret[MAX_SECRET_LENGTH + 1];
379 u_char request_vector[AUTH_VECTOR_LEN];
380} REQUEST_INFO;
381
382#ifndef MIN
383#define MIN(a, b) ((a) < (b) ? (a) : (b))
384#endif
385#ifndef MAX
386#define MAX(a, b) ((a) > (b) ? (a) : (b))
387#endif
388
389#ifndef PATH_MAX
390#define PATH_MAX 1024
391#endif
392
393typedef struct env
394{
395 int maxsize, size;
396 char **env;
397} ENV;
398
399#define ENV_SIZE 128
400
401__BEGIN_DECLS
402
403/* Function prototypes */
404
405/* avpair.c */
406
407VALUE_PAIR *rc_avpair_add __P((VALUE_PAIR **, int, void *, int, int));
408int rc_avpair_assign __P((VALUE_PAIR *, void *, int));
409VALUE_PAIR *rc_avpair_new __P((int, void *, int, int));
410VALUE_PAIR *rc_avpair_gen __P((AUTH_HDR *));
411VALUE_PAIR *rc_avpair_get __P((VALUE_PAIR *, UINT4));
412VALUE_PAIR *rc_avpair_copy __P((VALUE_PAIR *));
413void rc_avpair_insert __P((VALUE_PAIR **, VALUE_PAIR *, VALUE_PAIR *));
414void rc_avpair_free __P((VALUE_PAIR *));
415int rc_avpair_parse __P((char *, VALUE_PAIR **));
416int rc_avpair_tostr __P((VALUE_PAIR *, char *, int, char *, int));
417VALUE_PAIR *rc_avpair_readin __P((FILE *));
418
419/* buildreq.c */
420
421void rc_buildreq __P((SEND_DATA *, int, char *, unsigned short, int, int));
422unsigned char rc_get_seqnbr __P((void));
423int rc_auth __P((UINT4, VALUE_PAIR *, VALUE_PAIR **, char *, REQUEST_INFO *));
424int rc_auth_using_server __P((SERVER *, UINT4, VALUE_PAIR *, VALUE_PAIR **,
425 char *, REQUEST_INFO *));
426int rc_auth_proxy __P((VALUE_PAIR *, VALUE_PAIR **, char *));
427int rc_acct __P((UINT4, VALUE_PAIR *));
428int rc_acct_using_server __P((SERVER *, UINT4, VALUE_PAIR *));
429int rc_acct_proxy __P((VALUE_PAIR *));
430int rc_check __P((char *, unsigned short, char *));
431
432/* clientid.c */
433
434int rc_read_mapfile __P((char *));
435UINT4 rc_map2id __P((char *));
436
437/* config.c */
438
439int rc_read_config __P((char *));
440char *rc_conf_str __P((char *));
441int rc_conf_int __P((char *));
442SERVER *rc_conf_srv __P((char *));
443int rc_find_server __P((char *, UINT4 *, char *));
444
445/* dict.c */
446
447int rc_read_dictionary __P((char *));
448DICT_ATTR *rc_dict_getattr __P((int, int));
449DICT_ATTR *rc_dict_findattr __P((char *));
450DICT_VALUE *rc_dict_findval __P((char *));
451DICT_VALUE * rc_dict_getval __P((UINT4, char *));
452VENDOR_DICT * rc_dict_findvendor __P((char *));
453VENDOR_DICT * rc_dict_getvendor __P((int));
454
455/* ip_util.c */
456
457UINT4 rc_get_ipaddr __P((char *));
458int rc_good_ipaddr __P((char *));
459const char *rc_ip_hostname __P((UINT4));
460unsigned short rc_getport __P((int));
461int rc_own_hostname __P((char *, int));
462UINT4 rc_own_ipaddress __P((void));
463
464
465/* log.c */
466
467void rc_openlog __P((char *));
468void rc_log __P((int, const char *, ...));
469
470/* sendserver.c */
471
472int rc_send_server __P((SEND_DATA *, char *, REQUEST_INFO *));
473
474/* util.c */
475
476void rc_str2tm __P((char *, struct tm *));
477char *rc_mksid __P((void));
478char *rc_getifname __P((char *));
479char *rc_getstr __P((char *, int));
480void rc_mdelay __P((int));
481char *rc_mksid __P((void));
482
483/* env.c */
484
485struct env *rc_new_env __P((int));
486void rc_free_env __P((struct env *));
487int rc_add_env __P((struct env *, char *, char *));
488int rc_import_env __P((struct env *, char **));
489
490/* md5.c */
491
492void rc_md5_calc __P((unsigned char *, unsigned char *, unsigned int));
493
494__END_DECLS
495
496#endif /* RADIUSCLIENT_H */