]> git.meshlink.io Git - catta/blobdiff - avahi-core/netlink.c
* include dbus-protocol.h in dbus-protocol.c
[catta] / avahi-core / netlink.c
index e3cc3fa1a4614d4a90920d7d498a5d5243ddbc79..50ddf5c282aa3442e62fb9627024aac925fdbbc1 100644 (file)
 #include <unistd.h>
 #include <errno.h>
 #include <string.h>
+#include <sys/ioctl.h>
 
 #include "netlink.h"
+#include "log.h"
 
 struct AvahiNetlink {
     GMainContext *context;
@@ -43,23 +45,25 @@ gboolean avahi_netlink_work(AvahiNetlink *nl, gboolean block) {
     g_assert(nl);
 
     for (;;) {
-        guint8 replybuf[64*1024];
         ssize_t bytes;
-        struct nlmsghdr *p = (struct nlmsghdr *) replybuf;
+        struct nlmsghdr *p;
+        guint8 buffer[64*1024];
 
-        if ((bytes = recv(nl->fd, replybuf, sizeof(replybuf), block ? 0 : MSG_DONTWAIT)) < 0) {
+        p = (struct nlmsghdr *) buffer;
+
+        if ((bytes = recv(nl->fd, buffer, sizeof(buffer), block ? 0 : MSG_DONTWAIT)) < 0) {
 
             if (errno == EAGAIN || errno == EINTR)
                 break;
 
-            g_warning("NETLINK: recv() failed");
+            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;
                 }
 
@@ -160,7 +164,7 @@ AvahiNetlink *avahi_netlink_new(GMainContext *context, gint priority, guint32 gr
 
 void avahi_netlink_free(AvahiNetlink *nl) {
     g_assert(nl);
-    
+
     g_source_destroy(nl->source);
     g_source_unref(nl->source);
     g_main_context_unref(nl->context);
@@ -176,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;
     }