using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Vanara.InteropServices;
using static Vanara.PInvoke.Ws2_32;
namespace Vanara.PInvoke
{
public static partial class IpHlpApi
{
/// Set the value of MIB_IPSTATS.dwDefaultTTL to this value to keep the current value when calling SetIpStatistics.
public const uint MIB_USE_CURRENT_TTL = uint.MaxValue;
/// The address type or state for .
[PInvokeData("ipmib.h", MSDNShortId = "ed1777bd-4c02-43e0-9bbb-6bb02702e1a4")]
[Flags]
public enum MIB_IPADDRTYPE : ushort
{
/// Primary IP address.
MIB_IPADDR_PRIMARY = 0x0001,
/// Dynamic IP address.
MIB_IPADDR_DYNAMIC = 0x0004,
/// Address is on disconnected interface
MIB_IPADDR_DISCONNECTED = 0x0008,
/// Address is being deleted
MIB_IPADDR_DELETED = 0x0040,
/// Transient address
MIB_IPADDR_TRANSIENT = 0x0080,
/// Address is eligible for DNS.
MIB_IPADDR_DNS_ELIGIBLE = 0X0100,
}
/// The MIB_IPFORWARD_PROTO enumeration indicates which protocols have updated routes.
[PInvokeData("IpHlpApi.h")]
public enum MIB_IPFORWARD_PROTO
{
/// A route added by a protocol not specified in [RFC1354].
MIB_IPPROTO_OTHER = 1,
/// A route added locally on an interface.
MIB_IPPROTO_LOCAL = 2,
///
/// A static route. This value is used to identify route information for IP routing set through network management such as DHCP,
/// the Simple Network Management Protocol (SNMP), or by any other API to create routes.
///
MIB_IPPROTO_NETMGMT = 3,
/// A route added as a result of an Internet Control Message Protocol (ICMP) redirect.
MIB_IPPROTO_ICMP = 4,
/// A route added by the Exterior Gateway Protocol (EGP), a dynamic routing protocol.
MIB_IPPROTO_EGP = 5,
/// A route added by the Gateway-to-Gateway Protocol (GGP), a dynamic routing protocol.
MIB_IPPROTO_GGP = 6,
///
/// A route added by the Hellospeak protocol, a dynamic routing protocol. This protocol is not supported and MUST NOT be used.
///
MIB_IPPROTO_HELLO = 7,
///
/// A route added by the Berkeley Routing Information Protocol (RIP) or RIP-II, a dynamic routing protocol. See [RFC1058] and [RFC1723].
///
MIB_IPPROTO_RIP = 8,
///
/// A route added by the Intermediate System-to-Intermediate System (IS-IS) protocol, a dynamic routing protocol. The IS-IS
/// protocol was developed for use in the Open Systems Interconnection (OSI) protocol suite.
///
MIB_IPPROTO_IS_IS = 9,
///
/// A route added by the End System-to-Intermediate System (ES-IS) protocol, a dynamic routing protocol. The ES-IS protocol was
/// developed for use in the Open Systems Interconnection (OSI) protocol suite.
///
MIB_IPPROTO_ES_IS = 10,
/// A route added by the Cisco Interior Gateway Routing Protocol (IGRP), a dynamic routing protocol.
MIB_IPPROTO_CISCO = 11,
///
/// A route added by the Bolt, Beranek, and Newman (BBN) Interior Gateway Protocol (IGP) that used the Shortest Path First (SPF)
/// algorithm, a dynamic routing protocol.
///
MIB_IPPROTO_BBN = 12,
/// A route added by the Open Shortest Path First (OSPF) protocol, a dynamic routing protocol.
MIB_IPPROTO_OSPF = 13,
/// A route added by the Border Gateway Protocol (BGP), a dynamic routing protocol.
MIB_IPPROTO_BGP = 14,
/// The mib ipproto idpr
MIB_IPPROTO_IDPR = 15,
/// The mib ipproto eigrp
MIB_IPPROTO_EIGRP = 16,
/// The mib ipproto DVMRP
MIB_IPPROTO_DVMRP = 17,
/// The mib ipproto RPL
MIB_IPPROTO_RPL = 18,
/// The mib ipproto DHCP
MIB_IPPROTO_DHCP = 19,
/// A route that was originally generated by a routing protocol, but now is static.
MIB_IPPROTO_NT_AUTOSTATIC = 10002,
/// A route added as a static route from the routing user interface (5) or a routing command.
MIB_IPPROTO_NT_STATIC = 10006,
///
/// A route added as a static route from the routing user interface or a routing command. These routes do not cause demand-dial.
///
MIB_IPPROTO_NT_STATIC_NON_DOD = 10007,
}
/// Specifies the type of the IP route.
[PInvokeData("IpHlpApi.h")]
public enum MIB_IPFORWARD_TYPE
{
/// Other than the type specified in [RFC1354].
MIB_IPROUTE_TYPE_OTHER = 1,
/// An invalid route is deleted.
MIB_IPROUTE_TYPE_INVALID = 2,
/// A local route where the next hop is the final destination (a local interface).
MIB_IPROUTE_TYPE_DIRECT = 3,
/// The remote route where the next hop is not the final destination (a remote destination).
MIB_IPROUTE_TYPE_INDIRECT = 4,
}
/// The type of ARP entry in .
[PInvokeData("ipmib.h")]
public enum MIB_IPNET_TYPE
{
/// Other
MIB_IPNET_TYPE_OTHER = 1,
/// An invalid ARP type. This can indicate an unreachable or incomplete ARP entry.
MIB_IPNET_TYPE_INVALID = 2,
/// A dynamic ARP type.
MIB_IPNET_TYPE_DYNAMIC = 3,
/// A static ARP type.
MIB_IPNET_TYPE_STATIC = 4,
}
/// Specifies whether IP forwarding is enabled or disabled for a protocol (IPv4 or IPv6).
[PInvokeData("ipmib.h", MSDNShortId = "920e71b6-247c-4442-9f66-704a6c878feb")]
public enum MIB_IPSTATS_FORWARDING
{
/// IP forwarding is enabled.
MIB_IP_FORWARDING = 1,
/// IP forwarding is not enabled.
MIB_IP_NOT_FORWARDING = 2,
///
/// Use the current IP forwarding setting. This value is only applicable when setting the forwarding and time-to-live (TTL)
/// options using the SetIpStatistics and SetIpStatisticsEx functions.
///
MIB_USE_CURRENT_FORWARDING = -1
}
/// The MIB_TCP_STATE enumeration enumerates different possible TCP states.
[PInvokeData("IpHlpApi.h", MSDNShortId = "cc669305")]
public enum MIB_TCP_STATE
{
/// The TCP connection is closed.
MIB_TCP_STATE_CLOSED,
/// The TCP connection is in the listen state.
MIB_TCP_STATE_LISTEN,
/// A SYN packet has been sent.
MIB_TCP_STATE_SYN_SENT,
/// A SYN packet has been received.
MIB_TCP_STATE_SYN_RCVD,
/// The TCP connection has been established.
MIB_TCP_STATE_ESTAB,
/// The TCP connection is waiting for a FIN packet.
MIB_TCP_STATE_FIN_WAIT1,
/// The TCP connection is waiting for a FIN packet.
MIB_TCP_STATE_FIN_WAIT2,
/// The TCP connection is in the close wait state.
MIB_TCP_STATE_CLOSE_WAIT,
/// The TCP connection is closing.
MIB_TCP_STATE_CLOSING,
/// The TCP connection is in the last ACK state.
MIB_TCP_STATE_LAST_ACK,
/// The TCP connection is in the time wait state.
MIB_TCP_STATE_TIME_WAIT,
/// The TCP connection is in the delete TCB state.
MIB_TCP_STATE_DELETE_TCB,
}
///
/// The MIB_ICMP structure contains the Internet Control Message Protocol (ICMP) statistics for a particular computer.
///
///
/// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files
/// has changed and the MIB_ICMP structure is defined in the Ipmib.h header file not in the Iprtrmib.h header file. Note that
/// the Ipmib.h header file is automatically included in Iprtrmib.h which is automatically included in the Iphlpapi.h header file.
/// The Ipmib.h and Iprtrmib.h header files should never be used directly.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/ipmib/ns-ipmib-_mib_icmp typedef struct _MIB_ICMP { MIBICMPINFO stats; }
// MIB_ICMP, *PMIB_ICMP;
[PInvokeData("ipmib.h", MSDNShortId = "45ccaacb-f2cd-4be5-94ef-48d4403d5f60")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct MIB_ICMP
{
/// A MIBICMPINFO structure that contains the ICMP statistics for the computer.
public MIBICMPINFO stats;
}
///
///
/// The MIB_ICMP_EX structure contains the extended Internet Control Message Protocol (ICMP) statistics for a particular computer.
///
///
///
///
/// Two MIBICMPSTATS_EX structures are required to hold all the extended ICMP statistics for a given computer. One
/// MIBICMPSTATS_EX structure contains the extended statistics for incoming ICMP messages. The other contains the extended
/// statistics for outgoing ICMP messages. For this reason, the MIB_ICMP_EX structure contains two MIBICMPSTATS_EX structures.
///
///
/// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files
/// has changed and the MIB_ICMP_EX structure is defined in the Ipmib.h header file not in the Iprtrmib.h header file. Note
/// that the Ipmib.h header file is automatically included in Iprtrmib.h which is automatically included in the Iphlpapi.h header
/// file. The Ipmib.h and Iprtrmib.h header files should never be used directly.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/ipmib/ns-ipmib-_mib_icmp_ex_xpsp1 typedef struct _MIB_ICMP_EX_XPSP1 {
// MIBICMPSTATS_EX icmpInStats; MIBICMPSTATS_EX icmpOutStats; } MIB_ICMP_EX_XPSP1, *PMIB_ICMP_EX_XPSP1;
[PInvokeData("ipmib.h", MSDNShortId = "3d2c7edc-c9e6-4db6-b7c8-07f7f01cbe0d")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct MIB_ICMP_EX
{
/// Specifies an MIBICMPSTATS_EX structure that contains the extended statistics for incoming ICMP messages.
public MIBICMPSTATS_EX icmpInStats;
/// Specifies an MIBICMPSTATS_EX structure that contains the extended statistics for outgoing ICMP messages.
public MIBICMPSTATS_EX icmpOutStats;
}
///
/// The MIB_IPADDRROW specifies information for a particular IPv4 address in the MIB_IPADDRTABLE structure.
///
///
///
/// On Windows XP and later, the dwIndex member of the MIB_IPADDRROW structure has a data type of IF_INDEX. The
/// wType member is only available on Windows XP and later. On Windows 2000 and earlier, this member is defined as Unused2.
///
///
/// The GetIpAddrTable function retrieves the interface–to–IPv4 address mapping table on a local computer and returns this
/// information in an MIB_IPADDRTABLE structure. The table member in the MIB_IPADDRTABLE structure contains an array of
/// MIB_IPADDRROW entries.
///
///
/// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files
/// has changed and the MIB_IPADDRROW structure is defined in the Ipmib.h header file not in the Iprtrmib.h header file. Note
/// that the Ipmib.h header file is automatically included in Iprtrmib.h which is automatically included in the Iphlpapi.h header
/// file. The Ipmib.h and Iprtrmib.h header files should never be used directly.
///
/// Examples
///
/// To view an example that retrieves the MIB_IPADDRTABLE structure and then prints out the MIB_IPADDRROW structures in this
/// table, see the GetIpAddrTable function.
///
///
// https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/ipmib/ns-ipmib-_mib_ipaddrrow_xp typedef struct
// _MIB_IPADDRROW_XP { DWORD dwAddr; IF_INDEX dwIndex; DWORD dwMask; DWORD dwBCastAddr; DWORD dwReasmSize; unsigned short unused1;
// unsigned short wType; } MIB_IPADDRROW_XP, *PMIB_IPADDRROW_XP;
[PInvokeData("ipmib.h", MSDNShortId = "ed1777bd-4c02-43e0-9bbb-6bb02702e1a4")]
[StructLayout(LayoutKind.Sequential, Pack = 2)]
public struct MIB_IPADDRROW
{
///
/// Type: DWORD
/// The IPv4 address in network byte order.
///
public IN_ADDR dwAddr;
///
/// Type: DWORD
/// The index of the interface associated with this IPv4 address.
///
public uint dwIndex;
///
/// Type: DWORD
/// The subnet mask for the IPv4 address in network byte order.
///
public IN_ADDR dwMask;
///
/// Type: DWORD
///
/// The broadcast address in network byte order. A broadcast address is typically the IPv4 address with the host portion set to
/// either all zeros or all ones.
///
/// The proper value for this member is not returned by the GetIpAddrTable function.
///
public IN_ADDR dwBCastAddr;
///
/// Type: DWORD
/// The maximum re-assembly size for received datagrams.
///
public uint dwReasmSize;
///
/// Type: unsigned short
/// This member is reserved.
///
public ushort unused1;
///
/// Type: unsigned short
/// The address type or state. This member can be a combination of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// MIB_IPADDR_PRIMARY 0x0001
/// Primary IP address
///
/// -
/// MIB_IPADDR_DYNAMIC 0x0004
/// Dynamic IP address
///
/// -
/// MIB_IPADDR_DISCONNECTED 0x0008
/// Address is on disconnected interface
///
/// -
/// MIB_IPADDR_DELETED 0x0040
/// Address is being deleted
///
/// -
/// MIB_IPADDR_TRANSIENT 0x0080
/// Transient address
///
///
///
public MIB_IPADDRTYPE wType;
}
///
/// The MIB_IPFORWARDROW structure contains information that describes an IPv4 network route.
///
///
///
/// The GetIpForwardTable function enumerates the IPv4 route entries on a local system and returns this information in a
/// MIB_IPFORWARDTABLE structure that contains an array of MIB_IPFORWARDROW structure entries.
///
///
/// The dwForwardDest, dwForwardMask, and dwForwardNextHop members of the MIB_IPFORWARDROW structure
/// represent IPv4 addresses in network byte order.
///
///
/// The dwForwardProto member of the MIB_IPFORWARDROW structure specifies the protocol or routing mechanism that
/// generated the route. Routing protocol identifiers are used to identify route information for the specified routing protocol. For
/// example, MIB_IPPROTO_NETMGMT is used to identify route information for IP routing set through network management such as
/// the Dynamic Host Configuration Protocol (DCHP), the Simple Network Management Protocol (SNMP), or by calls to the
/// CreateIpForwardEntry, DeleteIpForwardEntry , or SetIpForwardEntry functions. See Protocol Identifiers for a list of possible
/// protocols and routing mechanisms.
///
///
/// An IPv4 address of 0.0.0.0 in the dwForwardDest member of the MIB_IPFORWARDROW structure is considered a default
/// route. The MIB_IPFORWARDTABLE may contain multiple MIB_IPFORWARDROW entries with the dwForwardDest member set to
/// 0.0.0.0 when there are multiple network adapters installed.
///
/// When dwForwardAge is set to INFINITE, the route will not be removed based on a timeout
///
/// value. Any other value for dwForwardAge specifies the number of seconds since the route was added or modified in the
/// network routing table.
///
///
/// On Windows Server 2003 or Windows 2000 Server when the Routing and Remote Access Service (RRAS) is running, the
/// MIB_IPFORWARDROW entries returned have the dwForwardType and dwForwardAge members set to zero.
///
///
/// On Windows Vista and Windows Server 2008, the route metric specified in the dwForwardMetric1 member of the
/// MIB_IPFORWARDROW structure represents a combination of the route metric added to the interface metric specified in the
/// Metric member of the MIB_IPINTERFACE_ROW structure of the associated interface. So the dwForwardMetric1 member of
/// the MIB_IPFORWARDROW structure should be equal to or greater than Metric member of the associated
/// MIB_IPINTERFACE_ROW structure. If an application would like to set the route metric to 0, then the dwForwardMetric1
/// member of the MIB_IPFORWARDROW structure should be set equal to the value of the interface metric specified in the
/// Metric member of the associated MIB_IPINTERFACE_ROW structure. An application can retrieve the interface metric by
/// calling the GetIpInterfaceEntry function.
///
///
/// A number of members of the MIB_IPFORWARDROW structure are not currently used by IPv4 routing. These members include
/// dwForwardPolicy, dwForwardNextHopAS, dwForwardMetric2, dwForwardMetric3, dwForwardMetric4, and dwForwardMetric5.
///
///
/// 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 Ipmib.h header file, not in the Iprtrmib.h header file. Note that the Ipmib.h
/// header file is automatically included in Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Ipmib.h
/// and Iprtrmib.h header files should never be used directly.
///
/// Examples
///
/// To view an example that retrieves the MIB_IPFORWARDTABLE structure and then prints out the MIB_IPFORWARDROW structure
/// entries in this table, see the GetIpForwardTable function.
///
///
// https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/ipmib/ns-ipmib-_mib_ipforwardrow typedef struct
// _MIB_IPFORWARDROW { DWORD dwForwardDest; DWORD dwForwardMask; DWORD dwForwardPolicy; DWORD dwForwardNextHop; IF_INDEX
// dwForwardIfIndex; union { DWORD dwForwardType; MIB_IPFORWARD_TYPE ForwardType; }; union { DWORD dwForwardProto;
// MIB_IPFORWARD_PROTO ForwardProto; }; DWORD dwForwardAge; DWORD dwForwardNextHopAS; DWORD dwForwardMetric1; DWORD dwForwardMetric2;
// DWORD dwForwardMetric3; DWORD dwForwardMetric4; DWORD dwForwardMetric5; } MIB_IPFORWARDROW, *PMIB_IPFORWARDROW;
[PInvokeData("ipmib.h", MSDNShortId = "ff451481-3e9d-4add-94e2-846d67002a38")]
[StructLayout(LayoutKind.Sequential)]
public struct MIB_IPFORWARDROW
{
///
/// Type: DWORD
///
/// The destination IPv4 address of the route. An entry with a IPv4 address of 0.0.0.0 is considered a default route. This member
/// cannot be set to a multicast (class D) IPv4 address.
///
///
public IN_ADDR dwForwardDest;
///
/// Type: DWORD
///
/// The IPv4 subnet mask to use with the destination IPv4 address before being compared to the value in the dwForwardDest member.
///
///
/// The dwForwardMask value should be applied to the destination IPv4 address (logical and operation) before a comparison
/// with the value in the dwForwardDest member.
///
///
public IN_ADDR dwForwardMask;
///
/// Type: DWORD
///
/// The set of conditions that would cause the selection of a multi-path route (the set of next hops for a given destination).
/// This member is typically in IP TOS format. This encoding of this member is described in RFC 1354. For more information, see http://www.ietf.org/rfc/rfc1354.txt.
///
///
public uint dwForwardPolicy;
///
/// Type: DWORD
///
/// For remote routes, the IPv4 address of the next system en route. Otherwise, this member should be an IPv4 address of 0.0.0.0.
///
///
public IN_ADDR dwForwardNextHop;
///
/// Type: DWORD
/// The index of the local interface through which the next hop of this route should be reached.
///
public uint dwForwardIfIndex;
///
public MIB_IPFORWARD_TYPE dwForwardType;
///
public MIB_IPFORWARD_PROTO dwForwardProto;
///
/// Type: DWORD
/// The number of seconds since the route was added or modified in the network routing table.
///
public uint dwForwardAge;
///
/// Type: DWORD
///
/// The autonomous system number of the next hop. When this member is unknown or not relevant to the protocol or routing
/// mechanism specified in dwForwardProto, this value should be set to zero. This value is documented in RFC 1354. For
/// more information, see http://www.ietf.org/rfc/rfc1354.txt
///
///
public uint dwForwardNextHopAS;
///
/// Type: DWORD
///
/// The primary routing metric value for this route. The semantics of this metric are determined by the routing protocol
/// specified in the dwForwardProto member. If this metric is not used, its value should be set to -1. This value is
/// documented in in RFC 1354. For more information, see http://www.ietf.org/rfc/rfc1354.txt
///
///
public uint dwForwardMetric1;
///
/// Type: DWORD
///
/// An alternate routing metric value for this route. The semantics of this metric are determined by the routing protocol
/// specified in the dwForwardProto member. If this metric is not used, its value should be set to -1. This value is
/// documented in RFC 1354. For more information, see http://www.ietf.org/rfc/rfc1354.txt
///
///
public uint dwForwardMetric2;
///
/// Type: DWORD
///
/// An alternate routing metric value for this route. The semantics of this metric are determined by the routing protocol
/// specified in the dwForwardProto member. If this metric is not used, its value should be set to -1. This value is
/// documented in RFC 1354. For more information, see http://www.ietf.org/rfc/rfc1354.txt
///
///
public uint dwForwardMetric3;
///
/// Type: DWORD
///
/// An alternate routing metric value for this route. The semantics of this metric are determined by the routing protocol
/// specified in the dwForwardProto member. If this metric is not used, its value should be set to -1. This value is
/// documented in RFC 1354. For more information, see http://www.ietf.org/rfc/rfc1354.txt
///
///
public uint dwForwardMetric4;
///
/// Type: DWORD
///
/// An alternate routing metric value for this route. The semantics of this metric are determined by the routing protocol
/// specified in the dwForwardProto member. If this metric is not used, its value should be set to -1. This value is
/// documented in RFC 1354. For more information, see http://www.ietf.org/rfc/rfc1354.txt
///
///
public uint dwForwardMetric5;
}
///
///
/// The MIB_IPNETROW structure contains information for an Address Resolution Protocol (ARP) table entry for an IPv4 address.
///
///
///
///
/// On the Windows SDK released for Windows Vista and later, the organization of header files has changed and the MIB_IPNETROW
/// structure is defined in the Ipmib.h header file not in the Iprtrmib.h header file. Note that the Ipmib.h header file is
/// automatically included in Iprtrmib.h which is automatically included in the Iphlpapi.h header file. The Ipmib.h and Iprtrmib.h
/// header files should never be used directly.
///
///
// https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/ipmib/ns-ipmib-_mib_ipnetrow_lh typedef struct
// _MIB_IPNETROW_LH { IF_INDEX dwIndex; DWORD dwPhysAddrLen; UCHAR bPhysAddr[MAXLEN_PHYSADDR]; DWORD dwAddr; union { DWORD dwType;
// MIB_IPNET_TYPE Type; }; } MIB_IPNETROW_LH, *PMIB_IPNETROW_LH;
[PInvokeData("ipmib.h", MSDNShortId = "aa9aa9f9-2334-4b08-896f-f4a77caa0f7f")]
[StructLayout(LayoutKind.Sequential)]
public struct MIB_IPNETROW
{
///
/// Type: DWORD
/// The index of the adapter.
///
public uint dwIndex;
///
/// Type: DWORD
/// The length, in bytes, of the physical address.
///
public uint dwPhysAddrLen;
///
/// Type: BYTE[MAXLEN_PHYSADDR]
/// The physical address.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXLEN_PHYSADDR)]
public byte[] bPhysAddr;
///
/// Type: DWORD
/// The IPv4 address.
///
public IN_ADDR dwAddr;
/// The type of ARP entry. This type can be one of the following values.
public MIB_IPNET_TYPE dwType;
/// Initializes a new instance of the struct.
/// The IPv4 address.
/// The index of the adapter.
/// The physical hardware address of the adapter for the network interface associated with this IP address.
/// The type of ARP entry.
public MIB_IPNETROW(IN_ADDR ipV4, uint ifIdx, byte[] macAddr = null, MIB_IPNET_TYPE? type = null)
{
dwIndex = ifIdx;
dwAddr = ipV4;
dwPhysAddrLen = macAddr == null ? 0U : (uint)macAddr.Length;
bPhysAddr = new byte[8];
if (macAddr != null) Array.Copy(macAddr, bPhysAddr, 6);
dwType = type ?? MIB_IPNET_TYPE.MIB_IPNET_TYPE_OTHER;
}
}
/// The MIB_IPSTATS structure stores information about the IP protocol running on a particular computer.
///
/// The MIB_IPSTATS structure stores information per protocol (IPv4 or IPv6).
///
/// The dwForwarding member specifies the per-protocol forwarding state for IPv4 or IPv6, not the forwarding state for an
/// interface. The forwarding state of each interface state is the state that is in affect for that interface. The per-protocol state
/// returned by the GetIpStatistics or the GetIpStatisticsEx function is not the forwarding state in affect. The
/// dwForwarding member exists to serve two purposes:
///
///
/// -
///
/// Provides a default value for the forwarding state when a new interface is created with no specific forwarding state (neither
/// disabled nor enabled) . This value is inherited per-protocol state.
///
///
/// -
///
/// Provides a value set by a domain administrator to enable or disable a per-protocol forwarding state. The forwarding states of all
/// interfaces using that protocol are also enabled or disabled.
///
///
///
///
/// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files
/// has changed and the MIB_IPSTATS structure is defined in the Ipmib.h header file not in the Iprtrmib.h header file. Note
/// that the Ipmib.h header file is automatically included in Iprtrmib.h which is automatically included in the Iphlpapi.h header
/// file. The Ipmib.h and Iprtrmib.h header files should never be used directly.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/ipmib/ns-ipmib-mib_ipstats_w2k typedef struct _MIB_IPSTATS_W2K { DWORD
// dwForwarding; DWORD dwDefaultTTL; DWORD dwInReceives; DWORD dwInHdrErrors; DWORD dwInAddrErrors; DWORD dwForwDatagrams; DWORD
// dwInUnknownProtos; DWORD dwInDiscards; DWORD dwInDelivers; DWORD dwOutRequests; DWORD dwRoutingDiscards; DWORD dwOutDiscards;
// DWORD dwOutNoRoutes; DWORD dwReasmTimeout; DWORD dwReasmReqds; DWORD dwReasmOks; DWORD dwReasmFails; DWORD dwFragOks; DWORD
// dwFragFails; DWORD dwFragCreates; DWORD dwNumIf; DWORD dwNumAddr; DWORD dwNumRoutes; } MIB_IPSTATS_W2K, *PMIB_IPSTATS_W2K;
[PInvokeData("ipmib.h", MSDNShortId = "920e71b6-247c-4442-9f66-704a6c878feb")]
[StructLayout(LayoutKind.Sequential)]
public struct MIB_IPSTATS
{
///
/// Type: DWORD
/// Specifies whether IP forwarding is enabled or disabled for a protocol (IPv4 or IPv6).
///
/// On Windows Vista and later, this member is defined as a union containing a DWORD dwForwarding member and a
/// MIB_IPSTATS_FORWARDING Forwarding member where MIB_IPSTATS_FORWARDING is an enumeration defined in the Ipmib.h
/// header file.
///
///
/// Note This member applies to the entire system per protocol (IPv4 or IPv6) and doesn’t return per interface
/// configuration for IP forwarding.
///
///
///
/// Value
/// Meaning
///
/// -
/// MIB_IP_FORWARDING 1
/// IP forwarding is enabled.
///
/// -
/// MIB_IP_NOT_FORWARDING 2
/// IP forwarding is not enabled.
///
/// -
/// MIB_USE_CURRENT_FORWARDING 0xffff
///
/// Use the current IP forwarding setting. This value is only applicable when setting the forwarding and time-to-live (TTL)
/// options using the SetIpStatistics and SetIpStatisticsEx functions.
///
///
///
///
public MIB_IPSTATS_FORWARDING Forwarding;
///
/// Type: DWORD
/// The default initial time-to-live (TTL) for datagrams originating on a particular computer.
///
/// This member can be set to MIB_USE_CURRENT_TTL to use the current deafult TTL value when setting the forwarding and
/// time-to-live (TTL) options using the SetIpStatistics and SetIpStatisticsEx functions.
///
///
public uint dwDefaultTTL;
///
/// Type: DWORD
/// The number of datagrams received.
///
public uint dwInReceives;
///
/// Type: DWORD
/// The number of datagrams received that have header errors.
///
public uint dwInHdrErrors;
///
/// Type: DWORD
/// The number of datagrams received that have address errors.
///
public uint dwInAddrErrors;
///
/// Type: DWORD
/// The number of datagrams forwarded.
///
public uint dwForwDatagrams;
///
/// Type: DWORD
/// The number of datagrams received that have an unknown protocol.
///
public uint dwInUnknownProtos;
///
/// Type: DWORD
/// The number of received datagrams discarded.
///
public uint dwInDiscards;
///
/// Type: DWORD
/// The number of received datagrams delivered.
///
public uint dwInDelivers;
///
/// Type: DWORD
/// The number of outgoing datagrams that IP is requested to transmit. This number does not include forwarded datagrams.
///
public uint dwOutRequests;
///
/// Type: DWORD
/// The number of outgoing datagrams discarded.
///
public uint dwRoutingDiscards;
///
/// Type: DWORD
/// The number of transmitted datagrams discarded.
///
public uint dwOutDiscards;
///
/// Type: DWORD
///
/// The number of datagrams for which this computer did not have a route to the destination IP address. These datagrams were discarded.
///
///
public uint dwOutNoRoutes;
///
/// Type: DWORD
///
/// The amount of time allowed for all pieces of a fragmented datagram to arrive. If all pieces do not arrive within this time,
/// the datagram is discarded.
///
///
public uint dwReasmTimeout;
///
/// Type: DWORD
/// The number of datagrams that require re-assembly.
///
public uint dwReasmReqds;
///
/// Type: DWORD
/// The number of datagrams that were successfully reassembled.
///
public uint dwReasmOks;
///
/// Type: DWORD
/// The number of datagrams that cannot be reassembled.
///
public uint dwReasmFails;
///
/// Type: DWORD
/// The number of datagrams that were fragmented successfully.
///
public uint dwFragOks;
///
/// Type: DWORD
///
/// The number of datagrams that have not been fragmented because the IP header specifies no fragmentation. These datagrams are discarded.
///
///
public uint dwFragFails;
///
/// Type: DWORD
/// The number of fragments created.
///
public uint dwFragCreates;
///
/// Type: DWORD
/// The number of interfaces.
///
public uint dwNumIf;
///
/// Type: DWORD
/// The number of IP addresses associated with this computer.
///
public uint dwNumAddr;
///
/// Type: DWORD
/// The number of routes in the IP routing table.
///
public uint dwNumRoutes;
}
/// The MIBICMPINFO structure contains Internet Control Message Protocol (ICMP) statistics for a particular computer.
///
///
/// Two MIBICMPSTATS structures are required to hold all the ICMP statistics for a given computer. One MIBICMPSTATS structure
/// contains the statistics for incoming ICMP messages. The other contains the statistics for outgoing ICMP messages. For this
/// reason, the MIBICMPINFO structure contains two MIBICMPSTATS structures.
///
///
/// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files
/// has changed and the MIBICMPINFO structure is defined in the Ipmib.h header file not in the Iprtrmib.h header file. Note
/// that the Ipmib.h header file is automatically included in Iprtrmib.h which is automatically included in the Iphlpapi.h header
/// file. The Ipmib.h and Iprtrmib.h header files should never be used directly.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/ipmib/ns-ipmib-_mibicmpinfo typedef struct _MIBICMPINFO { MIBICMPSTATS
// icmpInStats; MIBICMPSTATS icmpOutStats; } MIBICMPINFO;
[PInvokeData("ipmib.h", MSDNShortId = "547da10e-3490-44d2-9142-0caed041503b")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct MIBICMPINFO
{
/// An MIBICMPSTATS structure that contains the statistics for incoming ICMP messages.
public MIBICMPSTATS icmpInStats;
/// An MIBICMPSTATS structure that contains the statistics for outgoing ICMP messages.
public MIBICMPSTATS icmpOutStats;
}
///
/// The MIBICMPSTATS structure contains statistics for either incoming or outgoing Internet Control Message Protocol (ICMP)
/// messages on a particular computer.
///
///
///
/// Two MIBICMPSTATS structures are required to hold all the ICMP statistics for a given computer. One MIBICMPSTATS
/// structure contains the statistics for incoming ICMP messages. The other contains the statistics for outgoing ICMP messages. For
/// this reason, the MIBICMPINFO structure contains two MIBICMPSTATS structures.
///
///
/// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files
/// has changed and the MIBICMPSTATS structure is defined in the Ipmib.h header file not in the Iprtrmib.h header file. Note
/// that the Ipmib.h header file is automatically included in Iprtrmib.h which is automatically included in the Iphlpapi.h header
/// file. The Ipmib.h and Iprtrmib.h header files should never be used directly.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/ipmib/ns-ipmib-_mibicmpstats typedef struct _MIBICMPSTATS { DWORD dwMsgs;
// DWORD dwErrors; DWORD dwDestUnreachs; DWORD dwTimeExcds; DWORD dwParmProbs; DWORD dwSrcQuenchs; DWORD dwRedirects; DWORD dwEchos;
// DWORD dwEchoReps; DWORD dwTimestamps; DWORD dwTimestampReps; DWORD dwAddrMasks; DWORD dwAddrMaskReps; } MIBICMPSTATS, *PMIBICMPSTATS;
[PInvokeData("ipmib.h", MSDNShortId = "080cdd28-3e2d-4cd0-8e5a-9ec9dcb9df48")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct MIBICMPSTATS
{
///
/// Type: DWORD
/// The number of messages received or sent.
///
public uint dwMsgs;
///
/// Type: DWORD
/// The number of errors received or sent.
///
public uint dwErrors;
///
/// Type: DWORD
///
/// The number of destination-unreachable messages received or sent. A destination-unreachable message is sent to the originating
/// computer when a datagram fails to reach its intended destination.
///
///
public uint dwDestUnreachs;
///
/// Type: DWORD
///
/// The number of time-to-live (TTL) exceeded messages received or sent. A time-to-live exceeded message is sent to the
/// originating computer when a datagram is discarded because the number of routers it has passed through exceeds its
/// time-to-live value.
///
///
public uint dwTimeExcds;
///
/// Type: DWORD
///
/// The number of parameter-problem messages received or sent. A parameter-problem message is sent to the originating computer
/// when a router or host detects an error in a datagram's IP header.
///
///
public uint dwParmProbs;
///
/// Type: DWORD
///
/// The number of source quench messages received or sent. A source quench request is sent to a computer to request that it
/// reduce its rate of packet transmission.
///
///
public uint dwSrcQuenchs;
///
/// Type: DWORD
///
/// The number of redirect messages received or sent. A redirect message is sent to the originating computer when a better route
/// is discovered for a datagram sent by that computer.
///
///
public uint dwRedirects;
///
/// Type: DWORD
///
/// The number of echo requests received or sent. An echo request causes the receiving computer to send an echo reply message
/// back to the originating computer.
///
///
public uint dwEchos;
///
/// Type: DWORD
///
/// The number of echo replies received or sent. A computer sends an echo reply in response to receiving an echo request message.
///
///
public uint dwEchoReps;
///
/// Type: DWORD
///
/// The number of time-stamp requests received or sent. A time-stamp request causes the receiving computer to send a time-stamp
/// reply back to the originating computer.
///
///
public uint dwTimestamps;
///
/// Type: DWORD
///
/// The number of time-stamp replies received or sent. A computer sends a time-stamp reply in response to receiving a time-stamp
/// request. Routers can use time-stamp requests and replies to measure the transmission speed of datagrams on a network.
///
///
public uint dwTimestampReps;
///
/// Type: DWORD
///
/// The number of address mask requests received or sent. A computer sends an address mask request to determine the number of
/// bits in the subnet mask for its local subnet.
///
///
public uint dwAddrMasks;
///
/// Type: DWORD
///
/// The number of address mask responses received or sent. A computer sends an address mask response in response to an address
/// mask request.
///
///
public uint dwAddrMaskReps;
}
///
///
/// The MIBICMPSTATS_EX structure contains extended statistics for either incoming or outgoing Internet Control Message
/// Protocol (ICMP) messages on a particular computer.
///
///
///
///
/// Two MIBICMPSTATS_EX structures are required to hold all the extended ICMP statistics for a given computer. One
/// MIBICMPSTATS_EX structure contains the extended statistics for incoming ICMP messages. The other contains the extended
/// statistics for outgoing ICMP messages. For this reason, the MIB_ICMP_EX structure contains two MIBICMPSTATS_EX structures.
///
///
/// On the Microsoft Windows Software Development Kit (SDK) released for Windows Vista and later, the organization of header files
/// has changed and the MIBICMPSTATS_EX structure is defined in the Ipmib.h header file not in the Iprtrmib.h header file.
/// Note that the Ipmib.h header file is automatically included in Iprtrmib.h which is automatically included in the Iphlpapi.h
/// header file. The Ipmib.h and Iprtrmib.h header files should never be used directly.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/ipmib/ns-ipmib-_mibicmpstats_ex_xpsp1 typedef struct _MIBICMPSTATS_EX_XPSP1 {
// DWORD dwMsgs; DWORD dwErrors; DWORD rgdwTypeCount[256]; } MIBICMPSTATS_EX_XPSP1, *PMIBICMPSTATS_EX_XPSP1;
[PInvokeData("ipmib.h", MSDNShortId = "d97921f8-8be0-4a14-887f-aaafcb82eb1f")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct MIBICMPSTATS_EX
{
///
/// Type: DWORD
/// Specifies the number of messages received or sent.
///
public uint dwMsgs;
///
/// Type: DWORD
/// The number of errors received or sent.
///
public uint dwErrors;
///
/// Type: DWORD[256]
/// The type count.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
public uint[] rgdwTypeCount;
}
///
/// The MIB_IPADDRTABLE structure contains a table of IPv4 address entries.
///
///
///
/// The GetIpAddrTable function retrieves the interface–to–IPv4 address mapping table on a local computer and returns this
/// information in an MIB_IPADDRTABLE structure.
///
///
/// The MIB_IPADDRTABLE structure may contain padding for alignment between the dwNumEntries member and the first
/// MIB_IPADDRROW array entry in the table member. Padding for alignment may also be present between the MIB_IPADDRROW
/// array entries in the table member. Any access to a MIB_IPADDRROW 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 and the MIB_IPADDRROW is defined in the Ipmib.h header file not in the Iprtrmib.h header file. Note that the Ipmib.h
/// header file is automatically included in Iprtrmib.h which is automatically included in the Iphlpapi.h header file. The Ipmib.h
/// and Iprtrmib.h header files should never be used directly.
///
/// Examples
///
/// To view an example that retrieves the MIB_IPADDRTABLE structure and then prints out the MIB_IPADDRROW structures in this
/// table, see the GetIpAddrTable function.
///
///
// https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/ipmib/ns-ipmib-_mib_ipaddrtable typedef struct
// _MIB_IPADDRTABLE { DWORD dwNumEntries; MIB_IPADDRROW table[ANY_SIZE]; } MIB_IPADDRTABLE, *PMIB_IPADDRTABLE;
[PInvokeData("ipmib.h", MSDNShortId = "12a929e5-813d-4dae-9ea0-5a3c0a88cf05")]
[CorrespondingType(typeof(MIB_IPADDRROW))]
[DefaultProperty(nameof(table))]
public class MIB_IPADDRTABLE : SafeElementArray
{
/// Initializes a new instance of the class.
/// Amount of space, in bytes, to reserve.
public MIB_IPADDRTABLE(uint byteSize) : base((int)byteSize, 0)
{
}
///
/// The number of IPv4 address entries in the table.
///
public uint dwNumEntries => Count;
///
/// A pointer to a table of IPv4 address entries implemented as an array of MIB_IPADDRROW structures.
///
public MIB_IPADDRROW[] table { get => Elements; set => Elements = value; }
/// Performs an implicit conversion from to .
/// The MIB_IPADDRTABLE instance.
/// The result of the conversion.
public static implicit operator IntPtr(MIB_IPADDRTABLE table) => table.DangerousGetHandle();
}
/// The MIB_IPFORWARDTABLE structure contains a table of IPv4 route entries.
///
///
/// The GetIpForwardTable function enumerates the IPv4 route entries on a local system and returns this information in a
/// MIB_IPFORWARDTABLE structure.
///
///
/// The MIB_IPFORWARDTABLE structure may contain padding for alignment between the dwNumEntries member and the first
/// MIB_IPFORWARDROW array entry in the table member. Padding for alignment may also be present between the
/// MIB_IPFORWARDROW array entries in the table member. Any access to a MIB_IPFORWARDROW 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 Ipmib.h header file, not in the Iprtrmib.h header file. Note that the Ipmib.h
/// header file is automatically included in Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Ipmib.h
/// and Iprtrmib.h header files should never be used directly.
///
/// Examples
///
/// To view an example that retrieves the MIB_IPFORWARDTABLE structure and then prints out the MIB_IPFORWARDROW structure
/// entries in this table, see the GetIpForwardTable function.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/ipmib/ns-ipmib-_mib_ipforwardtable typedef struct _MIB_IPFORWARDTABLE { DWORD
// dwNumEntries; MIB_IPFORWARDROW table[ANY_SIZE]; } MIB_IPFORWARDTABLE, *PMIB_IPFORWARDTABLE;
[PInvokeData("ipmib.h", MSDNShortId = "bdecf944-fe19-4033-8778-362523984b03")]
[CorrespondingType(typeof(MIB_IPFORWARDROW))]
[DefaultProperty(nameof(table))]
public class MIB_IPFORWARDTABLE : SafeElementArray
{
/// Initializes a new instance of the class.
/// Size of the byte.
public MIB_IPFORWARDTABLE(uint byteSize) : base((int)byteSize, 0)
{
}
/// The number of route entries in the table.
public uint dwNumEntries => Count;
/// A pointer to a table of route entries implemented as an array of MIB_IPFORWARDROW structures.
/// The .
///
public MIB_IPFORWARDROW[] table { get => Elements; set => Elements = value; }
/// Performs an implicit conversion from to .
/// The table.
/// The result of the conversion.
public static implicit operator IntPtr(MIB_IPFORWARDTABLE table) => table.DangerousGetHandle();
}
///
/// The MIB_IPNETTABLE structure contains a table of Address Resolution Protocol (ARP) entries for IPv4 addresses.
///
///
/// The GetIpNetTable function retrieves the IPv4-to-physical address mapping table.
/// on a local system and returns this information in a MIB_IPNETTABLE structure.
/// The dwNumEntries member in this structure may be zero if there are no ARP entries in the table.
///
/// The MIB_IPNETTABLE structure may contain padding for alignment between the dwNumEntries member and the first
/// MIB_IPNETROW array entry in the table member. Padding for alignment may also be present between the MIB_IPNETROW
/// array entries in the table member. Any access to a MIB_IPNETROW 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 and the MIB_IPNETTABLE structure is defined in the Ipmib.h header file not in the Iprtrmib.h header file. Note
/// that the Ipmib.h header file is automatically included in Iprtrmib.h which is automatically included in the Iphlpapi.h header
/// file. The Ipmib.h and Iprtrmib.h header files should never be used directly.
///
///
// https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/ipmib/ns-ipmib-_mib_ipnettable typedef struct
// _MIB_IPNETTABLE { DWORD dwNumEntries; MIB_IPNETROW table[ANY_SIZE]; } MIB_IPNETTABLE, *PMIB_IPNETTABLE;
[PInvokeData("ipmib.h", MSDNShortId = "1cac1c19-bc42-4aee-b9d0-d007b8798eeb")]
[CorrespondingType(typeof(MIB_IPNETROW))]
[DefaultProperty(nameof(table))]
public class MIB_IPNETTABLE : SafeElementArray
{
/// Initializes a new instance of the class.
/// Amount of space, in bytes, to reserve.
public MIB_IPNETTABLE(uint byteSize) : base((int)byteSize, 0)
{
}
///
/// The number of ARP entries in the table.
///
public uint dwNumEntries => Count;
///
/// A pointer to a table of ARP entries implemented as an array of MIB_IPNETROW structures.
///
public MIB_IPNETROW[] table { get => Elements; set => Elements = value; }
/// Performs an implicit conversion from to .
/// The MIB_IPNETTABLE instance.
/// The result of the conversion.
public static implicit operator IntPtr(MIB_IPNETTABLE table) => table.DangerousGetHandle();
}
}
}