CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2011

    DHCP Discovery Program - Need Help With Boot Options

    So I wrote this program in C# using sharppcap with the purpose of sending out a custom DHCP discovery packet. The program works. What I need help with is understanding DHCP Options if anyone has experience/knowledge of this.

    I understand what is supposed to go there, but I don't know if there is supposed to be an order to the byte fields or if anything can go in there (according to the DHCP options).

    For instance, I want the DHCP server to return a packet with the subnet mask (option 1), router (option 3), DNS (option 6), and domain name (option 15).

    So in the string I use in the code, I have this (ddcp being a structure): ddcp.DHCP_OPTIONS = "35370103060F";

    35 = 53 (DHCP Message Type)
    37 = 55 (Parameter Request List)

    And then do I put codes after 37 to get specific data back, such as 01 for Subnet Mask, 06 for DNS, etc...?

    If anyone can shed light on DHCP Options and how to get useful information back, that would be awesome.

    I should note that I think something should go after the DHCP Message Type, but if I put a 01 or 03 after that, I get no response from my dhcp server unless I'm using the wrong codes for message type. But if I use the DHCP Options as-is, I get a response back.

  2. #2
    Join Date
    Jan 2011

    Cool Re: DHCP Discovery Program - Need Help With DHCP Options

    Ok, so I figured it out and updating this thread in case, if for some bizarre reason >_<, people like me are trying to build a custom DHCP discover packet.

    So in DHCP Options, it goes: DHCP Code -> Length of values -> Values -> DHCP Code -> Length -> Values... etc..

    These are the DHCP options from a test server I built running on Windows Server 2008:

    35 = DHCP Code
    01 = Length of Values
    02 = Value
    01 = DHCP Code
    04 = Length of Values
    FF FF FF 00 = Values
    3A = DHCP Code
    04 = Length of Values
    00 05 46 00 = Values
    3B = DHCP Code
    04 = Length of Values
    00 09 3A 80 = Values

    And so on. You can follow this pattern to the end at FF, which is DHCP Code for "End".
    It took ages of staring at this to see the pattern >_<.

    So there ya go!

  3. #3
    Join Date
    May 2001

    Re: DHCP Discovery Program - Need Help With Boot Options

    Did you check this RFC: http://www.faqs.org/rfcs/rfc2132.html?
    It seems to contain anything you need.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.