1 /* Copyright (c) 2007-2009, UNINETT AS
2 * Copyright (c) 2010-2012, NORDUnet A/S */
3 /* See LICENSE for licensing information. */
16 #define CONFIG_MAIN SYSCONFDIR"/radsecproxy.conf"
18 /* MAX_REQUESTS must be 256 due to Radius' 8 bit ID field */
19 #define MAX_REQUESTS 256
20 #define REQUEST_RETRY_INTERVAL 5
21 #define REQUEST_RETRY_COUNT 2
22 #define DUPLICATE_INTERVAL REQUEST_RETRY_INTERVAL * REQUEST_RETRY_COUNT
23 #define MAX_CERT_DEPTH 5
24 #define STATUS_SERVER_PERIOD 25
25 #define IDLE_TIMEOUT 300
27 /* 27262 is vendor DANTE Ltd. */
28 #define DEFAULT_TTL_ATTR "27262:1"
34 #define RAD_PROTOCOUNT 4
36 enum rsp_fticks_reporting_type {
37 RSP_FTICKS_REPORTING_NONE = 0, /* Default. */
38 RSP_FTICKS_REPORTING_BASIC,
39 RSP_FTICKS_REPORTING_FULL
42 enum rsp_fticks_mac_type {
43 RSP_FTICKS_MAC_STATIC = 0,
44 RSP_FTICKS_MAC_ORIGINAL,
45 RSP_FTICKS_MAC_VENDOR_HASHED,
46 RSP_FTICKS_MAC_VENDOR_KEY_HASHED, /* Default. */
47 RSP_FTICKS_MAC_FULLY_HASHED,
48 RSP_FTICKS_MAC_FULLY_KEY_HASHED
54 char *ftickssyslogfacility;
56 uint32_t ttlattrtype[2];
59 uint8_t loopprevention;
60 enum rsp_fticks_reporting_type fticks_reporting;
61 enum rsp_fticks_mac_type fticks_mac;
67 struct commonprotoopts {
73 struct timeval created;
75 uint8_t *buf, *replybuf;
83 int udpsock; /* only for UDP */
84 uint16_t udpport; /* only for UDP */
87 /* requests that our client will send */
89 pthread_mutex_t *lock;
92 struct timeval expiry;
97 pthread_mutex_t mutex;
103 uint8_t type; /* RAD_UDP/RAD_TLS/RAD_TCP */
104 const struct protodefs *pdef;
108 struct list *hostports;
112 regex_t *certcnregex;
113 regex_t *certuriregex;
115 char *confrewriteout;
116 char *confrewriteusername;
117 struct modattr *rewriteusername;
118 char *dynamiclookupcommand;
119 uint8_t statusserver;
120 uint8_t retryinterval;
123 uint8_t certnamecheck;
125 uint8_t loopprevention;
126 struct rewrite *rewritein;
127 struct rewrite *rewriteout;
128 pthread_mutex_t *lock; /* only used for updating clients so far */
130 struct list *clients;
131 struct server *servers;
132 char *fticks_viscountry;
133 char *fticks_visinst;
136 #include "tlscommon.h"
139 struct clsrvconf *conf;
142 struct request *rqs[MAX_REQUESTS];
143 struct gqueue *replyq;
144 struct gqueue *rbios; /* for dtls */
145 struct sockaddr *addr;
146 time_t expiry; /* for udp */
150 struct clsrvconf *conf;
153 pthread_mutex_t lock;
155 uint8_t clientrdgone;
156 struct timeval lastconnecttry;
157 struct timeval lastreply;
158 uint8_t connectionok;
162 #if defined ENABLE_EXPERIMENTAL_DYNDISC
165 char *dynamiclookuparg;
167 struct timeval lastrcv;
168 struct rqout *requests;
170 pthread_mutex_t newrq_mutex;
171 pthread_cond_t newrq_cond;
172 struct gqueue *rbios; /* for dtls */
181 pthread_mutex_t mutex;
182 struct realm *parent;
183 struct list *subrealms;
184 struct list *srvconfs;
185 struct list *accsrvconfs;
195 uint8_t *removeattrs;
196 uint32_t *removevendorattrs;
197 struct list *addattrs;
198 struct list *modattrs;
206 uint8_t retrycountdefault;
207 uint8_t retrycountmax;
208 uint8_t retryintervaldefault;
209 uint8_t retryintervalmax;
210 uint8_t duplicateintervaldefault;
211 void (*setprotoopts)(struct commonprotoopts *);
212 char **(*getlistenerargs)();
213 void *(*listener)(void*);
214 int (*connecter)(struct server *, struct timeval *, int, char *);
215 void *(*clientconnreader)(void*);
216 int (*clientradput)(struct server *, unsigned char *);
217 void (*addclient)(struct client *);
218 void (*addserverextra)(struct clsrvconf *);
223 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
225 #define ATTRTYPE(x) ((x)[0])
226 #define ATTRLEN(x) ((x)[1])
227 #define ATTRVAL(x) ((x) + 2)
228 #define ATTRVALLEN(x) ((x)[1] - 2)
230 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
231 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
232 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
233 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
234 void removelockedclient(struct client *client);
235 void removeclient(struct client *client);
236 struct gqueue *newqueue();
237 void freebios(struct gqueue *q);
238 struct request *newrequest();
239 void freerq(struct request *rq);
240 int radsrv(struct request *rq);
241 void replyh(struct server *server, unsigned char *buf);
242 struct addrinfo *resolve_hostport_addrinfo(uint8_t type, char *hostport);
243 uint8_t *radattr2ascii(struct tlv *attr);
245 /* Local Variables: */
246 /* c-file-style: "stroustrup" */