4
4
* radiusd.h Structures, prototypes and global variables
5
5
* for the FreeRADIUS server.
7
* Version: $Id: radiusd.h,v 1.263 2008/04/30 10:00:53 aland Exp $
9
9
* This program is free software; you can redistribute it and/or modify
10
10
* it under the terms of the GNU General Public License as published by
27
27
#include <freeradius-devel/ident.h>
28
RCSIDH(radiusd_h, "$Id: radiusd.h,v 1.263 2008/04/30 10:00:53 aland Exp $")
28
RCSIDH(radiusd_h, "$Id$")
30
30
#include <freeradius-devel/libradius.h>
31
31
#include <freeradius-devel/radpaths.h>
36
36
typedef struct auth_req REQUEST;
38
#include <freeradius-devel/realms.h>
40
38
#ifdef HAVE_PTHREAD_H
41
39
#include <pthread.h>
42
typedef pthread_t child_pid_t;
43
#define child_kill pthread_kill
45
typedef pid_t child_pid_t;
46
#define child_kill kill
49
#define NO_SUCH_CHILD_PID (child_pid_t) (0)
52
43
#define REQUEST_MAGIC (0xdeadbeef)
47
* New defines for minimizing the size of the server, to strip
48
* out functionality. In order to ensure that people don't have
49
* to re-run "configure", after "cvs update", we play some
50
* special games with the defines. i.e. any top-level "configure"
51
* option should set both WITH_FOO and WITHOUT_FOO. After a few
52
* weeks, the WITHOUT_FOO can be deleted from the configure script.
55
#define WITH_PROXY (1)
58
#ifndef WITHOUT_DETAIL
59
#define WITH_DETAIL (1)
62
#ifndef WITHOUT_SESSION_MGMT
63
#define WITH_SESSION_MGMT (1)
66
#ifndef WITHOUT_UNLANG
67
#define WITH_UNLANG (1)
70
#ifndef WITHOUT_ACCOUNTING
71
#define WITH_ACCOUNTING (1)
73
#ifdef WITH_SESSION_MGMT
74
#error WITH_SESSION_MGMT is defined, but WITH_ACCOUNTING is not. Session management requires accounting.
77
#error WITH_DETAIL is defined, but WITH_ACCOUNTING is not. Detail file reading requires accounting.
81
#ifndef WITHOUT_DYNAMIC_CLIENTS
82
#define WITH_DYNAMIC_CLIENTS (1)
89
#ifndef WITHOUT_COMMAND_SOCKET
91
#define WITH_COMMAND_SOCKET (1)
98
#error WITH_COA requires WITH_PROXY
102
#include <freeradius-devel/stats.h>
103
#include <freeradius-devel/realms.h>
58
109
typedef struct request_data_t request_data_t;
60
typedef struct rad_snmp_client_entry_t rad_snmp_client_entry_t;
62
111
typedef struct radclient {
63
112
fr_ipaddr_t ipaddr;
73
122
int number; /* internal use only */
74
123
const CONF_SECTION *cs;
76
rad_snmp_client_entry_t *auth, *acct;
126
#ifdef WITH_ACCOUNTING
131
#ifdef WITH_DYNAMIC_CLIENTS
133
int dynamic; /* was dynamically defined */
135
time_t last_new_client;
141
home_server *coa_server;
142
home_pool_t *coa_pool;
99
180
* For listening on multiple IP's and ports.
101
182
typedef struct rad_listen_t rad_listen_t;
183
typedef void (*radlog_func_t)(int, int, REQUEST *, const char *, ...);
103
185
#define REQUEST_DATA_REGEX (0xadbeef00)
104
186
#define REQUEST_MAX_REGEX (8)
120
206
request_data_t *data;
121
207
RADCLIENT *client;
122
child_pid_t child_pid;
208
#ifdef HAVE_PTHREAD_H
123
211
time_t timestamp;
124
212
int number; /* internal server number */
126
214
rad_listen_t *listener;
127
216
rad_listen_t *proxy_listener;
220
int simul_max; /* see modcall.c && xlat.c */
221
#ifdef WITH_SESSION_MGMT
131
223
int simul_mpp; /* WEIRD: 1 is false, 2 is true */
133
226
int options; /* miscellanous options */
134
227
const char *module; /* for debugging unresponsive children */
157
251
int num_proxied_requests;
158
252
int num_proxied_responses;
160
255
const char *server;
257
radlog_func_t radlog; /* logging function, if set */
260
int num_coa_requests;
162
262
}; /* REQUEST typedef */
164
264
#define RAD_REQUEST_OPTION_NONE (0)
265
#define RAD_REQUEST_OPTION_DEBUG (1)
266
#define RAD_REQUEST_OPTION_DEBUG2 (2)
267
#define RAD_REQUEST_OPTION_DEBUG3 (3)
268
#define RAD_REQUEST_OPTION_DEBUG4 (4)
166
270
#define REQUEST_ACTIVE (1)
167
271
#define REQUEST_STOP_PROCESSING (2)
215
320
rad_listen_print_t print;
329
#define RAD_LISTEN_STATUS_INIT (0)
330
#define RAD_LISTEN_STATUS_KNOWN (1)
331
#define RAD_LISTEN_STATUS_CLOSED (2)
332
#define RAD_LISTEN_STATUS_FINISH (3)
221
334
typedef enum radlog_dest_t {
222
335
RADLOG_STDOUT = 0,
255
368
radlog_dest_t radlog_dest;
256
369
CONF_SECTION *config;
257
370
const char *name;
371
const char *auth_badpass_msg;
372
const char *auth_goodpass_msg;
261
375
#define DEBUG if(debug_flag)log_debug
262
376
#define DEBUG2 if (debug_flag > 1)log_debug
263
377
#define DEBUG3 if (debug_flag > 2)log_debug
378
#define DEBUG4 if (debug_flag > 3)log_debug
381
#define RDEBUG(fmt, ...) if(request && request->radlog) request->radlog(L_DBG, 1, request, fmt, ## __VA_ARGS__)
382
#define RDEBUG2(fmt, ...) if(request && request->radlog) request->radlog(L_DBG, 2, request, fmt, ## __VA_ARGS__)
383
#define RDEBUG3(fmt, ...) if(request && request->radlog) request->radlog(L_DBG, 3, request, fmt, ## __VA_ARGS__)
384
#define RDEBUG4(fmt, ...) if(request && request->radlog) request->radlog(L_DBG, 4, request, fmt, ## __VA_ARGS__)
387
#define RDEBUG2 DEBUG2
388
#define RDEBUG3 DEBUG3
389
#define RDEBUG4 DEBUG4
265
392
#define SECONDS_PER_DAY 86400
266
393
#define MAX_REQUEST_TIME 30
363
490
void *rad_malloc(size_t size); /* calls exit(1) on error! */
364
491
REQUEST *request_alloc(void);
365
492
REQUEST *request_alloc_fake(REQUEST *oldreq);
493
REQUEST *request_alloc_coa(REQUEST *request);
366
494
int request_data_add(REQUEST *request,
367
495
void *unique_ptr, int unique_int,
368
496
void *opaque, void (*free_opaque)(void *));
379
507
RADCLIENT_LIST *clients_parse_section(CONF_SECTION *section);
380
508
void client_free(RADCLIENT *client);
381
509
int client_add(RADCLIENT_LIST *clients, RADCLIENT *client);
510
#ifdef WITH_DYNAMIC_CLIENTS
511
void client_delete(RADCLIENT_LIST *clients, RADCLIENT *client);
512
RADCLIENT *client_create(RADCLIENT_LIST *clients, REQUEST *request);
382
514
RADCLIENT *client_find(const RADCLIENT_LIST *clients,
383
515
const fr_ipaddr_t *ipaddr);
384
516
RADCLIENT *client_findbynumber(const RADCLIENT_LIST *clients,
386
518
RADCLIENT *client_find_old(const fr_ipaddr_t *ipaddr);
519
int client_validate(RADCLIENT_LIST *clients, RADCLIENT *master,
521
RADCLIENT *client_read(const char *filename, int in_server, int flag);
389
525
int pairlist_read(const char *file, PAIR_LIST **list, int complain);
407
543
void vp_listdebug(VALUE_PAIR *vp);
544
void radlog_request(int lvl, int priority, REQUEST *request, const char *msg, ...)
546
__attribute__ ((format (printf, 4, 5)))
410
551
char *auth_name(char *buf, size_t buflen, REQUEST *request, int do_cli);
433
574
int radius_callback_compare(REQUEST *req, VALUE_PAIR *request,
434
575
VALUE_PAIR *check, VALUE_PAIR *check_pairs,
435
576
VALUE_PAIR **reply_pairs);
577
int radius_find_compare(int attribute);
436
578
VALUE_PAIR *radius_paircreate(REQUEST *request, VALUE_PAIR **vps,
437
579
int attribute, int type);
438
580
VALUE_PAIR *radius_pairmake(REQUEST *request, VALUE_PAIR **vps,
451
593
void xlat_free(void);
454
extern int thread_pool_init(CONF_SECTION *cs, int spawn_flag);
596
extern int thread_pool_init(CONF_SECTION *cs, int *spawn_flag);
455
597
extern int thread_pool_addrequest(REQUEST *, RAD_REQUEST_FUNP);
456
598
extern pid_t rad_fork(void);
457
599
extern pid_t rad_waitpid(pid_t pid, int *status);
458
600
extern int total_active_threads(void);
459
601
extern void thread_pool_lock(void);
460
602
extern void thread_pool_unlock(void);
603
extern void thread_pool_queue_stats(int *array);
462
605
#ifndef HAVE_PTHREAD_H
463
606
#define rad_fork(n) fork()
471
614
int read_mainconfig(int reload);
472
615
int free_mainconfig(void);
616
void hup_mainconfig(void);
617
void fr_suid_down(void);
618
void fr_suid_up(void);
619
void fr_suid_down_permanent(void);
475
622
void listen_free(rad_listen_t **head);
476
623
int listen_init(CONF_SECTION *cs, rad_listen_t **head);
477
rad_listen_t *proxy_new_listener(void);
624
rad_listen_t *proxy_new_listener(fr_ipaddr_t *ipaddr, int exists);
478
625
RADCLIENT *client_listener_find(const rad_listen_t *listener,
479
const fr_ipaddr_t *ipaddr);
626
const fr_ipaddr_t *ipaddr, int src_port);
628
RADCLIENT_LIST *listener_find_client_list(const fr_ipaddr_t *ipaddr,
630
rad_listen_t *listener_find_byipaddr(const fr_ipaddr_t *ipaddr, int port);
482
634
int radius_event_init(CONF_SECTION *cs, int spawn_flag);
487
639
RADIUS_PACKET *packet, REQUEST **prequest,
488
640
RADCLIENT *client);
489
641
REQUEST *received_proxy_response(RADIUS_PACKET *packet);
642
void event_new_fd(rad_listen_t *listener);
492
645
int radius_evaluate_condition(REQUEST *request, int modreturn, int depth,