using System; using System.Globalization; using System.Text; namespace System.Net.NetworkInformation { /// Provides the Media Access Control (MAC) address for a network interface (adapter). // Token: 0x020001AA RID: 426 public class PhysicalAddress { /// Initializes a new instance of the class. /// A array containing the address. // Token: 0x06000E26 RID: 3622 RVA: 0x00027F0C File Offset: 0x0002610C public PhysicalAddress(byte[] address) { this.bytes = address; } // Token: 0x06000E28 RID: 3624 RVA: 0x00027F30 File Offset: 0x00026130 internal static PhysicalAddress ParseEthernet(string address) { if (address == null) { return PhysicalAddress.None; } string[] array = address.Split(new char[] { ':' }); byte[] array2 = new byte[array.Length]; int num = 0; foreach (string text in array) { array2[num++] = byte.Parse(text, NumberStyles.HexNumber); } return new PhysicalAddress(array2); } /// Parses the specified and stores its contents as the address bytes of the returned by this method. /// A instance with the specified address. /// A containing the address that will be used to initialize the instance returned by this method. /// The parameter contains an illegal hardware address. This exception also occurs if the parameter contains a string in the incorrect format. // Token: 0x06000E29 RID: 3625 RVA: 0x00027FA0 File Offset: 0x000261A0 public static PhysicalAddress Parse(string address) { if (address == null) { return PhysicalAddress.None; } if (address == string.Empty) { throw new FormatException("An invalid physical address was specified."); } string[] array = address.Split(new char[] { '-' }); if (array.Length == 1) { if (address.Length != 12) { throw new FormatException("An invalid physical address was specified."); } array = new string[6]; for (int i = 0; i < array.Length; i++) { array[i] = address.Substring(i * 2, 2); } } if (array.Length == 6) { foreach (string text in array) { if (text.Length > 2) { throw new FormatException("An invalid physical address was specified."); } if (text.Length < 2) { throw new IndexOutOfRangeException("An invalid physical address was specified."); } } byte[] array3 = new byte[6]; for (int k = 0; k < 6; k++) { byte b = (byte)(PhysicalAddress.GetValue(array[k][0]) << 4); b += PhysicalAddress.GetValue(array[k][1]); array3[k] = b; } return new PhysicalAddress(array3); } throw new FormatException("An invalid physical address was specified."); } // Token: 0x06000E2A RID: 3626 RVA: 0x000280EC File Offset: 0x000262EC private static byte GetValue(char c) { if (c >= '0' && c <= '9') { return (byte)(c - '0'); } if (c >= 'a' && c <= 'f') { return (byte)(c - 'a' + '\n'); } if (c >= 'A' && c <= 'F') { return (byte)(c - 'A' + '\n'); } throw new FormatException("Invalid physical address."); } /// Compares two instances. /// true if this instance and the specified instance contain the same address; otherwise false. /// The to compare to the current instance. // Token: 0x06000E2B RID: 3627 RVA: 0x0002814C File Offset: 0x0002634C public override bool Equals(object comparand) { PhysicalAddress physicalAddress = comparand as PhysicalAddress; if (physicalAddress == null) { return false; } if (this.bytes.Length != physicalAddress.bytes.Length) { return false; } for (int i = 0; i < this.bytes.Length; i++) { if (this.bytes[i] != physicalAddress.bytes[i]) { return false; } } return true; } /// Returns the hash value of a physical address. /// An integer hash value. // Token: 0x06000E2C RID: 3628 RVA: 0x000281B0 File Offset: 0x000263B0 public override int GetHashCode() { return ((int)this.bytes[5] << 8) ^ (int)this.bytes[4] ^ ((int)this.bytes[3] << 24) ^ ((int)this.bytes[2] << 16) ^ ((int)this.bytes[1] << 8) ^ (int)this.bytes[0]; } /// Returns the address of the current instance. /// A array containing the address. // Token: 0x06000E2D RID: 3629 RVA: 0x000281FC File Offset: 0x000263FC public byte[] GetAddressBytes() { return this.bytes; } /// Returns the representation of the address of this instance. /// A containing the address contained in this instance. // Token: 0x06000E2E RID: 3630 RVA: 0x00028204 File Offset: 0x00026404 public override string ToString() { if (this.bytes == null) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(); foreach (byte b in this.bytes) { stringBuilder.AppendFormat("{0:X2}", b); } return stringBuilder.ToString(); } // Token: 0x04000CCF RID: 3279 private const int numberOfBytes = 6; /// Returns a new instance with a zero length address. This field is read-only. // Token: 0x04000CD0 RID: 3280 public static readonly PhysicalAddress None = new PhysicalAddress(new byte[0]); // Token: 0x04000CD1 RID: 3281 private byte[] bytes; } }