2 * radiusd.h Structures, prototypes and global variables
3 * for the Cistron Radius server.
16 typedef pthread_t child_pid_t;
17 #define child_kill pthread_kill
19 typedef pid_t child_pid_t;
20 #define child_kill kill
23 #define NO_SUCH_CHILD_PID (child_pid_t) (0)
26 #define REQUEST_MAGIC (0xdeadbeef)
29 typedef struct auth_req {
31 uint32_t magic; /* for debugging only */
33 RADIUS_PACKET *packet;
36 RADIUS_PACKET *proxy_reply;
37 VALUE_PAIR *config_items;
41 child_pid_t child_pid;
44 /* Could almost keep a const char * here instead of a _copy_ of the
45 * secret... but what if the RADCLIENT structure is freed because it was
46 * taken out of the config file and SIGHUPed? */
48 int proxy_is_replicate;
50 time_t proxy_next_try;
53 struct auth_req *prev;
54 struct auth_req *next;
58 * Function handler for requests.
60 typedef int (*RAD_REQUEST_FUNP)(REQUEST *);
62 typedef struct radclient {
67 struct radclient *next;
78 typedef struct realm {
91 typedef struct pair_list {
96 struct pair_list *next;
99 #define DEBUG if(debug_flag)log_debug
100 #define DEBUG2 if (debug_flag > 1)log_debug
102 #define SECONDS_PER_DAY 86400
103 #define MAX_REQUEST_TIME 30
104 #define CLEANUP_DELAY 5
105 #define MAX_REQUESTS 256
106 /* FIXME: these two should be command-line options */
107 #define RETRY_DELAY 5
108 #define RETRY_COUNT 3
122 * This definition of true as NOT false is definitive. :) Making
123 * it '1' can cause problems on stupid platforms. See articles
124 * on C portability for more information.
126 #define TRUE (!FALSE)
129 /* for paircompare_register */
130 typedef int (*COMPARE)(VALUE_PAIR *, VALUE_PAIR *, VALUE_PAIR *, VALUE_PAIR **);
135 extern const char *progname;
136 extern int debug_flag;
137 extern const char *radacct_dir;
138 extern const char *radlog_dir;
139 extern const char *radlib_dir;
140 extern const char *radius_dir;
141 extern const char *radius_libdir;
142 extern uint32_t expiration_seconds;
143 extern pid_t radius_pid;
145 extern int log_stripped_names;
146 extern uint32_t myip;
147 extern int log_auth_detail;
149 extern int log_auth_pass;
150 extern int auth_port;
151 extern int acct_port;
152 extern int proxy_port;
156 * Function prototypes.
160 int rad_accounting(REQUEST *);
163 int radutmp_add(REQUEST *);
164 int radutmp_zap(uint32_t nas, int port, char *user, time_t t);
165 int radutmp_checksimul(char *name, VALUE_PAIR *, int maxsimul);
168 void debug_pair(FILE *, VALUE_PAIR *);
169 int log_err (char *);
170 void sig_cleanup(int);
171 int rad_respond(REQUEST *, RAD_REQUEST_FUNP fun);
174 void (*reset_signal(int signo, void (*func)(int)))(int);
175 void request_free(REQUEST *request);
176 RADIUS_PACKET * build_reply(int code, REQUEST *request,
177 VALUE_PAIR *vps, const char *user_msg);
180 RADCLIENT *client_find(uint32_t ipno);
181 char *client_name(uint32_t ipno);
182 REALM *realm_find(const char *);
183 PAIR_LIST *pairlist_read(const char *file, int complain);
184 void pairlist_free(PAIR_LIST **);
185 int read_config_files(void);
188 int read_naslist_file(char *);
189 NAS *nas_find(uint32_t ipno);
190 char *nas_name(uint32_t ipno);
191 char *nas_name2(RADIUS_PACKET *r);
192 NAS *nas_findbyname(char *nasname);
198 int log(int, const char *, ...);
199 int log_debug(const char *, ...);
203 int pam_pass(char *name, char *passwd, const char *pamauth);
204 #define PAM_DEFAULT_TYPE "radius"
208 int proxy_receive(REQUEST *request);
209 int proxy_send(REQUEST *request);
210 struct timeval *proxy_setuptimeout(struct timeval *);
211 void proxy_retry(void);
214 char *auth_name(char *buf, size_t buflen, REQUEST *request, int do_cli);
215 int rad_authenticate (REQUEST *);
218 char *radius_xlate(char *output, size_t outputlen,
220 VALUE_PAIR *req, VALUE_PAIR *reply);
221 int radius_exec_program(const char *, VALUE_PAIR *, VALUE_PAIR **,
222 int, const char **user_msg);
225 int timestr_match(char *, time_t);
228 int paircompare_register(int attr, int otherattr, COMPARE func);
229 void paircompare_unregister(int attr, COMPARE func);
230 int paircmp(VALUE_PAIR *request, VALUE_PAIR *check,
232 void pair_builtincompare_init(void);
235 int radius_xlat2(char * out, int outlen, char *str,
236 REQUEST * request, VALUE_PAIR *reply);
238 #ifdef WITH_THREAD_POOL
240 extern int thread_pool_init(void);
241 extern int thread_pool_clean(void);