2016-06-27 16:29:55 +00:00
|
|
|
diff -up cups-2.2b2/cups/http-support.c.avahi-address cups-2.2b2/cups/http-support.c
|
|
|
|
--- cups-2.2b2/cups/http-support.c.avahi-address 2016-06-24 17:43:35.000000000 +0200
|
|
|
|
+++ cups-2.2b2/cups/http-support.c 2016-06-27 15:31:34.201361844 +0200
|
|
|
|
@@ -2340,7 +2340,7 @@ http_resolve_cb(
|
2013-04-04 14:50:25 +00:00
|
|
|
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) */
|
2016-06-27 16:29:55 +00:00
|
|
|
@@ -2493,39 +2493,62 @@ http_resolve_cb(
|
2013-06-28 11:16:55 +00:00
|
|
|
* getting the IP address of the .local name and then do reverse-lookups...
|
|
|
|
*/
|
|
|
|
|
|
|
|
- http_addrlist_t *addrlist, /* List of addresses */
|
|
|
|
- *addr; /* Current address */
|
|
|
|
+ http_addr_t addr;
|
|
|
|
+ size_t addrlen;
|
|
|
|
+ int error;
|
2013-04-04 14:50:25 +00:00
|
|
|
|
2016-06-27 16:29:55 +00:00
|
|
|
DEBUG_printf(("5http_resolve_cb: Looking up \"%s\".", hostTarget));
|
2013-04-04 14:50:25 +00:00
|
|
|
|
|
|
|
- snprintf(fqdn, sizeof(fqdn), "%d", ntohs(port));
|
|
|
|
- if ((addrlist = httpAddrGetList(hostTarget, AF_UNSPEC, fqdn)) != NULL)
|
2013-06-28 11:16:55 +00:00
|
|
|
+ switch (address->proto)
|
2013-04-04 14:50:25 +00:00
|
|
|
{
|
|
|
|
- for (addr = addrlist; addr; addr = addr->next)
|
2013-06-28 11:16:55 +00:00
|
|
|
+ case AVAHI_PROTO_INET:
|
|
|
|
+ addr.ipv4.sin_family = AF_INET;
|
|
|
|
+ addrlen = sizeof (addr.ipv4.sin_addr);
|
|
|
|
+ memcpy (&addr.ipv4.sin_addr, &address->data, addrlen);
|
|
|
|
+ break;
|
|
|
|
+ case AVAHI_PROTO_INET6:
|
|
|
|
+ addr.ipv6.sin6_family = AF_INET6;
|
|
|
|
+ addrlen = sizeof (addr.ipv6.sin6_addr);
|
|
|
|
+ memcpy (&addr.ipv6.sin6_addr, &address->data, addrlen);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ DEBUG_printf(("8http_resolve_cb: unknown address family %d",
|
|
|
|
+ address->proto));
|
|
|
|
+ addrlen = 0;
|
|
|
|
+ }
|
2013-04-04 14:50:25 +00:00
|
|
|
+
|
2013-06-28 11:16:55 +00:00
|
|
|
+ if (addrlen > 0) {
|
|
|
|
+ error = getnameinfo(&addr.addr, httpAddrLength (&addr),
|
|
|
|
+ fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
|
|
|
|
+
|
|
|
|
+ if (!error)
|
2013-04-04 14:50:25 +00:00
|
|
|
{
|
2014-09-12 16:19:24 +00:00
|
|
|
- int error = getnameinfo(&(addr->addr.addr), (socklen_t)httpAddrLength(&(addr->addr)), fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
|
2013-06-28 11:16:55 +00:00
|
|
|
+ DEBUG_printf(("8http_resolve_cb: Found \"%s\".", fqdn));
|
|
|
|
|
2013-04-04 14:50:25 +00:00
|
|
|
- if (!error)
|
2014-09-12 16:19:24 +00:00
|
|
|
- {
|
2016-06-27 16:29:55 +00:00
|
|
|
- DEBUG_printf(("5http_resolve_cb: Found \"%s\".", fqdn));
|
2013-06-28 11:16:55 +00:00
|
|
|
+ if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
|
|
|
|
+ _cups_strcasecmp(hostptr, ".local"))
|
2014-09-12 16:19:24 +00:00
|
|
|
|
2013-04-04 14:50:25 +00:00
|
|
|
- if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
|
|
|
|
- _cups_strcasecmp(hostptr, ".local"))
|
|
|
|
- {
|
|
|
|
- hostTarget = fqdn;
|
|
|
|
- break;
|
|
|
|
- }
|
2014-09-12 16:19:24 +00:00
|
|
|
+ {
|
2013-06-28 11:16:55 +00:00
|
|
|
+ hostTarget = fqdn;
|
|
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ avahi_address_snprint (fqdn, sizeof (fqdn), address);
|
2013-04-04 14:50:25 +00:00
|
|
|
+ hostTarget = fqdn;
|
2014-09-12 16:19:24 +00:00
|
|
|
+
|
2013-04-04 14:50:25 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
- else
|
2016-06-27 16:29:55 +00:00
|
|
|
- DEBUG_printf(("5http_resolve_cb: \"%s\" did not resolve: %d",
|
2013-04-04 14:50:25 +00:00
|
|
|
- httpAddrString(&(addr->addr), fqdn, sizeof(fqdn)),
|
|
|
|
- error));
|
2013-06-28 11:16:55 +00:00
|
|
|
+ DEBUG_printf(("8http_resolve_cb: \"%s\" did not resolve: %d",
|
|
|
|
+ fqdn, error));
|
2013-04-04 14:50:25 +00:00
|
|
|
#endif /* DEBUG */
|
2013-06-28 11:16:55 +00:00
|
|
|
}
|
2014-09-12 16:19:24 +00:00
|
|
|
|
2013-06-28 11:16:55 +00:00
|
|
|
- httpAddrFreeList(addrlist);
|
|
|
|
}
|
2013-04-04 14:50:25 +00:00
|
|
|
+ } else {
|
|
|
|
+ /*
|
|
|
|
+ * Use the IP address that responded...
|
|
|
|
+ */
|
2013-06-28 11:16:55 +00:00
|
|
|
+
|
2013-04-04 14:50:25 +00:00
|
|
|
+ avahi_address_snprint (fqdn, sizeof (fqdn), address);
|
|
|
|
+ hostTarget = fqdn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|