Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ GetNetworkInterfaces()

static NetworkInterface[] System.Net.NetworkInformation.SystemNetworkInterface.GetNetworkInterfaces ( )
inlinestaticpackage

Definition at line 90 of file SystemNetworkInterface.cs.

91 {
93 uint outBufLen = 0u;
94 ref readonly global::Interop.IpHlpApi.FIXED_INFO fixedInfo = ref System.Net.NetworkInformation.HostInformationPal.FixedInfo;
96 global::Interop.IpHlpApi.GetAdaptersAddressesFlags flags = global::Interop.IpHlpApi.GetAdaptersAddressesFlags.IncludeWins | global::Interop.IpHlpApi.GetAdaptersAddressesFlags.IncludeGateways;
97 uint adaptersAddresses = global::Interop.IpHlpApi.GetAdaptersAddresses(family, (uint)flags, IntPtr.Zero, IntPtr.Zero, ref outBufLen);
98 while (true)
99 {
100 switch (adaptersAddresses)
101 {
102 case 111u:
103 {
105 try
106 {
107 adaptersAddresses = global::Interop.IpHlpApi.GetAdaptersAddresses(family, (uint)flags, IntPtr.Zero, intPtr, ref outBufLen);
108 if (adaptersAddresses == 0)
109 {
111 while (intPtr2 != IntPtr.Zero)
112 {
113 global::Interop.IpHlpApi.IpAdapterAddresses ipAdapterAddresses = Marshal.PtrToStructure<global::Interop.IpHlpApi.IpAdapterAddresses>(intPtr2);
116 }
117 }
118 }
119 finally
120 {
122 }
123 break;
124 }
125 case 87u:
126 case 232u:
127 return Array.Empty<SystemNetworkInterface>();
128 default:
129 throw new NetworkInformationException((int)adaptersAddresses);
130 case 0u:
131 return list.ToArray();
132 }
133 }
134 }
static ref readonly global::Interop.IpHlpApi.FIXED_INFO FixedInfo
SystemNetworkInterface(in global::Interop.IpHlpApi.FIXED_INFO fixedInfo, in global::Interop.IpHlpApi.IpAdapterAddresses ipAdapterAddresses)
static void FreeHGlobal(IntPtr hglobal)
Definition Marshal.cs:1680
static ? object PtrToStructure(IntPtr ptr, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type structureType)
Definition Marshal.cs:1164
static IntPtr AllocHGlobal(int cb)
Definition Marshal.cs:625

References System.Net.NetworkInformation.SystemNetworkInterface.SystemNetworkInterface(), System.Runtime.InteropServices.Marshal.AllocHGlobal(), System.Net.NetworkInformation.HostInformationPal.FixedInfo, System.Runtime.InteropServices.Marshal.FreeHGlobal(), System.list, System.Runtime.InteropServices.Marshal.PtrToStructure(), and System.IntPtr.Zero.

Referenced by System.Net.NetworkInformation.NetworkInterfacePal.GetAllNetworkInterfaces(), and System.Net.NetworkInformation.SystemNetworkInterface.InternalGetIsNetworkAvailable().