2 * radiusd.h Structures, prototypes and global variables
3 * for the Cistron Radius server.
11 #include "libradius.h"
22 typedef pthread_t child_pid_t;
23 #define child_kill pthread_kill
25 typedef pid_t child_pid_t;
26 #define child_kill kill
29 #define NO_SUCH_CHILD_PID (child_pid_t) (0)
32 #define REQUEST_MAGIC (0xdeadbeef)
35 typedef struct auth_req {
37 uint32_t magic; /* for debugging only */
39 RADIUS_PACKET *packet;
42 RADIUS_PACKET *proxy_reply;
43 VALUE_PAIR *config_items;
47 child_pid_t child_pid;
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 */
63 struct auth_req *prev;
64 struct auth_req *next;
68 * Function handler for requests.
70 typedef int (*RAD_REQUEST_FUNP)(REQUEST *);
72 typedef struct radclient {
77 struct radclient *next;
88 typedef struct realm {
101 typedef struct pair_list {
106 struct pair_list *next;
109 #define DEBUG if(debug_flag)log_debug
110 #define DEBUG2 if (debug_flag > 1)log_debug
112 #define SECONDS_PER_DAY 86400
113 #define MAX_REQUEST_TIME 30
114 #define CLEANUP_DELAY 5
115 #define MAX_REQUESTS 256
116 /* FIXME: these two should be command-line options */
117 #define RETRY_DELAY 5
118 #define RETRY_COUNT 3
132 * This definition of true as NOT false is definitive. :) Making
133 * it '1' can cause problems on stupid platforms. See articles
134 * on C portability for more information.
136 #define TRUE (!FALSE)
139 /* for paircompare_register */
140 typedef int (*COMPARE)(VALUE_PAIR *, VALUE_PAIR *, VALUE_PAIR *, VALUE_PAIR **);
145 extern const char *progname;
146 extern int debug_flag;
147 extern char *radacct_dir;
148 extern char *radlog_dir;
149 extern const char *radlib_dir;
150 extern char *radius_dir;
151 extern const char *radius_libdir;
152 extern uint32_t expiration_seconds;
154 extern int log_stripped_names;
155 extern uint32_t myip;
156 extern int log_auth_detail;
158 extern int log_auth_pass;
159 extern int auth_port;
160 extern int acct_port;
161 extern int proxy_port;
163 extern int proxy_retry_count;
164 extern int proxy_retry_delay;
167 * Function prototypes.
171 int rad_accounting(REQUEST *);
174 int radutmp_add(REQUEST *);
175 int radutmp_zap(uint32_t nas, int port, char *user, time_t t);
176 int radutmp_checksimul(char *name, VALUE_PAIR *, int maxsimul);
179 int rad_check_ts(uint32_t nasaddr, int port, const char *user,
180 const char *sessionid);
181 int session_zap(uint32_t nasaddr, int port, const char *user,
182 const char *sessionid, uint32_t cliaddr,
183 char proto, time_t t);
186 void debug_pair(FILE *, VALUE_PAIR *);
187 int log_err (char *);
188 void sig_cleanup(int);
189 int rad_respond(REQUEST *, RAD_REQUEST_FUNP fun);
192 void (*reset_signal(int signo, void (*func)(int)))(int);
193 void request_free(REQUEST *request);
194 RADIUS_PACKET * build_reply(int code, REQUEST *request,
195 VALUE_PAIR *vps, const char *user_msg);
198 RADCLIENT *client_find(uint32_t ipno);
199 char *client_name(uint32_t ipno);
200 REALM *realm_find(const char *);
201 REALM *realm_findbyaddr(uint32_t ipno);
202 int pairlist_read(const char *file, PAIR_LIST **list, int complain);
203 void pairlist_free(PAIR_LIST **);
204 int read_config_files(void);
207 int read_naslist_file(char *);
208 NAS *nas_find(uint32_t ipno);
209 char *nas_name(uint32_t ipno);
210 char *nas_name2(RADIUS_PACKET *r);
211 NAS *nas_findbyname(char *nasname);
217 int radlog(int, const char *, ...)
219 __attribute__ ((format (printf, 2, 3)))
222 int log_debug(const char *, ...)
224 __attribute__ ((format (printf, 1, 2)))
230 int pam_pass(char *name, char *passwd, const char *pamauth);
231 #define PAM_DEFAULT_TYPE "radius"
235 int proxy_receive(REQUEST *request);
236 int proxy_send(REQUEST *request);
239 char *auth_name(char *buf, size_t buflen, REQUEST *request, int do_cli);
240 int rad_authenticate (REQUEST *);
243 char *radius_xlate(char *output, size_t outputlen,
245 VALUE_PAIR *req, VALUE_PAIR *reply);
246 int radius_exec_program(const char *, VALUE_PAIR *, VALUE_PAIR **,
247 int, const char **user_msg);
250 int timestr_match(char *, time_t);
253 int paircompare_register(int attr, int otherattr, COMPARE func);
254 void paircompare_unregister(int attr, COMPARE func);
255 int paircmp(VALUE_PAIR *request, VALUE_PAIR *check,
257 void pair_builtincompare_init(void);
260 int radius_xlat2(char * out, int outlen, char *str,
261 REQUEST * request, VALUE_PAIR *reply);
263 #ifdef WITH_THREAD_POOL
265 extern int thread_pool_init(void);
266 extern int thread_pool_clean(void);