From 8d80bf94fc38a158f3721e6725aa48b3993e157a Mon Sep 17 00:00:00 2001 From: venaas Date: Fri, 19 Dec 2008 11:18:42 +0000 Subject: cleaning up code git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@442 e88ac4ed-0b26-0410-9574-a7f39faa03bf --- udp.c | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'udp.c') diff --git a/udp.c b/udp.c index 6286392..d6521cf 100644 --- a/udp.c +++ b/udp.c @@ -29,17 +29,49 @@ #include "list.h" #include "util.h" #include "radsecproxy.h" -#include "tls.h" + +void *udpserverrd(void *arg); +int clientradputudp(struct server *server, unsigned char *rad); +void addclientudp(struct client *client); +void addserverextraudp(struct clsrvconf *conf); +void udpsetsrcres(char *source); +void initextraudp(); + +static const struct protodefs protodefs = { + "udp", + NULL, /* secretdefault */ + SOCK_DGRAM, /* socktype */ + "1812", /* portdefault */ + REQUEST_RETRY_COUNT, /* retrycountdefault */ + 10, /* retrycountmax */ + REQUEST_RETRY_INTERVAL, /* retryintervaldefault */ + 60, /* retryintervalmax */ + DUPLICATE_INTERVAL, /* duplicateintervaldefault */ + udpserverrd, /* listener */ + NULL, /* connecter */ + NULL, /* clientconnreader */ + clientradputudp, /* clientradput */ + addclientudp, /* addclient */ + addserverextraudp, /* addserverextra */ + udpsetsrcres, /* setsrcres */ + initextraudp /* initextra */ +}; static int client4_sock = -1; static int client6_sock = -1; static struct queue *server_replyq = NULL; static struct addrinfo *srcres = NULL; +static uint8_t handle; + +const struct protodefs *udpinit(uint8_t h) { + handle = h; + return &protodefs; +} void udpsetsrcres(char *source) { if (!srcres) - srcres = resolve_hostport_addrinfo(RAD_UDP, source); + srcres = resolve_hostport_addrinfo(handle, source); } void removeudpclientfromreplyq(struct client *c) { @@ -92,8 +124,8 @@ unsigned char *radudpget(int s, struct client **client, struct server **server, } p = client - ? find_clconf(RAD_UDP, (struct sockaddr *)&from, NULL) - : find_srvconf(RAD_UDP, (struct sockaddr *)&from, NULL); + ? find_clconf(handle, (struct sockaddr *)&from, NULL) + : find_srvconf(handle, (struct sockaddr *)&from, NULL); if (!p) { debug(DBG_WARN, "radudpget: got packet from wrong or unknown UDP peer %s, ignoring", addr2string((struct sockaddr *)&from)); recv(s, buf, 4, 0); @@ -285,7 +317,7 @@ void initextraudp() { if (pthread_create(&cl6th, NULL, udpclientrd, (void *)&client6_sock)) debugx(1, DBG_ERR, "pthread_create failed"); - if (find_clconf_type(RAD_UDP, NULL)) { + if (find_clconf_type(handle, NULL)) { server_replyq = newqueue(); if (pthread_create(&srvth, NULL, udpserverwr, (void *)server_replyq)) debugx(1, DBG_ERR, "pthread_create failed"); -- cgit v1.2.3