-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b72dcb6
commit b174b96
Showing
1 changed file
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
MIT License | ||
Copyright (c) Léo Corporation | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
using System.Net.NetworkInformation; | ||
|
||
namespace InternetTest.Classes | ||
{ | ||
public class AdapterInfo | ||
{ | ||
public string Name { get; set; } | ||
public NetworkInterfaceType NetworkInterfaceType { get; set; } | ||
public OperationalStatus Status { get; set; } | ||
public string IpVersion { get; set; } | ||
public string DnsSuffix { get; set; } | ||
public int Mtu { get; set; } | ||
public bool DnsEnabled { get; set; } | ||
public bool IsDynamicDnsEnabled { get; set; } | ||
public bool IsReceiveOnly { get; set; } | ||
public bool SupportsMulticast { get; set; } | ||
public long Speed { get; set; } | ||
public long BytesReceived { get; set; } | ||
public long BytesSent { get; set; } | ||
public long IncomingPacketsDiscarded { get; set; } | ||
public long IncomingPacketsWithErrors { get; set; } | ||
public long IncomingUnknownProtocolPackets { get; set; } | ||
public long NonUnicastPacketsReceived { get; set; } | ||
public long NonUnicastPacketsSent { get; set; } | ||
public long OutgoingPacketsDiscarded { get; set; } | ||
public long OutgoingPacketsWithErrors { get; set; } | ||
public long OutputQueueLength { get; set; } | ||
public long UnicastPacketsReceived { get; set; } | ||
public long UnicastPacketsSent { get; set; } | ||
|
||
public AdapterInfo(NetworkInterface adapter) | ||
{ | ||
IPInterfaceProperties properties = adapter.GetIPProperties(); | ||
IPInterfaceStatistics statistics = adapter.GetIPStatistics(); | ||
Name = adapter.Description; | ||
NetworkInterfaceType = adapter.NetworkInterfaceType; | ||
Status = adapter.OperationalStatus; | ||
DnsSuffix = properties.DnsSuffix; | ||
Mtu = properties.GetIPv4Properties().Mtu; | ||
DnsEnabled = properties.IsDnsEnabled; | ||
IsDynamicDnsEnabled = properties.IsDynamicDnsEnabled; | ||
IsReceiveOnly = adapter.IsReceiveOnly; | ||
SupportsMulticast = adapter.SupportsMulticast; | ||
Speed = adapter.Speed; | ||
BytesReceived = statistics.BytesReceived; | ||
BytesSent = statistics.BytesSent; | ||
IncomingPacketsDiscarded = statistics.IncomingPacketsDiscarded; | ||
IncomingPacketsWithErrors = statistics.IncomingPacketsWithErrors; | ||
IncomingUnknownProtocolPackets = statistics.IncomingUnknownProtocolPackets; | ||
NonUnicastPacketsReceived = statistics.NonUnicastPacketsReceived; | ||
NonUnicastPacketsSent = statistics.NonUnicastPacketsSent; | ||
OutgoingPacketsDiscarded = statistics.OutgoingPacketsDiscarded; | ||
OutgoingPacketsWithErrors = statistics.OutgoingPacketsWithErrors; | ||
OutputQueueLength = statistics.OutputQueueLength; | ||
UnicastPacketsReceived = statistics.UnicastPacketsReceived; | ||
UnicastPacketsSent = statistics.UnicastPacketsSent; | ||
} | ||
} | ||
} |