2 * Copyright (C) 2006-2009 Stig Venaas <venaas@uninett.no>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
15 #define CONFIG_MAIN "/etc/radsecproxy.conf"
17 /* MAX_REQUESTS must be 256 due to Radius' 8 bit ID field */
18 #define MAX_REQUESTS 256
19 #define REQUEST_RETRY_INTERVAL 5
20 #define REQUEST_RETRY_COUNT 2
21 #define DUPLICATE_INTERVAL REQUEST_RETRY_INTERVAL * REQUEST_RETRY_COUNT
22 #define MAX_CERT_DEPTH 5
23 #define STATUS_SERVER_PERIOD 25
24 #define IDLE_TIMEOUT 300
26 /* 27262 is vendor DANTE Ltd. */
27 #define DEFAULT_TTL_ATTR "27262:1"
33 #define RAD_PROTOCOUNT 4
38 uint32_t ttlattrtype[2];
41 uint8_t loopprevention;
44 struct commonprotoopts {
50 struct timeval created;
52 uint8_t *buf, *replybuf;
60 int udpsock; /* only for UDP */
61 uint16_t udpport; /* only for UDP */
64 /* requests that our client will send */
66 pthread_mutex_t *lock;
69 struct timeval expiry;
74 pthread_mutex_t mutex;
80 uint8_t type; /* RAD_UDP/RAD_TLS/RAD_TCP */
81 const struct protodefs *pdef;
84 struct list *hostports;
89 regex_t *certuriregex;
92 char *confrewriteusername;
93 struct modattr *rewriteusername;
94 char *dynamiclookupcommand;
96 uint8_t retryinterval;
99 uint8_t certnamecheck;
101 uint8_t loopprevention;
102 struct rewrite *rewritein;
103 struct rewrite *rewriteout;
104 pthread_mutex_t *lock; /* only used for updating clients so far */
106 struct list *clients;
107 struct server *servers;
110 #include "tlscommon.h"
113 struct clsrvconf *conf;
116 struct request *rqs[MAX_REQUESTS];
117 struct gqueue *replyq;
118 struct gqueue *rbios; /* for dtls */
119 struct sockaddr *addr;
120 time_t expiry; /* for udp */
124 struct clsrvconf *conf;
127 pthread_mutex_t lock;
129 uint8_t clientrdgone;
130 struct timeval lastconnecttry;
131 struct timeval lastreply;
132 uint8_t connectionok;
135 char *dynamiclookuparg;
137 struct timeval lastrcv;
138 struct rqout *requests;
140 pthread_mutex_t newrq_mutex;
141 pthread_cond_t newrq_cond;
142 struct gqueue *rbios; /* for dtls */
151 pthread_mutex_t mutex;
152 struct realm *parent;
153 struct list *subrealms;
154 struct list *srvconfs;
155 struct list *accsrvconfs;
165 uint8_t *removeattrs;
166 uint32_t *removevendorattrs;
167 struct list *addattrs;
168 struct list *modattrs;
176 uint8_t retrycountdefault;
177 uint8_t retrycountmax;
178 uint8_t retryintervaldefault;
179 uint8_t retryintervalmax;
180 uint8_t duplicateintervaldefault;
181 void (*setprotoopts)(struct commonprotoopts *);
182 char **(*getlistenerargs)();
183 void *(*listener)(void*);
184 int (*connecter)(struct server *, struct timeval *, int, char *);
185 void *(*clientconnreader)(void*);
186 int (*clientradput)(struct server *, unsigned char *);
187 void (*addclient)(struct client *);
188 void (*addserverextra)(struct clsrvconf *);
193 #define RADLEN(x) ntohs(((uint16_t *)(x))[1])
195 #define ATTRTYPE(x) ((x)[0])
196 #define ATTRLEN(x) ((x)[1])
197 #define ATTRVAL(x) ((x) + 2)
198 #define ATTRVALLEN(x) ((x)[1] - 2)
200 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
201 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
202 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
203 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
204 void removelockedclient(struct client *client);
205 void removeclient(struct client *client);
206 struct gqueue *newqueue();
207 void freebios(struct gqueue *q);
208 struct request *newrequest();
209 void freerq(struct request *rq);
210 int radsrv(struct request *rq);
211 void replyh(struct server *server, unsigned char *buf);
212 struct addrinfo *resolve_hostport_addrinfo(uint8_t type, char *hostport);
214 /* Local Variables: */
215 /* c-file-style: "stroustrup" */