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
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;
95 struct rewrite *rewritein;
96 struct rewrite *rewriteout;
97 struct addrinfo *addrinfo;
99 pthread_mutex_t *lock; /* only used for updating clients so far */
101 struct list *clients;
102 struct server *servers;
106 struct clsrvconf *conf;
109 struct request *rqs[MAX_REQUESTS];
110 struct queue *replyq;
111 struct queue *rbios; /* for dtls */
112 struct sockaddr *addr;
116 struct clsrvconf *conf;
119 pthread_mutex_t lock;
121 uint8_t clientrdgone;
122 struct timeval lastconnecttry;
123 struct timeval lastreply;
124 uint8_t connectionok;
126 char *dynamiclookuparg;
128 struct timeval lastrcv;
129 struct rqout *requests;
131 pthread_mutex_t newrq_mutex;
132 pthread_cond_t newrq_cond;
133 struct queue *rbios; /* for dtls */
141 pthread_mutex_t subrealms_mutex;
142 struct list *subrealms;
143 struct list *srvconfs;
144 struct list *accsrvconfs;
155 uint32_t cacheexpiry;
169 uint8_t *removeattrs;
170 uint32_t *removevendorattrs;
171 struct list *addattrs;
172 struct list *modattrs;
180 uint8_t retrycountdefault;
181 uint8_t retrycountmax;
182 uint8_t retryintervaldefault;
183 uint8_t retryintervalmax;
184 uint8_t duplicateintervaldefault;
185 void *(*listener)(void*);
187 int (*connecter)(struct server *, struct timeval *, int, char *);
188 void *(*clientconnreader)(void*);
189 int (*clientradput)(struct server *, unsigned char *);
190 void (*addclient)(struct client *);
191 void (*addserverextra)(struct clsrvconf *);
195 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
197 #define ATTRTYPE(x) ((x)[0])
198 #define ATTRLEN(x) ((x)[1])
199 #define ATTRVAL(x) ((x) + 2)
200 #define ATTRVALLEN(x) ((x)[1] - 2)
202 struct addrinfo *getsrcprotores(uint8_t type);
203 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
204 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
205 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
206 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
207 void removeclient(struct client *client);
208 struct queue *newqueue();
209 void freebios(struct queue *q);
210 struct request *newrequest();
211 void freerq(struct request *rq);
212 int radsrv(struct request *rq);
213 X509 *verifytlscert(SSL *ssl);
214 int verifyconfcert(X509 *cert, struct clsrvconf *conf);
215 void replyh(struct server *server, unsigned char *buf);
216 SSL_CTX *tlsgetctx(uint8_t type, struct tls *t);