1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +00:00

Remove almost all uses of NetAddress.

This probably has a bunch of bugs because of Network Order/Host Order
issues. If we intend to actually support BE architectures, these
problems are going to get much much worse :(
This commit is contained in:
Darryl Pogue
2012-03-12 21:59:10 -07:00
parent 4b3d4a0d83
commit 4737e791cb
10 changed files with 38 additions and 80 deletions

View File

@ -94,30 +94,6 @@ static NetAddressNode NodeFromString (const wchar_t * string[]) {
*
***/
//===========================================================================
void NetAddressToString (
const NetAddress & addr,
wchar_t * str,
unsigned chars,
ENetAddressFormat format
) {
ASSERT(str);
static const wchar_t * s_fmts[] = {
L"%S", // kNetAddressFormatNodeNumber
L"%S:%u", // kNetAddressFormatAll
};
ASSERT(format < arrsize(s_fmts));
const sockaddr_in & inetaddr = * (const sockaddr_in *) &addr;
StrPrintf(
str,
chars,
s_fmts[format],
inet_ntoa(inetaddr.sin_addr),
ntohs(inetaddr.sin_port)
);
}
//===========================================================================
bool NetAddressFromString (NetAddress * addr, const wchar_t str[], unsigned defaultPort) {
ASSERT(addr);
@ -146,14 +122,3 @@ bool NetAddressFromString (NetAddress * addr, const wchar_t str[], unsigned defa
// address already zeroed
return false;
}
//===========================================================================
void NetAddressNodeToString (
NetAddressNode node,
wchar_t * str,
unsigned chars
) {
in_addr addr;
addr.S_un.S_addr = htonl(node);
StrPrintf(str, chars, L"%S", inet_ntoa(addr));
}

View File

@ -74,19 +74,6 @@ typedef uint32_t NetAddressNode;
*
***/
enum ENetAddressFormat {
kNetAddressFormatNodeNumber,
kNetAddressFormatAll,
kNumNetAddressFormats
};
void NetAddressToString (
const NetAddress & addr,
wchar_t * str,
unsigned chars,
ENetAddressFormat format
);
// 'str' must be in the form of a dotted IP address (IPv4 or IPv6)
// - names which require DNS lookup will cause the function to return false
bool NetAddressFromString (
@ -95,10 +82,4 @@ bool NetAddressFromString (
unsigned defaultPort
);
void NetAddressNodeToString (
NetAddressNode node,
wchar_t * str,
unsigned chars
);
#endif