2 * Copyright (C) 2006-2009 Stig Venaas <venaas@uninett.no>
3 * Copyright (C) 2010,2011,2012 NORDUnet A/S
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
21 #define CONFIG_MAIN SYSCONFDIR"/radsecproxy.conf"
23 /* MAX_REQUESTS must be 256 due to Radius' 8 bit ID field */
24 #define MAX_REQUESTS 256
25 #define REQUEST_RETRY_INTERVAL 5
26 #define REQUEST_RETRY_COUNT 2
27 #define DUPLICATE_INTERVAL REQUEST_RETRY_INTERVAL * REQUEST_RETRY_COUNT
28 #define MAX_CERT_DEPTH 5
29 #define STATUS_SERVER_PERIOD 25
30 #define IDLE_TIMEOUT 300
32 /* 27262 is vendor DANTE Ltd. */
33 #define DEFAULT_TTL_ATTR "27262:1"
39 #define RAD_PROTOCOUNT 4
41 enum rsp_fticks_reporting_type {
42 RSP_FTICKS_REPORTING_NONE = 0, /* Default. */
43 RSP_FTICKS_REPORTING_BASIC,
44 RSP_FTICKS_REPORTING_FULL
47 enum rsp_fticks_mac_type {
48 RSP_FTICKS_MAC_STATIC = 0,
49 RSP_FTICKS_MAC_ORIGINAL,
50 RSP_FTICKS_MAC_VENDOR_HASHED,
51 RSP_FTICKS_MAC_VENDOR_KEY_HASHED, /* Default. */
52 RSP_FTICKS_MAC_FULLY_HASHED,
53 RSP_FTICKS_MAC_FULLY_KEY_HASHED
59 char *ftickssyslogfacility;
61 uint32_t ttlattrtype[2];
64 uint8_t loopprevention;
65 enum rsp_fticks_reporting_type fticks_reporting;
66 enum rsp_fticks_mac_type fticks_mac;
72 struct commonprotoopts {
78 struct timeval created;
80 uint8_t *buf, *replybuf;
88 int udpsock; /* only for UDP */
89 uint16_t udpport; /* only for UDP */
92 /* requests that our client will send */
94 pthread_mutex_t *lock;
97 struct timeval expiry;
101 struct list *entries;
102 pthread_mutex_t mutex;
108 uint8_t type; /* RAD_UDP/RAD_TLS/RAD_TCP */
109 const struct protodefs *pdef;
113 struct list *hostports;
117 regex_t *certcnregex;
118 regex_t *certuriregex;
120 char *confrewriteout;
121 char *confrewriteusername;
122 struct modattr *rewriteusername;
123 char *dynamiclookupcommand;
124 uint8_t statusserver;
125 uint8_t retryinterval;
128 uint8_t certnamecheck;
130 uint8_t loopprevention;
131 struct rewrite *rewritein;
132 struct rewrite *rewriteout;
133 pthread_mutex_t *lock; /* only used for updating clients so far */
135 struct list *clients;
136 struct server *servers;
137 char *fticks_viscountry;
138 char *fticks_visinst;
141 #include "tlscommon.h"
144 struct clsrvconf *conf;
147 struct request *rqs[MAX_REQUESTS];
148 struct gqueue *replyq;
149 struct gqueue *rbios; /* for dtls */
150 struct sockaddr *addr;
151 time_t expiry; /* for udp */
155 struct clsrvconf *conf;
158 pthread_mutex_t lock;
160 uint8_t clientrdgone;
161 struct timeval lastconnecttry;
162 struct timeval lastreply;
163 uint8_t connectionok;
167 #if defined ENABLE_EXPERIMENTAL_DYNDISC
170 char *dynamiclookuparg;
172 struct timeval lastrcv;
173 struct rqout *requests;
175 pthread_mutex_t newrq_mutex;
176 pthread_cond_t newrq_cond;
177 struct gqueue *rbios; /* for dtls */
186 pthread_mutex_t mutex;
187 struct realm *parent;
188 struct list *subrealms;
189 struct list *srvconfs;
190 struct list *accsrvconfs;
200 uint8_t *removeattrs;
201 uint32_t *removevendorattrs;
202 struct list *addattrs;
203 struct list *modattrs;
211 uint8_t retrycountdefault;
212 uint8_t retrycountmax;
213 uint8_t retryintervaldefault;
214 uint8_t retryintervalmax;
215 uint8_t duplicateintervaldefault;
216 void (*setprotoopts)(struct commonprotoopts *);
217 char **(*getlistenerargs)();
218 void *(*listener)(void*);
219 int (*connecter)(struct server *, struct timeval *, int, char *);
220 void *(*clientconnreader)(void*);
221 int (*clientradput)(struct server *, unsigned char *);
222 void (*addclient)(struct client *);
223 void (*addserverextra)(struct clsrvconf *);
228 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
230 #define ATTRTYPE(x) ((x)[0])
231 #define ATTRLEN(x) ((x)[1])
232 #define ATTRVAL(x) ((x) + 2)
233 #define ATTRVALLEN(x) ((x)[1] - 2)
235 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
236 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
237 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
238 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
239 void removelockedclient(struct client *client);
240 void removeclient(struct client *client);
241 struct gqueue *newqueue();
242 void freebios(struct gqueue *q);
243 struct request *newrequest();
244 void freerq(struct request *rq);
245 int radsrv(struct request *rq);
246 void replyh(struct server *server, unsigned char *buf);
247 struct addrinfo *resolve_hostport_addrinfo(uint8_t type, char *hostport);
248 uint8_t *radattr2ascii(struct tlv *attr);
250 /* Local Variables: */
251 /* c-file-style: "stroustrup" */