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;
94 struct rewrite *rewritein;
95 struct rewrite *rewriteout;
96 struct addrinfo *addrinfo;
98 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;
164 uint8_t *removeattrs;
165 uint32_t *removevendorattrs;
166 struct list *addattrs;
167 struct list *modattrs;
175 uint8_t retrycountdefault;
176 uint8_t retrycountmax;
177 uint8_t retryintervaldefault;
178 uint8_t retryintervalmax;
179 uint8_t duplicateintervaldefault;
180 void *(*listener)(void*);
182 int (*connecter)(struct server *, struct timeval *, int, char *);
183 void *(*clientconnreader)(void*);
184 int (*clientradput)(struct server *, unsigned char *);
185 void (*addclient)(struct client *);
186 void (*addserverextra)(struct clsrvconf *);
190 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
192 #define ATTRTYPE(x) ((x)[0])
193 #define ATTRLEN(x) ((x)[1])
194 #define ATTRVAL(x) ((x) + 2)
195 #define ATTRVALLEN(x) ((x)[1] - 2)
197 struct addrinfo *getsrcprotores(uint8_t type);
198 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
199 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
200 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
201 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
202 void removeclient(struct client *client);
203 void removeclientrqs(struct client *client);
204 struct queue *newqueue();
205 void removequeue(struct queue *q);
206 void freebios(struct queue *q);
207 struct request *newrequest();
208 void freerq(struct request *rq);
209 int radsrv(struct request *rq);
210 X509 *verifytlscert(SSL *ssl);
211 int verifyconfcert(X509 *cert, struct clsrvconf *conf);
212 void replyh(struct server *server, unsigned char *buf);
213 int connecttcp(struct addrinfo *addrinfo, struct addrinfo *src);
214 int bindtoaddr(struct addrinfo *addrinfo, int family, int reuse, int v6only);