Skip to content

Commit

Permalink
Added Vendor Class Identifier in DHCP offers and requests.
Browse files Browse the repository at this point in the history
The Vendor Class Identifier is a constant string that identifies the
kind of hardware that asks the DHCP server for a IP address.
The ID is passed via the option 60 of the DHCP messages.

The ID is set to "WIZnetSE" constant.

From a DHCP server point of view, this ID is useful for giving specific
configuration for Wiznet modules : IP address from different address
pool,  different gateway, longer lease, etc.

Reference documentation :
https://datatracker.ietf.org/doc/html/rfc2132#section-9.13
  • Loading branch information
kbenyous committed Feb 20, 2022
1 parent 4f7ada3 commit fb2705d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ioLibrary/Internet/DHCP/dhcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ uint32_t DHCP_XID; // Any number

RIP_MSG* pDHCPMSG; // Buffer pointer for DHCP processing

uint8_t VENDOR_ID[] = DHCP_VENDOR_ID;

uint8_t HOST_NAME[] = DCHP_HOST_NAME;

uint8_t DHCP_CHADDR[6] = {0, }; // DHCP Client MAC address.
Expand Down Expand Up @@ -387,6 +389,13 @@ void send_DHCP_DISCOVER(void)
pDHCPMSG->OPT[k++] = 0x01;
pDHCPMSG->OPT[k++] = DHCP_DISCOVER;

// Class identifier
pDHCPMSG->OPT[k++] = dhcpClassIdentifier;
pDHCPMSG->OPT[k++] = 0; // fill zero length of class identifier
for(i = 0 ; VENDOR_ID[i] != 0; i++)
pDHCPMSG->OPT[k++] = VENDOR_ID[i];
pDHCPMSG->OPT[k - (i+1)] = i;

// Client identifier
pDHCPMSG->OPT[k++] = dhcpClientIdentifier;
pDHCPMSG->OPT[k++] = 0x07;
Expand Down Expand Up @@ -476,6 +485,13 @@ void send_DHCP_REQUEST(void)
pDHCPMSG->OPT[k++] = 0x01;
pDHCPMSG->OPT[k++] = DHCP_REQUEST;

// Class identifier
pDHCPMSG->OPT[k++] = dhcpClassIdentifier;
pDHCPMSG->OPT[k++] = 0; // fill zero length of class identifier
for(i = 0 ; VENDOR_ID[i] != 0; i++)
pDHCPMSG->OPT[k++] = VENDOR_ID[i];
pDHCPMSG->OPT[k - (i+1)] = i;

pDHCPMSG->OPT[k++] = dhcpClientIdentifier;
pDHCPMSG->OPT[k++] = 0x07;
pDHCPMSG->OPT[k++] = 0x01;
Expand Down
2 changes: 2 additions & 0 deletions ioLibrary/Internet/DHCP/dhcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@

#define MAGIC_COOKIE 0x63825363 ///< Any number. You can be modifyed it any number

#define DHCP_VENDOR_ID "WIZnetSE" ///< Vendor ID used for DHCP requests, using Class-Id (option 60)

#define DCHP_HOST_NAME "WIZnet\0"


Expand Down

0 comments on commit fb2705d

Please sign in to comment.