Beispiel #1
0
        /// <summary>
        /// Pick up OUI code from MAC address
        /// </summary>
        /// <param name="mac"></param>
        /// <returns></returns>
        public static MacOui From(MacAddress mac)
        {
            var ret = new MacOui();

            ret.Data[0] = mac.Value[0];
            ret.Data[1] = mac.Value[1];
            ret.Data[2] = mac.Value[2];
            return(ret);
        }
Beispiel #2
0
        /// <summary>
        /// Parse string
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static MacOui Parse(string value)
        {
            var ret = new MacOui();

            var cs = value.Trim().ToLower().Split(new[] { ':', '-', ' ', '.' }, StringSplitOptions.RemoveEmptyEntries);

            if (cs.Length >= 3)
            {
                for (var i = 0; i < 3; i++)
                {
                    ret.Data[i] = Convert.ToByte(cs[i], 16);
                }
                return(ret);
            }
            throw new FormatException("use aa:bb:cc format");
        }