/// <summary>
        ///   Creates a new instance of the DnsUpdateMessage as response to the current instance
        /// </summary>
        /// <returns>A new instance of the DnsUpdateMessage as response to the current instance</returns>
        public DnsUpdateMessage CreateResponseInstance()
        {
            DnsUpdateMessage result = new DnsUpdateMessage()
            {
                TransactionID = TransactionID,
                IsQuery       = false,
                OperationCode = OperationCode,
                Questions     = new List <DnsQuestion>(Questions),
            };

            return(result);
        }
        /// <summary>
        ///   Creates a new instance of the DnsUpdateMessage as response to the current instance
        /// </summary>
        /// <returns>A new instance of the DnsUpdateMessage as response to the current instance</returns>
        public DnsUpdateMessage CreateResponseInstance()
        {
            DnsUpdateMessage result = new DnsUpdateMessage()
            {
                TransactionID = TransactionID,
                IsEDnsEnabled = IsEDnsEnabled,
                IsQuery       = false,
                OperationCode = OperationCode,
                Questions     = new List <DnsQuestion>(Questions),
            };

            if (IsEDnsEnabled)
            {
                result.EDnsOptions.Version        = EDnsOptions.Version;
                result.EDnsOptions.UdpPayloadSize = EDnsOptions.UdpPayloadSize;
            }

            return(result);
        }
		public static DnsMessageBase Create(byte[] resultData, bool isRequest, DnsServer.SelectTsigKey tsigKeySelector, byte[] originalMac)
		{
			int flagPosition = 2;
			ushort flags = 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;
		}
		/// <summary>
		///   Creates a new instance of the DnsUpdateMessage as response to the current instance
		/// </summary>
		/// <returns>A new instance of the DnsUpdateMessage as response to the current instance</returns>
		public DnsUpdateMessage CreateResponseInstance()
		{
			DnsUpdateMessage result = new DnsUpdateMessage()
			{
				TransactionID = TransactionID,
				IsEDnsEnabled = IsEDnsEnabled,
				IsQuery = false,
				OperationCode = OperationCode,
				Questions = new List<DnsQuestion>(Questions),
			};

			if (IsEDnsEnabled)
			{
				result.EDnsOptions.Version = EDnsOptions.Version;
				result.EDnsOptions.UdpPayloadSize = EDnsOptions.UdpPayloadSize;
			}

			return result;
		}
		/// <summary>
		///   Send an dynamic update to the dns server and returns the answer as an asynchronous operation.
		/// </summary>
		/// <param name="message"> Update, that should be send to the dns server </param>
		/// <param name="token"> The token to monitor cancellation requests </param>
		/// <returns> The complete response of the dns server </returns>
		public Task<DnsUpdateMessage> SendUpdateAsync(DnsUpdateMessage message, CancellationToken token = default(CancellationToken))
		{
			if (message == null)
				throw new ArgumentNullException(nameof(message));

			if (message.ZoneName == null)
				throw new ArgumentException("Zone name must be provided", nameof(message));

			return SendMessageAsync(message, token);
		}
		/// <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(nameof(message));

			if (message.ZoneName == null)
				throw new ArgumentException("Zone name must be provided", nameof(message));

			return SendMessage(message);
		}
Exemple #7
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 BeginSendMessage(message, requestCallback, state);
		}
Exemple #8
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 SendMessage(message);
		}