2004-09-06 23:29:29 +02:00
|
|
|
/*
|
|
|
|
* Protocol enumeration functions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 Stefan Leichter
|
2004-11-02 00:18:47 +01:00
|
|
|
* Copyright (C) 2004 Hans Leidekker
|
2004-09-06 23:29:29 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2004-11-02 20:24:46 +01:00
|
|
|
/* 02/11/2004
|
|
|
|
* The protocol enumeration functions were verified to match Win2k versions
|
|
|
|
* for these protocols: IPX, SPX, SPXII, TCP/IP and UDP/IP.
|
|
|
|
*/
|
|
|
|
|
2004-09-06 23:29:29 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#ifdef HAVE_ARPA_INET_H
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NETDB_H
|
|
|
|
#include <netdb.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "wtypes.h"
|
|
|
|
#include "nspapi.h"
|
|
|
|
#include "winsock2.h"
|
|
|
|
#include "wsipx.h"
|
|
|
|
#include "wshisotp.h"
|
|
|
|
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(winsock);
|
|
|
|
|
2004-11-02 00:18:47 +01:00
|
|
|
/* names of the protocols */
|
|
|
|
static const CHAR NameIpx[] = "IPX";
|
|
|
|
static const CHAR NameSpx[] = "SPX";
|
|
|
|
static const CHAR NameSpxII[] = "SPX II";
|
|
|
|
static const CHAR NameTcp[] = "TCP/IP";
|
|
|
|
static const CHAR NameUdp[] = "UDP/IP";
|
|
|
|
|
|
|
|
static const WCHAR NameIpxW[] = {'I', 'P', 'X', '\0'};
|
|
|
|
static const WCHAR NameSpxW[] = {'S', 'P', 'X', '\0'};
|
|
|
|
static const WCHAR NameSpxIIW[] = {'S', 'P', 'X', ' ', 'I', 'I', '\0'};
|
|
|
|
static const WCHAR NameTcpW[] = {'T', 'C', 'P', '/', 'I', 'P', '\0'};
|
|
|
|
static const WCHAR NameUdpW[] = {'U', 'D', 'P', '/', 'I', 'P', '\0'};
|
|
|
|
|
|
|
|
/* Taken from Win2k */
|
2004-11-02 20:24:46 +01:00
|
|
|
static const GUID ProviderIdIP = { 0xe70f1aa0, 0xab8b, 0x11cf,
|
|
|
|
{ 0x8c, 0xa3, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 } };
|
|
|
|
static const GUID ProviderIdIPX = { 0x11058240, 0xbe47, 0x11cf,
|
|
|
|
{ 0x95, 0xc8, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 } };
|
|
|
|
static const GUID ProviderIdSPX = { 0x11058241, 0xbe47, 0x11cf,
|
|
|
|
{ 0x95, 0xc8, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 } };
|
2004-09-06 23:29:29 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
2004-11-02 00:18:47 +01:00
|
|
|
* WINSOCK_EnterSingleProtocolW [internal]
|
2004-09-06 23:29:29 +02:00
|
|
|
*
|
2004-11-02 00:18:47 +01:00
|
|
|
* enters the protocol information of one given protocol into the given
|
|
|
|
* buffer.
|
2004-09-06 23:29:29 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2004-11-02 00:18:47 +01:00
|
|
|
* 1 if a protocol was entered into the buffer.
|
|
|
|
* SOCKET_ERROR otherwise.
|
2004-09-06 23:29:29 +02:00
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* - only implemented for IPX, SPX, SPXII, TCP, UDP
|
|
|
|
* - there is no check that the operating system supports the returned
|
|
|
|
* protocols
|
|
|
|
*/
|
2004-11-02 00:18:47 +01:00
|
|
|
static INT WINSOCK_EnterSingleProtocolW( INT protocol, WSAPROTOCOL_INFOW* info )
|
2004-09-06 23:29:29 +02:00
|
|
|
{
|
2004-11-02 00:18:47 +01:00
|
|
|
memset( info, 0, sizeof(WSAPROTOCOL_INFOW) );
|
|
|
|
info->iProtocol = protocol;
|
|
|
|
|
|
|
|
switch (protocol)
|
|
|
|
{
|
|
|
|
case WS_IPPROTO_TCP:
|
|
|
|
info->dwServiceFlags1 = XP1_PARTIAL_MESSAGE | XP1_EXPEDITED_DATA |
|
|
|
|
XP1_GRACEFUL_CLOSE | XP1_GUARANTEED_ORDER |
|
|
|
|
XP1_GUARANTEED_DELIVERY;
|
2004-11-02 20:24:46 +01:00
|
|
|
memcpy( &info->ProviderId, &ProviderIdIP, sizeof(GUID) );
|
2004-11-02 00:18:47 +01:00
|
|
|
info->dwCatalogEntryId = 0x3e9;
|
|
|
|
info->ProtocolChain.ChainLen = 1;
|
|
|
|
info->iVersion = 2;
|
|
|
|
info->iAddressFamily = WS_AF_INET;
|
|
|
|
info->iMaxSockAddr = 0x10;
|
|
|
|
info->iMinSockAddr = 0x10;
|
|
|
|
info->iSocketType = WS_SOCK_STREAM;
|
|
|
|
strcpyW( info->szProtocol, NameTcpW );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WS_IPPROTO_UDP:
|
|
|
|
info->dwServiceFlags1 = XP1_PARTIAL_MESSAGE | XP1_SUPPORT_BROADCAST |
|
|
|
|
XP1_SUPPORT_MULTIPOINT | XP1_MESSAGE_ORIENTED |
|
|
|
|
XP1_CONNECTIONLESS;
|
2004-11-02 20:24:46 +01:00
|
|
|
memcpy( &info->ProviderId, &ProviderIdIP, sizeof(GUID) );
|
2004-11-02 00:18:47 +01:00
|
|
|
info->dwCatalogEntryId = 0x3ea;
|
|
|
|
info->ProtocolChain.ChainLen = 1;
|
|
|
|
info->iVersion = 2;
|
|
|
|
info->iAddressFamily = WS_AF_INET;
|
|
|
|
info->iMaxSockAddr = 0x10;
|
|
|
|
info->iMinSockAddr = 0x10;
|
|
|
|
info->iSocketType = WS_SOCK_DGRAM;
|
|
|
|
info->dwMessageSize = 0xffbb;
|
|
|
|
strcpyW( info->szProtocol, NameUdpW );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSPROTO_IPX:
|
|
|
|
info->dwServiceFlags1 = XP1_PARTIAL_MESSAGE | XP1_SUPPORT_BROADCAST |
|
|
|
|
XP1_SUPPORT_MULTIPOINT | XP1_MESSAGE_ORIENTED |
|
|
|
|
XP1_CONNECTIONLESS;
|
2004-11-02 20:24:46 +01:00
|
|
|
memcpy( &info->ProviderId, &ProviderIdIPX, sizeof(GUID) );
|
|
|
|
info->dwCatalogEntryId = 0x406;
|
|
|
|
info->ProtocolChain.ChainLen = 1;
|
|
|
|
info->iVersion = 2;
|
2004-11-02 00:18:47 +01:00
|
|
|
info->iAddressFamily = WS_AF_IPX;
|
|
|
|
info->iMaxSockAddr = 0x10;
|
|
|
|
info->iMinSockAddr = 0x0e;
|
|
|
|
info->iSocketType = WS_SOCK_DGRAM;
|
2004-11-02 20:24:46 +01:00
|
|
|
info->iProtocolMaxOffset = 0xff;
|
|
|
|
info->dwMessageSize = 0x240;
|
2004-11-02 00:18:47 +01:00
|
|
|
strcpyW( info->szProtocol, NameIpxW );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSPROTO_SPX:
|
2004-11-02 20:24:46 +01:00
|
|
|
info->dwServiceFlags1 = XP1_IFS_HANDLES | XP1_PSEUDO_STREAM |
|
|
|
|
XP1_MESSAGE_ORIENTED | XP1_GUARANTEED_ORDER |
|
|
|
|
XP1_GUARANTEED_DELIVERY;
|
|
|
|
memcpy( &info->ProviderId, &ProviderIdSPX, sizeof(GUID) );
|
|
|
|
info->dwCatalogEntryId = 0x407;
|
|
|
|
info->ProtocolChain.ChainLen = 1;
|
|
|
|
info->iVersion = 2;
|
2004-11-02 00:18:47 +01:00
|
|
|
info->iAddressFamily = WS_AF_IPX;
|
|
|
|
info->iMaxSockAddr = 0x10;
|
|
|
|
info->iMinSockAddr = 0x0e;
|
|
|
|
info->iSocketType = 5;
|
2004-11-02 20:24:46 +01:00
|
|
|
info->dwMessageSize = 0xffffffff;
|
2004-11-02 00:18:47 +01:00
|
|
|
strcpyW( info->szProtocol, NameSpxW );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSPROTO_SPXII:
|
2004-11-02 20:24:46 +01:00
|
|
|
info->dwServiceFlags1 = XP1_IFS_HANDLES | XP1_GRACEFUL_CLOSE |
|
2004-11-02 00:18:47 +01:00
|
|
|
XP1_PSEUDO_STREAM | XP1_MESSAGE_ORIENTED |
|
|
|
|
XP1_GUARANTEED_ORDER | XP1_GUARANTEED_DELIVERY;
|
2004-11-02 20:24:46 +01:00
|
|
|
memcpy( &info->ProviderId, &ProviderIdSPX, sizeof(GUID) );
|
|
|
|
info->dwCatalogEntryId = 0x409;
|
|
|
|
info->ProtocolChain.ChainLen = 1;
|
|
|
|
info->iVersion = 2;
|
2004-11-02 00:18:47 +01:00
|
|
|
info->iAddressFamily = WS_AF_IPX;
|
|
|
|
info->iMaxSockAddr = 0x10;
|
|
|
|
info->iMinSockAddr = 0x0e;
|
|
|
|
info->iSocketType = 5;
|
2004-11-02 20:24:46 +01:00
|
|
|
info->dwMessageSize = 0xffffffff;
|
2004-11-02 00:18:47 +01:00
|
|
|
strcpyW( info->szProtocol, NameSpxIIW );
|
|
|
|
break;
|
|
|
|
|
2004-09-06 23:29:29 +02:00
|
|
|
default:
|
2004-11-02 00:18:47 +01:00
|
|
|
if ((protocol == ISOPROTO_TP4) || (protocol == NSPROTO_SPX))
|
|
|
|
FIXME("Protocol <%s> not implemented\n",
|
|
|
|
(protocol == ISOPROTO_TP4) ? "ISOPROTO_TP4" : "NSPROTO_SPX");
|
2004-09-06 23:29:29 +02:00
|
|
|
else
|
2004-11-02 00:18:47 +01:00
|
|
|
FIXME("unknown Protocol <0x%08x>\n", protocol);
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
}
|
|
|
|
return 1;
|
2004-09-06 23:29:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2004-11-02 00:18:47 +01:00
|
|
|
* WINSOCK_EnterSingleProtocolA [internal]
|
2004-09-06 23:29:29 +02:00
|
|
|
*
|
2004-11-02 00:18:47 +01:00
|
|
|
* see function WINSOCK_EnterSingleProtocolW
|
2004-09-06 23:29:29 +02:00
|
|
|
*
|
|
|
|
*/
|
2004-11-02 00:18:47 +01:00
|
|
|
static INT WINSOCK_EnterSingleProtocolA( INT protocol, WSAPROTOCOL_INFOA* info )
|
2004-09-06 23:29:29 +02:00
|
|
|
{
|
2004-11-02 00:18:47 +01:00
|
|
|
memset( info, 0, sizeof(WSAPROTOCOL_INFOA) );
|
|
|
|
info->iProtocol = protocol;
|
|
|
|
|
|
|
|
switch (protocol)
|
|
|
|
{
|
|
|
|
case WS_IPPROTO_TCP:
|
|
|
|
info->dwServiceFlags1 = XP1_IFS_HANDLES | XP1_EXPEDITED_DATA |
|
|
|
|
XP1_GRACEFUL_CLOSE | XP1_GUARANTEED_ORDER |
|
|
|
|
XP1_GUARANTEED_DELIVERY;
|
2004-11-02 20:24:46 +01:00
|
|
|
memcpy( &info->ProviderId, &ProviderIdIP, sizeof(GUID) );
|
2004-11-02 00:18:47 +01:00
|
|
|
info->dwCatalogEntryId = 0x3e9;
|
|
|
|
info->ProtocolChain.ChainLen = 1;
|
|
|
|
info->iVersion = 2;
|
|
|
|
info->iAddressFamily = WS_AF_INET;
|
|
|
|
info->iMaxSockAddr = 0x10;
|
|
|
|
info->iMinSockAddr = 0x10;
|
|
|
|
info->iSocketType = WS_SOCK_STREAM;
|
|
|
|
strcpy( info->szProtocol, NameTcp );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WS_IPPROTO_UDP:
|
|
|
|
info->dwServiceFlags1 = XP1_IFS_HANDLES | XP1_SUPPORT_BROADCAST |
|
|
|
|
XP1_SUPPORT_MULTIPOINT | XP1_MESSAGE_ORIENTED |
|
|
|
|
XP1_CONNECTIONLESS;
|
2004-11-02 20:24:46 +01:00
|
|
|
memcpy( &info->ProviderId, &ProviderIdIP, sizeof(GUID) );
|
2004-11-02 00:18:47 +01:00
|
|
|
info->dwCatalogEntryId = 0x3ea;
|
|
|
|
info->ProtocolChain.ChainLen = 1;
|
|
|
|
info->iVersion = 2;
|
|
|
|
info->iAddressFamily = WS_AF_INET;
|
|
|
|
info->iMaxSockAddr = 0x10;
|
|
|
|
info->iMinSockAddr = 0x10;
|
|
|
|
info->iSocketType = WS_SOCK_DGRAM;
|
|
|
|
info->dwMessageSize = 0xffbb;
|
|
|
|
strcpy( info->szProtocol, NameUdp );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSPROTO_IPX:
|
2004-11-02 20:24:46 +01:00
|
|
|
info->dwServiceFlags1 = XP1_IFS_HANDLES | XP1_SUPPORT_BROADCAST |
|
2004-11-02 00:18:47 +01:00
|
|
|
XP1_SUPPORT_MULTIPOINT | XP1_MESSAGE_ORIENTED |
|
|
|
|
XP1_CONNECTIONLESS;
|
2004-11-02 20:24:46 +01:00
|
|
|
memcpy( &info->ProviderId, &ProviderIdIPX, sizeof(GUID) );
|
|
|
|
info->dwCatalogEntryId = 0x406;
|
|
|
|
info->ProtocolChain.ChainLen = 1;
|
|
|
|
info->iVersion = 2;
|
2004-11-02 00:18:47 +01:00
|
|
|
info->iAddressFamily = WS_AF_IPX;
|
|
|
|
info->iMaxSockAddr = 0x10;
|
|
|
|
info->iMinSockAddr = 0x0e;
|
|
|
|
info->iSocketType = WS_SOCK_DGRAM;
|
2004-11-02 20:24:46 +01:00
|
|
|
info->iProtocolMaxOffset = 0xff;
|
|
|
|
info->dwMessageSize = 0x240;
|
2004-11-02 00:18:47 +01:00
|
|
|
strcpy( info->szProtocol, NameIpx );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSPROTO_SPX:
|
2004-11-02 20:24:46 +01:00
|
|
|
info->dwServiceFlags1 = XP1_IFS_HANDLES | XP1_PSEUDO_STREAM |
|
|
|
|
XP1_MESSAGE_ORIENTED | XP1_GUARANTEED_ORDER |
|
|
|
|
XP1_GUARANTEED_DELIVERY;
|
|
|
|
memcpy( &info->ProviderId, &ProviderIdSPX, sizeof(GUID) );
|
|
|
|
info->dwCatalogEntryId = 0x407;
|
|
|
|
info->ProtocolChain.ChainLen = 1;
|
|
|
|
info->iVersion = 2;
|
2004-11-02 00:18:47 +01:00
|
|
|
info->iAddressFamily = WS_AF_IPX;
|
|
|
|
info->iMaxSockAddr = 0x10;
|
|
|
|
info->iMinSockAddr = 0x0e;
|
|
|
|
info->iSocketType = 5;
|
2004-11-02 20:24:46 +01:00
|
|
|
info->dwMessageSize = 0xffffffff;
|
2004-11-02 00:18:47 +01:00
|
|
|
strcpy( info->szProtocol, NameSpx );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSPROTO_SPXII:
|
2004-11-02 20:24:46 +01:00
|
|
|
info->dwServiceFlags1 = XP1_IFS_HANDLES | XP1_GRACEFUL_CLOSE |
|
2004-11-02 00:18:47 +01:00
|
|
|
XP1_PSEUDO_STREAM | XP1_MESSAGE_ORIENTED |
|
|
|
|
XP1_GUARANTEED_ORDER | XP1_GUARANTEED_DELIVERY;
|
2004-11-02 20:24:46 +01:00
|
|
|
memcpy( &info->ProviderId, &ProviderIdSPX, sizeof(GUID) );
|
|
|
|
info->dwCatalogEntryId = 0x409;
|
|
|
|
info->ProtocolChain.ChainLen = 1;
|
|
|
|
info->iVersion = 2;
|
2004-11-02 00:18:47 +01:00
|
|
|
info->iAddressFamily = WS_AF_IPX;
|
|
|
|
info->iMaxSockAddr = 0x10;
|
|
|
|
info->iMinSockAddr = 0x0e;
|
|
|
|
info->iSocketType = 5;
|
2004-11-02 20:24:46 +01:00
|
|
|
info->dwMessageSize = 0xffffffff;
|
2004-11-02 00:18:47 +01:00
|
|
|
strcpy( info->szProtocol, NameSpxII );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if ((protocol == ISOPROTO_TP4) || (protocol == NSPROTO_SPX))
|
|
|
|
FIXME("Protocol <%s> not implemented\n",
|
|
|
|
(protocol == ISOPROTO_TP4) ? "ISOPROTO_TP4" : "NSPROTO_SPX");
|
|
|
|
else
|
|
|
|
FIXME("unknown Protocol <0x%08x>\n", protocol);
|
|
|
|
return SOCKET_ERROR;
|
2004-09-06 23:29:29 +02:00
|
|
|
}
|
2004-11-02 00:18:47 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2004-09-06 23:29:29 +02:00
|
|
|
|
2004-11-02 00:18:47 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* WSAEnumProtocolsA [WS2_32.@]
|
|
|
|
*
|
|
|
|
* see function WSAEnumProtocolsW
|
|
|
|
*/
|
|
|
|
INT WINAPI WSAEnumProtocolsA( LPINT protocols, LPWSAPROTOCOL_INFOA buffer, LPDWORD len )
|
|
|
|
{
|
|
|
|
INT i = 0;
|
|
|
|
DWORD size = 0;
|
2004-11-02 20:24:46 +01:00
|
|
|
INT local[] = { WS_IPPROTO_TCP, WS_IPPROTO_UDP, NSPROTO_IPX, NSPROTO_SPX, NSPROTO_SPXII, 0 };
|
2004-11-02 00:18:47 +01:00
|
|
|
|
|
|
|
if (!buffer)
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
|
|
|
|
if (!protocols) protocols = local;
|
2004-09-06 23:29:29 +02:00
|
|
|
|
2004-11-02 00:18:47 +01:00
|
|
|
while (protocols[i]) i++;
|
|
|
|
|
|
|
|
size = i * sizeof(WSAPROTOCOL_INFOA);
|
|
|
|
|
|
|
|
if (*len < size)
|
|
|
|
{
|
|
|
|
*len = size;
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
}
|
2004-09-06 23:29:29 +02:00
|
|
|
|
2004-11-02 00:18:47 +01:00
|
|
|
for (i = 0; protocols[i]; i++)
|
|
|
|
{
|
|
|
|
if (WINSOCK_EnterSingleProtocolA( protocols[i], &buffer[i] ) == SOCKET_ERROR)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return i;
|
2004-09-06 23:29:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2004-11-02 00:18:47 +01:00
|
|
|
* WSAEnumProtocolsW [WS2_32.@]
|
2004-09-06 23:29:29 +02:00
|
|
|
*
|
|
|
|
* Retrieves information about specified set of active network protocols.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2004-11-02 00:18:47 +01:00
|
|
|
* protocols [I] Pointer to null-terminated array of protocol id's. NULL
|
|
|
|
* retrieves information on all available protocols.
|
|
|
|
* buffer [I] Pointer to a buffer to be filled with WSAPROTOCOL_INFO
|
|
|
|
* structures.
|
|
|
|
* len [I/O] Pointer to a variable specifying buffer size. On output
|
|
|
|
* the variable holds the number of bytes needed when the
|
|
|
|
* specified size is too small.
|
2004-09-06 23:29:29 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2004-11-02 00:18:47 +01:00
|
|
|
* Success: number of WSAPROTOCOL_INFO structures in buffer.
|
|
|
|
* Failure: SOCKET_ERROR
|
2004-09-06 23:29:29 +02:00
|
|
|
*
|
|
|
|
* NOTES
|
2004-11-02 20:24:46 +01:00
|
|
|
* NT4SP5 does not return SPX if protocols == NULL
|
2004-11-02 00:18:47 +01:00
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* - NT4SP5 returns in addition these list of NETBIOS protocols
|
|
|
|
* (address family 17), each entry two times one for socket type 2 and 5
|
|
|
|
*
|
|
|
|
* iProtocol szProtocol
|
|
|
|
* 0x80000000 \Device\NwlnkNb
|
|
|
|
* 0xfffffffa \Device\NetBT_CBENT7
|
|
|
|
* 0xfffffffb \Device\Nbf_CBENT7
|
|
|
|
* 0xfffffffc \Device\NetBT_NdisWan5
|
|
|
|
* 0xfffffffd \Device\NetBT_El9202
|
|
|
|
* 0xfffffffe \Device\Nbf_El9202
|
|
|
|
* 0xffffffff \Device\Nbf_NdisWan4
|
|
|
|
*
|
|
|
|
* - there is no check that the operating system supports the returned
|
|
|
|
* protocols
|
2004-09-06 23:29:29 +02:00
|
|
|
*/
|
2004-11-02 00:18:47 +01:00
|
|
|
INT WINAPI WSAEnumProtocolsW( LPINT protocols, LPWSAPROTOCOL_INFOW buffer, LPDWORD len )
|
2004-09-06 23:29:29 +02:00
|
|
|
{
|
2004-11-02 00:18:47 +01:00
|
|
|
INT i = 0;
|
|
|
|
DWORD size = 0;
|
2004-11-02 20:24:46 +01:00
|
|
|
INT local[] = { WS_IPPROTO_TCP, WS_IPPROTO_UDP, NSPROTO_IPX, NSPROTO_SPX, NSPROTO_SPXII, 0 };
|
2004-11-02 00:18:47 +01:00
|
|
|
|
|
|
|
if (!buffer)
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
|
|
|
|
if (!protocols) protocols = local;
|
|
|
|
|
|
|
|
while (protocols[i]) i++;
|
|
|
|
|
|
|
|
size = i * sizeof(WSAPROTOCOL_INFOW);
|
|
|
|
|
|
|
|
if (*len < size)
|
|
|
|
{
|
|
|
|
*len = size;
|
|
|
|
return SOCKET_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; protocols[i]; i++)
|
|
|
|
{
|
|
|
|
if (WINSOCK_EnterSingleProtocolW( protocols[i], &buffer[i] ) == SOCKET_ERROR)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return i;
|
2004-09-06 23:29:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2004-11-02 00:18:47 +01:00
|
|
|
* WSCEnumProtocols [WS2_32.@]
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* protocols [I] Null-terminated array of iProtocol values.
|
|
|
|
* buffer [O] Buffer of WSAPROTOCOL_INFOW structures.
|
|
|
|
* len [I/O] Size of buffer on input/output.
|
|
|
|
* errno [O] Error code.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: number of protocols to be reported on.
|
|
|
|
* Failure: SOCKET_ERROR. error is in errno.
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* Doesn't supply info on layered protocols.
|
2004-09-06 23:29:29 +02:00
|
|
|
*
|
|
|
|
*/
|
2004-11-02 00:18:47 +01:00
|
|
|
INT WINAPI WSCEnumProtocols( LPINT protocols, LPWSAPROTOCOL_INFOW buffer, LPDWORD len, LPINT errno )
|
2004-09-06 23:29:29 +02:00
|
|
|
{
|
2004-11-02 00:18:47 +01:00
|
|
|
INT ret = WSAEnumProtocolsW( protocols, buffer, len );
|
|
|
|
|
|
|
|
if (ret == SOCKET_ERROR) *errno = WSAENOBUFS;
|
|
|
|
|
|
|
|
return ret;
|
2004-09-06 23:29:29 +02:00
|
|
|
}
|