summaryrefslogtreecommitdiff
path: root/hostport.c
diff options
context:
space:
mode:
authorSimon Leinen <simon.leinen@switch.ch>2009-07-22 12:24:13 +0000
committerkolla <kolla@e88ac4ed-0b26-0410-9574-a7f39faa03bf>2009-07-22 12:24:13 +0000
commitc70699706ed9e28d621676737ee5b83a2b90f528 (patch)
tree74cf428a3f954cb4a9cfe815641e9401a26d2ea8 /hostport.c
parent4bb60779f948ad8f31b343d316bd6c3a78b5075d (diff)
From: Simon Leinen <simon.leinen@switch.ch>
Message-ID: <19015.29517.446579.671665@switch.ch> Subject: SourceUDP and accounting packets git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@503 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'hostport.c')
-rw-r--r--hostport.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/hostport.c b/hostport.c
index 7110f74..2e6e067 100644
--- a/hostport.c
+++ b/hostport.c
@@ -243,7 +243,7 @@ static int prefixmatch(void *a1, void *a2, uint8_t len) {
return (((uint8_t *)a1)[l] & mask[r]) == (((uint8_t *)a2)[l] & mask[r]);
}
-int addressmatches(struct list *hostports, struct sockaddr *addr) {
+int addressmatches(struct list *hostports, struct sockaddr *addr, uint8_t checkport) {
struct sockaddr_in6 *sa6 = NULL;
struct in_addr *a4 = NULL;
struct addrinfo *res;
@@ -264,9 +264,14 @@ int addressmatches(struct list *hostports, struct sockaddr *addr) {
for (res = hp->addrinfo; res; res = res->ai_next)
if (hp->prefixlen == 255) {
if ((a4 && res->ai_family == AF_INET &&
- !memcmp(a4, &((struct sockaddr_in *)res->ai_addr)->sin_addr, 4)) ||
+ !memcmp(a4, &((struct sockaddr_in *)res->ai_addr)->sin_addr, 4) &&
+ (!checkport || ((struct sockaddr_in *)res->ai_addr)->sin_port ==
+ ((struct sockaddr_in *)addr)->sin_port)) ||
(sa6 && res->ai_family == AF_INET6 &&
- !memcmp(&sa6->sin6_addr, &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr, 16)))
+ !memcmp(&sa6->sin6_addr,
+ &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr, 16) &&
+ (!checkport || ((struct sockaddr_in6 *)res->ai_addr)->sin6_port ==
+ ((struct sockaddr_in6 *)addr)->sin6_port)))
return 1;
} else {
if ((a4 && res->ai_family == AF_INET &&