Use inet_ntop(3) instead of inet_ntoa(3) for AF_INET socket details.
This also makes the code closer to the one used for AF_INET6.
This commit is contained in:
parent
a930ecddaa
commit
b9eabd15fd
@ -106,8 +106,13 @@ addr_to_string(struct sockaddr_storage *ss, char *buffer, int buflen)
|
||||
|
||||
case AF_INET:
|
||||
sin = (struct sockaddr_in *)ss;
|
||||
snprintf(buffer, buflen, "%s:%d", inet_ntoa(sin->sin_addr),
|
||||
ntohs(sin->sin_port));
|
||||
if (IS_INADDR_ANY(sin->sin_addr))
|
||||
snprintf(buffer, buflen, "%s:%d", "*",
|
||||
ntohs(sin->sin_port));
|
||||
else if (inet_ntop(AF_INET, &sin->sin_addr, buffer2,
|
||||
sizeof(buffer2)) != NULL)
|
||||
snprintf(buffer, buflen, "%s:%d", buffer2,
|
||||
ntohs(sin->sin_port));
|
||||
break;
|
||||
|
||||
case AF_INET6:
|
||||
|
Loading…
Reference in New Issue
Block a user