next_state(userdata);
}
-AvahiAnnouncer *avahi_get_announcer(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
+static AvahiAnnouncer *get_announcer(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
AvahiAnnouncer *a;
assert(s);
return;
/* We don't want duplicate announcers */
- if (avahi_get_announcer(s, e, i))
+ if (get_announcer(s, e, i))
return;
if ((!(a = avahi_new(AvahiAnnouncer, 1)))) {
assert(i);
assert(!e->dead);
- if (!(a = avahi_get_announcer(s, e, i)))
+ if (!(a = get_announcer(s, e, i)))
return 0;
return
assert(i);
assert(!e->dead);
- if (!(a = avahi_get_announcer(s, e, i)))
+ if (!(a = get_announcer(s, e, i)))
return 0;
/* avahi_log_debug("state: %i", a->state); */
assert(e);
assert(i);
- if (!(a = avahi_get_announcer(s, e, i)))
+ if (!(a = get_announcer(s, e, i)))
return;
if (a->state == AVAHI_PROBING && a->entry->group)
assert(e);
assert(!e->dead);
- if (!(a = avahi_get_announcer(m->server, e, i)))
+ if (!(a = get_announcer(m->server, e, i)))
return;
reannounce(a);
remove_announcer(s, e->announcers);
}
-void avahi_goodbye_all(AvahiServer *s, int send_goodbye, int remove) {
- AvahiEntry *e;
-
- assert(s);
-
- for (e = s->entries; e; e = e->entries_next)
- if (!e->dead)
- avahi_goodbye_entry(s, e, send_goodbye, remove);
-
-}
-
void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, int send_goodbye, int rem);
void avahi_goodbye_entry(AvahiServer *s, AvahiEntry *e, int send_goodbye, int rem);
-void avahi_goodbye_all(AvahiServer *s, int send_goodbye, int rem);
-
-AvahiAnnouncer *avahi_get_announcer(AvahiServer *s, AvahiEntry *e, AvahiInterface *i);
void avahi_reannounce_entry(AvahiServer *s, AvahiEntry *e);
#include <avahi-core/log.h>
#include <avahi-core/publish.h>
#include <avahi-core/lookup.h>
+#include <avahi-core/dns-srv-rr.h>
static AvahiSEntryGroup *group = NULL;
static AvahiServer *server = NULL;
*flags |= AVAHI_LOOKUP_USE_WIDE_AREA;
}
-
static AvahiSRBLookup* lookup_new(
AvahiSRecordBrowser *b,
AvahiIfIndex interface,
return NULL;
}
+static void browser_cancel(AvahiSRecordBrowser *b) {
+ assert(b);
+
+ if (b->root_lookup) {
+ lookup_unref(b->root_lookup);
+ b->root_lookup = NULL;
+ }
+
+ if (b->defer_time_event) {
+ avahi_time_event_free(b->defer_time_event);
+ b->defer_time_event = NULL;
+ }
+}
+
+
static void lookup_wide_area_callback(
AvahiWideAreaLookupEngine *e,
AvahiBrowserEvent event,
b->flags & AVAHI_LOOKUP_USE_WIDE_AREA ? AVAHI_LOOKUP_RESULT_WIDE_AREA : AVAHI_LOOKUP_RESULT_MULTICAST,
b->userdata);
- avahi_s_record_browser_cancel(b);
+ browser_cancel(b);
return;
}
assert(b);
assert(!b->dead);
- avahi_s_record_browser_cancel(b);
+ browser_cancel(b);
/* Request a new iteration of the cache scanning */
if (!b->defer_time_event) {
return b;
}
-void avahi_s_record_browser_cancel(AvahiSRecordBrowser *b) {
- assert(b);
-
- if (b->root_lookup) {
- lookup_unref(b->root_lookup);
- b->root_lookup = NULL;
- }
-
- if (b->defer_time_event) {
- avahi_time_event_free(b->defer_time_event);
- b->defer_time_event = NULL;
- }
-}
-
void avahi_s_record_browser_free(AvahiSRecordBrowser *b) {
assert(b);
assert(!b->dead);
b->dead = 1;
b->server->need_browser_cleanup = 1;
- avahi_s_record_browser_cancel(b);
+ browser_cancel(b);
}
void avahi_s_record_browser_destroy(AvahiSRecordBrowser *b) {
assert(b);
- avahi_s_record_browser_cancel(b);
+ browser_cancel(b);
AVAHI_LLIST_REMOVE(AvahiSRecordBrowser, browser, b->server->record_browsers, b);
void avahi_s_record_browser_destroy(AvahiSRecordBrowser *b);
void avahi_s_record_browser_restart(AvahiSRecordBrowser *b);
-void avahi_s_record_browser_cancel(AvahiSRecordBrowser *b);
#endif
avahi_free(c);
}
-AvahiCacheEntry *avahi_cache_lookup_key(AvahiCache *c, AvahiKey *k) {
+static AvahiCacheEntry *lookup_key(AvahiCache *c, AvahiKey *k) {
assert(c);
assert(k);
} else {
AvahiCacheEntry *e, *n;
- for (e = avahi_cache_lookup_key(c, pattern); e; e = n) {
+ for (e = lookup_key(c, pattern); e; e = n) {
n = e->by_key_next;
if ((ret = cb(c, pattern, e, userdata)))
return NULL;
}
-AvahiCacheEntry *avahi_cache_lookup_record(AvahiCache *c, AvahiRecord *r) {
+static AvahiCacheEntry *lookup_record(AvahiCache *c, AvahiRecord *r) {
assert(c);
assert(r);
AvahiCacheEntry *e;
- if ((e = avahi_cache_lookup_record(c, r)))
+ if ((e = lookup_record(c, r)))
expire_in_one_second(c, e, AVAHI_CACHE_GOODBYE_FINAL);
} else {
/* This is an update request */
- if ((first = avahi_cache_lookup_key(c, r->key))) {
+ if ((first = lookup_key(c, r->key))) {
if (cache_flush) {
assert(record);
assert(a);
- if (!(e = avahi_cache_lookup_record(c, record)))
+ if (!(e = lookup_record(c, record)))
return;
/* This function is called for each response suppression
AvahiCache *avahi_cache_new(AvahiServer *server, AvahiInterface *interface);
void avahi_cache_free(AvahiCache *c);
-AvahiCacheEntry *avahi_cache_lookup_key(AvahiCache *c, AvahiKey *k);
-AvahiCacheEntry *avahi_cache_lookup_record(AvahiCache *c, AvahiRecord *r);
-
void avahi_cache_update(AvahiCache *c, AvahiRecord *r, int cache_flush, const AvahiAddress *a);
int avahi_cache_dump(AvahiCache *c, AvahiDumpCallback callback, void* userdata);
#include <avahi-common/simple-watch.h>
#include <avahi-common/timeval.h>
-#include "core.h"
-#include "log.h"
-#include "lookup.h"
+#include <avahi-core/core.h>
+#include <avahi-core/log.h>
+#include <avahi-core/lookup.h>
+#include <avahi-core/publish.h>
static char *name = NULL;
static AvahiSEntryGroup *group = NULL;
--- /dev/null
+#ifndef foodnssrvhfoo
+#define foodnssrvhfoo
+
+/* $Id$ */
+
+/***
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+ Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+/** \file avahi-core/dns-srv-rr.h Functions for announcing and browsing for unicast DNS servers via mDNS */
+
+/** A domain service browser object. Use this to browse for
+ * conventional unicast DNS servers which may be used to resolve
+ * conventional domain names */
+typedef struct AvahiSDNSServerBrowser AvahiSDNSServerBrowser;
+
+#include <avahi-common/cdecl.h>
+#include <avahi-common/defs.h>
+#include <avahi-core/core.h>
+#include <avahi-core/publish.h>
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+AVAHI_C_DECL_BEGIN
+#endif
+
+/** The type of DNS server */
+typedef enum {
+ AVAHI_DNS_SERVER_RESOLVE, /**< Unicast DNS servers for normal resolves (_domain._udp)*/
+ AVAHI_DNS_SERVER_UPDATE, /**< Unicast DNS servers for updates (_dns-update._udp)*/
+ AVAHI_DNS_SERVER_MAX
+} AvahiDNSServerType;
+
+/** Publish the specified unicast DNS server address via mDNS. You may
+ * browse for records create this way wit
+ * avahi_s_dns_server_browser_new(). */
+int avahi_server_add_dns_server_address(
+ AvahiServer *s,
+ AvahiSEntryGroup *g,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiPublishFlags flags,
+ const char *domain,
+ AvahiDNSServerType type,
+ const AvahiAddress *address,
+ uint16_t port /** should be 53 */);
+
+/** Similar to avahi_server_add_dns_server_address(), but specify a
+host name instead of an address. The specified host name should be
+resolvable via mDNS */
+int avahi_server_add_dns_server_name(
+ AvahiServer *s,
+ AvahiSEntryGroup *g,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiPublishFlags flags,
+ const char *domain,
+ AvahiDNSServerType type,
+ const char *name,
+ uint16_t port /** should be 53 */);
+
+/** Callback prototype for AvahiSDNSServerBrowser events */
+typedef void (*AvahiSDNSServerBrowserCallback)(
+ AvahiSDNSServerBrowser *b,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiBrowserEvent event,
+ const char *host_name, /**< Host name of the DNS server, probably useless */
+ const AvahiAddress *a, /**< Address of the DNS server */
+ uint16_t port, /**< Port number of the DNS servers, probably 53 */
+ AvahiLookupResultFlags flags, /**< Lookup flags */
+ void* userdata);
+
+/** Create a new AvahiSDNSServerBrowser object */
+AvahiSDNSServerBrowser *avahi_s_dns_server_browser_new(
+ AvahiServer *server,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ const char *domain,
+ AvahiDNSServerType type,
+ AvahiProtocol aprotocol, /**< Address protocol for the DNS server */
+ AvahiLookupFlags flags, /**< Lookup flags. */
+ AvahiSDNSServerBrowserCallback callback,
+ void* userdata);
+
+/** Free an AvahiSDNSServerBrowser object */
+void avahi_s_dns_server_browser_free(AvahiSDNSServerBrowser *b);
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+AVAHI_C_DECL_END
+#endif
+
+#endif
#include "browse.h"
#include "log.h"
#include "util.h"
+#include "dns-srv-rr.h"
void avahi_entry_free(AvahiServer*s, AvahiEntry *e) {
AvahiEntry *t;
return e->value;
}
-void* avahi_hashmap_steal(AvahiHashmap *m, const void *key) {
- Entry *e;
- void *v;
-
- assert(m);
-
- if (!(e = entry_get(m, key)))
- return NULL;
-
- v = e->value;
- entry_free(m, e, 1);
- return v;
-}
-
int avahi_hashmap_insert(AvahiHashmap *m, void *key, void *value) {
unsigned idx;
Entry *e;
void avahi_hashmap_free(AvahiHashmap *m);
void* avahi_hashmap_lookup(AvahiHashmap *m, const void *key);
-void* avahi_hashmap_steal(AvahiHashmap *m, const void *key);
int avahi_hashmap_insert(AvahiHashmap *m, void *key, void *value);
int avahi_hashmap_replace(AvahiHashmap *m, void *key, void *value);
void avahi_hashmap_remove(AvahiHashmap *m, const void *key);
/** \example core-browse-services.c Example how to browse for DNS-SD
* services using an embedded mDNS stack. */
-#include <avahi-common/cdecl.h>
-#include <avahi-common/defs.h>
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-AVAHI_C_DECL_BEGIN
-#endif
-
/** A browsing object for arbitrary RRs */
typedef struct AvahiSRecordBrowser AvahiSRecordBrowser;
/** A DNS-SD service resolver. Use this to retrieve addres, port and TXT data for a DNS-SD service */
typedef struct AvahiSServiceResolver AvahiSServiceResolver;
-/** A domain service browser object. Use this to browse for
- * conventional unicast DNS servers which may be used to resolve
- * conventional domain names */
-typedef struct AvahiSDNSServerBrowser AvahiSDNSServerBrowser;
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-AVAHI_C_DECL_END
-#endif
-
+#include <avahi-common/cdecl.h>
+#include <avahi-common/defs.h>
#include <avahi-core/core.h>
-#include <avahi-core/publish.h>
#ifndef DOXYGEN_SHOULD_SKIP_THIS
AVAHI_C_DECL_BEGIN
#endif
-
/** Callback prototype for AvahiSRecordBrowser events */
typedef void (*AvahiSRecordBrowserCallback)(
AvahiSRecordBrowser *b, /**< The AvahiSRecordBrowser object that is emitting this callback */
/** Free an AvahiSServiceResolver object */
void avahi_s_service_resolver_free(AvahiSServiceResolver *r);
-/** Callback prototype for AvahiSDNSServerBrowser events */
-typedef void (*AvahiSDNSServerBrowserCallback)(
- AvahiSDNSServerBrowser *b,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- AvahiBrowserEvent event,
- const char *host_name, /**< Host name of the DNS server, probably useless */
- const AvahiAddress *a, /**< Address of the DNS server */
- uint16_t port, /**< Port number of the DNS servers, probably 53 */
- AvahiLookupResultFlags flags, /**< Lookup flags */
- void* userdata);
-
-/** Create a new AvahiSDNSServerBrowser object */
-AvahiSDNSServerBrowser *avahi_s_dns_server_browser_new(
- AvahiServer *server,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- const char *domain,
- AvahiDNSServerType type,
- AvahiProtocol aprotocol, /**< Address protocol for the DNS server */
- AvahiLookupFlags flags, /**< Lookup flags. */
- AvahiSDNSServerBrowserCallback callback,
- void* userdata);
-
-/** Free an AvahiSDNSServerBrowser object */
-void avahi_s_dns_server_browser_free(AvahiSDNSServerBrowser *b);
-
#ifndef DOXYGEN_SHOULD_SKIP_THIS
AVAHI_C_DECL_END
#endif
* service using an embedded mDNS stack. It behaves like a network
* printer registering both an IPP and a BSD LPR service. */
-#include <avahi-common/cdecl.h>
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-AVAHI_C_DECL_BEGIN
-#endif
-
/** A group of locally registered DNS RRs */
typedef struct AvahiSEntryGroup AvahiSEntryGroup;
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-AVAHI_C_DECL_END
-#endif
-
+#include <avahi-common/cdecl.h>
#include <avahi-core/core.h>
#ifndef DOXYGEN_SHOULD_SKIP_THIS
const char *domain,
...) AVAHI_GCC_SENTINEL;
-/** The type of DNS server */
-typedef enum {
- AVAHI_DNS_SERVER_RESOLVE, /**< Unicast DNS servers for normal resolves (_domain._udp)*/
- AVAHI_DNS_SERVER_UPDATE, /**< Unicast DNS servers for updates (_dns-update._udp)*/
- AVAHI_DNS_SERVER_MAX
-} AvahiDNSServerType;
-
-/** Publish the specified unicast DNS server address via mDNS. You may
- * browse for records create this way wit
- * avahi_s_dns_server_browser_new(). */
-int avahi_server_add_dns_server_address(
- AvahiServer *s,
- AvahiSEntryGroup *g,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- AvahiPublishFlags flags,
- const char *domain,
- AvahiDNSServerType type,
- const AvahiAddress *address,
- uint16_t port /** should be 53 */);
-
-/** Similar to avahi_server_add_dns_server_address(), but specify a
-host name instead of an address. The specified host name should be
-resolvable via mDNS */
-int avahi_server_add_dns_server_name(
- AvahiServer *s,
- AvahiSEntryGroup *g,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- AvahiPublishFlags flags,
- const char *domain,
- AvahiDNSServerType type,
- const char *name,
- uint16_t port /** should be 53 */);
-
-
#ifndef DOXYGEN_SHOULD_SKIP_THIS
AVAHI_C_DECL_END
#endif
#include "browse.h"
#include "log.h"
#include "util.h"
+#include "dns-srv-rr.h"
static void enum_aux_records(AvahiServer *s, AvahiInterface *i, const char *name, uint16_t type, void (*callback)(AvahiServer *s, AvahiRecord *r, int flush_cache, void* userdata), void* userdata) {
AvahiKey *k;
server_set_state(s, AVAHI_SERVER_RUNNING);
}
-void avahi_server_increase_host_rr_pending(AvahiServer *s) {
- assert(s);
-
- s->n_host_rr_pending ++;
-}
-
void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void *userdata) {
assert(s);
assert(g);
if (state == AVAHI_ENTRY_GROUP_REGISTERING &&
s->state == AVAHI_SERVER_REGISTERING)
- avahi_server_increase_host_rr_pending(s);
+ s->n_host_rr_pending ++;
else if (state == AVAHI_ENTRY_GROUP_COLLISION &&
(s->state == AVAHI_SERVER_REGISTERING || s->state == AVAHI_SERVER_RUNNING)) {
assert(s);
server_set_state(s, AVAHI_SERVER_REGISTERING);
- s->n_host_rr_pending ++; /** Make sure that the state isn't changed tp AVAHI_SERVER_RUNNING too early */
+ s->n_host_rr_pending ++; /** Make sure that the state isn't changed tp AVAHI_SERVER_RUNNING too early */
register_hinfo(s);
register_browse_domain(s);
USA.
***/
-#include <avahi-common/llist.h>
-#include <avahi-common/watch.h>
-
/** A locally registered DNS resource record */
typedef struct AvahiEntry AvahiEntry;
+#include <avahi-common/llist.h>
+#include <avahi-common/watch.h>
+
#include "core.h"
#include "iface.h"
#include "prioq.h"
#include "hashmap.h"
#include "wide-area.h"
#include "multicast-lookup.h"
+#include "dns-srv-rr.h"
#define AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS 100
void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void *userdata);
void avahi_server_decrease_host_rr_pending(AvahiServer *s);
-void avahi_server_increase_host_rr_pending(AvahiServer *s);
int avahi_server_set_errno(AvahiServer *s, int error);
return avahi_timeval_compare(&a->last_run, &b->last_run);
}
+static AvahiTimeEvent* time_event_queue_root(AvahiTimeEventQueue *q) {
+ assert(q);
+
+ return q->prioq->root ? q->prioq->root->data : NULL;
+}
+
static void update_timeout(AvahiTimeEventQueue *q) {
AvahiTimeEvent *e;
assert(q);
- if ((e = avahi_time_event_queue_root(q)))
+ if ((e = time_event_queue_root(q)))
q->poll_api->timeout_update(q->timeout, &e->expiry);
else
q->poll_api->timeout_update(q->timeout, NULL);
AvahiTimeEventQueue *q = userdata;
AvahiTimeEvent *e;
- if ((e = avahi_time_event_queue_root(q))) {
+ if ((e = time_event_queue_root(q))) {
struct timeval now;
gettimeofday(&now, NULL);
assert(q);
- while ((e = avahi_time_event_queue_root(q)))
+ while ((e = time_event_queue_root(q)))
avahi_time_event_free(e);
avahi_prio_queue_free(q->prioq);
update_timeout(e->queue);
}
-AvahiTimeEvent* avahi_time_event_queue_root(AvahiTimeEventQueue *q) {
- assert(q);
-
- return q->prioq->root ? q->prioq->root->data : NULL;
-}
-
-AvahiTimeEvent* avahi_time_event_next(AvahiTimeEvent *e) {
- assert(e);
-
- return e->node->next->data;
-}
-
-
void avahi_time_event_free(AvahiTimeEvent *e);
void avahi_time_event_update(AvahiTimeEvent *e, const struct timeval *timeval);
-AvahiTimeEvent* avahi_time_event_queue_root(AvahiTimeEventQueue *q);
-AvahiTimeEvent* avahi_time_event_next(AvahiTimeEvent *e);
-
#endif
return r;
}
-char *avahi_strdown(char *s) {
- char *c;
-
- assert(s);
-
- for (c = s; *c; c++)
- *c = (char) tolower(*c);
-
- return s;
-}
-
char *avahi_strup(char *s) {
char *c;
assert(s);
/** Change every character in the string to upper case (ASCII), return a pointer to the string */
char *avahi_strup(char *s);
-/** Change every character in the string to lower case (ASCII), return a pointer to the string */
-char *avahi_strdown(char *s);
-
AVAHI_C_DECL_END
#endif
assert(e->cache_n_entries == 0);
}
-
void avahi_wide_area_set_servers(AvahiWideAreaLookupEngine *e, const AvahiAddress *a, unsigned n) {
assert(e);
-
if (a) {
for (e->n_dns_servers = 0; n > 0 && e->n_dns_servers < AVAHI_MAX_WIDE_AREA_SERVERS; a++, n--)
if ((a->proto == AVAHI_PROTO_INET && e->fd_ipv4 >= 0) || (a->proto == AVAHI_PROTO_INET6 && e->fd_ipv6 >= 0))
#include <avahi-common/simple-watch.h>
#include <avahi-common/error.h>
#include <avahi-common/alternative.h>
+
#include <avahi-core/core.h>
#include <avahi-core/publish.h>
+#include <avahi-core/dns-srv-rr.h>
#include <avahi-core/log.h>
#include "main.h"
#include <avahi-common/llist.h>
#include <avahi-common/malloc.h>
#include <avahi-common/error.h>
+
#include <avahi-core/log.h>
#include <avahi-core/lookup.h>
+#include <avahi-core/dns-srv-rr.h>
#include "simple-protocol.h"
#include "main.h"
* add support for subtypes in static services
* drop partially created created entries on failure
* Add static host configuration like static services [lathiat]
-* wrap avahi_server_add_record() via DBUS and in avahi-client [lathiat]
+* wrap avahi_server_add_record() via DBUS and in avahi-client [lathiat]
+* remove AVAHI_PUBLISH_IS_PROXY
+* replace avahi_server_is_service_local() by AVAHI_PUBLISH flag
later:
* implement avahi-utils in C