mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 18:59:09 +00:00
@ -134,7 +134,6 @@ target_link_libraries(plClient plSurface)
|
||||
target_link_libraries(plClient plTransform)
|
||||
target_link_libraries(plClient plUnifiedTime)
|
||||
target_link_libraries(plClient plVault)
|
||||
target_link_libraries(plClient pnAddrInfo)
|
||||
target_link_libraries(plClient pnAsyncCore)
|
||||
target_link_libraries(plClient pnAsyncCoreExe)
|
||||
target_link_libraries(plClient pnDispatch)
|
||||
|
@ -1,7 +1,6 @@
|
||||
add_definitions(-D_LIB)
|
||||
|
||||
add_subdirectory(inc)
|
||||
add_subdirectory(pnAddrInfo)
|
||||
add_subdirectory(pnAsyncCore)
|
||||
add_subdirectory(pnAsyncCoreExe)
|
||||
add_subdirectory(pnDispatch)
|
||||
|
@ -1,18 +0,0 @@
|
||||
include_directories(../../CoreLib)
|
||||
|
||||
set(pnAddrInfo_SOURCES
|
||||
pnAddrInfo.cpp
|
||||
)
|
||||
|
||||
set(pnAddrInfo_HEADERS
|
||||
pnAddrInfo.h
|
||||
)
|
||||
|
||||
add_library(pnAddrInfo STATIC ${pnAddrInfo_SOURCES} ${pnAddrInfo_HEADERS})
|
||||
target_link_libraries(pnAddrInfo CoreLib)
|
||||
if(WIN32)
|
||||
target_link_libraries(pnAddrInfo ws2_32)
|
||||
endif(WIN32)
|
||||
|
||||
source_group("Source Files" FILES ${pnAddrInfo_SOURCES})
|
||||
source_group("Header Files" FILES ${pnAddrInfo_HEADERS})
|
@ -1,179 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef SERVER
|
||||
|
||||
|
||||
#include "HeadSpin.h"
|
||||
#include "pnAddrInfo.h"
|
||||
#include <string.h>
|
||||
|
||||
#if HS_BUILD_FOR_UNIX
|
||||
# include <unistd.h>
|
||||
# include <arpa/inet.h>
|
||||
# include <netinet/in.h>
|
||||
# include <net/if.h>
|
||||
# include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
const pnAddrInfo* pnAddrInfo::GetInterface()
|
||||
{
|
||||
static pnAddrInfo addrinfo;
|
||||
return &addrinfo;
|
||||
}
|
||||
|
||||
struct addrinfo* pnAddrInfo::GetAddrByNameSimple(const char* name, const int family)
|
||||
{
|
||||
struct addrinfo* info;
|
||||
struct addrinfo hints;
|
||||
memset(&hints,0,sizeof(hints));
|
||||
hints.ai_family = family;
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
if (Get(name,NULL,&hints,&info) != 0)
|
||||
info = NULL;
|
||||
return info;
|
||||
};
|
||||
|
||||
int pnAddrInfo::Get(const char* node, const char* service, const struct addrinfo* hints, struct addrinfo** res)
|
||||
{
|
||||
return getaddrinfo(node,service,hints,res);
|
||||
}
|
||||
|
||||
void pnAddrInfo::Free(struct addrinfo* res)
|
||||
{
|
||||
freeaddrinfo(res);
|
||||
}
|
||||
|
||||
const char* pnAddrInfo::GetErrorString(int errcode)
|
||||
{
|
||||
return gai_strerror(errcode);
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
//// UNIX
|
||||
//////////////////////////////////
|
||||
|
||||
#if HS_BUILD_FOR_UNIX
|
||||
pnAddrInfo::pnAddrInfo()
|
||||
{
|
||||
}
|
||||
|
||||
pnAddrInfo::~pnAddrInfo()
|
||||
{
|
||||
}
|
||||
|
||||
void pnAddrInfo::GetLocalAddrs(List& addrslist, bool incLoopBack)
|
||||
{
|
||||
struct ifconf info;
|
||||
struct ifreq infos[128];
|
||||
|
||||
info.ifc_len = sizeof(infos);
|
||||
info.ifc_req = infos;
|
||||
|
||||
int s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
if (ioctl(s,SIOCGIFCONF,&info) == 0)
|
||||
{
|
||||
int i;
|
||||
int entries = info.ifc_len / sizeof(struct ifreq);
|
||||
|
||||
for (i = 0; i < entries; i++)
|
||||
{
|
||||
struct in_addr addr = ((struct sockaddr_in *)&(infos[i].ifr_addr))->sin_addr;
|
||||
|
||||
if (incLoopBack || (addr.s_addr != htonl(INADDR_LOOPBACK)))
|
||||
{
|
||||
addrslist.push_back(inet_ntoa(addr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(s);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////
|
||||
//// Windows
|
||||
////////////////////////////////////
|
||||
|
||||
#if HS_BUILD_FOR_WIN32
|
||||
pnAddrInfo::pnAddrInfo()
|
||||
{
|
||||
WSADATA data;
|
||||
WSAStartup(MAKEWORD( 2, 2 ), &data);
|
||||
}
|
||||
|
||||
pnAddrInfo::~pnAddrInfo()
|
||||
{
|
||||
WSACleanup();
|
||||
}
|
||||
|
||||
void pnAddrInfo::GetLocalAddrs(List& addrslist, bool incLoopBack)
|
||||
{
|
||||
INTERFACE_INFO infos[128]; // get at most 128 interfaces
|
||||
const unsigned int bufSize = sizeof(infos);
|
||||
DWORD retSize;
|
||||
|
||||
SOCKET s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
if (WSAIoctl(s, SIO_GET_INTERFACE_LIST, NULL, 0,
|
||||
(void*)infos, bufSize, &retSize, NULL, NULL) == 0)
|
||||
{
|
||||
unsigned int entries = retSize/sizeof(INTERFACE_INFO);
|
||||
int i;
|
||||
for (i = 0; i < entries; i++)
|
||||
{
|
||||
if (infos[i].iiFlags & IFF_UP)
|
||||
{
|
||||
struct in_addr addr = infos[i].iiAddress.AddressIn.sin_addr;
|
||||
if (incLoopBack || (addr.s_addr != htonl(INADDR_LOOPBACK)))
|
||||
addrslist.push_back(inet_ntoa(addr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closesocket(s);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SERVER
|
@ -1,83 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef PN_ADDR_INFO_H
|
||||
#define PN_ADDR_INFO_H
|
||||
|
||||
#ifndef SERVER
|
||||
|
||||
// A wrapper library for getaddrinfo
|
||||
// made to support Windows 98, Me, 2k
|
||||
// Unix and XP use native code
|
||||
|
||||
#if HS_BUILD_FOR_UNIX
|
||||
# include <sys/types.h>
|
||||
# include <sys/socket.h>
|
||||
# include <netdb.h>
|
||||
#elif !defined(HS_BUILD_FOR_WIN32)
|
||||
# error "pnAddrInfo Not Implemented!"
|
||||
#endif
|
||||
|
||||
#include "HeadSpin.h"
|
||||
#include "hsStlUtils.h"
|
||||
|
||||
|
||||
class pnAddrInfo
|
||||
{
|
||||
public:
|
||||
typedef std::list<std::string> List;
|
||||
|
||||
pnAddrInfo();
|
||||
~pnAddrInfo();
|
||||
|
||||
static const pnAddrInfo* GetInterface();
|
||||
|
||||
static struct addrinfo* GetAddrByNameSimple(const char* name, const int family = PF_INET);
|
||||
static int Get(const char* node, const char* service, const struct addrinfo* hints, struct addrinfo** res);
|
||||
static const char* GetErrorString(int errcode);
|
||||
static void Free(struct addrinfo* res);
|
||||
|
||||
static void GetLocalAddrs(List& addrslist, bool incLoopBack = false);
|
||||
};
|
||||
|
||||
#endif // SERVER
|
||||
|
||||
#endif // PN_ADDR_INFO_H
|
@ -34,7 +34,10 @@ set(pnNetCommon_SOURCES
|
||||
)
|
||||
|
||||
add_library(pnNetCommon STATIC ${pnNetCommon_HEADERS} ${pnNetCommon_SOURCES})
|
||||
target_link_libraries(pnNetCommon pnAddrInfo plStatusLog)
|
||||
target_link_libraries(pnNetCommon plStatusLog)
|
||||
if(WIN32)
|
||||
target_link_libraries(pnNetCommon Ws2_32)
|
||||
endif(WIN32)
|
||||
|
||||
source_group("Header Files" FILES ${pnNetCommon_HEADERS})
|
||||
source_group("Source Files" FILES ${pnNetCommon_SOURCES})
|
||||
|
@ -40,7 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "pnNetCommon.h"
|
||||
#include "pnAddrInfo/pnAddrInfo.h"
|
||||
|
||||
#if HS_BUILD_FOR_UNIX
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
@ -68,19 +68,25 @@ plString GetTextAddr(uint32_t binAddr)
|
||||
uint32_t GetBinAddr(const char * textAddr)
|
||||
{
|
||||
uint32_t addr = 0;
|
||||
|
||||
if (!textAddr)
|
||||
return addr;
|
||||
|
||||
struct addrinfo* ai = NULL;
|
||||
|
||||
addr = inet_addr(textAddr);
|
||||
if(addr == INADDR_NONE)
|
||||
{
|
||||
ai = pnAddrInfo::GetAddrByNameSimple(textAddr);
|
||||
if(ai!= NULL)
|
||||
memcpy(&addr,(void*)(&(((sockaddr_in*)(ai->ai_addr))->sin_addr)),sizeof(addr));
|
||||
pnAddrInfo::Free(ai);
|
||||
struct addrinfo* ai = nil;
|
||||
struct addrinfo hints;
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
hints.ai_family = PF_INET;
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
if (getaddrinfo(textAddr, nil, &hints, &ai) != 0)
|
||||
{
|
||||
hsAssert(false, "getaddrinfo failed");
|
||||
return addr;
|
||||
}
|
||||
|
||||
memcpy(&addr, (void*)(&(((sockaddr_in*)(ai->ai_addr))->sin_addr)), sizeof(addr));
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
|
||||
return addr;
|
||||
|
@ -171,7 +171,6 @@ target_link_libraries(MaxMain plSurface)
|
||||
target_link_libraries(MaxMain plTransform)
|
||||
target_link_libraries(MaxMain plUnifiedTime)
|
||||
target_link_libraries(MaxMain plVault)
|
||||
target_link_libraries(MaxMain pnAddrInfo)
|
||||
target_link_libraries(MaxMain pnAsyncCore)
|
||||
target_link_libraries(MaxMain pnAsyncCoreExe)
|
||||
target_link_libraries(MaxMain pnDispatch)
|
||||
|
@ -104,7 +104,6 @@ target_link_libraries(MaxPlasmaLights plSurface)
|
||||
target_link_libraries(MaxPlasmaLights plTransform)
|
||||
target_link_libraries(MaxPlasmaLights plUnifiedTime)
|
||||
target_link_libraries(MaxPlasmaLights plVault)
|
||||
target_link_libraries(MaxPlasmaLights pnAddrInfo)
|
||||
target_link_libraries(MaxPlasmaLights pnAsyncCore)
|
||||
target_link_libraries(MaxPlasmaLights pnAsyncCoreExe)
|
||||
target_link_libraries(MaxPlasmaLights pnDispatch)
|
||||
|
@ -40,7 +40,6 @@ target_link_libraries(plResBrowser plResMgr)
|
||||
target_link_libraries(plResBrowser plScene)
|
||||
target_link_libraries(plResBrowser plStatusLog)
|
||||
target_link_libraries(plResBrowser plUnifiedTime)
|
||||
target_link_libraries(plResBrowser pnAddrInfo)
|
||||
target_link_libraries(plResBrowser pnDispatch)
|
||||
target_link_libraries(plResBrowser pnFactory)
|
||||
target_link_libraries(plResBrowser pnKeyedObject)
|
||||
|
Reference in New Issue
Block a user