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
59 uint32_t ttlattrtype[2];
62 uint8_t loopprevention;
63 enum rsp_fticks_reporting_type fticks_reporting;
64 enum rsp_fticks_mac_type fticks_mac;
68 struct commonprotoopts {
74 struct timeval created;
76 uint8_t *buf, *replybuf;
84 int udpsock; /* only for UDP */
85 uint16_t udpport; /* only for UDP */
88 /* requests that our client will send */
90 pthread_mutex_t *lock;
93 struct timeval expiry;
98 pthread_mutex_t mutex;
104 uint8_t type; /* RAD_UDP/RAD_TLS/RAD_TCP */
105 const struct protodefs *pdef;
108 struct list *hostports;
112 regex_t *certcnregex;
113 regex_t *certuriregex;
115 char *confrewriteout;
116 char *confrewriteusername;
117 struct modattr *rewriteusername;
118 char *dynamiclookupcommand;
119 uint8_t statusserver;
120 uint8_t retryinterval;
123 uint8_t certnamecheck;
125 uint8_t loopprevention;
126 struct rewrite *rewritein;
127 struct rewrite *rewriteout;
128 pthread_mutex_t *lock; /* only used for updating clients so far */
130 struct list *clients;
131 struct server *servers;
132 char *fticks_viscountry;
135 #include "tlscommon.h"
138 struct clsrvconf *conf;
141 struct request *rqs[MAX_REQUESTS];
142 struct gqueue *replyq;
143 struct gqueue *rbios; /* for dtls */
144 struct sockaddr *addr;
145 time_t expiry; /* for udp */
149 struct clsrvconf *conf;
152 pthread_mutex_t lock;
154 uint8_t clientrdgone;
155 struct timeval lastconnecttry;
156 struct timeval lastreply;
157 uint8_t connectionok;
160 char *dynamiclookuparg;
162 struct timeval lastrcv;
163 struct rqout *requests;
165 pthread_mutex_t newrq_mutex;
166 pthread_cond_t newrq_cond;
167 struct gqueue *rbios; /* for dtls */
176 pthread_mutex_t mutex;
177 struct realm *parent;
178 struct list *subrealms;
179 struct list *srvconfs;
180 struct list *accsrvconfs;
190 uint8_t *removeattrs;
191 uint32_t *removevendorattrs;
192 struct list *addattrs;
193 struct list *modattrs;
201 uint8_t retrycountdefault;
202 uint8_t retrycountmax;
203 uint8_t retryintervaldefault;
204 uint8_t retryintervalmax;
205 uint8_t duplicateintervaldefault;
206 void (*setprotoopts)(struct commonprotoopts *);
207 char **(*getlistenerargs)();
208 void *(*listener)(void*);
209 int (*connecter)(struct server *, struct timeval *, int, char *);
210 void *(*clientconnreader)(void*);
211 int (*clientradput)(struct server *, unsigned char *);
212 void (*addclient)(struct client *);
213 void (*addserverextra)(struct clsrvconf *);
218 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
220 #define ATTRTYPE(x) ((x)[0])
221 #define ATTRLEN(x) ((x)[1])
222 #define ATTRVAL(x) ((x) + 2)
223 #define ATTRVALLEN(x) ((x)[1] - 2)
225 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
226 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
227 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
228 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
229 void removelockedclient(struct client *client);
230 void removeclient(struct client *client);
231 struct gqueue *newqueue();
232 void freebios(struct gqueue *q);
233 struct request *newrequest();
234 void freerq(struct request *rq);
235 int radsrv(struct request *rq);
236 void replyh(struct server *server, unsigned char *buf);
237 struct addrinfo *resolve_hostport_addrinfo(uint8_t type, char *hostport);
238 uint8_t *radattr2ascii(struct tlv *attr);
240 /* Local Variables: */
241 /* c-file-style: "stroustrup" */