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 MAX_CERT_DEPTH 5
21 #define STATUS_SERVER_PERIOD 25
22 #define IDLE_TIMEOUT 300
41 uint8_t loopprevention;
44 /* requests that our client will send */
50 struct timeval expiry;
53 uint8_t origid; /* used by servwr */
54 char origauth[16]; /* used by servwr */
55 struct sockaddr_storage fromsa; /* used by udpservwr */
56 int fromudpsock; /* used by udpservwr */
59 /* replies that a server will send */
62 struct sockaddr_storage tosa; /* used by udpservwr */
63 int toudpsock; /* used by udpservwr */
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;
91 uint8_t certnamecheck;
93 struct rewrite *rewritein;
94 struct rewrite *rewriteout;
95 struct addrinfo *addrinfo;
98 struct server *servers;
102 struct clsrvconf *conf;
103 int sock; /* for tcp/dtls */
105 struct queue *replyq;
106 struct queue *rbios; /* for dtls */
107 struct sockaddr *addr; /* for udp */
111 struct clsrvconf *conf;
114 pthread_mutex_t lock;
116 uint8_t clientrdgone;
117 struct timeval lastconnecttry;
118 struct timeval lastreply;
119 uint8_t connectionok;
121 char *dynamiclookuparg;
123 struct timeval lastrcv;
124 struct request *requests;
126 pthread_mutex_t newrq_mutex;
127 pthread_cond_t newrq_cond;
128 struct queue *rbios; /* for dtls */
136 pthread_mutex_t subrealms_mutex;
137 struct list *subrealms;
138 struct list *srvconfs;
139 struct list *accsrvconfs;
161 uint8_t *removeattrs;
162 uint32_t *removevendorattrs;
163 struct list *addattrs;
164 struct list *modattrs;
172 uint8_t retrycountdefault;
173 uint8_t retrycountmax;
174 uint8_t retryintervaldefault;
175 uint8_t retryintervalmax;
176 void *(*listener)(void*);
178 int (*connecter)(struct server *, struct timeval *, int, char *);
179 void *(*clientconnreader)(void*);
180 int (*clientradput)(struct server *, unsigned char *);
181 void (*addclient)(struct client *);
182 void (*addserverextra)(struct clsrvconf *);
186 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
188 #define ATTRTYPE(x) ((x)[0])
189 #define ATTRLEN(x) ((x)[1])
190 #define ATTRVAL(x) ((x) + 2)
191 #define ATTRVALLEN(x) ((x)[1] - 2)
193 #define SOCKADDR_SIZE(addr) ((addr).ss_family == AF_INET ? \
194 sizeof(struct sockaddr_in) : \
195 sizeof(struct sockaddr_in6))
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);
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 int radsrv(struct request *rq);
208 X509 *verifytlscert(SSL *ssl);
209 int verifyconfcert(X509 *cert, struct clsrvconf *conf);
210 void replyh(struct server *server, unsigned char *buf);
211 int connecttcp(struct addrinfo *addrinfo, struct addrinfo *src);
212 int bindtoaddr(struct addrinfo *addrinfo, int family, int reuse, int v6only);