Detection of multicast IPv4 addresses was looking at the wrong end.
authorEmil Mikulic <emikulic@gmail.com>
Mon, 12 Sep 2011 10:45:55 +0000 (20:45 +1000)
committerEmil Mikulic <emikulic@gmail.com>
Mon, 12 Sep 2011 10:45:55 +0000 (20:45 +1000)
dns.c

diff --git a/dns.c b/dns.c
index df2342b..f8d7296 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -191,15 +191,17 @@ dns_get_result(struct addr *ipaddr, char **name)
       /* Identify common special cases.  */
       const char *type = "none";
 
-      if (reply.addr.family == IPv6) {
+      switch (reply.addr.family) {
+      case IPv6:
          if (IN6_IS_ADDR_LINKLOCAL(&reply.addr.ip.v6))
             type = "link-local";
          else if (IN6_IS_ADDR_SITELOCAL(&reply.addr.ip.v6))
             type = "site-local";
          else if (IN6_IS_ADDR_MULTICAST(&reply.addr.ip.v6))
             type = "multicast";
-      } else { /* AF_INET */
-         if (IN_MULTICAST(reply.addr.ip.v4))
+         break;
+      case IPv4:
+         if (IN_MULTICAST(htonl(reply.addr.ip.v4)))
             type = "multicast";
       }
       xasprintf(name, "(%s)", type);