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;
51 struct sockaddr_storage fromsa; /* used by udpservwr */
52 int fromudpsock; /* used by udpservwr */
54 char origauth[16]; /* used by servwr */
55 uint8_t origid; /* used by servwr */
58 /* requests that our client will send */
60 pthread_mutex_t *lock;
63 struct timeval expiry;
66 /* replies that a server will send */
69 struct sockaddr_storage tosa; /* used by udpservwr */
70 int toudpsock; /* used by udpservwr */
75 pthread_mutex_t mutex;
81 uint8_t type; /* RAD_UDP/RAD_TLS/RAD_TCP */
82 const struct protodefs *pdef;
89 regex_t *certuriregex;
92 char *confrewriteusername;
93 struct modattr *rewriteusername;
94 char *dynamiclookupcommand;
96 uint8_t retryinterval;
99 uint8_t certnamecheck;
101 struct rewrite *rewritein;
102 struct rewrite *rewriteout;
103 struct addrinfo *addrinfo;
105 pthread_mutex_t *lock; /* only used for updating clients so far */
106 struct list *clients;
107 struct server *servers;
111 struct clsrvconf *conf;
112 int sock; /* for tcp/dtls */
114 pthread_mutex_t lock; /* used for updating rqs */
115 struct request *rqs[MAX_REQUESTS];
116 struct queue *replyq;
117 struct queue *rbios; /* for dtls */
118 struct sockaddr *addr; /* for udp */
122 struct clsrvconf *conf;
125 pthread_mutex_t lock;
127 uint8_t clientrdgone;
128 struct timeval lastconnecttry;
129 struct timeval lastreply;
130 uint8_t connectionok;
132 char *dynamiclookuparg;
134 struct timeval lastrcv;
135 struct rqout *requests;
137 pthread_mutex_t newrq_mutex;
138 pthread_cond_t newrq_cond;
139 struct queue *rbios; /* for dtls */
147 pthread_mutex_t subrealms_mutex;
148 struct list *subrealms;
149 struct list *srvconfs;
150 struct list *accsrvconfs;
172 uint8_t *removeattrs;
173 uint32_t *removevendorattrs;
174 struct list *addattrs;
175 struct list *modattrs;
183 uint8_t retrycountdefault;
184 uint8_t retrycountmax;
185 uint8_t retryintervaldefault;
186 uint8_t retryintervalmax;
187 uint8_t duplicateintervaldefault;
188 void *(*listener)(void*);
190 int (*connecter)(struct server *, struct timeval *, int, char *);
191 void *(*clientconnreader)(void*);
192 int (*clientradput)(struct server *, unsigned char *);
193 void (*addclient)(struct client *);
194 void (*addserverextra)(struct clsrvconf *);
198 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
200 #define ATTRTYPE(x) ((x)[0])
201 #define ATTRLEN(x) ((x)[1])
202 #define ATTRVAL(x) ((x) + 2)
203 #define ATTRVALLEN(x) ((x)[1] - 2)
205 #define SOCKADDR_SIZE(addr) ((addr).ss_family == AF_INET ? \
206 sizeof(struct sockaddr_in) : \
207 sizeof(struct sockaddr_in6))
209 struct addrinfo *getsrcprotores(uint8_t type);
210 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
211 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
212 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
213 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
214 void removeclient(struct client *client);
215 void removeclientrqs(struct client *client);
216 struct queue *newqueue();
217 void removequeue(struct queue *q);
218 void freebios(struct queue *q);
219 struct request *newrequest();
220 void freerq(struct request *rq);
221 int radsrv(struct request *rq);
222 X509 *verifytlscert(SSL *ssl);
223 int verifyconfcert(X509 *cert, struct clsrvconf *conf);
224 void replyh(struct server *server, unsigned char *buf);
225 int connecttcp(struct addrinfo *addrinfo, struct addrinfo *src);
226 int bindtoaddr(struct addrinfo *addrinfo, int family, int reuse, int v6only);