36 lines
823 B
C#
36 lines
823 B
C#
using System.Net;
|
|
using System.Text;
|
|
|
|
namespace NWService
|
|
{
|
|
public class DeviceInfo
|
|
{
|
|
private IPAddress ipAddr;
|
|
private byte[] macAddr;
|
|
|
|
public DeviceInfo(IPAddress iPAddress, byte[] macAddressBytes)
|
|
{
|
|
this.ipAddr = iPAddress;
|
|
this.macAddr = macAddressBytes;
|
|
}
|
|
|
|
public IPAddress GetIPAddress()
|
|
{
|
|
return ipAddr;
|
|
}
|
|
|
|
public string GetMacAddress(char separate = ':')
|
|
{
|
|
StringBuilder sb = new StringBuilder(18);
|
|
foreach (byte b in this.macAddr) {
|
|
if (sb.Length > 0)
|
|
{
|
|
sb.Append(separate);
|
|
}
|
|
sb.Append(string.Format("{0:X2}", b));
|
|
}
|
|
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
} |