summaryrefslogtreecommitdiffstats
path: root/abs/extra/cups/cups-avahi-address.patch
blob: a03d1adbb998211b25c570a6b5e018907d9a82db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
diff -up cups-1.6.2/cups/http-support.c.avahi-address cups-1.6.2/cups/http-support.c
--- cups-1.6.2/cups/http-support.c.avahi-address	2013-03-11 18:44:36.000000000 +0000
+++ cups-1.6.2/cups/http-support.c	2013-04-04 15:39:06.651847041 +0100
@@ -2121,7 +2121,7 @@ http_resolve_cb(
     const char             *type,	/* I - Registration type */
     const char             *domain,	/* I - Domain (unused) */
     const char             *hostTarget,	/* I - Hostname */
-    const AvahiAddress     *address,	/* I - Address (unused) */
+    const AvahiAddress     *address,	/* I - Address */
     uint16_t               port,	/* I - Port number */
     AvahiStringList        *txt,	/* I - TXT record */
     AvahiLookupResultFlags flags,	/* I - Lookup flags (unused) */
@@ -2253,36 +2253,37 @@ http_resolve_cb(
 
     DEBUG_printf(("8http_resolve_cb: Looking up \"%s\".", hostTarget));
 
-    snprintf(fqdn, sizeof(fqdn), "%d", ntohs(port));
-    if ((addrlist = httpAddrGetList(hostTarget, AF_UNSPEC, fqdn)) != NULL)
+    int error = getnameinfo(&(address->data),
+			    address->proto == AVAHI_PROTO_INET ?
+			    sizeof (AvahiIPv4Address) :
+			    (address->proto == AVAHI_PROTO_INET6 ?
+			     sizeof (AvahiIPv6Address) :
+			     sizeof (address->data)),
+			    fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
+
+    if (!error)
     {
-      for (addr = addrlist; addr; addr = addr->next)
+      DEBUG_printf(("8http_resolve_cb: Found \"%s\".", fqdn));
+
+      if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
+	  _cups_strcasecmp(hostptr, ".local"))
       {
-        int error = getnameinfo(&(addr->addr.addr),
-	                        httpAddrLength(&(addr->addr)),
-			        fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
-
-        if (!error)
-	{
-	  DEBUG_printf(("8http_resolve_cb: Found \"%s\".", fqdn));
-
-	  if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
-	      _cups_strcasecmp(hostptr, ".local"))
-	  {
-	    hostTarget = fqdn;
-	    break;
-	  }
-	}
+	hostTarget = fqdn;
+      }
+    }
 #ifdef DEBUG
-	else
-	  DEBUG_printf(("8http_resolve_cb: \"%s\" did not resolve: %d",
-	                httpAddrString(&(addr->addr), fqdn, sizeof(fqdn)),
-			error));
+    else
+      DEBUG_printf(("8http_resolve_cb: \"%s\" did not resolve: %d",
+		    httpAddrString(&(addr->addr), fqdn, sizeof(fqdn)),
+		    error));
 #endif /* DEBUG */
-      }
+  } else {
+   /*
+    * Use the IP address that responded...
+    */
 
-      httpAddrFreeList(addrlist);
-    }
+   avahi_address_snprint (fqdn, sizeof (fqdn), address);
+   hostTarget = fqdn;
   }
 
  /*