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
25 /* 27262 is vendor DANTE Ltd. */
26 #define DEFAULT_TTL_ATTR "27262:1"
32 #define RAD_PROTOCOUNT 4
35 char **listenargs[RAD_PROTOCOUNT];
36 char *sourcearg[RAD_PROTOCOUNT];
39 uint32_t ttlattrtype[2];
42 uint8_t loopprevention;
46 struct timeval created;
48 uint8_t *buf, *replybuf;
56 int udpsock; /* only for UDP */
57 uint16_t udpport; /* only for UDP */
60 /* requests that our client will send */
62 pthread_mutex_t *lock;
65 struct timeval expiry;
70 pthread_mutex_t mutex;
76 uint8_t type; /* RAD_UDP/RAD_TLS/RAD_TCP */
77 const struct protodefs *pdef;
84 regex_t *certuriregex;
87 char *confrewriteusername;
88 struct modattr *rewriteusername;
89 char *dynamiclookupcommand;
91 uint8_t retryinterval;
94 uint8_t certnamecheck;
96 struct rewrite *rewritein;
97 struct rewrite *rewriteout;
98 struct addrinfo *addrinfo;
100 pthread_mutex_t *lock; /* only used for updating clients so far */
102 struct list *clients;
103 struct server *servers;
107 struct clsrvconf *conf;
110 struct request *rqs[MAX_REQUESTS];
111 struct queue *replyq;
112 struct queue *rbios; /* for dtls */
113 struct sockaddr *addr;
114 time_t expiry; /* for udp */
118 struct clsrvconf *conf;
121 pthread_mutex_t lock;
123 uint8_t clientrdgone;
124 struct timeval lastconnecttry;
125 struct timeval lastreply;
126 uint8_t connectionok;
128 char *dynamiclookuparg;
130 struct timeval lastrcv;
131 struct rqout *requests;
133 pthread_mutex_t newrq_mutex;
134 pthread_cond_t newrq_cond;
135 struct queue *rbios; /* for dtls */
144 pthread_mutex_t mutex;
145 struct realm *parent;
146 struct list *subrealms;
147 struct list *srvconfs;
148 struct list *accsrvconfs;
160 uint32_t cacheexpiry;
163 X509_VERIFY_PARAM *vpm;
175 uint8_t *removeattrs;
176 uint32_t *removevendorattrs;
177 struct list *addattrs;
178 struct list *modattrs;
186 uint8_t retrycountdefault;
187 uint8_t retrycountmax;
188 uint8_t retryintervaldefault;
189 uint8_t retryintervalmax;
190 uint8_t duplicateintervaldefault;
191 void *(*listener)(void*);
192 int (*connecter)(struct server *, struct timeval *, int, char *);
193 void *(*clientconnreader)(void*);
194 int (*clientradput)(struct server *, unsigned char *);
195 void (*addclient)(struct client *);
196 void (*addserverextra)(struct clsrvconf *);
197 void (*setsrcres)(char *source);
201 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
203 #define ATTRTYPE(x) ((x)[0])
204 #define ATTRLEN(x) ((x)[1])
205 #define ATTRVAL(x) ((x) + 2)
206 #define ATTRVALLEN(x) ((x)[1] - 2)
208 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
209 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
210 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
211 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
212 void removelockedclient(struct client *client);
213 void removeclient(struct client *client);
214 struct queue *newqueue();
215 void freebios(struct queue *q);
216 struct request *newrequest();
217 void freerq(struct request *rq);
218 int radsrv(struct request *rq);
219 X509 *verifytlscert(SSL *ssl);
220 int verifyconfcert(X509 *cert, struct clsrvconf *conf);
221 void replyh(struct server *server, unsigned char *buf);
222 SSL_CTX *tlsgetctx(uint8_t type, struct tls *t);
223 struct addrinfo *resolve_hostport_addrinfo(uint8_t type, char *hostport);