mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04: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:
@ -115,9 +115,8 @@ static bool QueryAccept (
|
|||||||
SimpleNetConn * ,
|
SimpleNetConn * ,
|
||||||
const NetAddress & addr
|
const NetAddress & addr
|
||||||
) {
|
) {
|
||||||
wchar_t str[64];
|
plString str = addr.AsString();
|
||||||
NetAddressToString(addr, str, arrsize(str), kNetAddressFormatAll);
|
LogMsg(kLogPerf, L"pfCsrSrv: Accepted connection from %s", str.c_str());
|
||||||
LogMsg(kLogPerf, L"pfCsrSrv: Accepted connection from %s", str);
|
|
||||||
return channel == kSimpleNetChannelCsr;
|
return channel == kSimpleNetChannelCsr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,12 +547,11 @@ static SOCKET ListenSocket (NetAddress * listenAddr) {
|
|||||||
sockaddr_in addr;
|
sockaddr_in addr;
|
||||||
addr.sin_family = AF_INET;
|
addr.sin_family = AF_INET;
|
||||||
addr.sin_port = htons((uint16_t)port);
|
addr.sin_port = htons((uint16_t)port);
|
||||||
addr.sin_addr.S_un.S_addr = htonl(node);
|
addr.sin_addr.S_un.S_addr = node;
|
||||||
memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
|
memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
|
||||||
if (bind(s, (sockaddr *) &addr, sizeof(addr))) {
|
if (bind(s, (sockaddr *) &addr, sizeof(addr))) {
|
||||||
wchar_t str[32];
|
plString str = listenAddr->AsString();
|
||||||
NetAddressToString(*listenAddr, str, arrsize(str), kNetAddressFormatAll);
|
LogMsg(kLogError, "bind to addr %s failed (err %u)", str.c_str(), WSAGetLastError());
|
||||||
LogMsg(kLogError, "bind to addr %s failed (err %u)", str, WSAGetLastError());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,13 +340,10 @@ void AsyncAddressLookupAddr (
|
|||||||
lookup->lookupProc = lookupProc;
|
lookup->lookupProc = lookupProc;
|
||||||
lookup->port = 1;
|
lookup->port = 1;
|
||||||
lookup->param = param;
|
lookup->param = param;
|
||||||
NetAddressToString(
|
|
||||||
address,
|
plString str = address.GetHostString();
|
||||||
lookup->name,
|
lookup->name = str.toUtf16().GetData();
|
||||||
arrsize(lookup->name),
|
|
||||||
kNetAddressFormatNodeNumber
|
|
||||||
);
|
|
||||||
|
|
||||||
s_critsect.Enter();
|
s_critsect.Enter();
|
||||||
{
|
{
|
||||||
// Start the lookup thread if it wasn't started already
|
// Start the lookup thread if it wasn't started already
|
||||||
|
@ -57,7 +57,7 @@ plNetAddress::plNetAddress(uint32_t addr, uint16_t port)
|
|||||||
SetPort(port);
|
SetPort(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
plNetAddress::plNetAddress(const char * addr, uint16_t port)
|
plNetAddress::plNetAddress(const char* addr, uint16_t port)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
SetHost(addr);
|
SetHost(addr);
|
||||||
@ -103,6 +103,11 @@ plString plNetAddress::GetHostString() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t plNetAddress::GetHost() const
|
uint32_t plNetAddress::GetHost() const
|
||||||
|
{
|
||||||
|
return ntohl(fAddr.sin_addr.s_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t plNetAddress::GetHostBE() const
|
||||||
{
|
{
|
||||||
return fAddr.sin_addr.s_addr;
|
return fAddr.sin_addr.s_addr;
|
||||||
}
|
}
|
||||||
@ -122,6 +127,13 @@ bool plNetAddress::SetHost(const char* hostname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool plNetAddress::SetHost(uint32_t addr)
|
bool plNetAddress::SetHost(uint32_t addr)
|
||||||
|
{
|
||||||
|
fAddr.sin_addr.s_addr = htonl(addr);
|
||||||
|
fAddr.sin_family = AF_INET;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool plNetAddress::SetHostBE(uint32_t addr)
|
||||||
{
|
{
|
||||||
memcpy(&fAddr.sin_addr, &addr,sizeof(addr));
|
memcpy(&fAddr.sin_addr, &addr,sizeof(addr));
|
||||||
fAddr.sin_family = AF_INET;
|
fAddr.sin_family = AF_INET;
|
||||||
|
@ -95,8 +95,10 @@ public:
|
|||||||
bool SetPort(uint16_t port);
|
bool SetPort(uint16_t port);
|
||||||
|
|
||||||
uint32_t GetHost() const;
|
uint32_t GetHost() const;
|
||||||
|
uint32_t GetHostBE() const;
|
||||||
bool SetHost(const char* hostname);
|
bool SetHost(const char* hostname);
|
||||||
bool SetHost(uint32_t ip4addr);
|
bool SetHost(uint32_t ip4addr);
|
||||||
|
bool SetHostBE(uint32_t addr);
|
||||||
|
|
||||||
const AddressType& GetAddressInfo() const { return fAddr; }
|
const AddressType& GetAddressInfo() const { return fAddr; }
|
||||||
AddressType& GetAddressInfo() { return fAddr; }
|
AddressType& GetAddressInfo() { return fAddr; }
|
||||||
|
@ -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) {
|
bool NetAddressFromString (NetAddress * addr, const wchar_t str[], unsigned defaultPort) {
|
||||||
ASSERT(addr);
|
ASSERT(addr);
|
||||||
@ -146,14 +122,3 @@ bool NetAddressFromString (NetAddress * addr, const wchar_t str[], unsigned defa
|
|||||||
// address already zeroed
|
// address already zeroed
|
||||||
return false;
|
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));
|
|
||||||
}
|
|
||||||
|
@ -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)
|
// '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
|
// - names which require DNS lookup will cause the function to return false
|
||||||
bool NetAddressFromString (
|
bool NetAddressFromString (
|
||||||
@ -95,10 +82,4 @@ bool NetAddressFromString (
|
|||||||
unsigned defaultPort
|
unsigned defaultPort
|
||||||
);
|
);
|
||||||
|
|
||||||
void NetAddressNodeToString (
|
|
||||||
NetAddressNode node,
|
|
||||||
wchar_t * str,
|
|
||||||
unsigned chars
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -591,23 +591,22 @@ static void INetCliAuthAgeRequestCallback (
|
|||||||
unsigned ageMcpId,
|
unsigned ageMcpId,
|
||||||
unsigned ageVaultId,
|
unsigned ageVaultId,
|
||||||
const Uuid & ageInstId,
|
const Uuid & ageInstId,
|
||||||
NetAddressNode gameAddr
|
plNetAddress gameAddr
|
||||||
) {
|
) {
|
||||||
if (!IS_NET_ERROR(result) || result == kNetErrVaultNodeNotFound) {
|
if (!IS_NET_ERROR(result) || result == kNetErrVaultNodeNotFound) {
|
||||||
s_age.ageInstId = ageInstId;
|
s_age.ageInstId = ageInstId;
|
||||||
s_age.ageVaultId = ageVaultId;
|
s_age.ageVaultId = ageVaultId;
|
||||||
|
|
||||||
wchar_t gameAddrStr[64];
|
|
||||||
wchar_t ageInstIdStr[64];
|
wchar_t ageInstIdStr[64];
|
||||||
NetAddressNodeToString(gameAddr, gameAddrStr, arrsize(gameAddrStr));
|
plString gameAddrStr = gameAddr.GetHostString();
|
||||||
LogMsg(
|
LogMsg(
|
||||||
kLogPerf,
|
kLogPerf,
|
||||||
L"Connecting to game server %s, ageInstId %s",
|
L"Connecting to game server %s, ageInstId %s",
|
||||||
gameAddrStr,
|
gameAddrStr.c_str(),
|
||||||
GuidToString(ageInstId, ageInstIdStr, arrsize(ageInstIdStr))
|
GuidToString(ageInstId, ageInstIdStr, arrsize(ageInstIdStr))
|
||||||
);
|
);
|
||||||
NetCliGameDisconnect();
|
NetCliGameDisconnect();
|
||||||
NetCliGameStartConnect(gameAddr);
|
NetCliGameStartConnect(gameAddr.GetHost());
|
||||||
NetCliGameJoinAgeRequest(
|
NetCliGameJoinAgeRequest(
|
||||||
ageMcpId,
|
ageMcpId,
|
||||||
s_account.accountUuid,
|
s_account.accountUuid,
|
||||||
|
@ -90,8 +90,8 @@ struct CliAuConn : AtomicRef {
|
|||||||
LINK(CliAuConn) link;
|
LINK(CliAuConn) link;
|
||||||
AsyncSocket sock;
|
AsyncSocket sock;
|
||||||
NetCli * cli;
|
NetCli * cli;
|
||||||
wchar_t name[MAX_PATH];
|
wchar_t name[MAX_PATH];
|
||||||
NetAddress addr;
|
plNetAddress addr;
|
||||||
Uuid token;
|
Uuid token;
|
||||||
unsigned seq;
|
unsigned seq;
|
||||||
unsigned serverChallenge;
|
unsigned serverChallenge;
|
||||||
@ -1545,9 +1545,9 @@ static void Connect (
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
static void AsyncLookupCallback (
|
static void AsyncLookupCallback (
|
||||||
void * param,
|
void * param,
|
||||||
const wchar_t name[],
|
const wchar_t name[],
|
||||||
unsigned addrCount,
|
unsigned addrCount,
|
||||||
const NetAddress addrs[]
|
const plNetAddress addrs[]
|
||||||
) {
|
) {
|
||||||
if (!addrCount) {
|
if (!addrCount) {
|
||||||
ReportNetError(kNetProtocolCli2Auth, kNetErrNameLookupFailed);
|
ReportNetError(kNetProtocolCli2Auth, kNetErrNameLookupFailed);
|
||||||
@ -2753,13 +2753,16 @@ bool AgeRequestTrans::Send () {
|
|||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void AgeRequestTrans::Post () {
|
void AgeRequestTrans::Post () {
|
||||||
|
plNetAddress addr;
|
||||||
|
addr.SetHost(m_gameSrvNode);
|
||||||
|
|
||||||
m_callback(
|
m_callback(
|
||||||
m_result,
|
m_result,
|
||||||
m_param,
|
m_param,
|
||||||
m_ageMcpId,
|
m_ageMcpId,
|
||||||
m_ageVaultId,
|
m_ageVaultId,
|
||||||
m_ageInstId,
|
m_ageInstId,
|
||||||
m_gameSrvNode
|
addr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
#endif
|
#endif
|
||||||
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLAUTH_H
|
#define PLASMA20_SOURCES_PLASMA_PUBUTILLIB_PLNETGAMELIB_PRIVATE_PLNGLAUTH_H
|
||||||
|
|
||||||
|
#include "pnNetCommon/plNetAddress.h"
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
@ -326,7 +327,7 @@ typedef void (*FNetCliAuthAgeRequestCallback)(
|
|||||||
unsigned ageMcpId,
|
unsigned ageMcpId,
|
||||||
unsigned ageVaultId,
|
unsigned ageVaultId,
|
||||||
const Uuid & ageInstId,
|
const Uuid & ageInstId,
|
||||||
NetAddressNode gameAddr
|
plNetAddress gameAddr
|
||||||
);
|
);
|
||||||
void NetCliAuthAgeRequest (
|
void NetCliAuthAgeRequest (
|
||||||
const wchar_t ageName[], // L"Teledahn"
|
const wchar_t ageName[], // L"Teledahn"
|
||||||
|
Reference in New Issue
Block a user