public byte[] GetBytes(uint ttl, string replyIP, string replyIPv6) { if (string.Equals(this.Question.Type, "AAAA") && !String.IsNullOrEmpty(replyIPv6)) { replyIP = replyIPv6; } byte[] rdata = IPAddress.Parse(replyIP).GetAddressBytes(); this.Header = new LLMNRHeader { ID = this.Header.ID, QR = true, Opcode = "0000", C = false, TC = false, T = false, Z = "0000", RCode = "0000", QDCount = 1, ANCount = 1 }; this.Resource = new LLMNRResource { Name = this.Question.QName, Type = this.Question.QType, Class = this.Question.QClass, TTL = ttl, RDLength = (ushort)rdata.Length, RData = rdata }; return(Utilities.BlockCopy(this.Header.GetBytes(), this.Question.GetBytes(), this.Resource.GetBytes())); }
public byte[] GetPacket(uint ttl, string ip, string ipv6, byte[] data, out string name, out string type) { this.ReadBytes(data, 0); name = ""; type = "A"; if (!this.QR) { LLMNRQuestion question = new LLMNRQuestion(); question.ReadBytes(data, 12); if (string.Equals(BitConverter.ToString(question.QType), "00-1C")) { type = "AAAA"; ip = ipv6; } LLMNRResource response = new LLMNRResource(); return(response.GetBytes(question, ttl, ip, this.ID)); } return(null); }