using skyscraper5.Skyscraper.IO;
using static skyscraper8.Docsis.AnnexC.DsidEncoding;

namespace skyscraper8.Docsis.AnnexC
{
	internal class EncodedMulticastAttributes
	{
		public EncodedMulticastAttributes(byte[] buffer)
		{
			MemoryStream ms = new MemoryStream(buffer, false);

			while (ms.GetAvailableBytes() > 2)
			{
				byte type = ms.ReadUInt8();
				byte length = ms.ReadUInt8();
				byte[] v = ms.ReadBytes(length);
				switch (type)
				{
					case 2:
						this.MulticastCmInterfaceMask = new MulticastCmInterfaceMask(v);
						break;
					default:
						//CM-SP-MULPIv4.0-I01-190815.pdf, page 732
						throw new NotImplementedException(String.Format("DSID Encoding 50.4.{0}", type));
				}
			}
		}

		public MulticastCmInterfaceMask MulticastCmInterfaceMask { get; }
	}
}