#include <sys/ioctl.h>
#include "netlink.h"
+#include "log.h"
struct AvahiNetlink {
GMainContext *context;
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;
}
NULL
};
- g_assert(context);
g_assert(cb);
if ((fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)) < 0) {
}
nl = g_new(AvahiNetlink, 1);
- nl->context = context;
- g_main_context_ref(context);
+ g_main_context_ref(nl->context = context ? context : g_main_context_default());
nl->fd = fd;
nl->seq = 0;
nl->callback = cb;
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;
}