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; }
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; }
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); }
/// <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);
/// <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);
/// <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);
/// <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);
public void RemoveOptionValue(DhcpServerOptionIds optionId) => DhcpServerOptionValue.DeleteScopeOptionValue(Scope, (int)optionId);
/// <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);
/// <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);
/// <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);
/// <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);
/// <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);
/// <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);
/// <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);
/// <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);
public void RemoveOptionValue(DhcpServerOptionIds optionId) => DhcpServerOptionValue.DeleteScopeReservationOptionValue(Reservation, (int)optionId);