From 87028029f3968195d3f2c67e43fa0bea79550797 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" Date: Mon, 8 Sep 2014 17:06:23 +0200 Subject: [PATCH] fix an error message for IPv6 --- src/socket.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/socket.c b/src/socket.c index dc989d8..28132db 100644 --- a/src/socket.c +++ b/src/socket.c @@ -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; } -- 2.39.5