public byte[] GetBytes(LLMNRQuestion llmnrQuestion, uint TTL, string responseData, byte[] id)
        {
            byte[] rdata = IPAddress.Parse(responseData).GetAddressBytes();

            LLMNRHeader responseHeader = new LLMNRHeader
            {
                ID      = id,
                QR      = true,
                Opcode  = "0000",
                C       = false,
                TC      = false,
                T       = false,
                Z       = "0000",
                RCode   = "0000",
                QDCount = 1,
                ANCount = 1
            };

            this.Name     = llmnrQuestion.QName;
            this.Type     = llmnrQuestion.QType;
            this.Class    = llmnrQuestion.QClass;
            this.TTL      = TTL;
            this.RDLength = (ushort)rdata.Length;
            this.RData    = rdata;

            return(Utilities.BlockCopy(responseHeader.GetBytes(), llmnrQuestion.GetBytes(), this.GetBytes()));
        }
Exemple #2
0
        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);
        }