Re: How to query DHCP Vendor Class Options?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Just a little followup, on how this problem was solved.

After discussing this with MS developer support and the team responsible for
the DhcpCApi, we established that custom vendor classes are not supported,
by the DhcpCApi.

The following workaround can be used:

1. Use the Microsoft specific vendor class, by setting IsVendor == true.
(Notice that different OS versions have different vendor class ids)
2. Use a custom User Class.

<codesnip>
SendParams.nParams := 0;
SendParams.Params := nil;

RequestOption.Flags := 0;
RequestOption.OptionId := OptionsID;
RequestOption.IsVendor := true;
RequestOption.Data := nil;
RequestOption.nBytesData := 0;
RequestParams.nParams := 1;
RequestParams.Params := @RequestOption;

cbBytes := 0;
DhcpRequestParams(
DHCPCAPI_REQUEST_SYNCHRONOUS,
nil,
pAdapterName,
pUserClassID,
SendParams,
RequestParams,
nil,
cbBytes,
nil);

Buffer := AllocMem(cbBytes);
DhcpCApiCheck(DhcpRequestParams(
DHCPCAPI_REQUEST_SYNCHRONOUS,
nil,
pAdapterName,
pUserClassID,
SendParams,
RequestParams,
Buffer,
cbBytes,
nil));

</codesnip>

"Christoph Lindemann" <clindemann2@xxxxxxxxxxxxxxxxx> wrote in message
news:F23826AE-D4C0-4564-9E1A-665ABA83E5F9@xxxxxxxxxxxxxxxx
Hi everyone,

Could someone please help me on: How to query DHCP vendor class options
using the Windows DhcpCApi API?

Problem
-------------------

We would like to configure our client application using DHCP. For this I
have been trying to use DhcpRequestParams (from windows DhcpCApi). But I
have
only been able to query standard options, and "MSFT" (Microsoft) class
options.
I am probably doing something wrong, but I have not been able to find any
examples on how to do this. And I only found a few usenet threads where
this
was discussed, without any real conclusion.

The following is how I think it should be implemented (which obviosly is
wrong, as it does not work):

Used software
-------------------
-DHCP Server: Windows 2000 Advanced Server SP4
-Workstation Client: Windows XP SP2 (with and without hotfix KB919250)
-And our little test app, described later

On MS DHCP Server
-------------------
1) I have defined a new vendor class "VendorTest"
2) Added a new "predefined option":
Class: VendorTest
Name: VendorValue
Code: 130
Type: String
Array: False
Value: VendorValueContent
3) Added new scope option:
Vendor Class: VendorTest
User Class: Default User Class
Option: 130 (VendorValue)
Data Entry: VendorValueContent

Test App Code
-------------------
The following code illustrates what I have used. (The example is in
Delphi)

SendOption.Flags := 0;
SendOption.OptionId := OPTION_VENDOR_SPEC_INFO;
SendOption.IsVendor := false;
SendOption.Data := VendorClassIDPtr;
SendOption.nBytesData := VendorClassIDSize;
SendParams.nParams := 1;
SendParams.Params := @SendOption;

RequestOption.Flags := 0;
RequestOption.OptionId := 130;
RequestOption.IsVendor := true;
RequestOption.Data := nil;
RequestOption.nBytesData := 0;
RequestParams.nParams := 1;
RequestParams.Params := @RequestOption;

cbBytes := 0;
DhcpRequestParams(
DHCPCAPI_REQUEST_SYNCHRONOUS,
nil,
PWideChar(AdapterName),
nil,
SendParams,
RequestParams,
nil,
@cbBytes,
nil);

Buffer := AllocMem(cbBytes);

DhcpCApiCheck( DhcpRequestParams(
DHCPCAPI_REQUEST_SYNCHRONOUS,
nil,
PWideChar(AdapterName),
nil,
SendParams,
RequestParams,
Buffer,
@cbBytes,
nil));


DCHP Packets
-------------------
The code above results in the following DHCP Packet beeing send:

0101 0600 0633 .....3]
8743 0000 0000 C0A8 0A68 0000 0000 0000 [.C.......h......]
0000 0000 0000 0011 2F9E C527 0000 0000 [......../..'....]
0000 0000 0000 0000 0000 0000 0000 0000 [................]
0000 0000 0000 0000 0000 0000 0000 0000 [................]
0000 0000 0000 0000 0000 0000 0000 0000 [................]
0000 0000 0000 0000 0000 0000 0000 0000 [................]
0000 0000 0000 0000 0000 0000 0000 0000 [................]
0000 0000 0000 0000 0000 0000 0000 0000 [................]
0000 0000 0000 0000 0000 0000 0000 0000 [................]
0000 0000 0000 0000 0000 0000 0000 0000 [................]
0000 0000 0000 0000 0000 0000 0000 0000 [................]
0000 0000 0000 0000 0000 0000 0000 0000 [................]
0000 0000 0000 0000 0000 0000 0000 0000 [................]
0000 0000 0000 0000 0000 0000 0000 0000 [................]
0000 0000 0000 6382 5363 3501 083D 0701 [......c.Sc5..=..]
0000 0000 0000 6382 5363 3501 083D 0701 [../..'..cil-winx]
703C 084D 5346 5420 352E 3037 0B01 0F03 [p<.MSFT 5.07....]
062C 2E2F 1F21 F92B 2B05 5600 0001 82FF [.,./.!.++.V.....]
0000 0000 0000 [......

Which does not include the VendorTest option 130 request.


.



Relevant Pages

  • Re: How to query DHCP Vendor Class Options?
    ... I saw a trace in MSDN newsgroup about using DHCP client API to retrieve ... vendor specific information. ... Use the Microsoft specific vendor class, ... RequestOption.Data:= nil; ...
    (microsoft.public.win32.programmer.networks)
  • Re: Help with DHCP Vendor Class IDs
    ... I am sure the server NIC is capable, now it's a matter of obtaining the ... So I guess my question next will be: Where can I find the vendor class info ... That allowed the phones to receive addresses only from the phone ...
    (microsoft.public.windows.server.networking)
  • Re: URGENT- Help needed with DHCP vendor class configuration
    ... the vendor we are working with changed their ... >> We have defined a DHCP vendor class on a Windows 2000 Server that uses ... >> need to use Windows 2003 Server with the vendor equipment and when we try ...
    (microsoft.public.windows.server.networking)
  • DHCP Question
    ... I do know how to add vendor classes to ... if there is any way I can use the vendor class to define ... class of MSFT 5.0 to get IP addresses from my DHCP server ...
    (microsoft.public.windows.server.general)
  • DHCP/Vendor Class question with clarification
    ... I do know how to add vendor classes to ... if there is any way I can use the vendor class to define ... class of MSFT 5.0 to get IP addresses from my DHCP server ...
    (microsoft.public.windows.server.general)