using System; using System.ComponentModel; using System.Runtime.InteropServices; using Vanara.InteropServices; using static Vanara.PInvoke.Ws2_32; using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME; namespace Vanara.PInvoke { public static partial class IpHlpApi { /// /// The TCP_CONNECTION_OFFLOAD_STATE enumeration defines the possible TCP offload states for a TCP connection. /// /// /// The TCP_CONNECTION_OFFLOAD_STATE enumeration is defined on Windows Server 2003 and later. /// /// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files /// has changed and the TCP_CONNECTION_OFFLOAD_STATE enumeration is defined in the Tcpmib.h header file not in the Iprtrmib.h /// header file. Note that the Tcpmib.h header file is automatically included in Iprtrmib.h which is automatically included in the /// Iphlpapi.h header file. The Tcpmib.h and Iprtrmib.h header files should never be used directly. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ne-tcpmib-tcp_connection_offload_state typedef enum // TCP_CONNECTION_OFFLOAD_STATE { TcpConnectionOffloadStateInHost , TcpConnectionOffloadStateOffloading , // TcpConnectionOffloadStateOffloaded , TcpConnectionOffloadStateUploading , TcpConnectionOffloadStateMax } *PTCP_CONNECTION_OFFLOAD_STATE; [PInvokeData("tcpmib.h", MSDNShortId = "cef633e7-1577-4f10-bd14-8d8e85aa78e6")] public enum TCP_CONNECTION_OFFLOAD_STATE { /// The TCP connection is currently owned by the network stack on the local computer, and is not offloaded TcpConnectionOffloadStateInHost = 0, /// The TCP connection is in the process of being offloaded, but the offload has not been completed. TcpConnectionOffloadStateOffloading, /// The TCP connection is offloaded to the network interface controller. TcpConnectionOffloadStateOffloaded, /// /// The TCP connection is in the process of being uploaded back to the network stack on the local computer, but the /// reinstate-to-host process has not completed. /// TcpConnectionOffloadStateUploading, /// /// The maximum possible value for the TCP_CONNECTION_OFFLOAD_STATE enumeration type. This is not a legal value for the possible /// TCP connection offload state. /// TcpConnectionOffloadStateMax, } /// The TCP_RTO_ALGORITHM enumerates different TCP retransmission time-out algorithms. [PInvokeData("tcpmib.h", MSDNShortId = "cc669306")] public enum TCP_RTO_ALGORITHM { /// Other. TcpRtoAlgorithmOther = 1, /// Constant time-out. TcpRtoAlgorithmConstant = 2, /// MIL-STD-1778. See [RFC4022]. TcpRtoAlgorithmRsre = 3, /// Van Jacobson's algorithm. See [RFC1144]. TcpRtoAlgorithmVanj = 4, /// Other. MIB_TCP_RTO_OTHER = 1, /// Constant time-out. MIB_TCP_RTO_CONSTANT = 2, /// MIL-STD-1778. See [RFC4022]. MIB_TCP_RTO_RSRE = 3, /// Van Jacobson's algorithm. See [RFC1144]. MIB_TCP_RTO_VANJ = 4, } /// /// The MIB_TCP6ROW structure contains information that describes an IPv6 TCP connection. /// /// /// The MIB_TCP6ROW structure is defined on Windows Vista and later. /// /// The GetTcp6Table function retrieves the IPv6 TCP connection table on the local computer and returns this information in a /// MIB_TCP6TABLE structure. /// /// An array of MIB_TCP6ROW structures are contained in the MIB_TCP6TABLE structure. /// /// The State member indicates the state of the TCP entry in a TCP state diagram. A TCP connection progresses through a series /// of states during its lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, /// CLOSING, LAST-ACK, TIME-WAIT, and the fictional state CLOSED. The CLOSED state is fictional because it represents the state when /// there is no Transmission Control Block, and therefore, no connection. The TCP protocol is described in RFC 793. For more /// information, see http://www.ietf.org/rfc/rfc793.txt. /// /// /// The dwLocalPort, and dwRemotePort members are in network byte order. In order to use the dwLocalPort or /// dwRemotePort members, the ntohs or inet_ntoa functions in Windows Sockets or similar functions may be needed. /// /// /// The dwLocalScopeId, and dwRemoteScopeId members are in network byte order. In order to use the /// dwLocalScopeId or dwRemoteScopeId members, the ntohl or inet_ntoa functions in Windows Sockets or similar functions /// may be needed. /// /// /// The LocalAddr and RemoteAddr members are stored in in6_addr structures. The RtlIpv6AddressToString or /// RtlIpv6AddressToStringEx functions may be used to convert the IPv6 address in the LocalAddr or RemoteAddr members /// to a string without loading the Windows Sockets DLL. /// /// Examples /// /// The following example retrieves the TCP connection table for IPv6 and prints the state of each connection represented as a /// MIB_TCP6ROW structure. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcp6row typedef struct _MIB_TCP6ROW { // MIB_TCP_STATE State; IN6_ADDR LocalAddr; DWORD dwLocalScopeId; DWORD dwLocalPort; IN6_ADDR RemoteAddr; DWORD dwRemoteScopeId; // DWORD dwRemotePort; } MIB_TCP6ROW, *PMIB_TCP6ROW; [PInvokeData("tcpmib.h", MSDNShortId = "b3e9eda5-5e86-4790-8b1b-ca9bae44b502")] [StructLayout(LayoutKind.Sequential)] public struct MIB_TCP6ROW { /// /// Type: MIB_TCP_STATE /// /// The state of the TCP connection. This member can be one of the values from the MIB_TCP_STATE enumeration type defined /// in the Tcpmib.h header file. /// /// /// /// Value /// Meaning /// /// /// MIB_TCP_STATE_CLOSED 1 /// The TCP connection is in the CLOSED state that represents no connection state at all. /// /// /// MIB_TCP_STATE_LISTEN 2 /// The TCP connection is in the LISTEN state waiting for a connection request from any remote TCP and port. /// /// /// MIB_TCP_STATE_SYN_SENT 3 /// /// The TCP connection is in the SYN-SENT state waiting for a matching connection request after having sent a connection request /// (SYN packet). /// /// /// /// MIB_TCP_STATE_SYN_RCVD 4 /// /// The TCP connection is in the SYN-RECEIVED state waiting for a confirming connection request acknowledgment after having both /// received and sent a connection request (SYN packet). /// /// /// /// MIB_TCP_STATE_ESTAB 5 /// /// The TCP connection is in the ESTABLISHED state that represents an open connection, data received can be delivered to the /// user. This is the normal state for the data transfer phase of the TCP connection. /// /// /// /// MIB_TCP_STATE_FIN_WAIT1 6 /// /// The TCP connection is FIN-WAIT-1 state waiting for a connection termination request from the remote TCP, or an acknowledgment /// of the connection termination request previously sent. /// /// /// /// MIB_TCP_STATE_FIN_WAIT2 7 /// The TCP connection is FIN-WAIT-1 state waiting for a connection termination request from the remote TCP. /// /// /// MIB_TCP_STATE_CLOSE_WAIT 8 /// The TCP connection is in the CLOSE-WAIT state waiting for a connection termination request from the local user. /// /// /// MIB_TCP_STATE_CLOSING 9 /// /// The TCP connection is in the CLOSING state waiting for a connection termination request acknowledgment from the remote TCP. /// /// /// /// MIB_TCP_STATE_LAST_ACK 10 /// /// The TCP connection is in the LAST-ACK state waiting for an acknowledgment of the connection termination request previously /// sent to the remote TCP (which includes an acknowledgment of its connection termination request). /// /// /// /// MIB_TCP_STATE_TIME_WAIT 11 /// /// The TCP connection is in the TIME-WAIT state waiting for enough time to pass to be sure the remote TCP received the /// acknowledgment of its connection termination request. /// /// /// /// MIB_TCP_STATE_DELETE_TCB 12 /// /// The TCP connection is in the delete TCB state that represents the deletion of the Transmission Control Block (TCB), a data /// structure used to maintain information on each TCP entry. /// /// /// /// public MIB_TCP_STATE dwState; /// /// Type: IN6_ADDR /// /// The local IPv6 address for the TCP connection on the local computer. A value of zero indicates the listener can accept a /// connection on any interface. /// /// public IN6_ADDR LocalAddr; /// /// Type: DWORD /// The local scope ID for the TCP connection on the local computer. /// public uint dwLocalScopeId; /// /// Type: DWORD /// The local port number in network byte order for the TCP connection on the local computer. /// /// The maximum size of an IP port number is 16 bits, so only the lower 16 bits should be used. The upper 16 bits may contain /// uninitialized data. /// /// public uint dwLocalPort; /// /// Type: IN6_ADDR /// /// The IPv6 address for the TCP connection on the remote computer. When the State member is MIB_TCP_STATE_LISTEN, /// this value has no meaning. /// /// public IN6_ADDR RemoteAddr; /// /// Type: DWORD /// /// The remote scope ID for the TCP connection on the remote computer. When the State member is /// MIB_TCP_STATE_LISTEN, this value has no meaning. /// /// public uint dwRemoteScopeId; /// /// Type: DWORD /// /// The remote port number in network byte order for the TCP connection on the remote computer. When the State member is /// MIB_TCP_STATE_LISTEN, this value has no meaning. /// /// /// The maximum size of an IP port number is 16 bits, so only the lower 16 bits should be used. The upper 16 bits may contain /// uninitialized data. /// /// public uint dwRemotePort; } /// /// /// The MIB_TCP6ROW_OWNER_MODULE structure contains information that describes an IPv6 TCP connection bound to a specific /// process ID (PID) with ownership data. /// /// /// /// /// The MIB_TCP6TABLE_OWNER_MODULE structure is returned by a call to GetExtendedTcpTable with the TableClass parameter set to a /// TCP_TABLE_OWNER_MODULE_LISTENER, TCP_TABLE_OWNER_MODULE_CONNECTIONS, or TCP_TABLE_OWNER_MODULE_ALL from the /// TCP_TABLE_CLASS enumeration and the ulAf parameter set to AF_INET6. The MIB_TCP6TABLE_OWNER_MODULE structure /// contains an array of MIB_TCP6ROW_OWNER_MODULE structures. /// /// /// The dwState member indicates the state of the TCP entry in a TCP state diagram. A TCP connection progresses through a /// series of states during its lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, /// CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT, and the fictional state CLOSED. The CLOSED state is fictional because it represents the /// state when there is no Transmission Control Block, and therefore, no connection. The TCP protocol is described in RFC 793. For /// more information, see http://www.ietf.org/rfc/rfc793.txt. /// /// /// The ucLocalAddr and ucRemoteAddr members are stored in a character array in network byte order. The /// RtlIpv6AddressToString or RtlIpv6AddressToStringEx functions may be used to convert the IPv6 address in the ucLocalAddr or /// ucRemoteAddr members to a string without loading the Windows Sockets DLL. /// /// /// The dwLocalScopeId, and dwRemoteScopeId members are in network byte order. In order to use the /// dwLocalScopeId or dwRemoteScopeId members, the ntohl or inet_ntoa functions in Windows Sockets or similar functions /// may be needed. /// /// /// The dwLocalPort and dwRemotePort members are in network byte order. In order to use the dwLocalPort or /// dwRemotePort members, the ntohs or inet_ntoa functions in Windows Sockets or similar functions may be needed. /// /// /// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files /// has changed. This structure is defined in the Tcpmib.h header file, not in the Iprtrmib.h header file. Note that the Tcpmib.h /// header file is automatically included in Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Tcpmib.h /// and Iprtrmib.h header files should never be used directly. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcp6row_owner_module typedef struct // _MIB_TCP6ROW_OWNER_MODULE { UCHAR ucLocalAddr[16]; DWORD dwLocalScopeId; DWORD dwLocalPort; UCHAR ucRemoteAddr[16]; DWORD // dwRemoteScopeId; DWORD dwRemotePort; DWORD dwState; DWORD dwOwningPid; LARGE_INTEGER liCreateTimestamp; ULONGLONG // OwningModuleInfo[TCPIP_OWNING_MODULE_SIZE]; } MIB_TCP6ROW_OWNER_MODULE, *PMIB_TCP6ROW_OWNER_MODULE; [PInvokeData("tcpmib.h", MSDNShortId = "24f2041c-0a8c-4f2c-8585-ebbb0cad394f")] [StructLayout(LayoutKind.Sequential)] public struct MIB_TCP6ROW_OWNER_MODULE { /// /// Type: UCHAR[16] /// /// The IPv6 address for the local endpoint of the TCP connection on the local computer. A value of zero indicates the listener /// can accept a connection on any interface. /// /// public IN6_ADDR ucLocalAddr; /// /// Type: DWORD /// The scope ID in network byte order for the local IPv6 address. /// public uint dwLocalScopeId; /// /// Type: DWORD /// The port number in network byte order for the local endpoint of the TCP connection on the local computer. /// public uint dwLocalPort; /// /// Type: UCHAR[16] /// /// The IPv6 address of the remote endpoint of the TCP connection on the remote computer. When the dwState member is /// MIB_TCP_STATE_LISTEN, this value has no meaning. /// /// public IN6_ADDR ucRemoteAddr; /// /// Type: DWORD /// The scope ID in network byte order for the remote IPv6 address. /// public uint dwRemoteScopeId; /// /// Type: DWORD /// The port number in network byte order for the remote endpoint of the TCP connection on the remote computer. /// public uint dwRemotePort; /// /// Type: DWORD /// /// The state of the TCP connection. This member can be one of the values from the MIB_TCP_STATE enumeration defined in /// the Tcpmib.h header file. Note that the Tcpmib.h header file is automatically included in Iprtrmib.h, which is automatically /// included in the Iphlpapi.h header file. The Tcpmib.h and Iprtrmib.h header files should never be used directly. /// /// /// /// Value /// Meaning /// /// /// MIB_TCP_STATE_CLOSED 1 /// The TCP connection is in the CLOSED state that represents no connection state at all. /// /// /// MIB_TCP_STATE_LISTEN 2 /// The TCP connection is in the LISTEN state waiting for a connection request from any remote TCP and port. /// /// /// MIB_TCP_STATE_SYN_SENT 3 /// /// The TCP connection is in the SYN-SENT state waiting for a matching connection request after having sent a connection request /// (SYN packet). /// /// /// /// MIB_TCP_STATE_SYN_RCVD 4 /// /// The TCP connection is in the SYN-RECEIVED state waiting for a confirming connection request acknowledgment after having both /// received and sent a connection request (SYN packet). /// /// /// /// MIB_TCP_STATE_ESTAB 5 /// /// The TCP connection is in the ESTABLISHED state that represents an open connection, data received can be delivered to the /// user. This is the normal state for the data transfer phase of the TCP connection. /// /// /// /// MIB_TCP_STATE_FIN_WAIT1 6 /// /// The TCP connection is FIN-WAIT-1 state waiting for a connection termination request from the remote TCP, or an acknowledgment /// of the connection termination request previously sent. /// /// /// /// MIB_TCP_STATE_FIN_WAIT2 7 /// The TCP connection is FIN-WAIT-1 state waiting for a connection termination request from the remote TCP. /// /// /// MIB_TCP_STATE_CLOSE_WAIT 8 /// The TCP connection is in the CLOSE-WAIT state waiting for a connection termination request from the local user. /// /// /// MIB_TCP_STATE_CLOSING 9 /// /// The TCP connection is in the CLOSING state waiting for a connection termination request acknowledgment from the remote TCP. /// /// /// /// MIB_TCP_STATE_LAST_ACK 10 /// /// The TCP connection is in the LAST-ACK state waiting for an acknowledgment of the connection termination request previously /// sent to the remote TCP (which includes an acknowledgment of its connection termination request). /// /// /// /// MIB_TCP_STATE_TIME_WAIT 11 /// /// The TCP connection is in the TIME-WAIT state waiting for enough time to pass to be sure the remote TCP received the /// acknowledgment of its connection termination request. /// /// /// /// MIB_TCP_STATE_DELETE_TCB 12 /// /// The TCP connection is in the delete TCB state that represents the deletion of the Transmission Control Block (TCB), a data /// structure used to maintain information on each TCP entry. /// /// /// /// public MIB_TCP_STATE dwState; /// /// Type: DWORD /// The PID of the local process that issued a context bind for this TCP connection. /// public uint dwOwningPid; /// /// Type: LARGE_INTEGER /// A SYSTEMTIME structure that indicates when the context bind operation that created this TCP connection occurred. /// public SYSTEMTIME liCreateTimestamp; /// /// Type: ULONGLONG[TCPIP_OWNING_MODULE_SIZE] /// An array of opaque data that contains ownership information. /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = TCPIP_OWNING_MODULE_SIZE)] public ulong[] OwningModuleInfo; } /// /// /// The MIB_TCP6ROW_OWNER_PID structure contains information that describes an IPv6 TCP connection associated with a specific /// process ID (PID). /// /// /// /// /// The MIB_TCP6TABLE_OWNER_PID structure is returned by a call to GetExtendedTcpTable with the TableClass parameter set to /// TCP_TABLE_OWNER_PID_LISTENER, TCP_TABLE_OWNER_PID_CONNECTIONS, or TCP_TABLE_OWNER_PID_ALL from the /// TCP_TABLE_CLASS enumeration and the ulAf parameter set to AF_INET6. The MIB_TCP6TABLE_OWNER_PID structure contains /// an array of MIB_TCP6ROW_OWNER_PID structures. /// /// /// The dwState member indicates the state of the TCP entry in a TCP state diagram. A TCP connection progresses through a /// series of states during its lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, /// CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT, and the fictional state CLOSED. The CLOSED state is fictional because it represents the /// state when there is no Transmission Control Block, and therefore, no connection. The TCP protocol is described in RFC 793. For /// more information, see http://www.ietf.org/rfc/rfc793.txt. /// /// /// The dwLocalPort, and dwRemotePort members are in network byte order. In order to use the dwLocalPort or /// dwRemotePort members, the ntohs or inet_ntoa functions in Windows Sockets or similar functions may be needed. /// /// /// The dwLocalScopeId, and dwRemoteScopeId members are in network byte order. In order to use the /// dwLocalScopeId or dwRemoteScopeId members, the ntohl or inet_ntoa functions in Windows Sockets or similar functions /// may be needed. /// /// /// The ucLocalAddr and ucRemoteAddr members are stored in a character array in network byte order. The /// RtlIpv6AddressToString or RtlIpv6AddressToStringEx functions may be used to convert the IPv6 address in the ucLocalAddr or /// ucRemoteAddr members to a string without loading the Windows Sockets DLL. /// /// /// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files /// has changed. This structure is defined in the Tcpmib.h header file, not in the Iprtrmib.h header file. Note that the Tcpmib.h /// header file is automatically included in Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Tcpmib.h /// and Iprtrmib.h header files should never be used directly. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcp6row_owner_pid typedef struct // _MIB_TCP6ROW_OWNER_PID { UCHAR ucLocalAddr[16]; DWORD dwLocalScopeId; DWORD dwLocalPort; UCHAR ucRemoteAddr[16]; DWORD // dwRemoteScopeId; DWORD dwRemotePort; DWORD dwState; DWORD dwOwningPid; } MIB_TCP6ROW_OWNER_PID, *PMIB_TCP6ROW_OWNER_PID; [PInvokeData("tcpmib.h", MSDNShortId = "d0c9c783-c095-487e-a007-8a10700f9fea")] [StructLayout(LayoutKind.Sequential)] public struct MIB_TCP6ROW_OWNER_PID { /// /// Type: UCHAR[16] /// /// The IPv6 address for the local endpoint of the TCP connection on the local computer. A value of zero indicates the listener /// can accept a connection on any interface. /// /// public IN6_ADDR ucLocalAddr; /// /// Type: DWORD /// The scope ID in network byte order for the local IPv6 address. /// public uint dwLocalScopeId; /// /// Type: DWORD /// The port number in network byte order for the local endpoint of the TCP connection on the local computer. /// public uint dwLocalPort; /// /// Type: UCHAR[16] /// /// The IPv6 address of the remote endpoint of the TCP connection on the remote computer. When the dwState member is /// MIB_TCP_STATE_LISTEN, this value has no meaning. /// /// public IN6_ADDR ucRemoteAddr; /// /// Type: DWORD /// The scope ID in network byte order for the remote IPv6 address. /// public uint dwRemoteScopeId; /// /// Type: DWORD /// The port number in network byte order for the remote endpoint of the TCP connection on the remote computer. /// public uint dwRemotePort; /// /// Type: DWORD /// /// The state of the TCP connection. This member can be one of the values from the MIB_TCP_STATE enumeration defined in /// the Tcpmib.h header file. Note that the Tcpmib.h header file is automatically included in Iprtrmib.h, which is automatically /// included in the Iphlpapi.h header file. The Tcpmib.h and Iprtrmib.h header files should never be used directly. /// /// /// /// Value /// Meaning /// /// /// MIB_TCP_STATE_CLOSED 1 /// The TCP connection is in the CLOSED state that represents no connection state at all. /// /// /// MIB_TCP_STATE_LISTEN 2 /// The TCP connection is in the LISTEN state waiting for a connection request from any remote TCP and port. /// /// /// MIB_TCP_STATE_SYN_SENT 3 /// /// The TCP connection is in the SYN-SENT state waiting for a matching connection request after having sent a connection request /// (SYN packet). /// /// /// /// MIB_TCP_STATE_SYN_RCVD 4 /// /// The TCP connection is in the SYN-RECEIVED state waiting for a confirming connection request acknowledgment after having both /// received and sent a connection request (SYN packet). /// /// /// /// MIB_TCP_STATE_ESTAB 5 /// /// The TCP connection is in the ESTABLISHED state that represents an open connection, data received can be delivered to the /// user. This is the normal state for the data transfer phase of the TCP connection. /// /// /// /// MIB_TCP_STATE_FIN_WAIT1 6 /// /// The TCP connection is FIN-WAIT-1 state waiting for a connection termination request from the remote TCP, or an acknowledgment /// of the connection termination request previously sent. /// /// /// /// MIB_TCP_STATE_FIN_WAIT2 7 /// The TCP connection is FIN-WAIT-1 state waiting for a connection termination request from the remote TCP. /// /// /// MIB_TCP_STATE_CLOSE_WAIT 8 /// The TCP connection is in the CLOSE-WAIT state waiting for a connection termination request from the local user. /// /// /// MIB_TCP_STATE_CLOSING 9 /// /// The TCP connection is in the CLOSING state waiting for a connection termination request acknowledgment from the remote TCP. /// /// /// /// MIB_TCP_STATE_LAST_ACK 10 /// /// The TCP connection is in the LAST-ACK state waiting for an acknowledgment of the connection termination request previously /// sent to the remote TCP (which includes an acknowledgment of its connection termination request). /// /// /// /// MIB_TCP_STATE_TIME_WAIT 11 /// /// The TCP connection is in the TIME-WAIT state waiting for enough time to pass to be sure the remote TCP received the /// acknowledgment of its connection termination request. /// /// /// /// MIB_TCP_STATE_DELETE_TCB 12 /// /// The TCP connection is in the delete TCB state that represents the deletion of the Transmission Control Block (TCB), a data /// structure used to maintain information on each TCP entry. /// /// /// /// public MIB_TCP_STATE dwState; /// /// Type: DWORD /// The PID of the local process that issued a context bind for this TCP connection. /// public uint dwOwningPid; } /// The MIB_TCP6ROW2 structure contains information that describes an IPv6 TCP connection. /// /// The MIB_TCP6ROW2 structure is defined on Windows Vista and later. /// /// The GetTcp6Table2function retrieves the IPv6 TCP connection table on the local computer and returns this information in a /// MIB_TCP6TABLE2 structure. /// /// An array of MIB_TCP6ROW2 structures are contained in the MIB_TCP6TABLE2 structure. /// /// The State member indicates the state of the TCP entry in a TCP state diagram. A TCP connection progresses through a series /// of states during its lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, /// CLOSING, LAST-ACK, TIME-WAIT, and the fictional state CLOSED. The CLOSED state is fictional because it represents the state when /// there is no Transmission Control Block, and therefore, no connection. The TCP protocol is described in RFC 793. For more /// information, see http://www.ietf.org/rfc/rfc793.txt. /// /// /// The dwLocalPort, and dwRemotePort members are in network byte order. In order to use the dwLocalPort or /// dwRemotePort members, the ntohs or inet_ntoa functions in Windows Sockets or similar functions may be needed. /// /// /// The dwLocalScopeId, and dwRemoteScopeId members are in network byte order. In order to use the /// dwLocalScopeId or dwRemoteScopeId members, the ntohl or inet_ntoa functions in Windows Sockets or similar functions /// may be needed. /// /// /// The LocalAddr and RemoteAddr members are stored in in6_addr structures. The RtlIpv6AddressToString or /// RtlIpv6AddressToStringEx functions may be used to convert the IPv6 address in the LocalAddr or RemoteAddr members /// to a string without loading the Windows Sockets DLL. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcp6row2 typedef struct _MIB_TCP6ROW2 { IN6_ADDR // LocalAddr; DWORD dwLocalScopeId; DWORD dwLocalPort; IN6_ADDR RemoteAddr; DWORD dwRemoteScopeId; DWORD dwRemotePort; MIB_TCP_STATE // State; DWORD dwOwningPid; TCP_CONNECTION_OFFLOAD_STATE dwOffloadState; } MIB_TCP6ROW2, *PMIB_TCP6ROW2; [PInvokeData("tcpmib.h", MSDNShortId = "bbec3397-0317-40f7-926f-2ec48cf5386d")] [StructLayout(LayoutKind.Sequential)] public struct MIB_TCP6ROW2 { /// /// Type: IN6_ADDR /// /// The local IPv6 address for the TCP connection on the local computer. A value of zero indicates the listener can accept a /// connection on any interface. /// /// public IN6_ADDR LocalAddr; /// /// Type: DWORD /// The local scope ID for the TCP connection on the local computer. /// public uint dwLocalScopeId; /// /// Type: DWORD /// The local port number in network byte order for the TCP connection on the local computer. /// /// The maximum size of an IP port number is 16 bits, so only the lower 16 bits should be used. The upper 16 bits may contain /// uninitialized data. /// /// public uint dwLocalPort; /// /// Type: IN6_ADDR /// /// The IPv6 address for the TCP connection on the remote computer. When the State member is MIB_TCP_STATE_LISTEN, /// this value has no meaning. /// /// public IN6_ADDR RemoteAddr; /// /// Type: DWORD /// /// The remote scope ID for the TCP connection on the remote computer. When the State member is /// MIB_TCP_STATE_LISTEN, this value has no meaning. /// /// public uint dwRemoteScopeId; /// /// Type: DWORD /// /// The remote port number in network byte order for the TCP connection on the remote computer. When the State member is /// MIB_TCP_STATE_LISTEN, this value has no meaning. /// /// /// The maximum size of an IP port number is 16 bits, so only the lower 16 bits should be used. The upper 16 bits may contain /// uninitialized data. /// /// public uint dwRemotePort; /// /// Type: MIB_TCP_STATE /// /// The state of the TCP connection. This member can be one of the values from the MIB_TCP_STATE enumeration type defined /// in the Tcpmib.h header file. /// /// /// /// Value /// Meaning /// /// /// MIB_TCP_STATE_CLOSED 1 /// The TCP connection is in the CLOSED state that represents no connection state at all. /// /// /// MIB_TCP_STATE_LISTEN 2 /// The TCP connection is in the LISTEN state waiting for a connection request from any remote TCP and port. /// /// /// MIB_TCP_STATE_SYN_SENT 3 /// /// The TCP connection is in the SYN-SENT state waiting for a matching connection request after having sent a connection request /// (SYN packet). /// /// /// /// MIB_TCP_STATE_SYN_RCVD 4 /// /// The TCP connection is in the SYN-RECEIVED state waiting for a confirming connection request acknowledgment after having both /// received and sent a connection request (SYN packet). /// /// /// /// MIB_TCP_STATE_ESTAB 5 /// /// The TCP connection is in the ESTABLISHED state that represents an open connection, data received can be delivered to the /// user. This is the normal state for the data transfer phase of the TCP connection. /// /// /// /// MIB_TCP_STATE_FIN_WAIT1 6 /// /// The TCP connection is FIN-WAIT-1 state waiting for a connection termination request from the remote TCP, or an acknowledgment /// of the connection termination request previously sent. /// /// /// /// MIB_TCP_STATE_FIN_WAIT2 7 /// The TCP connection is FIN-WAIT-1 state waiting for a connection termination request from the remote TCP. /// /// /// MIB_TCP_STATE_CLOSE_WAIT 8 /// The TCP connection is in the CLOSE-WAIT state waiting for a connection termination request from the local user. /// /// /// MIB_TCP_STATE_CLOSING 9 /// /// The TCP connection is in the CLOSING state waiting for a connection termination request acknowledgment from the remote TCP. /// /// /// /// MIB_TCP_STATE_LAST_ACK 10 /// /// The TCP connection is in the LAST-ACK state waiting for an acknowledgment of the connection termination request previously /// sent to the remote TCP (which includes an acknowledgment of its connection termination request). /// /// /// /// MIB_TCP_STATE_TIME_WAIT 11 /// /// The TCP connection is in the TIME-WAIT state waiting for enough time to pass to be sure the remote TCP received the /// acknowledgment of its connection termination request. /// /// /// /// MIB_TCP_STATE_DELETE_TCB 12 /// /// The TCP connection is in the delete TCB state that represents the deletion of the Transmission Control Block (TCB), a data /// structure used to maintain information on each TCP entry. /// /// /// /// public MIB_TCP_STATE State; /// /// Type: DWORD /// The PID of the process that issued a context bind for this TCP connection. /// public uint dwOwningPid; /// /// Type: TCP_CONNECTION_OFFLOAD_STATE /// /// The offload state for this TCP connection. This parameter can be one of the enumeration values for the /// TCP_CONNECTION_OFFLOAD_STATE defined in the Tcpmib.h header. /// /// public TCP_CONNECTION_OFFLOAD_STATE dwOffloadState; } /// /// The MIB_TCPROW structure contains information that descibes an IPv4 TCP connection. /// /// /// /// The GetTcpTable function retrieves the IPv4 TCP connection table on the local computer and returns this information in a /// MIB_TCPTABLE structure. /// /// /// An array of MIB_TCPROW structures are contained in the MIB_TCPTABLE structure. The MIB_TCPROW structure is /// also used by the SetTcpEntry function. /// /// /// The dwState member indicates the state of the TCP entry in a TCP state diagram. A TCP connection progresses through a /// series of states during its lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, /// CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT, and the fictional state CLOSED. The CLOSED state is fictional because it represents the /// state when there is no Transmission Control Block, and therefore, no connection. The TCP protocol is described in RFC 793. For /// more information, see http://www.ietf.org/rfc/rfc793.txt. /// /// /// The dwLocalAddr and dwRemoteAddr members are stored as a DWORD in the same format as the in_addr structure. /// In order to use the dwLocalAddr or dwRemoteAddr members, the ntohl or inet_ntoa functions in Windows Sockets or /// similar functions may be needed. On Windows Vista and later, the RtlIpv4AddressToString or RtlIpv4AddressToStringEx functions may /// be used to convert the IPv4 address in the dwLocalAddr or dwRemoteAddr members to a string without loading the /// Windows Sockets DLL. /// /// /// The dwLocalPort, and dwRemotePort members are in network byte order. In order to use the dwLocalPort or /// dwRemotePort members, the ntohs or inet_ntoa functions in Windows Sockets or similar functions may be needed. /// /// /// The MIB_TCPROW structure changed slightly on Windows Vista and later. On Windows Vista and later, the dwState /// member is replaced by a union that contains the following members. /// /// /// /// Member /// Description /// /// /// DWORD dwState /// The state of the TCP connection. /// /// /// MIB_TCP_STATE State /// /// The state of the TCP connection. This member can be one of the values from the MIB_TCP_STATE enumeration type defined in the /// Tcpmib.h header file. The possible values are the same as those defined for the dwState member. /// /// /// /// /// In the Windows SDK, the version of the structure for use on Windows Vista and later is defined as MIB_TCPROW_LH. In the /// Windows SDK, the version of this structure to be used on earlier systems including Windows 2000 and later is defined as /// MIB_TCPROW_W2K. When compiling an application if the target platform is Windows Vista and later (, , or ), the /// MIB_TCPROW_LH structure is typedefed to the MIB_TCPROW structure. When compiling an application if the target /// platform is not Windows Vista and later, the MIB_TCPROW_W2K structure is typedefed to the MIB_TCPROW structure. /// /// /// On the Windows SDK released for Windows Vista and later, the organization of header files has changed. This structure is defined /// in the Tcpmib.h header file, not in the Iprtrmib.h header file. Note that the Tcpmib.h header file is automatically included in /// Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Tcpmib.h and Iprtrmib.h header files should never /// be used directly. /// /// Examples /// /// The following example retrieves the TCP connection table and prints the state of each connection represented as a /// MIB_TCPROW structure. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcprow_lh typedef struct // _MIB_TCPROW_LH { union { DWORD dwState; MIB_TCP_STATE State; }; DWORD dwLocalAddr; DWORD dwLocalPort; DWORD dwRemoteAddr; DWORD // dwRemotePort; } MIB_TCPROW_LH, *PMIB_TCPROW_LH; [PInvokeData("tcpmib.h", MSDNShortId = "36364854-caa8-4652-be8e-f741b36d9fd7")] [StructLayout(LayoutKind.Sequential)] public struct MIB_TCPROW { /// The state of the TCP connection. public MIB_TCP_STATE dwState; /// /// Type: DWORD /// /// The local IPv4 address for the TCP connection on the local computer. A value of zero indicates the listener can accept a /// connection on any interface. /// /// public uint dwLocalAddr; /// /// Type: DWORD /// The local port number in network byte order for the TCP connection on the local computer. /// /// The maximum size of an IP port number is 16 bits, so only the lower 16 bits should be used. The upper 16 bits may contain /// uninitialized data. /// /// public uint dwLocalPort; /// /// Type: DWORD /// /// The IPv4 address for the TCP connection on the remote computer. When the dwState member is /// MIB_TCP_STATE_LISTEN, this value has no meaning. /// /// public uint dwRemoteAddr; /// /// Type: DWORD /// /// The remote port number in network byte order for the TCP connection on the remote computer. When the dwState member is /// MIB_TCP_STATE_LISTEN, this member has no meaning. /// /// /// The maximum size of an IP port number is 16 bits, so only the lower 16 bits should be used. The upper 16 bits may contain /// uninitialized data. /// /// public uint dwRemotePort; } /// /// /// The MIB_TCPROW_OWNER_MODULE structure contains information that describes an IPv4 TCP connection with ownership data, IPv4 /// addresses, ports used by the TCP connection, and the specific process ID (PID) associated with connection. /// /// /// /// /// The MIB_TCPROW_OWNER_MODULE structure is returned by a call to GetExtendedTcpTable with the TableClass parameter set to /// TCP_TABLE_OWNER_MODULE_LISTENER, TCP_TABLE_OWNER_MODULE_CONNECTIONS, or TCP_TABLE_OWNER_MODULE_ALL from the /// TCP_TABLE_CLASS enumeration and the ulAf parameter set to AF_INET4. /// /// /// The dwState member indicates the state of the TCP entry in a TCP state diagram. A TCP connection progresses through a /// series of states during its lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, /// CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT, and the fictional state CLOSED. The CLOSED state is fictional because it represents the /// state when there is no Transmission Control Block, and therefore, no connection. The TCP protocol is described in RFC 793. For /// more information, see http://www.ietf.org/rfc/rfc793.txt. /// /// /// The dwLocalPort, and dwRemotePort members are in network byte order. In order to use the dwLocalPort or /// dwRemotePort members, the ntohs or inet_ntoa functions in Windows Sockets or similar functions may be needed. The /// dwLocalAddr and dwRemoteAddr members are stored as a DWORD in the same format as the in_addr structure. In /// order to use the dwLocalAddr or dwRemoteAddr members, the ntohl or inet_ntoa functions in Windows Sockets or /// similar functions may be needed. On Windows Vista and later, the RtlIpv4AddressToString or RtlIpv4AddressToStringEx functions may /// be used to convert the IPv4 address in the dwLocalAddr or dwRemoteAddr members to a string without loading the /// Windows Sockets DLL. /// /// /// On the Windows SDK released for Windows Vista and later, the organization of header files has changed. This structure is defined /// in the Tcpmib.h header file, not in the Iprtrmib.h header file. Note that the Tcpmib.h header file is automatically included in /// Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Tcpmib.h and Iprtrmib.h header files should never /// be used directly. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcprow_owner_module typedef struct // _MIB_TCPROW_OWNER_MODULE { DWORD dwState; DWORD dwLocalAddr; DWORD dwLocalPort; DWORD dwRemoteAddr; DWORD dwRemotePort; DWORD // dwOwningPid; LARGE_INTEGER liCreateTimestamp; ULONGLONG OwningModuleInfo[TCPIP_OWNING_MODULE_SIZE]; } MIB_TCPROW_OWNER_MODULE, *PMIB_TCPROW_OWNER_MODULE; [PInvokeData("tcpmib.h", MSDNShortId = "5fc1e95a-4ab1-4a15-aedc-47cfd811c035")] [StructLayout(LayoutKind.Sequential)] public struct MIB_TCPROW_OWNER_MODULE { /// /// Type: DWORD /// dwState /// /// Type: DWORD The state of the TCP connection. This member can be one of the values defined in the Iprtrmib.h /// header file. /// /// /// On the Windows SDK released for Windows Vista and later, the organization of header files has changed. This member can be one /// of the values from the MIB_TCP_STATE enumeration defined in the Tcpmib.h header file, not in the Iprtrmib.h header /// file. Note that the Tcpmib.h header file is automatically included in Iprtrmib.h, which is automatically included in the /// Iphlpapi.h header file. The Tcpmib.h and Iprtrmib.h header files should never be used directly. /// /// /// /// Value /// Meaning /// /// /// MIB_TCP_STATE_CLOSED 1 /// The TCP connection is in the CLOSED state that represents no connection state at all. /// /// /// MIB_TCP_STATE_LISTEN 2 /// The TCP connection is in the LISTEN state waiting for a connection request from any remote TCP and port. /// /// /// MIB_TCP_STATE_SYN_SENT 3 /// /// The TCP connection is in the SYN-SENT state waiting for a matching connection request after having sent a connection request /// (SYN packet). /// /// /// /// MIB_TCP_STATE_SYN_RCVD 4 /// /// The TCP connection is in the SYN-RECEIVED state waiting for a confirming connection request acknowledgment after having both /// received and sent a connection request (SYN packet). /// /// /// /// MIB_TCP_STATE_ESTAB 5 /// /// The TCP connection is in the ESTABLISHED state that represents an open connection, data received can be delivered to the /// user. This is the normal state for the data transfer phase of the TCP connection. /// /// /// /// MIB_TCP_STATE_FIN_WAIT1 6 /// /// The TCP connection is FIN-WAIT-1 state waiting for a connection termination request from the remote TCP, or an acknowledgment /// of the connection termination request previously sent. /// /// /// /// MIB_TCP_STATE_FIN_WAIT2 7 /// The TCP connection is FIN-WAIT-1 state waiting for a connection termination request from the remote TCP. /// /// /// MIB_TCP_STATE_CLOSE_WAIT 8 /// The TCP connection is in the CLOSE-WAIT state waiting for a connection termination request from the local user. /// /// /// MIB_TCP_STATE_CLOSING 9 /// /// The TCP connection is in the CLOSING state waiting for a connection termination request acknowledgment from the remote TCP. /// /// /// /// MIB_TCP_STATE_LAST_ACK 10 /// /// The TCP connection is in the LAST-ACK state waiting for an acknowledgment of the connection termination request previously /// sent to the remote TCP (which includes an acknowledgment of its connection termination request). /// /// /// /// MIB_TCP_STATE_TIME_WAIT 11 /// /// The TCP connection is in the TIME-WAIT state waiting for enough time to pass to be sure the remote TCP received the /// acknowledgment of its connection termination request. /// /// /// /// MIB_TCP_STATE_DELETE_TCB 12 /// /// The TCP connection is in the delete TCB state that represents the deletion of the Transmission Control Block (TCB), a data /// structure used to maintain information on each TCP entry. /// /// /// /// public MIB_TCP_STATE dwState; /// /// Type: DWORD /// /// The local IPv4 address for the TCP connection on the local computer. A value of zero indicates the listener can accept a /// connection on any interface. /// /// public IN_ADDR dwLocalAddr; /// /// Type: DWORD /// The local port number in network byte order for the TCP connection on the local computer. /// public uint dwLocalPort; /// /// Type: DWORD /// /// The IPv4 address for the TCP connection on the remote computer. When the dwState member is /// MIB_TCP_STATE_LISTEN, this value has no meaning. /// /// public IN_ADDR dwRemoteAddr; /// /// Type: DWORD /// /// The remote port number in network byte order for the TCP connection on the remote computer. When the dwState member is /// MIB_TCP_STATE_LISTEN, this member has no meaning. /// /// public uint dwRemotePort; /// /// Type: DWORD /// The PID of the process that issued a context bind for this TCP connection. /// public uint dwOwningPid; /// /// Type: LARGE_INTEGER /// A SYSTEMTIME structure that indicates when the context bind operation that created this TCP link occurred. /// public SYSTEMTIME liCreateTimestamp; /// /// Type: ULONGLONG[TCPIP_OWNING_MODULE_SIZE] /// An array of opaque data that contains ownership information. /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = TCPIP_OWNING_MODULE_SIZE)] public ulong[] OwningModuleInfo; } /// /// /// The MIB_TCPROW_OWNER_PID structure contains information that describes an IPv4 TCP connection with IPv4 addresses, ports /// used by the TCP connection, and the specific process ID (PID) associated with connection. /// /// /// /// /// The MIB_TCPROW_OWNER_PID structure is returned by a call to GetExtendedTcpTable with the TableClass parameter set to /// TCP_TABLE_OWNER_PID_LISTENER, TCP_TABLE_OWNER_PID_CONNECTIONS, or TCP_TABLE_OWNER_PID_ALL from the /// TCP_TABLE_CLASS enumeration and the ulAf parameter set to AF_INET4. /// /// /// The dwState member indicates the state of the TCP entry in a TCP state diagram. A TCP connection progresses through a /// series of states during its lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, /// CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT, and the fictional state CLOSED. The CLOSED state is fictional because it represents the /// state when there is no Transmission Control Block, and therefore, no connection. The TCP protocol is described in RFC 793. For /// more information, see http://www.ietf.org/rfc/rfc793.txt. /// /// /// The dwLocalPort, and dwRemotePort members are in network byte order. In order to use the dwLocalPort or /// dwRemotePort members, the ntohs or inet_ntoa functions in Windows Sockets or similar functions may be needed. The /// dwLocalAddr and dwRemoteAddr members are stored as a DWORD in the same format as the in_addr structure. In /// order to use the dwLocalAddr or dwRemoteAddr members, the ntohl or inet_ntoa functions in Windows Sockets or /// similar functions may be needed. On Windows Vista and later, the RtlIpv4AddressToString or RtlIpv4AddressToStringEx functions may /// be used to convert the IPv4 address in the dwLocalAddr or dwRemoteAddr members to a string without loading the /// Windows Sockets DLL. /// /// /// On the Windows SDK released for Windows Vista and later, the organization of header files has changed. This structure is defined /// in the Tcpmib.h header file, not in the Iprtrmib.h header file. Note that the Tcpmib.h header file is automatically included in /// Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Tcpmib.h and Iprtrmib.h header files should never /// be used directly. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcprow_owner_pid typedef struct // _MIB_TCPROW_OWNER_PID { DWORD dwState; DWORD dwLocalAddr; DWORD dwLocalPort; DWORD dwRemoteAddr; DWORD dwRemotePort; DWORD // dwOwningPid; } MIB_TCPROW_OWNER_PID, *PMIB_TCPROW_OWNER_PID; [PInvokeData("tcpmib.h", MSDNShortId = "220b69a4-b372-4eff-8d5a-eca0d39b8af9")] [StructLayout(LayoutKind.Sequential)] public struct MIB_TCPROW_OWNER_PID { /// /// Type: DWORD /// The state of the TCP connection. This member can be one of the values defined in the Iprtrmib.h header file. /// /// On the Windows SDK released for Windows Vista and later, the organization of header files has changed. This member can be one /// of the values from the MIB_TCP_STATE enumeration defined in the Tcpmib.h header file, not in the Iprtrmib.h header /// file. Note that the Tcpmib.h header file is automatically included in Iprtrmib.h, which is automatically included in the /// Iphlpapi.h header file. The Tcpmib.h and Iprtrmib.h header files should never be used directly. /// /// /// /// Value /// Meaning /// /// /// MIB_TCP_STATE_CLOSED 1 /// The TCP connection is in the CLOSED state that represents no connection state at all. /// /// /// MIB_TCP_STATE_LISTEN 2 /// The TCP connection is in the LISTEN state waiting for a connection request from any remote TCP and port. /// /// /// MIB_TCP_STATE_SYN_SENT 3 /// /// The TCP connection is in the SYN-SENT state waiting for a matching connection request after having sent a connection request /// (SYN packet). /// /// /// /// MIB_TCP_STATE_SYN_RCVD 4 /// /// The TCP connection is in the SYN-RECEIVED state waiting for a confirming connection request acknowledgment after having both /// received and sent a connection request (SYN packet). /// /// /// /// MIB_TCP_STATE_ESTAB 5 /// /// The TCP connection is in the ESTABLISHED state that represents an open connection, data received can be delivered to the /// user. This is the normal state for the data transfer phase of the TCP connection. /// /// /// /// MIB_TCP_STATE_FIN_WAIT1 6 /// /// The TCP connection is FIN-WAIT-1 state waiting for a connection termination request from the remote TCP, or an acknowledgment /// of the connection termination request previously sent. /// /// /// /// MIB_TCP_STATE_FIN_WAIT2 7 /// The TCP connection is FIN-WAIT-2 state waiting for a connection termination request from the remote TCP. /// /// /// MIB_TCP_STATE_CLOSE_WAIT 8 /// The TCP connection is in the CLOSE-WAIT state waiting for a connection termination request from the local user. /// /// /// MIB_TCP_STATE_CLOSING 9 /// /// The TCP connection is in the CLOSING state waiting for a connection termination request acknowledgment from the remote TCP. /// /// /// /// MIB_TCP_STATE_LAST_ACK 10 /// /// The TCP connection is in the LAST-ACK state waiting for an acknowledgment of the connection termination request previously /// sent to the remote TCP (which includes an acknowledgment of its connection termination request). /// /// /// /// MIB_TCP_STATE_TIME_WAIT 11 /// /// The TCP connection is in the TIME-WAIT state waiting for enough time to pass to be sure the remote TCP received the /// acknowledgment of its connection termination request. /// /// /// /// MIB_TCP_STATE_DELETE_TCB 12 /// /// The TCP connection is in the delete TCB state that represents the deletion of the Transmission Control Block (TCB), a data /// structure used to maintain information on each TCP entry. /// /// /// /// public MIB_TCP_STATE dwState; /// /// Type: DWORD /// /// The local IPv4 address for the TCP connection on the local computer. A value of zero indicates the listener can accept a /// connection on any interface. /// /// public IN_ADDR dwLocalAddr; /// /// Type: DWORD /// The local port number in network byte order for the TCP connection on the local computer. /// public uint dwLocalPort; /// /// Type: DWORD /// /// The IPv4 address for the TCP connection on the remote computer. When the dwState member is /// MIB_TCP_STATE_LISTEN, this value has no meaning. /// /// public IN_ADDR dwRemoteAddr; /// /// Type: DWORD /// /// The remote port number in network byte order for the TCP connection on the remote computer. When the dwState member is /// MIB_TCP_STATE_LISTEN, this member has no meaning. /// /// public uint dwRemotePort; /// /// Type: DWORD /// The PID of the process that issued a context bind for this TCP connection. /// public uint dwOwningPid; } /// /// The MIB_TCPROW2 structure contains information that describes an IPv4 TCP connection. /// /// /// /// The GetTcpTable2 function retrieves the IPv4 TCP connection table on the local computer and returns this information in a /// MIB_TCPTABLE2 structure. /// /// An array of MIB_TCPROW2 structures are contained in the MIB_TCPTABLE2 structure. /// /// The dwState member indicates the state of the TCP entry in a TCP state diagram. A TCP connection progresses through a /// series of states during its lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, /// CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT, and the fictional state CLOSED. The CLOSED state is fictional because it represents the /// state when there is no Transmission Control Block, and therefore, no connection. The TCP protocol is described in RFC 793. For /// more information, see http://www.ietf.org/rfc/rfc793.txt. /// /// /// The dwLocalPort, and dwRemotePort members are in network byte order. In order to use the dwLocalPort or /// dwRemotePort members, the ntohs or inet_ntoa functions in Windows Sockets or similar functions may be needed. The /// dwLocalAddr and dwRemoteAddr members are stored as a DWORD in the same format as the in_addr structure. In /// order to use the dwLocalAddr or dwRemoteAddr members, the ntohl or inet_ntoa functions in Windows Sockets or /// similar functions may be needed. On Windows Vista and later, the RtlIpv4AddressToString or RtlIpv4AddressToStringEx functions may /// be used to convert the IPv4 address in the dwLocalAddr or dwRemoteAddr members to a string without loading the /// Windows Sockets DLL. /// /// Examples /// /// The following example retrieves the TCP connection table for IPv4 and prints the state of each connection represented as a /// MIB_TCPROW2 structure. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcprow2 typedef struct _MIB_TCPROW2 { // DWORD dwState; DWORD dwLocalAddr; DWORD dwLocalPort; DWORD dwRemoteAddr; DWORD dwRemotePort; DWORD dwOwningPid; // TCP_CONNECTION_OFFLOAD_STATE dwOffloadState; } MIB_TCPROW2, *PMIB_TCPROW2; [PInvokeData("tcpmib.h", MSDNShortId = "cff343cd-fe85-4e60-87bd-c1e9833cea38")] [StructLayout(LayoutKind.Sequential)] public struct MIB_TCPROW2 { /// /// Type: DWORD /// The state of the TCP connection. This member can be one of the values defined in the Iprtrmib.h header file. /// /// On the Windows SDK released for Windows Vista and later, the organization of header files has changed. This member can be one /// of the values from the MIB_TCP_STATE enumeration defined in the Tcpmib.h header file, not in the Iprtrmib.h header /// file. Note that the Tcpmib.h header file is automatically included in Iprtrmib.h, which is automatically included in the /// Iphlpapi.h header file. The Tcpmib.h and Iprtrmib.h header files should never be used directly. /// /// /// /// Value /// Meaning /// /// /// MIB_TCP_STATE_CLOSED 1 /// The TCP connection is in the CLOSED state that represents no connection state at all. /// /// /// MIB_TCP_STATE_LISTEN 2 /// The TCP connection is in the LISTEN state waiting for a connection request from any remote TCP and port. /// /// /// MIB_TCP_STATE_SYN_SENT 3 /// /// The TCP connection is in the SYN-SENT state waiting for a matching connection request after having sent a connection request /// (SYN packet). /// /// /// /// MIB_TCP_STATE_SYN_RCVD 4 /// /// The TCP connection is in the SYN-RECEIVED state waiting for a confirming connection request acknowledgment after having both /// received and sent a connection request (SYN packet). /// /// /// /// MIB_TCP_STATE_ESTAB 5 /// /// The TCP connection is in the ESTABLISHED state that represents an open connection, data received can be delivered to the /// user. This is the normal state for the data transfer phase of the TCP connection. /// /// /// /// MIB_TCP_STATE_FIN_WAIT1 6 /// /// The TCP connection is FIN-WAIT-1 state waiting for a connection termination request from the remote TCP, or an acknowledgment /// of the connection termination request previously sent. /// /// /// /// MIB_TCP_STATE_FIN_WAIT2 7 /// The TCP connection is FIN-WAIT-1 state waiting for a connection termination request from the remote TCP. /// /// /// MIB_TCP_STATE_CLOSE_WAIT 8 /// The TCP connection is in the CLOSE-WAIT state waiting for a connection termination request from the local user. /// /// /// MIB_TCP_STATE_CLOSING 9 /// /// The TCP connection is in the CLOSING state waiting for a connection termination request acknowledgment from the remote TCP. /// /// /// /// MIB_TCP_STATE_LAST_ACK 10 /// /// The TCP connection is in the LAST-ACK state waiting for an acknowledgment of the connection termination request previously /// sent to the remote TCP (which includes an acknowledgment of its connection termination request). /// /// /// /// MIB_TCP_STATE_TIME_WAIT 11 /// /// The TCP connection is in the TIME-WAIT state waiting for enough time to pass to be sure the remote TCP received the /// acknowledgment of its connection termination request. /// /// /// /// MIB_TCP_STATE_DELETE_TCB 12 /// /// The TCP connection is in the delete TCB state that represents the deletion of the Transmission Control Block (TCB), a data /// structure used to maintain information on each TCP entry. /// /// /// /// public MIB_TCP_STATE dwState; /// /// Type: DWORD /// /// The local IPv4 address for the TCP connection on the local computer. A value of zero indicates the listener can accept a /// connection on any interface. /// /// public IN_ADDR dwLocalAddr; /// /// Type: DWORD /// The local port number in network byte order for the TCP connection on the local computer. /// /// The maximum size of an IP port number is 16 bits, so only the lower 16 bits should be used. The upper 16 bits may contain /// uninitialized data. /// /// public uint dwLocalPort; /// /// Type: DWORD /// /// The IPv4 address for the TCP connection on the remote computer. When the dwState member is /// MIB_TCP_STATE_LISTEN, this value has no meaning. /// /// public IN_ADDR dwRemoteAddr; /// /// Type: DWORD /// /// The remote port number in network byte order for the TCP connection on the remote computer. When the dwState member is /// MIB_TCP_STATE_LISTEN, this member has no meaning. /// /// /// The maximum size of an IP port number is 16 bits, so only the lower 16 bits should be used. The upper 16 bits may contain /// uninitialized data. /// /// public uint dwRemotePort; /// /// Type: DWORD /// The PID of the process that issued a context bind for this TCP connection. /// public uint dwOwningPid; /// /// Type: TCP_CONNECTION_OFFLOAD_STATE /// /// The offload state for this TCP connection. This parameter can be one of the enumeration values for the /// TCP_CONNECTION_OFFLOAD_STATE defined in the Tcpmib.h header. /// /// public TCP_CONNECTION_OFFLOAD_STATE dwOffloadState; } /// /// The MIB_TCPSTATS structure contains statistics for the TCP protocol running on the local computer. /// /// /// The GetTcpStatistics function returns a pointer to a MIB_TCPSTATS structure. /// /// The MIB_TCPSTATS structure changed slightly on Windows Vista and later. On Windows Vista and later, the /// dwRtoAlgorithm member is replaced by a union that contains the following members. /// /// /// /// Member /// Description /// /// /// DWORD dwRtoAlgorithm /// The retransmission time-out (RTO) algorithm in use. /// /// /// TCP_RTO_ALGORITHM RtoAlgorithm /// /// The retransmission time-out (RTO) algorithm in use. This member can be one of the values from the TCP_RTO_ALGORITHM enumeration /// type defined in the Tcpmib.h header file. The possible values are the same as those defined for the dwRtoAlgorithm member. /// /// /// /// /// In the Windows SDK, the version of the structure for use on Windows Vista and later is defined as MIB_TCPSTATS_LH. In the /// Windows SDK, the version of this structure to be used on earlier systems including Windows 2000 and later is defined as /// MIB_TCPSTATS_W2K. When compiling an application if the target platform is Windows Vista and later (, , or ), the /// MIB_TCPSTATS_LH structure is typedefed to the MIB_TCPSTATS structure. When compiling an application if the target /// platform is not Windows Vista and later, the MIB_TCPSTATS_W2K structure is typedefed to the MIB_TCPSTATS structure. /// /// /// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files /// has changed. This structure is defined in the Tcpmib.h header file, not in the Iprtrmib.h header file. Note that the Tcpmib.h /// header file is automatically included in Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Tcpmib.h /// and Iprtrmib.h header files should never be used directly. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcpstats_lh typedef struct // _MIB_TCPSTATS_LH { union { DWORD dwRtoAlgorithm; TCP_RTO_ALGORITHM RtoAlgorithm; }; DWORD dwRtoMin; DWORD dwRtoMax; DWORD // dwMaxConn; DWORD dwActiveOpens; DWORD dwPassiveOpens; DWORD dwAttemptFails; DWORD dwEstabResets; DWORD dwCurrEstab; DWORD // dwInSegs; DWORD dwOutSegs; DWORD dwRetransSegs; DWORD dwInErrs; DWORD dwOutRsts; DWORD dwNumConns; } MIB_TCPSTATS_LH, *PMIB_TCPSTATS_LH; [PInvokeData("tcpmib.h", MSDNShortId = "08d85d02-62a0-479d-bf56-5dad452436f3")] [StructLayout(LayoutKind.Sequential)] public struct MIB_TCPSTATS { /// /// The retransmission time-out (RTO) algorithm in use. This member can be one of the values from the TCP_RTO_ALGORITHM /// enumeration type defined in the Tcpmib.h header file. The possible values are the same as those defined for the /// dwRtoAlgorithm member. /// public TCP_RTO_ALGORITHM RtoAlgorithm; /// /// Type: DWORD /// The minimum RTO value in milliseconds. /// public uint dwRtoMin; /// /// Type: DWORD /// The maximum RTO value in milliseconds. /// public uint dwRtoMax; /// /// Type: DWORD /// The maximum number of connections. If this member is -1, the maximum number of connections is variable. /// public uint dwMaxConn; /// /// Type: DWORD /// The number of active opens. In an active open, the client is initiating a connection with the server. /// public uint dwActiveOpens; /// /// Type: DWORD /// The number of passive opens. In a passive open, the server is listening for a connection request from a client. /// public uint dwPassiveOpens; /// /// Type: DWORD /// The number of failed connection attempts. /// public uint dwAttemptFails; /// /// Type: DWORD /// The number of established connections that were reset. /// public uint dwEstabResets; /// /// Type: DWORD /// The number of currently established connections. /// public uint dwCurrEstab; /// /// Type: DWORD /// The number of segments received. /// public uint dwInSegs; /// /// Type: DWORD /// The number of segments transmitted. This number does not include retransmitted segments. /// public uint dwOutSegs; /// /// Type: DWORD /// The number of segments retransmitted. /// public uint dwRetransSegs; /// /// Type: DWORD /// The number of errors received. /// public uint dwInErrs; /// /// Type: DWORD /// The number of segments transmitted with the reset flag set. /// public uint dwOutRsts; /// /// Type: DWORD /// /// The number of connections that are currently present in the system. This total number includes connections in all states /// except listening connections. /// /// public uint dwNumConns; } /// /// /// [Some information relates to pre-released product which may be substantially modified before it's commercially released. /// Microsoft makes no warranties, express or implied, with respect to the information provided here.] /// /// /// The MIB_TCPSTATS2 structure contains statistics for the TCP protocol running on the local computer. This structure is /// different from MIB_TCPSTATS structure in that it uses 64-bit counters, rather than 32-bit counters. /// /// /// /// The GetTcpStatisticsEx2 function returns a pointer to a MIB_TCPSTATS2 structure. /// /// This structure is defined in the Tcpmib.h header file, not in the Iprtrmib.h header file. Note that the Tcpmib.h header file is /// automatically included in Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Tcpmib.h and Iprtrmib.h /// header files should never be used directly. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcpstats2 typedef struct // _MIB_TCPSTATS2 { TCP_RTO_ALGORITHM RtoAlgorithm; DWORD dwRtoMin; DWORD dwRtoMax; DWORD dwMaxConn; DWORD dwActiveOpens; DWORD // dwPassiveOpens; DWORD dwAttemptFails; DWORD dwEstabResets; DWORD dwCurrEstab; DWORD64 dw64InSegs; DWORD64 dw64OutSegs; DWORD // dwRetransSegs; DWORD dwInErrs; DWORD dwOutRsts; DWORD dwNumConns; } MIB_TCPSTATS2, *PMIB_TCPSTATS2; [PInvokeData("tcpmib.h", MSDNShortId = "A32AA866-406B-4BE0-A4F1-5EBC9DFD646D")] [StructLayout(LayoutKind.Sequential)] public struct MIB_TCPSTATS2 { /// /// The retransmission time-out (RTO) algorithm in use. This member can be one of the values from the TCP_RTO_ALGORITHM /// enumeration type defined in the Tcpmib.h header file. The possible values are the same as those defined for the /// dwRtoAlgorithm member. /// public TCP_RTO_ALGORITHM RtoAlgorithm; /// /// Type: DWORD /// The minimum RTO value in milliseconds. /// public uint dwRtoMin; /// /// Type: DWORD /// The maximum RTO value in milliseconds. /// public uint dwRtoMax; /// /// Type: DWORD /// The maximum number of connections. If this member is -1, the maximum number of connections is variable. /// public uint dwMaxConn; /// /// Type: DWORD /// The number of active opens. In an active open, the client is initiating a connection with the server. /// public uint dwActiveOpens; /// /// Type: DWORD /// The number of passive opens. In a passive open, the server is listening for a connection request from a client. /// public uint dwPassiveOpens; /// /// Type: DWORD /// The number of failed connection attempts. /// public uint dwAttemptFails; /// /// Type: DWORD /// The number of established connections that were reset. /// public uint dwEstabResets; /// /// Type: DWORD /// The number of currently established connections. /// public uint dwCurrEstab; /// /// Type: DWORD /// The number of segments received. /// public ulong dw64InSegs; /// /// Type: DWORD64 /// The number of segments transmitted. This number does not include retransmitted segments. /// public ulong dw64OutSegs; /// /// Type: DWORD64 /// The number of segments retransmitted. /// public uint dwRetransSegs; /// /// Type: DWORD /// The number of errors received. /// public uint dwInErrs; /// /// Type: DWORD /// The number of segments transmitted with the reset flag set. /// public uint dwOutRsts; /// /// Type: DWORD /// /// The number of connections that are currently present in the system. This total number includes connections in all states /// except listening connections. /// /// public uint dwNumConns; } /// The MIB_TCP6TABLE structure contains a table of TCP connections for IPv6 on the local computer. [PInvokeData("tcpmib.h", MSDNShortId = "aa814506")] [CorrespondingType(typeof(MIB_TCP6ROW))] [DefaultProperty(nameof(table))] public class MIB_TCP6TABLE : SafeElementArray { /// Initializes a new instance of the class. /// Amount of space, in bytes, to reserve. public MIB_TCP6TABLE(uint byteSize) : base((int)byteSize, 0) { } /// A value that specifies the number of TCP connections in the array. public uint dwNumEntries => Count; /// An array of MIB_TCP6ROW structures containing TCP connection entries. public MIB_TCP6ROW[] table { get => Elements; set => Elements = value; } /// Performs an implicit conversion from to . /// The MIB_TCP6TABLE instance. /// The result of the conversion. public static implicit operator IntPtr(MIB_TCP6TABLE table) => table.DangerousGetHandle(); } /// /// /// The MIB_TCP6TABLE_OWNER_MODULE structure contains a table of process IDs (PIDs) and the IPv6 TCP links context bound to /// these PIDs with any available ownership data. /// /// /// /// /// The MIB_TCP6TABLE_OWNER_MODULE structure is returned by a call to GetExtendedTcpTable with the TableClass parameter set to /// a TCP_TABLE_OWNER_MODULE_LISTENER, TCP_TABLE_OWNER_MODULE_CONNECTIONS, or TCP_TABLE_OWNER_MODULE_ALL from /// the TCP_TABLE_CLASS enumeration and the ulAf parameter set to AF_INET6. /// /// /// The MIB_TCP6TABLE_OWNER_MODULE structure may contain padding for alignment between the dwNumEntries member and the /// first MIB_TCP6ROW_OWNER_MODULE array entry in the table member. Padding for alignment may also be present between the /// MIB_TCP6ROW_OWNER_MODULE array entries in the table member. Any access to a MIB_TCP6ROW_OWNER_MODULE array /// entry should assume padding may exist. /// /// /// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files /// has changed. This structure is defined in the Tcpmib.h header file, not in the Iprtrmib.h header file. Note that the Tcpmib.h /// header file is automatically included in Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Tcpmib.h /// and Iprtrmib.h header files should never be used directly. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcp6table_owner_module typedef struct // _MIB_TCP6TABLE_OWNER_MODULE { DWORD dwNumEntries; MIB_TCP6ROW_OWNER_MODULE table[ANY_SIZE]; } MIB_TCP6TABLE_OWNER_MODULE, *PMIB_TCP6TABLE_OWNER_MODULE; [PInvokeData("tcpmib.h", MSDNShortId = "aa52531c-1d4e-44f9-8638-1528beb491f3")] [CorrespondingType(typeof(MIB_TCP6ROW_OWNER_MODULE))] [DefaultProperty(nameof(table))] public class MIB_TCP6TABLE_OWNER_MODULE : SafeElementArray { /// Initializes a new instance of the class. /// Amount of space, in bytes, to reserve. public MIB_TCP6TABLE_OWNER_MODULE(uint byteSize) : base((int)byteSize, 0) { } /// /// The number of MIB_TCP6ROW_OWNER_MODULE elements in the table. /// public uint dwNumEntries => (uint)Count; /// /// Array of MIB_TCP6ROW_OWNER_MODULE structures returned by a call to GetExtendedTcpTable. /// public MIB_TCP6ROW_OWNER_MODULE[] table { get => Elements; set => Elements = value; } /// Performs an implicit conversion from to . /// The MIB_TCP6TABLE_OWNER_MODULE instance. /// The result of the conversion. public static implicit operator IntPtr(MIB_TCP6TABLE_OWNER_MODULE table) => table.DangerousGetHandle(); } /// /// /// The MIB_TCP6TABLE_OWNER_PID structure contains a table of process IDs (PIDs) and the IPv6 TCP links that are context bound /// to these PIDs. /// /// /// /// /// The MIB_TCP6TABLE_OWNER_PID structure is returned by a call to GetExtendedTcpTable with the TableClass parameter set to /// TCP_TABLE_OWNER_PID_LISTENER, TCP_TABLE_OWNER_PID_CONNECTIONS, or TCP_TABLE_OWNER_PID_ALL from the /// TCP_TABLE_CLASS enumeration and the ulAf parameter set to AF_INET6. /// /// /// The MIB_TCP6TABLE_OWNER_PID structure may contain padding for alignment between the dwNumEntries member and the /// first MIB_TCP6ROW_OWNER_PID array entry in the table member. Padding for alignment may also be present between the /// MIB_TCP6ROW_OWNER_PID array entries in the table member. Any access to a MIB_TCP6ROW_OWNER_PID array entry /// should assume padding may exist. /// /// /// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files /// has changed. This structure is defined in the Tcpmib.h header file, not in the Iprtrmib.h header file. Note that the Tcpmib.h /// header file is automatically included in Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Tcpmib.h /// and Iprtrmib.h header files should never be used directly. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcp6table_owner_pid typedef struct // _MIB_TCP6TABLE_OWNER_PID { DWORD dwNumEntries; MIB_TCP6ROW_OWNER_PID table[ANY_SIZE]; } MIB_TCP6TABLE_OWNER_PID, *PMIB_TCP6TABLE_OWNER_PID; [PInvokeData("tcpmib.h", MSDNShortId = "93629d1d-e5f2-4ae8-b585-17e39ae4986d")] [CorrespondingType(typeof(MIB_TCP6ROW_OWNER_PID))] [DefaultProperty(nameof(table))] public class MIB_TCP6TABLE_OWNER_PID : SafeElementArray { /// Initializes a new instance of the class. /// Amount of space, in bytes, to reserve. public MIB_TCP6TABLE_OWNER_PID(uint byteSize) : base((int)byteSize, 0) { } /// /// The number of MIB_TCP6ROW_OWNER_PID elements in the table. /// public uint dwNumEntries => Count; /// /// Array of MIB_TCP6ROW_OWNER_PID structures returned by a call to GetExtendedTcpTable. /// public MIB_TCP6ROW_OWNER_PID[] table { get => Elements; set => Elements = value; } /// Performs an implicit conversion from to . /// The MIB_TCP6TABLE_OWNER_PID instance. /// The result of the conversion. public static implicit operator IntPtr(MIB_TCP6TABLE_OWNER_PID table) => table.DangerousGetHandle(); } /// The MIB_TCP6TABLE2 structure contains a table of IPv6 TCP connections on the local computer. /// /// The MIB_TCP6TABLE2 structure is defined on Windows Vista and later. /// /// The GetTcp6Table2function retrieves the IPv6 TCP connection table on the local computer and returns this information in a /// MIB_TCP6TABLE2 structure. /// /// An array of MIB_TCP6ROW2 structures are contained in the MIB_TCP6TABLE2 structure. /// /// The MIB_TCP6TABLE2 structure may contain padding for alignment between the dwNumEntries member and the first /// MIB_TCP6ROW2 array entry in the table member. Padding for alignment may also be present between the MIB_TCP6ROW2 /// array entries in the table member. Any access to a MIB_TCP6ROW2 array entry should assume padding may exist. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcp6table2 typedef struct _MIB_TCP6TABLE2 { DWORD // dwNumEntries; MIB_TCP6ROW2 table[ANY_SIZE]; } MIB_TCP6TABLE2, *PMIB_TCP6TABLE2; [PInvokeData("tcpmib.h", MSDNShortId = "3cb8568e-ce31-4ed1-aa9e-abcb826c0cea")] [CorrespondingType(typeof(MIB_TCP6ROW2))] [DefaultProperty(nameof(table))] public class MIB_TCP6TABLE2 : SafeElementArray { /// Initializes a new instance of the class. /// Amount of space, in bytes, to reserve. public MIB_TCP6TABLE2(uint byteSize) : base((int)byteSize, 0) { } /// A value that specifies the number of TCP connections in the array. public uint dwNumEntries => Count; /// An array of MIB_TCP6ROW2 structures containing TCP connection entries. public MIB_TCP6ROW2[] table { get => Elements; set => Elements = value; } /// Performs an implicit conversion from to . /// The MIB_TCP6TABLE instance. /// The result of the conversion. public static implicit operator IntPtr(MIB_TCP6TABLE2 table) => table.DangerousGetHandle(); } /// /// The MIB_TCPTABLE structure contains a table of TCP connections for IPv4 on the local computer. /// /// /// /// The GetTcpTable function retrieves the IPv4 TCP connection table on the local computer and returns this information in a /// MIB_TCPTABLE structure. An array of MIB_TCPROW structures are contained in the MIB_TCPTABLE structure. /// /// /// The MIB_TCPTABLE structure may contain padding for alignment between the dwNumEntries member and the first /// MIB_TCPROW array entry in the table member. Padding for alignment may also be present between the MIB_TCPROW array /// entries in the table member. Any access to a MIB_TCPROW array entry should assume padding may exist. /// /// /// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files /// has changed. This structure is defined in the Tcpmib.h header file, not in the Iprtrmib.h header file. Note that the Tcpmib.h /// header file is automatically included in Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Tcpmib.h /// and Iprtrmib.h header files should never be used directly. /// /// Examples /// /// The following example retrieves the TCP connection table for IPv4 as a MIB_TCPTABLE structure and prints the state of each /// connection represented as a MIB_TCPROW structure. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcptable typedef struct _MIB_TCPTABLE // { DWORD dwNumEntries; MIB_TCPROW table[ANY_SIZE]; } MIB_TCPTABLE, *PMIB_TCPTABLE; [PInvokeData("tcpmib.h", MSDNShortId = "a8ed8ac2-a72f-4099-ac99-a8b0b77b7b84")] [CorrespondingType(typeof(MIB_TCPROW))] [DefaultProperty(nameof(table))] public class MIB_TCPTABLE : SafeElementArray { /// Initializes a new instance of the class. /// Amount of space, in bytes, to reserve. public MIB_TCPTABLE(uint byteSize) : base((int)byteSize, 0) { } /// /// The number of entries in the table. /// public uint dwNumEntries => Count; /// /// A pointer to a table of TCP connections implemented as an array of MIB_TCPROW structures. /// public MIB_TCPROW[] table { get => Elements; set => Elements = value; } /// Performs an implicit conversion from to . /// The MIB_TCPTABLE instance. /// The result of the conversion. public static implicit operator IntPtr(MIB_TCPTABLE table) => table.DangerousGetHandle(); } /// /// /// The MIB_TCPTABLE_OWNER_MODULE structure contains a table of process IDs (PIDs) and the IPv4 TCP links context bound to the /// PIDs, and any available ownership data. /// /// /// /// /// This table is specifically returned by a call to GetExtendedTcpTable with the TableClass parameter set to a /// TCP_TABLE_OWNER_MODULE_* value from the TCP_TABLE_CLASS enumeration and the ulAf parameter set to AF_INET4. /// /// /// The MIB_TCPTABLE_OWNER_MODULE structure may contain padding for alignment between the dwNumEntries member and the /// first MIB_TCPROW_OWNER_MODULE array entry in the table member. Padding for alignment may also be present between the /// MIB_TCPROW_OWNER_MODULE array entries in the table member. Any access to a MIB_TCPROW_OWNER_MODULE array /// entry should assume padding may exist. /// /// /// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files /// has changed. This structure is defined in the Tcpmib.h header file, not in the Iprtrmib.h header file. Note that the Tcpmib.h /// header file is automatically included in Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Tcpmib.h /// and Iprtrmib.h header files should never be used directly. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcptable_owner_module typedef struct // _MIB_TCPTABLE_OWNER_MODULE { DWORD dwNumEntries; MIB_TCPROW_OWNER_MODULE table[ANY_SIZE]; } MIB_TCPTABLE_OWNER_MODULE, *PMIB_TCPTABLE_OWNER_MODULE; [PInvokeData("tcpmib.h", MSDNShortId = "d44c9d82-906b-43ea-8edd-cf973864668d")] [CorrespondingType(typeof(MIB_TCPROW_OWNER_MODULE))] [DefaultProperty(nameof(table))] public class MIB_TCPTABLE_OWNER_MODULE : SafeElementArray { /// Initializes a new instance of the class. /// Amount of space, in bytes, to reserve. public MIB_TCPTABLE_OWNER_MODULE(uint byteSize) : base((int)byteSize, 0) { } /// /// The number of MIB_TCPROW_OWNER_MODULE elements in the table. /// public uint dwNumEntries => (uint)Count; /// /// Array of MIB_TCPROW_OWNER_MODULE structures returned by a call to GetExtendedTcpTable. /// public MIB_TCPROW_OWNER_MODULE[] table { get => Elements; set => Elements = value; } /// Performs an implicit conversion from to . /// The MIB_TCPTABLE_OWNER_MODULE instance. /// The result of the conversion. public static implicit operator IntPtr(MIB_TCPTABLE_OWNER_MODULE table) => table.DangerousGetHandle(); } /// /// /// The MIB_TCPTABLE_OWNER_PID structure contains a table of process IDs (PIDs) and the IPv4 TCP links that are context bound /// to these PIDs. /// /// /// /// /// This table is specifically returned by a call to GetExtendedTcpTable with the TableClass parameter set to a /// TCP_TABLE_OWNER_PID_* value from the TCP_TABLE_CLASS enumeration and the ulAf parameter set to AF_INET4. /// /// /// The MIB_TCPTABLE_OWNER_PID structure may contain padding for alignment between the dwNumEntries member and the /// first MIB_TCPROW_OWNER_PID array entry in the table member. Padding for alignment may also be present between the /// MIB_TCPROW_OWNER_PID array entries in the table member. Any access to a MIB_TCPROW_OWNER_PID array entry /// should assume padding may exist. /// /// /// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files /// has changed. This structure is defined in the Tcpmib.h header file, not in the Iprtrmib.h header file. Note that the Tcpmib.h /// header file is automatically included in Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Tcpmib.h /// and Iprtrmib.h header files should never be used directly. /// /// // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcptable_owner_pid typedef struct // _MIB_TCPTABLE_OWNER_PID { DWORD dwNumEntries; MIB_TCPROW_OWNER_PID table[ANY_SIZE]; } MIB_TCPTABLE_OWNER_PID, *PMIB_TCPTABLE_OWNER_PID; [PInvokeData("tcpmib.h", MSDNShortId = "ef39b832-1f22-468a-8734-c7d9bd3ac965")] [CorrespondingType(typeof(MIB_TCPROW_OWNER_PID))] [DefaultProperty(nameof(table))] public class MIB_TCPTABLE_OWNER_PID : SafeElementArray { /// Initializes a new instance of the class. /// Amount of space, in bytes, to reserve. public MIB_TCPTABLE_OWNER_PID(uint byteSize) : base((int)byteSize, 0) { } /// /// The number of MIB_TCPROW_OWNER_PID elements in the table. /// public uint dwNumEntries => Count; /// /// Array of MIB_TCPROW_OWNER_PID structures returned by a call to GetExtendedTcpTable. /// public MIB_TCPROW_OWNER_PID[] table { get => Elements; set => Elements = value; } /// Performs an implicit conversion from to . /// The MIB_TCPTABLE_OWNER_PID instance. /// The result of the conversion. public static implicit operator IntPtr(MIB_TCPTABLE_OWNER_PID table) => table.DangerousGetHandle(); } /// The MIB_TCPTABLE2 structure contains a table of IPv4 TCP connections on the local computer. /// /// /// The GetTcpTable2function retrieves the IPv4 TCP connection table on the local computer and returns this information in a /// MIB_TCPTABLE2 structure. An array of MIB_TCPROW2 structures are contained in the MIB_TCPTABLE2 structure. /// /// /// The MIB_TCPTABLE2 structure may contain padding for alignment between the dwNumEntries member and the first /// MIB_TCPROW2 array entry in the table member. Padding for alignment may also be present between the MIB_TCPROW2 /// array entries in the table member. Any access to a MIB_TCPROW2 array entry should assume padding may exist. /// /// Examples /// /// The following example retrieves the TCP connection table for IPv4 as a MIB_TCPTABLE2 structure prints the state of each /// connection represented as a MIB_TCPROW2 structure. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/tcpmib/ns-tcpmib-_mib_tcptable2 typedef struct _MIB_TCPTABLE2 { DWORD // dwNumEntries; MIB_TCPROW2 table[ANY_SIZE]; } MIB_TCPTABLE2, *PMIB_TCPTABLE2; [PInvokeData("tcpmib.h", MSDNShortId = "e07de994-0bd5-4d18-9012-8ff191dd6939")] [CorrespondingType(typeof(MIB_TCPROW2))] [DefaultProperty(nameof(table))] public class MIB_TCPTABLE2 : SafeElementArray { /// Initializes a new instance of the class. /// Amount of space, in bytes, to reserve. public MIB_TCPTABLE2(uint byteSize) : base((int)byteSize, 0) { } /// The number of entries in the table. public uint dwNumEntries => Count; /// /// A pointer to a table of TCP connections implemented as an array of MIB_TCPROW2 structures. /// public MIB_TCPROW2[] table { get => Elements; set => Elements = value; } /// Performs an implicit conversion from to . /// The MIB_TCPTABLE instance. /// The result of the conversion. public static implicit operator IntPtr(MIB_TCPTABLE2 table) => table.DangerousGetHandle(); } } }