internal DhcpServerPacketOption(DhcpServerOptionIds optionId, byte[] data)
 {
     id        = optionId;
     dataLong  = default;
     dataArray = data;
     length    = data.Length;
 }
 internal DhcpServerPacketOption(DhcpServerOptionIds optionId)
 {
     id        = optionId;
     dataLong  = default;
     dataArray = null;
     length    = 0;
 }
Example #3
0
        public bool TryGetOption(DhcpServerOptionIds optionId, out DhcpServerPacketOption option)
        {
            if (TryGetOptionIndex(optionId, out var optionIndex))
            {
                option = DhcpServerPacketOption.Parse(Buffer, ref optionIndex);
                return(true);
            }

            option = default;
            return(false);
        }
        internal DhcpServerPacketOption(DhcpServerOptionIds optionId, ulong data, int length)
        {
            if (length > 8)
            {
                throw new ArgumentOutOfRangeException(nameof(length));
            }

            id          = optionId;
            dataLong    = data;
            dataArray   = null;
            this.length = length;
        }
Example #5
0
        protected bool TryGetOptionIndex(DhcpServerOptionIds optionId, out int optionIndex)
        {
            var buffer = this.buffer ?? Buffer;

            for (var offset = OptionsOffset; offset < buffer.Length;)
            {
                var optionTag = (DhcpServerOptionIds)buffer[offset];

                if (optionTag == optionId)
                {
                    optionIndex = offset;
                    return(true);
                }

                if (optionTag == DhcpServerOptionIds.End)
                {
                    break;
                }

                switch (optionTag)
                {
                case DhcpServerOptionIds.Pad:
                case DhcpServerOptionIds.End:
                    // 0-byte fixed length
                    offset++;
                    break;

                case DhcpServerOptionIds.SubnetMask:
                case DhcpServerOptionIds.TimeOffset:
                    // 4-byte fixed length
                    offset += 5;
                    break;

                default:
                    // variable length
                    offset++;
                    offset += buffer[offset] + 1;
                    break;
                }
            }

            optionIndex = -1;
            return(false);
        }
Example #6
0
 /// <summary>
 /// Queries the DHCP Server for the specified OptionId Value within a User Class
 /// </summary>
 /// <param name="className">The name of the User Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="IDhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetUserOptionValue(string className, DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.GetGlobalUserOptionValue(Server, className, (int)optionId);
Example #7
0
 /// <summary>
 /// Queries the DHCP Server for the specified OptionId Value from the Default options
 /// </summary>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="IDhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetDefaultOptionValue(DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.GetGlobalDefaultOptionValue(Server, (int)optionId);
Example #8
0
 /// <summary>
 /// Retrieves the Option Value associated with the Option and Scope within a User Class
 /// </summary>
 /// <param name="className">The name of the User Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetUserOptionValue(string className, DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.GetScopeUserOptionValue(Scope, (int)optionId, className);
Example #9
0
 /// <summary>
 /// Retrieves the Option Value associated with the Option and Scope from the Default options
 /// </summary>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetDefaultOptionValue(DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.GetScopeDefaultOptionValue(Scope, (int)optionId);
Example #10
0
 public void RemoveOptionValue(DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.DeleteScopeOptionValue(Scope, (int)optionId);
Example #11
0
 /// <summary>
 /// Retrieves the Option Value associated with the Option and Scope Reservation from the Default options
 /// </summary>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="IDhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetDefaultOptionValue(DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.GetScopeReservationDefaultOptionValue(Reservation, (int)optionId);
Example #12
0
 /// <summary>
 /// Queries the DHCP Server for the specified OptionId within a User Class
 /// </summary>
 /// <param name="className">The name of the User Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option to retrieve</param>
 /// <returns>A <see cref="IDhcpServerOption"/>.</returns>
 public IDhcpServerOption GetUserOption(string className, DhcpServerOptionIds optionId)
 => DhcpServerOption.GetUserOption(Server, className, (int)optionId);
Example #13
0
 /// <summary>
 /// Retrieves the Option Value associated with the Option and Scope within a Vendor Class
 /// </summary>
 /// <param name="vendorName">The name of the Vendor Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetVendorOptionValue(string vendorName, DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.GetScopeVendorOptionValue(Scope, (int)optionId, vendorName);
Example #14
0
 /// <summary>
 /// Queries the DHCP Server for the specified OptionId Value within a Vendor Class
 /// </summary>
 /// <param name="className">The name of the User Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="IDhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetVendorOptionValue(string vendorName, DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.GetGlobalVendorOptionValue(Server, vendorName, (int)optionId);
Example #15
0
 /// <summary>
 /// Retrieves the Option Value associated with the Option and Scope within a User Class
 /// </summary>
 /// <param name="className">The name of the User Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns>
 public void RemoveUserOptionValue(string className, DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.DeleteScopeUserOptionValue(Scope, (int)optionId, className);
Example #16
0
 /// <summary>
 /// Queries the DHCP Server for the specified OptionId from the Default options
 /// </summary>
 /// <param name="optionId">The identifier for the option to retrieve</param>
 /// <returns>A <see cref="IDhcpServerOption"/>.</returns>
 public IDhcpServerOption GetDefaultOption(DhcpServerOptionIds optionId)
 => DhcpServerOption.GetDefaultOption(Server, (int)optionId);
Example #17
0
 /// <summary>
 /// Retrieves the Option Value associated with the Option and Scope within a Vendor Class
 /// </summary>
 /// <param name="vendorName">The name of the Vendor Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns>
 public void RemoveVendorOptionValue(string vendorName, DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.DeleteScopeVendorOptionValue(Scope, (int)optionId, vendorName);
Example #18
0
 /// <summary>
 /// Queries the DHCP Server for the specified OptionId within a Vendor Class
 /// </summary>
 /// <param name="vendorName">The name of the Vendor Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option to retrieve</param>
 /// <returns>A <see cref="IDhcpServerOption"/>.</returns>
 public IDhcpServerOption GetVendorOption(string vendorName, DhcpServerOptionIds optionId)
 => DhcpServerOption.GetVendorOption(Server, vendorName, (int)optionId);
Example #19
0
 public void RemoveOptionValue(DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.DeleteScopeReservationOptionValue(Reservation, (int)optionId);