summaryrefslogtreecommitdiff
path: root/common/sock_any.c
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2004-09-04 00:05:08 +0000
committerStef Walter <stef@memberwebs.com>2004-09-04 00:05:08 +0000
commit557769cc1da3e633f00d2d80c368482e0501b5fd (patch)
tree0e957cc91ba9113c00ac8f18b71191c8e5bce2b2 /common/sock_any.c
parent9b288451c618394ae35b11206043b69ca1620b6d (diff)
Transparent proxy support.
Diffstat (limited to 'common/sock_any.c')
-rw-r--r--common/sock_any.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/common/sock_any.c b/common/sock_any.c
index 03621ff..e5f24c0 100644
--- a/common/sock_any.c
+++ b/common/sock_any.c
@@ -353,3 +353,33 @@ int sock_any_ntop(struct sockaddr_any* any, char* addr, size_t addrlen, int opts
return 0;
}
+
+int sock_any_cmp(struct sockaddr_any* a1, struct sockaddr_any* a2, int opts)
+{
+ if(a1->s.a.sa_family != a2->s.a.sa_family)
+ return -1;
+
+ switch(a1->s.a.sa_family)
+ {
+ case AF_UNIX:
+ return strcmp(a1->s.un.sun_path, a2->s.un.sun_path);
+
+ 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)
+ 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)
+ return -1;
+ return 0;
+#endif
+ default:
+ errno = EAFNOSUPPORT;
+ return -1;
+ }
+}