PxeDhcpGetOptionValue function

Retrieves an option value from a DHCP packet.

Syntax


DWORD PXEAPI PxeDhcpGetOptionValue(
  _In_       PVOID pPacket,
  _In_       ULONG uPacketLen,
  _In_       ULONG uInstance,
  _In_       BYTE bOption,
  _Out_opt_  PBYTE pbOptionLen,
  _Out_opt_  PVOID *ppOptionValue
);

Parameters

pPacket [in]

Pointer to a reply packet allocated with the PxePacketAllocate function.

uPacketLen [in]

Length of the packet pointed to by the pReplyPacket parameter.

uInstance [in]

One-based index that specifies which instance of the bOption parameter to retrieve.

bOption [in]

Option whose value will be retrieved.

pbOptionLen [out, optional]

Address of BYTE which will receive the length of the option value.

ppOptionValue [out, optional]

Address of PVOID which will receive the address of the option value inside the packet.

Return value

Common return values are listed in the following table. For all other failures, an appropriate Windows error code is returned.

Return code/valueDescription
ERROR_SUCCESS
0 (0x0)

The option was found and a pointer to the value was returned.

ERROR_FILE_NOT_FOUND
2 (0x2)

The option was not located.

ERROR_INVALID_DATA
13 (0xD)

The packet is not a valid DHCP packet. This test is not as thorough as the tests used by the PxeDhcpIsValid function; only the packet length and magic cookie are verified.

 

Examples


if (ERROR_SUCCESS == PxeDhcpGetOptionValue(
                                   pPacket,
                                   uPacketLen,
                                   60, // Vendor Class Identifier
                                   bOption,
                                   &bOptionLen,
                                   &pValue))
 {
  if (bOptionLen >= 9 && 
      strncmp((char*) pValue, "PXEClient", 9) == 0)
  {
   // Packet is a PXEClient packet
  }
 }
 else
 {
  // Packet is not a PXEClient packet
 }


Requirements

Minimum supported client

None supported

Minimum supported server

Windows Server 2008, Windows Server 2003 with SP2 [desktop apps only]

Header

WdsPxe.h

Library

WdsPxe.lib

DLL

WdsPxe.dll

See also

Windows Deployment Services Server Functions
PxeDhcpAppendOption
PxeDhcpGetVendorOptionValue
PxePacketAllocate

 

 

Community Additions

ADD
Show:
© 2014 Microsoft