2 * Copyright (C) 2006-2008 Stig Venaas <venaas@uninett.no>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
14 #define CONFIG_MAIN "/etc/radsecproxy.conf"
16 /* MAX_REQUESTS must be 256 due to Radius' 8 bit ID field */
17 #define MAX_REQUESTS 256
18 #define REQUEST_RETRY_INTERVAL 5
19 #define REQUEST_RETRY_COUNT 2
20 #define DUPLICATE_INTERVAL REQUEST_RETRY_INTERVAL * REQUEST_RETRY_COUNT
21 #define MAX_CERT_DEPTH 5
22 #define STATUS_SERVER_PERIOD 25
23 #define IDLE_TIMEOUT 300
29 #define RAD_PROTOCOUNT 4
32 char **listenargs[RAD_PROTOCOUNT];
39 uint8_t loopprevention;
43 struct timeval created;
45 uint8_t *buf, *replybuf;
53 int udpsock; /* only for UDP */
54 uint16_t udpport; /* only for UDP */
57 /* requests that our client will send */
59 pthread_mutex_t *lock;
62 struct timeval expiry;
67 pthread_mutex_t mutex;
73 uint8_t type; /* RAD_UDP/RAD_TLS/RAD_TCP */
74 const struct protodefs *pdef;
81 regex_t *certuriregex;
84 char *confrewriteusername;
85 struct modattr *rewriteusername;
86 char *dynamiclookupcommand;
88 uint8_t retryinterval;
91 uint8_t certnamecheck;
92 struct rewrite *rewritein;
93 struct rewrite *rewriteout;
94 struct addrinfo *addrinfo;
96 pthread_mutex_t *lock; /* only used for updating clients so far */
99 struct server *servers;
103 struct clsrvconf *conf;
106 struct request *rqs[MAX_REQUESTS];
107 struct queue *replyq;
108 struct queue *rbios; /* for dtls */
109 struct sockaddr *addr;
110 time_t expiry; /* for udp */
114 struct clsrvconf *conf;
117 pthread_mutex_t lock;
119 uint8_t clientrdgone;
120 struct timeval lastconnecttry;
121 struct timeval lastreply;
122 uint8_t connectionok;
124 char *dynamiclookuparg;
126 struct timeval lastrcv;
127 struct rqout *requests;
129 pthread_mutex_t newrq_mutex;
130 pthread_cond_t newrq_cond;
131 struct queue *rbios; /* for dtls */
140 pthread_mutex_t mutex;
141 struct realm *parent;
142 struct list *subrealms;
143 struct list *srvconfs;
144 struct list *accsrvconfs;
156 uint32_t cacheexpiry;
159 X509_VERIFY_PARAM *vpm;
171 uint8_t *removeattrs;
172 uint32_t *removevendorattrs;
173 struct list *addattrs;
174 struct list *modattrs;
182 uint8_t retrycountdefault;
183 uint8_t retrycountmax;
184 uint8_t retryintervaldefault;
185 uint8_t retryintervalmax;
186 uint8_t duplicateintervaldefault;
187 void *(*listener)(void*);
189 int (*connecter)(struct server *, struct timeval *, int, char *);
190 void *(*clientconnreader)(void*);
191 int (*clientradput)(struct server *, unsigned char *);
192 void (*addclient)(struct client *);
193 void (*addserverextra)(struct clsrvconf *);
194 uint8_t freesrcprotores;
198 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
200 #define ATTRTYPE(x) ((x)[0])
201 #define ATTRLEN(x) ((x)[1])
202 #define ATTRVAL(x) ((x) + 2)
203 #define ATTRVALLEN(x) ((x)[1] - 2)
205 struct addrinfo *getsrcprotores(uint8_t type);
206 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
207 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
208 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
209 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
210 void removelockedclient(struct client *client);
211 void removeclient(struct client *client);
212 struct queue *newqueue();
213 void freebios(struct queue *q);
214 struct request *newrequest();
215 void freerq(struct request *rq);
216 int radsrv(struct request *rq);
217 X509 *verifytlscert(SSL *ssl);
218 int verifyconfcert(X509 *cert, struct clsrvconf *conf);
219 void replyh(struct server *server, unsigned char *buf);
220 SSL_CTX *tlsgetctx(uint8_t type, struct tls *t);