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;
54 int udpsock; /* only for UDP */
55 uint16_t udpport; /* only for UDP */
58 /* requests that our client will send */
60 pthread_mutex_t *lock;
63 struct timeval expiry;
68 pthread_mutex_t mutex;
74 uint8_t type; /* RAD_UDP/RAD_TLS/RAD_TCP */
75 const struct protodefs *pdef;
82 regex_t *certuriregex;
85 char *confrewriteusername;
86 struct modattr *rewriteusername;
87 char *dynamiclookupcommand;
89 uint8_t retryinterval;
92 uint8_t certnamecheck;
93 struct rewrite *rewritein;
94 struct rewrite *rewriteout;
95 struct addrinfo *addrinfo;
97 pthread_mutex_t *lock; /* only used for updating clients so far */
100 struct server *servers;
104 struct clsrvconf *conf;
107 struct request *rqs[MAX_REQUESTS];
108 struct queue *replyq;
109 struct queue *rbios; /* for dtls */
110 struct sockaddr *addr;
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 */
139 pthread_mutex_t subrealms_mutex;
140 struct list *subrealms;
141 struct list *srvconfs;
142 struct list *accsrvconfs;
153 uint32_t cacheexpiry;
167 uint8_t *removeattrs;
168 uint32_t *removevendorattrs;
169 struct list *addattrs;
170 struct list *modattrs;
178 uint8_t retrycountdefault;
179 uint8_t retrycountmax;
180 uint8_t retryintervaldefault;
181 uint8_t retryintervalmax;
182 uint8_t duplicateintervaldefault;
183 void *(*listener)(void*);
185 int (*connecter)(struct server *, struct timeval *, int, char *);
186 void *(*clientconnreader)(void*);
187 int (*clientradput)(struct server *, unsigned char *);
188 void (*addclient)(struct client *);
189 void (*addserverextra)(struct clsrvconf *);
193 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
195 #define ATTRTYPE(x) ((x)[0])
196 #define ATTRLEN(x) ((x)[1])
197 #define ATTRVAL(x) ((x) + 2)
198 #define ATTRVALLEN(x) ((x)[1] - 2)
200 struct addrinfo *getsrcprotores(uint8_t type);
201 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
202 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
203 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
204 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
205 void removeclient(struct client *client);
206 void removeclientrqs(struct client *client);
207 struct queue *newqueue();
208 void removequeue(struct queue *q);
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 int connecttcp(struct addrinfo *addrinfo, struct addrinfo *src);
217 int bindtoaddr(struct addrinfo *addrinfo, int family, int reuse, int v6only);
218 SSL_CTX *tlsgetctx(uint8_t type, struct tls *t);