Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SystemIPGlobalProperties.cs
Go to the documentation of this file.
5
7
9{
11
13
15
17
19
21 {
22 }
23
37
39 {
43 {
44 if (item.State == TcpState.Listen)
45 {
46 list.Add(item.LocalEndPoint);
47 }
48 }
49 return list.ToArray();
50 }
51
53 {
54 uint dwOutBufLen = 0u;
55 uint num = 0u;
58 {
59 num = global::Interop.IpHlpApi.GetTcpTable(IntPtr.Zero, ref dwOutBufLen, order: true);
60 while (true)
61 {
62 switch (num)
63 {
64 case 122u:
65 {
67 try
68 {
69 num = global::Interop.IpHlpApi.GetTcpTable(intPtr, ref dwOutBufLen, order: true);
70 if (num != 0)
71 {
72 continue;
73 }
75 ref readonly global::Interop.IpHlpApi.MibTcpTable reference = ref MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibTcpTable>(span);
76 if (reference.numberOfEntries != 0)
77 {
78 span = span.Slice(sizeof(global::Interop.IpHlpApi.MibTcpTable));
79 for (int i = 0; i < reference.numberOfEntries; i++)
80 {
81 list.Add(new SystemTcpConnectionInformation(in MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibTcpRow>(span)));
82 span = span.Slice(sizeof(global::Interop.IpHlpApi.MibTcpRow));
83 }
84 }
85 }
86 finally
87 {
89 }
90 continue;
91 }
92 default:
93 throw new NetworkInformationException((int)num);
94 case 0u:
95 case 232u:
96 break;
97 }
98 break;
99 }
100 }
102 {
103 dwOutBufLen = 0u;
104 num = global::Interop.IpHlpApi.GetExtendedTcpTable(IntPtr.Zero, ref dwOutBufLen, order: true, 23u, global::Interop.IpHlpApi.TcpTableClass.TcpTableOwnerPidAll, 0u);
105 while (true)
106 {
107 switch (num)
108 {
109 case 122u:
110 {
112 try
113 {
114 num = global::Interop.IpHlpApi.GetExtendedTcpTable(intPtr2, ref dwOutBufLen, order: true, 23u, global::Interop.IpHlpApi.TcpTableClass.TcpTableOwnerPidAll, 0u);
115 if (num != 0)
116 {
117 continue;
118 }
120 ref readonly global::Interop.IpHlpApi.MibTcp6TableOwnerPid reference2 = ref MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibTcp6TableOwnerPid>(span2);
121 if (reference2.numberOfEntries != 0)
122 {
123 span2 = span2.Slice(sizeof(global::Interop.IpHlpApi.MibTcp6TableOwnerPid));
124 for (int j = 0; j < reference2.numberOfEntries; j++)
125 {
126 list.Add(new SystemTcpConnectionInformation(in MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibTcp6RowOwnerPid>(span2)));
127 span2 = span2.Slice(sizeof(global::Interop.IpHlpApi.MibTcp6RowOwnerPid));
128 }
129 }
130 }
131 finally
132 {
134 }
135 continue;
136 }
137 default:
138 throw new NetworkInformationException((int)num);
139 case 0u:
140 case 232u:
141 break;
142 }
143 break;
144 }
145 }
146 return list;
147 }
148
149 public unsafe override IPEndPoint[] GetActiveUdpListeners()
150 {
151 uint dwOutBufLen = 0u;
152 uint num = 0u;
155 {
156 num = global::Interop.IpHlpApi.GetUdpTable(IntPtr.Zero, ref dwOutBufLen, order: true);
157 while (true)
158 {
159 switch (num)
160 {
161 case 122u:
162 {
164 try
165 {
166 num = global::Interop.IpHlpApi.GetUdpTable(intPtr, ref dwOutBufLen, order: true);
167 if (num != 0)
168 {
169 continue;
170 }
172 ref readonly global::Interop.IpHlpApi.MibUdpTable reference = ref MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibUdpTable>(span);
173 if (reference.numberOfEntries != 0)
174 {
175 span = span.Slice(sizeof(global::Interop.IpHlpApi.MibUdpTable));
176 for (int i = 0; i < reference.numberOfEntries; i++)
177 {
178 ref readonly global::Interop.IpHlpApi.MibUdpRow reference2 = ref MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibUdpRow>(span);
179 int port = (reference2.localPort1 << 8) | reference2.localPort2;
180 list.Add(new IPEndPoint(reference2.localAddr, port));
181 span = span.Slice(sizeof(global::Interop.IpHlpApi.MibUdpRow));
182 }
183 }
184 }
185 finally
186 {
188 }
189 continue;
190 }
191 default:
192 throw new NetworkInformationException((int)num);
193 case 0u:
194 case 232u:
195 break;
196 }
197 break;
198 }
199 }
201 {
202 dwOutBufLen = 0u;
203 num = global::Interop.IpHlpApi.GetExtendedUdpTable(IntPtr.Zero, ref dwOutBufLen, order: true, 23u, global::Interop.IpHlpApi.UdpTableClass.UdpTableOwnerPid, 0u);
204 while (true)
205 {
206 switch (num)
207 {
208 case 122u:
209 {
211 try
212 {
213 num = global::Interop.IpHlpApi.GetExtendedUdpTable(intPtr2, ref dwOutBufLen, order: true, 23u, global::Interop.IpHlpApi.UdpTableClass.UdpTableOwnerPid, 0u);
214 if (num != 0)
215 {
216 continue;
217 }
219 ref readonly global::Interop.IpHlpApi.MibUdp6TableOwnerPid reference3 = ref MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibUdp6TableOwnerPid>(span2);
220 if (reference3.numberOfEntries != 0)
221 {
222 span2 = span2.Slice(sizeof(global::Interop.IpHlpApi.MibUdp6TableOwnerPid));
223 for (int j = 0; j < reference3.numberOfEntries; j++)
224 {
225 ref readonly global::Interop.IpHlpApi.MibUdp6RowOwnerPid reference4 = ref MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibUdp6RowOwnerPid>(span2);
226 int port2 = (reference4.localPort1 << 8) | reference4.localPort2;
227 list.Add(new IPEndPoint(new IPAddress(reference4.localAddrAsSpan, reference4.localScopeId), port2));
228 span2 = span2.Slice(sizeof(global::Interop.IpHlpApi.MibUdp6RowOwnerPid));
229 }
230 }
231 }
232 finally
233 {
235 }
236 continue;
237 }
238 default:
239 throw new NetworkInformationException((int)num);
240 case 0u:
241 case 232u:
242 break;
243 }
244 break;
245 }
246 }
247 return list.ToArray();
248 }
249
251 {
252 return new SystemIPGlobalStatistics(AddressFamily.InterNetwork);
253 }
254
256 {
257 return new SystemIPGlobalStatistics(AddressFamily.InterNetworkV6);
258 }
259
261 {
262 return new SystemTcpStatistics(AddressFamily.InterNetwork);
263 }
264
266 {
267 return new SystemTcpStatistics(AddressFamily.InterNetworkV6);
268 }
269
271 {
272 return new SystemUdpStatistics(AddressFamily.InterNetwork);
273 }
274
276 {
277 return new SystemUdpStatistics(AddressFamily.InterNetworkV6);
278 }
279
281 {
282 return new SystemIcmpV4Statistics();
283 }
284
286 {
287 return new SystemIcmpV6Statistics();
288 }
289
290 public override IAsyncResult BeginGetUnicastAddresses(AsyncCallback callback, object state)
291 {
293 }
294
299
301 {
302 return GetUnicastAddressesAsync().GetAwaiter().GetResult();
303 }
304
329}
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static ref readonly global::Interop.IpHlpApi.FIXED_INFO FixedInfo
static NetworkInterface[] GetAllNetworkInterfaces()
override UnicastIPAddressInformationCollection GetUnicastAddresses()
override TcpConnectionInformation[] GetActiveTcpConnections()
override IAsyncResult BeginGetUnicastAddresses(AsyncCallback callback, object state)
override async Task< UnicastIPAddressInformationCollection > GetUnicastAddressesAsync()
override UnicastIPAddressInformationCollection EndGetUnicastAddresses(IAsyncResult asyncResult)
unsafe List< SystemTcpConnectionInformation > GetAllTcpConnections()
static unsafe bool UnsafeNotifyStableUnicastIpAddressTable(Action< object > callback, object state)
static bool OSSupportsIPv6
Definition Socket.cs:591
static bool OSSupportsIPv4
Definition Socket.cs:589
static void FreeHGlobal(IntPtr hglobal)
Definition Marshal.cs:1680
static IntPtr AllocHGlobal(int cb)
Definition Marshal.cs:625
static IAsyncResult Begin(Task task, AsyncCallback callback, object state)
Definition TaskToApm.cs:43
static void End(IAsyncResult asyncResult)
Definition TaskToApm.cs:48
static readonly IntPtr Zero
Definition IntPtr.cs:18