Browse Source

Add an operator== to plNetAddress.

Darryl Pogue 13 years ago
parent
commit
4b3d4a0d83
  1. 2
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp
  2. 7
      Sources/Plasma/NucleusLib/pnNetCommon/plNetAddress.h
  3. 9
      Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Addr.cpp
  4. 5
      Sources/Plasma/NucleusLib/pnUtils/pnUtAddr.h

2
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp

@ -177,7 +177,7 @@ static bool ListenPortIncrement (
) { ) {
NtListener * listener; NtListener * listener;
for (listener = s_listenList.Head(); listener; listener = s_listenList.Next(listener)) { for (listener = s_listenList.Head(); listener; listener = s_listenList.Next(listener)) {
if (!NetAddressEqual(listener->addr, listenAddr)) if (listener->addr != listenAddr)
continue; continue;
if (listener->notifyProc != notifyProc) if (listener->notifyProc != notifyProc)
continue; continue;

7
Sources/Plasma/NucleusLib/pnNetCommon/plNetAddress.h

@ -79,6 +79,13 @@ public:
plNetAddress(const char* addr, uint16_t port); plNetAddress(const char* addr, uint16_t port);
virtual ~plNetAddress(){} virtual ~plNetAddress(){}
bool operator==(const plNetAddress& other) const {
return (GetHost() == other.GetHost()) && (GetPort() == other.GetPort());
}
bool operator!=(const plNetAddress& other) const {
return !(*this == other);
}
void Clear(); void Clear();
bool SetAnyAddr(); bool SetAnyAddr();

9
Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Addr.cpp

@ -94,15 +94,6 @@ static NetAddressNode NodeFromString (const wchar_t * string[]) {
* *
***/ ***/
//===========================================================================
int NetAddressCompare (const NetAddress & a1, const NetAddress & a2) {
const sockaddr_in & i1 = * (const sockaddr_in *) &a1;
const sockaddr_in & i2 = * (const sockaddr_in *) &a2;
int d = i1.sin_addr.S_un.S_addr - i2.sin_addr.S_un.S_addr;
return d ? d : i1.sin_port - i2.sin_port;
}
//=========================================================================== //===========================================================================
void NetAddressToString ( void NetAddressToString (
const NetAddress & addr, const NetAddress & addr,

5
Sources/Plasma/NucleusLib/pnUtils/pnUtAddr.h

@ -80,11 +80,6 @@ enum ENetAddressFormat {
kNumNetAddressFormats kNumNetAddressFormats
}; };
int NetAddressCompare (const NetAddress & a1, const NetAddress & a2);
inline bool NetAddressEqual (const NetAddress & a1, const NetAddress & a2) {
return NetAddressCompare(a1, a2) == 0;
}
void NetAddressToString ( void NetAddressToString (
const NetAddress & addr, const NetAddress & addr,
wchar_t * str, wchar_t * str,

Loading…
Cancel
Save