private void SendAddressResponse(Packet p, IPEndPoint ep) { var packet = new Packet(); packet.TransactionID = p.TransactionID; packet.Flags.IsResponse = true; packet.Flags.IsAuthoritative = true; var ip4Address = GetIP4Address(); var ip6Address = GetIP6Address(); var a = AAnswer.Build(fullName, ip4Address, (UInt16)120, true, 1); var aaaa = AAAAAnswer.Build(fullName, ip6Address, (UInt16)120, true, 1); if (a != null) { packet.Answers.Add(a); } if (aaaa != null) { packet.Answers.Add(aaaa); } if (ep != null) { _service.SendPacket(p, ep); } else { _service.SendPacket(packet); } }
private Packet BuildResponse(string name, UInt16 id, ServiceInfo info, IPAddress ip4Address, IPAddress ip6Address) { var ret = new Packet(); ret.TransactionID = id; ret.Flags.IsResponse = true; ret.Flags.IsAuthoritative = true; var dnsName = name; var domainName = string.Join(".", info.Name, dnsName); var machineName = fullName; var ptr = PTRAnswer.Build(dnsName, domainName, 4500, false, 1); var txt = TXTAnswer.Build(domainName, 4500, info.Flags, info.Data, true, 1); var srv = SRVAnswer.Build(domainName, 120, info.Priority, info.Weight, info.Port, machineName, true, 1); var a = AAnswer.Build(machineName, ip4Address, (UInt16)120, true, 1); var aaaa = AAAAAnswer.Build(machineName, ip6Address, (UInt16)120, true, 1); ret.Answers.Add(ptr); ret.Answers.Add(txt); ret.Answers.Add(srv); if (aaaa != null) { ret.Answers.Add(aaaa); } if (a != null) { ret.Answers.Add(a); } return(ret); }