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
31 #define PTHREAD_STACK_SIZE 32768
33 /* 27262 is vendor DANTE Ltd. */
34 #define DEFAULT_TTL_ATTR "27262:1"
40 #define RAD_PROTOCOUNT 4
42 enum rsp_fticks_reporting_type {
43 RSP_FTICKS_REPORTING_NONE = 0, /* Default. */
44 RSP_FTICKS_REPORTING_BASIC,
45 RSP_FTICKS_REPORTING_FULL
48 enum rsp_fticks_mac_type {
49 RSP_FTICKS_MAC_STATIC = 0,
50 RSP_FTICKS_MAC_ORIGINAL,
51 RSP_FTICKS_MAC_VENDOR_HASHED,
52 RSP_FTICKS_MAC_VENDOR_KEY_HASHED, /* Default. */
53 RSP_FTICKS_MAC_FULLY_HASHED,
54 RSP_FTICKS_MAC_FULLY_KEY_HASHED
60 char *ftickssyslogfacility;
62 uint32_t ttlattrtype[2];
65 uint8_t loopprevention;
66 enum rsp_fticks_reporting_type fticks_reporting;
67 enum rsp_fticks_mac_type fticks_mac;
73 struct commonprotoopts {
79 struct timeval created;
81 uint8_t *buf, *replybuf;
89 int udpsock; /* only for UDP */
90 uint16_t udpport; /* only for UDP */
93 /* requests that our client will send */
95 pthread_mutex_t *lock;
98 struct timeval expiry;
102 struct list *entries;
103 pthread_mutex_t mutex;
109 uint8_t type; /* RAD_UDP/RAD_TLS/RAD_TCP */
110 const struct protodefs *pdef;
114 struct list *hostports;
118 regex_t *certcnregex;
119 regex_t *certuriregex;
121 char *confrewriteout;
122 char *confrewriteusername;
123 struct modattr *rewriteusername;
124 char *dynamiclookupcommand;
125 uint8_t statusserver;
126 uint8_t retryinterval;
129 uint8_t certnamecheck;
131 uint8_t loopprevention;
132 struct rewrite *rewritein;
133 struct rewrite *rewriteout;
134 pthread_mutex_t *lock; /* only used for updating clients so far */
136 struct list *clients;
137 struct server *servers;
138 char *fticks_viscountry;
139 char *fticks_visinst;
142 #include "tlscommon.h"
145 struct clsrvconf *conf;
148 struct request *rqs[MAX_REQUESTS];
149 struct gqueue *replyq;
150 struct gqueue *rbios; /* for dtls */
151 struct sockaddr *addr;
152 time_t expiry; /* for udp */
156 struct clsrvconf *conf;
159 pthread_mutex_t lock;
161 uint8_t clientrdgone;
162 struct timeval lastconnecttry;
163 struct timeval lastreply;
164 uint8_t connectionok;
168 #if defined ENABLE_EXPERIMENTAL_DYNDISC
171 char *dynamiclookuparg;
173 struct timeval lastrcv;
174 struct rqout *requests;
176 pthread_mutex_t newrq_mutex;
177 pthread_cond_t newrq_cond;
178 struct gqueue *rbios; /* for dtls */
187 pthread_mutex_t mutex;
188 struct realm *parent;
189 struct list *subrealms;
190 struct list *srvconfs;
191 struct list *accsrvconfs;
201 uint8_t *removeattrs;
202 uint32_t *removevendorattrs;
203 struct list *addattrs;
204 struct list *modattrs;
212 uint8_t retrycountdefault;
213 uint8_t retrycountmax;
214 uint8_t retryintervaldefault;
215 uint8_t retryintervalmax;
216 uint8_t duplicateintervaldefault;
217 void (*setprotoopts)(struct commonprotoopts *);
218 char **(*getlistenerargs)();
219 void *(*listener)(void*);
220 int (*connecter)(struct server *, struct timeval *, int, char *);
221 void *(*clientconnreader)(void*);
222 int (*clientradput)(struct server *, unsigned char *);
223 void (*addclient)(struct client *);
224 void (*addserverextra)(struct clsrvconf *);
229 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
231 #define ATTRTYPE(x) ((x)[0])
232 #define ATTRLEN(x) ((x)[1])
233 #define ATTRVAL(x) ((x) + 2)
234 #define ATTRVALLEN(x) ((x)[1] - 2)
236 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
237 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
238 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
239 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
240 void removelockedclient(struct client *client);
241 void removeclient(struct client *client);
242 struct gqueue *newqueue();
243 void freebios(struct gqueue *q);
244 struct request *newrequest();
245 void freerq(struct request *rq);
246 int radsrv(struct request *rq);
247 void replyh(struct server *server, unsigned char *buf);
248 struct addrinfo *resolve_hostport_addrinfo(uint8_t type, char *hostport);
249 uint8_t *radattr2ascii(struct tlv *attr);
250 pthread_attr_t pthread_attr;
252 /* Local Variables: */
253 /* c-file-style: "stroustrup" */