From 002738e77ae6149c43a3d55b9364d365e1483578 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Thu, 11 Nov 2010 16:38:05 +0000 Subject: Don't force connections to come from same source port. Also allow address reuse for connections in time wait state. --- common/sock_any.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'common/sock_any.c') diff --git a/common/sock_any.c b/common/sock_any.c index 9a03f09..3ca68a3 100644 --- a/common/sock_any.c +++ b/common/sock_any.c @@ -367,14 +367,14 @@ int sock_any_cmp(const struct sockaddr_any* a1, const struct sockaddr_any* a2, i case AF_INET: if(memcmp(&(a1->s.in.sin_addr), &(a2->s.in.sin_addr), sizeof(a2->s.in.sin_addr)) != 0) return -1; - if(!(opts && SANY_OPT_NOPORT) && a1->s.in.sin_port != a2->s.in.sin_port) + if(!(opts & SANY_OPT_NOPORT) && a1->s.in.sin_port != a2->s.in.sin_port) return -1; return 0; #ifdef HAVE_INET6 case AF_INET6: if(memcmp(&(a1->s.in6.sin6_addr), &(a2->s.in6.sin6_addr), sizeof(a2->s.in6.sin6_addr)) != 0) return -1; - if(!(opts && SANY_OPT_NOPORT) && a1->s.in6.sin6_port != a2->s.in6.sin6_port) + if(!(opts & SANY_OPT_NOPORT) && a1->s.in6.sin6_port != a2->s.in6.sin6_port) return -1; return 0; #endif @@ -383,3 +383,24 @@ int sock_any_cmp(const struct sockaddr_any* a1, const struct sockaddr_any* a2, i return -1; } } + +void +sock_any_cpy(struct sockaddr_any* dst, const struct sockaddr_any* src, int opts) +{ + memcpy(dst, src, sizeof(struct sockaddr_any)); + switch(src->s.a.sa_family) + { + case AF_INET: + if(opts & SANY_OPT_NOPORT) + dst->s.in.sin_port = 0; + break; +#ifdef HAVE_INET6 + case AF_INET6: + if(opts & SANY_OPT_NOPORT) + dst->s.in6.sin_port = 0; + break; +#endif + default: + break; + } +} -- cgit v1.2.3