diff options
author | venaas <venaas> | 2008-12-22 13:14:41 +0000 |
---|---|---|
committer | venaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf> | 2008-12-22 13:14:41 +0000 |
commit | e0c9e33cc484025e2b80bec19f7130554e9e3781 (patch) | |
tree | 8e59eef2efd7c569707224edbc67ade716d8673f /udp.c | |
parent | a99d921cf322a09d779500c2cdeb55e3df260fb8 (diff) |
moved more code to tlscommon, fixed a couple of minor lint warnings
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@447 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'udp.c')
-rw-r--r-- | udp.c | 34 |
1 files changed, 30 insertions, 4 deletions
@@ -6,7 +6,6 @@ * copyright notice and this permission notice appear in all copies. */ -#ifdef RADPROT_UDP #include <signal.h> #include <sys/socket.h> #include <netinet/in.h> @@ -25,12 +24,13 @@ #include <arpa/inet.h> #include <regex.h> #include <pthread.h> -#include <openssl/ssl.h> -#include "debug.h" #include "list.h" -#include "util.h" #include "radsecproxy.h" +#ifdef RADPROT_UDP +#include "debug.h" +#include "util.h" + static void setprotoopts(struct commonprotoopts *opts); static char **getlistenerargs(); void *udpserverrd(void *arg); @@ -102,6 +102,31 @@ void removeudpclientfromreplyq(struct client *c) { pthread_mutex_unlock(&c->replyq->mutex); } +static int addr_equal(struct sockaddr *a, struct sockaddr *b) { + switch (a->sa_family) { + case AF_INET: + return !memcmp(&((struct sockaddr_in*)a)->sin_addr, + &((struct sockaddr_in*)b)->sin_addr, + sizeof(struct in_addr)); + case AF_INET6: + return IN6_ARE_ADDR_EQUAL(&((struct sockaddr_in6*)a)->sin6_addr, + &((struct sockaddr_in6*)b)->sin6_addr); + default: + /* Must not reach */ + return 0; + } +} + +uint16_t port_get(struct sockaddr *sa) { + switch (sa->sa_family) { + case AF_INET: + return ntohs(((struct sockaddr_in *)sa)->sin_port); + case AF_INET6: + return ntohs(((struct sockaddr_in6 *)sa)->sin6_port); + } + return 0; +} + /* 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 */ @@ -261,6 +286,7 @@ void *udpserverrd(void *arg) { radsrv(rq); } free(sp); + return NULL; } void *udpserverwr(void *arg) { |