2012-09-20 05:42:46 +04:00
|
|
|
/**
|
|
|
|
* WinPR: Windows Portable Runtime
|
|
|
|
* Windows Sockets (Winsock)
|
|
|
|
*
|
|
|
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
#include <winpr/crt.h>
|
2015-01-28 21:46:17 +03:00
|
|
|
#include <winpr/synch.h>
|
2014-06-01 23:04:28 +04:00
|
|
|
|
2012-09-20 05:42:46 +04:00
|
|
|
#include <winpr/winsock.h>
|
|
|
|
|
2015-02-09 06:29:52 +03:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2015-05-21 23:24:03 +03:00
|
|
|
#ifdef HAVE_SYS_FILIO_H
|
|
|
|
#include <sys/filio.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_SOCKIO_H
|
|
|
|
#include <sys/sockio.h>
|
|
|
|
#endif
|
2015-02-09 06:29:52 +03:00
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
#include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
|
2015-05-23 02:01:37 +03:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#define WSAIOCTL_IFADDRS
|
|
|
|
#include <ifaddrs.h>
|
|
|
|
#endif
|
|
|
|
|
2012-09-20 05:42:46 +04:00
|
|
|
/**
|
|
|
|
* ws2_32.dll:
|
2018-08-22 14:17:10 +03:00
|
|
|
*
|
2012-09-20 05:42:46 +04:00
|
|
|
* __WSAFDIsSet
|
|
|
|
* accept
|
|
|
|
* bind
|
|
|
|
* closesocket
|
|
|
|
* connect
|
|
|
|
* freeaddrinfo
|
|
|
|
* FreeAddrInfoEx
|
|
|
|
* FreeAddrInfoExW
|
|
|
|
* FreeAddrInfoW
|
|
|
|
* getaddrinfo
|
|
|
|
* GetAddrInfoExA
|
|
|
|
* GetAddrInfoExCancel
|
|
|
|
* GetAddrInfoExOverlappedResult
|
|
|
|
* GetAddrInfoExW
|
|
|
|
* GetAddrInfoW
|
|
|
|
* gethostbyaddr
|
|
|
|
* gethostbyname
|
|
|
|
* gethostname
|
|
|
|
* GetHostNameW
|
|
|
|
* getnameinfo
|
|
|
|
* GetNameInfoW
|
|
|
|
* getpeername
|
|
|
|
* getprotobyname
|
|
|
|
* getprotobynumber
|
|
|
|
* getservbyname
|
|
|
|
* getservbyport
|
|
|
|
* getsockname
|
|
|
|
* getsockopt
|
|
|
|
* htonl
|
|
|
|
* htons
|
|
|
|
* inet_addr
|
|
|
|
* inet_ntoa
|
|
|
|
* inet_ntop
|
|
|
|
* inet_pton
|
|
|
|
* InetNtopW
|
|
|
|
* InetPtonW
|
|
|
|
* ioctlsocket
|
|
|
|
* listen
|
|
|
|
* ntohl
|
|
|
|
* ntohs
|
|
|
|
* recv
|
|
|
|
* recvfrom
|
|
|
|
* select
|
|
|
|
* send
|
|
|
|
* sendto
|
|
|
|
* SetAddrInfoExA
|
|
|
|
* SetAddrInfoExW
|
|
|
|
* setsockopt
|
|
|
|
* shutdown
|
|
|
|
* socket
|
|
|
|
* WahCloseApcHelper
|
|
|
|
* WahCloseHandleHelper
|
|
|
|
* WahCloseNotificationHandleHelper
|
|
|
|
* WahCloseSocketHandle
|
|
|
|
* WahCloseThread
|
|
|
|
* WahCompleteRequest
|
|
|
|
* WahCreateHandleContextTable
|
|
|
|
* WahCreateNotificationHandle
|
|
|
|
* WahCreateSocketHandle
|
|
|
|
* WahDestroyHandleContextTable
|
|
|
|
* WahDisableNonIFSHandleSupport
|
|
|
|
* WahEnableNonIFSHandleSupport
|
|
|
|
* WahEnumerateHandleContexts
|
|
|
|
* WahInsertHandleContext
|
|
|
|
* WahNotifyAllProcesses
|
|
|
|
* WahOpenApcHelper
|
|
|
|
* WahOpenCurrentThread
|
|
|
|
* WahOpenHandleHelper
|
|
|
|
* WahOpenNotificationHandleHelper
|
|
|
|
* WahQueueUserApc
|
|
|
|
* WahReferenceContextByHandle
|
|
|
|
* WahRemoveHandleContext
|
|
|
|
* WahWaitForNotification
|
|
|
|
* WahWriteLSPEvent
|
|
|
|
* WEP
|
|
|
|
* WPUCompleteOverlappedRequest
|
|
|
|
* WPUGetProviderPathEx
|
|
|
|
* WSAAccept
|
|
|
|
* WSAAddressToStringA
|
|
|
|
* WSAAddressToStringW
|
|
|
|
* WSAAdvertiseProvider
|
|
|
|
* WSAAsyncGetHostByAddr
|
|
|
|
* WSAAsyncGetHostByName
|
|
|
|
* WSAAsyncGetProtoByName
|
|
|
|
* WSAAsyncGetProtoByNumber
|
|
|
|
* WSAAsyncGetServByName
|
|
|
|
* WSAAsyncGetServByPort
|
|
|
|
* WSAAsyncSelect
|
|
|
|
* WSACancelAsyncRequest
|
|
|
|
* WSACancelBlockingCall
|
|
|
|
* WSACleanup
|
|
|
|
* WSACloseEvent
|
|
|
|
* WSAConnect
|
|
|
|
* WSAConnectByList
|
|
|
|
* WSAConnectByNameA
|
|
|
|
* WSAConnectByNameW
|
|
|
|
* WSACreateEvent
|
|
|
|
* WSADuplicateSocketA
|
|
|
|
* WSADuplicateSocketW
|
|
|
|
* WSAEnumNameSpaceProvidersA
|
|
|
|
* WSAEnumNameSpaceProvidersExA
|
|
|
|
* WSAEnumNameSpaceProvidersExW
|
|
|
|
* WSAEnumNameSpaceProvidersW
|
|
|
|
* WSAEnumNetworkEvents
|
|
|
|
* WSAEnumProtocolsA
|
|
|
|
* WSAEnumProtocolsW
|
|
|
|
* WSAEventSelect
|
|
|
|
* WSAGetLastError
|
|
|
|
* WSAGetOverlappedResult
|
|
|
|
* WSAGetQOSByName
|
|
|
|
* WSAGetServiceClassInfoA
|
|
|
|
* WSAGetServiceClassInfoW
|
|
|
|
* WSAGetServiceClassNameByClassIdA
|
|
|
|
* WSAGetServiceClassNameByClassIdW
|
|
|
|
* WSAHtonl
|
|
|
|
* WSAHtons
|
|
|
|
* WSAInstallServiceClassA
|
|
|
|
* WSAInstallServiceClassW
|
|
|
|
* WSAIoctl
|
|
|
|
* WSAIsBlocking
|
|
|
|
* WSAJoinLeaf
|
|
|
|
* WSALookupServiceBeginA
|
|
|
|
* WSALookupServiceBeginW
|
|
|
|
* WSALookupServiceEnd
|
|
|
|
* WSALookupServiceNextA
|
|
|
|
* WSALookupServiceNextW
|
|
|
|
* WSANSPIoctl
|
|
|
|
* WSANtohl
|
|
|
|
* WSANtohs
|
|
|
|
* WSAPoll
|
|
|
|
* WSAProviderCompleteAsyncCall
|
|
|
|
* WSAProviderConfigChange
|
|
|
|
* WSApSetPostRoutine
|
|
|
|
* WSARecv
|
|
|
|
* WSARecvDisconnect
|
|
|
|
* WSARecvFrom
|
|
|
|
* WSARemoveServiceClass
|
|
|
|
* WSAResetEvent
|
|
|
|
* WSASend
|
|
|
|
* WSASendDisconnect
|
|
|
|
* WSASendMsg
|
|
|
|
* WSASendTo
|
|
|
|
* WSASetBlockingHook
|
|
|
|
* WSASetEvent
|
|
|
|
* WSASetLastError
|
|
|
|
* WSASetServiceA
|
|
|
|
* WSASetServiceW
|
|
|
|
* WSASocketA
|
|
|
|
* WSASocketW
|
|
|
|
* WSAStartup
|
|
|
|
* WSAStringToAddressA
|
|
|
|
* WSAStringToAddressW
|
|
|
|
* WSAUnadvertiseProvider
|
|
|
|
* WSAUnhookBlockingHook
|
|
|
|
* WSAWaitForMultipleEvents
|
|
|
|
* WSCDeinstallProvider
|
|
|
|
* WSCDeinstallProviderEx
|
|
|
|
* WSCEnableNSProvider
|
|
|
|
* WSCEnumProtocols
|
|
|
|
* WSCEnumProtocolsEx
|
|
|
|
* WSCGetApplicationCategory
|
|
|
|
* WSCGetApplicationCategoryEx
|
|
|
|
* WSCGetProviderInfo
|
|
|
|
* WSCGetProviderPath
|
|
|
|
* WSCInstallNameSpace
|
|
|
|
* WSCInstallNameSpaceEx
|
|
|
|
* WSCInstallNameSpaceEx2
|
|
|
|
* WSCInstallProvider
|
|
|
|
* WSCInstallProviderAndChains
|
|
|
|
* WSCInstallProviderEx
|
|
|
|
* WSCSetApplicationCategory
|
|
|
|
* WSCSetApplicationCategoryEx
|
|
|
|
* WSCSetProviderInfo
|
|
|
|
* WSCUnInstallNameSpace
|
|
|
|
* WSCUnInstallNameSpaceEx2
|
|
|
|
* WSCUpdateProvider
|
|
|
|
* WSCUpdateProviderEx
|
|
|
|
* WSCWriteNameSpaceOrder
|
|
|
|
* WSCWriteProviderOrder
|
|
|
|
* WSCWriteProviderOrderEx
|
|
|
|
*/
|
|
|
|
|
2012-09-20 18:42:01 +04:00
|
|
|
#ifdef _WIN32
|
2012-09-20 05:42:46 +04:00
|
|
|
|
2012-09-20 18:42:01 +04:00
|
|
|
#if (_WIN32_WINNT < 0x0600)
|
2012-09-20 05:42:46 +04:00
|
|
|
|
2016-06-16 12:47:33 +03:00
|
|
|
PCSTR winpr_inet_ntop(INT Family, PVOID pAddr, PSTR pStringBuf, size_t StringBufSize)
|
2012-09-20 18:42:01 +04:00
|
|
|
{
|
|
|
|
if (Family == AF_INET)
|
|
|
|
{
|
|
|
|
struct sockaddr_in in;
|
|
|
|
memset(&in, 0, sizeof(in));
|
|
|
|
in.sin_family = AF_INET;
|
|
|
|
memcpy(&in.sin_addr, pAddr, sizeof(struct in_addr));
|
2019-11-06 17:24:51 +03:00
|
|
|
getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in), pStringBuf, StringBufSize,
|
|
|
|
NULL, 0, NI_NUMERICHOST);
|
2012-09-20 18:42:01 +04:00
|
|
|
return pStringBuf;
|
|
|
|
}
|
|
|
|
else if (Family == AF_INET6)
|
|
|
|
{
|
|
|
|
struct sockaddr_in6 in;
|
|
|
|
memset(&in, 0, sizeof(in));
|
|
|
|
in.sin6_family = AF_INET6;
|
|
|
|
memcpy(&in.sin6_addr, pAddr, sizeof(struct in_addr6));
|
2019-11-06 17:24:51 +03:00
|
|
|
getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in6), pStringBuf, StringBufSize,
|
|
|
|
NULL, 0, NI_NUMERICHOST);
|
2012-09-20 18:42:01 +04:00
|
|
|
return pStringBuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-06-16 12:47:33 +03:00
|
|
|
INT winpr_inet_pton(INT Family, PCSTR pszAddrString, PVOID pAddrBuf)
|
2016-06-08 17:51:58 +03:00
|
|
|
{
|
|
|
|
SOCKADDR_STORAGE addr;
|
|
|
|
int addr_len = sizeof(addr);
|
|
|
|
|
|
|
|
if ((Family != AF_INET) && (Family != AF_INET6))
|
|
|
|
return -1;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
if (WSAStringToAddressA((char*)pszAddrString, Family, NULL, (struct sockaddr*)&addr,
|
2018-08-22 14:17:10 +03:00
|
|
|
&addr_len) != 0)
|
2016-06-08 17:51:58 +03:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (Family == AF_INET)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
memcpy(pAddrBuf, &((struct sockaddr_in*)&addr)->sin_addr, sizeof(struct in_addr));
|
2016-06-08 17:51:58 +03:00
|
|
|
}
|
|
|
|
else if (Family == AF_INET6)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
memcpy(pAddrBuf, &((struct sockaddr_in6*)&addr)->sin6_addr, sizeof(struct in6_addr));
|
2016-06-08 17:51:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-09-20 18:42:01 +04:00
|
|
|
#endif /* (_WIN32_WINNT < 0x0600) */
|
|
|
|
|
|
|
|
#else /* _WIN32 */
|
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
#include <netdb.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
|
2014-06-02 05:37:20 +04:00
|
|
|
#ifndef MSG_NOSIGNAL
|
|
|
|
#define MSG_NOSIGNAL 0
|
|
|
|
#endif
|
|
|
|
|
2014-02-06 01:25:55 +04:00
|
|
|
int WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
ZeroMemory(lpWSAData, sizeof(WSADATA));
|
|
|
|
lpWSAData->wVersion = wVersionRequired;
|
|
|
|
lpWSAData->wHighVersion = MAKEWORD(2, 2);
|
|
|
|
return 0; /* success */
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int WSACleanup(void)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
return 0; /* success */
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void WSASetLastError(int iError)
|
|
|
|
{
|
2014-12-12 17:08:39 +03:00
|
|
|
switch (iError)
|
|
|
|
{
|
|
|
|
/* Base error codes */
|
|
|
|
case WSAEINTR:
|
|
|
|
errno = EINTR;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEBADF:
|
|
|
|
errno = EBADF;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEACCES:
|
|
|
|
errno = EACCES;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEFAULT:
|
|
|
|
errno = EFAULT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEINVAL:
|
|
|
|
errno = EINVAL;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEMFILE:
|
|
|
|
errno = EMFILE;
|
|
|
|
break;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
/* BSD sockets error codes */
|
2014-02-06 01:25:55 +04:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEWOULDBLOCK:
|
|
|
|
errno = EWOULDBLOCK;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEINPROGRESS:
|
|
|
|
errno = EINPROGRESS;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEALREADY:
|
|
|
|
errno = EALREADY;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAENOTSOCK:
|
|
|
|
errno = ENOTSOCK;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEDESTADDRREQ:
|
|
|
|
errno = EDESTADDRREQ;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEMSGSIZE:
|
|
|
|
errno = EMSGSIZE;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEPROTOTYPE:
|
|
|
|
errno = EPROTOTYPE;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAENOPROTOOPT:
|
|
|
|
errno = ENOPROTOOPT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEPROTONOSUPPORT:
|
|
|
|
errno = EPROTONOSUPPORT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAESOCKTNOSUPPORT:
|
|
|
|
errno = ESOCKTNOSUPPORT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEOPNOTSUPP:
|
|
|
|
errno = EOPNOTSUPP;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEPFNOSUPPORT:
|
|
|
|
errno = EPFNOSUPPORT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEAFNOSUPPORT:
|
|
|
|
errno = EAFNOSUPPORT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEADDRINUSE:
|
|
|
|
errno = EADDRINUSE;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEADDRNOTAVAIL:
|
|
|
|
errno = EADDRNOTAVAIL;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAENETDOWN:
|
|
|
|
errno = ENETDOWN;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAENETUNREACH:
|
|
|
|
errno = ENETUNREACH;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAENETRESET:
|
|
|
|
errno = ENETRESET;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAECONNABORTED:
|
|
|
|
errno = ECONNABORTED;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAECONNRESET:
|
|
|
|
errno = ECONNRESET;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAENOBUFS:
|
|
|
|
errno = ENOBUFS;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEISCONN:
|
|
|
|
errno = EISCONN;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAENOTCONN:
|
|
|
|
errno = ENOTCONN;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAESHUTDOWN:
|
|
|
|
errno = ESHUTDOWN;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAETOOMANYREFS:
|
|
|
|
errno = ETOOMANYREFS;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAETIMEDOUT:
|
|
|
|
errno = ETIMEDOUT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAECONNREFUSED:
|
|
|
|
errno = ECONNREFUSED;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAELOOP:
|
|
|
|
errno = ELOOP;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAENAMETOOLONG:
|
|
|
|
errno = ENAMETOOLONG;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEHOSTDOWN:
|
|
|
|
errno = EHOSTDOWN;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEHOSTUNREACH:
|
|
|
|
errno = EHOSTUNREACH;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAENOTEMPTY:
|
|
|
|
errno = ENOTEMPTY;
|
|
|
|
break;
|
|
|
|
#ifdef EPROCLIM
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEPROCLIM:
|
|
|
|
errno = EPROCLIM;
|
|
|
|
break;
|
|
|
|
#endif
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEUSERS:
|
|
|
|
errno = EUSERS;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEDQUOT:
|
|
|
|
errno = EDQUOT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAESTALE:
|
|
|
|
errno = ESTALE;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-12-12 17:08:39 +03:00
|
|
|
case WSAEREMOTE:
|
|
|
|
errno = EREMOTE;
|
|
|
|
break;
|
|
|
|
}
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int WSAGetLastError(void)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int iError = 0;
|
|
|
|
|
|
|
|
switch (errno)
|
|
|
|
{
|
|
|
|
/* Base error codes */
|
|
|
|
case EINTR:
|
|
|
|
iError = WSAEINTR;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EBADF:
|
|
|
|
iError = WSAEBADF;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EACCES:
|
|
|
|
iError = WSAEACCES;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EFAULT:
|
|
|
|
iError = WSAEFAULT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EINVAL:
|
|
|
|
iError = WSAEINVAL;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EMFILE:
|
|
|
|
iError = WSAEMFILE;
|
|
|
|
break;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
/* BSD sockets error codes */
|
2014-06-01 23:04:28 +04:00
|
|
|
|
|
|
|
case EWOULDBLOCK:
|
|
|
|
iError = WSAEWOULDBLOCK;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EINPROGRESS:
|
|
|
|
iError = WSAEINPROGRESS;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EALREADY:
|
|
|
|
iError = WSAEALREADY;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ENOTSOCK:
|
|
|
|
iError = WSAENOTSOCK;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EDESTADDRREQ:
|
|
|
|
iError = WSAEDESTADDRREQ;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EMSGSIZE:
|
|
|
|
iError = WSAEMSGSIZE;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EPROTOTYPE:
|
|
|
|
iError = WSAEPROTOTYPE;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ENOPROTOOPT:
|
|
|
|
iError = WSAENOPROTOOPT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EPROTONOSUPPORT:
|
|
|
|
iError = WSAEPROTONOSUPPORT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ESOCKTNOSUPPORT:
|
|
|
|
iError = WSAESOCKTNOSUPPORT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EOPNOTSUPP:
|
|
|
|
iError = WSAEOPNOTSUPP;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EPFNOSUPPORT:
|
|
|
|
iError = WSAEPFNOSUPPORT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EAFNOSUPPORT:
|
|
|
|
iError = WSAEAFNOSUPPORT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EADDRINUSE:
|
|
|
|
iError = WSAEADDRINUSE;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EADDRNOTAVAIL:
|
|
|
|
iError = WSAEADDRNOTAVAIL;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ENETDOWN:
|
|
|
|
iError = WSAENETDOWN;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ENETUNREACH:
|
|
|
|
iError = WSAENETUNREACH;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ENETRESET:
|
|
|
|
iError = WSAENETRESET;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ECONNABORTED:
|
|
|
|
iError = WSAECONNABORTED;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ECONNRESET:
|
|
|
|
iError = WSAECONNRESET;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ENOBUFS:
|
|
|
|
iError = WSAENOBUFS;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EISCONN:
|
|
|
|
iError = WSAEISCONN;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ENOTCONN:
|
|
|
|
iError = WSAENOTCONN;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ESHUTDOWN:
|
|
|
|
iError = WSAESHUTDOWN;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ETOOMANYREFS:
|
|
|
|
iError = WSAETOOMANYREFS;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ETIMEDOUT:
|
|
|
|
iError = WSAETIMEDOUT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ECONNREFUSED:
|
|
|
|
iError = WSAECONNREFUSED;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ELOOP:
|
|
|
|
iError = WSAELOOP;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ENAMETOOLONG:
|
|
|
|
iError = WSAENAMETOOLONG;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EHOSTDOWN:
|
|
|
|
iError = WSAEHOSTDOWN;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EHOSTUNREACH:
|
|
|
|
iError = WSAEHOSTUNREACH;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ENOTEMPTY:
|
|
|
|
iError = WSAENOTEMPTY;
|
|
|
|
break;
|
|
|
|
#ifdef EPROCLIM
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EPROCLIM:
|
|
|
|
iError = WSAEPROCLIM;
|
|
|
|
break;
|
|
|
|
#endif
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EUSERS:
|
|
|
|
iError = WSAEUSERS;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EDQUOT:
|
|
|
|
iError = WSAEDQUOT;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case ESTALE:
|
|
|
|
iError = WSAESTALE;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
case EREMOTE:
|
|
|
|
iError = WSAEREMOTE;
|
|
|
|
break;
|
2018-08-22 14:17:10 +03:00
|
|
|
/* Special cases */
|
2014-06-02 05:37:20 +04:00
|
|
|
#if (EAGAIN != EWOULDBLOCK)
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-02 05:37:20 +04:00
|
|
|
case EAGAIN:
|
|
|
|
iError = WSAEWOULDBLOCK;
|
|
|
|
break;
|
|
|
|
#endif
|
2015-04-21 21:42:06 +03:00
|
|
|
#if defined(EPROTO)
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2014-06-02 05:37:20 +04:00
|
|
|
case EPROTO:
|
|
|
|
iError = WSAECONNRESET;
|
|
|
|
break;
|
2015-04-21 21:42:06 +03:00
|
|
|
#endif
|
2014-06-01 23:04:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Windows Sockets Extended Error Codes:
|
|
|
|
*
|
|
|
|
* WSASYSNOTREADY
|
|
|
|
* WSAVERNOTSUPPORTED
|
|
|
|
* WSANOTINITIALISED
|
|
|
|
* WSAEDISCON
|
|
|
|
* WSAENOMORE
|
|
|
|
* WSAECANCELLED
|
|
|
|
* WSAEINVALIDPROCTABLE
|
|
|
|
* WSAEINVALIDPROVIDER
|
|
|
|
* WSAEPROVIDERFAILEDINIT
|
|
|
|
* WSASYSCALLFAILURE
|
|
|
|
* WSASERVICE_NOT_FOUND
|
|
|
|
* WSATYPE_NOT_FOUND
|
|
|
|
* WSA_E_NO_MORE
|
|
|
|
* WSA_E_CANCELLED
|
|
|
|
* WSAEREFUSED
|
|
|
|
*/
|
2014-06-02 05:37:20 +04:00
|
|
|
return iError;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
2015-01-28 21:46:17 +03:00
|
|
|
HANDLE WSACreateEvent(void)
|
|
|
|
{
|
|
|
|
return CreateEvent(NULL, TRUE, FALSE, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WSASetEvent(HANDLE hEvent)
|
|
|
|
{
|
|
|
|
return SetEvent(hEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WSAResetEvent(HANDLE hEvent)
|
|
|
|
{
|
2015-09-05 16:18:01 +03:00
|
|
|
/* POSIX systems auto reset the socket,
|
|
|
|
* if no more data is available. */
|
|
|
|
return TRUE;
|
2015-01-28 21:46:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WSACloseEvent(HANDLE hEvent)
|
|
|
|
{
|
|
|
|
BOOL status;
|
|
|
|
status = CloseHandle(hEvent);
|
|
|
|
|
|
|
|
if (!status)
|
|
|
|
SetLastError(6);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
int WSAEventSelect(SOCKET s, WSAEVENT hEventObject, LONG lNetworkEvents)
|
|
|
|
{
|
2015-07-14 12:58:01 +03:00
|
|
|
u_long arg = 1;
|
2015-07-14 12:39:41 +03:00
|
|
|
ULONG mode = 0;
|
2015-02-09 06:29:52 +03:00
|
|
|
|
|
|
|
if (_ioctlsocket(s, FIONBIO, &arg) != 0)
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
|
2015-07-03 10:29:36 +03:00
|
|
|
if (arg == 0)
|
|
|
|
return 0;
|
|
|
|
|
2015-07-14 12:39:41 +03:00
|
|
|
if (lNetworkEvents & FD_READ)
|
|
|
|
mode |= WINPR_FD_READ;
|
2018-08-22 14:17:10 +03:00
|
|
|
|
2015-07-14 12:39:41 +03:00
|
|
|
if (lNetworkEvents & FD_WRITE)
|
|
|
|
mode |= WINPR_FD_WRITE;
|
|
|
|
|
|
|
|
if (SetEventFileDescriptor(hEventObject, s, mode) < 0)
|
2015-02-09 06:29:52 +03:00
|
|
|
return SOCKET_ERROR;
|
|
|
|
|
2015-01-28 21:46:17 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-08-22 14:17:10 +03:00
|
|
|
DWORD WSAWaitForMultipleEvents(DWORD cEvents, const HANDLE* lphEvents, BOOL fWaitAll,
|
|
|
|
DWORD dwTimeout, BOOL fAlertable)
|
2015-01-28 21:46:17 +03:00
|
|
|
{
|
|
|
|
return WaitForMultipleObjectsEx(cEvents, lphEvents, fWaitAll, dwTimeout, fAlertable);
|
|
|
|
}
|
|
|
|
|
2018-08-22 14:17:10 +03:00
|
|
|
SOCKET WSASocketA(int af, int type, int protocol, LPWSAPROTOCOL_INFOA lpProtocolInfo, GROUP g,
|
|
|
|
DWORD dwFlags)
|
2015-02-18 21:35:33 +03:00
|
|
|
{
|
|
|
|
SOCKET s;
|
|
|
|
s = _socket(af, type, protocol);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2018-08-22 14:17:10 +03:00
|
|
|
SOCKET WSASocketW(int af, int type, int protocol, LPWSAPROTOCOL_INFOW lpProtocolInfo, GROUP g,
|
|
|
|
DWORD dwFlags)
|
2015-02-18 21:35:33 +03:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
return WSASocketA(af, type, protocol, (LPWSAPROTOCOL_INFOA)lpProtocolInfo, g, dwFlags);
|
2015-02-18 21:35:33 +03:00
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
int WSAIoctl(SOCKET s, DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInBuffer,
|
|
|
|
LPVOID lpvOutBuffer, DWORD cbOutBuffer, LPDWORD lpcbBytesReturned,
|
|
|
|
LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
2015-02-18 21:35:33 +03:00
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
int index;
|
|
|
|
ULONG nFlags;
|
|
|
|
size_t offset;
|
|
|
|
size_t ifreq_len;
|
|
|
|
struct ifreq* ifreq;
|
|
|
|
struct ifconf ifconf;
|
|
|
|
char address[128];
|
|
|
|
char broadcast[128];
|
|
|
|
char netmask[128];
|
|
|
|
char buffer[4096];
|
|
|
|
int numInterfaces;
|
|
|
|
int maxNumInterfaces;
|
|
|
|
INTERFACE_INFO* pInterface;
|
|
|
|
INTERFACE_INFO* pInterfaces;
|
|
|
|
struct sockaddr_in* pAddress;
|
|
|
|
struct sockaddr_in* pBroadcast;
|
|
|
|
struct sockaddr_in* pNetmask;
|
|
|
|
|
|
|
|
if ((dwIoControlCode != SIO_GET_INTERFACE_LIST) ||
|
2018-08-22 14:17:10 +03:00
|
|
|
(!lpvOutBuffer || !cbOutBuffer || !lpcbBytesReturned))
|
2015-02-18 21:35:33 +03:00
|
|
|
{
|
|
|
|
WSASetLastError(WSAEINVAL);
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
fd = (int)s;
|
|
|
|
pInterfaces = (INTERFACE_INFO*)lpvOutBuffer;
|
2015-02-18 21:35:33 +03:00
|
|
|
maxNumInterfaces = cbOutBuffer / sizeof(INTERFACE_INFO);
|
2015-05-23 02:01:37 +03:00
|
|
|
#ifdef WSAIOCTL_IFADDRS
|
|
|
|
{
|
|
|
|
struct ifaddrs* ifa = NULL;
|
|
|
|
struct ifaddrs* ifap = NULL;
|
|
|
|
|
|
|
|
if (getifaddrs(&ifap) != 0)
|
|
|
|
{
|
|
|
|
WSASetLastError(WSAENETDOWN);
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
numInterfaces = 0;
|
|
|
|
|
|
|
|
for (ifa = ifap; ifa; ifa = ifa->ifa_next)
|
|
|
|
{
|
|
|
|
pInterface = &pInterfaces[index];
|
2019-11-06 17:24:51 +03:00
|
|
|
pAddress = (struct sockaddr_in*)&pInterface->iiAddress;
|
|
|
|
pBroadcast = (struct sockaddr_in*)&pInterface->iiBroadcastAddress;
|
|
|
|
pNetmask = (struct sockaddr_in*)&pInterface->iiNetmask;
|
2015-05-23 02:01:37 +03:00
|
|
|
nFlags = 0;
|
|
|
|
|
|
|
|
if (ifa->ifa_flags & IFF_UP)
|
|
|
|
nFlags |= _IFF_UP;
|
|
|
|
|
|
|
|
if (ifa->ifa_flags & IFF_BROADCAST)
|
|
|
|
nFlags |= _IFF_BROADCAST;
|
|
|
|
|
|
|
|
if (ifa->ifa_flags & IFF_LOOPBACK)
|
|
|
|
nFlags |= _IFF_LOOPBACK;
|
|
|
|
|
|
|
|
if (ifa->ifa_flags & IFF_POINTOPOINT)
|
|
|
|
nFlags |= _IFF_POINTTOPOINT;
|
|
|
|
|
|
|
|
if (ifa->ifa_flags & IFF_MULTICAST)
|
|
|
|
nFlags |= _IFF_MULTICAST;
|
|
|
|
|
|
|
|
pInterface->iiFlags = nFlags;
|
|
|
|
|
|
|
|
if (ifa->ifa_addr)
|
|
|
|
{
|
|
|
|
if ((ifa->ifa_addr->sa_family != AF_INET) && (ifa->ifa_addr->sa_family != AF_INET6))
|
|
|
|
continue;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr), address, sizeof(address), 0, 0,
|
|
|
|
NI_NUMERICHOST);
|
|
|
|
inet_pton(ifa->ifa_addr->sa_family, address, (void*)&pAddress->sin_addr);
|
2015-05-23 02:01:37 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ZeroMemory(pAddress, sizeof(struct sockaddr_in));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ifa->ifa_dstaddr)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
if ((ifa->ifa_dstaddr->sa_family != AF_INET) &&
|
|
|
|
(ifa->ifa_dstaddr->sa_family != AF_INET6))
|
2015-05-23 02:01:37 +03:00
|
|
|
continue;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
getnameinfo(ifa->ifa_dstaddr, sizeof(struct sockaddr), broadcast, sizeof(broadcast),
|
|
|
|
0, 0, NI_NUMERICHOST);
|
|
|
|
inet_pton(ifa->ifa_dstaddr->sa_family, broadcast, (void*)&pBroadcast->sin_addr);
|
2015-05-23 02:01:37 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ZeroMemory(pBroadcast, sizeof(struct sockaddr_in));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ifa->ifa_netmask)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
if ((ifa->ifa_netmask->sa_family != AF_INET) &&
|
|
|
|
(ifa->ifa_netmask->sa_family != AF_INET6))
|
2015-05-23 02:01:37 +03:00
|
|
|
continue;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
getnameinfo(ifa->ifa_netmask, sizeof(struct sockaddr), netmask, sizeof(netmask), 0,
|
|
|
|
0, NI_NUMERICHOST);
|
|
|
|
inet_pton(ifa->ifa_netmask->sa_family, netmask, (void*)&pNetmask->sin_addr);
|
2015-05-23 02:01:37 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ZeroMemory(pNetmask, sizeof(struct sockaddr_in));
|
|
|
|
}
|
|
|
|
|
|
|
|
numInterfaces++;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
2018-08-22 14:17:10 +03:00
|
|
|
*lpcbBytesReturned = (DWORD)(numInterfaces * sizeof(INTERFACE_INFO));
|
2015-05-23 02:01:37 +03:00
|
|
|
freeifaddrs(ifap);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2015-02-18 21:35:33 +03:00
|
|
|
ifconf.ifc_len = sizeof(buffer);
|
|
|
|
ifconf.ifc_buf = buffer;
|
|
|
|
|
|
|
|
if (ioctl(fd, SIOCGIFCONF, &ifconf) != 0)
|
|
|
|
{
|
|
|
|
WSASetLastError(WSAENETDOWN);
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
offset = 0;
|
|
|
|
numInterfaces = 0;
|
|
|
|
ifreq = ifconf.ifc_req;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
while ((ifconf.ifc_len >= 0) && (offset < (size_t)ifconf.ifc_len) &&
|
|
|
|
(numInterfaces < maxNumInterfaces))
|
2015-02-18 21:35:33 +03:00
|
|
|
{
|
|
|
|
pInterface = &pInterfaces[index];
|
2019-11-06 17:24:51 +03:00
|
|
|
pAddress = (struct sockaddr_in*)&pInterface->iiAddress;
|
|
|
|
pBroadcast = (struct sockaddr_in*)&pInterface->iiBroadcastAddress;
|
|
|
|
pNetmask = (struct sockaddr_in*)&pInterface->iiNetmask;
|
2015-02-18 21:35:33 +03:00
|
|
|
|
|
|
|
if (ioctl(fd, SIOCGIFFLAGS, ifreq) != 0)
|
|
|
|
goto next_ifreq;
|
|
|
|
|
|
|
|
nFlags = 0;
|
|
|
|
|
|
|
|
if (ifreq->ifr_flags & IFF_UP)
|
|
|
|
nFlags |= _IFF_UP;
|
|
|
|
|
|
|
|
if (ifreq->ifr_flags & IFF_BROADCAST)
|
|
|
|
nFlags |= _IFF_BROADCAST;
|
|
|
|
|
|
|
|
if (ifreq->ifr_flags & IFF_LOOPBACK)
|
|
|
|
nFlags |= _IFF_LOOPBACK;
|
|
|
|
|
|
|
|
if (ifreq->ifr_flags & IFF_POINTOPOINT)
|
|
|
|
nFlags |= _IFF_POINTTOPOINT;
|
|
|
|
|
|
|
|
if (ifreq->ifr_flags & IFF_MULTICAST)
|
|
|
|
nFlags |= _IFF_MULTICAST;
|
|
|
|
|
|
|
|
pInterface->iiFlags = nFlags;
|
|
|
|
|
|
|
|
if (ioctl(fd, SIOCGIFADDR, ifreq) != 0)
|
|
|
|
goto next_ifreq;
|
|
|
|
|
|
|
|
if ((ifreq->ifr_addr.sa_family != AF_INET) && (ifreq->ifr_addr.sa_family != AF_INET6))
|
|
|
|
goto next_ifreq;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
getnameinfo(&ifreq->ifr_addr, sizeof(ifreq->ifr_addr), address, sizeof(address), 0, 0,
|
|
|
|
NI_NUMERICHOST);
|
|
|
|
inet_pton(ifreq->ifr_addr.sa_family, address, (void*)&pAddress->sin_addr);
|
2015-02-18 21:35:33 +03:00
|
|
|
|
|
|
|
if (ioctl(fd, SIOCGIFBRDADDR, ifreq) != 0)
|
|
|
|
goto next_ifreq;
|
|
|
|
|
|
|
|
if ((ifreq->ifr_addr.sa_family != AF_INET) && (ifreq->ifr_addr.sa_family != AF_INET6))
|
|
|
|
goto next_ifreq;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
getnameinfo(&ifreq->ifr_addr, sizeof(ifreq->ifr_addr), broadcast, sizeof(broadcast), 0, 0,
|
|
|
|
NI_NUMERICHOST);
|
|
|
|
inet_pton(ifreq->ifr_addr.sa_family, broadcast, (void*)&pBroadcast->sin_addr);
|
2015-02-18 21:35:33 +03:00
|
|
|
|
|
|
|
if (ioctl(fd, SIOCGIFNETMASK, ifreq) != 0)
|
|
|
|
goto next_ifreq;
|
|
|
|
|
|
|
|
if ((ifreq->ifr_addr.sa_family != AF_INET) && (ifreq->ifr_addr.sa_family != AF_INET6))
|
|
|
|
goto next_ifreq;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
getnameinfo(&ifreq->ifr_addr, sizeof(ifreq->ifr_addr), netmask, sizeof(netmask), 0, 0,
|
|
|
|
NI_NUMERICHOST);
|
|
|
|
inet_pton(ifreq->ifr_addr.sa_family, netmask, (void*)&pNetmask->sin_addr);
|
2015-02-18 21:35:33 +03:00
|
|
|
numInterfaces++;
|
2018-08-22 14:17:10 +03:00
|
|
|
next_ifreq:
|
2017-02-10 18:06:20 +03:00
|
|
|
#if !defined(__linux__) && !defined(__sun__) && !defined(__CYGWIN__)
|
2015-02-18 21:35:33 +03:00
|
|
|
ifreq_len = IFNAMSIZ + ifreq->ifr_addr.sa_len;
|
|
|
|
#else
|
|
|
|
ifreq_len = sizeof(*ifreq);
|
|
|
|
#endif
|
2019-11-06 17:24:51 +03:00
|
|
|
ifreq = (struct ifreq*)&((BYTE*)ifreq)[ifreq_len];
|
2015-02-18 21:35:33 +03:00
|
|
|
offset += ifreq_len;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
2018-08-22 14:17:10 +03:00
|
|
|
*lpcbBytesReturned = (DWORD)(numInterfaces * sizeof(INTERFACE_INFO));
|
2015-02-18 21:35:33 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-06 01:25:55 +04:00
|
|
|
SOCKET _accept(SOCKET s, struct sockaddr* addr, int* addrlen)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
|
|
|
socklen_t s_addrlen = (socklen_t)*addrlen;
|
2014-06-01 23:04:28 +04:00
|
|
|
status = accept(fd, addr, &s_addrlen);
|
2019-11-06 17:24:51 +03:00
|
|
|
*addrlen = (socklen_t)s_addrlen;
|
2014-06-01 23:04:28 +04:00
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int _bind(SOCKET s, const struct sockaddr* addr, int namelen)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
|
|
|
status = bind(fd, addr, (socklen_t)namelen);
|
2014-06-01 23:04:28 +04:00
|
|
|
|
2014-10-10 04:27:42 +04:00
|
|
|
if (status < 0)
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int closesocket(SOCKET s)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
2014-06-01 23:04:28 +04:00
|
|
|
status = close(fd);
|
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int _connect(SOCKET s, const struct sockaddr* name, int namelen)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
|
|
|
status = connect(fd, name, (socklen_t)namelen);
|
2014-06-01 23:04:28 +04:00
|
|
|
|
2014-10-10 04:27:42 +04:00
|
|
|
if (status < 0)
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
|
2014-06-01 23:04:28 +04:00
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int _ioctlsocket(SOCKET s, long cmd, u_long* argp)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
2015-02-09 06:29:52 +03:00
|
|
|
|
|
|
|
if (cmd == FIONBIO)
|
|
|
|
{
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
if (!argp)
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
|
|
|
|
flags = fcntl(fd, F_GETFL);
|
|
|
|
|
|
|
|
if (flags == -1)
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
|
|
|
|
if (*argp)
|
|
|
|
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
|
|
|
else
|
|
|
|
fcntl(fd, F_SETFL, flags & ~(O_NONBLOCK));
|
|
|
|
}
|
|
|
|
|
2014-02-06 01:25:55 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int _getpeername(SOCKET s, struct sockaddr* name, int* namelen)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
|
|
|
socklen_t s_namelen = (socklen_t)*namelen;
|
2014-06-01 23:04:28 +04:00
|
|
|
status = getpeername(fd, name, &s_namelen);
|
2019-11-06 17:24:51 +03:00
|
|
|
*namelen = (int)s_namelen;
|
2014-06-01 23:04:28 +04:00
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int _getsockname(SOCKET s, struct sockaddr* name, int* namelen)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
|
|
|
socklen_t s_namelen = (socklen_t)*namelen;
|
2014-06-01 23:04:28 +04:00
|
|
|
status = getsockname(fd, name, &s_namelen);
|
2019-11-06 17:24:51 +03:00
|
|
|
*namelen = (int)s_namelen;
|
2014-06-01 23:04:28 +04:00
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int _getsockopt(SOCKET s, int level, int optname, char* optval, int* optlen)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
|
|
|
socklen_t s_optlen = (socklen_t)*optlen;
|
|
|
|
status = getsockopt(fd, level, optname, (void*)optval, &s_optlen);
|
|
|
|
*optlen = (socklen_t)s_optlen;
|
2014-06-01 23:04:28 +04:00
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
u_long _htonl(u_long hostlong)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
return htonl(hostlong);
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
u_short _htons(u_short hostshort)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
return htons(hostshort);
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long _inet_addr(const char* cp)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
return (long)inet_addr(cp);
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
char* _inet_ntoa(struct in_addr in)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
return inet_ntoa(in);
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int _listen(SOCKET s, int backlog)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
2014-06-01 23:04:28 +04:00
|
|
|
status = listen(fd, backlog);
|
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
2012-09-20 18:42:01 +04:00
|
|
|
|
2014-02-06 01:25:55 +04:00
|
|
|
u_long _ntohl(u_long netlong)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
return ntohl(netlong);
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
u_short _ntohs(u_short netshort)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
return ntohs(netshort);
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int _recv(SOCKET s, char* buf, int len, int flags)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
|
|
|
status = (int)recv(fd, (void*)buf, (size_t)len, flags);
|
2014-06-01 23:04:28 +04:00
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int _recvfrom(SOCKET s, char* buf, int len, int flags, struct sockaddr* from, int* fromlen)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
|
|
|
socklen_t s_fromlen = (socklen_t)*fromlen;
|
|
|
|
status = (int)recvfrom(fd, (void*)buf, (size_t)len, flags, from, &s_fromlen);
|
|
|
|
*fromlen = (int)s_fromlen;
|
2014-06-01 23:04:28 +04:00
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
2018-08-22 14:17:10 +03:00
|
|
|
int _select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds,
|
|
|
|
const struct timeval* timeout)
|
2014-02-06 01:25:55 +04:00
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
|
|
|
|
2014-07-02 17:15:46 +04:00
|
|
|
do
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
status = select(nfds, readfds, writefds, exceptfds, (struct timeval*)timeout);
|
|
|
|
} while ((status < 0) && (errno == EINTR));
|
2014-06-01 23:04:28 +04:00
|
|
|
|
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int _send(SOCKET s, const char* buf, int len, int flags)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
2014-06-02 05:37:20 +04:00
|
|
|
flags |= MSG_NOSIGNAL;
|
2019-11-06 17:24:51 +03:00
|
|
|
status = (int)send(fd, (void*)buf, (size_t)len, flags);
|
2014-06-01 23:04:28 +04:00
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int _sendto(SOCKET s, const char* buf, int len, int flags, const struct sockaddr* to, int tolen)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
|
|
|
status = (int)sendto(fd, (void*)buf, (size_t)len, flags, to, (socklen_t)tolen);
|
2014-06-01 23:04:28 +04:00
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int _setsockopt(SOCKET s, int level, int optname, const char* optval, int optlen)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
|
|
|
status = setsockopt(fd, level, optname, (void*)optval, (socklen_t)optlen);
|
2014-06-01 23:04:28 +04:00
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int _shutdown(SOCKET s, int how)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
int fd = (int)s;
|
2014-06-01 23:04:28 +04:00
|
|
|
int s_how = -1;
|
|
|
|
|
|
|
|
switch (how)
|
|
|
|
{
|
|
|
|
case SD_RECEIVE:
|
|
|
|
s_how = SHUT_RD;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SD_SEND:
|
|
|
|
s_how = SHUT_WR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SD_BOTH:
|
|
|
|
s_how = SHUT_RDWR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s_how < 0)
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
|
|
|
|
status = shutdown(fd, s_how);
|
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
SOCKET _socket(int af, int type, int protocol)
|
|
|
|
{
|
2014-10-10 04:27:42 +04:00
|
|
|
int fd;
|
2014-06-01 23:04:28 +04:00
|
|
|
SOCKET s;
|
2014-10-10 04:27:42 +04:00
|
|
|
fd = socket(af, type, protocol);
|
|
|
|
|
2018-08-20 12:11:47 +03:00
|
|
|
if (fd < 0)
|
2014-10-10 04:27:42 +04:00
|
|
|
return INVALID_SOCKET;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
s = (SOCKET)fd;
|
2014-06-01 23:04:28 +04:00
|
|
|
return s;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct hostent* _gethostbyaddr(const char* addr, int len, int type)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
struct hostent* host;
|
2019-11-06 17:24:51 +03:00
|
|
|
host = gethostbyaddr((void*)addr, (socklen_t)len, type);
|
2014-06-01 23:04:28 +04:00
|
|
|
return host;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct hostent* _gethostbyname(const char* name)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
struct hostent* host;
|
|
|
|
host = gethostbyname(name);
|
|
|
|
return host;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int _gethostname(char* name, int namelen)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
int status;
|
2019-11-06 17:24:51 +03:00
|
|
|
status = gethostname(name, (size_t)namelen);
|
2014-06-01 23:04:28 +04:00
|
|
|
return status;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct servent* _getservbyport(int port, const char* proto)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
struct servent* serv;
|
|
|
|
serv = getservbyport(port, proto);
|
|
|
|
return serv;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct servent* _getservbyname(const char* name, const char* proto)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
struct servent* serv;
|
|
|
|
serv = getservbyname(name, proto);
|
|
|
|
return serv;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct protoent* _getprotobynumber(int number)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
struct protoent* proto;
|
|
|
|
proto = getprotobynumber(number);
|
|
|
|
return proto;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct protoent* _getprotobyname(const char* name)
|
|
|
|
{
|
2014-06-01 23:04:28 +04:00
|
|
|
struct protoent* proto;
|
|
|
|
proto = getprotobyname(name);
|
|
|
|
return proto;
|
2014-02-06 01:25:55 +04:00
|
|
|
}
|
2012-09-20 18:42:01 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
#endif /* _WIN32 */
|