Great!
I really need this feature.
BTW I tried implementing something, but I'm not that much familiar with the
avahi internals.
I'm attaching my patch. Basically I was able to transfer registered local
services into the cache without receiving a messages on the network.
Of course that is just one step. The cache needs to be kept up to date.
I used the following call to test:
avahi_server_add_service(server, group, 1, AVAHI_PROTO_UNSPEC,
AVAHI_PUBLISH_NO_ANNOUNCE, "My Service Name", "_daap._tcp", NULL, NULL,
7777, "foo", NULL);
I used avahi-0.6.21 source.
--Yavor
PS: I'll file a wishlist bug too.
On Feb 12, 2008 6:17 AM, Lennart Poettering <[EMAIL PROTECTED]> wrote:
> On Thu, 24.01.08 10:46, Yavor Goulishev ([EMAIL PROTECTED]) wrote:
>
> > Hi all,
> > I'm trying to register local only services.
> > The services should not be visible from other machines.
> >
> > I can do this with Bonjour by passing the interface index
> > kDNSServiceInterfaceIndexLocalOnly (-1) to the DNSServiceRegister
> function
> > call.
> >
> > Unfortunately I can't do this with Avahi. Passing -1 for the interface
> index
> > means unspecified.
> > Looking at the core code, this feature is not implemented.
> > Are there any plans for implementing it?
>
> Hmm, I wasn't aware of this feature of Bonjour. It might make sense to
> add this. Please file a wishlist bug on our BTS so I don't forget
> about this.
>
> I see no practical reason why we shouldn't implement something like this.
>
> > Is there any other way to register local only services with Avahi?
>
> Nope. We have some stuff to implement the inverse (i.e. not show local
> services), but I guess that doesn't help much..,
>
> Lennart
>
> --
> Lennart Poettering Red Hat, Inc.
> lennart [at] poettering [dot] net ICQ# 11060553
> http://0pointer.net/lennart/ GnuPG 0x1A015CC4
> _______________________________________________
> avahi mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/avahi
>
Index: entry.c
===================================================================
--- entry.c (revision 5067)
+++ entry.c (working copy)
@@ -52,6 +52,8 @@
#include "rr-util.h"
#include "domain-util.h"
+void avahi_transfer_zone_to_cache(AvahiServer * s);
+
static void transport_flags_from_domain(AvahiServer *s, AvahiPublishFlags
*flags, const char *domain) {
assert(flags);
assert(domain);
@@ -77,6 +79,8 @@
assert(s);
assert(e);
+ avahi_transfer_zone_to_cache(s);
+
avahi_goodbye_entry(s, e, 1, 1);
/* Remove from linked list */
@@ -563,6 +567,25 @@
return avahi_string_list_add_printf(strlst, AVAHI_SERVICE_COOKIE"=%u",
s->local_service_cookie);
}
+void avahi_transfer_zone_to_cache(AvahiServer * s)
+{
+ /* Major Assumptions:
+ - The index of the "lo" interface is always 1.
+ */
+ AvahiAddress a;
+ avahi_address_parse("127.0.0.1", AVAHI_PROTO_INET, &a);
+ AvahiInterface * i = avahi_interface_monitor_get_interface(s->monitor, 1,
AVAHI_PROTO_INET);
+
+ AvahiEntry *e;
+ avahi_cache_flush(i->cache);
+ for (e = s->entries; e; e = e->entries_next) {
+ if (e->dead) {
+ continue;
+ }
+ avahi_cache_update(i->cache, e->record, 1, &a);
+ }
+}
+
static int server_add_service_strlst_nocopy(
AvahiServer *s,
AvahiSEntryGroup *g,
@@ -665,6 +688,8 @@
goto fail;
}
+ avahi_transfer_zone_to_cache(s);
+
fail:
if (ret != AVAHI_OK && !(flags & AVAHI_PUBLISH_UPDATE)) {
if (srv_entry)
Index: probe-sched.c
===================================================================
--- probe-sched.c (revision 5067)
+++ probe-sched.c (working copy)
@@ -216,6 +216,8 @@
return 1;
}
+void avahi_transfer_zone_to_cache(AvahiServer * s);
+
static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) {
AvahiProbeJob *pj = data, *next;
AvahiProbeScheduler *s;
@@ -224,6 +226,8 @@
assert(pj);
s = pj->scheduler;
+
+ avahi_transfer_zone_to_cache(s->interface->monitor->server);
if (pj->done) {
/* Lets remove it from the history */
_______________________________________________
avahi mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/avahi