summaryrefslogtreecommitdiff
path: root/dtls.c
diff options
context:
space:
mode:
authorvenaas <venaas>2008-12-18 15:14:00 +0000
committervenaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf>2008-12-18 15:14:00 +0000
commit3c779c1093a5cb6314bc366c6135fb2eaac8cdeb (patch)
tree0ba9c4f9ebdb9a91bee68c286abc9c1e6b66a286 /dtls.c
parentdfb9fcfbba3e196b4c082cc9b8a1fe7b80ac8564 (diff)
cleaning up code
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@441 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'dtls.c')
-rw-r--r--dtls.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/dtls.c b/dtls.c
index 51ec0cb..7fdd2d9 100644
--- a/dtls.c
+++ b/dtls.c
@@ -35,6 +35,7 @@
static int client4_sock = -1;
static int client6_sock = -1;
+static struct addrinfo *srcres = NULL;
struct sessioncacheentry {
pthread_mutex_t mutex;
@@ -48,6 +49,11 @@ struct dtlsservernewparams {
struct sockaddr_storage addr;
};
+void dtlssetsrcres(char *source) {
+ if (!srcres)
+ srcres = resolve_hostport_addrinfo(RAD_DTLS, source);
+}
+
int udp2bio(int s, struct queue *q, int cnt) {
unsigned char *buf;
BIO *rbio;
@@ -613,7 +619,7 @@ void addserverextradtls(struct clsrvconf *conf) {
switch (conf->addrinfo->ai_family) {
case AF_INET:
if (client4_sock < 0) {
- client4_sock = bindtoaddr(getsrcprotores(RAD_DTLS), AF_INET, 0, 1);
+ client4_sock = bindtoaddr(srcres, AF_INET, 0, 1);
if (client4_sock < 0)
debugx(1, DBG_ERR, "addserver: failed to create client socket for server %s", conf->host);
}
@@ -621,7 +627,7 @@ void addserverextradtls(struct clsrvconf *conf) {
break;
case AF_INET6:
if (client6_sock < 0) {
- client6_sock = bindtoaddr(getsrcprotores(RAD_DTLS), AF_INET6, 0, 1);
+ client6_sock = bindtoaddr(srcres, AF_INET6, 0, 1);
if (client6_sock < 0)
debugx(1, DBG_ERR, "addserver: failed to create client socket for server %s", conf->host);
}
@@ -634,6 +640,11 @@ void addserverextradtls(struct clsrvconf *conf) {
void initextradtls() {
pthread_t cl4th, cl6th;
+
+ if (srcres) {
+ freeaddrinfo(srcres);
+ srcres = NULL;
+ }
if (client4_sock >= 0)
if (pthread_create(&cl4th, NULL, udpdtlsclientrd, (void *)&client4_sock))