Blame SOURCES/cups-avahi-address.patch

ea9550
diff -up cups-1.6.2/cups/http-support.c.avahi-address cups-1.6.2/cups/http-support.c
ea9550
--- cups-1.6.2/cups/http-support.c.avahi-address	2013-03-11 18:44:36.000000000 +0000
ea9550
+++ cups-1.6.2/cups/http-support.c	2013-06-28 13:42:15.834715511 +0100
ea9550
@@ -2121,7 +2121,7 @@ http_resolve_cb(
ea9550
     const char             *type,	/* I - Registration type */
ea9550
     const char             *domain,	/* I - Domain (unused) */
ea9550
     const char             *hostTarget,	/* I - Hostname */
ea9550
-    const AvahiAddress     *address,	/* I - Address (unused) */
ea9550
+    const AvahiAddress     *address,	/* I - Address */
ea9550
     uint16_t               port,	/* I - Port number */
ea9550
     AvahiStringList        *txt,	/* I - TXT record */
ea9550
     AvahiLookupResultFlags flags,	/* I - Lookup flags (unused) */
ea9550
@@ -2248,41 +2248,59 @@ http_resolve_cb(
ea9550
     * getting the IP address of the .local name and then do reverse-lookups...
ea9550
     */
ea9550
 
ea9550
-    http_addrlist_t	*addrlist,	/* List of addresses */
ea9550
-			*addr;		/* Current address */
ea9550
+    http_addr_t addr;
ea9550
+    size_t addrlen;
ea9550
+    int error;
ea9550
 
ea9550
     DEBUG_printf(("8http_resolve_cb: Looking up \"%s\".", hostTarget));
ea9550
 
ea9550
-    snprintf(fqdn, sizeof(fqdn), "%d", ntohs(port));
ea9550
-    if ((addrlist = httpAddrGetList(hostTarget, AF_UNSPEC, fqdn)) != NULL)
ea9550
+    switch (address->proto)
ea9550
     {
ea9550
-      for (addr = addrlist; addr; addr = addr->next)
ea9550
+    case AVAHI_PROTO_INET:
ea9550
+      addr.ipv4.sin_family = AF_INET;
ea9550
+      addrlen = sizeof (addr.ipv4.sin_addr);
ea9550
+      memcpy (&addr.ipv4.sin_addr, &address->data, addrlen);
ea9550
+      break;
ea9550
+    case AVAHI_PROTO_INET6:
ea9550
+      addr.ipv6.sin6_family = AF_INET6;
ea9550
+      addrlen = sizeof (addr.ipv6.sin6_addr);
ea9550
+      memcpy (&addr.ipv6.sin6_addr, &address->data, addrlen);
ea9550
+      break;
ea9550
+    default:
ea9550
+      DEBUG_printf(("8http_resolve_cb: unknown address family %d",
ea9550
+		    address->proto));
ea9550
+      addrlen = 0;
ea9550
+    }
ea9550
+
ea9550
+    if (addrlen > 0) {
ea9550
+      error = getnameinfo(&addr.addr, httpAddrLength (&addr),
ea9550
+			  fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
ea9550
+
ea9550
+      if (!error)
ea9550
       {
ea9550
-        int error = getnameinfo(&(addr->addr.addr),
ea9550
-	                        httpAddrLength(&(addr->addr)),
ea9550
-			        fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
ea9550
+	DEBUG_printf(("8http_resolve_cb: Found \"%s\".", fqdn));
ea9550
 
ea9550
-        if (!error)
ea9550
+	if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
ea9550
+	    _cups_strcasecmp(hostptr, ".local"))
ea9550
 	{
ea9550
-	  DEBUG_printf(("8http_resolve_cb: Found \"%s\".", fqdn));
ea9550
-
ea9550
-	  if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
ea9550
-	      _cups_strcasecmp(hostptr, ".local"))
ea9550
-	  {
ea9550
-	    hostTarget = fqdn;
ea9550
-	    break;
ea9550
-	  }
ea9550
+	  hostTarget = fqdn;
ea9550
 	}
ea9550
+      } else {
ea9550
+	avahi_address_snprint (fqdn, sizeof (fqdn), address);
ea9550
+	hostTarget = fqdn;
ea9550
 #ifdef DEBUG
ea9550
-	else
ea9550
-	  DEBUG_printf(("8http_resolve_cb: \"%s\" did not resolve: %d",
ea9550
-	                httpAddrString(&(addr->addr), fqdn, sizeof(fqdn)),
ea9550
-			error));
ea9550
+	DEBUG_printf(("8http_resolve_cb: \"%s\" did not resolve: %d",
ea9550
+		      fqdn, error));
ea9550
 #endif /* DEBUG */
ea9550
       }
ea9550
-
ea9550
-      httpAddrFreeList(addrlist);
ea9550
     }
ea9550
+  } else {
ea9550
+   /*
ea9550
+    * Use the IP address that responded...
ea9550
+    */
ea9550
+
ea9550
+   avahi_address_snprint (fqdn, sizeof (fqdn), address);
ea9550
+   hostTarget = fqdn;
ea9550
   }
ea9550
 
ea9550
  /*