]> git.meshlink.io Git - catta/commitdiff
fix an error message for IPv6
authorSven M. Hallberg <pesco@khjk.org>
Mon, 8 Sep 2014 15:06:23 +0000 (17:06 +0200)
committerSven M. Hallberg <pesco@khjk.org>
Mon, 8 Sep 2014 15:06:23 +0000 (17:06 +0200)
src/socket.c

index dc989d8ac466f1647a5aa278b5ee980b667aae77..28132db16de3bc113e219892a0339ad4acdc45ec 100644 (file)
@@ -464,9 +464,12 @@ static int sendmsg_loop(int fd, struct msghdr *msg, int flags) {
 
         if (errno != EAGAIN && errno != EWOULDBLOCK) {
             char where[64];
-            struct sockaddr_in *sin = msg->msg_name;
+            struct sockaddr *sa = msg->msg_name;
 
-            inet_ntop(sin->sin_family, &sin->sin_addr, where, sizeof(where));
+            if(sa->sa_family == AF_INET)
+                inet_ntop(sa->sa_family, &((struct sockaddr_in *)sa)->sin_addr, where, sizeof(where));
+            else
+                inet_ntop(sa->sa_family, &((struct sockaddr_in6 *)sa)->sin6_addr, where, sizeof(where));
             catta_log_debug("sendmsg() to %s failed: %s", where, errnostrsocket());
             return -1;
         }