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;
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;
161 char *dynamiclookuparg;
163 struct timeval lastrcv;
164 struct rqout *requests;
166 pthread_mutex_t newrq_mutex;
167 pthread_cond_t newrq_cond;
168 struct gqueue *rbios; /* for dtls */
177 pthread_mutex_t mutex;
178 struct realm *parent;
179 struct list *subrealms;
180 struct list *srvconfs;
181 struct list *accsrvconfs;
191 uint8_t *removeattrs;
192 uint32_t *removevendorattrs;
193 struct list *addattrs;
194 struct list *modattrs;
202 uint8_t retrycountdefault;
203 uint8_t retrycountmax;
204 uint8_t retryintervaldefault;
205 uint8_t retryintervalmax;
206 uint8_t duplicateintervaldefault;
207 void (*setprotoopts)(struct commonprotoopts *);
208 char **(*getlistenerargs)();
209 void *(*listener)(void*);
210 int (*connecter)(struct server *, struct timeval *, int, char *);
211 void *(*clientconnreader)(void*);
212 int (*clientradput)(struct server *, unsigned char *);
213 void (*addclient)(struct client *);
214 void (*addserverextra)(struct clsrvconf *);
219 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
221 #define ATTRTYPE(x) ((x)[0])
222 #define ATTRLEN(x) ((x)[1])
223 #define ATTRVAL(x) ((x) + 2)
224 #define ATTRVALLEN(x) ((x)[1] - 2)
226 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
227 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
228 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
229 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
230 void removelockedclient(struct client *client);
231 void removeclient(struct client *client);
232 struct gqueue *newqueue();
233 void freebios(struct gqueue *q);
234 struct request *newrequest();
235 void freerq(struct request *rq);
236 int radsrv(struct request *rq);
237 void replyh(struct server *server, unsigned char *buf);
238 struct addrinfo *resolve_hostport_addrinfo(uint8_t type, char *hostport);
239 uint8_t *radattr2ascii(struct tlv *attr);
241 /* Local Variables: */
242 /* c-file-style: "stroustrup" */