diff options
author | venaas <venaas> | 2008-12-19 11:18:42 +0000 |
---|---|---|
committer | venaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf> | 2008-12-19 11:18:42 +0000 |
commit | 8d80bf94fc38a158f3721e6725aa48b3993e157a (patch) | |
tree | 7723a6493b616ed18d19804c2dc526527357394f /udp.c | |
parent | 3c779c1093a5cb6314bc366c6135fb2eaac8cdeb (diff) |
cleaning up code
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@442 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'udp.c')
-rw-r--r-- | udp.c | 42 |
1 files changed, 37 insertions, 5 deletions
@@ -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"); |