netplay address printing:
* Don't cast if we can safely alter the format specifiers * Fix a spelling error: 'address famliy' -> 'address family' git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7897 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
ae8ec8652c
commit
7952b39be8
|
@ -359,29 +359,29 @@ static int addressToText(const struct sockaddr* addr, char* buf, size_t size)
|
||||||
unsigned char* address = (unsigned char*)&((const struct sockaddr_in*)addr)->sin_addr.s_addr;
|
unsigned char* address = (unsigned char*)&((const struct sockaddr_in*)addr)->sin_addr.s_addr;
|
||||||
|
|
||||||
return snprintf(buf, size,
|
return snprintf(buf, size,
|
||||||
"%i.%i.%i.%i",
|
"%hhu.%hhu.%hhu.%hhu",
|
||||||
(int)(address[0]),
|
address[0],
|
||||||
(int)(address[1]),
|
address[1],
|
||||||
(int)(address[2]),
|
address[2],
|
||||||
(int)(address[3]));
|
address[3]);
|
||||||
}
|
}
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
{
|
{
|
||||||
uint16_t* address = (uint16_t*)&((const struct sockaddr_in6*)addr)->sin6_addr.s6_addr;
|
uint16_t* address = (uint16_t*)&((const struct sockaddr_in6*)addr)->sin6_addr.s6_addr;
|
||||||
|
|
||||||
return snprintf(buf, size,
|
return snprintf(buf, size,
|
||||||
"%x:%x:%x:%x:%x:%x:%x:%x",
|
"%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx",
|
||||||
(int)ntohs(address[0]),
|
ntohs(address[0]),
|
||||||
(int)ntohs(address[1]),
|
ntohs(address[1]),
|
||||||
(int)ntohs(address[2]),
|
ntohs(address[2]),
|
||||||
(int)ntohs(address[3]),
|
ntohs(address[3]),
|
||||||
(int)ntohs(address[4]),
|
ntohs(address[4]),
|
||||||
(int)ntohs(address[5]),
|
ntohs(address[5]),
|
||||||
(int)ntohs(address[6]),
|
ntohs(address[6]),
|
||||||
(int)ntohs(address[7]));
|
ntohs(address[7]));
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
ASSERT(!"Unknown address famliy", "Got non IPv4 or IPv6 address!");
|
ASSERT(!"Unknown address family", "Got non IPv4 or IPv6 address!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue