ReactOS  0.4.13-dev-551-gf37fb1f
ioctl.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_new/src/ioctl.c
5  * PURPOSE: Socket I/O Control Code support.
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  */
21 INT
22 WSAAPI
24  IN LONG cmd,
25  IN OUT ULONG FAR* argp)
26 {
27  DWORD Dummy;
28 
29  /* Let WSA do it */
30  return WSAIoctl(s,
31  cmd,
32  argp,
33  sizeof(ULONG),
34  argp,
35  sizeof(ULONG),
36  &Dummy,
37  NULL,
38  NULL);
39 }
40 
41 /*
42  * @implemented
43  */
44 INT
45 WSAAPI
48  IN LPVOID lpvInBuffer,
49  IN DWORD cbInBuffer,
50  OUT LPVOID lpvOutBuffer,
51  IN DWORD cbOutBuffer,
52  OUT LPDWORD lpcbBytesReturned,
54  IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
55 {
56  PWSSOCKET Socket;
57  INT Status;
58  INT ErrorCode;
59  LPWSATHREADID ThreadId;
60  DPRINT("WSAIoctl: %lx, %lx\n", s, dwIoControlCode);
61 
62  /* Check for WSAStartup */
63  if ((ErrorCode = WsQuickPrologTid(&ThreadId)) == ERROR_SUCCESS)
64  {
65  /* Get the Socket Context */
66  if ((Socket = WsSockGetSocket(s)))
67  {
68  /* Make the call */
69  Status = Socket->Provider->Service.lpWSPIoctl(s,
71  lpvInBuffer,
72  cbInBuffer,
73  lpvOutBuffer,
74  cbOutBuffer,
75  lpcbBytesReturned,
77  lpCompletionRoutine,
78  ThreadId,
79  &ErrorCode);
80 
81  /* Deference the Socket Context */
82  WsSockDereference(Socket);
83 
84  /* Return Provider Value */
85  if (Status == ERROR_SUCCESS) return Status;
86  }
87  else
88  {
89  /* No Socket Context Found */
91  }
92  }
93 
94  /* Return with an Error */
96  return SOCKET_ERROR;
97 }
#define WSAENOTSOCK
Definition: winerror.h:1951
#define SOCKET_ERROR
Definition: winsock.h:333
#define IN
Definition: typedefs.h:38
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
#define ERROR_SUCCESS
Definition: deptool.c:10
Definition: ftp_var.h:139
INT WSAAPI WSAIoctl(IN SOCKET s, IN DWORD dwIoControlCode, IN LPVOID lpvInBuffer, IN DWORD cbInBuffer, OUT LPVOID lpvOutBuffer, IN DWORD cbOutBuffer, OUT LPDWORD lpcbBytesReturned, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
Definition: ioctl.c:46
PWSSOCKET WSAAPI WsSockGetSocket(IN SOCKET Handle)
Definition: dsocket.c:140
int32_t INT
Definition: typedefs.h:56
WSPPROC_TABLE Service
Definition: ws2_32p.h:80
VOID WSAAPI WsSockDereference(IN PWSSOCKET Socket)
Definition: dsocket.c:205
LPWSPIOCTL lpWSPIoctl
Definition: ws2spi.h:477
long LONG
Definition: pedump.c:60
#define FAR
Definition: guiddef.h:36
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
FORCEINLINE DWORD WsQuickPrologTid(LPWSATHREADID *Tid)
Definition: ws2_32p.h:900
PTPROVIDER Provider
Definition: ws2_32p.h:199
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
GLdouble s
Definition: gl.h:2039
Status
Definition: gdiplustypes.h:24
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:90
INT WSAAPI ioctlsocket(IN SOCKET s, IN LONG cmd, IN OUT ULONG FAR *argp)
Definition: ioctl.c:23
#define WSAAPI
Definition: winsock2.h:584
#define OUT
Definition: typedefs.h:39
void(CALLBACK * LPWSAOVERLAPPED_COMPLETION_ROUTINE)(IN DWORD dwError, IN DWORD cbTransferred, IN LPWSAOVERLAPPED lpOverlapped, IN DWORD dwFlags)
Definition: winsock2.h:722
uint32_t * LPDWORD
Definition: typedefs.h:57
unsigned int ULONG
Definition: retypes.h:1
UINT_PTR SOCKET
Definition: winsock.h:47
_In_ DWORD dwIoControlCode
Definition: winddi.h:1700