コード例 #1
0
        private StatusCode Ask(IPv4 dnsServer,
                               Dns.Query []  queries,
                               out Dns.Format answer)
        {
            answer = null;

            Dns.Format outFrame = new Dns.Format();
            outFrame.SetFlags(flags);
            foreach (object o in queries)
            {
                outFrame.Queries.Add(o);
            }

            byte[] outData = new byte [outFrame.Size];
            if (outData.Length > Dns.Format.MaxUdpMessageLength)
            {
                return(StatusCode.OverSizeMessage);
            }

            int offset = 0;

            outFrame.Write(outData, ref offset);

            byte[]     rcvData;
            StatusCode askResponse = AskDnsServer(dnsServer, outData, out rcvData);

            if (askResponse != StatusCode.Success)
            {
                return(askResponse);
            }
            VTable.Assert(rcvData != null);

            try {
                offset = 0;
                Dump(rcvData, offset);
                answer = Dns.Format.Parse(rcvData, ref offset);
            }
            catch (Exception e) {
                DebugPrint("Parser threw {0}", e);
                return(StatusCode.TransportError);
            }

            return(StatusCode.Success);
        }
コード例 #2
0
 public StatusCode Ask(IPv4 dnsServer,
                       Dns.Query query,
                       out Dns.Format answer)
 {
     return(Ask(dnsServer, new Dns.Query [] { query }, out answer));
 }