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 21, 2022
1 parent e285249 commit 32c804a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Internet/DHCP/dhcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,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]; // DHCP Client MAC address.
Expand Down Expand Up @@ -374,6 +376,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 for 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 @@ -460,6 +469,14 @@ 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 for 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;
pDHCPMSG->OPT[k++] = 0x01;
Expand Down
2 changes: 2 additions & 0 deletions Internet/DHCP/dhcp.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ extern "C" {

#define MAGIC_COOKIE 0x63825363 ///< You should not modify it number.

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

#define DCHP_HOST_NAME "WIZnet\0"

/*
Expand Down

0 comments on commit 32c804a

Please sign in to comment.