cleaning up code
[radsecproxy.git] / radsecproxy.h
index 8c17c96..7a83402 100644 (file)
 #define STATUS_SERVER_PERIOD 25
 #define IDLE_TIMEOUT 300
 
+/* 27262 is vendor DANTE Ltd. */
+#define DEFAULT_TTL_ATTR "27262:1"
+
 #define RAD_UDP 0
 #define RAD_TLS 1
 #define RAD_TCP 2
 #define RAD_DTLS 3
+#define RAD_PROTOCOUNT 4
 
 struct options {
-    char **listenudp;
-    char **listentcp;
-    char **listentls;
-    char **listendtls;
-    char **listenaccudp;
-    char *sourceudp;
-    char *sourcetcp;
-    char *sourcetls;
-    char *sourcedtls;
+    char **listenargs[RAD_PROTOCOUNT];
+    char *sourcearg[RAD_PROTOCOUNT];
     char *logdestination;
+    char *ttlattr;
+    uint32_t ttlattrtype[2];
+    uint8_t addttl;
     uint8_t loglevel;
     uint8_t loopprevention;
 };
 
 struct request {
     struct timeval created;
-    uint8_t refcount;
+    uint32_t refcount;
     uint8_t *buf, *replybuf;
     struct radmsg *msg;
     struct client *from;
+    struct server *to;
     char *origusername;
     uint8_t rqid;
     uint8_t rqauth[16];
+    uint8_t newid;
     int udpsock; /* only for UDP */
     uint16_t udpport; /* only for UDP */
 };
@@ -90,12 +92,13 @@ struct clsrvconf {
     uint8_t retrycount;
     uint8_t dupinterval;
     uint8_t certnamecheck;
-    SSL_CTX *ssl_ctx;
+    uint8_t addttl;
     struct rewrite *rewritein;
     struct rewrite *rewriteout;
     struct addrinfo *addrinfo;
     uint8_t prefixlen;
     pthread_mutex_t *lock; /* only used for updating clients so far */
+    struct tls *tlsconf;
     struct list *clients;
     struct server *servers;
 };
@@ -108,6 +111,7 @@ struct client {
     struct queue *replyq;
     struct queue *rbios; /* for dtls */
     struct sockaddr *addr;
+    time_t expiry; /* for udp */
 };
 
 struct server {
@@ -136,7 +140,9 @@ struct realm {
     char *message;
     uint8_t accresp;
     regex_t regex;
-    pthread_mutex_t subrealms_mutex;
+    uint32_t refcount;
+    pthread_mutex_t mutex;
+    struct realm *parent;
     struct list *subrealms;
     struct list *srvconfs;
     struct list *accsrvconfs;
@@ -150,6 +156,11 @@ struct tls {
     char *certkeyfile;
     char *certkeypwd;
     uint8_t crlcheck;
+    char **policyoids;
+    uint32_t cacheexpiry;
+    uint32_t tlsexpiry;
+    uint32_t dtlsexpiry;
+    X509_VERIFY_PARAM *vpm;
     SSL_CTX *tlsctx;
     SSL_CTX *dtlsctx;
 };
@@ -170,7 +181,7 @@ struct rewrite {
 struct protodefs {
     char *name;
     char *secretdefault;
-    uint8_t socktype;
+    int socktype;
     char *portdefault;
     uint8_t retrycountdefault;
     uint8_t retrycountmax;
@@ -178,12 +189,12 @@ struct protodefs {
     uint8_t retryintervalmax;
     uint8_t duplicateintervaldefault;
     void *(*listener)(void*);
-    char **srcaddrport;
     int (*connecter)(struct server *, struct timeval *, int, char *);
     void *(*clientconnreader)(void*);
     int (*clientradput)(struct server *, unsigned char *);
     void (*addclient)(struct client *);
     void (*addserverextra)(struct clsrvconf *);
+    void (*setsrcres)(char *source);
     void (*initextra)();
 };
 
@@ -194,15 +205,13 @@ struct protodefs {
 #define ATTRVAL(x) ((x) + 2)
 #define ATTRVALLEN(x) ((x)[1] - 2)
 
-struct addrinfo *getsrcprotores(uint8_t type);
 struct clsrvconf *find_clconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
 struct clsrvconf *find_srvconf(uint8_t type, struct sockaddr *addr, struct list_node **cur);
 struct clsrvconf *find_clconf_type(uint8_t type, struct list_node **cur);
 struct client *addclient(struct clsrvconf *conf, uint8_t lock);
+void removelockedclient(struct client *client);
 void removeclient(struct client *client);
-void removeclientrqs(struct client *client);
 struct queue *newqueue();
-void removequeue(struct queue *q);
 void freebios(struct queue *q);
 struct request *newrequest();
 void freerq(struct request *rq);
@@ -210,5 +219,5 @@ int radsrv(struct request *rq);
 X509 *verifytlscert(SSL *ssl);
 int verifyconfcert(X509 *cert, struct clsrvconf *conf);
 void replyh(struct server *server, unsigned char *buf);
-int connecttcp(struct addrinfo *addrinfo, struct addrinfo *src);
-int bindtoaddr(struct addrinfo *addrinfo, int family, int reuse, int v6only);
+SSL_CTX *tlsgetctx(uint8_t type, struct tls *t);
+struct addrinfo *resolve_hostport_addrinfo(uint8_t type, char *hostport);