From: Sven M. Hallberg Date: Mon, 8 Sep 2014 15:06:23 +0000 (+0200) Subject: fix an error message for IPv6 X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=87028029f3968195d3f2c67e43fa0bea79550797;p=catta fix an error message for IPv6 --- 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; }