-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEthernetMacAddress.cs
50 lines (42 loc) · 1.23 KB
/
EthernetMacAddress.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
namespace WoLib
{
public class EthernetMacAddress
{
public byte[] mac_address
{
get; private set;
}
public EthernetMacAddress(byte a, byte b, byte c, byte d, byte e, byte f)
{
mac_address = new byte[6];
mac_address[0] = a;
mac_address[1] = b;
mac_address[2] = c;
mac_address[3] = d;
mac_address[4] = e;
mac_address[5] = f;
}
public EthernetMacAddress(byte[] hex_address)
{
if (hex_address.Length > 6)
{
throw new Exception("Hex address too long! Has to be six bytes!");
}else if (hex_address.Length < 6)
{
throw new Exception("Hex address too short! Has to be six bytes!");
}
mac_address = hex_address;
}
public override string ToString()
{
string info = "";
foreach (byte b in mac_address)
{
info += b.ToString("x") + ":";
}
info = info.Remove(info.Length-1);
return info;
}
}
}