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.
15 #define CONFIG_MAIN "/etc/radsecproxy.conf"
17 /* MAX_REQUESTS must be 256 due to Radius' 8 bit ID field */
18 #define MAX_REQUESTS 256
19 #define REQUEST_RETRY_INTERVAL 5
20 #define REQUEST_RETRY_COUNT 2
21 #define DUPLICATE_INTERVAL REQUEST_RETRY_INTERVAL * REQUEST_RETRY_COUNT
22 #define MAX_CERT_DEPTH 5
23 #define STATUS_SERVER_PERIOD 25
24 #define IDLE_TIMEOUT 300
26 /* 27262 is vendor DANTE Ltd. */
27 #define DEFAULT_TTL_ATTR "27262:1"
33 #define RAD_PROTOCOUNT 4
38 uint32_t ttlattrtype[2];
41 uint8_t loopprevention;
44 struct commonprotoopts {
50 struct timeval created;
52 uint8_t *buf, *replybuf;
60 int udpsock; /* only for UDP */
61 uint16_t udpport; /* only for UDP */
64 /* requests that our client will send */
66 pthread_mutex_t *lock;
69 struct timeval expiry;
74 pthread_mutex_t mutex;
80 uint8_t type; /* RAD_UDP/RAD_TLS/RAD_TCP */
81 const struct protodefs *pdef;
88 regex_t *certuriregex;
91 char *confrewriteusername;
92 struct modattr *rewriteusername;
93 char *dynamiclookupcommand;
95 uint8_t retryinterval;
98 uint8_t certnamecheck;
100 struct rewrite *rewritein;
101 struct rewrite *rewriteout;
102 struct addrinfo *addrinfo;
104 pthread_mutex_t *lock; /* only used for updating clients so far */
106 struct list *clients;
107 struct server *servers;
110 #include "tlscommon.h"
113 struct clsrvconf *conf;
116 struct request *rqs[MAX_REQUESTS];
117 struct queue *replyq;
118 struct queue *rbios; /* for dtls */
119 struct sockaddr *addr;
120 time_t expiry; /* for udp */
124 struct clsrvconf *conf;
127 pthread_mutex_t lock;
129 uint8_t clientrdgone;
130 struct timeval lastconnecttry;
131 struct timeval lastreply;
132 uint8_t connectionok;
134 char *dynamiclookuparg;
136 struct timeval lastrcv;
137 struct rqout *requests;
139 pthread_mutex_t newrq_mutex;
140 pthread_cond_t newrq_cond;
141 struct queue *rbios; /* for dtls */
150 pthread_mutex_t mutex;
151 struct realm *parent;
152 struct list *subrealms;
153 struct list *srvconfs;
154 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 (*setprotoopts)(struct commonprotoopts *);
181 char **(*getlistenerargs)();
182 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 *);
192 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
194 #define ATTRTYPE(x) ((x)[0])
195 #define ATTRLEN(x) ((x)[1])
196 #define ATTRVAL(x) ((x) + 2)
197 #define ATTRVALLEN(x) ((x)[1] - 2)
199 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
200 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
201 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
202 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
203 void removelockedclient(struct client *client);
204 void removeclient(struct client *client);
205 struct queue *newqueue();
206 void freebios(struct queue *q);
207 struct request *newrequest();
208 void freerq(struct request *rq);
209 int radsrv(struct request *rq);
210 void replyh(struct server *server, unsigned char *buf);
211 struct addrinfo *resolve_hostport_addrinfo(uint8_t type, char *hostport);