From fb4af51e107fb96380efeadc252e25da079be6cc Mon Sep 17 00:00:00 2001 From: venaas Date: Fri, 19 Dec 2008 13:35:39 +0000 Subject: cleaning up code git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@443 e88ac4ed-0b26-0410-9574-a7f39faa03bf --- dtls.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'dtls.c') diff --git a/dtls.c b/dtls.c index 3303c4d..6ada359 100644 --- a/dtls.c +++ b/dtls.c @@ -32,12 +32,14 @@ #include "util.h" #include "radsecproxy.h" +static void setprotoopts(struct commonprotoopts *opts); +static char **getlistenerargs(); void *udpdtlsserverrd(void *arg); int dtlsconnect(struct server *server, struct timeval *when, int timeout, char *text); void *dtlsclientrd(void *arg); int clientradputdtls(struct server *server, unsigned char *rad); void addserverextradtls(struct clsrvconf *conf); -void dtlssetsrcres(char *source); +void dtlssetsrcres(); void initextradtls(); static const struct protodefs protodefs = { @@ -50,6 +52,8 @@ static const struct protodefs protodefs = { REQUEST_RETRY_INTERVAL, /* retryintervaldefault */ 60, /* retryintervalmax */ DUPLICATE_INTERVAL, /* duplicateintervaldefault */ + setprotoopts, /* setprotoopts */ + getlistenerargs, /* getlistenerargs */ udpdtlsserverrd, /* listener */ dtlsconnect, /* connecter */ dtlsclientrd, /* clientconnreader */ @@ -64,12 +68,21 @@ static int client4_sock = -1; static int client6_sock = -1; static struct addrinfo *srcres = NULL; static uint8_t handle; +static struct commonprotoopts *protoopts = NULL; const struct protodefs *dtlsinit(uint8_t h) { handle = h; return &protodefs; } +static void setprotoopts(struct commonprotoopts *opts) { + protoopts = opts; +} + +static char **getlistenerargs() { + return protoopts ? protoopts->listenargs : NULL; +} + struct sessioncacheentry { pthread_mutex_t mutex; struct queue *rbios; @@ -82,9 +95,10 @@ struct dtlsservernewparams { struct sockaddr_storage addr; }; -void dtlssetsrcres(char *source) { +void dtlssetsrcres() { if (!srcres) - srcres = resolve_hostport_addrinfo(handle, source); + srcres = resolve_hostport_addrinfo(handle, protoopts ? protoopts->sourcearg : NULL); + } int udp2bio(int s, struct queue *q, int cnt) { -- cgit v1.1