#pragma warning disable IDE1006 // Naming Styles using System; using System.Runtime.InteropServices; namespace Vanara.PInvoke; /// Functions, structures and constants from ws2_32.h. public static partial class Ws2_32 { #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public static readonly uint SIO_ABSORB_RTRALERT = _WSAIOW(IOC_VENDOR, 5); public static readonly uint SIO_ACQUIRE_PORT_RESERVATION = _WSAIOW(IOC_VENDOR, 100); public static readonly uint SIO_APPLY_TRANSPORT_SETTING = _WSAIOW(IOC_VENDOR, 19); public static readonly uint SIO_ASSOCIATE_PORT_RESERVATION = _WSAIOW(IOC_VENDOR, 102); public static readonly uint SIO_CPU_AFFINITY = _WSAIOW(IOC_VENDOR, 21); public static readonly uint SIO_DELETE_PEER_TARGET_NAME = _WSAIOW(IOC_VENDOR, 203); public static readonly uint SIO_GET_TX_TIMESTAMP = _WSAIOW(IOC_VENDOR, 234); public static readonly uint SIO_INDEX_ADD_MCAST = _WSAIOW(IOC_VENDOR, 10); public static readonly uint SIO_INDEX_BIND = _WSAIOW(IOC_VENDOR, 8); public static readonly uint SIO_INDEX_DEL_MCAST = _WSAIOW(IOC_VENDOR, 11); public static readonly uint SIO_INDEX_MCASTIF = _WSAIOW(IOC_VENDOR, 9); public static readonly uint SIO_KEEPALIVE_VALS = _WSAIOW(IOC_VENDOR, 4); public static readonly uint SIO_LIMIT_BROADCASTS = _WSAIOW(IOC_VENDOR, 7); public static readonly uint SIO_LOOPBACK_FAST_PATH = _WSAIOW(IOC_VENDOR, 16); public static readonly uint SIO_PRIORITY_HINT = SIO_SET_PRIORITY_HINT; public static readonly uint SIO_QUERY_RSS_SCALABILITY_INFO = _WSAIOR(IOC_VENDOR, 210); public static readonly uint SIO_QUERY_SECURITY = _WSAIORW(IOC_VENDOR, 201); public static readonly uint SIO_QUERY_TRANSPORT_SETTING = _WSAIOW(IOC_VENDOR, 20); public static readonly uint SIO_QUERY_WFP_ALE_ENDPOINT_HANDLE = _WSAIOR(IOC_VENDOR, 205); public static readonly uint SIO_QUERY_WFP_CONNECTION_REDIRECT_CONTEXT = _WSAIOW(IOC_VENDOR, 221); public static readonly uint SIO_QUERY_WFP_CONNECTION_REDIRECT_RECORDS = _WSAIOW(IOC_VENDOR, 220); public static readonly uint SIO_RCVALL = _WSAIOW(IOC_VENDOR, 1); public static readonly uint SIO_RCVALL_IF = _WSAIOW(IOC_VENDOR, 14); public static readonly uint SIO_RCVALL_IGMPMCAST = _WSAIOW(IOC_VENDOR, 3); public static readonly uint SIO_RCVALL_MCAST = _WSAIOW(IOC_VENDOR, 2); public static readonly uint SIO_RCVALL_MCAST_IF = _WSAIOW(IOC_VENDOR, 13); public static readonly uint SIO_RELEASE_PORT_RESERVATION = _WSAIOW(IOC_VENDOR, 101); public static readonly uint SIO_SET_PEER_TARGET_NAME = _WSAIOW(IOC_VENDOR, 202); public static readonly uint SIO_SET_PRIORITY_HINT = _WSAIOW(IOC_VENDOR, 24); public static readonly uint SIO_SET_SECURITY = _WSAIOW(IOC_VENDOR, 200); public static readonly uint SIO_SET_WFP_CONNECTION_REDIRECT_RECORDS = _WSAIOW(IOC_VENDOR, 222); public static readonly uint SIO_SOCKET_USAGE_NOTIFICATION = _WSAIOW(IOC_VENDOR, 204); public static readonly uint SIO_TCP_INFO = _WSAIORW(IOC_VENDOR, 39); public static readonly uint SIO_TCP_INITIAL_RTO = _WSAIOW(IOC_VENDOR, 17); public static readonly uint SIO_TCP_SET_ACK_FREQUENCY = _WSAIOW(IOC_VENDOR, 23); public static readonly uint SIO_TCP_SET_ICW = _WSAIOW(IOC_VENDOR, 22); public static readonly uint SIO_TIMESTAMPING = _WSAIOW(IOC_VENDOR, 235); public static readonly uint SIO_UCAST_IF = _WSAIOW(IOC_VENDOR, 6); #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member /// /// The CONTROL_CHANNEL_TRIGGER_STATUS enumeration specifies the status from a query for the REAL_TIME_NOTIFICATION_CAPABILITY /// transport setting for a TCP socket that is used with ControlChannelTrigger to receive background network notifications in a /// Windows Store app. /// /// /// /// The CONTROL_CHANNEL_TRIGGER_STATUS structure is supported on Windows 8, and Windows Server 2012, and later versions of the /// operating system. /// /// /// A CONTROL_CHANNEL_TRIGGER_STATUS enumeration value is returned as output from the SIO_QUERY_TRANSPORT_SETTING IOCTL to a query /// the REAL_TIME_NOTIFICATION_CAPABILITY transport setting for a TCP socket that is used with ControlChannelTrigger to /// receive background network notifications in a Windows Store app. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ne-mstcpip-control_channel_trigger_status typedef enum { // CONTROL_CHANNEL_TRIGGER_STATUS_INVALID = 0, CONTROL_CHANNEL_TRIGGER_STATUS_SOFTWARE_SLOT_ALLOCATED = 1, // CONTROL_CHANNEL_TRIGGER_STATUS_HARDWARE_SLOT_ALLOCATED = 2, CONTROL_CHANNEL_TRIGGER_STATUS_POLICY_ERROR = 3, // CONTROL_CHANNEL_TRIGGER_STATUS_SYSTEM_ERROR = 4, CONTROL_CHANNEL_TRIGGER_STATUS_TRANSPORT_DISCONNECTED = 5, // CONTROL_CHANNEL_TRIGGER_STATUS_SERVICE_UNAVAILABLE = 6 } CONTROL_CHANNEL_TRIGGER_STATUS, *PCONTROL_CHANNEL_TRIGGER_STATUS; [PInvokeData("mstcpip.h", MSDNShortId = "NE:mstcpip.__unnamed_enum_0")] public enum CONTROL_CHANNEL_TRIGGER_STATUS { /// /// Value: /// 0 /// Status is invalid. /// CONTROL_CHANNEL_TRIGGER_STATUS_INVALID, /// /// Value: /// 1 /// A software slot was allocated for the /// ControlChannelTrigger /// . /// CONTROL_CHANNEL_TRIGGER_STATUS_SOFTWARE_SLOT_ALLOCATED, /// /// Value: /// 2 /// A hardware slot was allocated for the /// ControlChannelTrigger /// . /// CONTROL_CHANNEL_TRIGGER_STATUS_HARDWARE_SLOT_ALLOCATED, /// /// Value: /// 3 /// A status policy error. /// CONTROL_CHANNEL_TRIGGER_STATUS_POLICY_ERROR, /// /// Value: /// 4 /// A status system error. /// CONTROL_CHANNEL_TRIGGER_STATUS_SYSTEM_ERROR, /// /// Value: /// 5 /// The TCP transport is disconnected. /// CONTROL_CHANNEL_TRIGGER_STATUS_TRANSPORT_DISCONNECTED, /// /// Value: /// 6 /// Service is unavailable. /// CONTROL_CHANNEL_TRIGGER_STATUS_SERVICE_UNAVAILABLE, } /// The set of possible security flags for the connection defined in the Mstcpip.h header file. [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._SOCKET_SECURITY_QUERY_INFO")] [Flags] public enum SOCKET_INFO_CONNECTION : uint { /// If present, traffic is being secured by a security protocol. If absent, the traffic is flowing in the clear. SOCKET_INFO_CONNECTION_SECURED = 0x1, /// /// If present, the connection traffic is being encrypted. The SOCKET_INFO_CONNECTION_SECURED flag is always set when this /// flag is present. /// SOCKET_INFO_CONNECTION_ENCRYPTED = 0x2, /// SOCKET_INFO_CONNECTION_IMPERSONATED = 0x4, } /// /// The SOCKET_SECURITY_PROTOCOL enumeration indicates the type of security protocol to be used on a socket to secure network traffic. /// /// /// This enumeration is supported on Windows Vista and later. /// /// Currently, the only type of security protocol that is supported is IPsec. So specifying an enumeration value of /// SOCKET_SECURITY_PROTOCOL_DEFAULT has the same effect as specifying SOCKET_SECURITY_PROTOCOL_IPSEC. /// /// /// The SOCKET_SECURITY_PROTOCOL enumeration is used in the SOCKET_PEER_TARGET_NAME, SOCKET_SECURITY_QUERY_INFO, /// SOCKET_SECURITY_QUERY_TEMPLATE, SOCKET_SECURITY_SETTINGS, and SOCKET_SECURITY_SETTINGS_IPSEC structures to indicate the type of /// security protocol to be used on a socket in the SecurityProtocol member. These structures are used by the /// WSAQuerySocketSecurity, WSASetSocketPeerTargetName, and WSASetSocketSecurity functions. /// /// /// In addition to identifying the security protocol, this type is also used to decide how to interpret a pointer passed to some of /// the secure socket functions. This is analogous to how the sa_family member of the sockaddr type is used to interpret a /// pointer as either sockaddr_in or sockaddr_in6. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ne-mstcpip-socket_security_protocol typedef enum // _SOCKET_SECURITY_PROTOCOL { SOCKET_SECURITY_PROTOCOL_DEFAULT, SOCKET_SECURITY_PROTOCOL_IPSEC, SOCKET_SECURITY_PROTOCOL_IPSEC2, // SOCKET_SECURITY_PROTOCOL_INVALID } SOCKET_SECURITY_PROTOCOL; [PInvokeData("mstcpip.h", MSDNShortId = "NE:mstcpip._SOCKET_SECURITY_PROTOCOL")] public enum SOCKET_SECURITY_PROTOCOL { /// The default system security will be used. SOCKET_SECURITY_PROTOCOL_DEFAULT, /// IPsec will be used. SOCKET_SECURITY_PROTOCOL_IPSEC, /// SOCKET_SECURITY_PROTOCOL_IPSEC2, /// /// The maximum possible value for the /// SOCKET_SECURITY_PROTOCOL /// enumeration type. This is not a legal value. /// SOCKET_SECURITY_PROTOCOL_INVALID, } /// A set of flags that allow applications to set specific security requirements on a socket. [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._SOCKET_SECURITY_SETTINGS")] [Flags] public enum SOCKET_SETTINGS : uint { /// /// Indicates that guaranteed encryption of traffic is required. This flag should be set if the default policy prefers methods of /// protection that do not use encryption. If this flag is set and encryption is not possible for any reason, no packets will be /// sent and a connection will not be established. /// SOCKET_SETTINGS_GUARANTEE_ENCRYPTION = 0x1, /// /// Indicates that clear text connections are allowed. If this flag is set, some or all of the sent packets will be sent in clear /// text, especially if security with the peer could not be negotiated. /// SOCKET_SETTINGS_ALLOW_INSECURE = 0x2, } /// Flags for IPsec security settings. [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._SOCKET_SECURITY_SETTINGS_IPSEC")] [Flags] public enum SOCKET_SETTINGS_IPSEC : uint { /// /// When this flag is set, IPsec filter instantiation is omitted for the socket. This flag should be set when an application /// knows that IPsec filters and policy already exist for its traffic. Applications running on a domain with IPsec policy in /// place can also set this flag. /// SOCKET_SETTINGS_IPSEC_SKIP_FILTER_INSTANTIATION = 0x1, /// SOCKET_SETTINGS_IPSEC_OPTIONAL_PEER_NAME_VERIFICATION = 0x2, /// SOCKET_SETTINGS_IPSEC_ALLOW_FIRST_INBOUND_PKT_UNENCRYPTED = 0x4, /// SOCKET_SETTINGS_IPSEC_PEER_NAME_IS_RAW_FORMAT = 0x8, } /// The Windows Sockets SOCKET_USAGE_TYPE enumeration is used to specified the usage type for the socket. // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ne-mstcpip-socket_usage_type typedef enum _SOCKET_USAGE_TYPE { // SYSTEM_CRITICAL_SOCKET = 1 } SOCKET_USAGE_TYPE; [PInvokeData("mstcpip.h", MSDNShortId = "NE:mstcpip._SOCKET_USAGE_TYPE")] public enum SOCKET_USAGE_TYPE { /// /// Value: /// 1 /// The usage type is critical to the system. /// SYSTEM_CRITICAL_SOCKET = 1, } /// /// The Windows Sockets TCPSTATE enumeration indicates the possible states of a Transmission Control Protocol (TCP) connection. /// /// /// /// A TCP connection progresses from one state to another in response to events. The events are the user calls OPEN, SEND, RECEIVE, /// CLOSE, ABORT, and STATUS; the incoming segments, particularly those containing the SYN, ACK, RST and FIN flags; and timeouts. /// /// For more information about TCP connection states, see RFC 793. /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ne-mstcpip-tcpstate typedef enum _TCPSTATE { TCPSTATE_CLOSED, // TCPSTATE_LISTEN, TCPSTATE_SYN_SENT, TCPSTATE_SYN_RCVD, TCPSTATE_ESTABLISHED, TCPSTATE_FIN_WAIT_1, TCPSTATE_FIN_WAIT_2, // TCPSTATE_CLOSE_WAIT, TCPSTATE_CLOSING, TCPSTATE_LAST_ACK, TCPSTATE_TIME_WAIT, TCPSTATE_MAX } TCPSTATE; [PInvokeData("mstcpip.h", MSDNShortId = "NE:mstcpip._TCPSTATE")] public enum TCPSTATE { /// /// /// The TCP connection has no connection state at all. This state represents the state when there is no Transmission Control /// Block (TCB), and therefore, /// /// no connection. /// TCPSTATE_CLOSED, /// /// The TCP connection is waiting for a connection request from any remote /// TCP and port. /// TCPSTATE_LISTEN, /// /// -The TCP connection is waiting for a matching connection request /// after sending a connection request. /// TCPSTATE_SYN_SENT, /// /// The TCP connection is waiting for an acknowledgment that confirms the connection /// request after both receiving and sending a /// connection request. /// TCPSTATE_SYN_RCVD, /// /// The TCP connection is an open connection, so the data received can be /// delivered to the user. This state is normal state for the data transfer phase /// of the connection. /// TCPSTATE_ESTABLISHED, /// /// The TCP connection is waiting for a request to end the connection /// from the remote TCP, or an acknowledgment of the previously sent request to end the connection. /// TCPSTATE_FIN_WAIT_1, /// /// The TCP connection is waiting for a request to end the connection /// from the remote TCP. /// TCPSTATE_FIN_WAIT_2, /// /// The TCP connection is waiting for a request to end the connection /// from the local user. /// TCPSTATE_CLOSE_WAIT, /// The TCP connection is waiting for an acknowledgment of the request to end the connection from the remote TCP. TCPSTATE_CLOSING, /// /// The TCP connection is waiting for an acknowledgment of the request to end the connection that was previously sent to the /// remote TCP, which includes an acknowledgment of its request to end the connection. /// TCPSTATE_LAST_ACK, /// /// The TCP connection is waiting for enough time to pass to be sure /// the remote TCP received the acknowledgment of its request to end the connection. /// TCPSTATE_TIME_WAIT, /// /// The maximum value of the /// TCPSTATE /// enumeration. /// TCPSTATE_MAX, } /// Enable/disable timestamp reception for rx/tx direction. [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._TIMESTAMPING_CONFIG")] [Flags] public enum TIMESTAMPING_FLAG : uint { /// TIMESTAMPING_FLAG_RX = 0x1, /// TIMESTAMPING_FLAG_TX = 0x2, } /// /// The ASSOCIATE_NAMERES_CONTEXT_INPUT structure contains the transport setting ID and handle to a fully qualified domain name. /// /// /// /// Generally speaking, you can use ASSOCIATE_NAMERES_CONTEXT_INPUT to enforce policy based on Fully Qualified Domain Name /// (FQDN), rather than just IP address. you can do so by retrieving a handle to a FQDN with a call to GetAddrInfoEx, using the /// addinfoex4 structure. From there, you can use the handle in ASSOCIATE_NAMERES_CONTEXT_INPUT in a call to WSAIoctl, using /// the SIO_APPLY_TRANSPORT_SETTING ioctl. /// /// Examples /// /// The following code describes making a call to GetAddrInfoEx with a addinfoex4 structure to retrieve the handle to a FQDN. the /// sample then call WSAIoctl with the ASSOCIATE_NAMERES_CONTEXT_INPUT structure. /// /// /// // // Connect to a server using its IPv4 addresses // VOID ConnectServer( PCWSTR server) { int iResult; PADDRINFOEX4 pResult = NULL; ADDRINFOEX3 hints = { 0 }; PADDRINFOEX4 pCur = NULL; WSADATA wsaData; SOCKET connectSocket = INVALID_SOCKET; ULONG bytesReturned = 0; ASSOCIATE_NAMERES_CONTEXT_INPUT input = { 0 }; SOCKADDR_IN clientService; wchar_t ipstringbuffer[46]; String string; DWORD dwRetval; // // Initialize Winsock // iResult = WSAStartup( MAKEWORD(2, 2), &wsaData); if (iResult != 0) { printf("WSAStartup failed: %d\n", iResult); goto Exit; } // // Create a SOCKET for connection // connectSocket = socket( AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); if (connectSocket == INVALID_SOCKET) { printf("socket failed: %d\n", WSAGetLastError()); goto Exit; } // // Do name resolution // hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_EXTENDED | AI_FQDN | AI_CANONNAME | AI_RESOLUTION_HANDLE; hints.ai_version = ADDRINFOEX_VERSION_4; dwRetval = GetAddrInfoExW( server, NULL, NS_DNS, NULL, (const ADDRINFOEXW*)&hints, (PADDRINFOEXW*)&pResult, NULL, NULL, NULL, NULL); if (dwRetval != 0) { printf("GetAddrInfoEx failed with error: %d\n", dwRetval); goto Exit; } input.TransportSettingId.Guid = ASSOCIATE_NAMERES_CONTEXT; input.Handle = pResult->ai_resolutionhandle; // // Associate socket with the handle // if (WSAIoctl( connectSocket, SIO_APPLY_TRANSPORT_SETTING, (VOID *)&input, sizeof(input), NULL, 0, &bytesReturned, NULL, NULL) == SOCKET_ERROR) if (iResult != 0){ printf("WSAIoctl failed: %d\n", WSAGetLastError()); goto Exit; } // // Connect to server // pCur = pResult; while (pCur != NULL) { if (pCur->ai_addr->sa_family == AF_INET) { clientService = *(const sockaddr_in*)pCur->ai_addr; clientService.sin_port = htons(80); if (connect( connectSocket, (const SOCKADDR *)&clientService, sizeof(clientService)) == SOCKET_ERROR) { printf("connect failed: %d\n", WSAGetLastError()); goto Exit; } } pCur = pCur->ai_next; } Exit: if (connectSocket != INVALID_SOCKET) { closesocket(connectSocket); } if (pResult) { FreeAddrInfoExW((ADDRINFOEXW*)pResult); } WSACleanup(); return; } /// /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-associate_nameres_context_input typedef struct // _ASSOCIATE_NAMERES_CONTEXT_INPUT { TRANSPORT_SETTING_ID TransportSettingId; UINT64 Handle; } ASSOCIATE_NAMERES_CONTEXT_INPUT, *PASSOCIATE_NAMERES_CONTEXT_INPUT; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._ASSOCIATE_NAMERES_CONTEXT_INPUT")] [StructLayout(LayoutKind.Sequential)] public struct ASSOCIATE_NAMERES_CONTEXT_INPUT { /// The transport setting ID. public TRANSPORT_SETTING_ID TransportSettingId; /// Handle to a fully qualified domain name. public ulong Handle; } /// /// The INET_PORT_RANGE structure provides input data used by the SIO_ACQUIRE_PORT_RESERVATION IOCTL to acquire a runtime /// reservation for a block of TCP or UDP ports. /// /// /// The INET_PORT_RANGE structure is supported on Windows Vista and later. /// /// The INET_PORT_RANGE structure is the datatype passed in the input buffer to the SIO_ACQUIRE_PORT_RESERVATION IOCTL. This /// IOCTL is used to acquire a runtime reservation for a block of TCP or UDP ports. /// /// The INET_PORT_RANGE structure is typedefed to the INET_PORT_RESERVATION structure. /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-inet_port_range typedef struct _INET_PORT_RANGE { USHORT // StartPort; USHORT NumberOfPorts; } INET_PORT_RANGE, *PINET_PORT_RANGE, INET_PORT_RESERVATION, *PINET_PORT_RESERVATION; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._INET_PORT_RANGE")] [StructLayout(LayoutKind.Sequential)] public struct INET_PORT_RANGE { /// /// The starting TCP or UDP port number. If this parameter is set to zero, the system will choose a starting TCP or UDP port number. /// public ushort StartPort; /// The number of TCP or UDP port numbers to reserve. public ushort NumberOfPorts; } /// /// The INET_PORT_RESERVATION_INSTANCE structure contains a port reservation and a token for a block of TCP or UDP ports. /// /// /// The INET_PORT_RESERVATION_INSTANCE structure is supported on Windows Vista and later. /// /// The INET_PORT_RESERVATION_INSTANCE structure is returned by the SIO_ACQUIRE_PORT_RESERVATION IOCTL when acquiring a /// runtime reservation for a block of TCP or UDP ports. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-inet_port_reservation_instance typedef struct { // INET_PORT_RESERVATION Reservation; INET_PORT_RESERVATION_TOKEN Token; } INET_PORT_RESERVATION_INSTANCE, *PINET_PORT_RESERVATION_INSTANCE; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip.__unnamed_struct_2")] [StructLayout(LayoutKind.Sequential)] public struct INET_PORT_RESERVATION_INSTANCE { /// /// A runtime port reservation for a block of TCP or UDP ports. /// The INET_PORT_RESERVATION structure is typedefed to the INET_PORT_RANGE structure. /// public INET_PORT_RANGE Reservation; /// A port reservation token for a block of TCP or UDP ports. public INET_PORT_RESERVATION_TOKEN Token; } /// The INET_PORT_RESERVATION_TOKEN structure contains a port reservation token for a block of TCP or UDP ports. /// /// The INET_PORT_RESERVATION_TOKEN structure is supported on Windows Vista and later. /// /// The INET_PORT_RESERVATION_TOKEN structure is used by the SIO_ACQUIRE_PORT_RESERVATION , SIO_ASSOCIATE_PORT_RESERVATION, /// and SIO_RELEASE_PORT_RESERVATION Ioctl for TCP or UDP port reservations. The INET_PORT_RESERVATION_TOKEN structure is also /// equivalent to the ULONG64 Token parameter used by the CreatePersistentTcpPortReservation, CreatePersistentUdpPortReservation, /// DeletePersistentTcpPortReservation, DeletePersistentUdpPortReservation, LookupPersistentTcpPortReservation, and /// LookupPersistentUdpPortReservation functions in IP Helper. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-inet_port_reservation_token typedef struct { ULONG64 Token; // } INET_PORT_RESERVATION_TOKEN, *PINET_PORT_RESERVATION_TOKEN; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip.__unnamed_struct_1")] [StructLayout(LayoutKind.Sequential)] public struct INET_PORT_RESERVATION_TOKEN { /// A port reservation token for a block of TCP or UDP ports. public ulong Token; } /// /// The REAL_TIME_NOTIFICATION_SETTING_INPUT structure provides input settings to apply for the /// REAL_TIME_NOTIFICATION_CAPABILITY transport setting for a TCP socket that is used with ControlChannelTrigger to receive /// background network notifications in a Windows Store app. /// /// /// /// The REAL_TIME_NOTIFICATION_SETTING_INPUT structure is supported on Windows 8, and Windows Server 2012, and later versions /// of the operating system. /// /// /// If the TRANSPORT_SETTING_ID in the lpvInBuffer parameter passed to the SIO_APPLY_TRANSPORT_SETTING IOCTL has the /// Guid member set to REAL_TIME_NOTIFICATION_CAPABILITY, then this is a request to query the real time notification /// settings for the TCP socket used with ControlChannelTrigger to receive background network notifications in a Windows Store app. /// The lpvInBuffer parameter should point to a REAL_TIME_NOTIFICATION_SETTING_INPUT structure used as input to the /// SIO_APPLY_TRANSPORT_SETTING IOCTL to apply the transport setting. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-real_time_notification_setting_input typedef struct // _REAL_TIME_NOTIFICATION_SETTING_INPUT { TRANSPORT_SETTING_ID TransportSettingId; GUID BrokerEventGuid; } // REAL_TIME_NOTIFICATION_SETTING_INPUT, *PREAL_TIME_NOTIFICATION_SETTING_INPUT; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._REAL_TIME_NOTIFICATION_SETTING_INPUT")] [StructLayout(LayoutKind.Sequential)] public struct REAL_TIME_NOTIFICATION_SETTING_INPUT { /// The transport setting ID. public TRANSPORT_SETTING_ID TransportSettingId; /// The realtime notification broker event GUID for this transport ID. public Guid BrokerEventGuid; } /// /// The REAL_TIME_NOTIFICATION_SETTING_OUTPUT structure provides the output settings from a query for the /// REAL_TIME_NOTIFICATION_CAPABILITY transport setting for a TCP socket that is used with ControlChannelTrigger to receive /// background network notifications in a Windows Store app. /// /// /// /// The REAL_TIME_NOTIFICATION_SETTING_OUTPUT structure is supported on Windows 8, and Windows Server 2012, and later versions of the /// operating system. /// /// /// If the TRANSPORT_SETTING_ID in the lpvInBuffer parameter passed to the SIO_QUERY_TRANSPORT_SETTING IOCTL has the /// Guid member set to REAL_TIME_NOTIFICATION_CAPABILITY, then this is a request to query the real time notification /// settings for the TCP socket used with ControlChannelTrigger to receive background network notifications in a Windows Store app. /// If the WSAIoctl or LPWSPIoctl call is successful, this IOCTL returns a REAL_TIME_NOTIFICATION_SETTING_OUTPUT structure with the /// current status. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-real_time_notification_setting_output typedef struct // _REAL_TIME_NOTIFICATION_SETTING_OUTPUT { CONTROL_CHANNEL_TRIGGER_STATUS ChannelStatus; } REAL_TIME_NOTIFICATION_SETTING_OUTPUT, *PREAL_TIME_NOTIFICATION_SETTING_OUTPUT; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._REAL_TIME_NOTIFICATION_SETTING_OUTPUT")] [StructLayout(LayoutKind.Sequential)] public struct REAL_TIME_NOTIFICATION_SETTING_OUTPUT { /// The channel status for a socket that is used with the ControlChannelTrigger. public CONTROL_CHANNEL_TRIGGER_STATUS ChannelStatus; } /// /// The SOCKET_PEER_TARGET_NAME structure contains the IP address and name for a peer target and the type of security protocol /// to be used on a socket. /// /// /// The SOCKET_PEER_TARGET_NAME structure is supported on Windows Vista and later. /// /// The SOCKET_PEER_TARGET_NAME structure is used by the WSASetSocketPeerTargetName function to specify the peer target name /// that corresponds to a peer IP address. This target name is meant to be specified by client applications to securely identify the /// peer that should be authenticated. /// /// /// Currently, the only type of security protocol that is supported is IPsec. So specifying an enumeration value of /// SOCKET_SECURITY_PROTOCOL_DEFAULT has the same effect as specifying SOCKET_SECURITY_PROTOCOL_IPSEC in the /// SecurityProtocol member. /// /// /// The implementation of IPsec on Windows Vista and Windows Server 2008 only supports computer-to-computer and user-to-computer /// authentication. As a result, the peer target name specified in the AllStrings member of the SOCKET_PEER_TARGET_NAME /// structure should refer to the peer computer principal. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-socket_peer_target_name typedef struct // _SOCKET_PEER_TARGET_NAME { SOCKET_SECURITY_PROTOCOL SecurityProtocol; SOCKADDR_STORAGE PeerAddress; ULONG PeerTargetNameStringLen; // wchar_t AllStrings[0]; } SOCKET_PEER_TARGET_NAME; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._SOCKET_PEER_TARGET_NAME")] [StructLayout(LayoutKind.Sequential)] public struct SOCKET_PEER_TARGET_NAME { /// A SOCKET_SECURITY_PROTOCOL value that identifies the type of protocol used to secure the traffic on the socket. public SOCKET_SECURITY_PROTOCOL SecurityProtocol; /// The IP address of the peer for the socket. public SOCKADDR_STORAGE PeerAddress; /// The length, in bytes, of the peer target name in the AllStrings member. public uint PeerTargetNameStringLen; /// The peer target name for the socket. [MarshalAs(UnmanagedType.LPWStr, SizeConst = 0)] public string AllStrings; } /// /// The SOCKET_SECURITY_QUERY_INFO structure contains security information returned by the WSAQuerySocketSecurity function. /// /// /// The SOCKET_SECURITY_QUERY_INFO structure is supported on Windows Vista and later. /// /// The SOCKET_SECURITY_QUERY_INFO structure is used by the WSAQuerySocketSecurity function to return information about the /// security applied to a connection on a socket. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-socket_security_query_info typedef struct // _SOCKET_SECURITY_QUERY_INFO { SOCKET_SECURITY_PROTOCOL SecurityProtocol; ULONG Flags; UINT64 PeerApplicationAccessTokenHandle; // UINT64 PeerMachineAccessTokenHandle; } SOCKET_SECURITY_QUERY_INFO; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._SOCKET_SECURITY_QUERY_INFO")] [StructLayout(LayoutKind.Sequential)] public struct SOCKET_SECURITY_QUERY_INFO { /// A SOCKET_SECURITY_PROTOCOL value that identifies the protocol used to secure the traffic. public SOCKET_SECURITY_PROTOCOL SecurityProtocol; /// /// The set of possible security flags for the connection defined in the Mstcpip.h header file. /// /// /// Value /// Meaning /// /// /// SOCKET_INFO_CONNECTION_SECURED 0x00000001 /// If present, traffic is being secured by a security protocol. If absent, the traffic is flowing in the clear. /// /// /// SOCKET_INFO_CONNECTION_ENCRYPTED 0x00000002 /// /// If present, the connection traffic is being encrypted. The SOCKET_INFO_CONNECTION_SECURED flag is always set when this /// flag is present. /// /// /// /// public SOCKET_INFO_CONNECTION Flags; /// /// A handle to the access token that represents the account under which the peer application is running. After using the token /// for access checks, the application should close the handle using the CloseHandle function. /// public ulong PeerApplicationAccessTokenHandle; /// /// A handle to the access token for the peer computer's account during the course of the application. After using the token for /// access checks, the application should close the handle using the CloseHandle function. /// public ulong PeerMachineAccessTokenHandle; } /// /// The SOCKET_SECURITY_QUERY_TEMPLATE structure contains the security template used by the WSAQuerySocketSecurity function. /// /// /// The SOCKET_SECURITY_QUERY_TEMPLATE structure is supported on Windows Vista and later. /// /// The SOCKET_SECURITY_QUERY_TEMPLATE structure is used by the WSAQuerySocketSecurity function to specify the type of query /// information to return for a socket. The SOCKET_SECURITY_QUERY_TEMPLATE structure passed to the /// WSAQuerySocketSecurity function may contain zeros for all members to request default security information. /// /// /// If the SOCKET_SECURITY_QUERY_TEMPLATE structure is specified with the PeerTokenAccessMask member not specified (set /// to zero), then the WSAQuerySocketSecurity function will not return the PeerApplicationAccessTokenHandle and /// PeerMachineAccessTokenHandle members in the SOCKET_SECURITY_QUERY_INFO structure. /// /// /// Currently, the only type of security protocol that is supported is IPsec. So specifying an enumeration value of /// SOCKET_SECURITY_PROTOCOL_DEFAULT for the SecurityProtocol member has the same effect as specifying SOCKET_SECURITY_PROTOCOL_IPSEC. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-socket_security_query_template typedef struct // _SOCKET_SECURITY_QUERY_TEMPLATE { SOCKET_SECURITY_PROTOCOL SecurityProtocol; SOCKADDR_STORAGE PeerAddress; ULONG // PeerTokenAccessMask; } SOCKET_SECURITY_QUERY_TEMPLATE; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._SOCKET_SECURITY_QUERY_TEMPLATE")] [StructLayout(LayoutKind.Sequential)] public struct SOCKET_SECURITY_QUERY_TEMPLATE { /// A SOCKET_SECURITY_PROTOCOL value that identifies the protocol used to secure the traffic. public SOCKET_SECURITY_PROTOCOL SecurityProtocol; /// /// The IP address of the peer for which security information is being queried. For connection-oriented sockets (protocol of /// IPPROTO_TCP), the connected socket uniquely identifies a peer. In this case, this parameter is ignored. /// public SOCKADDR_STORAGE PeerAddress; /// /// The access mask used for opening the peer user application and computer token handles that are returned as part of the query information. /// public uint PeerTokenAccessMask; } /// The SOCKET_SECURITY_SETTINGS structure specifies generic security requirements for a socket. /// /// The SOCKET_SECURITY_SETTINGS structure is supported on Windows Vista and later. /// /// The SOCKET_SECURITY_SETTINGS structure is used by the WSASetSocketSecurity function to enable and apply security on a socket. /// /// /// Security settings not addressed in this structure are derived from the system default policy or the administratively configured /// policy. It is recommended that most applications specify a value of SOCKET_SECURITY_PROTOCOL_DEFAULT for the /// SOCKET_SECURITY_PROTOCOL enumeration in the SecurityProtocol member. This makes the application neutral to security /// protocols and allows easier deployments among different systems. /// /// /// Advanced applications can specify a security protocol and associated settings by casting them to the /// SOCKET_SECURITY_SETTINGS type. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-socket_security_settings typedef struct // _SOCKET_SECURITY_SETTINGS { SOCKET_SECURITY_PROTOCOL SecurityProtocol; ULONG SecurityFlags; } SOCKET_SECURITY_SETTINGS; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._SOCKET_SECURITY_SETTINGS")] [StructLayout(LayoutKind.Sequential)] public struct SOCKET_SECURITY_SETTINGS { /// A SOCKET_SECURITY_PROTOCOL value that identifies the type of security protocol to be used on the socket. public SOCKET_SECURITY_PROTOCOL SecurityProtocol; /// /// /// A set of flags that allow applications to set specific security requirements on a socket. The possible values are defined in /// the Mstcpip.h header file. /// /// /// /// Value /// Meaning /// /// /// SOCKET_SETTINGS_GUARANTEE_ENCRYPTION 0x00000001 /// /// Indicates that guaranteed encryption of traffic is required. This flag should be set if the default policy prefers methods of /// protection that do not use encryption. If this flag is set and encryption is not possible for any reason, no packets will be /// sent and a connection will not be established. /// /// /// /// SOCKET_SETTINGS_ALLOW_INSECURE 0x00000002 /// /// Indicates that clear text connections are allowed. If this flag is set, some or all of the sent packets will be sent in clear /// text, especially if security with the peer could not be negotiated. /// /// /// /// public SOCKET_SETTINGS SecurityFlags; } /// /// The SOCKET_SECURITY_SETTINGS_IPSEC structure specifies various security requirements and settings that are specific to IPsec. /// /// /// The SOCKET_SECURITY_SETTINGS_IPSEC structure is supported on Windows Vista and later. /// /// The SOCKET_SECURITY_SETTINGS_IPSEC structure is meant to be used by an advanced application that requires more flexibility /// and wishes to customize IPSec policy for their traffic. The pointer to the SOCKET_SECURITY_SETTINGS_IPSEC structure needs /// to cast to the SOCKET_SECURITY_SETTINGS structure type when calling the WSASetSocketSecurity function to enable and apply /// security on a socket. /// /// /// The SecurityProtocol member of the SOCKET_SECURITY_SETTINGS_IPSEC structure must be set to /// SOCKET_SECURITY_PROTOCOL_IPSEC, not SOCKET_SECURITY_PROTOCOL_DEFAULT. /// /// /// To simplify Internet Protocol security (IPsec) deployment, Windows Vista and later support an enhanced version of the Internet /// Key Exchange (IKE) protocol known as Authenticated Internet Protocol (AuthIP). AuthIP provides simplified IPsec policy /// configuration and maintenance in many configurations and additional flexibility for IPsec peer authentication. /// /// /// There is a possibility that some of the IPsec settings specified in the SOCKET_SECURITY_SETTINGS_IPSEC structure may end /// up being different from the actual settings applied to the network traffic on a socket. For example, this could happen when an /// application specifies custom main mode or quick mode policy, but a different policy with a higher priority (a domain policy, for /// example) specifies conflicting settings for the same traffic. To be aware of such conflicts, an application can use the Windows /// Filtering Platform API to query the policy being applied and subscribe for notifications. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-socket_security_settings_ipsec typedef struct // _SOCKET_SECURITY_SETTINGS_IPSEC { SOCKET_SECURITY_PROTOCOL SecurityProtocol; ULONG SecurityFlags; ULONG IpsecFlags; GUID // AuthipMMPolicyKey; GUID AuthipQMPolicyKey; GUID Reserved; UINT64 Reserved2; ULONG UserNameStringLen; ULONG DomainNameStringLen; // ULONG PasswordStringLen; wchar_t AllStrings[0]; } SOCKET_SECURITY_SETTINGS_IPSEC; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._SOCKET_SECURITY_SETTINGS_IPSEC")] [StructLayout(LayoutKind.Sequential)] public struct SOCKET_SECURITY_SETTINGS_IPSEC { /// /// Type: SOCKET_SECURITY_PROTOCOL /// /// A SOCKET_SECURITY_PROTOCOL value that identifies the type of security protocol to be used on the socket. This member must be /// set to SOCKET_SECURITY_PROTOCOL_IPSEC. /// /// public SOCKET_SECURITY_PROTOCOL SecurityProtocol; /// /// Type: ULONG /// /// A set of flags that allow applications to set specific security requirements on a socket. The possible values are defined in /// the Mstcpip.h header file. /// /// /// /// Value /// Meaning /// /// /// SOCKET_SETTINGS_GUARANTEE_ENCRYPTION 0x00000001 /// /// Indicates that guaranteed encryption of traffic is required. This flag should be set if the default policy prefers methods of /// protection that do not use encryption. If this flag is set and encryption is not possible for any reason, no packets will be /// sent and a connection will not be established. /// /// /// /// SOCKET_SETTINGS_ALLOW_INSECURE 0x00000002 /// /// Indicates that clear text connections are allowed. If this flag is set, some or all of the sent packets will be sent in clear /// text, especially if security with the peer could not be negotiated. /// /// /// /// public SOCKET_SETTINGS SecurityFlags; /// /// Type: ULONG /// Flags for IPsec security settings. The possible values are defined in the Mstcpip.h header file. /// /// /// Value /// Meaning /// /// /// SOCKET_SETTINGS_IPSEC_SKIP_FILTER_INSTANTIATION 0x00000001 /// /// When this flag is set, IPsec filter instantiation is omitted for the socket. This flag should be set when an application /// knows that IPsec filters and policy already exist for its traffic. Applications running on a domain with IPsec policy in /// place can also set this flag. /// /// /// /// public SOCKET_SETTINGS_IPSEC IpsecFlags; /// /// Type: GUID /// /// The GUID for the Windows Filtering Platform key of the AuthIP main mode provider context. If an application wishes to use a /// custom main mode policy, it should first use the FwpmProviderContextAdd0 function to add the corresponding provider context /// and specify the returned key in this member. This field is ignored for a GUID of zero. /// /// public Guid AuthipMMPolicyKey; /// /// Type: GUID /// /// The Windows Filtering Platform key of the AuthIp quick mode provider context. If an application wishes to use a custom quick /// mode policy, it should first use the FwpmProviderContextAdd0 function to add the corresponding provider context and specify /// the returned key in this field. This field is ignored for a GUID of zero. /// /// public Guid AuthipQMPolicyKey; /// /// Type: GUID /// Reserved for future use. /// public Guid Reserved; /// /// Type: UINT64 /// Reserved for future use. /// public ulong Reserved2; /// /// Type: ULONG /// The length, in bytes, of the user name in the AllStrings member. /// public uint UserNameStringLen; /// /// Type: ULONG /// The length, in bytes, of the domain name in the AllStrings member. /// public uint DomainNameStringLen; /// /// Type: ULONG /// The length, in bytes, of the password in the AllStrings member. /// public uint PasswordStringLen; /// /// Type: wchar_t[] /// A string that contains the user name, the domain name, and the password concatenated in this order. /// [MarshalAs(UnmanagedType.LPWStr, SizeConst = 0)] public string AllStrings; } /// Contains the Transmission Control Protocol (TCP) statistics that were collected for a socket. /// /// To get an instance of this structure, call the WSAIoctl or LPWSPIoctl function with the SIO_TCP_INFO control code. Specify 0 for /// the lpvInBuffer field to retrieve the v0 version of this structure. /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-tcp_info_v0 typedef struct _TCP_INFO_v0 { TCPSTATE State; // ULONG Mss; ULONG64 ConnectionTimeMs; BOOLEAN TimestampsEnabled; ULONG RttUs; ULONG MinRttUs; ULONG BytesInFlight; ULONG Cwnd; // ULONG SndWnd; ULONG RcvWnd; ULONG RcvBuf; ULONG64 BytesOut; ULONG64 BytesIn; ULONG BytesReordered; ULONG BytesRetrans; ULONG // FastRetrans; ULONG DupAcksIn; ULONG TimeoutEpisodes; UCHAR SynRetrans; } TCP_INFO_v0, *PTCP_INFO_v0; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._TCP_INFO_v0")] [StructLayout(LayoutKind.Sequential)] public struct TCP_INFO_v0 { /// A value from the TCPSTATE enumeration that indicates the state of the TCP connection. public TCPSTATE State; /// The current maximum segment size (MSS) for the connection, in bytes. public uint Mss; /// The lifetime of the connection, in milliseconds. public ulong ConnectionTimeMs; /// TRUE if TCP time stamps are turned on for the connection; otherwise FALSE. [MarshalAs(UnmanagedType.U1)] public bool TimestampsEnabled; /// The current estimated round-trip time for the connection, in microseconds. public uint RttUs; /// The minimum sampled round trip time, in microseconds. public uint MinRttUs; /// The current number of sent bytes that are unacknowledged. public uint BytesInFlight; /// The size of the current congestion window, in bytes. public uint Cwnd; /// The size of the send window (SND.WND in RFC 793), in bytes. public uint SndWnd; /// The size of the receive window (RCV.WND in RFC 793), in bytes. public uint RcvWnd; /// /// The size of the current receive buffer, in bytes. The size of the receive buffer changes dynamically when autotuning is /// turned on for the receive window. /// public uint RcvBuf; /// The total number of bytes sent. public ulong BytesOut; /// The total number of bytes received. public ulong BytesIn; /// The total number of bytes reordered. public uint BytesReordered; /// The total number of bytes retransmitted. public uint BytesRetrans; /// The number of calls of the Fast Retransmit algorithm. public uint FastRetrans; /// The total number of duplicate acknowledgments received. public uint DupAcksIn; /// The total number of retransmission timeout episodes. Each episode can consist of multiple timeouts. public uint TimeoutEpisodes; /// The total number of retransmitted synchronize control flags (SYNs). public byte SynRetrans; } /// /// Contains the Transmission Control Protocol (TCP) statistics that were collected for a socket. Version 1.0 of this structure /// provides additional fields. /// /// /// To get an instance of this structure, call the WSAIoctl or LPWSPIoctl function with the SIO_TCP_INFO control code. Specify 1 for /// the lpvInBuffer field to retrieve the v1 version of this structure. /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-tcp_info_v1 typedef struct _TCP_INFO_v1 { TCPSTATE State; // ULONG Mss; ULONG64 ConnectionTimeMs; BOOLEAN TimestampsEnabled; ULONG RttUs; ULONG MinRttUs; ULONG BytesInFlight; ULONG Cwnd; // ULONG SndWnd; ULONG RcvWnd; ULONG RcvBuf; ULONG64 BytesOut; ULONG64 BytesIn; ULONG BytesReordered; ULONG BytesRetrans; ULONG // FastRetrans; ULONG DupAcksIn; ULONG TimeoutEpisodes; UCHAR SynRetrans; ULONG SndLimTransRwin; ULONG SndLimTimeRwin; ULONG64 // SndLimBytesRwin; ULONG SndLimTransCwnd; ULONG SndLimTimeCwnd; ULONG64 SndLimBytesCwnd; ULONG SndLimTransSnd; ULONG SndLimTimeSnd; // ULONG64 SndLimBytesSnd; } TCP_INFO_v1, *PTCP_INFO_v1; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._TCP_INFO_v1")] [StructLayout(LayoutKind.Sequential)] public struct TCP_INFO_v1 { /// Contains the Transmission Control Protocol (TCP) statistics that were collected for a socket. public TCPSTATE State; /// The current maximum segment size (MSS) for the connection, in bytes. public uint Mss; /// The lifetime of the connection, in milliseconds. public ulong ConnectionTimeMs; /// TRUE if TCP time stamps are turned on for the connection; otherwise FALSE. [MarshalAs(UnmanagedType.U1)] public bool TimestampsEnabled; /// The current estimated round-trip time for the connection, in microseconds. public uint RttUs; /// The minimum sampled round trip time, in microseconds. public uint MinRttUs; /// The current number of sent bytes that are unacknowledged. public uint BytesInFlight; /// The size of the current congestion window, in bytes. public uint Cwnd; /// The size of the send window (SND.WND in RFC 793), in bytes. public uint SndWnd; /// The size of the receive window (RCV.WND in RFC 793), in bytes. public uint RcvWnd; /// /// The size of the current receive buffer, in bytes. The size of the receive buffer changes dynamically when autotuning is /// turned on for the receive window. /// public uint RcvBuf; /// The total number of bytes sent. public ulong BytesOut; /// The total number of bytes received. public ulong BytesIn; /// The total number of bytes reordered. public uint BytesReordered; /// The total number of bytes retransmitted. public uint BytesRetrans; /// The number of calls of the Fast Retransmit algorithm. public uint FastRetrans; /// The total number of duplicate acknowledgments received. public uint DupAcksIn; /// The total number of retransmission timeout episodes. Each episode can consist of multiple timeouts. public uint TimeoutEpisodes; /// The total number of retransmitted synchronize control flags (SYNs). public byte SynRetrans; /// /// The number of transitions into the "Receiver Limited" state from either the "Congestion Limited" or "Sender Limited" states. /// public uint SndLimTransRwin; /// /// The cumulative time, in milliseconds, spent in the "Receiver Limited" state where TCP transmission stops because the sender /// has filled the announced receiver window. /// public uint SndLimTimeRwin; /// The total number of bytes sent in the "Receiver Limited" state. public ulong SndLimBytesRwin; /// /// The number of transitions into the "Congestion Limited" state from either the "Receiver Limited" or "Sender Limited" states. /// public uint SndLimTransCwnd; /// /// The cumulative time, in milliseconds, spent in the "Congestion Limited" state. When there is a retransmission timeout, it is /// counted in this member and not the cumulative time for some other state. /// public uint SndLimTimeCwnd; /// The total number of bytes sent in the "Congestion Limited" state. public ulong SndLimBytesCwnd; /// /// The number of transitions into the "Sender Limited" state from either the "Receiver Limited" or "Congestion Limited" states. /// public uint SndLimTransSnd; /// The cumulative time, in milliseconds, spent in the "Sender Limited" state. public uint SndLimTimeSnd; /// The total number of bytes sent in the "Sender Limited" state. public ulong SndLimBytesSnd; } /// /// The TCP_INITIAL_RTO_PARAMETERS structure specifies data used by the SIO_TCP_INITIAL_RTO IOCTL to configure initial /// re-transmission timeout (RTO) parameters to be used on the socket. /// /// /// /// The TCP_INITIAL_RTO_PARAMETERS structure allows an application to configure the initial round trip time (RTT) used to compute the /// retransmission timeout. The application can also configure the number of re-transmissions that will be attempted before the /// connection attempt fails. /// /// /// An application should supply the RTT of choice in milliseconds and the maximum number of retransmissions in this structure. The /// Windows TCP/IP stack will honor these parameters for the subsequent connection attempt. The retransmission behavior for TCP is /// documented in IETF RFC 793 and 2988. /// /// /// An application may use the unspecified defines, TCP_INITIAL_RTO_UNSPECIFIED_RTT and /// TCP_INITIAL_RTO_UNSPECIFIED_MAX_SYN_RETRANSMISSIONS when supplying values for one of these fields. This allows the system /// to pick up administrator configured settings for the parameter left unspecified. /// /// /// An application can choose system defaults for any of these fields and supply those values using the default defines, /// TCP_INITIAL_RTO_DEFAULT_RTT and TCP_INITIAL_RTO_DEFAULT_MAX_SYN_RETRANSMISSIONS. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-tcp_initial_rto_parameters typedef struct // _TCP_INITIAL_RTO_PARAMETERS { USHORT Rtt; UCHAR MaxSynRetransmissions; } TCP_INITIAL_RTO_PARAMETERS, *PTCP_INITIAL_RTO_PARAMETERS; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._TCP_INITIAL_RTO_PARAMETERS")] [StructLayout(LayoutKind.Sequential)] public struct TCP_INITIAL_RTO_PARAMETERS { /// Supplies the initial RTT in milliseconds. public ushort Rtt; /// Supplies the number of retransmissions attempted before the connection setup fails. public byte MaxSynRetransmissions; } /// Argument structure for SIO_KEEPALIVE_VALS [PInvokeData("mstcpip.h")] [StructLayout(LayoutKind.Sequential)] public struct tcp_keepalive { /// /// Determines if TCP keep-alive is enabled or disabled. If the onoff member is set to a nonzero value, TCP keep-alive is enabled /// and the other members in the structure are used. /// public BOOL onoff; /// Specifies the timeout, in milliseconds, with no activity until the first keep-alive packet is sent. public uint keepalivetime; /// /// Specifies the interval, in milliseconds, between when successive keep-alive packets are sent if no acknowledgement is received. /// public uint keepaliveinterval; } /// /// Describes the input structure used by the SIO_TIMESTAMPING configuration IOCTL to configure timestamp reception for a datagram socket. /// // https://docs.microsoft.com/en-us/windows/win32/api/mstcpip/ns-mstcpip-timestamping_config typedef struct _TIMESTAMPING_CONFIG { // ULONG Flags; USHORT TxTimestampsBuffered; } TIMESTAMPING_CONFIG, *PTIMESTAMPING_CONFIG; [PInvokeData("mstcpip.h", MSDNShortId = "NS:mstcpip._TIMESTAMPING_CONFIG")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct TIMESTAMPING_CONFIG { /// /// Type: ULONG /// Enable/disable timestamp reception for rx/tx direction. /// /// Use the values TIMESTAMPING_FLAG_RX (0x1) and TIMESTAMPING_FLAG_TX (0x2) (both defined in mstcpip.h ). /// Specify a value to enable timestamp reception for that direction; and omit a value to disable timestamp reception for that direction. /// /// public TIMESTAMPING_FLAG Flags; /// /// Type: USHORT /// /// Determines how many tx timestamps may be buffered. When the count of tx timestamps that have been buffered reaches a value /// equal to TxTimestampsBuffered, and a new tx timestamp has been generated, the new timestamp will be discarded. /// /// public ushort TxTimestampsBuffered; } /// /// The TRANSPORT_SETTING_ID structure specifies the transport setting ID used by the SIO_APPLY_TRANSPORT_SETTING and /// SIO_QUERY_TRANSPORT_SETTING IOCTLs to apply or query the transport setting for a socket. /// /// /// /// The only transport setting defined for Windows 8 and Windows Server 2012 is for the REAL_TIME_NOTIFICATION_CAPABILITY /// capability on a TCP socket. For Windows 10 and Windows Server 2016, there is another transport setting defined as ASSOCIATE_NAMERES_CONTEXT. /// /// /// The TRANSPORT_SETTING_ID structure is passed as input to the SIO_APPLY_TRANSPORT_SETTING and SIO_QUERY_TRANSPORT_SETTING /// IOCTLs. The Guid member determines what transport setting is applied or queried. /// /// The only transport setting currently defines is for the REAL_TIME_NOTIFICATION_CAPABILITY capability on a TCP socket. /// // https://docs.microsoft.com/en-us/windows/win32/api/transportsettingcommon/ns-transportsettingcommon-transport_setting_id typedef // struct TRANSPORT_SETTING_ID { GUID Guid; } TRANSPORT_SETTING_ID, *PTRANSPORT_SETTING_ID; [PInvokeData("transportsettingcommon.h", MSDNShortId = "NS:transportsettingcommon.TRANSPORT_SETTING_ID")] [StructLayout(LayoutKind.Sequential)] public struct TRANSPORT_SETTING_ID { /// The transport setting ID. public Guid Guid; } }