#include <netdb.h>
#include <errno.h>
+#include "sockaddr.h"
#include "misc.h"
#include "nfslib.h"
#include "exportfs.h"
return true;
}
-static _Bool
-compare_sockaddrs4(const struct sockaddr *sa1, const struct sockaddr *sa2)
-{
- const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sa1;
- const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sa2;
- return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr;
-}
-
-static _Bool
-compare_sockaddrs(const struct sockaddr *sa1, const struct sockaddr *sa2)
-{
- if (sa1->sa_family == sa2->sa_family)
- switch (sa1->sa_family) {
- case AF_INET:
- return compare_sockaddrs4(sa1, sa2);
- }
-
- return false;
-}
-
static int
matchhostname(const char *hostname1, const char *hostname2)
{
for (ai1 = results1; ai1 != NULL; ai1 = ai1->ai_next)
for (ai2 = results2; ai2 != NULL; ai2 = ai2->ai_next)
- if (compare_sockaddrs(ai1->ai_addr, ai2->ai_addr)) {
+ if (nfs_compare_sockaddr(ai1->ai_addr, ai2->ai_addr)) {
result = 1;
break;
}