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

namespace skyscraper5.DNS.Protocol.ResourceRecords.Records
{
	internal class OptionRecord : BaseResourceRecord
	{
		public OptionRecord(IResourceRecord record, byte[] message, int dataOffset)
			: base(record)
		{
			MemoryStream ms = new MemoryStream(Data, false);
			while (ms.GetAvailableBytes() > 0)
			{
				ushort optionCode = ms.ReadUInt16BE();
				ushort optionLength = ms.ReadUInt16BE();
				byte[] optionData = ms.ReadBytes(optionLength);
				if (Options == null)
					Options = new List<KeyValuePair<ushort, byte[]>>();
				Options.Add(new KeyValuePair<ushort, byte[]>(optionCode, optionData));
			}
		}

		public List<KeyValuePair<ushort, byte[]>> Options { get; private set; }
	}
}
