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
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=353364
@ -106,7 +106,12 @@ 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),
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user