summaryrefslogtreecommitdiff
path: root/udp.c
diff options
context:
space:
mode:
authorvenaas <venaas>2008-09-14 17:16:03 +0000
committervenaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf>2008-09-14 17:16:03 +0000
commit52570225d77be0f9c751ab30e8ec6f98639be827 (patch)
tree2ca88824d8bb89a05d2a9e546dd292b9017fe6df /udp.c
parent973eaceb232a0038d97cf21c13c53ae33a5e232b (diff)
changing to use a separate client structure for each udp client
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@378 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'udp.c')
-rw-r--r--udp.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/udp.c b/udp.c
index c2302d4..4d27425 100644
--- a/udp.c
+++ b/udp.c
@@ -42,6 +42,7 @@ unsigned char *radudpget(int s, struct client **client, struct server **server,
int cnt, len;
unsigned char buf[4], *rad = NULL;
struct sockaddr_storage from;
+ struct sockaddr *fromcopy;
socklen_t fromlen = sizeof(from);
struct clsrvconf *p;
struct list_node *node;
@@ -101,10 +102,22 @@ unsigned char *radudpget(int s, struct client **client, struct server **server,
debug(DBG_DBG, "radudpget: packet was padded with %d bytes", cnt - len);
if (client) {
- node = list_first(p->clients);
- *client = node ? (struct client *)node->data : addclient(p);
- if (!*client)
+ for (node = list_first(p->clients); node; node = list_next(node))
+ if (addr_equal((struct sockaddr *)&from, ((struct client *)node->data)->addr))
+ break;
+ if (node) {
+ *client = (struct client *)node->data;
+ break;
+ }
+ fromcopy = addr_copy((struct sockaddr *)&from);
+ if (!fromcopy)
continue;
+ *client = addclient(p);
+ if (!*client) {
+ free(fromcopy);
+ continue;
+ }
+ (*client)->addr = fromcopy;
} else if (server)
*server = p->servers;
break;