summaryrefslogtreecommitdiffstats
path: root/avahi-core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-06-11 11:10:57 +0000
committerLennart Poettering <lennart@poettering.net>2005-06-11 11:10:57 +0000
commitc0244c2448a5504581ae24e78b5859760b999b8e (patch)
tree36f494e426c66eac524064ec87e547d4868fe887 /avahi-core
parentcc13c12d162239446a01c3f1d322cf9704379253 (diff)
* add logging API and make all code make use of it
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@112 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-core')
-rw-r--r--avahi-core/Makefile.am6
-rw-r--r--avahi-core/announce.c24
-rw-r--r--avahi-core/avahi-test.c29
-rw-r--r--avahi-core/browse-service-type.c3
-rw-r--r--avahi-core/browse-service.c3
-rw-r--r--avahi-core/browse.c2
-rw-r--r--avahi-core/cache.c14
-rw-r--r--avahi-core/conformance-test.c5
-rw-r--r--avahi-core/dns-test.c9
-rw-r--r--avahi-core/dns.c24
-rw-r--r--avahi-core/iface.c17
-rw-r--r--avahi-core/log.c88
-rw-r--r--avahi-core/log.h77
-rw-r--r--avahi-core/netlink.c7
-rw-r--r--avahi-core/prioq.c6
-rw-r--r--avahi-core/probe-sched.c7
-rw-r--r--avahi-core/query-sched.c8
-rw-r--r--avahi-core/response-sched.c15
-rw-r--r--avahi-core/server.c75
-rw-r--r--avahi-core/socket.c87
20 files changed, 339 insertions, 167 deletions
diff --git a/avahi-core/Makefile.am b/avahi-core/Makefile.am
index ca7c385..0746622 100644
--- a/avahi-core/Makefile.am
+++ b/avahi-core/Makefile.am
@@ -68,7 +68,8 @@ libavahi_core_la_SOURCES = \
resolve-service.c \
dns.c dns.h \
core.h \
- llist.h
+ llist.h \
+ log.c log.h
libavahi_core_la_CFLAGS = $(AM_CFLAGS)
libavahi_core_la_LIBADD = $(AM_LDADD) $(COMMON_LDADD)
@@ -98,7 +99,8 @@ avahi_reflector_LDADD = $(AM_LDADD) $(STATIC_COMMON_LDADD)
dns_test_SOURCES = \
dns.c dns.h \
- dns-test.c
+ dns-test.c \
+ log.c log.h
dns_test_CFLAGS = $(AM_CFLAGS)
dns_test_LDADD = $(AM_LDADD) $(STATIC_COMMON_LDADD)
diff --git a/avahi-core/announce.c b/avahi-core/announce.c
index 6f94a74..3374ada 100644
--- a/avahi-core/announce.c
+++ b/avahi-core/announce.c
@@ -107,7 +107,7 @@ void avahi_entry_group_check_probed(AvahiEntryGroup *g, gboolean immediately) {
static void next_state(AvahiAnnouncement *a) {
g_assert(a);
-/* g_message("%i -- %u", a->state, a->n_iteration); */
+/* avahi_log_debug("%i -- %u", a->state, a->n_iteration); */
if (a->state == AVAHI_WAITING) {
@@ -122,7 +122,7 @@ static void next_state(AvahiAnnouncement *a) {
/* gchar *t; */
-/* g_message("Enough probes for record [%s]", t = avahi_record_to_string(a->entry->record)); */
+/* avahi_log_debug("Enough probes for record [%s]", t = avahi_record_to_string(a->entry->record)); */
/* g_free(t); */
if (a->entry->group) {
@@ -164,7 +164,7 @@ static void next_state(AvahiAnnouncement *a) {
/* gchar *t; */
/* Announcing done */
-/* g_message("Enough announcements for record [%s]", t = avahi_record_to_string(a->entry->record)); */
+/* avahi_log_debug("Enough announcements for record [%s]", t = avahi_record_to_string(a->entry->record)); */
/* g_free(t); */
a->state = AVAHI_ESTABLISHED;
@@ -246,7 +246,7 @@ static void new_announcement(AvahiServer *s, AvahiInterface *i, AvahiEntry *e) {
g_assert(e);
g_assert(!e->dead);
-/* g_message("NEW ANNOUNCEMENT: %s.%i [%s]", i->hardware->name, i->protocol, t = avahi_record_to_string(e->record)); */
+/* avahi_log_debug("NEW ANNOUNCEMENT: %s.%i [%s]", i->hardware->name, i->protocol, t = avahi_record_to_string(e->record)); */
/* g_free(t); */
if (!avahi_interface_match(i, e->interface, e->protocol) || !i->announcing || !avahi_entry_commited(e))
@@ -267,7 +267,7 @@ static void new_announcement(AvahiServer *s, AvahiInterface *i, AvahiEntry *e) {
go_to_initial_state(a, FALSE);
-/* g_message("New announcement on interface %s.%i for entry [%s] state=%i", i->hardware->name, i->protocol, t = avahi_record_to_string(e->record), a->state); */
+/* avahi_log_debug("New announcement on interface %s.%i for entry [%s] state=%i", i->hardware->name, i->protocol, t = avahi_record_to_string(e->record), a->state); */
/* g_free(t); */
}
@@ -370,7 +370,7 @@ static AvahiRecord *make_goodbye_record(AvahiRecord *r) {
g_assert(r);
-/* g_message("Preparing goodbye for record [%s]", t = avahi_record_to_string(r)); */
+/* avahi_log_debug("Preparing goodbye for record [%s]", t = avahi_record_to_string(r)); */
/* g_free(t); */
g = avahi_record_copy(r);
@@ -407,7 +407,7 @@ void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, gboolean goodbye
g_assert(s);
g_assert(i);
-/* g_message("goodbye interface: %s.%u", i->hardware->name, i->protocol); */
+/* avahi_log_debug("goodbye interface: %s.%u", i->hardware->name, i->protocol); */
if (goodbye && avahi_interface_relevant(i)) {
AvahiEntry *e;
@@ -420,7 +420,7 @@ void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, gboolean goodbye
while (i->announcements)
remove_announcement(s, i->announcements);
-/* g_message("goodbye interface done: %s.%u", i->hardware->name, i->protocol); */
+/* avahi_log_debug("goodbye interface done: %s.%u", i->hardware->name, i->protocol); */
}
@@ -428,7 +428,7 @@ void avahi_goodbye_entry(AvahiServer *s, AvahiEntry *e, gboolean goodbye) {
g_assert(s);
g_assert(e);
-/* g_message("goodbye entry: %p", e); */
+/* avahi_log_debug("goodbye entry: %p", e); */
if (goodbye && !e->dead)
avahi_interface_monitor_walk(s->monitor, 0, AF_UNSPEC, send_goodbye_callback, e);
@@ -436,7 +436,7 @@ void avahi_goodbye_entry(AvahiServer *s, AvahiEntry *e, gboolean goodbye) {
while (e->announcements)
remove_announcement(s, e->announcements);
-/* g_message("goodbye entry done: %p", e); */
+/* avahi_log_debug("goodbye entry done: %p", e); */
}
@@ -445,13 +445,13 @@ void avahi_goodbye_all(AvahiServer *s, gboolean goodbye) {
g_assert(s);
-/* g_message("goodbye all"); */
+/* avahi_log_debug("goodbye all"); */
for (e = s->entries; e; e = e->entries_next)
if (!e->dead)
avahi_goodbye_entry(s, e, goodbye);
-/* g_message("goodbye all done"); */
+/* avahi_log_debug("goodbye all done"); */
}
diff --git a/avahi-core/avahi-test.c b/avahi-core/avahi-test.c
index bd642e8..5f4b91e 100644
--- a/avahi-core/avahi-test.c
+++ b/avahi-core/avahi-test.c
@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <avahi-core/core.h>
+#include <avahi-core/log.h>
static AvahiEntryGroup *group = NULL;
static AvahiServer *server = NULL;
@@ -53,7 +54,7 @@ static void record_browser_callback(AvahiRecordBrowser *r, gint interface, gucha
g_assert(interface > 0);
g_assert(protocol != AF_UNSPEC);
- g_message("SUBSCRIPTION: record [%s] on %i.%i is %s", t = avahi_record_to_string(record), interface, protocol,
+ avahi_log_debug("SUBSCRIPTION: record [%s] on %i.%i is %s", t = avahi_record_to_string(record), interface, protocol,
event == AVAHI_BROWSER_NEW ? "new" : "remove");
g_free(t);
@@ -63,23 +64,23 @@ static void remove_entries(void);
static void create_entries(gboolean new_name);
static void entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, gpointer userdata) {
- g_message("entry group state: %i", state);
+ avahi_log_debug("entry group state: %i", state);
if (state == AVAHI_ENTRY_GROUP_COLLISION) {
remove_entries();
create_entries(TRUE);
- g_message("Service name conflict, retrying with <%s>", service_name);
+ avahi_log_debug("Service name conflict, retrying with <%s>", service_name);
} else if (state == AVAHI_ENTRY_GROUP_ESTABLISHED) {
- g_message("Service established under name <%s>", service_name);
+ avahi_log_debug("Service established under name <%s>", service_name);
}
}
static void server_callback(AvahiServer *s, AvahiServerState state, gpointer userdata) {
- g_message("server state: %i", state);
+ avahi_log_debug("server state: %i", state);
if (state == AVAHI_SERVER_RUNNING) {
- g_message("Server startup complete. Host name is <%s>", avahi_server_get_host_name_fqdn(s));
+ avahi_log_debug("Server startup complete. Host name is <%s>", avahi_server_get_host_name_fqdn(s));
create_entries(FALSE);
} else if (state == AVAHI_SERVER_COLLISION) {
gchar *n;
@@ -87,7 +88,7 @@ static void server_callback(AvahiServer *s, AvahiServerState state, gpointer use
n = avahi_alternative_host_name(avahi_server_get_host_name(s));
- g_message("Host name conflict, retrying with <%s>", n);
+ avahi_log_debug("Host name conflict, retrying with <%s>", n);
avahi_server_set_host_name(s, n);
g_free(n);
}
@@ -127,7 +128,7 @@ static void hnr_callback(AvahiHostNameResolver *r, gint iface, guchar protocol,
if (a)
avahi_address_snprint(t, sizeof(t), a);
- g_message("HNR: (%i.%i) <%s> -> %s [%s]", iface, protocol, hostname, a ? t : "n/a", event == AVAHI_RESOLVER_FOUND ? "found" : "timeout");
+ avahi_log_debug("HNR: (%i.%i) <%s> -> %s [%s]", iface, protocol, hostname, a ? t : "n/a", event == AVAHI_RESOLVER_FOUND ? "found" : "timeout");
}
static void ar_callback(AvahiAddressResolver *r, gint iface, guchar protocol, AvahiBrowserEvent event, const AvahiAddress *a, const gchar *hostname, gpointer userdata) {
@@ -135,35 +136,35 @@ static void ar_callback(AvahiAddressResolver *r, gint iface, guchar protocol, Av
avahi_address_snprint(t, sizeof(t), a);
- g_message("AR: (%i.%i) %s -> <%s> [%s]", iface, protocol, t, hostname ? hostname : "n/a", event == AVAHI_RESOLVER_FOUND ? "found" : "timeout");
+ avahi_log_debug("AR: (%i.%i) %s -> <%s> [%s]", iface, protocol, t, hostname ? hostname : "n/a", event == AVAHI_RESOLVER_FOUND ? "found" : "timeout");
}
static void db_callback(AvahiDomainBrowser *b, gint iface, guchar protocol, AvahiBrowserEvent event, const gchar *domain, gpointer userdata) {
- g_message("DB: (%i.%i) <%s> [%s]", iface, protocol, domain, event == AVAHI_BROWSER_NEW ? "new" : "remove");
+ avahi_log_debug("DB: (%i.%i) <%s> [%s]", iface, protocol, domain, event == AVAHI_BROWSER_NEW ? "new" : "remove");
}
static void stb_callback(AvahiServiceTypeBrowser *b, gint iface, guchar protocol, AvahiBrowserEvent event, const gchar *service_type, const gchar *domain, gpointer userdata) {
- g_message("STB: (%i.%i) %s in <%s> [%s]", iface, protocol, service_type, domain, event == AVAHI_BROWSER_NEW ? "new" : "remove");
+ avahi_log_debug("STB: (%i.%i) %s in <%s> [%s]", iface, protocol, service_type, domain, event == AVAHI_BROWSER_NEW ? "new" : "remove");
}
static void sb_callback(AvahiServiceBrowser *b, gint iface, guchar protocol, AvahiBrowserEvent event, const gchar *name, const gchar *service_type, const gchar *domain, gpointer userdata) {
- g_message("SB: (%i.%i) <%s> as %s in <%s> [%s]", iface, protocol, name, service_type, domain, event == AVAHI_BROWSER_NEW ? "new" : "remove");
+ avahi_log_debug("SB: (%i.%i) <%s> as %s in <%s> [%s]", iface, protocol, name, service_type, domain, event == AVAHI_BROWSER_NEW ? "new" : "remove");
}
static void sr_callback(AvahiServiceResolver *r, gint iface, guchar protocol, AvahiBrowserEvent event, const gchar *service_name, const gchar*service_type, const gchar*domain_name, const gchar*hostname, const AvahiAddress *a, guint16 port, AvahiStringList *txt, gpointer userdata) {
if (event == AVAHI_RESOLVER_TIMEOUT)
- g_message("SR: (%i.%i) <%s> as %s in <%s> [timeout]", iface, protocol, service_name, service_type, domain_name);
+ avahi_log_debug("SR: (%i.%i) <%s> as %s in <%s> [timeout]", iface, protocol, service_name, service_type, domain_name);
else {
gchar t[64], *s;
avahi_address_snprint(t, sizeof(t), a);
s = avahi_string_list_to_string(txt);
- g_message("SR: (%i.%i) <%s> as %s in <%s>: %s/%s:%i (%s) [found]", iface, protocol, service_name, service_type, domain_name, hostname, t, port, s);
+ avahi_log_debug("SR: (%i.%i) <%s> as %s in <%s>: %s/%s:%i (%s) [found]", iface, protocol, service_name, service_type, domain_name, hostname, t, port, s);
g_free(s);
}
}
diff --git a/avahi-core/browse-service-type.c b/avahi-core/browse-service-type.c
index dec7eef..21c1157 100644
--- a/avahi-core/browse-service-type.c
+++ b/avahi-core/browse-service-type.c
@@ -27,6 +27,7 @@
#include "browse.h"
#include "util.h"
+#include "log.h"
struct AvahiServiceTypeBrowser {
AvahiServer *server;
@@ -77,7 +78,7 @@ static void record_browser_callback(AvahiRecordBrowser*rr, gint interface, gucha
return;
fail:
- g_warning("Invalid service type '%s'", n);
+ avahi_log_warn("Invalid service type '%s'", n);
g_free(n);
}
diff --git a/avahi-core/browse-service.c b/avahi-core/browse-service.c
index 10b3f33..280de6e 100644
--- a/avahi-core/browse-service.c
+++ b/avahi-core/browse-service.c
@@ -27,6 +27,7 @@
#include "browse.h"
#include "util.h"
+#include "log.h"
struct AvahiServiceBrowser {
AvahiServer *server;
@@ -79,7 +80,7 @@ static void record_browser_callback(AvahiRecordBrowser*rr, gint interface, gucha
return;
fail:
- g_warning("Invalid service '%s'", n);
+ avahi_log_warn("Invalid service '%s'", n);
g_free(n);
}
diff --git a/avahi-core/browse.c b/avahi-core/browse.c
index 45e8bce..deeb465 100644
--- a/avahi-core/browse.c
+++ b/avahi-core/browse.c
@@ -57,7 +57,7 @@ static void elapse(AvahiTimeEvent *e, void *userdata) {
if (s->n_query++ <= 8)
s->sec_delay *= 2;
-/* g_message("%i. Continuous querying for %s", s->n_query, t = avahi_key_to_string(s->key)); */
+/* avahi_log_debug("%i. Continuous querying for %s", s->n_query, t = avahi_key_to_string(s->key)); */
/* g_free(t); */
avahi_elapse_time(&tv, s->sec_delay*1000, 0);
diff --git a/avahi-core/cache.c b/avahi-core/cache.c
index 8f9ffaf..865950f 100644
--- a/avahi-core/cache.c
+++ b/avahi-core/cache.c
@@ -36,7 +36,7 @@ static void remove_entry(AvahiCache *c, AvahiCacheEntry *e) {
g_assert(c);
g_assert(e);
-/* g_message("removing from cache: %p %p", c, e); */
+/* avahi_log_debug("removing from cache: %p %p", c, e); */
/* Remove from hash table */
t = g_hash_table_lookup(c->hash_table, e->record->key);
@@ -157,7 +157,7 @@ static void elapse_func(AvahiTimeEvent *t, void *userdata) {
if (e->state == AVAHI_CACHE_FINAL) {
remove_entry(e->cache, e);
-/* g_message("Removing entry from cache due to expiration"); */
+/* avahi_log_debug("Removing entry from cache due to expiration"); */
} else {
guint percent = 0;
@@ -189,7 +189,7 @@ static void elapse_func(AvahiTimeEvent *t, void *userdata) {
/* Request a cache update, if we are subscribed to this entry */
if (avahi_is_subscribed(e->cache->server, e->cache->interface, e->record->key)) {
-/* g_message("Requesting cache entry update at %i%%.", percent); */
+/* avahi_log_debug("Requesting cache entry update at %i%%.", percent); */
avahi_interface_post_query(e->cache->interface, e->record->key, TRUE);
}
@@ -242,7 +242,7 @@ void avahi_cache_update(AvahiCache *c, AvahiRecord *r, gboolean cache_flush, con
g_assert(c);
g_assert(r && r->ref >= 1);
-/* g_message("cache update: %s", (txt = avahi_record_to_string(r))); */
+/* avahi_log_debug("cache update: %s", (txt = avahi_record_to_string(r))); */
/* g_free(txt); */
if (r->ttl == 0) {
@@ -284,7 +284,7 @@ void avahi_cache_update(AvahiCache *c, AvahiRecord *r, gboolean cache_flush, con
if (e) {
-/* g_message("found matching cache entry"); */
+/* avahi_log_debug("found matching cache entry"); */
/* We need to update the hash table key if we replace the
* record */
@@ -298,7 +298,7 @@ void avahi_cache_update(AvahiCache *c, AvahiRecord *r, gboolean cache_flush, con
} else {
/* No entry found, therefore we create a new one */
-/* g_message("couldn't find matching cache entry"); */
+/* avahi_log_debug("couldn't find matching cache entry"); */
if (c->n_entries >= AVAHI_MAX_CACHE_ENTRIES)
return;
@@ -362,7 +362,7 @@ gboolean avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e) {
age = avahi_timeval_diff(&now, &e->timestamp)/1000000;
-/* g_message("age: %u, ttl/2: %u", age, e->record->ttl); */
+/* avahi_log_debug("age: %u, ttl/2: %u", age, e->record->ttl); */
return age >= e->record->ttl/2;
}
diff --git a/avahi-core/conformance-test.c b/avahi-core/conformance-test.c
index 4bcd691..688daba 100644
--- a/avahi-core/conformance-test.c
+++ b/avahi-core/conformance-test.c
@@ -32,6 +32,7 @@
#include "core.h"
#include "util.h"
#include "alternative.h"
+#include "log.h"
static gchar *name = NULL;
static AvahiEntryGroup *group = NULL;
@@ -81,13 +82,13 @@ static void entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryG
if (state == AVAHI_ENTRY_GROUP_COLLISION)
create_service(NULL);
else if (state == AVAHI_ENTRY_GROUP_ESTABLISHED) {
- g_message("ESTABLISHED !!!!");
+ avahi_log_debug("ESTABLISHED !!!!");
try = 0;
}
}
static void server_callback(AvahiServer *s, AvahiServerState state, gpointer userdata) {
- g_message("server state: %i", state);
+ avahi_log_debug("server state: %i", state);
}
int main(int argc, char *argv[]) {
diff --git a/avahi-core/dns-test.c b/avahi-core/dns-test.c
index aa36f2a..07cd529 100644
--- a/avahi-core/dns-test.c
+++ b/avahi-core/dns-test.c
@@ -25,6 +25,7 @@
#include "dns.h"
#include "util.h"
+#include "log.h"
int main(int argc, char *argv[]) {
gchar t[256], *a, *b, *c, *d;
@@ -40,19 +41,19 @@ int main(int argc, char *argv[]) {
avahi_hexdump(AVAHI_DNS_PACKET_DATA(p), p->size);
avahi_dns_packet_consume_name(p, t, sizeof(t));
- g_message(">%s<", t);
+ avahi_log_debug(">%s<", t);
g_assert(avahi_domain_equal(a, t));
avahi_dns_packet_consume_name(p, t, sizeof(t));
- g_message(">%s<", t);
+ avahi_log_debug(">%s<", t);
g_assert(avahi_domain_equal(b, t));
avahi_dns_packet_consume_name(p, t, sizeof(t));
- g_message(">%s<", t);
+ avahi_log_debug(">%s<", t);
g_assert(avahi_domain_equal(c, t));
avahi_dns_packet_consume_name(p, t, sizeof(t));
- g_message(">%s<", t);
+ avahi_log_debug(">%s<", t);
g_assert(avahi_domain_equal(d, t));
avahi_dns_packet_free(p);
diff --git a/avahi-core/dns.c b/avahi-core/dns.c
index 9e19c9e..5addf53 100644
--- a/avahi-core/dns.c
+++ b/avahi-core/dns.c
@@ -465,7 +465,7 @@ AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, gboolean *ret_ca
g_assert(p);
g_assert(ret_cache_flush);
-/* g_message("consume_record()"); */
+/* avahi_log_debug("consume_record()"); */
if (avahi_dns_packet_consume_name(p, name, sizeof(name)) < 0 ||
avahi_dns_packet_consume_uint16(p, &type) < 0 ||
@@ -475,7 +475,7 @@ AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, gboolean *ret_ca
p->rindex + rdlength > p->size)
goto fail;
-/* g_message("name = %s, rdlength = %u", name, rdlength); */
+/* avahi_log_debug("name = %s, rdlength = %u", name, rdlength); */
*ret_cache_flush = !!(class & AVAHI_DNS_CACHE_FLUSH);
class &= ~AVAHI_DNS_CACHE_FLUSH;
@@ -488,7 +488,7 @@ AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, gboolean *ret_ca
case AVAHI_DNS_TYPE_PTR:
case AVAHI_DNS_TYPE_CNAME:
-/* g_message("ptr"); */
+/* avahi_log_debug("ptr"); */
if (avahi_dns_packet_consume_name(p, buf, sizeof(buf)) < 0)
goto fail;
@@ -499,7 +499,7 @@ AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, gboolean *ret_ca
case AVAHI_DNS_TYPE_SRV:
-/* g_message("srv"); */
+/* avahi_log_debug("srv"); */
if (avahi_dns_packet_consume_uint16(p, &r->data.srv.priority) < 0 ||
avahi_dns_packet_consume_uint16(p, &r->data.srv.weight) < 0 ||
@@ -512,7 +512,7 @@ AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, gboolean *ret_ca
case AVAHI_DNS_TYPE_HINFO:
-/* g_message("hinfo"); */
+/* avahi_log_debug("hinfo"); */
if (avahi_dns_packet_consume_string(p, buf, sizeof(buf)) < 0)
goto fail;
@@ -527,7 +527,7 @@ AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, gboolean *ret_ca
case AVAHI_DNS_TYPE_TXT:
-/* g_message("txt"); */
+/* avahi_log_debug("txt"); */
if (rdlength > 0) {
r->data.txt.string_list = avahi_string_list_parse(avahi_dns_packet_get_rptr(p), rdlength);
@@ -541,7 +541,7 @@ AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, gboolean *ret_ca
case AVAHI_DNS_TYPE_A:
-/* g_message("A"); */
+/* avahi_log_debug("A"); */
if (avahi_dns_packet_consume_bytes(p, &r->data.a.address, sizeof(AvahiIPv4Address)) < 0)
goto fail;
@@ -550,7 +550,7 @@ AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, gboolean *ret_ca
case AVAHI_DNS_TYPE_AAAA:
-/* g_message("aaaa"); */
+/* avahi_log_debug("aaaa"); */
if (avahi_dns_packet_consume_bytes(p, &r->data.aaaa.address, sizeof(AvahiIPv6Address)) < 0)
goto fail;
@@ -559,7 +559,7 @@ AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, gboolean *ret_ca
default:
-/* g_message("generic"); */
+/* avahi_log_debug("generic"); */
if (rdlength > 0) {
@@ -572,7 +572,7 @@ AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, gboolean *ret_ca
break;
}
-/* g_message("%i == %u ?", (guint8*) avahi_dns_packet_get_rptr(p) - (guint8*) start, rdlength); */
+/* avahi_log_debug("%i == %u ?", (guint8*) avahi_dns_packet_get_rptr(p) - (guint8*) start, rdlength); */
/* Check if we read enough data */
if ((guint8*) avahi_dns_packet_get_rptr(p) - (guint8*) start != rdlength)
@@ -678,7 +678,7 @@ guint8* avahi_dns_packet_append_record(AvahiDnsPacket *p, AvahiRecord *r, gboole
size = avahi_string_list_serialize(r->data.txt.string_list, NULL, 0);
-/* g_message("appending string: %u %p", size, r->data.txt.string_list); */
+/* avahi_log_debug("appending string: %u %p", size, r->data.txt.string_list); */
if (!(data = avahi_dns_packet_extend(p, size)))
goto fail;
@@ -717,7 +717,7 @@ guint8* avahi_dns_packet_append_record(AvahiDnsPacket *p, AvahiRecord *r, gboole
size = avahi_dns_packet_extend(p, 0) - start;
g_assert(size <= 0xFFFF);
-/* g_message("appended %u", size); */
+/* avahi_log_debug("appended %u", size); */
* (guint16*) l = g_htons((guint16) size);
diff --git a/avahi-core/iface.c b/avahi-core/iface.c
index d890e22..73f4cdf 100644
--- a/avahi-core/iface.c
+++ b/avahi-core/iface.c
@@ -37,6 +37,7 @@
#include "socket.h"
#include "announce.h"
#include "util.h"
+#include "log.h"
static void update_address_rr(AvahiInterfaceMonitor *m, AvahiInterfaceAddress *a, gboolean remove) {
g_assert(m);
@@ -235,7 +236,7 @@ static void check_interface_relevant(AvahiInterfaceMonitor *m, AvahiInterface *i
b = avahi_interface_relevant(i);
if (b && !i->announcing) {
- g_message("New relevant interface %s.%i (#%i)", i->hardware->name, i->protocol, i->hardware->index);
+ avahi_log_debug("New relevant interface %s.%i (#%i)", i->hardware->name, i->protocol, i->hardware->index);
if (i->protocol == AF_INET)
avahi_mdns_mcast_join_ipv4(i->hardware->index, m->server->fd_ipv4);
@@ -246,7 +247,7 @@ static void check_interface_relevant(AvahiInterfaceMonitor *m, AvahiInterface *i
avahi_announce_interface(m->server, i);
avahi_browser_new_interface(m->server, i);
} else if (!b && i->announcing) {
- g_message("Interface %s.%i no longer relevant", i->hardware->name, i->protocol);
+ avahi_log_debug("Interface %s.%i no longer relevant", i->hardware->name, i->protocol);
if (i->protocol == AF_INET)
avahi_mdns_mcast_leave_ipv4(i->hardware->index, m->server->fd_ipv4);
@@ -438,19 +439,19 @@ static void callback(AvahiNetlink *nl, struct nlmsghdr *n, gpointer userdata) {
m->list = LIST_DONE;
if (netlink_list_items(m->netlink, RTM_GETADDR, &m->query_addr_seq) < 0)
- g_warning("NETLINK: Failed to list addrs: %s", strerror(errno));
+ avahi_log_warn("NETLINK: Failed to list addrs: %s", strerror(errno));
else
m->list = LIST_ADDR;
} else {
m->list = LIST_DONE;
- g_message("Enumeration complete");
+ avahi_log_debug("Enumeration complete");
}
} else if (n->nlmsg_type == NLMSG_ERROR && (n->nlmsg_seq == m->query_link_seq || n->nlmsg_seq == m->query_addr_seq)) {
struct nlmsgerr *e = NLMSG_DATA (n);
if (e->error)
- g_warning("NETLINK: Failed to browse: %s", strerror(-e->error));
+ avahi_log_warn("NETLINK: Failed to browse: %s", strerror(-e->error));
}
}
@@ -544,9 +545,9 @@ void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, c
g_assert(!a || a->family == i->protocol);
/* if (a) */
-/* g_message("unicast sending on '%s.%i' to %s:%u", i->hardware->name, i->protocol, avahi_address_snprint(t, sizeof(t), a), port); */
+/* avahi_log_debug("unicast sending on '%s.%i' to %s:%u", i->hardware->name, i->protocol, avahi_address_snprint(t, sizeof(t), a), port); */
/* else */
-/* g_message("multicast sending on '%s.%i'", i->hardware->name, i->protocol); */
+/* avahi_log_debug("multicast sending on '%s.%i'", i->hardware->name, i->protocol); */
if (i->protocol == AF_INET && i->monitor->server->fd_ipv4 >= 0)
avahi_send_dns_packet_ipv4(i->monitor->server->fd_ipv4, i->hardware->index, p, a ? &a->data.ipv4 : NULL, port);
@@ -618,7 +619,7 @@ gboolean avahi_interface_relevant(AvahiInterface *i) {
break;
}
-/* g_message("%p. iface-relevant: %i %i %i %i %i %i", i, relevant_address, */
+/* avahi_log_debug("%p. iface-relevant: %i %i %i %i %i %i", i, relevant_address, */
/* (i->hardware->flags & IFF_UP), */
/* (i->hardware->flags & IFF_RUNNING), */
/* !(i->hardware->flags & IFF_LOOPBACK), */
diff --git a/avahi-core/log.c b/avahi-core/log.c
new file mode 100644
index 0000000..09b87da
--- /dev/null
+++ b/avahi-core/log.c
@@ -0,0 +1,88 @@
+/* $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.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "log.h"
+
+static AvahiLogFunction log_function = NULL;
+
+void avahi_set_log_function(AvahiLogFunction function) {
+ log_function = function;
+}
+
+void avahi_log_ap(AvahiLogLevel level, const gchar*format, va_list ap) {
+ char txt[256];
+
+ vsnprintf(txt, sizeof(txt), format, ap);
+
+ if (log_function)
+ log_function(level, txt);
+ else
+ fprintf(stderr, "%s\n", txt);
+}
+
+void avahi_log(AvahiLogLevel level, const gchar*format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ avahi_log_ap(level, format, ap);
+ va_end(ap);
+}
+
+void avahi_log_error(const gchar*format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ avahi_log_ap(AVAHI_LOG_ERROR, format, ap);
+ va_end(ap);
+}
+
+void avahi_log_warn(const gchar*format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ avahi_log_ap(AVAHI_LOG_WARN, format, ap);
+ va_end(ap);
+}
+
+void avahi_log_notice(const gchar*format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ avahi_log_ap(AVAHI_LOG_NOTICE, format, ap);
+ va_end(ap);
+}
+
+void avahi_log_info(const gchar*format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ avahi_log_ap(AVAHI_LOG_INFO, format, ap);
+ va_end(ap);
+}
+
+void avahi_log_debug(const gchar*format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ avahi_log_ap(AVAHI_LOG_DEBUG, format, ap);
+ va_end(ap);
+}
diff --git a/avahi-core/log.h b/avahi-core/log.h
new file mode 100644
index 0000000..e75b6c0
--- /dev/null
+++ b/avahi-core/log.h
@@ -0,0 +1,77 @@
+#ifndef foologhfoo
+#define foologhfoo
+
+/* $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.
+***/
+
+#include <stdarg.h>
+#include <glib.h>
+
+#ifdef __GNUC__
+#define AVAHI_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
+#else
+/** Macro for usage of GCC's printf compilation warnings */
+#define AVAHI_GCC_PRINTF_ATTR(a,b)
+#endif
+
+#define AVAHI_GCC_PRINTF_ATTR12 AVAHI_GCC_PRINTF_ATTR(1,2)
+#define AVAHI_GCC_PRINTF_ATTR23 AVAHI_GCC_PRINTF_ATTR(2,3)
+
+/** Log level for avahi_log_xxx() */
+typedef enum {
+ AVAHI_LOG_ERROR = 0, /**< Error messages */
+ AVAHI_LOG_WARN = 1, /**< Warning messages */
+ AVAHI_LOG_NOTICE = 2, /**< Notice messages */
+ AVAHI_LOG_INFO = 3, /**< Info messages */
+ AVAHI_LOG_DEBUG = 4, /**< Debug messages */
+ AVAHI_LOG_LEVEL_MAX
+} AvahiLogLevel;
+
+/** Prototype for a user supplied log function */
+typedef void (*AvahiLogFunction)(AvahiLogLevel level, const gchar *txt);
+
+/** Set a user supplied log function, replacing the default which
+ * prints to log messages unconditionally to STDERR. Pass NULL for
+ * resetting to the default log function */
+void avahi_set_log_function(AvahiLogFunction function);
+
+/** Issue a log message using a va_list object */
+void avahi_log_ap(AvahiLogLevel level, const gchar *format, va_list ap);
+
+/** Issue a log message by passing a log level and a format string */
+void avahi_log(AvahiLogLevel level, const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR23;
+
+/** Shortcut for avahi_log(AVAHI_LOG_ERROR, ...) */
+void avahi_log_error(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
+
+/** Shortcut for avahi_log(AVAHI_LOG_WARN, ...) */
+void avahi_log_warn(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
+
+/** Shortcut for avahi_log(AVAHI_LOG_NOTICE, ...) */
+void avahi_log_notice(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
+
+/** Shortcut for avahi_log(AVAHI_LOG_INFO, ...) */
+void avahi_log_info(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
+
+/** Shortcut for avahi_log(AVAHI_LOG_DEBUG, ...) */
+void avahi_log_debug(const gchar*format, ...) AVAHI_GCC_PRINTF_ATTR12;
+
+#endif
diff --git a/avahi-core/netlink.c b/avahi-core/netlink.c
index 88979e1..50ddf5c 100644
--- a/avahi-core/netlink.c
+++ b/avahi-core/netlink.c
@@ -29,6 +29,7 @@
#include <sys/ioctl.h>
#include "netlink.h"
+#include "log.h"
struct AvahiNetlink {
GMainContext *context;
@@ -55,14 +56,14 @@ gboolean avahi_netlink_work(AvahiNetlink *nl, gboolean block) {
if (errno == EAGAIN || errno == EINTR)
break;
- g_warning("NETLINK: recv() failed: %s", strerror(errno));
+ avahi_log_warn("NETLINK: recv() failed: %s", strerror(errno));
return FALSE;
}
if (nl->callback) {
for (; bytes > 0; p = NLMSG_NEXT(p, bytes)) {
if (!NLMSG_OK(p, (size_t) bytes)) {
- g_warning("NETLINK: packet truncated");
+ avahi_log_warn("NETLINK: packet truncated");
return FALSE;
}
@@ -179,7 +180,7 @@ int avahi_netlink_send(AvahiNetlink *nl, struct nlmsghdr *m, guint *ret_seq) {
m->nlmsg_flags |= NLM_F_ACK;
if (send(nl->fd, m, m->nlmsg_len, 0) < 0) {
- g_warning("NETLINK: send(): %s\n", strerror(errno));
+ avahi_log_warn("NETLINK: send(): %s\n", strerror(errno));
return -1;
}
diff --git a/avahi-core/prioq.c b/avahi-core/prioq.c
index 7e57ae5..ba98d20 100644
--- a/avahi-core/prioq.c
+++ b/avahi-core/prioq.c
@@ -356,12 +356,6 @@ void avahi_prio_queue_remove(AvahiPrioQueue *q, AvahiPrioQueueNode *n) {
if (n->parent) {
g_assert(n->prev);
if (n->parent->left == n) {
- if (n->parent->right != NULL) {
- g_message("fuck");
- for (;;);
-
- }
-
g_assert(n->parent->right == NULL);
n->parent->left = NULL;
} else {
diff --git a/avahi-core/probe-sched.c b/avahi-core/probe-sched.c
index a162dd7..26071d3 100644
--- a/avahi-core/probe-sched.c
+++ b/avahi-core/probe-sched.c
@@ -25,6 +25,7 @@
#include "probe-sched.h"
#include "util.h"
+#include "log.h"
#define AVAHI_PROBE_HISTORY_MSEC 150
#define AVAHI_PROBE_DEFER_MSEC 50
@@ -246,7 +247,7 @@ static void elapse_callback(AvahiTimeEvent *e, gpointer data) {
avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_QDCOUNT, 1);
avahi_interface_send_packet(s->interface, p);
} else
- g_warning("Probe record too large, cannot send");
+ avahi_log_warn("Probe record too large, cannot send");
avahi_dns_packet_free(p);
job_mark_done(s, pj);
@@ -279,7 +280,7 @@ static void elapse_callback(AvahiTimeEvent *e, gpointer data) {
continue;
if (!avahi_dns_packet_append_record(p, pj->record, FALSE, 0)) {
- g_warning("Bad probe size estimate!");
+ avahi_log_warn("Bad probe size estimate!");
/* Unmark all following jobs */
for (; pj; pj = pj->jobs_next)
@@ -370,7 +371,7 @@ gboolean avahi_probe_scheduler_post(AvahiProbeScheduler *s, AvahiRecord *record,
pj->time_event = avahi_time_event_queue_add(s->time_event_queue, &pj->delivery, elapse_callback, pj);
-/* g_message("Accepted new probe job."); */
+/* avahi_log_debug("Accepted new probe job."); */
return TRUE;
}
diff --git a/avahi-core/query-sched.c b/avahi-core/query-sched.c
index 7cdba04..d5135cb 100644
--- a/avahi-core/query-sched.c
+++ b/avahi-core/query-sched.c
@@ -326,7 +326,7 @@ gboolean avahi_query_scheduler_post(AvahiQueryScheduler *s, AvahiKey *key, gbool
g_assert(key);
if ((qj = find_history_job(s, key))) {
-/* g_message("Query suppressed by local duplicate suppression (history)"); */
+/* avahi_log_debug("Query suppressed by local duplicate suppression (history)"); */
return FALSE;
}
@@ -335,7 +335,7 @@ gboolean avahi_query_scheduler_post(AvahiQueryScheduler *s, AvahiKey *key, gbool
if ((qj = find_scheduled_job(s, key))) {
/* Duplicate questions suppression */
-/* g_message("Query suppressed by local duplicate suppression (scheduled)"); */
+/* avahi_log_debug("Query suppressed by local duplicate suppression (scheduled)"); */
if (avahi_timeval_compare(&tv, &qj->delivery) < 0) {
/* If the new entry should be scheduled earlier,
@@ -346,7 +346,7 @@ gboolean avahi_query_scheduler_post(AvahiQueryScheduler *s, AvahiKey *key, gbool
return TRUE;
} else {
-/* g_message("Accepted new query job.\n"); */
+/* avahi_log_debug("Accepted new query job.\n"); */
qj = job_new(s, key, FALSE);
qj->delivery = tv;
@@ -367,7 +367,7 @@ void avahi_query_scheduler_incoming(AvahiQueryScheduler *s, AvahiKey *key) {
* "DUPLICATE QUESTION SUPPRESION". */
if ((qj = find_scheduled_job(s, key))) {
-/* g_message("Query suppressed by distributed duplicate suppression"); */
+/* avahi_log_debug("Query suppressed by distributed duplicate suppression"); */
job_mark_done(s, qj);
return;
}
diff --git a/avahi-core/response-sched.c b/avahi-core/response-sched.c
index f88c63a..1e763e6 100644
--- a/avahi-core/response-sched.c
+++ b/avahi-core/response-sched.c
@@ -25,6 +25,7 @@
#include "response-sched.h"
#include "util.h"
+#include "log.h"
#define AVAHI_RESPONSE_HISTORY_MSEC 700
#define AVAHI_RESPONSE_DEFER_MSEC 20
@@ -233,7 +234,7 @@ static void send_response_packet(AvahiResponseScheduler *s, AvahiResponseJob *rj
if (!packet_add_response_job(s, p, rj)) {
avahi_dns_packet_free(p);
- g_warning("Record too large, cannot send");
+ avahi_log_warn("Record too large, cannot send");
job_mark_done(s, rj);
return;
}
@@ -339,7 +340,7 @@ gboolean avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *r
avahi_record_is_goodbye(record) == avahi_record_is_goodbye(rj->record) &&
rj->record->ttl >= record->ttl/2) {
-/* g_message("Response suppressed by known answer suppression."); */
+/* avahi_log_debug("Response suppressed by known answer suppression."); */
return FALSE;
}
@@ -349,7 +350,7 @@ gboolean avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *r
if (avahi_record_is_goodbye(record) == avahi_record_is_goodbye(rj->record) &&
rj->record->ttl >= record->ttl/2 &&
(rj->flush_cache || !flush_cache)) {
-/* g_message("Response suppressed by local duplicate suppression (history)"); */
+/* avahi_log_debug("Response suppressed by local duplicate suppression (history)"); */
return FALSE;
}
@@ -360,7 +361,7 @@ gboolean avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *r
avahi_elapse_time(&tv, immediately ? 0 : AVAHI_RESPONSE_DEFER_MSEC, immediately ? 0 : AVAHI_RESPONSE_JITTER_MSEC);
if ((rj = find_scheduled_job(s, record))) {
-/* g_message("Response suppressed by local duplicate suppression (scheduled)"); */
+/* avahi_log_debug("Response suppressed by local duplicate suppression (scheduled)"); */
/* Update a little ... */
@@ -384,7 +385,7 @@ gboolean avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *r
return TRUE;
} else {
-/* g_message("Accepted new response job."); */
+/* avahi_log_debug("Accepted new response job."); */
/* Create a new job and schedule it */
rj = job_new(s, record, AVAHI_SCHEDULED);
@@ -414,7 +415,7 @@ void avahi_response_scheduler_incoming(AvahiResponseScheduler *s, AvahiRecord *r
record->ttl >= rj->record->ttl/2) { /* sensible TTL */
/* A matching entry was found, so let's mark it done */
-/* g_message("Response suppressed by distributed duplicate suppression"); */
+/* avahi_log_debug("Response suppressed by distributed duplicate suppression"); */
job_mark_done(s, rj);
}
@@ -450,7 +451,7 @@ void avahi_response_scheduler_suppress(AvahiResponseScheduler *s, AvahiRecord *r
record->ttl >= rj->record->ttl/2) { /* sensible TTL */
/* A matching entry was found, so let's drop it */
-/* g_message("Known answer suppression active!"); */
+/* avahi_log_debug("Known answer suppression active!"); */
job_free(s, rj);
}
}
diff --git a/avahi-core/server.c b/avahi-core/server.c
index e565298..5b00e44 100644
--- a/avahi-core/server.c
+++ b/avahi-core/server.c
@@ -35,6 +35,7 @@
#include "iface.h"
#include "socket.h"
#include "browse.h"
+#include "log.h"
#define AVAHI_HOST_RR_HOLDOFF_MSEC 2000
@@ -161,7 +162,7 @@ void avahi_server_prepare_matching_responses(AvahiServer *s, AvahiInterface *i,
g_assert(i);
g_assert(k);
-/* g_message("Posting responses matching [%s]", txt = avahi_key_to_string(k)); */
+/* avahi_log_debug("Posting responses matching [%s]", txt = avahi_key_to_string(k)); */
/* g_free(txt); */
if (avahi_key_is_pattern(k)) {
@@ -248,9 +249,9 @@ static void incoming_probe(AvahiServer *s, AvahiRecord *record, AvahiInterface *
if (!ours) {
if (won)
- g_message("xxx Recieved conflicting probe [%s]. Local host won.", t);
+ avahi_log_debug("xxx Recieved conflicting probe [%s]. Local host won.", t);
else if (lost) {
- g_message("yyy Recieved conflicting probe [%s]. Local host lost. Withdrawing.", t);
+ avahi_log_debug("yyy Recieved conflicting probe [%s]. Local host lost. Withdrawing.", t);
withdraw_rrset(s, record->key);
}
}
@@ -267,7 +268,7 @@ static gboolean handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *
g_assert(record);
-/* g_message("CHECKING FOR CONFLICT: [%s]", t); */
+/* avahi_log_debug("CHECKING FOR CONFLICT: [%s]", t); */
for (e = g_hash_table_lookup(s->entries_by_key, record->key); e; e = n) {
n = e->by_key_next;
@@ -287,7 +288,7 @@ static gboolean handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *
/* Refresh */
t = avahi_record_to_string(record);
- g_message("Recieved record with bad TTL [%s]. Refreshing.", t);
+ avahi_log_debug("Recieved record with bad TTL [%s]. Refreshing.", t);
avahi_server_prepare_matching_responses(s, i, e->record->key, FALSE);
valid = FALSE;
@@ -316,7 +317,7 @@ static gboolean handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *
}
}
-/* g_message("ours=%i conflict=%i", ours, conflict); */
+/* avahi_log_debug("ours=%i conflict=%i", ours, conflict); */
if (!ours && conflict) {
gchar *t;
@@ -326,11 +327,11 @@ static gboolean handle_conflict(AvahiServer *s, AvahiInterface *i, AvahiRecord *
t = avahi_record_to_string(record);
if (withdraw_immediately) {
- g_message("Recieved conflicting record [%s] with local record to be. Withdrawing.", t);
+ avahi_log_debug("Recieved conflicting record [%s] with local record to be. Withdrawing.", t);
withdraw_rrset(s, record->key);
} else {
g_assert(conflicting_entry);
- g_message("Recieved conflicting record [%s]. Resetting our record.", t);
+ avahi_log_debug("Recieved conflicting record [%s]. Resetting our record.", t);
avahi_entry_return_to_initial_state(s, conflicting_entry, i);
/* Local unique records are returned to probin
@@ -380,7 +381,7 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP
avahi_dns_packet_inc_field(reply, AVAHI_DNS_FIELD_ANCOUNT);
else {
gchar *t = avahi_record_to_string(r);
- g_warning("Record [%s] not fitting in legacy unicast packet, dropping.", t);
+ avahi_log_warn("Record [%s] not fitting in legacy unicast packet, dropping.", t);
g_free(t);
}
@@ -444,7 +445,7 @@ void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsP
avahi_dns_packet_free(reply);
gchar *t = avahi_record_to_string(r);
- g_warning("Record [%s] too large, doesn't fit in any packet!", t);
+ avahi_log_warn("Record [%s] too large, doesn't fit in any packet!", t);
g_free(t);
break;
} else
@@ -544,7 +545,7 @@ static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterfac
g_assert(i);
g_assert(a);
-/* g_message("query"); */
+/* avahi_log_debug("query"); */
g_assert(avahi_record_list_empty(s->record_list));
@@ -554,7 +555,7 @@ static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterfac
gboolean unicast_response = FALSE;
if (!(key = avahi_dns_packet_consume_key(p, &unicast_response))) {
- g_warning("Packet too short (1)");
+ avahi_log_warn("Packet too short (1)");
goto fail;
}
@@ -571,7 +572,7 @@ static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterfac
gboolean unique = FALSE;
if (!(record = avahi_dns_packet_consume_record(p, &unique))) {
- g_warning("Packet too short (2)");
+ avahi_log_warn("Packet too short (2)");
goto fail;
}
@@ -589,7 +590,7 @@ static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterfac
gboolean unique = FALSE;
if (!(record = avahi_dns_packet_consume_record(p, &unique))) {
- g_warning("Packet too short (3)");
+ avahi_log_warn("Packet too short (3)");
goto fail;
}
@@ -619,7 +620,7 @@ static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInter
g_assert(i);
g_assert(a);
-/* g_message("response"); */
+/* avahi_log_debug("response"); */
for (n = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) +
avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ARCOUNT); n > 0; n--) {
@@ -628,13 +629,13 @@ static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInter
/* gchar *txt; */
if (!(record = avahi_dns_packet_consume_record(p, &cache_flush))) {
- g_warning("Packet too short (4)");
+ avahi_log_warn("Packet too short (4)");
break;
}
if (record->key->type != AVAHI_DNS_TYPE_ANY) {
-/* g_message("Handling response: %s", txt = avahi_record_to_string(record)); */
+/* avahi_log_debug("Handling response: %s", txt = avahi_record_to_string(record)); */
/* g_free(txt); */
if (handle_conflict(s, i, record, cache_flush, a)) {
@@ -744,7 +745,7 @@ static void reflect_legacy_unicast_query_packet(AvahiServer *s, AvahiDnsPacket *
if (!s->config.enable_reflector)
return;
-/* g_message("legacy unicast reflectr"); */
+/* avahi_log_debug("legacy unicast reflectr"); */
/* Reflecting legacy unicast queries is a little more complicated
than reflecting normal queries, since we must route the
@@ -756,7 +757,7 @@ static void reflect_legacy_unicast_query_packet(AvahiServer *s, AvahiDnsPacket *
if (!(slot = allocate_slot(s))) {
/* No slot available, we drop this legacy unicast query */
- g_warning("No slot available for legacy unicast reflection, dropping query packet.");
+ avahi_log_warn("No slot available for legacy unicast reflection, dropping query packet.");
return;
}
@@ -804,7 +805,7 @@ static gboolean originates_from_local_legacy_unicast_socket(AvahiServer *s, cons
socklen_t l = sizeof(lsa);
if (getsockname(s->fd_legacy_unicast_ipv4, &lsa, &l) != 0)
- g_warning("getsockname(): %s", strerror(errno));
+ avahi_log_warn("getsockname(): %s", strerror(errno));
else
return lsa.sin_port == ((struct sockaddr_in*) sa)->sin_port;
@@ -815,7 +816,7 @@ static gboolean originates_from_local_legacy_unicast_socket(AvahiServer *s, cons
socklen_t l = sizeof(lsa);
if (getsockname(s->fd_legacy_unicast_ipv6, &lsa, &l) != 0)
- g_warning("getsockname(): %s", strerror(errno));
+ avahi_log_warn("getsockname(): %s", strerror(errno));
else
return lsa.sin6_port == ((struct sockaddr_in6*) sa)->sin6_port;
}
@@ -835,11 +836,11 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const struct sock
if (!(i = avahi_interface_monitor_get_interface(s->monitor, iface, sa->sa_family)) ||
!avahi_interface_relevant(i)) {
- g_warning("Recieved packet from invalid interface.");
+ avahi_log_warn("Recieved packet from invalid interface.");
return;
}
-/* g_message("new packet recieved on interface '%s.%i'.", i->hardware->name, i->protocol); */
+/* avahi_log_debug("new packet recieved on interface '%s.%i'.", i->hardware->name, i->protocol); */
port = avahi_port_from_sockaddr(sa);
avahi_address_from_sockaddr(sa, &a);
@@ -853,7 +854,7 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const struct sock
return;
if (avahi_dns_packet_check_valid(p) < 0) {
- g_warning("Recieved invalid packet.");
+ avahi_log_warn("Recieved invalid packet.");
return;
}
@@ -861,7 +862,7 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const struct sock
gboolean legacy_unicast = FALSE;
if (avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ARCOUNT) != 0) {
- g_warning("Invalid query packet.");
+ avahi_log_warn("Invalid query packet.");
return;
}
@@ -870,7 +871,7 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const struct sock
if ((avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) != 0 ||
avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT) != 0)) {
- g_warning("Invalid legacy unicast query packet.");
+ avahi_log_warn("Invalid legacy unicast query packet.");
return;
}
@@ -882,16 +883,16 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const struct sock
handle_query_packet(s, p, i, &a, port, legacy_unicast);
-/* g_message("Handled query"); */
+/* avahi_log_debug("Handled query"); */
} else {
if (port != AVAHI_MDNS_PORT) {
- g_warning("Recieved repsonse with invalid source port %u on interface '%s.%i'", port, i->hardware->name, i->protocol);
+ avahi_log_warn("Recieved repsonse with invalid source port %u on interface '%s.%i'", port, i->hardware->name, i->protocol);
return;
}
if (ttl != 255) {
- g_warning("Recieved response with invalid TTL %u on interface '%s.%i'.", ttl, i->hardware->name, i->protocol);
+ avahi_log_warn("Recieved response with invalid TTL %u on interface '%s.%i'.", ttl, i->hardware->name, i->protocol);
if (s->config.check_response_ttl)
return;
}
@@ -899,12 +900,12 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const struct sock
if (avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_QDCOUNT) != 0 ||
avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT) == 0 ||
avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_NSCOUNT) != 0) {
- g_warning("Invalid response packet.");
+ avahi_log_warn("Invalid response packet.");
return;
}
handle_response_packet(s, p, i, &a);
-/* g_message("Handled response"); */
+/* avahi_log_debug("Handled response"); */
}
}
@@ -921,11 +922,11 @@ static void dispatch_legacy_unicast_packet(AvahiServer *s, AvahiDnsPacket *p, co
if (!(i = avahi_interface_monitor_get_interface(s->monitor, iface, sa->sa_family)) ||
!avahi_interface_relevant(i)) {
- g_warning("Recieved packet from invalid interface.");
+ avahi_log_warn("Recieved packet from invalid interface.");
return;
}
-/* g_message("new legacy unicast packet recieved on interface '%s.%i'.", i->hardware->name, i->protocol); */
+/* avahi_log_debug("new legacy unicast packet recieved on interface '%s.%i'.", i->hardware->name, i->protocol); */
port = avahi_port_from_sockaddr(sa);
avahi_address_from_sockaddr(sa, &a);
@@ -935,12 +936,12 @@ static void dispatch_legacy_unicast_packet(AvahiServer *s, AvahiDnsPacket *p, co
return;
if (avahi_dns_packet_check_valid(p) < 0 || avahi_dns_packet_is_query(p)) {
- g_warning("Recieved invalid packet.");
+ avahi_log_warn("Recieved invalid packet.");
return;
}
if (!(slot = find_slot(s, avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ID)))) {
- g_warning("Recieved legacy unicast response with unknown id");
+ avahi_log_warn("Recieved legacy unicast response with unknown id");
return;
}
@@ -1267,9 +1268,9 @@ AvahiServer *avahi_server_new(GMainContext *c, const AvahiServerConfig *sc, Avah
}
if (s->fd_ipv4 < 0 && s->config.use_ipv4)
- g_message("Failed to create IPv4 socket, proceeding in IPv6 only mode");
+ avahi_log_debug("Failed to create IPv4 socket, proceeding in IPv6 only mode");
else if (s->fd_ipv6 < 0 && s->config.use_ipv6)
- g_message("Failed to create IPv6 socket, proceeding in IPv4 only mode");
+ avahi_log_debug("Failed to create IPv6 socket, proceeding in IPv4 only mode");
s->fd_legacy_unicast_ipv4 = s->fd_ipv4 >= 0 && s->config.enable_reflector ? avahi_open_legacy_unicast_socket_ipv4() : -1;
s->fd_legacy_unicast_ipv6 = s->fd_ipv6 >= 0 && s->config.enable_reflector ? avahi_open_legacy_unicast_socket_ipv6() : -1;
diff --git a/avahi-core/socket.c b/avahi-core/socket.c
index 7007452..55db704 100644
--- a/avahi-core/socket.c
+++ b/avahi-core/socket.c
@@ -39,6 +39,7 @@
#include "dns.h"
#include "util.h"
#include "socket.h"
+#include "log.h"
static void mdns_mcast_group_ipv4(struct sockaddr_in *ret_sa) {
g_assert(ret_sa);
@@ -94,7 +95,7 @@ int avahi_mdns_mcast_join_ipv4 (int index, int fd) {
mreq.imr_ifindex = index;
if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
- g_warning("IP_ADD_MEMBERSHIP failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_ADD_MEMBERSHIP failed: %s\n", strerror(errno));
return -1;
}
@@ -112,7 +113,7 @@ int avahi_mdns_mcast_join_ipv6 (int index, int fd) {
mreq6.ipv6mr_interface = index;
if (setsockopt(fd, SOL_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) {
- g_warning("IPV6_ADD_MEMBERSHIP failed: %s\n", strerror(errno));
+ avahi_log_warn("IPV6_ADD_MEMBERSHIP failed: %s\n", strerror(errno));
return -1;
}
@@ -130,7 +131,7 @@ int avahi_mdns_mcast_leave_ipv4 (int index, int fd) {
mreq.imr_ifindex = index;
if (setsockopt(fd, SOL_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
- g_warning("IP_DROP_MEMBERSHIP failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_DROP_MEMBERSHIP failed: %s\n", strerror(errno));
return -1;
}
@@ -148,7 +149,7 @@ int avahi_mdns_mcast_leave_ipv6 (int index, int fd) {
mreq6.ipv6mr_interface = index;
if (setsockopt(fd, SOL_IPV6, IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) {
- g_warning("IPV6_DROP_MEMBERSHIP failed: %s\n", strerror(errno));
+ avahi_log_warn("IPV6_DROP_MEMBERSHIP failed: %s\n", strerror(errno));
return -1;
}
@@ -160,31 +161,31 @@ gint avahi_open_socket_ipv4(void) {
int fd = -1, ttl, yes;
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- g_warning("socket() failed: %s\n", strerror(errno));
+ avahi_log_warn("socket() failed: %s\n", strerror(errno));
goto fail;
}
ttl = 255;
if (setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) {
- g_warning("IP_MULTICAST_TTL failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_MULTICAST_TTL failed: %s\n", strerror(errno));
goto fail;
}
ttl = 255;
if (setsockopt(fd, SOL_IP, IP_TTL, &ttl, sizeof(ttl)) < 0) {
- g_warning("IP_TTL failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_TTL failed: %s\n", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
- g_warning("SO_REUSEADDR failed: %s\n", strerror(errno));
+ avahi_log_warn("SO_REUSEADDR failed: %s\n", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {
- g_warning("IP_MULTICAST_LOOP failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_MULTICAST_LOOP failed: %s\n", strerror(errno));
goto fail;
}
@@ -194,29 +195,29 @@ gint avahi_open_socket_ipv4(void) {
local.sin_port = htons(AVAHI_MDNS_PORT);
if (bind(fd, (struct sockaddr*) &local, sizeof(local)) < 0) {
- g_warning("bind() failed: %s\n", strerror(errno));
+ avahi_log_warn("bind() failed: %s\n", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IP, IP_RECVTTL, &yes, sizeof(yes)) < 0) {
- g_warning("IP_RECVTTL failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_RECVTTL failed: %s\n", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0) {
- g_warning("IP_PKTINFO failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_PKTINFO failed: %s\n", strerror(errno));
goto fail;
}
if (avahi_set_cloexec(fd) < 0) {
- g_warning("FD_CLOEXEC failed: %s\n", strerror(errno));
+ avahi_log_warn("FD_CLOEXEC failed: %s\n", strerror(errno));
goto fail;
}
if (avahi_set_nonblock(fd) < 0) {
- g_warning("O_NONBLOCK failed: %s\n", strerror(errno));
+ avahi_log_warn("O_NONBLOCK failed: %s\n", strerror(errno));
goto fail;
}
@@ -236,37 +237,37 @@ gint avahi_open_socket_ipv6(void) {
mdns_mcast_group_ipv6(&sa);
if ((fd = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
- g_warning("socket() failed: %s\n", strerror(errno));
+ avahi_log_warn("socket() failed: %s\n", strerror(errno));
goto fail;
}
ttl = 255;
if (setsockopt(fd, SOL_IPV6, IPV6_MULTICAST_HOPS, &ttl, sizeof(ttl)) < 0) {
- g_warning("IPV6_MULTICAST_HOPS failed: %s\n", strerror(errno));
+ avahi_log_warn("IPV6_MULTICAST_HOPS failed: %s\n", strerror(errno));
goto fail;
}
ttl = 255;
if (setsockopt(fd, SOL_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl)) < 0) {
- g_warning("IPV6_UNICAST_HOPS failed: %s\n", strerror(errno));
+ avahi_log_warn("IPV6_UNICAST_HOPS failed: %s\n", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
- g_warning("SO_REUSEADDR failed: %s\n", strerror(errno));
+ avahi_log_warn("SO_REUSEADDR failed: %s\n", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IPV6, IPV6_V6ONLY, &yes, sizeof(yes)) < 0) {
- g_warning("IPV6_V6ONLY failed: %s\n", strerror(errno));
+ avahi_log_warn("IPV6_V6ONLY failed: %s\n", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IPV6, IPV6_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {
- g_warning("IPV6_MULTICAST_LOOP failed: %s\n", strerror(errno));
+ avahi_log_warn("IPV6_MULTICAST_LOOP failed: %s\n", strerror(errno));
goto fail;
}
@@ -275,29 +276,29 @@ gint avahi_open_socket_ipv6(void) {
local.sin6_port = htons(AVAHI_MDNS_PORT);
if (bind(fd, (struct sockaddr*) &local, sizeof(local)) < 0) {
- g_warning("bind() failed: %s\n", strerror(errno));
+ avahi_log_warn("bind() failed: %s\n", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IPV6, IPV6_HOPLIMIT, &yes, sizeof(yes)) < 0) {
- g_warning("IPV6_HOPLIMIT failed: %s\n", strerror(errno));
+ avahi_log_warn("IPV6_HOPLIMIT failed: %s\n", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IPV6, IPV6_PKTINFO, &yes, sizeof(yes)) < 0) {
- g_warning("IPV6_PKTINFO failed: %s\n", strerror(errno));
+ avahi_log_warn("IPV6_PKTINFO failed: %s\n", strerror(errno));
goto fail;
}
if (avahi_set_cloexec(fd) < 0) {
- g_warning("FD_CLOEXEC failed: %s\n", strerror(errno));
+ avahi_log_warn("FD_CLOEXEC failed: %s\n", strerror(errno));
goto fail;
}
if (avahi_set_nonblock(fd) < 0) {
- g_warning("O_NONBLOCK failed: %s\n", strerror(errno));
+ avahi_log_warn("O_NONBLOCK failed: %s\n", strerror(errno));
goto fail;
}
@@ -320,7 +321,7 @@ static gint sendmsg_loop(gint fd, struct msghdr *msg, gint flags) {
break;
if (errno != EAGAIN) {
- g_message("sendmsg() failed: %s\n", strerror(errno));
+ avahi_log_debug("sendmsg() failed: %s\n", strerror(errno));
return -1;
}
@@ -432,7 +433,7 @@ AvahiDnsPacket* avahi_recv_dns_packet_ipv4(gint fd, struct sockaddr_in *ret_sa,
g_assert(ret_ttl);
if (ioctl(fd, FIONREAD, &ms) < 0) {
- g_warning("ioctl(): %s", strerror(errno));
+ avahi_log_warn("ioctl(): %s", strerror(errno));
goto fail;
}
@@ -451,7 +452,7 @@ AvahiDnsPacket* avahi_recv_dns_packet_ipv4(gint fd, struct sockaddr_in *ret_sa,
msg.msg_flags = 0;
if ((l = recvmsg(fd, &msg, 0)) < 0) {
- g_warning("recvmsg(): %s", strerror(errno));
+ avahi_log_warn("recvmsg(): %s", strerror(errno));
goto fail;
}
@@ -488,7 +489,7 @@ AvahiDnsPacket* avahi_recv_dns_packet_ipv4(gint fd, struct sockaddr_in *ret_sa,
}
}
-/* g_message("ttl=%u iface=%i", *ret_ttl, *ret_iface); */
+/* avahi_log_debug("ttl=%u iface=%i", *ret_ttl, *ret_iface); */
g_assert(found_iface);
g_assert(found_ttl);
@@ -519,7 +520,7 @@ AvahiDnsPacket* avahi_recv_dns_packet_ipv6(gint fd, struct sockaddr_in6 *ret_sa,
g_assert(ret_ttl);
if (ioctl(fd, FIONREAD, &ms) < 0) {
- g_warning("ioctl(): %s", strerror(errno));
+ avahi_log_warn("ioctl(): %s", strerror(errno));
goto fail;
}
@@ -538,7 +539,7 @@ AvahiDnsPacket* avahi_recv_dns_packet_ipv6(gint fd, struct sockaddr_in6 *ret_sa,
msg.msg_flags = 0;
if ((l = recvmsg(fd, &msg, 0)) < 0) {
- g_warning("recvmsg(): %s", strerror(errno));
+ avahi_log_warn("recvmsg(): %s", strerror(errno));
goto fail;
}
@@ -575,7 +576,7 @@ gint avahi_open_legacy_unicast_socket_ipv4(void) {
int fd = -1, yes;
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- g_warning("socket() failed: %s\n", strerror(errno));
+ avahi_log_warn("socket() failed: %s\n", strerror(errno));
goto fail;
}
@@ -583,29 +584,29 @@ gint avahi_open_legacy_unicast_socket_ipv4(void) {
local.sin_family = AF_INET;
if (bind(fd, (struct sockaddr*) &local, sizeof(local)) < 0) {
- g_warning("bind() failed: %s\n", strerror(errno));
+ avahi_log_warn("bind() failed: %s\n", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IP, IP_RECVTTL, &yes, sizeof(yes)) < 0) {
- g_warning("IP_RECVTTL failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_RECVTTL failed: %s\n", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IP, IP_PKTINFO, &yes, sizeof(yes)) < 0) {
- g_warning("IP_PKTINFO failed: %s\n", strerror(errno));
+ avahi_log_warn("IP_PKTINFO failed: %s\n", strerror(errno));
goto fail;
}
if (avahi_set_cloexec(fd) < 0) {
- g_warning("FD_CLOEXEC failed: %s\n", strerror(errno));
+ avahi_log_warn("FD_CLOEXEC failed: %s\n", strerror(errno));
goto fail;
}
if (avahi_set_nonblock(fd) < 0) {
- g_warning("O_NONBLOCK failed: %s\n", strerror(errno));
+ avahi_log_warn("O_NONBLOCK failed: %s\n", strerror(errno));
goto fail;
}
@@ -623,7 +624,7 @@ gint avahi_open_legacy_unicast_socket_ipv6(void) {
int fd = -1, yes;
if ((fd = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
- g_warning("socket() failed: %s\n", strerror(errno));
+ avahi_log_warn("socket() failed: %s\n", strerror(errno));
goto fail;
}
@@ -631,29 +632,29 @@ gint avahi_open_legacy_unicast_socket_ipv6(void) {
local.sin_family = AF_INET;
if (bind(fd, (struct sockaddr*) &local, sizeof(local)) < 0) {
- g_warning("bind() failed: %s\n", strerror(errno));
+ avahi_log_warn("bind() failed: %s\n", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IPV6, IPV6_HOPLIMIT, &yes, sizeof(yes)) < 0) {
- g_warning("IPV6_HOPLIMIT failed: %s\n", strerror(errno));
+ avahi_log_warn("IPV6_HOPLIMIT failed: %s\n", strerror(errno));
goto fail;
}
yes = 1;
if (setsockopt(fd, SOL_IPV6, IPV6_PKTINFO, &yes, sizeof(yes)) < 0) {
- g_warning("IPV6_PKTINFO failed: %s\n", strerror(errno));
+ avahi_log_warn("IPV6_PKTINFO failed: %s\n", strerror(errno));
goto fail;
}
if (avahi_set_cloexec(fd) < 0) {
- g_warning("FD_CLOEXEC failed: %s\n", strerror(errno));
+ avahi_log_warn("FD_CLOEXEC failed: %s\n", strerror(errno));
goto fail;
}
if (avahi_set_nonblock(fd) < 0) {
- g_warning("O_NONBLOCK failed: %s\n", strerror(errno));
+ avahi_log_warn("O_NONBLOCK failed: %s\n", strerror(errno));
goto fail;
}