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;
127 char *fticks_viscountry;
130 #include "tlscommon.h"
133 struct clsrvconf *conf;
136 struct request *rqs[MAX_REQUESTS];
137 struct gqueue *replyq;
138 struct gqueue *rbios; /* for dtls */
139 struct sockaddr *addr;
140 time_t expiry; /* for udp */
144 struct clsrvconf *conf;
147 pthread_mutex_t lock;
149 uint8_t clientrdgone;
150 struct timeval lastconnecttry;
151 struct timeval lastreply;
152 uint8_t connectionok;
155 char *dynamiclookuparg;
157 struct timeval lastrcv;
158 struct rqout *requests;
160 pthread_mutex_t newrq_mutex;
161 pthread_cond_t newrq_cond;
162 struct gqueue *rbios; /* for dtls */
171 pthread_mutex_t mutex;
172 struct realm *parent;
173 struct list *subrealms;
174 struct list *srvconfs;
175 struct list *accsrvconfs;
185 uint8_t *removeattrs;
186 uint32_t *removevendorattrs;
187 struct list *addattrs;
188 struct list *modattrs;
196 uint8_t retrycountdefault;
197 uint8_t retrycountmax;
198 uint8_t retryintervaldefault;
199 uint8_t retryintervalmax;
200 uint8_t duplicateintervaldefault;
201 void (*setprotoopts)(struct commonprotoopts *);
202 char **(*getlistenerargs)();
203 void *(*listener)(void*);
204 int (*connecter)(struct server *, struct timeval *, int, char *);
205 void *(*clientconnreader)(void*);
206 int (*clientradput)(struct server *, unsigned char *);
207 void (*addclient)(struct client *);
208 void (*addserverextra)(struct clsrvconf *);
213 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
215 #define ATTRTYPE(x) ((x)[0])
216 #define ATTRLEN(x) ((x)[1])
217 #define ATTRVAL(x) ((x) + 2)
218 #define ATTRVALLEN(x) ((x)[1] - 2)
220 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
221 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
222 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
223 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
224 void removelockedclient(struct client *client);
225 void removeclient(struct client *client);
226 struct gqueue *newqueue();
227 void freebios(struct gqueue *q);
228 struct request *newrequest();
229 void freerq(struct request *rq);
230 int radsrv(struct request *rq);
231 void replyh(struct server *server, unsigned char *buf);
232 struct addrinfo *resolve_hostport_addrinfo(uint8_t type, char *hostport);
234 /* Local Variables: */
235 /* c-file-style: "stroustrup" */