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;
70 struct commonprotoopts {
76 struct timeval created;
78 uint8_t *buf, *replybuf;
86 int udpsock; /* only for UDP */
87 uint16_t udpport; /* only for UDP */
90 /* requests that our client will send */
92 pthread_mutex_t *lock;
95 struct timeval expiry;
100 pthread_mutex_t mutex;
106 uint8_t type; /* RAD_UDP/RAD_TLS/RAD_TCP */
107 const struct protodefs *pdef;
110 struct list *hostports;
114 regex_t *certcnregex;
115 regex_t *certuriregex;
117 char *confrewriteout;
118 char *confrewriteusername;
119 struct modattr *rewriteusername;
120 char *dynamiclookupcommand;
121 uint8_t statusserver;
122 uint8_t retryinterval;
125 uint8_t certnamecheck;
127 uint8_t loopprevention;
128 struct rewrite *rewritein;
129 struct rewrite *rewriteout;
130 pthread_mutex_t *lock; /* only used for updating clients so far */
132 struct list *clients;
133 struct server *servers;
134 char *fticks_viscountry;
135 char *fticks_visinst;
138 #include "tlscommon.h"
141 struct clsrvconf *conf;
144 struct request *rqs[MAX_REQUESTS];
145 struct gqueue *replyq;
146 struct gqueue *rbios; /* for dtls */
147 struct sockaddr *addr;
148 time_t expiry; /* for udp */
152 struct clsrvconf *conf;
155 pthread_mutex_t lock;
157 uint8_t clientrdgone;
158 struct timeval lastconnecttry;
159 struct timeval lastreply;
160 uint8_t connectionok;
164 char *dynamiclookuparg;
166 struct timeval lastrcv;
167 struct rqout *requests;
169 pthread_mutex_t newrq_mutex;
170 pthread_cond_t newrq_cond;
171 struct gqueue *rbios; /* for dtls */
180 pthread_mutex_t mutex;
181 struct realm *parent;
182 struct list *subrealms;
183 struct list *srvconfs;
184 struct list *accsrvconfs;
194 uint8_t *removeattrs;
195 uint32_t *removevendorattrs;
196 struct list *addattrs;
197 struct list *modattrs;
205 uint8_t retrycountdefault;
206 uint8_t retrycountmax;
207 uint8_t retryintervaldefault;
208 uint8_t retryintervalmax;
209 uint8_t duplicateintervaldefault;
210 void (*setprotoopts)(struct commonprotoopts *);
211 char **(*getlistenerargs)();
212 void *(*listener)(void*);
213 int (*connecter)(struct server *, struct timeval *, int, char *);
214 void *(*clientconnreader)(void*);
215 int (*clientradput)(struct server *, unsigned char *);
216 void (*addclient)(struct client *);
217 void (*addserverextra)(struct clsrvconf *);
222 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
224 #define ATTRTYPE(x) ((x)[0])
225 #define ATTRLEN(x) ((x)[1])
226 #define ATTRVAL(x) ((x) + 2)
227 #define ATTRVALLEN(x) ((x)[1] - 2)
229 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
230 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
231 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
232 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
233 void removelockedclient(struct client *client);
234 void removeclient(struct client *client);
235 struct gqueue *newqueue();
236 void freebios(struct gqueue *q);
237 struct request *newrequest();
238 void freerq(struct request *rq);
239 int radsrv(struct request *rq);
240 void replyh(struct server *server, unsigned char *buf);
241 struct addrinfo *resolve_hostport_addrinfo(uint8_t type, char *hostport);
242 uint8_t *radattr2ascii(struct tlv *attr);
244 /* Local Variables: */
245 /* c-file-style: "stroustrup" */