apple / cups

Apple CUPS Sources
https://www.cups.org
Apache License 2.0
1.93k stars 464 forks source link

Add avahi support #3066

Closed michaelrsweet closed 12 years ago

michaelrsweet commented 15 years ago

Version: 1.6-feature CUPS.org User: twaugh.redhat

I'm in the process of adding support for Avahi, an implementation of mDNS/DNS-SD.

It is not yet complete, but seems to be working for at least the dnssd backend.

I'm attaching a patch for review, to see if I'm heading in the right direction before continuing on with the scheduler.

michaelrsweet commented 15 years ago

CUPS.org User: mike

The changes still need to conform to the CUPS coding standards (mainly comments are missing), and I'd rather make the code HAVE_AVAHI or HAVE_DNSSD (but only one gets defined). We can worry about adding configure options to choose which implementation to use at the end - some Linux distros come with mDNSResponder instead of Avahi.

I think you are going to have serious problems implementing Avahi in the scheduler since it is so tightly coupled to glib (or that's how it looked when I investigated adding "native" Avahi support last year), and the lack of documentation on the low-level interfaces that don't depend on glib (which is probably what you'll need to use) won't help either.

Finally, the source changes will be large enough we'll probably need a copyright assignment or at least a licensing to Apple to keep the CUPS sources (legally) clean.

Moving to -feature for now; if we end up with a complete implementation before 1.4.0 is released and have any legal issues resolved, it can go in 1.4.x, otherwise probably 1.5.x.

michaelrsweet commented 15 years ago

CUPS.org User: martin.pitt.canonical

Please note that this

causes the test suite to fail when being run without a running system D-BUS instance:

FAIL: 20 error messages, expected 18. [...] E [25/Aug/2009:16:17:48.540155 +0000] [CGI] Unable to create avahi client: No such file or directory E [25/Aug/2009:16:17:48.540492 +0000] [cups-deviced] PID 22335 (dnssd) stopped with status 1!

This is usually the case when calling "make check" during package build on build servers. It's usually a great idea to enable the tests during package build to catch regressions on particular architectures or from underlying libraries, so I wouldn't like to lose this feature. Perhaps this can be toned down to a mere printf() to stdout (for debugging), and exit cleanly?

michaelrsweet commented 15 years ago

CUPS.org User: martin.pitt.canonical

Just for the records, this is what avahi_client_new() tries:

connect(5, {sa_family=AF_FILE, path="/var/run/dbus/system_bus_socket"}, 33) = -1 ENOENT (No such file or directory)

Slightly altering the code snippet to

keeps the test suite happy. Would this be acceptable?

michaelrsweet commented 15 years ago

CUPS.org User: twaugh.redhat

It's the avahi equivalent of this:

if (DNSServiceCreateConnection(&main_ref) != kDNSServiceErr_NoError) { perror("ERROR: Unable to create service connection"); return (1); }

So if one has to change, the other also has to change.

michaelrsweet commented 14 years ago

CUPS.org User: Spudd86

might I suggest using pkg-config to detect avahi rather than AC_CHECK_HEADER

so you do like this instead:

PKG_CHECK_MODULES([AVAHI], [avahi-client]) AC_SUBST(AVAHI_CFLAGS) AC_SUBST(AVAHI_LIBS)

(with changes to make stuff work... but that's the idea)

michaelrsweet commented 14 years ago

CUPS.org User: twaugh.redhat

Note that the current version of the patch is here:

http://cvs.fedoraproject.org/viewvc/devel/cups/cups-avahi.patch?view=markup

and that further work is required for Avahi support in the scheduler.

michaelrsweet commented 13 years ago

CUPS.org User: twaugh.redhat

Having implemented native Avahi support for branch-1.4, I've now split it up into separate functional pieces and have begun re-basing them to trunk.

There are 5 in total but I have not yet re-based the last of them. I'll attach the first 4 here.

michaelrsweet commented 13 years ago

CUPS.org User: twaugh.redhat

I've updated patch number 4 in the sequence (Avahi poll API implementation) to fix a resource leak during an error condition. Problem spotted using static code analysis.

michaelrsweet commented 13 years ago

CUPS.org User: mike

Pushing out pending licensing...

michaelrsweet commented 13 years ago

CUPS.org User: anybody

Has this been included in CUPS 1.5 ?

A presentation from April 2010 mentioned "Bonjour support: Full support for Avahi" as one of the changes for CUPS v1.5 (Source: https://www.linuxfoundation.org/sites/main/files/cups-openprinting-april-10.pdf), however upon release of the new version I couldn't really identify something in the changelog that made it clear to me whether this has been included or not.

Basically what I want to do is use AirPrint in Gentoo, and since Gentoo doesn't ship an Avahi-patched-CUPS-1.4 (like Ubuntu does) i'm stuck on the very old 1.3.x release... I was hoping that a "reintegration" of AVAHI would be part of CUPS 1.5 and would allow me to upgrade. Was I wrong about this?

michaelrsweet commented 13 years ago

CUPS.org User: mike

No, current CUPS 1.5 does NOT have Avahi support. We are waiting on legal issues to incorporate the code changes.

michaelrsweet commented 13 years ago

CUPS.org User: twaugh.redhat

Current patch set, with license updated, attached.

michaelrsweet commented 12 years ago

CUPS.org User: twaugh.redhat

Current patch set attached.

michaelrsweet commented 12 years ago

CUPS.org User: stoatwblr

FWIW these patches don't get used when compiling cups 1.5 on rhel6

I assumed it's the avahi-client reference in dnssd.m4 that's causing it but converting that to avahi-libs doesn't work either.

michaelrsweet commented 12 years ago

CUPS.org User: twaugh.redhat

Note that you need to run these commands after applying the patches:

aclocal -I config-scripts autoconf -I config-scripts

michaelrsweet commented 12 years ago

CUPS.org User: stoatwblr

Slightly further now - it's checking for avahi and then decides "no"

michaelrsweet commented 12 years ago

CUPS.org User: twaugh.redhat

Did you supply '--enable-avahi' to configure? For a working Avahi-patched CUPS build, take a look at how it is done in e.g. Fedora.

michaelrsweet commented 12 years ago

CUPS.org User: andyrtr

Can you please rebase the patch set for 1.5.1 release? thanks.

michaelrsweet commented 12 years ago

CUPS.org User: stoatwblr

Yes I did use the --enable-avahi flags. Will look more closely at the Fedora builds. Thanks.

michaelrsweet commented 12 years ago

CUPS.org User: stoatwblr

Tim: More RHELisms, I'm afraid:

aclocal -I config-scripts

/usr/share/aclocal/aalib.m4:12: warning: underquoted definition of AM_PATH_AALIB /usr/share/aclocal/aalib.m4:12: run info '(automake)Extending aclocal' /usr/share/aclocal/aalib.m4:12: or see http://sources.redhat.com/automake/automake.html#Extending-aclocal

Also, would you mind looking at what's needed to rebase to 1.5.2?

michaelrsweet commented 12 years ago

CUPS.org User: twaugh.redhat

stoatwblr: I'm not sure what you mean. The warnings you are seeing are from a mistake in the aalib m4 macros -- they have no bearing on CUPS or Avahi, and are not responsible for any issues you may be seeing.

I've merged upstream cups changes into my patch set, for which a git repository can be obtained as follows: git clone http://twaugh.fedorapeople.org/cups-avahi.git

The separate parts of the Avahi support are available as patches here: http://twaugh.fedorapeople.org/cups-avahi/

Michael, is there any possibility that these patches will be merged into the CUPS source soon? I also have patches for trunk (although they are missing the needed libcups changes).. but I think Avahi support was targeted for 1.5 in any case.

michaelrsweet commented 12 years ago

CUPS.org User: mike

OK, so I've started integrating this but the changes do not conform to the CUPS coding standards and break the existing mDNSResponder code...

michaelrsweet commented 12 years ago

CUPS.org User: mike

OK, I'm just getting back to this to finish up the work. I think there is a serious issue with the dnssd implementation as it is doing a RESOLVE to get the TXT record. That is really not a good idea as it forces most devices to their full power state.

What we want to use here is a QUERY to get the TXT record, which means using avahi_record_browser_new to get the TXT record type.

Geez the Avahi documentation is awful...

michaelrsweet commented 12 years ago

CUPS.org User: mike

Oh, and another side-effect of how this is currently implemented is that we will flood the network with resolves, which is also not good (will fail in many cases and is not nice since it can cause a DoS of the network...)

michaelrsweet commented 12 years ago

CUPS.org User: mike

The _httpResolveURI changes also needed to be re-worked. There was no timeout after 90 seconds, no initial lookup for the service in the .local domain, and no reporting of offline/online status. I am also concerned about the use of the IP address in the resolved URI since that is often a VPN address for wide-area Bonjour. Will do some more testing to see if the glibc NSS stuff is working in recent Linux distros, since that is what we really want (so the hostname information is preserved in HTTP requests...)

michaelrsweet commented 12 years ago

CUPS.org User: mike

OK, the resolve issue was caused by Fedora's default firewall settings (disables mDNS completely... sigh...)

michaelrsweet commented 12 years ago

CUPS.org User: mike

OK, resolution and discovery are now working properly. Working on the registration code now...

FWIW, Avahi has a bad bug in avahi_simple_poll_iterate where the timeout value is not used: http://avahi.org/ticket/364

I've worked around the bug in question by implementing a custom poll function that uses the desired timeout...

michaelrsweet commented 12 years ago

CUPS.org User: mike

OK, I've re-worked all of the DNS-SD functionality in cupsd; I have a few more things to change to properly support Avahi, but we are really close now...

michaelrsweet commented 12 years ago

CUPS.org User: mike

OK, trunk now has mostly complete Avahi support in r10417. The one remaining task is to add browsing to the new cupsEnumDests() API.

The implementation in the scheduler is significantly different than provided, using the avahi_threaded_poll() path to avoid introducing the whole timeout interface and more complications.

michaelrsweet commented 12 years ago

CUPS.org User: twaugh.redhat

Thanks!

michaelrsweet commented 12 years ago

CUPS.org User: andyrtr

New 1.5.3 release requires the cups-avahi-2-backend.patch rebased and maybe more changes. Can you please have a look?

Hunk #6 FAILED at 131. Hunk #7 FAILED at 145.

Thanks. -Andy ArchLinux

michaelrsweet commented 12 years ago

CUPS.org User: mike

This is complete as of r10470.

michaelrsweet commented 12 years ago

"cups-avahi-backend.patch":

diff --git a/backend/dnssd.c b/backend/dnssd.c index ec32bba..a5d7a1b 100644 --- a/backend/dnssd.c +++ b/backend/dnssd.c @@ -20,7 +20,8 @@

@@ -30,7 +31,18 @@

include "backend-private.h"

include <cups/array.h>

-#include +#ifdef HAVE_AVAHI +# include <avahi-client/client.h> +# include <avahi-client/lookup.h> +# include <avahi-common/address.h> +# include <avahi-common/simple-watch.h> +# include <avahi-common/domain.h> +# include <avahi-common/error.h> +typedef AvahiServiceBrowser _DNSServiceRef; +#define kDNSServiceMaxDomainName AVAHI_DOMAIN_NAME_MAX +#else +# include +#endif /_ Avahi */

/* @@ -49,7 +61,11 @@ typedef enum

typedef struct { +#ifdef HAVE_AVAHI

+#ifdef HAVE_AVAHI +/*

+#ifdef HAVE_AVAHI

@@ -238,11 +351,19 @@ main(int argc, /* I - Number of command-line args */ } else {

+#ifndef HAVEAVAHI DNSServiceErrorType status; /* DNS query status / +#endif /_ !HAVEAVAHI / cups_devicet *best; / Best matching device _/ char deviceuri[1024]; / Device URI / int count; / Number of queries / @@ -255,6 +376,7 @@ main(int argc, / I - Number of command-line args _/ best = NULL, count = 0; device; device = (cups_device_t )cupsArrayNext(devices)) +#ifndef HAVEAVAHI if (!device->ref && !device->sent) { / @@ -283,23 +405,36 @@ main(int argc, /* I - Number of command-line args / count ++; } }

+#ifdef HAVE_AVAHI +static void +avahi_client_callback(

+#ifdef HAVE_AVAHI

+#ifndef HAVE_AVAHI /*

- priority[256]; /* Priority */

- &valueLen);

- value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MODEL", &valueLen);

@@ -797,6 +1125,35 @@ unquote(char dst, / I - Destination buffer */ }

+static int +device_type (const char *regtype) +{ +#ifdef HAVE_AVAHI

michaelrsweet commented 12 years ago

"0001-New-enable-avahi-configure-option.patch":

From d948ecde8d30db6fbf5688d9caf2592c7c09577d Mon Sep 17 00:00:00 2001 From: Tim Waugh twaugh@redhat.com Date: Tue, 4 Jan 2011 15:26:26 +0000 Subject: [PATCH 1/4] New --enable-avahi configure option.

Currently has no effect.

config-scripts/cups-dnssd.m4 | 15 +++++++++++++++ config.h.in | 7 +++++++ 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/config-scripts/cups-dnssd.m4 b/config-scripts/cups-dnssd.m4 index 0f582fc..48fb7ab 100644 --- a/config-scripts/cups-dnssd.m4 +++ b/config-scripts/cups-dnssd.m4 @@ -27,6 +27,21 @@ AC_ARG_WITH(dnssd-includes, [ --with-dnssd-includes set directory for DNS Ser DNSSDLIBS="" DNSSD_BACKEND=""

+AC_ARG_ENABLE(avahi, [ --enable-avahi turn on DNS Service Discovery support, default=no],

1.7.3.4

michaelrsweet commented 12 years ago

"0002-Avahi-support-in-the-dnssd-backend.patch":

From 5e72ac0b42633facc875ab46d1601b59aed60d13 Mon Sep 17 00:00:00 2001 From: Tim Waugh twaugh@redhat.com Date: Wed, 29 Jul 2009 13:45:35 +0100 Subject: [PATCH 2/4] Avahi support in the dnssd backend.


backend/dnssd.c | 580 +++++++++++++++++++++++++++++++++++++++++++------- cups/http-support.c | 191 +++++++++++++++++- 2 files changed, 687 insertions(+), 84 deletions(-)

diff --git a/backend/dnssd.c b/backend/dnssd.c index 57ecc6c..8e08271 100644 --- a/backend/dnssd.c +++ b/backend/dnssd.c @@ -15,14 +15,21 @@ *

+typedef struct +{

+#ifdef HAVE_DNSSD static void browse_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, @@ -92,12 +130,6 @@ static void browse_local_callback(DNSServiceRef sdRef, const char _regtype, const char replyDomain, void context); -static int compare_devices(cups_device_t a, cups_device_t b); -static void exec_backend(char _argv); -static cups_device_t get_device(cups_array_t *devices,

+#ifdef HAVE_AVAHI +static AvahiSimplePoll _simple_poll = NULL; +static int avahi_gotcallback; +#endif / HAVEAVAHI / + + +/_

+#ifdef HAVE_AVAHI

@@ -272,11 +466,35 @@ main(int argc, /* I - Number of command-line args */ } else {

+#ifdef HAVEDNSSD DNSServiceErrorType status; /* DNS query status / +#endif /_ HAVEDNSSD / cups_devicet *best; / Best matching device _/ char deviceuri[1024]; / Device URI / int count; / Number of queries / @@ -286,6 +504,7 @@ main(int argc, / I - Number of command-line args _/ best = NULL, count = 0; device; device = (cups_device_t )cupsArrayNext(devices)) +#ifdef HAVEDNSSD if (!device->ref && !device->sent) { / @@ -314,14 +533,23 @@ main(int argc, /* I - Number of command-line args / count ++; } }

+#ifdef HAVE_DNSSD /*

@@ -551,18 +812,7 @@ get_device(cups_array_t devices, / I - Device array / /

key.name = (char *)serviceName;

+#ifdef HAVE_DNSSD DNSServiceConstructFullName(fullName, device->name, regtype, replyDomain); +#else /* HAVE_AVAHI */

@@ -610,13 +869,20 @@ get_device(cups_array_t devices, / I - Device array */

+#ifdef HAVE_DNSSD DNSServiceConstructFullName(fullName, serviceName, regtype, replyDomain); +#else /* HAVE_AVAHI */

+#ifdef HAVE_DNSSD /*

- device_id[2048];/* 1284 device ID */

- */

- datalen = *data++;

- datanext = data + datalen;

- *ptr = '\0';

- data ++;

/*

+#ifdef HAVE_AVAHI +static void avahi_resolve_uri_client_cb(AvahiClient *client,

+#ifdef HAVE_DNSSD uribuf.buffer = resolved_uri; uribuf.bufsize = resolved_size; +#else

@@ -1447,6 +1493,7 @@ _httpResolveURI(

 uri = NULL;

+#ifdef HAVE_DNSSD if (DNSServiceCreateConnection(&ref) == kDNSServiceErr_NoError) { localref = ref; @@ -1545,6 +1592,36 @@ _httpResolveURI(

   DNSServiceRefDeallocate(ref);
 }

+#else /* HAVE_AVAHI */

-#else +#else /* HAVE_DNSSD || HAVEAVAHI / /_ * No DNS-SD support... */

 uri = NULL;

-#endif /* HAVEDNSSD / +#endif /_ HAVE_DNSSD || HAVE_AVAHI */

 if (logit && !uri)
   _cupsLangPrintFilter(stderr, "ERROR", _("Unable to find printer."));

@@ -1768,6 +1845,116 @@ resolve_callback(

endif /* HAVE_DNSSD */

+#ifdef HAVE_AVAHI +/*

michaelrsweet commented 12 years ago

"0003-Timed-callback-support-needed-for-Avahi.patch":

From cf80621258dfff7dad567ddb34ac042e9c59ade6 Mon Sep 17 00:00:00 2001 From: Tim Waugh twaugh@redhat.com Date: Tue, 21 Dec 2010 17:25:24 +0000 Subject: [PATCH 3/4] Timed callback support, needed for Avahi.


scheduler/Makefile | 3 +- scheduler/cupsd.h | 26 +++++++ scheduler/main.c | 39 ++++++++++ scheduler/timeout.c | 195 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 262 insertions(+), 1 deletions(-) create mode 100644 scheduler/timeout.c

diff --git a/scheduler/Makefile b/scheduler/Makefile index 0decf8f..688d564 100644 --- a/scheduler/Makefile +++ b/scheduler/Makefile @@ -39,7 +39,8 @@ CUPSDOBJS = \ server.o \ statbuf.o \ subscriptions.o \

+#ifdef HAVE_AVAHI +/*

+#ifdef HAVE_AVAHI +VAR cups_array_t Timeouts; / Timed callbacks for main loop / +#endif / HAVE_AVAHI */ + +

/*

+#ifdef HAVE_AVAHI +extern void cupsdInitTimeouts(void); +extern cupsd_timeout_t cupsdAddTimeout (const struct timeval tv,

diff --git a/scheduler/main.c b/scheduler/main.c index a19409e..798561d 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -153,6 +153,10 @@ main(int argc, /* I - Number of command-line args _/ int launchd_idleexit; / Idle exit on select timeout? _/

endif /_ HAVE_LAUNCHD */

+#ifdef HAVE_AVAHI

+#ifdef HAVE_AVAHI

+#ifdef HAVE_AVAHI

+#ifdef HAVE_AVAHI

+ */

1.7.3.4

michaelrsweet commented 12 years ago

"0004-Avahi-poll-API-implementation.patch":

From 6e0fe12e81d7f88b2d07924d6d1aed42d62bb89d Mon Sep 17 00:00:00 2001 From: Tim Waugh twaugh@redhat.com Date: Tue, 4 Jan 2011 16:12:00 +0000 Subject: [PATCH 4/4] Avahi poll API implementation.


scheduler/Makefile | 1 + scheduler/avahi.c | 443 ++++++++++++++++++++++++++++++++++++++++++++++++++++ scheduler/avahi.h | 49 ++++++ 3 files changed, 493 insertions(+), 0 deletions(-) create mode 100644 scheduler/avahi.c create mode 100644 scheduler/avahi.h

diff --git a/scheduler/Makefile b/scheduler/Makefile index 688d564..56e7df3 100644 --- a/scheduler/Makefile +++ b/scheduler/Makefile @@ -17,6 +17,7 @@ include ../Makedefs

CUPSDOBJS = \ auth.o \

+ */

1.7.3.4

michaelrsweet commented 12 years ago

"0004-Avahi-poll-API-implementation_v2.patch":

From 3aeafd44e8e0d5208e2ebdc65a2051942d766674 Mon Sep 17 00:00:00 2001 From: Tim Waugh twaugh@redhat.com Date: Tue, 4 Jan 2011 16:12:00 +0000 Subject: [PATCH 4/4] Avahi poll API implementation.


scheduler/Makefile | 1 + scheduler/avahi.c | 445 ++++++++++++++++++++++++++++++++++++++++++++++++++++ scheduler/avahi.h | 49 ++++++ 3 files changed, 495 insertions(+), 0 deletions(-) create mode 100644 scheduler/avahi.c create mode 100644 scheduler/avahi.h

diff --git a/scheduler/Makefile b/scheduler/Makefile index 81f8bab..b9a0149 100644 --- a/scheduler/Makefile +++ b/scheduler/Makefile @@ -17,6 +17,7 @@ include ../Makedefs

CUPSDOBJS = \ auth.o \

+ */

1.7.4

michaelrsweet commented 12 years ago

"cups-1-avahi-config.patch":

diff --git a/config-scripts/cups-dnssd.m4 b/config-scripts/cups-dnssd.m4 index 66a400b..5b17603 100644 --- a/config-scripts/cups-dnssd.m4 +++ b/config-scripts/cups-dnssd.m4 @@ -23,6 +23,21 @@ AC_ARG_WITH(dnssd-includes, [ --with-dnssd-includes set directory for DNS Ser DNSSDLIBS="" DNSSD_BACKEND=""

+AC_ARG_ENABLE(avahi, [ --enable-avahi turn on DNS Service Discovery support, default=no],

michaelrsweet commented 12 years ago

"cups-2-avahi-backend.patch":

diff --git a/backend/dnssd.c b/backend/dnssd.c index d1392ed..a35a9cc 100644 --- a/backend/dnssd.c +++ b/backend/dnssd.c @@ -15,14 +15,21 @@ *

+typedef struct +{

+#ifdef HAVE_DNSSD static void browse_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, @@ -93,12 +131,6 @@ static void browse_local_callback(DNSServiceRef sdRef, const char _regtype, const char replyDomain, void context); -static int compare_devices(cups_device_t a, cups_device_t b); -static void exec_backend(char _argv); -static cups_device_t get_device(cups_array_t *devices,

+#ifdef HAVE_AVAHI +static AvahiSimplePoll _simple_poll = NULL; +static int avahi_gotcallback; +#endif / HAVEAVAHI / + + +/_

+#ifdef HAVE_AVAHI

@@ -284,11 +478,35 @@ main(int argc, /* I - Number of command-line args */ } else {

+#ifdef HAVEDNSSD DNSServiceErrorType status; /* DNS query status / +#endif /_ HAVEDNSSD / cups_devicet *best; / Best matching device _/ char deviceuri[1024]; / Device URI / int count; / Number of queries / @@ -302,6 +520,7 @@ main(int argc, / I - Number of command-line args */ if (device->sent) sent ++;

+#ifdef HAVE_DNSSD if (device->ref) count ++;

@@ -333,14 +552,23 @@ main(int argc, /* I - Number of command-line args */ count ++; } }

+#ifdef HAVE_DNSSD /*

@@ -589,20 +854,7 @@ get_device(cups_array_t devices, / I - Device array / /

key.name = (char *)serviceName;

+#ifdef HAVE_DNSSD DNSServiceConstructFullName(fullName, device->name, regtype, replyDomain); +#else /* HAVE_AVAHI */

@@ -650,13 +911,20 @@ get_device(cups_array_t devices, / I - Device array */

+#ifdef HAVE_DNSSD DNSServiceConstructFullName(fullName, serviceName, regtype, replyDomain); +#else /* HAVE_AVAHI */

+#ifdef HAVE_DNSSD /*

- device_id[2048];/* 1284 device ID */

- break;

- datanext = data + datalen;

- *ptr = '\0';

- data ++;

- value[datanext - data] = '\0';

- }

/*

+#ifdef HAVE_AVAHI +static void avahi_resolve_uri_client_cb(AvahiClient *client,

+#ifdef HAVE_DNSSD uribuf.buffer = resolved_uri; uribuf.bufsize = resolved_size; uribuf.options = options; +#else

+#ifdef HAVE_DNSSD if (DNSServiceCreateConnection(&ref) == kDNSServiceErr_NoError) { localref = ref; @@ -1608,6 +1657,36 @@ _httpResolveURI(

   DNSServiceRefDeallocate(ref);
 }

+#else /* HAVE_AVAHI */

-#else +#else /* HAVE_DNSSD || HAVEAVAHI / /_ * No DNS-SD support... */

 uri = NULL;

-#endif /* HAVEDNSSD / +#endif /_ HAVE_DNSSD || HAVE_AVAHI */

 if ((options & _HTTP_RESOLVE_STDERR) && !uri)
   _cupsLangPrintFilter(stderr, "ERROR", _("Unable to find printer."));

@@ -1895,6 +1974,116 @@ http_resolve_cb(

endif /* HAVE_DNSSD */

+#ifdef HAVE_AVAHI +/*

michaelrsweet commented 12 years ago

"cups-3-timeouts.patch":

diff --git a/scheduler/Makefile b/scheduler/Makefile index 3c7da8e..7b4d05b 100644 --- a/scheduler/Makefile +++ b/scheduler/Makefile @@ -39,7 +39,8 @@ CUPSDOBJS = \ server.o \ statbuf.o \ subscriptions.o \

+#ifdef HAVE_AVAHI +/*

+#ifdef HAVE_AVAHI +VAR cups_array_t Timeouts; / Timed callbacks for main loop / +#endif / HAVE_AVAHI */ + +

/*

+#ifdef HAVE_AVAHI +extern void cupsdInitTimeouts(void); +extern cupsd_timeout_t cupsdAddTimeout (const struct timeval tv,

+#ifdef HAVE_AVAHI

+#ifdef HAVE_AVAHI

+#ifdef HAVE_AVAHI

michaelrsweet commented 12 years ago

"cups-4-avahi-poll.patch":

diff --git a/scheduler/Makefile b/scheduler/Makefile index 7b4d05b..63b5123 100644 --- a/scheduler/Makefile +++ b/scheduler/Makefile @@ -17,6 +17,7 @@ include ../Makedefs

CUPSDOBJS = \ auth.o \

michaelrsweet commented 12 years ago

"cups-5-avahi-services.patch":

diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c index 99b8e7b..2688eff 100644 --- a/cgi-bin/admin.c +++ b/cgi-bin/admin.c @@ -1643,7 +1643,7 @@ do_config_server(http_t http) / I - HTTP connection */ else local_protocols[0] = '\0';

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) if (cgiGetVariable("BROWSE_LOCAL_DNSSD")) { if (local_protocols[0]) @@ -1651,7 +1651,7 @@ do_config_server(http_t http) / I - HTTP connection _/ else strcat(localprotocols, "dnssd"); } -#endif / HAVEDNSSD / +#endif /_ defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */

ifdef HAVE_LDAP

   if (cgiGetVariable("BROWSE_LOCAL_LDAP"))

@@ -2718,9 +2718,9 @@ do_menu(http_t http) / I - HTTP connection _/

endif /_ HAVE_GSSAPI */

cgiSetVariable("KERBEROS", "");

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) cgiSetVariable("HAVE_DNSSD", "1"); -#endif /* HAVEDNSSD / +#endif /_ defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */

ifdef HAVE_LDAP

cgiSetVariable("HAVE_LDAP", "1"); diff --git a/scheduler/client.c b/scheduler/client.c index d5a5111..12ed881 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -4985,7 +4985,7 @@ valid_host(cupsd_client_t con) / I - Client connection */ !strncmp(host, "[::1]:", 6)); }

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) /*

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) cupsdSetString(&DNSSDRegType, "_ipp._tcp,_cups");

endif /* HAVE_DNSSD */

diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c index eb3c862..48dcef9 100644 --- a/scheduler/dirsvc.c +++ b/scheduler/dirsvc.c @@ -27,6 +27,7 @@

+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) +static cupsd_txt_record_t dnssdBuildTxtRecord(int txt_len, cupsd_printer_t p,

+#ifdef HAVE_AVAHI +static AvahiStringList avahiPackTxtRecord(char keyvalue[][2],

-#ifdef HAVE_DNSSD

@@ -702,10 +729,10 @@ cupsdRegisterPrinter(cupsd_printer_t p)/ I - Printer _/ slpRegisterPrinter(p); */

endif /_ HAVE_LIBSLP */

-#ifdef HAVE_DNSSD

@@ -1419,6 +1446,27 @@ ldap_disconnect(LDAP ld) / I - LDAP handle _/

endif /_ HAVE_LDAP */

+#ifdef HAVE_AVAHI +/*

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_DNSSD) { +#ifdef HAVEDNSSD DNSServiceErrorType error; /* Error from service creation / +#endif /_ HAVEDNSSD / cupsd_listenert *lis; / Current listening socket */

+#ifdef HAVE_DNSSD / * First create a "master" connection for all registrations... / @@ -1573,6 +1624,7 @@ cupsdStartBrowsing(void) fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);

   cupsdAddSelect(fd, (cupsd_selfunc_t)dnssdUpdate, NULL, NULL);

+#endif /* HAVE_DNSSD */

  /*
   * Then get the port we use for registrations.  If we are not listening

@@ -1606,9 +1658,16 @@ cupsdStartBrowsing(void) */

   cupsdUpdateDNSSDName();

+ +#ifdef HAVE_AVAHI

-#ifdef HAVE_DNSSD

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) /*

+#ifdef HAVE_DNSSD if (WebIFRef) DNSServiceRefDeallocate(WebIFRef);

@@ -2054,9 +2120,45 @@ cupsdUpdateDNSSDName(void) NULL)) != kDNSServiceErr_NoError) cupsdLogMessage(CUPSD_LOG_ERROR, "DNS-SD web interface registration failed: %d", error); +#endif /* HAVE_DNSSD */ + +#ifdef HAVE_AVAHI

+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) /*

-static char * /* O - TXT record _/ +static cupsd_txt_recordt / O - TXT record _/ dnssdBuildTxtRecord( int txtlen, / O - TXT record length _/ cupsd_printer_t p, /_ I - Printer information */ @@ -2379,7 +2483,12 @@ dnssdBuildTxtRecord( keyvalue[i ][0] = "ty"; keyvalue[i++][1] = p->make_model ? p->make_model : "Unknown";

+#ifdef HAVE_DNSSD return (dnssdPackTxtRecord(txt_len, keyvalue, i)); +#endif /* HAVE_DNSSD */ +#ifdef HAVE_AVAHI

@@ -2474,7 +2588,16 @@ static int /* O - Result of comparison _/ dnssdComparePrinters(cupsd_printert *a,/ I - First printer _/ cupsd_printert *b)/ I - Second printer */ {

@@ -2489,6 +2612,10 @@ dnssdDeregisterPrinter( { cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdDeregisterPrinter(%s)", p->name);

+#ifdef HAVE_DNSSD

+#ifdef HAVE_DNSSD /*

+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) /*

+#ifdef HAVE_DNSSD

@@ -2712,6 +2905,7 @@ dnssdRegisterPrinter(cupsd_printer_t p)/ I - Printer */

+#ifdef HAVE_DNSSD ipp_len = 0; /* anti-compiler-warning-code */ ipp_txt = dnssdBuildTxtRecord(&ipp_len, p, 0);

@@ -2884,6 +3078,209 @@ dnssdRegisterPrinter(cupsd_printer_t p)/ I - Printer */

if (printer_txt) free(printer_txt); +#endif /* HAVE_DNSSD */ +#ifdef HAVE_AVAHI

@@ -2896,6 +3293,10 @@ dnssdStop(void) { cupsd_printer_t p; / Current printer */

+#ifdef HAVE_DNSSD

+#ifdef HAVE_DNSSD /*

+#ifdef HAVE_DNSSD /*

+#ifdef HAVE_AVAHI +/*

+#ifdef HAVE_AVAHI +# include <avahi-client/publish.h> +#endif /* HAVEAVAHI / + /_

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) VAR char DNSSDComputerName VALUE(NULL), / Computer/server name / *DNSSDHostName VALUE(NULL), / Hostname / *DNSSDRegType VALUE(NULL); / Bonjour registration type / -VAR cups_array_t DNSSDAlias VALUE(NULL);

+#ifdef HAVE_AVAHI +VAR AvahiCupsPoll *AvahiCupsPollHandle VALUE(NULL);

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) if (!ra || cupsArrayFind(ra, "printer-dns-sd-name")) { if (printer->reg_name) @@ -6097,7 +6097,7 @@ copy_printer_attrs( ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_NOVALUE, "printer-dns-sd-name", 0); } -#endif /* HAVEDNSSD / +#endif /_ defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */

if (!ra || cupsArrayFind(ra, "printer-error-policy")) ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAGNAME, diff --git a/scheduler/main.c b/scheduler/main.c index 1e60572..6c210e6 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -120,6 +120,10 @@ main(int argc, /* I - Number of command-line args / cupsd_listenert *lis; / Current listener _/ time_t currenttime, / Current time / activity, / Client activity timer */ +#ifdef HAVE_AVAHI

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) cupsdClearString(&p->pdl); -#endif /* HAVEDNSSD / +#endif /_ defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */

cupsArrayDelete(p->filetypes);

@@ -3765,7 +3765,7 @@ add_printer_formats(cupsd_printer_t p) / I - Printer */ attr->values[i].string.text = _cupsStrAlloc(mimetype); }

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVEAVAHI) { char pdl[1024]; /* Buffer to build pdl list / mime_filtert *filter; / MIME filter looping var _/ @@ -3821,7 +3821,7 @@ add_printer_formats(cupsd_printert *p) / I - Printer */

 cupsdSetString(&p->pdl, pdl);

} -#endif /* HAVEDNSSD / +#endif /_ defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ }

diff --git a/scheduler/printers.h b/scheduler/printers.h index 1751578..fb04651 100644 --- a/scheduler/printers.h +++ b/scheduler/printers.h @@ -16,6 +16,9 @@

ifdef HAVE_DNSSD

include

endif /* HAVEDNSSD /

+#ifdef HAVEAVAHI +# include "avahi.h" +#endif / HAVE_AVAHI */

include <cups/pwg-private.h>

@@ -95,16 +98,23 @@ struct cupsd_printer_s time_t markertime; /* Last time marker attributes were updated / _ppd_cachet *pc; / PPD cache and mapping data */

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) char _regname, / Name used for service registration */

michaelrsweet commented 12 years ago

"cups-avahi-1-config.patch":

diff -up cups-1.5.0/config.h.in.avahi-1-config cups-1.5.0/config.h.in --- cups-1.5.0/config.h.in.avahi-1-config 2011-06-16 21:12:16.000000000 +0100 +++ cups-1.5.0/config.h.in 2011-08-05 15:04:09.535759988 +0100 @@ -390,6 +390,13 @@

/*

diff -up cups-1.5.0/config-scripts/cups-dnssd.m4.avahi-1-config cups-1.5.0/config-scripts/cups-dnssd.m4 --- cups-1.5.0/config-scripts/cups-dnssd.m4.avahi-1-config 2011-05-12 06:21:56.000000000 +0100 +++ cups-1.5.0/config-scripts/cups-dnssd.m4 2011-08-05 15:04:09.525760307 +0100 @@ -23,6 +23,21 @@ AC_ARG_WITH(dnssd-includes, [ --with-dn DNSSDLIBS="" DNSSD_BACKEND=""

+AC_ARG_ENABLE(avahi, [ --enable-avahi turn on DNS Service Discovery support, default=no],

michaelrsweet commented 12 years ago

"cups-avahi-2-backend.patch":

diff -up cups-1.5.0/backend/dnssd.c.avahi-2-backend cups-1.5.0/backend/dnssd.c --- cups-1.5.0/backend/dnssd.c.avahi-2-backend 2011-08-05 15:04:46.182591844 +0100 +++ cups-1.5.0/backend/dnssd.c 2011-08-05 15:05:13.868710181 +0100 @@ -15,14 +15,21 @@ *

+typedef struct +{

+#ifdef HAVE_DNSSD static void browse_callback(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, @@ -93,12 +131,6 @@ static void browse_local_callback(DNSSe const char _regtype, const char replyDomain, void context); -static int compare_devices(cups_device_t a, cups_device_t b); -static void exec_backend(char _argv); -static cups_device_t get_device(cups_array_t *devices,

+#ifdef HAVE_AVAHI +static AvahiSimplePoll _simple_poll = NULL; +static int avahi_gotcallback; +#endif / HAVEAVAHI / + + +/_

+#ifdef HAVE_AVAHI

@@ -284,11 +478,35 @@ main(int argc, /* I - Number of comm } else {

+#ifdef HAVEDNSSD DNSServiceErrorType status; /* DNS query status / +#endif /_ HAVEDNSSD / cups_devicet *best; / Best matching device _/ char deviceuri[1024]; / Device URI / int count; / Number of queries / @@ -302,6 +520,7 @@ main(int argc, / I - Number of comm if (device->sent) sent ++;

+#ifdef HAVE_DNSSD if (device->ref) count ++;

@@ -333,14 +552,23 @@ main(int argc, /* I - Number of comm count ++; } }

+#ifdef HAVE_DNSSD /*

@@ -589,20 +854,7 @@ get_device(cups_array_t devices, / I - */

key.name = (char *)serviceName;

+#ifdef HAVE_DNSSD DNSServiceConstructFullName(fullName, device->name, regtype, replyDomain); +#else /* HAVE_AVAHI */

@@ -650,13 +911,20 @@ get_device(cups_array_t devices, / I -

+#ifdef HAVE_DNSSD DNSServiceConstructFullName(fullName, serviceName, regtype, replyDomain); +#else /* HAVE_AVAHI */

+#ifdef HAVE_DNSSD /*

- device_id[2048];/* 1284 device ID */

- */

- datalen = *data++;

- break;

- datanext = data + datalen;

- data ++;

- }

/*

+#ifdef HAVE_AVAHI +static void avahi_resolve_uri_client_cb(AvahiClient *client,

+#ifdef HAVE_DNSSD uribuf.buffer = resolved_uri; uribuf.bufsize = resolved_size; uribuf.options = options; +#else

+#ifdef HAVE_DNSSD if (DNSServiceCreateConnection(&ref) == kDNSServiceErr_NoError) { localref = ref; @@ -1608,6 +1657,36 @@ _httpResolveURI(

   DNSServiceRefDeallocate(ref);
 }

+#else /* HAVE_AVAHI */

-#else +#else /* HAVE_DNSSD || HAVEAVAHI / /_ * No DNS-SD support... */

 uri = NULL;

-#endif /* HAVEDNSSD / +#endif /_ HAVE_DNSSD || HAVE_AVAHI */

 if ((options & _HTTP_RESOLVE_STDERR) && !uri)
   _cupsLangPrintFilter(stderr, "ERROR", _("Unable to find printer."));

@@ -1895,6 +1974,116 @@ http_resolve_cb(

endif /* HAVE_DNSSD */

+#ifdef HAVE_AVAHI +/*

michaelrsweet commented 12 years ago

"cups-avahi-3-timeouts.patch":

diff -up cups-1.5.0/scheduler/cupsd.h.avahi-3-timeouts cups-1.5.0/scheduler/cupsd.h --- cups-1.5.0/scheduler/cupsd.h.avahi-3-timeouts 2011-05-11 23:17:34.000000000 +0100 +++ cups-1.5.0/scheduler/cupsd.h 2011-10-07 13:20:41.522867324 +0100 @@ -140,6 +140,15 @@ extern const char *cups_hstrerror(int);

typedef void (cupsd_selfunc_t)(void data);

+#ifdef HAVE_AVAHI +/*

+#ifdef HAVE_AVAHI +VAR cups_array_t Timeouts; / Timed callbacks for main loop / +#endif / HAVE_AVAHI */ + +

/*

+#ifdef HAVE_AVAHI +extern void cupsdInitTimeouts(void); +extern cupsd_timeout_t cupsdAddTimeout (const struct timeval tv,

+#ifdef HAVE_AVAHI

+#ifdef HAVE_AVAHI

+#ifdef HAVE_AVAHI

michaelrsweet commented 12 years ago

"cups-avahi-4-poll.patch":

diff -up cups-1.5.0/scheduler/avahi.c.avahi-4-poll cups-1.5.0/scheduler/avahi.c --- cups-1.5.0/scheduler/avahi.c.avahi-4-poll 2011-10-11 10:56:50.102288037 +0100 +++ cups-1.5.0/scheduler/avahi.c 2011-10-11 10:56:50.102288037 +0100 @@ -0,0 +1,441 @@ +/*

michaelrsweet commented 12 years ago

"cups-avahi-5-services.patch":

diff -up cups-1.5.0/cgi-bin/admin.c.avahi-5-services cups-1.5.0/cgi-bin/admin.c --- cups-1.5.0/cgi-bin/admin.c.avahi-5-services 2011-05-20 04:49:49.000000000 +0100 +++ cups-1.5.0/cgi-bin/admin.c 2011-10-19 11:53:32.123177998 +0100 @@ -1643,7 +1643,7 @@ do_config_server(http_t http) / I - H else local_protocols[0] = '\0';

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) if (cgiGetVariable("BROWSE_LOCAL_DNSSD")) { if (local_protocols[0]) @@ -1651,7 +1651,7 @@ do_config_server(http_t http) / I - H else strcat(local_protocols, "dnssd"); } -#endif /* HAVEDNSSD / +#endif /_ defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */

ifdef HAVE_LDAP

   if (cgiGetVariable("BROWSE_LOCAL_LDAP"))

@@ -2718,9 +2718,9 @@ do_menu(http_t http) / I - HTTP conn

endif /* HAVE_GSSAPI */

cgiSetVariable("KERBEROS", "");

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) cgiSetVariable("HAVE_DNSSD", "1"); -#endif /* HAVEDNSSD / +#endif /_ defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */

ifdef HAVE_LDAP

cgiSetVariable("HAVE_LDAP", "1"); diff -up cups-1.5.0/scheduler/client.c.avahi-5-services cups-1.5.0/scheduler/client.c --- cups-1.5.0/scheduler/client.c.avahi-5-services 2011-06-10 22:16:18.000000000 +0100 +++ cups-1.5.0/scheduler/client.c 2011-10-19 11:53:32.127177926 +0100 @@ -4987,7 +4987,7 @@ valid_host(cupsd_client_t con) / I - !strncmp(host, "[::1]:", 6)); }

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) /*

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) cupsdSetString(&DNSSDRegType, "_ipp._tcp,_cups");

endif /* HAVE_DNSSD */

diff -up cups-1.5.0/scheduler/dirsvc.c.avahi-5-services cups-1.5.0/scheduler/dirsvc.c --- cups-1.5.0/scheduler/dirsvc.c.avahi-5-services 2011-10-19 11:53:32.011180075 +0100 +++ cups-1.5.0/scheduler/dirsvc.c 2011-10-19 11:53:58.916681461 +0100 @@ -27,6 +27,7 @@

+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) +static cupsd_txt_record_t dnssdBuildTxtRecord(int txt_len, cupsd_printer_t p,

+#ifdef HAVE_AVAHI +static AvahiStringList avahiPackTxtRecord(char keyvalue[][2],

-#ifdef HAVE_DNSSD

@@ -702,10 +727,10 @@ cupsdRegisterPrinter(cupsd_printer_t _p) slpRegisterPrinter(p); */

endif /_ HAVE_LIBSLP */

-#ifdef HAVE_DNSSD

@@ -1419,6 +1444,36 @@ ldap_disconnect(LDAP ld) / I - LDAP h

endif /* HAVE_LDAP */

+#ifdef HAVE_AVAHI +/*

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) if ((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_DNSSD) { +#ifdef HAVEDNSSD DNSServiceErrorType error; /* Error from service creation / +#endif /_ HAVEDNSSD / cupsd_listenert *lis; / Current listening socket */

+#ifdef HAVE_DNSSD / * First create a "master" connection for all registrations... / @@ -1573,6 +1631,7 @@ cupsdStartBrowsing(void) fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);

   cupsdAddSelect(fd, (cupsd_selfunc_t)dnssdUpdate, NULL, NULL);

+#endif /* HAVE_DNSSD */

  /*
   * Then get the port we use for registrations.  If we are not listening

@@ -1598,17 +1657,23 @@ cupsdStartBrowsing(void) */

   if (BrowseRemoteProtocols & BROWSE_DNSSD)

-#ifdef HAVE_DNSSD

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) /*

+#ifdef HAVE_DNSSD if (WebIFRef) DNSServiceRefDeallocate(WebIFRef);

@@ -2054,9 +2126,45 @@ cupsdUpdateDNSSDName(void) NULL)) != kDNSServiceErr_NoError) cupsdLogMessage(CUPSD_LOG_ERROR, "DNS-SD web interface registration failed: %d", error); +#endif /* HAVE_DNSSD */ + +#ifdef HAVE_AVAHI

+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) /*

-static char * /* O - TXT record _/ +static cupsd_txt_recordt / O - TXT record _/ dnssdBuildTxtRecord( int txtlen, / O - TXT record length _/ cupsd_printer_t p, /_ I - Printer information */ @@ -2379,7 +2489,12 @@ dnssdBuildTxtRecord( keyvalue[i ][0] = "ty"; keyvalue[i++][1] = p->make_model ? p->make_model : "Unknown";

+#ifdef HAVE_DNSSD return (dnssdPackTxtRecord(txt_len, keyvalue, i));

-}

-/*

- */

-static int /* O - Result of comparison _/ -dnssdComparePrinters(cupsd_printert *a,/ I - First printer */

@@ -2489,6 +2597,10 @@ dnssdDeregisterPrinter( { cupsdLogMessage(CUPSD_LOG_DEBUG2, "dnssdDeregisterPrinter(%s)", p->name);

+#ifdef HAVE_DNSSD

+#ifdef HAVE_DNSSD /*

+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) /*

+#ifdef HAVE_DNSSD

@@ -2712,6 +2890,7 @@ dnssdRegisterPrinter(cupsd_printer_t *p)

+#ifdef HAVE_DNSSD ipp_len = 0; /* anti-compiler-warning-code */ ipp_txt = dnssdBuildTxtRecord(&ipp_len, p, 0);

@@ -2884,6 +3063,209 @@ dnssdRegisterPrinter(cupsd_printer_t *p)

if (printer_txt) free(printer_txt); +#endif /* HAVE_DNSSD */ +#ifdef HAVE_AVAHI

@@ -2896,6 +3278,10 @@ dnssdStop(void) { cupsd_printer_t p; / Current printer */

+#ifdef HAVE_DNSSD

+#ifdef HAVE_DNSSD /*

+#ifdef HAVE_DNSSD /*

+#ifdef HAVE_AVAHI +/*

+#ifdef HAVE_AVAHI +# include <avahi-client/publish.h> +#endif /* HAVEAVAHI / + /_

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) VAR char DNSSDComputerName VALUE(NULL), / Computer/server name / *DNSSDHostName VALUE(NULL), / Hostname / *DNSSDRegType VALUE(NULL); / Bonjour registration type / -VAR cups_array_t DNSSDAlias VALUE(NULL);

+#ifdef HAVE_AVAHI +VAR AvahiCupsPoll *AvahiCupsPollHandle VALUE(NULL);

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) if (!ra || cupsArrayFind(ra, "printer-dns-sd-name")) { if (printer->reg_name) @@ -6106,7 +6106,7 @@ copy_printer_attrs( ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_NOVALUE, "printer-dns-sd-name", 0); } -#endif /* HAVEDNSSD / +#endif /_ defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */

if (!ra || cupsArrayFind(ra, "printer-error-policy")) ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_NAME, diff -up cups-1.5.0/scheduler/main.c.avahi-5-services cups-1.5.0/scheduler/main.c --- cups-1.5.0/scheduler/main.c.avahi-5-services 2011-10-19 11:53:32.101178406 +0100 +++ cups-1.5.0/scheduler/main.c 2011-10-19 11:53:32.151177479 +0100 @@ -120,6 +120,10 @@ main(int argc, /* I - Number of comm cupsd_listener_t lis; / Current listener _/ time_t currenttime, / Current time / activity, / Client activity timer */ +#ifdef HAVE_AVAHI

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) cupsdClearString(&p->pdl); -#endif /* HAVEDNSSD / +#endif /_ defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */

cupsArrayDelete(p->filetypes);

@@ -3787,7 +3787,7 @@ add_printer_formats(cupsd_printer_t *p) attr->values[i].string.text = _cupsStrAlloc(mimetype); }

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVEAVAHI) { char pdl[1024]; /* Buffer to build pdl list / mime_filtert *filter; / MIME filter looping var / @@ -3843,7 +3843,7 @@ add_printer_formats(cupsd_printer_t p)

 cupsdSetString(&p->pdl, pdl);

} -#endif /* HAVEDNSSD / +#endif /_ defined(HAVE_DNSSD) || defined(HAVE_AVAHI) */ }

diff -up cups-1.5.0/scheduler/printers.h.avahi-5-services cups-1.5.0/scheduler/printers.h --- cups-1.5.0/scheduler/printers.h.avahi-5-services 2011-03-18 18:42:46.000000000 +0000 +++ cups-1.5.0/scheduler/printers.h 2011-10-19 11:53:32.157177369 +0100 @@ -16,6 +16,9 @@

ifdef HAVE_DNSSD

include

endif /* HAVEDNSSD /

+#ifdef HAVEAVAHI +# include "avahi.h" +#endif / HAVE_AVAHI */

include <cups/pwg-private.h>

@@ -95,16 +98,23 @@ struct cupsd_printer_s time_t markertime; /* Last time marker attributes were updated / _ppd_cachet *pc; / PPD cache and mapping data */

-#ifdef HAVE_DNSSD +#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) char _regname, / Name used for service registration */