internal static IEnumerable <DhcpServerOption> GetAllOptions(DhcpServer Server) { IntPtr optionsPtr; var result = Api.DhcpGetAllOptions(Server.ipAddress.ToString(), 0, out optionsPtr); if (result != DhcpErrors.SUCCESS) { throw new DhcpServerException("DhcpGetAllOptions", result); } try { var bytes = new byte[64]; Marshal.Copy(optionsPtr, bytes, 0, 64); var options = (DHCP_ALL_OPTIONS)Marshal.PtrToStructure(optionsPtr, typeof(DHCP_ALL_OPTIONS)); foreach (var option in options.NonVendorOptions.Options) { yield return(DhcpServerOption.FromNative(Server, option, null, null)); } foreach (var option in options.VendorOptions) { yield return(DhcpServerOption.FromNative(Server, option)); } } finally { Api.DhcpRpcFreeMemory(optionsPtr); } }
private static DhcpServerOption GetOptionV0(DhcpServer Server, int OptionId) { IntPtr optionPtr; var result = Api.DhcpGetOptionInfo(Server.ipAddress.ToString(), OptionId, out optionPtr); if (result != DhcpErrors.SUCCESS) { throw new DhcpServerException("DhcpGetOptionInfo", result); } try { var option = (DHCP_OPTION)Marshal.PtrToStructure(optionPtr, typeof(DHCP_OPTION)); return(DhcpServerOption.FromNative(Server, option, null, null)); } finally { Api.DhcpRpcFreeMemory(optionPtr); } }
private static DhcpServerOption GetOptionV5(DhcpServer Server, int OptionId, string ClassName, string VendorName) { IntPtr optionPtr; uint flags = VendorName == null ? 0 : Constants.DHCP_FLAGS_OPTION_IS_VENDOR; var result = Api.DhcpGetOptionInfoV5(Server.ipAddress.ToString(), flags, OptionId, ClassName, VendorName, out optionPtr); if (result != DhcpErrors.SUCCESS) { throw new DhcpServerException("DhcpGetOptionInfoV5", result); } try { var option = (DHCP_OPTION)Marshal.PtrToStructure(optionPtr, typeof(DHCP_OPTION)); return(DhcpServerOption.FromNative(Server, option, ClassName, VendorName)); } finally { Api.DhcpRpcFreeMemory(optionPtr); } }
private static IEnumerable <DhcpServerOption> EnumOptionsV5(DhcpServer Server, string ClassName, string VendorName) { IntPtr enumInfoPtr; int elementsRead, elementsTotal; IntPtr resumeHandle = IntPtr.Zero; uint flags = VendorName == null ? 0 : Constants.DHCP_FLAGS_OPTION_IS_VENDOR; var result = Api.DhcpEnumOptionsV5(Server.ipAddress.ToString(), flags, ClassName, VendorName, ref resumeHandle, 0xFFFFFFFF, out enumInfoPtr, out elementsRead, out elementsTotal); if (result == DhcpErrors.ERROR_NO_MORE_ITEMS || result == DhcpErrors.EPT_S_NOT_REGISTERED) { yield break; } if (result != DhcpErrors.SUCCESS && result != DhcpErrors.ERROR_MORE_DATA) { throw new DhcpServerException("DhcpEnumOptions", result); } if (elementsRead == 0) { yield break; } try { var enumInfo = (DHCP_OPTION_ARRAY)Marshal.PtrToStructure(enumInfoPtr, typeof(DHCP_OPTION_ARRAY)); foreach (var option in enumInfo.Options) { yield return(DhcpServerOption.FromNative(Server, option, VendorName, ClassName)); } } finally { Api.DhcpRpcFreeMemory(enumInfoPtr); } }
/// <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> /// 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(int optionId) => DhcpServerOption.GetDefaultOption(Server, optionId);
public IEnumerable <IDhcpServerOption> GetVendorOptions(string vendorName) => DhcpServerOption.EnumVendorOptions(Server, vendorName);
public IEnumerable <IDhcpServerOption> GetUserOptions(string className) => DhcpServerOption.EnumUserOptions(Server, 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="DhcpServerOption"/>.</returns> public DhcpServerOption GetOption(int OptionId) { return(DhcpServerOption.GetDefaultOption(this, OptionId)); }
private DhcpServerOption GetOption() { return(DhcpServerOption.GetOption(this.Server, this.OptionId, this.ClassName, this.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, int optionId) => DhcpServerOption.GetVendorOption(Server, vendorName, optionId);
/// <summary> /// Queries the DHCP Server for the specified OptionId Value from the Default options /// </summary> /// <param name="Option">The associated option to retrieve the option value for</param> /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns> public DhcpServerOptionValue GetOptionValue(DhcpServerOption Option) { return(Option.GetGlobalValue()); }
/// <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="DhcpServerOption"/>.</returns> public DhcpServerOption GetUserOption(string ClassName, int OptionId) { return(DhcpServerOption.GetUserOption(this, OptionId, ClassName)); }
/// <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="DhcpServerOption"/>.</returns> public DhcpServerOption GetVendorOption(string VendorName, int OptionId) { return(DhcpServerOption.GetVendorOption(this, OptionId, VendorName)); }
/// <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, int optionId) => DhcpServerOption.GetUserOption(Server, className, 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);
public IEnumerator <IDhcpServerOption> GetEnumerator() => DhcpServerOption.GetAllOptions(Server).GetEnumerator();
/// <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 IEnumerable <IDhcpServerOption> GetDefaultOptions() => DhcpServerOption.EnumDefaultOptions(Server);
/// <summary> /// Retrieves the Option Value assoicated with the Option and Scope /// </summary> /// <param name="Option">The associated option to retrieve the option value for</param> /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns> public DhcpServerOptionValue GetOptionValue(DhcpServerOption Option) { return(Option.GetScopeValue(this)); }
private DhcpServerOption GetOption() => DhcpServerOption.GetOption(Server, OptionId, ClassName, VendorName);