SIO_RCVALL control code
The SIO_RCVALL control code enables a socket to receive all IPv4 or IPv6 packets passing through a network interface.
To perform this operation, call the WSAIoctl or WSPIoctl function with the following parameters.
int WSAIoctl( (socket) s, // descriptor identifying a socket SIO_RCV_ALL, // dwIoControlCode NULL, // lpvInBuffer 0, // cbInBuffer NULL, // lpvOutBuffer output buffer (DWORD) cbOutBuffer, // size of output buffer (LPDWORD) lpcbBytesReturned, // number of bytes returned (LPWSAOVERLAPPED) lpOverlapped, // OVERLAPPED structure (LPWSAOVERLAPPED_COMPLETION_ROUTINE) lpCompletionRoutine, // completion routine );
int WSPIoctl( (socket) s, // descriptor identifying a socket SIO_RCV_ALL, // dwIoControlCode NULL, // lpvInBuffer 0, // cbInBuffer NULL, // lpvOutBuffer output buffer (DWORD) cbOutBuffer, // size of output buffer (LPDWORD) lpcbBytesReturned, // number of bytes returned (LPWSAOVERLAPPED) lpOverlapped, // OVERLAPPED structure (LPWSAOVERLAPPED_COMPLETION_ROUTINE) lpCompletionRoutine, // completion routine (LPWSATHREADID) lpThreadId, // a WSATHREADID structure (LPINT) lpErrno // a pointer to the error code. );
Parameters
- s
-
A descriptor identifying a socket.
- dwIoControlCode
-
The control code for the operation. Use SIO_RCVALL for this operation.
- lpvInBuffer
-
A pointer to the input buffer that should contain the option value. The possible values for the SIO_RCVALL IOCTL option are specified in the RCVALL_VALUE enumeration defined in the Mstcpip.h header file.
The possible values for SIO_RCVALL are as follows:
- cbInBuffer
-
The size, in bytes, of the input buffer. This parameter should be equal to or greater than the size of the RCVALL_VALUE enumeration value pointed to by the lpvInBuffer parameter.
- lpvOutBuffer
-
A pointer to the output buffer. This parameter is unused for this operation.
- cbOutBuffer
-
The size, in bytes, of the output buffer. This parameter is unused for this operation.
- lpcbBytesReturned
-
A pointer to a variable that receives the size, in bytes, of the data stored in the output buffer. This parameter is unused for this operation.
- lpvOverlapped
-
A pointer to a WSAOVERLAPPED structure.
If socket s was created without the overlapped attribute, the lpOverlapped parameter is ignored.
If s was opened with the overlapped attribute and the lpOverlapped parameter is not NULL, the operation is performed as an overlapped (asynchronous) operation. In this case, lpOverlapped parameter must point to a valid WSAOVERLAPPED structure.
For overlapped operations, the WSAIoctl or WSPIoctl function returns immediately, and the appropriate completion method is signaled when the operation has been completed. Otherwise, the function does not return until the operation has been completed or an error occurs.
- lpCompletionRoutine
-
A pointer to the completion routine called when the operation has been completed (ignored for non-overlapped sockets).
- lpThreadId
-
A pointer to a WSATHREADID structure to be used by the provider in a subsequent call to WPUQueueApc. The provider should store the referenced WSATHREADID structure (not the pointer to same) until after the WPUQueueApc function returns.
Note This parameter applies only to the WSPIoctl function. - lpErrno
-
A pointer to the error code.
Note This parameter applies only to the WSPIoctl function.
Return value
If the operation completes successfully, the WSAIoctl or WSPIoctl function returns zero.
If the operation fails or is pending, the WSAIoctl or WSPIoctl function returns SOCKET_ERROR. To get extended error information, call WSAGetLastError.
| Error code | Meaning |
|---|---|
|
An overlapped operation was successfully initiated and completion will be indicated at a later time. | |
|
An overlapped operation was canceled due to the closure of the socket or the execution of the SIO_FLUSH IOCTL command. | |
|
The lpOverlapped or lpCompletionRoutine parameter is not totally contained in a valid part of the user address space. | |
|
The function is invoked when a callback is in progress. | |
|
A blocking operation was interrupted. | |
|
The dwIoControlCode parameter is not a valid command, or a specified input parameter is not acceptable, or the command is not applicable to the type of socket specified. This error is also returned if the cbInBuffer parameter is less than the sizeof(UCHAR) or the lpvInBuffer parameter points to value that is not a RCVALL_VALUE enumeration value. This error can also be returned if the network interface associated with the socket cannot be found. This could occur if the network interface associated with the socket is deleted or removed (a remove PCMCIA or USB network device, for example). | |
|
The network subsystem has failed. | |
|
No buffer space available. | |
|
The socket option is not supported on the specified protocol. | |
|
The descriptor s is not a socket. | |
|
The specified IOCTL command is not supported. This error is returned if the SIO_RCVALL IOCTL is not supported by the transport provider. |
Remarks
The SIO_RCVALL IOCTL is supported on Windows 2000 and later versions of the operating system.
The SIO_RCVALL IOCTL enables a socket to receive all IPv4 or IPv6 packets on a network interface. The socket handle passed to the WSAIoctl or WSPIoctl function must be one of the following:
- An IPv4 socket that was created with the address family set to AF_INET, the socket type set to SOCK_RAW, and the protocol set to IPPROTO_IP.
- An IPv6 socket that was created with the address family set to AF_INET6, the socket type set to SOCK_RAW, and the protocol set to IPPROTO_IPV6.
For more information on raw sockets, see TCP/IP Raw Sockets.
The socket also must be bound to an explicit local IPv4 or IPv6 interface, which means that you cannot bind to INADDR_ANY or in6addr_any.
Once the socket is bound and the IOCTL completes successfully, calls to the WSARecv or recv functions return IPv4 datagrams passing through the given IPv4 interface or return IPv6 datagrams passing through the given IPv6 interface. Note that you must supply a sufficiently large buffer. Setting this IOCTL will only capture IPv4 or IPv6 packets on a given interface. This IOCTL will not capture other packets (ARP, IPX, and NetBEUI packets, for example) on the interface.
A socket bound to a specific local interface with the SIO_RCVALL IOCTL will receive only packets passing through that interface. It will not receive packets received on another interface and getting forwarded out on another interface different from the socket bound with SIO_RCVALL IOCTL.
On Windows Server 2008 and earlier, the SIO_RCVALL IOCTL setting would not capture local packets sent out of a network interface. This included packets received on another interface and forwarded out the network interface specified for the SIO_RCVALL IOCTL.
On Windows 7 and Windows Server 2008 R2 , this was changed so that local packets sent out of a network interface are also captured. This includes packets received on another interface and then forwarded out the network interface bound to the socket with SIO_RCVALL IOCTL.
Setting this IOCTL requires Administrator privilege on the local computer.
This feature is sometimes referred to as promiscuous mode. Any direct change from applying this option on one interface and then to another interface with a single call using this IOCTL is not supported . An application must first use this IOCTL to turn off the behavior on the first interface, and then use this IOCTL to enable the behavior on a new interface.
Requirements
|
Minimum supported client |
Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows 2000 Server [desktop apps only] |
|
Header |
|
See also
- socket
- TCP/IP Raw Sockets
- WSAGetLastError
- WSAGetOverlappedResult
- WSAIoctl
- WSAOVERLAPPED
- WSASocket
- WSPIoctl