summaryrefslogtreecommitdiff
path: root/udp.c
diff options
context:
space:
mode:
authorvenaas <venaas>2008-08-21 09:55:13 +0000
committervenaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf>2008-08-21 09:55:13 +0000
commit0821c152301b03565125e823f580deef4812d554 (patch)
tree2ac62b398656d0af683d278ae4c494d0128e4950 /udp.c
parent193b6127860d8bd6ec638fb3d74ceff63698fb8d (diff)
restructuring code
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@351 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'udp.c')
-rw-r--r--udp.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/udp.c b/udp.c
index 470e6d8..db4dbfe 100644
--- a/udp.c
+++ b/udp.c
@@ -31,6 +31,10 @@
#include "radsecproxy.h"
#include "tls.h"
+static int client4_sock = -1;
+static int client6_sock = -1;
+static struct queue *server_replyq = NULL;
+
/* exactly one of client and server must be non-NULL */
/* return who we received from in *client or *server */
/* return from in sa if not NULL */
@@ -194,3 +198,47 @@ void *udpserverwr(void *arg) {
free(reply);
}
}
+
+void addclientudp(struct client *client) {
+ client->replyq = server_replyq;
+}
+
+void addserverextraudp(struct clsrvconf *conf) {
+ switch (conf->addrinfo->ai_family) {
+ case AF_INET:
+ if (client4_sock < 0) {
+ client4_sock = bindtoaddr(getsrcprotores(RAD_UDP), 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_UDP), 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 initextraudp() {
+ pthread_t cl4th, cl6th, srvth;
+
+ if (client4_sock >= 0)
+ if (pthread_create(&cl4th, NULL, udpclientrd, (void *)&client4_sock))
+ debugx(1, DBG_ERR, "pthread_create failed");
+ if (client6_sock >= 0)
+ if (pthread_create(&cl6th, NULL, udpclientrd, (void *)&client6_sock))
+ debugx(1, DBG_ERR, "pthread_create failed");
+
+ if (find_clconf_type(RAD_UDP, NULL)) {
+ server_replyq = newqueue();
+ if (pthread_create(&srvth, NULL, udpserverwr, (void *)server_replyq))
+ debugx(1, DBG_ERR, "pthread_create failed");
+ }
+}