sim_sock.c - preferred a bare textual IPv4 address be returned over an IPv4-mapped format address when returning the connecting IP address string in sim_accept_conn.
This commit is contained in:
parent
8b59f2a12a
commit
3e78dc6732
1 changed files with 2 additions and 0 deletions
|
@ -733,6 +733,8 @@ if (connectaddr != NULL) {
|
||||||
*connectaddr = calloc(1, NI_MAXHOST+1);
|
*connectaddr = calloc(1, NI_MAXHOST+1);
|
||||||
#ifdef AF_INET6
|
#ifdef AF_INET6
|
||||||
p_getnameinfo((struct sockaddr *)&clientname, size, *connectaddr, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
p_getnameinfo((struct sockaddr *)&clientname, size, *connectaddr, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
||||||
|
if (0 == memcmp("::ffff:", *connectaddr, 7)) /* is this a IPv4-mapped IPv6 address? */
|
||||||
|
strcpy(*connectaddr, 7+*connectaddr); /* prefer bare IPv4 address if possible */
|
||||||
#else
|
#else
|
||||||
strcpy(*connectaddr, inet_ntoa(((struct sockaddr_in *)&connectaddr)->s_addr));
|
strcpy(*connectaddr, inet_ntoa(((struct sockaddr_in *)&connectaddr)->s_addr));
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue