Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
bec06ad7
Commit
bec06ad7
authored
Nov 01, 2004
by
Hans Leidekker
Committed by
Alexandre Julliard
Nov 01, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fill WSAPROTOCOL_INFO structures instead of PROTOCOL_INFO structures.
Implement WSCEnumProtocols(). Add some tests.
parent
d3eb0550
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
397 additions
and
172 deletions
+397
-172
protocol.c
dlls/winsock/protocol.c
+260
-171
.cvsignore
dlls/winsock/tests/.cvsignore
+1
-0
Makefile.in
dlls/winsock/tests/Makefile.in
+1
-0
protocol.c
dlls/winsock/tests/protocol.c
+109
-0
ws2_32.spec
dlls/winsock/ws2_32.spec
+1
-1
winsock2.h
include/winsock2.h
+25
-0
No files found.
dlls/winsock/protocol.c
View file @
bec06ad7
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
* Protocol enumeration functions
* Protocol enumeration functions
*
*
* Copyright (C) 2001 Stefan Leichter
* Copyright (C) 2001 Stefan Leichter
* Copyright (C) 2004 Hans Leidekker
*
*
* This library is free software; you can redistribute it and/or
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* modify it under the terms of the GNU Lesser General Public
...
@@ -46,166 +47,273 @@
...
@@ -46,166 +47,273 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
winsock
);
WINE_DEFAULT_DEBUG_CHANNEL
(
winsock
);
/* name of the protocols
/* names of the protocols */
*/
static
const
CHAR
NameIpx
[]
=
"IPX"
;
static
const
WCHAR
NameIpx
[]
=
{
'I'
,
'P'
,
'X'
,
'\0'
};
static
const
CHAR
NameSpx
[]
=
"SPX"
;
static
const
WCHAR
NameSpx
[]
=
{
'S'
,
'P'
,
'X'
,
'\0'
};
static
const
CHAR
NameSpxII
[]
=
"SPX II"
;
static
const
WCHAR
NameSpxII
[]
=
{
'S'
,
'P'
,
'X'
,
' '
,
'I'
,
'I'
,
'\0'
};
static
const
CHAR
NameTcp
[]
=
"TCP/IP"
;
static
const
WCHAR
NameTcp
[]
=
{
'T'
,
'C'
,
'P'
,
'/'
,
'I'
,
'P'
,
'\0'
};
static
const
CHAR
NameUdp
[]
=
"UDP/IP"
;
static
const
WCHAR
NameUdp
[]
=
{
'U'
,
'D'
,
'P'
,
'/'
,
'I'
,
'P'
,
'\0'
};
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 */
GUID
ProviderId
=
{
0xe70f1aa0
,
0xab8b
,
0x11cf
,
{
0x8c
,
0xa3
,
0x00
,
0x80
,
0x5f
,
0x48
,
0xa1
,
0x92
}
};
/*****************************************************************************
/*****************************************************************************
* WINSOCK_EnterSingleProtocol [internal]
* WINSOCK_EnterSingleProtocol
W
[internal]
*
*
* enters the protocol informations of one given protocol into the
* enters the protocol information of one given protocol into the given
* given buffer. If the given buffer is too small only the required size for
* buffer.
* the protocols are returned.
*
*
* RETURNS
* RETURNS
* The number of protocols entered into the buffer
* 1 if a protocol was entered into the buffer.
* SOCKET_ERROR otherwise.
*
*
* BUGS
* BUGS
* - only implemented for IPX, SPX, SPXII, TCP, UDP
* - only implemented for IPX, SPX, SPXII, TCP, UDP
* - there is no check that the operating system supports the returned
* - there is no check that the operating system supports the returned
* protocols
* protocols
*/
*/
static
INT
WINSOCK_EnterSingleProtocol
(
INT
iProtocol
,
PROTOCOL_INFOA
*
lpBuffer
,
static
INT
WINSOCK_EnterSingleProtocolW
(
INT
protocol
,
WSAPROTOCOL_INFOW
*
info
)
LPDWORD
lpSize
,
BOOL
unicode
)
{
{
DWORD
dwLength
=
0
,
dwOldSize
=
*
lpSize
;
memset
(
info
,
0
,
sizeof
(
WSAPROTOCOL_INFOW
)
);
INT
iAnz
=
1
;
info
->
iProtocol
=
protocol
;
const
WCHAR
*
lpProtName
=
NULL
;
switch
(
protocol
)
*
lpSize
=
sizeof
(
PROTOCOL_INFOA
);
{
switch
(
iProtocol
)
{
case
WS_IPPROTO_TCP
:
case
WS_IPPROTO_TCP
:
info
->
dwServiceFlags1
=
XP1_PARTIAL_MESSAGE
|
XP1_EXPEDITED_DATA
|
dwLength
=
(
unicode
)
?
sizeof
(
WCHAR
)
*
(
strlenW
(
NameTcp
)
+
1
)
:
XP1_GRACEFUL_CLOSE
|
XP1_GUARANTEED_ORDER
|
WideCharToMultiByte
(
CP_ACP
,
0
,
NameTcp
,
-
1
,
XP1_GUARANTEED_DELIVERY
;
NULL
,
0
,
NULL
,
NULL
);
memcpy
(
&
info
->
ProviderId
,
&
ProviderId
,
sizeof
(
GUID
)
);
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
;
break
;
case
WS_IPPROTO_UDP
:
dwLength
=
(
unicode
)
?
sizeof
(
WCHAR
)
*
(
strlenW
(
NameUdp
)
+
1
)
:
case
WS_IPPROTO_UDP
:
WideCharToMultiByte
(
CP_ACP
,
0
,
NameUdp
,
-
1
,
info
->
dwServiceFlags1
=
XP1_PARTIAL_MESSAGE
|
XP1_SUPPORT_BROADCAST
|
NULL
,
0
,
NULL
,
NULL
);
XP1_SUPPORT_MULTIPOINT
|
XP1_MESSAGE_ORIENTED
|
XP1_CONNECTIONLESS
;
memcpy
(
&
info
->
ProviderId
,
&
ProviderId
,
sizeof
(
GUID
)
);
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
;
break
;
case
NSPROTO_IPX
:
dwLength
=
(
unicode
)
?
sizeof
(
WCHAR
)
*
(
strlenW
(
NameIpx
)
+
1
)
:
case
NSPROTO_IPX
:
WideCharToMultiByte
(
CP_ACP
,
0
,
NameIpx
,
-
1
,
info
->
dwServiceFlags1
=
XP1_PARTIAL_MESSAGE
|
XP1_SUPPORT_BROADCAST
|
NULL
,
0
,
NULL
,
NULL
);
XP1_SUPPORT_MULTIPOINT
|
XP1_MESSAGE_ORIENTED
|
XP1_CONNECTIONLESS
;
info
->
iAddressFamily
=
WS_AF_IPX
;
info
->
iMaxSockAddr
=
0x10
;
info
->
iMinSockAddr
=
0x0e
;
info
->
iSocketType
=
WS_SOCK_DGRAM
;
info
->
dwMessageSize
=
576
;
strcpyW
(
info
->
szProtocol
,
NameIpxW
);
break
;
break
;
case
NSPROTO_SPX
:
dwLength
=
(
unicode
)
?
sizeof
(
WCHAR
)
*
(
strlenW
(
NameSpx
)
+
1
)
:
case
NSPROTO_SPX
:
WideCharToMultiByte
(
CP_ACP
,
0
,
NameSpx
,
-
1
,
info
->
dwServiceFlags1
=
XP1_PARTIAL_MESSAGE
|
NULL
,
0
,
NULL
,
NULL
);
XP1_PSEUDO_STREAM
|
XP1_MESSAGE_ORIENTED
|
XP1_GUARANTEED_ORDER
|
XP1_GUARANTEED_DELIVERY
;
info
->
iAddressFamily
=
WS_AF_IPX
;
info
->
iMaxSockAddr
=
0x10
;
info
->
iMinSockAddr
=
0x0e
;
info
->
iSocketType
=
5
;
info
->
dwMessageSize
=
-
1
;
strcpyW
(
info
->
szProtocol
,
NameSpxW
);
break
;
break
;
case
NSPROTO_SPXII
:
dwLength
=
(
unicode
)
?
sizeof
(
WCHAR
)
*
(
strlenW
(
NameSpxII
)
+
1
)
:
case
NSPROTO_SPXII
:
WideCharToMultiByte
(
CP_ACP
,
0
,
NameSpxII
,
-
1
,
info
->
dwServiceFlags1
=
XP1_PARTIAL_MESSAGE
|
XP1_GRACEFUL_CLOSE
|
NULL
,
0
,
NULL
,
NULL
);
XP1_PSEUDO_STREAM
|
XP1_MESSAGE_ORIENTED
|
XP1_GUARANTEED_ORDER
|
XP1_GUARANTEED_DELIVERY
;
info
->
iAddressFamily
=
WS_AF_IPX
;
info
->
iMaxSockAddr
=
0x10
;
info
->
iMinSockAddr
=
0x0e
;
info
->
iSocketType
=
5
;
info
->
dwMessageSize
=
-
1
;
strcpyW
(
info
->
szProtocol
,
NameSpxIIW
);
break
;
break
;
default:
default:
*
lpSize
=
0
;
if
((
protocol
==
ISOPROTO_TP4
)
||
(
protocol
==
NSPROTO_SPX
))
if
((
iProtocol
==
ISOPROTO_TP4
)
||
(
iProtocol
==
NSPROTO_SPX
))
FIXME
(
"Protocol <%s> not implemented
\n
"
,
FIXME
(
"Protocol <%s> not implemented
\n
"
,
(
iP
rotocol
==
ISOPROTO_TP4
)
?
"ISOPROTO_TP4"
:
"NSPROTO_SPX"
);
(
p
rotocol
==
ISOPROTO_TP4
)
?
"ISOPROTO_TP4"
:
"NSPROTO_SPX"
);
else
else
FIXME
(
"unknown Protocol <0x%08x>
\n
"
,
iP
rotocol
);
FIXME
(
"unknown Protocol <0x%08x>
\n
"
,
p
rotocol
);
break
;
return
SOCKET_ERROR
;
}
}
return
1
;
}
*
lpSize
+=
dwLength
;
/*****************************************************************************
* WINSOCK_EnterSingleProtocolA [internal]
if
(
!
lpBuffer
||
!*
lpSize
||
(
*
lpSize
>
dwOldSize
))
*
return
0
;
* see function WINSOCK_EnterSingleProtocolW
*
memset
(
lpBuffer
,
0
,
dwOldSize
);
*/
static
INT
WINSOCK_EnterSingleProtocolA
(
INT
protocol
,
WSAPROTOCOL_INFOA
*
info
)
lpBuffer
->
lpProtocol
=
(
LPSTR
)
&
lpBuffer
[
iAnz
];
{
lpBuffer
->
iProtocol
=
iProtocol
;
memset
(
info
,
0
,
sizeof
(
WSAPROTOCOL_INFOA
)
);
info
->
iProtocol
=
protocol
;
switch
(
iProtocol
)
{
switch
(
protocol
)
case
WS_IPPROTO_TCP
:
{
lpBuffer
->
dwServiceFlags
=
XP_FRAGMENTATION
|
XP_EXPEDITED_DATA
|
case
WS_IPPROTO_TCP
:
XP_GRACEFUL_CLOSE
|
XP_GUARANTEED_ORDER
|
info
->
dwServiceFlags1
=
XP1_IFS_HANDLES
|
XP1_EXPEDITED_DATA
|
XP_GUARANTEED_DELIVERY
;
XP1_GRACEFUL_CLOSE
|
XP1_GUARANTEED_ORDER
|
lpBuffer
->
iAddressFamily
=
WS_AF_INET
;
XP1_GUARANTEED_DELIVERY
;
lpBuffer
->
iMaxSockAddr
=
0x10
;
/* NT4 SP5 */
memcpy
(
&
info
->
ProviderId
,
&
ProviderId
,
sizeof
(
GUID
)
);
lpBuffer
->
iMinSockAddr
=
0x10
;
/* NT4 SP5 */
info
->
dwCatalogEntryId
=
0x3e9
;
lpBuffer
->
iSocketType
=
WS_SOCK_STREAM
;
info
->
ProtocolChain
.
ChainLen
=
1
;
lpBuffer
->
dwMessageSize
=
0
;
info
->
iVersion
=
2
;
lpProtName
=
NameTcp
;
info
->
iAddressFamily
=
WS_AF_INET
;
info
->
iMaxSockAddr
=
0x10
;
info
->
iMinSockAddr
=
0x10
;
info
->
iSocketType
=
WS_SOCK_STREAM
;
strcpy
(
info
->
szProtocol
,
NameTcp
);
break
;
break
;
case
WS_IPPROTO_UDP
:
lpBuffer
->
dwServiceFlags
=
XP_FRAGMENTATION
|
XP_SUPPORTS_BROADCAST
|
case
WS_IPPROTO_UDP
:
XP_SUPPORTS_MULTICAST
|
XP_MESSAGE_ORIENTED
|
info
->
dwServiceFlags1
=
XP1_IFS_HANDLES
|
XP1_SUPPORT_BROADCAST
|
XP_CONNECTIONLESS
;
XP1_SUPPORT_MULTIPOINT
|
XP1_MESSAGE_ORIENTED
|
lpBuffer
->
iAddressFamily
=
WS_AF_INET
;
XP1_CONNECTIONLESS
;
lpBuffer
->
iMaxSockAddr
=
0x10
;
/* NT4 SP5 */
memcpy
(
&
info
->
ProviderId
,
&
ProviderId
,
sizeof
(
GUID
)
);
lpBuffer
->
iMinSockAddr
=
0x10
;
/* NT4 SP5 */
info
->
dwCatalogEntryId
=
0x3ea
;
lpBuffer
->
iSocketType
=
WS_SOCK_DGRAM
;
info
->
ProtocolChain
.
ChainLen
=
1
;
lpBuffer
->
dwMessageSize
=
65457
;
/* NT4 SP5 */
info
->
iVersion
=
2
;
lpProtName
=
NameUdp
;
info
->
iAddressFamily
=
WS_AF_INET
;
info
->
iMaxSockAddr
=
0x10
;
info
->
iMinSockAddr
=
0x10
;
info
->
iSocketType
=
WS_SOCK_DGRAM
;
info
->
dwMessageSize
=
0xffbb
;
strcpy
(
info
->
szProtocol
,
NameUdp
);
break
;
break
;
case
NSPROTO_IPX
:
lpBuffer
->
dwServiceFlags
=
XP_FRAGMENTATION
|
XP_SUPPORTS_BROADCAST
|
case
NSPROTO_IPX
:
XP_SUPPORTS_MULTICAST
|
XP_MESSAGE_ORIENTED
|
info
->
dwServiceFlags1
=
XP1_PARTIAL_MESSAGE
|
XP1_SUPPORT_BROADCAST
|
XP_CONNECTIONLESS
;
XP1_SUPPORT_MULTIPOINT
|
XP1_MESSAGE_ORIENTED
|
lpBuffer
->
iAddressFamily
=
WS_AF_IPX
;
XP1_CONNECTIONLESS
;
lpBuffer
->
iMaxSockAddr
=
0x10
;
/* NT4 SP5 */
info
->
iAddressFamily
=
WS_AF_IPX
;
lpBuffer
->
iMinSockAddr
=
0x0e
;
/* NT4 SP5 */
info
->
iMaxSockAddr
=
0x10
;
lpBuffer
->
iSocketType
=
WS_SOCK_DGRAM
;
info
->
iMinSockAddr
=
0x0e
;
lpBuffer
->
dwMessageSize
=
576
;
/* NT4 SP5 */
info
->
iSocketType
=
WS_SOCK_DGRAM
;
lpProtName
=
NameIpx
;
info
->
dwMessageSize
=
576
;
strcpy
(
info
->
szProtocol
,
NameIpx
);
break
;
break
;
case
NSPROTO_SPX
:
lpBuffer
->
dwServiceFlags
=
XP_FRAGMENTATION
|
case
NSPROTO_SPX
:
XP_PSEUDO_STREAM
|
XP_MESSAGE_ORIENTED
|
info
->
dwServiceFlags1
=
XP1_PARTIAL_MESSAGE
|
XP_GUARANTEED_ORDER
|
XP_GUARANTEED_DELIVERY
;
XP1_PSEUDO_STREAM
|
XP1_MESSAGE_ORIENTED
|
lpBuffer
->
iAddressFamily
=
WS_AF_IPX
;
XP1_GUARANTEED_ORDER
|
XP1_GUARANTEED_DELIVERY
;
lpBuffer
->
iMaxSockAddr
=
0x10
;
/* NT4 SP5 */
info
->
iAddressFamily
=
WS_AF_IPX
;
lpBuffer
->
iMinSockAddr
=
0x0e
;
/* NT4 SP5 */
info
->
iMaxSockAddr
=
0x10
;
lpBuffer
->
iSocketType
=
5
;
info
->
iMinSockAddr
=
0x0e
;
lpBuffer
->
dwMessageSize
=
-
1
;
/* NT4 SP5 */
info
->
iSocketType
=
5
;
lpProtName
=
NameSpx
;
info
->
dwMessageSize
=
-
1
;
strcpy
(
info
->
szProtocol
,
NameSpx
);
break
;
break
;
case
NSPROTO_SPXII
:
lpBuffer
->
dwServiceFlags
=
XP_FRAGMENTATION
|
XP_GRACEFUL_CLOSE
|
case
NSPROTO_SPXII
:
XP_PSEUDO_STREAM
|
XP_MESSAGE_ORIENTED
|
info
->
dwServiceFlags1
=
XP1_PARTIAL_MESSAGE
|
XP1_GRACEFUL_CLOSE
|
XP_GUARANTEED_ORDER
|
XP_GUARANTEED_DELIVERY
;
XP1_PSEUDO_STREAM
|
XP1_MESSAGE_ORIENTED
|
lpBuffer
->
iAddressFamily
=
WS_AF_IPX
;
XP1_GUARANTEED_ORDER
|
XP1_GUARANTEED_DELIVERY
;
lpBuffer
->
iMaxSockAddr
=
0x10
;
/* NT4 SP5 */
info
->
iAddressFamily
=
WS_AF_IPX
;
lpBuffer
->
iMinSockAddr
=
0x0e
;
/* NT4 SP5 */
info
->
iMaxSockAddr
=
0x10
;
lpBuffer
->
iSocketType
=
5
;
info
->
iMinSockAddr
=
0x0e
;
lpBuffer
->
dwMessageSize
=
-
1
;
/* NT4 SP5 */
info
->
iSocketType
=
5
;
lpProtName
=
NameSpxII
;
info
->
dwMessageSize
=
-
1
;
strcpy
(
info
->
szProtocol
,
NameSpxII
);
break
;
break
;
}
if
(
unicode
)
default:
strcpyW
(
(
LPWSTR
)
lpBuffer
->
lpProtocol
,
lpProtName
);
if
((
protocol
==
ISOPROTO_TP4
)
||
(
protocol
==
NSPROTO_SPX
))
FIXME
(
"Protocol <%s> not implemented
\n
"
,
(
protocol
==
ISOPROTO_TP4
)
?
"ISOPROTO_TP4"
:
"NSPROTO_SPX"
);
else
else
WideCharToMultiByte
(
CP_ACP
,
0
,
lpProtName
,
-
1
,
lpBuffer
->
lpProtocol
,
FIXME
(
"unknown Protocol <0x%08x>
\n
"
,
protocol
);
dwOldSize
-
iAnz
*
sizeof
(
PROTOCOL_INFOA
),
NULL
,
NULL
);
return
SOCKET_ERROR
;
}
return
1
;
}
/*****************************************************************************
* WSAEnumProtocolsA [WS2_32.@]
*
* see function WSAEnumProtocolsW
*/
INT
WINAPI
WSAEnumProtocolsA
(
LPINT
protocols
,
LPWSAPROTOCOL_INFOA
buffer
,
LPDWORD
len
)
{
INT
i
=
0
;
DWORD
size
=
0
;
INT
local
[]
=
{
WS_IPPROTO_TCP
,
WS_IPPROTO_UDP
,
NSPROTO_IPX
,
NSPROTO_SPXII
,
0
};
if
(
!
buffer
)
return
SOCKET_ERROR
;
if
(
!
protocols
)
protocols
=
local
;
while
(
protocols
[
i
])
i
++
;
size
=
i
*
sizeof
(
WSAPROTOCOL_INFOA
);
return
iAnz
;
if
(
*
len
<
size
)
{
*
len
=
size
;
return
SOCKET_ERROR
;
}
for
(
i
=
0
;
protocols
[
i
];
i
++
)
{
if
(
WINSOCK_EnterSingleProtocolA
(
protocols
[
i
],
&
buffer
[
i
]
)
==
SOCKET_ERROR
)
return
i
;
}
return
i
;
}
}
/*****************************************************************************
/*****************************************************************************
* W
INSOCK_EnumProtocol [internal
]
* W
SAEnumProtocolsW [WS2_32.@
]
*
*
* Enters the information about installed protocols into a given buffer
* Retrieves information about specified set of active network protocols.
*
* PARAMS
* 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.
*
*
* RETURNS
* RETURNS
*
SOCKET_ERROR if the buffer is to small for the requested protocol infos
*
Success: number of WSAPROTOCOL_INFO structures in buffer.
*
on success the number of protocols inside the buffer
*
Failure: SOCKET_ERROR
*
*
* NOTE
* NOTE
S
* NT4SP5 does not return SPX if lpiProtocols == NULL
* NT4SP5 does not return SPX if lpiProtocols == NULL
*
*
* BUGS
* BUGS
* - NT4SP5 returns in addition these list of NETBIOS protocols
* - NT4SP5 returns in addition these list of NETBIOS protocols
* (address family 17), each entry two times one for socket type 2 and 5
* (address family 17), each entry two times one for socket type 2 and 5
*
*
*
iProtocol lp
Protocol
*
iProtocol sz
Protocol
* 0x80000000 \Device\NwlnkNb
* 0x80000000 \Device\NwlnkNb
* 0xfffffffa \Device\NetBT_CBENT7
* 0xfffffffa \Device\NetBT_CBENT7
* 0xfffffffb \Device\Nbf_CBENT7
* 0xfffffffb \Device\Nbf_CBENT7
...
@@ -217,76 +325,57 @@ static INT WINSOCK_EnterSingleProtocol( INT iProtocol, PROTOCOL_INFOA* lpBuffer,
...
@@ -217,76 +325,57 @@ static INT WINSOCK_EnterSingleProtocol( INT iProtocol, PROTOCOL_INFOA* lpBuffer,
* - there is no check that the operating system supports the returned
* - there is no check that the operating system supports the returned
* protocols
* protocols
*/
*/
static
INT
WINSOCK_EnumProtocol
(
LPINT
lpiProtocols
,
PROTOCOL_INFOA
*
lpBuffer
,
INT
WINAPI
WSAEnumProtocolsW
(
LPINT
protocols
,
LPWSAPROTOCOL_INFOW
buffer
,
LPDWORD
len
)
LPDWORD
lpdwLength
,
BOOL
unicode
)
{
{
DWORD
dwCurSize
,
dwOldSize
=
*
lpdwLength
,
dwTemp
;
INT
i
=
0
;
INT
anz
=
0
,
i
;
DWORD
size
=
0
;
INT
iLocal
[]
=
{
WS_IPPROTO_TCP
,
WS_IPPROTO_UDP
,
NSPROTO_IPX
,
NSPROTO_SPXII
,
0
};
INT
local
[]
=
{
WS_IPPROTO_TCP
,
WS_IPPROTO_UDP
,
NSPROTO_IPX
,
NSPROTO_SPXII
,
0
};
if
(
!
lpiProtocols
)
lpiProtocols
=
iLocal
;
if
(
!
buffer
)
return
SOCKET_ERROR
;
*
lpdwLength
=
0
;
if
(
!
protocols
)
protocols
=
local
;
while
(
*
lpiProtocols
)
{
dwCurSize
=
0
;
WINSOCK_EnterSingleProtocol
(
*
lpiProtocols
,
NULL
,
&
dwCurSize
,
unicode
);
if
(
lpBuffer
&&
dwCurSize
&&
((
*
lpdwLength
+
dwCurSize
)
<=
dwOldSize
))
while
(
protocols
[
i
])
i
++
;
{
/* reserve the required space for the current protocol_info after the
* last protocol_info before the start of the string buffer and adjust
* the references into the string buffer
*/
memmove
(
&
((
char
*
)
&
lpBuffer
[
anz
])[
dwCurSize
],
&
lpBuffer
[
anz
],
*
lpdwLength
-
anz
*
sizeof
(
PROTOCOL_INFOA
));
for
(
i
=
0
;
i
<
anz
;
i
++
)
lpBuffer
[
i
].
lpProtocol
+=
dwCurSize
;
dwTemp
=
dwCurSize
;
anz
+=
WINSOCK_EnterSingleProtocol
(
*
lpiProtocols
,
&
lpBuffer
[
anz
],
&
dwTemp
,
unicode
);
}
*
lpdwLength
+=
dwCurSize
;
size
=
i
*
sizeof
(
WSAPROTOCOL_INFOW
);
lpiProtocols
++
;
}
if
(
dwOldSize
<
*
lpdwLength
)
anz
=
SOCKET_ERROR
;
if
(
*
len
<
size
)
{
*
len
=
size
;
return
SOCKET_ERROR
;
}
return
anz
;
for
(
i
=
0
;
protocols
[
i
];
i
++
)
{
if
(
WINSOCK_EnterSingleProtocolW
(
protocols
[
i
],
&
buffer
[
i
]
)
==
SOCKET_ERROR
)
return
i
;
}
return
i
;
}
}
/*****************************************************************************
/*****************************************************************************
* WSAEnumProtocolsA [WSOCK32.1111]
* WSCEnumProtocols [WS2_32.@]
*
* Retrieves information about specified set of active network protocols.
*
*
* PARAMS
* PARAMS
* lpiProtocols [I] Pointer to null-terminated array of protocol id's. NULL retrieves
* protocols [I] Null-terminated array of iProtocol values.
* information on all available protocols.
* buffer [O] Buffer of WSAPROTOCOL_INFOW structures.
* lpProtocolBuffer [I] Pointer to a buffer to be filled with PROTOCOL_INFO structures.
* len [I/O] Size of buffer on input/output.
* lpdwBufferLength [I/O] Pointer to a variable specifying buffer size. On output the variable
* errno [O] Error code.
* holds the number of bytes needed when the specified size is too small.
*
*
* RETURNS
* RETURNS
*
Success: number of PROTOCOL_INFO structures in buffer
.
*
Success: number of protocols to be reported on
.
*
Failure: SOCKET_ERROR
*
Failure: SOCKET_ERROR. error is in errno.
*
*
* NOTES
* BUGS
* see function WINSOCK_EnumProtocol for BUGS
* Doesn't supply info on layered protocols.
*/
INT
WINAPI
WSAEnumProtocolsA
(
LPINT
lpiProtocols
,
LPWSAPROTOCOL_INFOA
lpBuffer
,
LPDWORD
lpdwLength
)
{
return
WINSOCK_EnumProtocol
(
lpiProtocols
,
(
PROTOCOL_INFOA
*
)
lpBuffer
,
lpdwLength
,
FALSE
);
}
/*****************************************************************************
* WSAEnumProtocolsW [WSOCK32.1112]
*
*
* see function WSAEnumProtocolsA
*/
*/
INT
WINAPI
WS
AEnumProtocolsW
(
LPINT
lpiProtocols
,
LPWSAPROTOCOL_INFOW
lpBuffer
,
LPDWORD
lpdwLength
)
INT
WINAPI
WS
CEnumProtocols
(
LPINT
protocols
,
LPWSAPROTOCOL_INFOW
buffer
,
LPDWORD
len
,
LPINT
errno
)
{
{
return
WINSOCK_EnumProtocol
(
lpiProtocols
,
(
PROTOCOL_INFOA
*
)
lpBuffer
,
lpdwLength
,
TRUE
);
INT
ret
=
WSAEnumProtocolsW
(
protocols
,
buffer
,
len
);
if
(
ret
==
SOCKET_ERROR
)
*
errno
=
WSAENOBUFS
;
return
ret
;
}
}
dlls/winsock/tests/.cvsignore
View file @
bec06ad7
Makefile
Makefile
protocol.ok
sock.ok
sock.ok
testlist.c
testlist.c
dlls/winsock/tests/Makefile.in
View file @
bec06ad7
...
@@ -6,6 +6,7 @@ TESTDLL = ws2_32.dll
...
@@ -6,6 +6,7 @@ TESTDLL = ws2_32.dll
IMPORTS
=
ws2_32
IMPORTS
=
ws2_32
CTESTS
=
\
CTESTS
=
\
protocol.c
\
sock.c
sock.c
@MAKE_TEST_RULES@
@MAKE_TEST_RULES@
...
...
dlls/winsock/tests/protocol.c
0 → 100644
View file @
bec06ad7
/*
* Unit test suite for protocol functions
*
* Copyright 2004 Hans Leidekker
*
* 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
*/
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winsock2.h>
#include "wine/test.h"
#include "wine/debug.h"
static
void
test_WSAEnumProtocolsA
()
{
INT
ret
;
DWORD
len
=
0
;
WSAPROTOCOL_INFOA
info
,
*
buffer
;
ret
=
WSAEnumProtocolsA
(
NULL
,
NULL
,
&
len
);
ok
(
ret
==
SOCKET_ERROR
,
"WSAEnumProtocolsA() succeeded unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
len
=
0
;
ret
=
WSAEnumProtocolsA
(
NULL
,
&
info
,
&
len
);
ok
(
ret
==
SOCKET_ERROR
,
"WSAEnumProtocolsA() succeeded unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
if
(
buffer
)
{
INT
i
;
ret
=
WSAEnumProtocolsA
(
NULL
,
buffer
,
&
len
);
ok
(
ret
!=
SOCKET_ERROR
,
"WSAEnumProtocolsA() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
for
(
i
=
0
;
i
<
ret
;
i
++
)
{
ok
(
strlen
(
buffer
[
i
].
szProtocol
),
"No protocol name found
\n
"
);
}
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
}
static
void
test_WSAEnumProtocolsW
()
{
INT
ret
;
DWORD
len
=
0
;
WSAPROTOCOL_INFOW
info
,
*
buffer
;
ret
=
WSAEnumProtocolsW
(
NULL
,
NULL
,
&
len
);
ok
(
ret
==
SOCKET_ERROR
,
"WSAEnumProtocolsW() succeeded unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
len
=
0
;
ret
=
WSAEnumProtocolsW
(
NULL
,
&
info
,
&
len
);
ok
(
ret
==
SOCKET_ERROR
,
"WSAEnumProtocolsW() succeeded unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
if
(
buffer
)
{
INT
i
;
ret
=
WSAEnumProtocolsW
(
NULL
,
buffer
,
&
len
);
ok
(
ret
!=
SOCKET_ERROR
,
"WSAEnumProtocolsW() failed unexpectedly: %d
\n
"
,
WSAGetLastError
()
);
for
(
i
=
0
;
i
<
ret
;
i
++
)
{
ok
(
lstrlenW
(
buffer
[
i
].
szProtocol
),
"No protocol name found
\n
"
);
}
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
}
START_TEST
(
protocol
)
{
WSADATA
data
;
WORD
version
=
MAKEWORD
(
2
,
2
);
if
(
WSAStartup
(
version
,
&
data
))
return
;
test_WSAEnumProtocolsA
();
test_WSAEnumProtocolsW
();
}
dlls/winsock/ws2_32.spec
View file @
bec06ad7
...
@@ -86,7 +86,7 @@
...
@@ -86,7 +86,7 @@
82 stdcall WSAWaitForMultipleEvents(long ptr long long long) kernel32.WaitForMultipleObjectsEx
82 stdcall WSAWaitForMultipleEvents(long ptr long long long) kernel32.WaitForMultipleObjectsEx
83 stdcall WSCDeinstallProvider(ptr ptr)
83 stdcall WSCDeinstallProvider(ptr ptr)
84 stub WSCEnableNSProvider
84 stub WSCEnableNSProvider
85 st
ub WSCEnumProtocols
85 st
dcall WSCEnumProtocols(ptr ptr ptr ptr)
86 stub WSCGetProviderPath
86 stub WSCGetProviderPath
87 stub WSCInstallNameSpace
87 stub WSCInstallNameSpace
88 stdcall WSCInstallProvider(ptr wstr ptr long ptr)
88 stdcall WSCInstallProvider(ptr wstr ptr long ptr)
...
...
include/winsock2.h
View file @
bec06ad7
...
@@ -176,6 +176,31 @@ typedef struct _WSAPROTOCOLCHAIN
...
@@ -176,6 +176,31 @@ typedef struct _WSAPROTOCOLCHAIN
DWORD
ChainEntries
[
MAX_PROTOCOL_CHAIN
];
/* a list of dwCatalogEntryIds */
DWORD
ChainEntries
[
MAX_PROTOCOL_CHAIN
];
/* a list of dwCatalogEntryIds */
}
WSAPROTOCOLCHAIN
,
*
LPWSAPROTOCOLCHAIN
;
}
WSAPROTOCOLCHAIN
,
*
LPWSAPROTOCOLCHAIN
;
#define XP1_CONNECTIONLESS 0x00000001
#define XP1_GUARANTEED_DELIVERY 0x00000002
#define XP1_GUARANTEED_ORDER 0x00000004
#define XP1_MESSAGE_ORIENTED 0x00000008
#define XP1_PSEUDO_STREAM 0x00000010
#define XP1_GRACEFUL_CLOSE 0x00000020
#define XP1_EXPEDITED_DATA 0x00000040
#define XP1_CONNECT_DATA 0x00000080
#define XP1_DISCONNECT_DATA 0x00000100
#define XP1_SUPPORT_BROADCAST 0x00000200
#define XP1_SUPPORT_MULTIPOINT 0x00000400
#define XP1_MULTIPOINT_CONTROL_PLANE 0x00000800
#define XP1_MULTIPOINT_DATA_PLANE 0x00001000
#define XP1_QOS_SUPPORTED 0x00002000
#define XP1_INTERRUPT 0x00004000
#define XP1_UNI_SEND 0x00008000
#define XP1_UNI_RECV 0x00010000
#define XP1_IFS_HANDLES 0x00020000
#define XP1_PARTIAL_MESSAGE 0x00040000
#define BIGENDIAN 0x0000
#define LITTLEENDIAN 0x0001
#define SECURITY_PROTOCOL_NONE 0x0000
#define WSAPROTOCOL_LEN 255
#define WSAPROTOCOL_LEN 255
typedef
struct
_WSAPROTOCOL_INFOA
typedef
struct
_WSAPROTOCOL_INFOA
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment