ReactOS  0.4.13-dev-1158-g658d5a3
wshtcpip.c File Reference
#include "wshtcpip.h"
#include <debug.h>
Include dependency graph for wshtcpip.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOL EXPORT DllMain (HANDLE hInstDll, ULONG dwReason, PVOID Reserved)
 
INT EXPORT WSHAddressToString (IN LPSOCKADDR Address, IN INT AddressLength, IN LPWSAPROTOCOL_INFOW ProtocolInfo OPTIONAL, OUT LPWSTR AddressString, IN OUT LPDWORD AddressStringLength)
 
INT EXPORT WSHEnumProtocols (IN LPINT lpiProtocols OPTIONAL, IN LPWSTR lpTransportKeyName, IN OUT LPVOID lpProtocolBuffer, IN OUT LPDWORD lpdwBufferLength)
 
INT EXPORT WSHGetBroadcastSockaddr (IN PVOID HelperDllSocketContext, OUT PSOCKADDR Sockaddr, OUT PINT SockaddrLength)
 
INT EXPORT WSHGetProviderGuid (IN LPWSTR ProviderName, OUT LPGUID ProviderGuid)
 
INT EXPORT WSHGetSockaddrType (IN PSOCKADDR Sockaddr, IN DWORD SockaddrLength, OUT PSOCKADDR_INFO SockaddrInfo)
 
static void GetTdiTypeId (_In_ INT Level, _In_ INT OptionName, _Out_ PULONG TdiType, _Out_ PULONG TdiId)
 
INT EXPORT WSHGetSocketInformation (IN PVOID HelperDllSocketContext, IN SOCKET SocketHandle, IN HANDLE TdiAddressObjectHandle, IN HANDLE TdiConnectionObjectHandle, IN INT Level, IN INT OptionName, OUT PCHAR OptionValue, OUT LPINT OptionLength)
 
INT EXPORT WSHGetWildcardSockaddr (IN PVOID HelperDllSocketContext, OUT PSOCKADDR Sockaddr, OUT PINT SockaddrLength)
 
DWORD EXPORT WSHGetWinsockMapping (OUT PWINSOCK_MAPPING Mapping, IN DWORD MappingLength)
 
INT EXPORT WSHGetWSAProtocolInfo (IN LPWSTR ProviderName, OUT LPWSAPROTOCOL_INFOW *ProtocolInfo, OUT LPDWORD ProtocolInfoEntries)
 
INT EXPORT WSHIoctl (IN PVOID HelperDllSocketContext, IN SOCKET SocketHandle, IN HANDLE TdiAddressObjectHandle, IN HANDLE TdiConnectionObjectHandle, IN DWORD IoControlCode, IN LPVOID InputBuffer, IN DWORD InputBufferLength, IN LPVOID OutputBuffer, IN DWORD OutputBufferLength, OUT LPDWORD NumberOfBytesReturned, IN LPWSAOVERLAPPED Overlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine, OUT LPBOOL NeedsCompletion)
 
INT EXPORT WSHJoinLeaf (IN PVOID HelperDllSocketContext, IN SOCKET SocketHandle, IN HANDLE TdiAddressObjectHandle, IN HANDLE TdiConnectionObjectHandle, IN PVOID LeafHelperDllSocketContext, IN SOCKET LeafSocketHandle, IN PSOCKADDR Sockaddr, IN DWORD SockaddrLength, IN LPWSABUF CallerData, IN LPWSABUF CalleeData, IN LPQOS SocketQOS, IN LPQOS GroupQOS, IN DWORD Flags)
 
INT SendRequest (IN PVOID Request, IN DWORD RequestSize, IN DWORD IOCTL)
 
INT EXPORT WSHNotify (IN PVOID HelperDllSocketContext, IN SOCKET SocketHandle, IN HANDLE TdiAddressObjectHandle, IN HANDLE TdiConnectionObjectHandle, IN DWORD NotifyEvent)
 
INT EXPORT WSHOpenSocket (IN OUT PINT AddressFamily, IN OUT PINT SocketType, IN OUT PINT Protocol, OUT PUNICODE_STRING TransportDeviceName, OUT PVOID HelperDllSocketContext, OUT PDWORD NotificationEvents)
 
INT EXPORT WSHOpenSocket2 (OUT PINT AddressFamily, IN OUT PINT SocketType, IN OUT PINT Protocol, IN GROUP Group, IN DWORD Flags, OUT PUNICODE_STRING TransportDeviceName, OUT PVOID *HelperDllSocketContext, OUT PDWORD NotificationEvents)
 
INT EXPORT WSHSetSocketInformation (IN PVOID HelperDllSocketContext, IN SOCKET SocketHandle, IN HANDLE TdiAddressObjectHandle, IN HANDLE TdiConnectionObjectHandle, IN INT Level, IN INT OptionName, IN PCHAR OptionValue, IN INT OptionLength)
 
INT EXPORT WSHStringToAddress (IN LPWSTR AddressString, IN DWORD AddressFamily, IN LPWSAPROTOCOL_INFOW ProtocolInfo OPTIONAL, OUT LPSOCKADDR Address, IN OUT LPDWORD AddressStringLength)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file wshtcpip.c.

Function Documentation

◆ DllMain()

BOOL EXPORT DllMain ( HANDLE  hInstDll,
ULONG  dwReason,
PVOID  Reserved 
)

Definition at line 16 of file wshtcpip.c.

19 {
20  DPRINT("DllMain of wshtcpip.dll\n");
21 
22  switch (dwReason) {
23  case DLL_PROCESS_ATTACH:
24  /* Don't need thread attach notifications
25  so disable them to improve performance */
26  DisableThreadLibraryCalls(hInstDll);
27  break;
28 
29  case DLL_THREAD_ATTACH:
30  break;
31 
32  case DLL_THREAD_DETACH:
33  break;
34 
35  case DLL_PROCESS_DETACH:
36  break;
37  }
38  return TRUE;
39 }
#define TRUE
Definition: types.h:120
#define DLL_THREAD_ATTACH
Definition: compat.h:121
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
#define DLL_THREAD_DETACH
Definition: compat.h:122
DWORD dwReason
Definition: misc.cpp:154
void DPRINT(...)
Definition: polytest.cpp:61
#define DLL_PROCESS_DETACH
Definition: compat.h:119

◆ GetTdiTypeId()

static void GetTdiTypeId ( _In_ INT  Level,
_In_ INT  OptionName,
_Out_ PULONG  TdiType,
_Out_ PULONG  TdiId 
)
static

Definition at line 161 of file wshtcpip.c.

166 {
167  switch (Level)
168  {
169  case SOL_SOCKET:
170  *TdiType = INFO_TYPE_ADDRESS_OBJECT;
171  switch (OptionName)
172  {
173  case SO_KEEPALIVE:
174  /* FIXME: Return proper option */
175  ASSERT(FALSE);
176  break;
177  default:
178  break;
179  }
180  break;
181 
182  case IPPROTO_IP:
183  *TdiType = INFO_TYPE_ADDRESS_OBJECT;
184  switch (OptionName)
185  {
186  case IP_TTL:
187  *TdiId = AO_OPTION_TTL;
188  return;
189 
190  case IP_DONTFRAGMENT:
191  *TdiId = AO_OPTION_IP_DONTFRAGMENT;
192  return;
193 
194 #if 0
196  *TdiId = AO_OPTION_BROADCAST;
197  return;
198 #endif
199 
200  case IP_HDRINCL:
201  *TdiId = AO_OPTION_IP_HDRINCL;
202  return;
203 
204  default:
205  break;
206  }
207  break;
208 
209  case IPPROTO_TCP:
210  *TdiType = INFO_TYPE_CONNECTION;
211  switch (OptionName)
212  {
213  case TCP_NODELAY:
214  *TdiId = TCP_SOCKET_NODELAY;
215  return;
216  default:
217  break;
218  }
219 
220  default:
221  break;
222  }
223 
224  DPRINT1("Unknown level/option name: %d %d\n", Level, OptionName);
225  *TdiType = 0;
226  *TdiId = 0;
227 }
#define IP_RECEIVE_BROADCAST
Definition: ws2ipdef.h:43
#define AO_OPTION_TTL
Definition: tcpioctl.h:61
#define SO_KEEPALIVE
Definition: winsock.h:181
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
#define SOL_SOCKET
Definition: winsock.h:398
#define AO_OPTION_BROADCAST
Definition: tcpioctl.h:71
#define INFO_TYPE_CONNECTION
Definition: tdiinfo.h:71
#define TCP_NODELAY
Definition: tcpdef.h:117
#define IP_HDRINCL
Definition: ws2ipdef.h:28
#define AO_OPTION_IP_HDRINCL
Definition: tcpioctl.h:72
#define IPPROTO_IP
Definition: winsock.h:255
#define IP_DONTFRAGMENT
Definition: winsock.h:326
#define TCP_SOCKET_NODELAY
Definition: tcpioctl.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define INFO_TYPE_ADDRESS_OBJECT
Definition: tdiinfo.h:70
#define AO_OPTION_IP_DONTFRAGMENT
Definition: tcpioctl.h:69
#define DPRINT1
Definition: precomp.h:8
#define IP_TTL
Definition: winsock.h:324

Referenced by WSHSetSocketInformation().

◆ SendRequest()

INT SendRequest ( IN PVOID  Request,
IN DWORD  RequestSize,
IN DWORD  IOCTL 
)

Definition at line 397 of file wshtcpip.c.

401 {
403  HANDLE TcpCC;
405 
407  return WSAEINVAL;
408 
409  Success = DeviceIoControl(TcpCC,
410  IOCTL,
411  Request,
412  RequestSize,
413  NULL,
414  0,
415  &BytesReturned,
416  NULL);
417 
418  closeTcpFile(TcpCC);
419 
420  DPRINT("DeviceIoControl: %ld\n", ((Success != FALSE) ? 0 : GetLastError()));
421 
422  if (!Success)
423  return WSAEINVAL;
424 
425  return NO_ERROR;
426 }
#define WSAEINVAL
Definition: winerror.h:1946
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define NO_ERROR
Definition: dderror.h:5
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
#define FILE_READ_DATA
Definition: nt_native.h:628
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define FILE_WRITE_DATA
Definition: nt_native.h:631
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
_In_ FILTER_INFORMATION_CLASS _In_ ULONG _Out_ PULONG BytesReturned
Definition: fltkernel.h:1716
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by WSHNotify(), and WSHSetSocketInformation().

◆ WSHAddressToString()

INT EXPORT WSHAddressToString ( IN LPSOCKADDR  Address,
IN INT  AddressLength,
IN LPWSAPROTOCOL_INFOW ProtocolInfo  OPTIONAL,
OUT LPWSTR  AddressString,
IN OUT LPDWORD  AddressStringLength 
)

Definition at line 44 of file wshtcpip.c.

50 {
52 
53  return NO_ERROR;
54 }
#define NO_ERROR
Definition: dderror.h:5
#define UNIMPLEMENTED
Definition: debug.h:114

◆ WSHEnumProtocols()

INT EXPORT WSHEnumProtocols ( IN LPINT lpiProtocols  OPTIONAL,
IN LPWSTR  lpTransportKeyName,
IN OUT LPVOID  lpProtocolBuffer,
IN OUT LPDWORD  lpdwBufferLength 
)

Definition at line 59 of file wshtcpip.c.

64 {
66 
67  return NO_ERROR;
68 }
#define NO_ERROR
Definition: dderror.h:5
#define UNIMPLEMENTED
Definition: debug.h:114

◆ WSHGetBroadcastSockaddr()

INT EXPORT WSHGetBroadcastSockaddr ( IN PVOID  HelperDllSocketContext,
OUT PSOCKADDR  Sockaddr,
OUT PINT  SockaddrLength 
)

Definition at line 73 of file wshtcpip.c.

77 {
78  INT Size = 2 * sizeof(UINT);
79 
80  if (*SockaddrLength < Size)
81  {
82  DPRINT1("Socket address length too small: %d\n", *SockaddrLength);
83  return WSAEFAULT;
84  }
85 
86  RtlZeroMemory(Sockaddr, *SockaddrLength);
87 
88  Sockaddr->sa_family = AF_INET;
89  *((PUINT)Sockaddr->sa_data) = INADDR_BROADCAST;
90 
91  /* *SockaddrLength = Size; */
92 
93  return NO_ERROR;
94 }
#define INADDR_BROADCAST
Definition: winsock.h:313
#define WSAEFAULT
Definition: winerror.h:1945
#define NO_ERROR
Definition: dderror.h:5
int32_t INT
Definition: typedefs.h:56
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8
#define AF_INET
Definition: tcpip.h:117
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
unsigned int * PUINT
Definition: ndis.h:50

◆ WSHGetProviderGuid()

INT EXPORT WSHGetProviderGuid ( IN LPWSTR  ProviderName,
OUT LPGUID  ProviderGuid 
)

Definition at line 99 of file wshtcpip.c.

102 {
104 
105  return NO_ERROR;
106 }
#define NO_ERROR
Definition: dderror.h:5
#define UNIMPLEMENTED
Definition: debug.h:114

◆ WSHGetSockaddrType()

INT EXPORT WSHGetSockaddrType ( IN PSOCKADDR  Sockaddr,
IN DWORD  SockaddrLength,
OUT PSOCKADDR_INFO  SockaddrInfo 
)

Definition at line 116 of file wshtcpip.c.

120 {
121  PSOCKADDR_IN ipv4 = (PSOCKADDR_IN)Sockaddr;
122 
123  if (!ipv4 || !SockaddrInfo || SockaddrLength < sizeof(SOCKADDR_IN) ||
124  ipv4->sin_family != AF_INET)
125  {
126  DPRINT1("Invalid parameter: %x %x %d %u\n", ipv4, SockaddrInfo, SockaddrLength, (ipv4 ? ipv4->sin_family : 0));
127  return WSAEINVAL;
128  }
129 
130  switch (ntohl(ipv4->sin_addr.s_addr))
131  {
132  case INADDR_ANY:
133  SockaddrInfo->AddressInfo = SockaddrAddressInfoWildcard;
134  break;
135 
136  case INADDR_BROADCAST:
137  SockaddrInfo->AddressInfo = SockaddrAddressInfoBroadcast;
138  break;
139 
140  case INADDR_LOOPBACK:
141  SockaddrInfo->AddressInfo = SockaddrAddressInfoLoopback;
142  break;
143 
144  default:
145  SockaddrInfo->AddressInfo = SockaddrAddressInfoNormal;
146  break;
147  }
148 
149  if (ntohs(ipv4->sin_port) == 0)
150  SockaddrInfo->EndpointInfo = SockaddrEndpointInfoWildcard;
151  else if (ntohs(ipv4->sin_port) < IPPORT_RESERVED)
152  SockaddrInfo->EndpointInfo = SockaddrEndpointInfoReserved;
153  else
154  SockaddrInfo->EndpointInfo = SockaddrEndpointInfoNormal;
155 
156  return NO_ERROR;
157 }
#define INADDR_BROADCAST
Definition: winsock.h:313
u_short sin_port
Definition: winsock.h:511
#define WSAEINVAL
Definition: winerror.h:1946
#define INADDR_ANY
Definition: StrAddr.c:4
#define NO_ERROR
Definition: dderror.h:5
#define ntohs(x)
Definition: module.h:208
#define IPPORT_RESERVED
Definition: winsock.h:290
struct in_addr sin_addr
Definition: winsock.h:512
struct sockaddr_in * PSOCKADDR_IN
Definition: winsock.h:488
#define DPRINT1
Definition: precomp.h:8
#define AF_INET
Definition: tcpip.h:117
#define INADDR_LOOPBACK
Definition: winsock.h:312
short sin_family
Definition: winsock.h:510
#define ntohl(x)
Definition: module.h:203

◆ WSHGetSocketInformation()

INT EXPORT WSHGetSocketInformation ( IN PVOID  HelperDllSocketContext,
IN SOCKET  SocketHandle,
IN HANDLE  TdiAddressObjectHandle,
IN HANDLE  TdiConnectionObjectHandle,
IN INT  Level,
IN INT  OptionName,
OUT PCHAR  OptionValue,
OUT LPINT  OptionLength 
)

Definition at line 231 of file wshtcpip.c.

240 {
242 
243  DPRINT1("Get: Unknown level/option name: %d %d\n", Level, OptionName);
244 
245  *OptionLength = 0;
246 
247  return NO_ERROR;
248 }
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
#define NO_ERROR
Definition: dderror.h:5
#define DPRINT1
Definition: precomp.h:8
#define UNIMPLEMENTED
Definition: debug.h:114

◆ WSHGetWildcardSockaddr()

INT EXPORT WSHGetWildcardSockaddr ( IN PVOID  HelperDllSocketContext,
OUT PSOCKADDR  Sockaddr,
OUT PINT  SockaddrLength 
)

Definition at line 253 of file wshtcpip.c.

257 {
258  INT Size = 2 * sizeof(UINT);
259 
260  if (*SockaddrLength < Size)
261  {
262  DPRINT1("Socket address length too small: %d\n", *SockaddrLength);
263  return WSAEFAULT;
264  }
265 
266  RtlZeroMemory(Sockaddr, *SockaddrLength);
267 
268  Sockaddr->sa_family = AF_INET;
269  *((PUINT)Sockaddr->sa_data) = INADDR_ANY;
270 
271  /* *SockaddrLength = Size; */
272 
273  return NO_ERROR;
274 }
#define WSAEFAULT
Definition: winerror.h:1945
#define INADDR_ANY
Definition: StrAddr.c:4
#define NO_ERROR
Definition: dderror.h:5
int32_t INT
Definition: typedefs.h:56
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8
#define AF_INET
Definition: tcpip.h:117
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
unsigned int * PUINT
Definition: ndis.h:50

◆ WSHGetWinsockMapping()

DWORD EXPORT WSHGetWinsockMapping ( OUT PWINSOCK_MAPPING  Mapping,
IN DWORD  MappingLength 
)

Definition at line 279 of file wshtcpip.c.

282 {
283  DWORD Rows = 6;
284  DWORD Columns = 3;
285  DWORD Size = 2 * sizeof(DWORD) + Columns * Rows * sizeof(DWORD);
286 
287  if (MappingLength < Size)
288  {
289  DPRINT1("Mapping length too small: %d\n", MappingLength);
290  return Size;
291  }
292 
293  Mapping->Rows = Rows;
294  Mapping->Columns = Columns;
295 
296  Mapping->Mapping[0].AddressFamily = AF_INET;
297  Mapping->Mapping[0].SocketType = SOCK_STREAM;
298  Mapping->Mapping[0].Protocol = 0;
299 
300  Mapping->Mapping[1].AddressFamily = AF_INET;
301  Mapping->Mapping[1].SocketType = SOCK_STREAM;
302  Mapping->Mapping[1].Protocol = IPPROTO_TCP;
303 
304  Mapping->Mapping[2].AddressFamily = AF_INET;
305  Mapping->Mapping[2].SocketType = SOCK_DGRAM;
306  Mapping->Mapping[2].Protocol = 0;
307 
308  Mapping->Mapping[3].AddressFamily = AF_INET;
309  Mapping->Mapping[3].SocketType = SOCK_DGRAM;
310  Mapping->Mapping[3].Protocol = IPPROTO_UDP;
311 
312  Mapping->Mapping[4].AddressFamily = AF_INET;
313  Mapping->Mapping[4].SocketType = SOCK_RAW;
314  Mapping->Mapping[4].Protocol = 0;
315 
316  Mapping->Mapping[5].AddressFamily = AF_INET;
317  Mapping->Mapping[5].SocketType = SOCK_RAW;
318  Mapping->Mapping[5].Protocol = IPPROTO_ICMP;
319 
320  return NO_ERROR;
321 }
static PVOID Mapping[EMS_PHYSICAL_PAGES]
Definition: emsdrv.c:41
#define NO_ERROR
Definition: dderror.h:5
#define DWORD
Definition: nt_native.h:44
#define SOCK_RAW
Definition: winsock.h:337
_In_ ULONG Rows
Definition: haltypes.h:7
unsigned long DWORD
Definition: ntddk_ex.h:95
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
static const COLUMN_LIST Columns[]
Definition: listview.c:19
#define DPRINT1
Definition: precomp.h:8
#define AF_INET
Definition: tcpip.h:117
#define SOCK_STREAM
Definition: tcpip.h:118
#define SOCK_DGRAM
Definition: winsock.h:336

◆ WSHGetWSAProtocolInfo()

INT EXPORT WSHGetWSAProtocolInfo ( IN LPWSTR  ProviderName,
OUT LPWSAPROTOCOL_INFOW ProtocolInfo,
OUT LPDWORD  ProtocolInfoEntries 
)

Definition at line 326 of file wshtcpip.c.

330 {
332 
333  return NO_ERROR;
334 }
#define NO_ERROR
Definition: dderror.h:5
#define UNIMPLEMENTED
Definition: debug.h:114

◆ WSHIoctl()

INT EXPORT WSHIoctl ( IN PVOID  HelperDllSocketContext,
IN SOCKET  SocketHandle,
IN HANDLE  TdiAddressObjectHandle,
IN HANDLE  TdiConnectionObjectHandle,
IN DWORD  IoControlCode,
IN LPVOID  InputBuffer,
IN DWORD  InputBufferLength,
IN LPVOID  OutputBuffer,
IN DWORD  OutputBufferLength,
OUT LPDWORD  NumberOfBytesReturned,
IN LPWSAOVERLAPPED  Overlapped,
IN LPWSAOVERLAPPED_COMPLETION_ROUTINE  CompletionRoutine,
OUT LPBOOL  NeedsCompletion 
)

Definition at line 339 of file wshtcpip.c.

353 {
354  INT res;
355 
357  {
359  OutputBuffer,
361  NumberOfBytesReturned,
362  NeedsCompletion);
363  return res;
364  }
365 
367 
368  DPRINT1("Ioctl: Unknown IOCTL code: %d\n", IoControlCode);
369 
370  return WSAEINVAL;
371 }
INT WSHIoctl_GetInterfaceList(IN LPVOID OutputBuffer, IN DWORD OutputBufferLength, OUT LPDWORD NumberOfBytesReturned, OUT LPBOOL NeedsCompletion)
Definition: iflist.c:216
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
#define WSAEINVAL
Definition: winerror.h:1946
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
int32_t INT
Definition: typedefs.h:56
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
#define DPRINT1
Definition: precomp.h:8
GLuint res
Definition: glext.h:9613
#define UNIMPLEMENTED
Definition: debug.h:114
#define SIO_GET_INTERFACE_LIST
Definition: ws2ipdef.h:62

◆ WSHJoinLeaf()

INT EXPORT WSHJoinLeaf ( IN PVOID  HelperDllSocketContext,
IN SOCKET  SocketHandle,
IN HANDLE  TdiAddressObjectHandle,
IN HANDLE  TdiConnectionObjectHandle,
IN PVOID  LeafHelperDllSocketContext,
IN SOCKET  LeafSocketHandle,
IN PSOCKADDR  Sockaddr,
IN DWORD  SockaddrLength,
IN LPWSABUF  CallerData,
IN LPWSABUF  CalleeData,
IN LPQOS  SocketQOS,
IN LPQOS  GroupQOS,
IN DWORD  Flags 
)

Definition at line 376 of file wshtcpip.c.

390 {
392 
393  return NO_ERROR;
394 }
#define NO_ERROR
Definition: dderror.h:5
#define UNIMPLEMENTED
Definition: debug.h:114

◆ WSHNotify()

INT EXPORT WSHNotify ( IN PVOID  HelperDllSocketContext,
IN SOCKET  SocketHandle,
IN HANDLE  TdiAddressObjectHandle,
IN HANDLE  TdiConnectionObjectHandle,
IN DWORD  NotifyEvent 
)

Definition at line 430 of file wshtcpip.c.

436 {
437  PSOCKET_CONTEXT Context = HelperDllSocketContext;
439  HANDLE TcpCC;
440  TDIEntityID *EntityIDs;
442  PQUEUED_REQUEST QueuedRequest, NextQueuedRequest;
443 
444  switch (NotifyEvent)
445  {
446  case WSH_NOTIFY_CLOSE:
447  DPRINT("WSHNotify: WSH_NOTIFY_CLOSE\n");
448  QueuedRequest = Context->RequestQueue;
449  while (QueuedRequest)
450  {
451  NextQueuedRequest = QueuedRequest->Next;
452 
453  HeapFree(GetProcessHeap(), 0, QueuedRequest->Info);
454  HeapFree(GetProcessHeap(), 0, QueuedRequest);
455 
456  QueuedRequest = NextQueuedRequest;
457  }
458  HeapFree(GetProcessHeap(), 0, HelperDllSocketContext);
459  break;
460 
461 
462  case WSH_NOTIFY_BIND:
463  DPRINT("WSHNotify: WSH_NOTIFY_BIND\n");
464  Status = openTcpFile(&TcpCC, FILE_READ_DATA);
465  if (Status != STATUS_SUCCESS)
466  return WSAEINVAL;
467 
468  Status = tdiGetEntityIDSet(TcpCC,
469  &EntityIDs,
470  &EntityCount);
471 
472  closeTcpFile(TcpCC);
473 
474  if (Status != STATUS_SUCCESS)
475  return WSAEINVAL;
476 
477  for (i = 0; i < EntityCount; i++)
478  {
479  if (EntityIDs[i].tei_entity == CO_TL_ENTITY ||
480  EntityIDs[i].tei_entity == CL_TL_ENTITY ||
481  EntityIDs[i].tei_entity == ER_ENTITY)
482  {
483  Context->AddrFileInstance = EntityIDs[i].tei_instance;
484  Context->AddrFileEntityType = EntityIDs[i].tei_entity;
485  }
486  }
487 
488  DPRINT("Instance: %lx Type: %lx\n", Context->AddrFileInstance, Context->AddrFileEntityType);
489 
490  tdiFreeThingSet(EntityIDs);
491 
492  Context->SocketState = SocketStateBound;
493 
494  QueuedRequest = Context->RequestQueue;
495  while (QueuedRequest)
496  {
497  QueuedRequest->Info->ID.toi_entity.tei_entity = Context->AddrFileEntityType;
498  QueuedRequest->Info->ID.toi_entity.tei_instance = Context->AddrFileInstance;
499 
500  SendRequest(QueuedRequest->Info,
501  sizeof(*QueuedRequest->Info) + QueuedRequest->Info->BufferSize,
503 
504  NextQueuedRequest = QueuedRequest->Next;
505 
506  HeapFree(GetProcessHeap(), 0, QueuedRequest->Info);
507  HeapFree(GetProcessHeap(), 0, QueuedRequest);
508 
509  QueuedRequest = NextQueuedRequest;
510  }
511  Context->RequestQueue = NULL;
512  break;
513 
514  default:
515  DPRINT1("Unwanted notification received! (%ld)\n", NotifyEvent);
516  break;
517  }
518 
519  return NO_ERROR;
520 }
TDIEntityID toi_entity
Definition: tdiinfo.h:74
ULONG EntityCount
Definition: main.c:24
#define WSAEINVAL
Definition: winerror.h:1946
LONG NTSTATUS
Definition: precomp.h:26
#define WSH_NOTIFY_BIND
Definition: wsahelp.h:10
#define NO_ERROR
Definition: dderror.h:5
NTSTATUS tdiGetEntityIDSet(HANDLE tcpFile, TDIEntityID **entitySet, PDWORD numEntities)
Definition: enum.c:122
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FILE_READ_DATA
Definition: nt_native.h:628
#define IOCTL_TCP_SET_INFORMATION_EX
Definition: ticonsts.h:45
smooth NULL
Definition: ftsmooth.c:416
#define CO_TL_ENTITY
Definition: tdiinfo.h:45
void DPRINT(...)
Definition: polytest.cpp:61
VOID tdiFreeThingSet(PVOID things)
Definition: enum.c:118
ULONG tei_entity
Definition: tdiinfo.h:31
#define GetProcessHeap()
Definition: compat.h:395
ULONG tei_instance
Definition: tdiinfo.h:32
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
Status
Definition: gdiplustypes.h:24
INT SendRequest(IN PVOID Request, IN DWORD RequestSize, IN DWORD IOCTL)
Definition: wshtcpip.c:397
#define CL_TL_ENTITY
Definition: tdiinfo.h:43
#define WSH_NOTIFY_CLOSE
Definition: wsahelp.h:17
#define ER_ENTITY
Definition: tdiinfo.h:46
#define DPRINT1
Definition: precomp.h:8
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
PTCP_REQUEST_SET_INFORMATION_EX Info
Definition: wshtcpip.h:39
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ WSHOpenSocket()

INT EXPORT WSHOpenSocket ( IN OUT PINT  AddressFamily,
IN OUT PINT  SocketType,
IN OUT PINT  Protocol,
OUT PUNICODE_STRING  TransportDeviceName,
OUT PVOID  HelperDllSocketContext,
OUT PDWORD  NotificationEvents 
)

Definition at line 525 of file wshtcpip.c.

535 {
537  SocketType,
538  Protocol,
539  0,
540  0,
541  TransportDeviceName,
542  HelperDllSocketContext,
543  NotificationEvents);
544 }
IN PCO_ADDRESS_FAMILY AddressFamily
Definition: ndis.h:1906
_In_ USHORT SocketType
Definition: wsk.h:182
INT EXPORT WSHOpenSocket2(OUT PINT AddressFamily, IN OUT PINT SocketType, IN OUT PINT Protocol, IN GROUP Group, IN DWORD Flags, OUT PUNICODE_STRING TransportDeviceName, OUT PVOID *HelperDllSocketContext, OUT PDWORD NotificationEvents)
Definition: wshtcpip.c:549

◆ WSHOpenSocket2()

INT EXPORT WSHOpenSocket2 ( OUT PINT  AddressFamily,
IN OUT PINT  SocketType,
IN OUT PINT  Protocol,
IN GROUP  Group,
IN DWORD  Flags,
OUT PUNICODE_STRING  TransportDeviceName,
OUT PVOID HelperDllSocketContext,
OUT PDWORD  NotificationEvents 
)

Definition at line 549 of file wshtcpip.c.

