-/*
- free all elements of conn_list
-*/
-void destroy_conn_list(void)
-{
- conn_list_t *p, *next;
-cp
- for(p = conn_list; p != NULL; )
- {
- next = p->next;
- free_conn_element(p);
- p = next;
- }
-
- conn_list = NULL;
-cp
+int sockaddrcmp(const sockaddr_t *a, const sockaddr_t *b) {
+ int result;
+
+ result = a->sa.sa_family - b->sa.sa_family;
+
+ if(result)
+ return result;
+
+ switch (a->sa.sa_family) {
+ case AF_UNSPEC:
+ return 0;
+
+ case AF_UNKNOWN:
+ result = strcmp(a->unknown.address, b->unknown.address);
+
+ if(result)
+ return result;
+
+ return strcmp(a->unknown.port, b->unknown.port);
+
+ case AF_INET:
+ result = memcmp(&a->in.sin_addr, &b->in.sin_addr, sizeof(a->in.sin_addr));
+
+ if(result)
+ return result;
+
+ return memcmp(&a->in.sin_port, &b->in.sin_port, sizeof(a->in.sin_port));
+
+ case AF_INET6:
+ result = memcmp(&a->in6.sin6_addr, &b->in6.sin6_addr, sizeof(a->in6.sin6_addr));
+
+ if(result)
+ return result;
+
+ return memcmp(&a->in6.sin6_port, &b->in6.sin6_port, sizeof(a->in6.sin6_port));
+
+ default:
+ logger(LOG_ERR, "sockaddrcmp() was called with unknown address family %d, exitting!",
+ a->sa.sa_family);
+ abort();
+ }