Пример #1
0
        /// <summary>
        /// Send an dynamic update to the DNS server and returns the answer asynchronously.
        /// </summary>
        /// <param name="message"> Update, that should be send to the DNS server </param>
        /// <param name="requestCallback"> An <see cref="System.AsyncCallback" /> delegate that references the method to invoked then the operation is complete. </param>
        /// <param name="state"> A user-defined object that contains information about the receive operation. This object is passed to the <paramref
        ///  name="requestCallback" /> delegate when the operation is complete. </param>
        /// <returns> An <see cref="System.IAsyncResult" /> IAsyncResult object that references the asynchronous receive. </returns>
        public IAsyncResult BeginSendUpdate(DnsUpdateMessage message, AsyncCallback requestCallback, object state)
        {
            if (message == null)
                throw new ArgumentNullException("message");

            if (String.IsNullOrEmpty(message.ZoneName))
                throw new ArgumentException("Zone name must be provided", "message");

            return this.BeginSendMessage(message, requestCallback, state);
        }
Пример #2
0
        /// <summary>
        /// Send an dynamic update to the DNS server and returns the answer.
        /// </summary>
        /// <param name="message"> Update, that should be send to the DNS server </param>
        /// <returns> The complete response of the DNS server </returns>
        public DnsUpdateMessage SendUpdate(DnsUpdateMessage message)
        {
            if (message == null)
                throw new ArgumentNullException("message");

            if (String.IsNullOrEmpty(message.ZoneName))
                throw new ArgumentException("Zone name must be provided", "message");

            return this.SendMessage(message);
        }
Пример #3
0
        /// <summary>
        /// Creates a DNS message.
        /// </summary>
        /// <param name="resultData">The result data.</param>
        /// <param name="isRequest">If <b>true</b> the message is a request.</param>
        /// <param name="tsigKeySelector">The transaction signature key selector.</param>
        /// <param name="originalMac">The original MAC.</param>
        /// <returns>The DNS message.</returns>
        internal static DnsMessageBase Create(byte[] resultData, bool isRequest, DnsServer.SelectTsigKey tsigKeySelector, byte[] originalMac)
        {
            int flagPosition = 2;
            ushort flags = DnsMessageBase.ParseUShort(resultData, ref flagPosition);

            DnsMessageBase res;

            switch ((OperationCode) ((flags & 0x7800) >> 11))
            {
                case OperationCode.Update:
                    res = new DnsUpdateMessage();
                    break;

                default:
                    res = new DnsMessage();
                    break;
            }

            res.Parse(resultData, isRequest, tsigKeySelector, originalMac);

            return res;
        }