]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Use recvmsg_alloc on Solaris too.
authorRoy Marples <roy@marples.name>
Thu, 1 Sep 2016 17:12:37 +0000 (17:12 +0000)
committerRoy Marples <roy@marples.name>
Thu, 1 Sep 2016 17:12:37 +0000 (17:12 +0000)
common.c
if-sun.c

index a0b1be14280b5c1a8f554bc7b502090f8db6672b..3c0de44eb1d5e86333b051b9ef82de17cca82a98 100644 (file)
--- a/common.c
+++ b/common.c
@@ -27,6 +27,9 @@
 
 #include <sys/param.h>
 #include <sys/time.h>
+#ifdef __sun
+#include <sys/sysmacros.h>
+#endif
 
 #include <ctype.h>
 #include <err.h>
index 53a428013b46d6373da4572a9e55d565bb5c2e1a..064ab936bfa1c3e346df670cd391e0a4bb0f8d04 100644 (file)
--- a/if-sun.c
+++ b/if-sun.c
@@ -769,20 +769,15 @@ if_dispatch(struct dhcpcd_ctx *ctx, const struct rt_msghdr *rtm)
 int
 if_handlelink(struct dhcpcd_ctx *ctx)
 {
-       char buf[2048];
-       const char *p, *e;
-       size_t msglen;
+       struct msghdr msg;
        ssize_t bytes;
-       const struct rt_msghdr *rtm;
 
-       if ((bytes = read(ctx->link_fd, buf, sizeof(buf))) == -1)
+       memset(&msg, 0, sizeof(msg));
+       msg.msg_iov = &ctx->iov;
+
+       if ((bytes = recvmsg_alloc(ctx->link_fd, &msg)) == -1)
                return -1;
-       e = buf + bytes;
-       for (p = buf; p < e; p += msglen) {
-               rtm = (const  void *)p;
-               msglen = rtm->rtm_msglen;
-               if_dispatch(ctx, rtm);
-       }
+       if_dispatch(ctx, ctx->iov.iov_base);
        return 0;
 }