X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=dtls.c;h=9f68133f5e7964e47e71b3be841307d2ba241df6;hb=0821c152301b03565125e823f580deef4812d554;hp=5bd7826662349437c4f8680eb4021318bf917511;hpb=193b6127860d8bd6ec638fb3d74ceff63698fb8d;p=radsecproxy.git diff --git a/dtls.c b/dtls.c index 5bd7826..9f68133 100644 --- a/dtls.c +++ b/dtls.c @@ -32,6 +32,9 @@ #include "radsecproxy.h" #include "dtls.h" +static int client4_sock = -1; +static int client6_sock = -1; + int udp2bio(int s, struct queue *q, int cnt) { unsigned char *buf; BIO *rbio; @@ -470,3 +473,42 @@ void *dtlsclientrd(void *arg) { free(buf); } } + +void addclientdtls(struct client *client) { + client->replyq = newqueue(); + client->rbios = newqueue(); +} + +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); + if (client4_sock < 0) + debugx(1, DBG_ERR, "addserver: failed to create client socket for server %s", conf->host); + } + conf->servers->sock = client4_sock; + break; + case AF_INET6: + if (client6_sock < 0) { + client6_sock = bindtoaddr(getsrcprotores(RAD_DTLS), AF_INET6, 0, 1); + if (client6_sock < 0) + debugx(1, DBG_ERR, "addserver: failed to create client socket for server %s", conf->host); + } + conf->servers->sock = client6_sock; + break; + default: + debugx(1, DBG_ERR, "addserver: unsupported address family"); + } +} + +void initextradtls() { + pthread_t cl4th, cl6th; + + if (client4_sock >= 0) + if (pthread_create(&cl4th, NULL, udpdtlsclientrd, (void *)&client4_sock)) + debugx(1, DBG_ERR, "pthread_create failed"); + if (client6_sock >= 0) + if (pthread_create(&cl6th, NULL, udpdtlsclientrd, (void *)&client6_sock)) + debugx(1, DBG_ERR, "pthread_create failed"); +}