ReactOS 0.4.15-dev-7924-g5949c20
dupsock.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 API
4 * FILE: dll/win32/ws2_32/src/dupsock.c
5 * PURPOSE: Socket Duplication
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include <ws2_32.h>
12
13#define NDEBUG
14#include <debug.h>
15
16/* FUNCTIONS *****************************************************************/
17
18/*
19 * @implemented
20 */
21INT
24 IN DWORD dwProcessId,
25 OUT LPWSAPROTOCOL_INFOA lpProtocolInfo)
26{
27 WSAPROTOCOL_INFOW ProtocolInfoW;
29 DPRINT("WSADuplicateSocketA: %lx, %lx, %p\n", s, dwProcessId, lpProtocolInfo);
30
31 /* Call the Unicode Function */
32 ErrorCode = WSADuplicateSocketW(s, dwProcessId, &ProtocolInfoW);
33
34 /* Check for success */
36 {
37 /* Convert Protocol Info to Ansi */
38 if (lpProtocolInfo)
39 {
40 /* Convert the information to ANSI */
42 lpProtocolInfo);
43 }
44 else
45 {
46 /* Fail */
48 }
49
50 /* Check if the conversion failed */
52 {
53 /* Set the last error and normalize the error */
56 }
57 }
58
59 /* Return */
60 return ErrorCode;
61}
62
63/*
64 * @implemented
65 */
66INT
69 IN DWORD dwProcessId,
70 OUT LPWSAPROTOCOL_INFOW lpProtocolInfo)
71{
72 PWSSOCKET Socket;
73 INT Status;
75 DPRINT("WSADuplicateSocketW: %lx, %lx, %p\n", s, dwProcessId, lpProtocolInfo);
76
77 /* Check for WSAStartup */
79 {
80 /* Get the Socket Context */
81 if ((Socket = WsSockGetSocket(s)))
82 {
83 /* Make the call */
85 dwProcessId,
86 lpProtocolInfo,
87 &ErrorCode);
88 /* Deference the Socket Context */
89 WsSockDereference(Socket);
90
91 /* Return Provider Value */
92 if (Status == ERROR_SUCCESS) return Status;
93
94 /* If everything seemed fine, then the WSP call failed itself */
96 }
97 else
98 {
99 /* No Socket Context Found */
101 }
102 }
103
104 /* Return with an Error */
106 return SOCKET_ERROR;
107}
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SetLastError(x)
Definition: compat.h:752
INT WSAAPI WSADuplicateSocketA(IN SOCKET s, IN DWORD dwProcessId, OUT LPWSAPROTOCOL_INFOA lpProtocolInfo)
Definition: dupsock.c:23
INT WSAAPI WSADuplicateSocketW(IN SOCKET s, IN DWORD dwProcessId, OUT LPWSAPROTOCOL_INFOW lpProtocolInfo)
Definition: dupsock.c:68
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
GLdouble s
Definition: gl.h:2039
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define DPRINT
Definition: sndvol32.h:71
WSPPROC_TABLE Service
Definition: ws2_32p.h:80
LPWSPDUPLICATESOCKET lpWSPDuplicateSocket
Definition: ws2spi.h:469
PTPROVIDER Provider
Definition: ws2_32p.h:199
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
#define WSASYSCALLFAILURE
Definition: winerror.h:1994
#define WSAENOTSOCK
Definition: winerror.h:1951
#define WSAEFAULT
Definition: winerror.h:1945
#define WSAAPI
Definition: winsock2.h:605
UINT_PTR SOCKET
Definition: winsock.h:47
#define SOCKET_ERROR
Definition: winsock.h:333
FORCEINLINE DWORD WsQuickProlog(VOID)
Definition: ws2_32p.h:892
VOID WSAAPI WsSockDereference(IN PWSSOCKET Socket)
Definition: dsocket.c:205
INT WSAAPI MapUnicodeProtocolInfoToAnsi(IN LPWSAPROTOCOL_INFOW UnicodeInfo, OUT LPWSAPROTOCOL_INFOA AnsiInfo)
Definition: wsautil.c:224
PWSSOCKET WSAAPI WsSockGetSocket(IN SOCKET Handle)
Definition: dsocket.c:140