4 * radiusd.h Structures, prototypes and global variables
5 * for the Cistron Radius server.
10 #include "libradius.h"
21 typedef pthread_t child_pid_t;
22 #define child_kill pthread_kill
24 typedef pid_t child_pid_t;
25 #define child_kill kill
28 #define NO_SUCH_CHILD_PID (child_pid_t) (0)
31 #define REQUEST_MAGIC (0xdeadbeef)
34 typedef struct auth_req {
36 uint32_t magic; /* for debugging only */
38 RADIUS_PACKET *packet;
41 RADIUS_PACKET *proxy_reply;
42 VALUE_PAIR *config_items;
46 child_pid_t child_pid;
48 int number; /* internal server number */
50 /* Could almost keep a const char * here instead of a _copy_ of the
51 * secret... but what if the RADCLIENT structure is freed because it was
52 * taken out of the config file and SIGHUPed? */
54 int proxy_is_replicate;
56 time_t proxy_next_try;
60 int simul_mpp; /* WEIRD: 1 is false, 2 is true */
67 * Function handler for requests.
69 typedef int (*RAD_REQUEST_FUNP)(REQUEST *);
71 typedef struct radclient {
77 struct radclient *next;
88 typedef struct realm {
101 typedef struct pair_list {
106 struct pair_list *next;
107 struct pair_list *lastdefault;
110 typedef struct main_config_t {
112 int log_auth_badpass;
113 int log_auth_goodpass;
117 char *do_nospace_user;
118 char *do_nospace_pass;
122 #define DEBUG if(debug_flag)log_debug
123 #define DEBUG2 if (debug_flag > 1)log_debug
125 #define SECONDS_PER_DAY 86400
126 #define MAX_REQUEST_TIME 30
127 #define CLEANUP_DELAY 5
128 #define MAX_REQUESTS 256
129 #define RETRY_DELAY 5
130 #define RETRY_COUNT 3
144 * This definition of true as NOT false is definitive. :) Making
145 * it '1' can cause problems on stupid platforms. See articles
146 * on C portability for more information.
148 #define TRUE (!FALSE)
151 /* for paircompare_register */
152 typedef int (*RAD_COMPARE_FUNC)(void *instance, VALUE_PAIR *, VALUE_PAIR *, VALUE_PAIR *, VALUE_PAIR **);
157 extern const char *progname;
158 extern int debug_flag;
159 extern const char *radacct_dir;
160 extern const char *radlog_dir;
161 extern const char *radlib_dir;
162 extern const char *radius_dir;
163 extern const char *radius_libdir;
164 extern uint32_t expiration_seconds;
166 extern int log_stripped_names;
167 extern uint32_t myip;
168 extern int log_auth_detail;
169 extern int auth_port;
170 extern int acct_port;
172 extern int proxy_port;
174 extern int proxy_retry_count;
175 extern int proxy_retry_delay;
176 extern int spawn_flag;
178 /* Define a global config structure */
179 extern struct main_config_t mainconfig;
182 * Function prototypes.
186 int rad_accounting(REQUEST *);
189 int rad_check_ts(uint32_t nasaddr, int port, const char *user,
190 const char *sessionid);
191 int session_zap(uint32_t nasaddr, int port, const char *user,
192 const char *sessionid, uint32_t cliaddr,
193 char proto, time_t t);
196 void debug_pair(FILE *, VALUE_PAIR *);
197 int log_err (char *);
198 void sig_cleanup(int);
199 int rad_process(REQUEST *, int);
200 int rad_respond(REQUEST *, RAD_REQUEST_FUNP fun);
203 void (*reset_signal(int signo, void (*func)(int)))(int);
204 void request_free(REQUEST **request);
205 int rad_mkdir(char *directory, int mode);
206 int rad_checkfilename(const char *filename);
207 void *rad_malloc(size_t size); /* calls exit(1) on error! */
208 void xfree(const char *ptr);
211 int read_clients_file(const char *file);
212 RADCLIENT *client_find(uint32_t ipno);
213 const char *client_name(uint32_t ipno);
214 void client_walk(void);
217 REALM *realm_find(const char *);
218 REALM *realm_findbyaddr(uint32_t ipno);
219 int pairlist_read(const char *file, PAIR_LIST **list, int complain);
220 void pairlist_free(PAIR_LIST **);
221 int read_config_files(void);
224 int read_naslist_file(char *);
225 NAS *nas_find(uint32_t ipno);
226 const char *nas_name(uint32_t ipno);
227 const char *nas_name2(RADIUS_PACKET *r);
228 NAS *nas_findbyname(char *nasname);
234 int radlog(int, const char *, ...)
236 __attribute__ ((format (printf, 2, 3)))
239 int log_debug(const char *, ...)
241 __attribute__ ((format (printf, 1, 2)))
246 int proxy_receive(REQUEST *request);
247 int proxy_send(REQUEST *request);
250 char *auth_name(char *buf, size_t buflen, REQUEST *request, int do_cli);
251 int rad_authenticate (REQUEST *);
252 VALUE_PAIR *rad_getpass(REQUEST *request);
255 int radius_exec_program(const char *, REQUEST *,
256 int, const char **user_msg);
259 int timestr_match(char *, time_t);
262 int paircompare_register(int attr, int otherattr,
263 RAD_COMPARE_FUNC func,
265 void paircompare_unregister(int attr, RAD_COMPARE_FUNC func);
266 int paircmp(VALUE_PAIR *request, VALUE_PAIR *check,
268 int simplepaircmp(VALUE_PAIR *, VALUE_PAIR *);
269 void pair_builtincompare_init(void);
272 int radius_xlat2(char * out, int outlen, const char *fmt,
275 #ifdef WITH_THREAD_POOL
277 extern int thread_pool_init(void);
278 extern int thread_pool_clean(time_t now);