using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Skyscraper;

namespace skyscraper5.Docsis
{
    public abstract class MacManagementMessage : Validatable
    {
        public PhysicalAddress Source { get; }
        public PhysicalAddress Destination { get; }

        protected MacManagementMessage(PhysicalAddress source, PhysicalAddress destination, byte[] buffer)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            Source = source;
            Destination = destination;
        }

        public MacManagementMessageTypeAttribute MessageType
        {
            get
            {
                Type type = this.GetType();
                object[] customAttributes = type.GetCustomAttributes(typeof(MacManagementMessageTypeAttribute), false);
                if (customAttributes.Length == 0)
                    return null;
                MacManagementMessageTypeAttribute attribute = (MacManagementMessageTypeAttribute)customAttributes[0];
                return attribute;
            }
        }
    }
}
