using System.IO;
using System.Net.NetworkInformation;
using skyscraper5.Docsis.AnnexC;
using skyscraper5.Skyscraper.IO;
using skyscraper5.Skyscraper.Plugins;

namespace skyscraper5.Docsis.MacManagement
{
	[SkyscraperPlugin]
	[MacManagementMessageType(4,45)]
    public class T45_V4_MultipartRegistrationResponse : MacManagementMessage
    {
        public T45_V4_MultipartRegistrationResponse(PhysicalAddress source, PhysicalAddress destination, byte[] buffer) : base(source, destination, buffer)
        {
            File.WriteAllBytes("T45_V4_MultipartRegistrationResponseTest.bin", buffer);
            MemoryStream ms = new MemoryStream(buffer, false);
            SID = ms.ReadUInt16BE();
            Response = ms.ReadUInt8();
            NumberOfFragments = ms.ReadUInt8();
            FragmentSequenceNumber = ms.ReadUInt8();
            TlvEncodedInformation = new CommonTlvEncodingObject(ms);
            Valid = true;
        }

        public CommonTlvEncodingObject TlvEncodedInformation { get; set; }

        public byte FragmentSequenceNumber { get; set; }

        public byte NumberOfFragments { get; set; }

        public byte Response { get; set; }

        public ushort SID { get; set; }
    }
}