574 {
580 
581  DPRINT("WSHOpenSocket2 called\n");
582 
583  switch (*SocketType) {
584  case SOCK_STREAM:
585  String = TcpDeviceName;
586  break;
587 
588  case SOCK_DGRAM:
589  String = UdpDeviceName;
590  break;
591 
592  case SOCK_RAW:
593  if ((*Protocol < 0) || (*Protocol > 255))
594  return WSAEINVAL;
595 
596  String = RawDeviceName;
597  break;
598 
599  default:
600  return WSAEINVAL;
601  }
602 
603  RtlInitUnicodeString(TransportDeviceName, NULL);
604 
605  TransportDeviceName->MaximumLength = String.Length + /* Transport device name */
606  (4 * sizeof(WCHAR) + /* Separator and protocol */
607  sizeof(UNICODE_NULL)); /* Terminating null */
608 
609  TransportDeviceName->Buffer = HeapAlloc(
610  GetProcessHeap(),
611  0,
612  TransportDeviceName->MaximumLength);
613 
614  if (!TransportDeviceName->Buffer)
615  return WSAENOBUFS;
616 
617  /* Append the transport device name */
618  RtlAppendUnicodeStringToString(TransportDeviceName, &String);
619 
620  if (*SocketType == SOCK_RAW) {
621  /* Append a separator */
622  TransportDeviceName->Buffer[TransportDeviceName->Length / sizeof(WCHAR)] = OBJ_NAME_PATH_SEPARATOR;
623  TransportDeviceName->Length += sizeof(WCHAR);
624  TransportDeviceName->Buffer[TransportDeviceName->Length / sizeof(WCHAR)] = UNICODE_NULL;
625 
626  /* Append the protocol number */
627  String.Buffer = TransportDeviceName->Buffer + (TransportDeviceName->Length / sizeof(WCHAR));
628  String.Length = 0;
629  String.MaximumLength = TransportDeviceName->MaximumLength - TransportDeviceName->Length;
630 
632 
633  TransportDeviceName->Length += String.Length;
634  }
635 
636  /* Setup a socket context area */
637 
639  if (!Context) {
640  RtlFreeUnicodeString(TransportDeviceName);
641  return WSAENOBUFS;
642  }
643 
644  Context->AddressFamily = *AddressFamily;
645  Context->SocketType = *SocketType;
646  Context->Protocol = *Protocol;
647  Context->Flags = Flags;
648  Context->SocketState = SocketStateCreated;
649 
650  *HelperDllSocketContext = Context;
651  *NotificationEvents = WSH_NOTIFY_CLOSE | WSH_NOTIFY_BIND;
652 
653  return NO_ERROR;
654 }
IN PCO_ADDRESS_FAMILY AddressFamily
Definition: ndis.h:1906
#define WSAEINVAL
Definition: winerror.h:1946
#define DD_TCP_DEVICE_NAME
Definition: wshtcpip.h:27
#define WSH_NOTIFY_BIND
Definition: wsahelp.h:10
_In_ USHORT _In_ ULONG Protocol
Definition: wsk.h:182
static WCHAR String[]
Definition: stringtable.c:55
#define NO_ERROR
Definition: dderror.h:5
#define SOCK_RAW
Definition: winsock.h:337
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define UNICODE_NULL
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define DD_RAW_IP_DEVICE_NAME
Definition: wshtcpip.h:29
NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString(ULONG Value, ULONG Base, PUNICODE_STRING String)
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define DD_UDP_DEVICE_NAME
Definition: wshtcpip.h:28
_In_ USHORT SocketType
Definition: wsk.h:182
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define WSH_NOTIFY_CLOSE
Definition: wsahelp.h:17
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
struct tagContext Context
Definition: acpixf.h:1024
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define SOCK_STREAM
Definition: tcpip.h:118
#define SOCK_DGRAM
Definition: winsock.h:336
#define WSAENOBUFS
Definition: winerror.h:1968
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by WSHOpenSocket().

◆ WSHSetSocketInformation()

INT EXPORT WSHSetSocketInformation ( IN PVOID  HelperDllSocketContext,
IN SOCKET  SocketHandle,
IN HANDLE  TdiAddressObjectHandle,
IN HANDLE  TdiConnectionObjectHandle,
IN INT  Level,
IN INT  OptionName,
IN PCHAR  OptionValue,
IN INT  OptionLength 
)

Definition at line 658 of file wshtcpip.c.

