2 * Copyright (C) 2006-2009 Stig Venaas <venaas@uninett.no>
3 * Copyright (C) 2010,2011 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 "/etc/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
58 char *ftickssyslogfacility;
60 uint32_t ttlattrtype[2];
63 uint8_t loopprevention;
64 enum rsp_fticks_reporting_type fticks_reporting;
65 enum rsp_fticks_mac_type fticks_mac;
69 struct commonprotoopts {
75 struct timeval created;
77 uint8_t *buf, *replybuf;
85 int udpsock; /* only for UDP */
86 uint16_t udpport; /* only for UDP */
89 /* requests that our client will send */
91 pthread_mutex_t *lock;
94 struct timeval expiry;
99 pthread_mutex_t mutex;
105 uint8_t type; /* RAD_UDP/RAD_TLS/RAD_TCP */
106 const struct protodefs *pdef;
109 struct list *hostports;
113 regex_t *certcnregex;
114 regex_t *certuriregex;
116 char *confrewriteout;
117 char *confrewriteusername;
118 struct modattr *rewriteusername;
119 char *dynamiclookupcommand;
120 uint8_t statusserver;
121 uint8_t retryinterval;
124 uint8_t certnamecheck;
126 uint8_t loopprevention;
127 struct rewrite *rewritein;
128 struct rewrite *rewriteout;
129 pthread_mutex_t *lock; /* only used for updating clients so far */
131 struct list *clients;
132 struct server *servers;
133 char *fticks_viscountry;
134 char *fticks_visinst;
137 #include "tlscommon.h"
140 struct clsrvconf *conf;
143 struct request *rqs[MAX_REQUESTS];
144 struct gqueue *replyq;
145 struct gqueue *rbios; /* for dtls */
146 struct sockaddr *addr;
147 time_t expiry; /* for udp */
151 struct clsrvconf *conf;
154 pthread_mutex_t lock;
156 uint8_t clientrdgone;
157 struct timeval lastconnecttry;
158 struct timeval lastreply;
159 uint8_t connectionok;
162 char *dynamiclookuparg;
164 struct timeval lastrcv;
165 struct rqout *requests;
167 pthread_mutex_t newrq_mutex;
168 pthread_cond_t newrq_cond;
169 struct gqueue *rbios; /* for dtls */
178 pthread_mutex_t mutex;
179 struct realm *parent;
180 struct list *subrealms;
181 struct list *srvconfs;
182 struct list *accsrvconfs;
192 uint8_t *removeattrs;
193 uint32_t *removevendorattrs;
194 struct list *addattrs;
195 struct list *modattrs;
203 uint8_t retrycountdefault;
204 uint8_t retrycountmax;
205 uint8_t retryintervaldefault;
206 uint8_t retryintervalmax;
207 uint8_t duplicateintervaldefault;
208 void (*setprotoopts)(struct commonprotoopts *);
209 char **(*getlistenerargs)();
210 void *(*listener)(void*);
211 int (*connecter)(struct server *, struct timeval *, int, char *);
212 void *(*clientconnreader)(void*);
213 int (*clientradput)(struct server *, unsigned char *);
214 void (*addclient)(struct client *);
215 void (*addserverextra)(struct clsrvconf *);
220 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
222 #define ATTRTYPE(x) ((x)[0])
223 #define ATTRLEN(x) ((x)[1])
224 #define ATTRVAL(x) ((x) + 2)
225 #define ATTRVALLEN(x) ((x)[1] - 2)
227 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
228 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
229 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
230 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
231 void removelockedclient(struct client *client);
232 void removeclient(struct client *client);
233 struct gqueue *newqueue();
234 void freebios(struct gqueue *q);
235 struct request *newrequest();
236 void freerq(struct request *rq);
237 int radsrv(struct request *rq);
238 void replyh(struct server *server, unsigned char *buf);
239 struct addrinfo *resolve_hostport_addrinfo(uint8_t type, char *hostport);
240 uint8_t *radattr2ascii(struct tlv *attr);
242 /* Local Variables: */
243 /* c-file-style: "stroustrup" */