2 * Copyright (C) 2006-2009 Stig Venaas <venaas@uninett.no>
3 * Copyright (C) 2010 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.
16 #define CONFIG_MAIN "/etc/radsecproxy.conf"
18 /* MAX_REQUESTS must be 256 due to Radius' 8 bit ID field */
19 #define MAX_REQUESTS 256
20 #define REQUEST_RETRY_INTERVAL 5
21 #define REQUEST_RETRY_COUNT 2
22 #define DUPLICATE_INTERVAL REQUEST_RETRY_INTERVAL * REQUEST_RETRY_COUNT
23 #define MAX_CERT_DEPTH 5
24 #define STATUS_SERVER_PERIOD 25
25 #define IDLE_TIMEOUT 300
27 /* 27262 is vendor DANTE Ltd. */
28 #define DEFAULT_TTL_ATTR "27262:1"
34 #define RAD_PROTOCOUNT 4
36 enum rsp_fticks_reporting_type {
37 RSP_FTICKS_REPORTING_NONE = 0, /* Default. */
38 RSP_FTICKS_REPORTING_BASIC,
39 RSP_FTICKS_REPORTING_FULL
42 enum rsp_fticks_mac_type {
43 RSP_FTICKS_MAC_STATIC = 0, /* Default. */
44 RSP_FTICKS_MAC_ORIGINAL,
45 RSP_FTICKS_MAC_VENDOR_HASHED,
46 RSP_FTICKS_MAC_VENDOR_KEY_HASHED,
47 RSP_FTICKS_MAC_FULLY_HASHED,
48 RSP_FTICKS_MAC_FULLY_KEY_HASHED
54 uint32_t ttlattrtype[2];
57 uint8_t loopprevention;
58 enum rsp_fticks_reporting_type fticks_reporting;
59 enum rsp_fticks_mac_type fticks_mac;
63 struct commonprotoopts {
69 struct timeval created;
71 uint8_t *buf, *replybuf;
79 int udpsock; /* only for UDP */
80 uint16_t udpport; /* only for UDP */
83 /* requests that our client will send */
85 pthread_mutex_t *lock;
88 struct timeval expiry;
93 pthread_mutex_t mutex;
99 uint8_t type; /* RAD_UDP/RAD_TLS/RAD_TCP */
100 const struct protodefs *pdef;
103 struct list *hostports;
107 regex_t *certcnregex;
108 regex_t *certuriregex;
110 char *confrewriteout;
111 char *confrewriteusername;
112 struct modattr *rewriteusername;
113 char *dynamiclookupcommand;
114 uint8_t statusserver;
115 uint8_t retryinterval;
118 uint8_t certnamecheck;
120 uint8_t loopprevention;
121 struct rewrite *rewritein;
122 struct rewrite *rewriteout;
123 pthread_mutex_t *lock; /* only used for updating clients so far */
125 struct list *clients;
126 struct server *servers;
129 #include "tlscommon.h"
132 struct clsrvconf *conf;
135 struct request *rqs[MAX_REQUESTS];
136 struct gqueue *replyq;
137 struct gqueue *rbios; /* for dtls */
138 struct sockaddr *addr;
139 time_t expiry; /* for udp */
143 struct clsrvconf *conf;
146 pthread_mutex_t lock;
148 uint8_t clientrdgone;
149 struct timeval lastconnecttry;
150 struct timeval lastreply;
151 uint8_t connectionok;
154 char *dynamiclookuparg;
156 struct timeval lastrcv;
157 struct rqout *requests;
159 pthread_mutex_t newrq_mutex;
160 pthread_cond_t newrq_cond;
161 struct gqueue *rbios; /* for dtls */
170 pthread_mutex_t mutex;
171 struct realm *parent;
172 struct list *subrealms;
173 struct list *srvconfs;
174 struct list *accsrvconfs;
184 uint8_t *removeattrs;
185 uint32_t *removevendorattrs;
186 struct list *addattrs;
187 struct list *modattrs;
195 uint8_t retrycountdefault;
196 uint8_t retrycountmax;
197 uint8_t retryintervaldefault;
198 uint8_t retryintervalmax;
199 uint8_t duplicateintervaldefault;
200 void (*setprotoopts)(struct commonprotoopts *);
201 char **(*getlistenerargs)();
202 void *(*listener)(void*);
203 int (*connecter)(struct server *, struct timeval *, int, char *);
204 void *(*clientconnreader)(void*);
205 int (*clientradput)(struct server *, unsigned char *);
206 void (*addclient)(struct client *);
207 void (*addserverextra)(struct clsrvconf *);
212 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
214 #define ATTRTYPE(x) ((x)[0])
215 #define ATTRLEN(x) ((x)[1])
216 #define ATTRVAL(x) ((x) + 2)
217 #define ATTRVALLEN(x) ((x)[1] - 2)
219 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
220 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
221 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
222 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
223 void removelockedclient(struct client *client);
224 void removeclient(struct client *client);
225 struct gqueue *newqueue();
226 void freebios(struct gqueue *q);
227 struct request *newrequest();
228 void freerq(struct request *rq);
229 int radsrv(struct request *rq);
230 void replyh(struct server *server, unsigned char *buf);
231 struct addrinfo *resolve_hostport_addrinfo(uint8_t type, char *hostport);
233 /* Local Variables: */
234 /* c-file-style: "stroustrup" */