using skyscraper5.Skyscraper.IO;
using skyscraper8.Docsis.DQoS;
using System;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace skyscraper5.Docsis.AnnexC
{
	public class EthernetLlcPacketClassificationEncoding
	{

		public EthernetLlcPacketClassificationEncoding(byte[] buffer)
		{
			MemoryStream ms = new MemoryStream(buffer, false);
			while (ms.GetAvailableBytes() >= 3)
			{
				byte type = ms.ReadUInt8();
				ushort length = ms.ReadUInt8();
				byte[] v = ms.ReadBytes(length);
				switch (type)
				{
					case 3:
						(v[1], v[2]) = (v[2], v[1]);
						this.Type = v[0];
						this.EProt = BitConverter.ToUInt16(v, 1);
						break;
					default:
						//CM-SP-MULPIv4.0-I01-190815.pdf, page 747
						throw new NotImplementedException(string.Format("EthernetLlcPacketClassificationEncoding [22/23/60].10.{0}", type));
				}
			}
		}

		public byte Type { get; }
		public ushort EProt { get; }
	}
}