667 {
668  PSOCKET_CONTEXT Context = HelperDllSocketContext;
669  ULONG TdiType, TdiId;
670  INT Status;
672  PQUEUED_REQUEST Queued, NextQueued;
673 
674  DPRINT("WSHSetSocketInformation\n");
675 
676  /* FIXME: We only handle address file object here */
677 
678  switch (Level)
679  {
680  case SOL_SOCKET:
681  switch (OptionName)
682  {
683  case SO_DONTROUTE:
684  if (OptionLength < sizeof(BOOL))
685  {
686  return WSAEFAULT;
687  }
688  Context->DontRoute = *(BOOL*)OptionValue;
689  /* This is silently ignored on Windows */
690  return 0;
691 
692  case SO_KEEPALIVE:
693  /* FIXME -- We'll send this to TCPIP */
694  DPRINT1("Set: SO_KEEPALIVE not yet supported\n");
695  return 0;
696 
697  default:
698  /* Invalid option */
699  DPRINT1("Set: Received unexpected SOL_SOCKET option %d\n", OptionName);
700  return WSAENOPROTOOPT;
701  }
702  break;
703 
704  case IPPROTO_IP:
705  switch (OptionName)
706  {
707  case IP_TTL:
708  case IP_DONTFRAGMENT:
709  case IP_HDRINCL:
710  /* Send these to TCPIP */
711  break;
712 
713  default:
714  /* Invalid option -- FIXME */
715  DPRINT1("Set: Received unsupported IPPROTO_IP option %d\n", OptionName);
716  return 0;
717  }
718  break;
719 
720  case IPPROTO_TCP:
721  switch (OptionName)
722  {
723  case TCP_NODELAY:
724  if (OptionLength < sizeof(CHAR))
725  {
726  return WSAEFAULT;
727  }
728  break;
729 
730  default:
731  /* Invalid option */
732  DPRINT1("Set: Received unexpected IPPROTO_TCP option %d\n", OptionName);
733  return 0;
734  }
735  break;
736 
737  default:
738  DPRINT1("Set: Received unexpected %d option %d\n", Level, OptionName);
739  return 0;
740  }
741 
742  /* If we get here, GetAddressOption must return something valid */
743  GetTdiTypeId(Level, OptionName, &TdiType, &TdiId);
744  ASSERT((TdiId != 0) && (TdiType != 0));
745 
746  Info = HeapAlloc(GetProcessHeap(), 0, sizeof(*Info) + OptionLength);
747  if (!Info)
748  return WSAENOBUFS;
749 
750  Info->ID.toi_entity.tei_entity = Context->AddrFileEntityType;
751  Info->ID.toi_entity.tei_instance = Context->AddrFileInstance;
752  Info->ID.toi_class = INFO_CLASS_PROTOCOL;
753  Info->ID.toi_type = TdiType;
754  Info->ID.toi_id = TdiId;
755  Info->BufferSize = OptionLength;
756  memcpy(Info->Buffer, OptionValue, OptionLength);
757 
758  if (Context->SocketState == SocketStateCreated)
759  {
760  if (Context->RequestQueue)
761  {
762  Queued = Context->RequestQueue;
763  while ((NextQueued = Queued->Next))
764  {
765  Queued = NextQueued;
766  }
767 
768  Queued->Next = HeapAlloc(GetProcessHeap(), 0, sizeof(QUEUED_REQUEST));
769  if (!Queued->Next)
770  {
772  return WSAENOBUFS;
773  }
774 
775  NextQueued = Queued->Next;
776  NextQueued->Next = NULL;
777  NextQueued->Info = Info;
778  }
779  else
780  {
781  Context->RequestQueue = HeapAlloc(GetProcessHeap(), 0, sizeof(QUEUED_REQUEST));
782  if (!Context->RequestQueue)
783  {
785  return WSAENOBUFS;
786  }
787 
788  Context->RequestQueue->Next = NULL;
789  Context->RequestQueue->Info = Info;
790  }
791 
792  return 0;
793  }
794 
795  Status = SendRequest(Info, sizeof(*Info) + Info->BufferSize, IOCTL_TCP_SET_INFORMATION_EX);
796 
798 
799  return Status;
800 }
#define WSAEFAULT
Definition: winerror.h:1945
static void GetTdiTypeId(_In_ INT Level, _In_ INT OptionName, _Out_ PULONG TdiType, _Out_ PULONG TdiId)
Definition: wshtcpip.c:161
char CHAR
Definition: xmlstorage.h:175
#define SO_KEEPALIVE
Definition: winsock.h:181
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
#define SOL_SOCKET
Definition: winsock.h:398
#define WSAENOPROTOOPT
Definition: winerror.h:1955
int32_t INT
Definition: typedefs.h:56
struct TraceInfo Info
#define TCP_NODELAY
Definition: tcpdef.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IP_HDRINCL
Definition: ws2ipdef.h:28
#define IOCTL_TCP_SET_INFORMATION_EX
Definition: ticonsts.h:45
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define IPPROTO_IP
Definition: winsock.h:255
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define IP_DONTFRAGMENT
Definition: winsock.h:326
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Status
Definition: gdiplustypes.h:24
INT SendRequest(IN PVOID Request, IN DWORD RequestSize, IN DWORD IOCTL)
Definition: wshtcpip.c:397
#define DPRINT1
Definition: precomp.h:8
#define IP_TTL
Definition: winsock.h:324
unsigned int ULONG
Definition: retypes.h:1
PTCP_REQUEST_SET_INFORMATION_EX Info
Definition: wshtcpip.h:39
#define WSAENOBUFS
Definition: winerror.h:1968
#define HeapFree(x, y, z)
Definition: compat.h:394
#define SO_DONTROUTE
Definition: winsock.h:182
#define INFO_CLASS_PROTOCOL
Definition: tdiinfo.h:65

◆ WSHStringToAddress()

INT EXPORT WSHStringToAddress ( IN LPWSTR  AddressString,
IN DWORD  AddressFamily,
IN LPWSAPROTOCOL_INFOW ProtocolInfo  OPTIONAL,
OUT LPSOCKADDR  Address,
IN OUT LPDWORD  AddressStringLength 
)

Definition at line 805 of file wshtcpip.c.

811 {
813 
814  return NO_ERROR;
815 }
#define NO_ERROR
Definition: dderror.h:5
#define UNIMPLEMENTED
Definition: debug.h:114