]> git.pld-linux.org Git - packages/cups.git/blame - cups-avahi-address.patch
more verbose files, so we can track what belongs to cups and what to cups-filters...
[packages/cups.git] / cups-avahi-address.patch
CommitLineData
3e1538e5
JR
1diff -up cups-1.6.2/cups/http-support.c.avahi-address cups-1.6.2/cups/http-support.c
2--- cups-1.6.2/cups/http-support.c.avahi-address 2013-03-11 18:44:36.000000000 +0000
3+++ cups-1.6.2/cups/http-support.c 2013-06-28 13:42:15.834715511 +0100
4@@ -2121,7 +2121,7 @@ http_resolve_cb(
5 const char *type, /* I - Registration type */
6 const char *domain, /* I - Domain (unused) */
7 const char *hostTarget, /* I - Hostname */
8- const AvahiAddress *address, /* I - Address (unused) */
9+ const AvahiAddress *address, /* I - Address */
10 uint16_t port, /* I - Port number */
11 AvahiStringList *txt, /* I - TXT record */
12 AvahiLookupResultFlags flags, /* I - Lookup flags (unused) */
13@@ -2248,41 +2248,59 @@ http_resolve_cb(
14 * getting the IP address of the .local name and then do reverse-lookups...
15 */
16
17- http_addrlist_t *addrlist, /* List of addresses */
18- *addr; /* Current address */
19+ http_addr_t addr;
20+ size_t addrlen;
21+ int error;
22
23 DEBUG_printf(("8http_resolve_cb: Looking up \"%s\".", hostTarget));
24
25- snprintf(fqdn, sizeof(fqdn), "%d", ntohs(port));
26- if ((addrlist = httpAddrGetList(hostTarget, AF_UNSPEC, fqdn)) != NULL)
27+ switch (address->proto)
28 {
29- for (addr = addrlist; addr; addr = addr->next)
30+ case AVAHI_PROTO_INET:
31+ addr.ipv4.sin_family = AF_INET;
32+ addrlen = sizeof (addr.ipv4.sin_addr);
33+ memcpy (&addr.ipv4.sin_addr, &address->data, addrlen);
34+ break;
35+ case AVAHI_PROTO_INET6:
36+ addr.ipv6.sin6_family = AF_INET6;
37+ addrlen = sizeof (addr.ipv6.sin6_addr);
38+ memcpy (&addr.ipv6.sin6_addr, &address->data, addrlen);
39+ break;
40+ default:
41+ DEBUG_printf(("8http_resolve_cb: unknown address family %d",
42+ address->proto));
43+ addrlen = 0;
44+ }
45+
46+ if (addrlen > 0) {
47+ error = getnameinfo(&addr.addr, httpAddrLength (&addr),
48+ fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
49+
50+ if (!error)
51 {
52- int error = getnameinfo(&(addr->addr.addr),
53- httpAddrLength(&(addr->addr)),
54- fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
55+ DEBUG_printf(("8http_resolve_cb: Found \"%s\".", fqdn));
56
57- if (!error)
58+ if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
59+ _cups_strcasecmp(hostptr, ".local"))
60 {
61- DEBUG_printf(("8http_resolve_cb: Found \"%s\".", fqdn));
62-
63- if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
64- _cups_strcasecmp(hostptr, ".local"))
65- {
66- hostTarget = fqdn;
67- break;
68- }
69+ hostTarget = fqdn;
70 }
71+ } else {
72+ avahi_address_snprint (fqdn, sizeof (fqdn), address);
73+ hostTarget = fqdn;
74 #ifdef DEBUG
75- else
76- DEBUG_printf(("8http_resolve_cb: \"%s\" did not resolve: %d",
77- httpAddrString(&(addr->addr), fqdn, sizeof(fqdn)),
78- error));
79+ DEBUG_printf(("8http_resolve_cb: \"%s\" did not resolve: %d",
80+ fqdn, error));
81 #endif /* DEBUG */
82 }
83-
84- httpAddrFreeList(addrlist);
85 }
86+ } else {
87+ /*
88+ * Use the IP address that responded...
89+ */
90+
91+ avahi_address_snprint (fqdn, sizeof (fqdn), address);
92+ hostTarget = fqdn;
93 }
94
95 /*
This page took 0.059401 seconds and 4 git commands to generate.