using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Docsis.AnnexC;
using skyscraper5.Skyscraper.IO;
using skyscraper5.Skyscraper.Plugins;

namespace skyscraper5.Docsis.MacManagement
{
	[SkyscraperPlugin]
	[MacManagementMessageType(4,36)]
    internal class DynamicBondingChangeRequest : MacManagementMessage
    {
        public DynamicBondingChangeRequest(PhysicalAddress source, PhysicalAddress destination, byte[] buffer) : base(source, destination, buffer)
        {
            //CM-SP-MULPIv4.0-I01-190815.pdf  page 191 is wrong!
            //CM-SP-MULPIv3.1-I03-1406101.pdf page 177 is right instead!
            MemoryStream ms = new MemoryStream(buffer, false);
            TransactionId = ms.ReadUInt16BE();
            NumberOfFragments = ms.ReadUInt8();
            FragmentSequenceNumber = ms.ReadUInt8();
            TlvEncodedInformation = new CommonTlvEncodingObject(ms);
            Valid = true;
        }

        public byte FragmentSequenceNumber { get; set; }

        public byte NumberOfFragments { get; set; }

        public CommonTlvEncodingObject TlvEncodedInformation { get; set; }

        public ushort TransactionId { get; set; }
    }
}
