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;
105 int sock; /* for tcp/dtls */
107 pthread_mutex_t lock; /* used for updating rqs */
108 struct request *rqs[MAX_REQUESTS];
109 struct queue *replyq;
110 struct queue *rbios; /* for dtls */
111 struct sockaddr *addr; /* for udp */
115 struct clsrvconf *conf;
118 pthread_mutex_t lock;
120 uint8_t clientrdgone;
121 struct timeval lastconnecttry;
122 struct timeval lastreply;
123 uint8_t connectionok;
125 char *dynamiclookuparg;
127 struct timeval lastrcv;
128 struct rqout *requests;
130 pthread_mutex_t newrq_mutex;
131 pthread_cond_t newrq_cond;
132 struct queue *rbios; /* for dtls */
140 pthread_mutex_t subrealms_mutex;
141 struct list *subrealms;
142 struct list *srvconfs;
143 struct list *accsrvconfs;
165 uint8_t *removeattrs;
166 uint32_t *removevendorattrs;
167 struct list *addattrs;
168 struct list *modattrs;
176 uint8_t retrycountdefault;
177 uint8_t retrycountmax;
178 uint8_t retryintervaldefault;
179 uint8_t retryintervalmax;
180 uint8_t duplicateintervaldefault;
181 void *(*listener)(void*);
183 int (*connecter)(struct server *, struct timeval *, int, char *);
184 void *(*clientconnreader)(void*);
185 int (*clientradput)(struct server *, unsigned char *);
186 void (*addclient)(struct client *);
187 void (*addserverextra)(struct clsrvconf *);
191 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
193 #define ATTRTYPE(x) ((x)[0])
194 #define ATTRLEN(x) ((x)[1])
195 #define ATTRVAL(x) ((x) + 2)
196 #define ATTRVALLEN(x) ((x)[1] - 2)
198 #define SOCKADDR_SIZE(addr) ((addr).ss_family == AF_INET ? \
199 sizeof(struct sockaddr_in) : \
200 sizeof(struct sockaddr_in6))
202 #define SOCKADDRP_SIZE(addr) ((addr)->sa_family == AF_INET ? \
203 sizeof(struct sockaddr_in) : \
204 sizeof(struct sockaddr_in6))
206 struct addrinfo *getsrcprotores(uint8_t type);
207 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
208 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
209 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
210 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
211 void removeclient(struct client *client);
212 void removeclientrqs(struct client *client);
213 struct queue *newqueue();
214 void removequeue(struct queue *q);
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 int connecttcp(struct addrinfo *addrinfo, struct addrinfo *src);
223 int bindtoaddr(struct addrinfo *addrinfo, int family, int reuse, int v6only);