Skip to content

Commit b811910

Browse files
committed
Added Vendor Class Identifier in DHCP offers and requests.
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
1 parent e285249 commit b811910

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Internet/DHCP/dhcp.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ uint32_t DHCP_XID; // Any number
214214

215215
RIP_MSG* pDHCPMSG; // Buffer pointer for DHCP processing
216216

217+
uint8_t VENDOR_ID[] = DHCP_VENDOR_ID;
218+
217219
uint8_t HOST_NAME[] = DCHP_HOST_NAME;
218220

219221
uint8_t DHCP_CHADDR[6]; // DHCP Client MAC address.
@@ -374,6 +376,13 @@ void send_DHCP_DISCOVER(void)
374376
pDHCPMSG->OPT[k++] = 0x01;
375377
pDHCPMSG->OPT[k++] = DHCP_DISCOVER;
376378

379+
// Class identifier
380+
pDHCPMSG->OPT[k++] = dhcpClassIdentifier;
381+
pDHCPMSG->OPT[k++] = 0; // fill zero length for class identifier
382+
for(i = 0 ; VENDOR_ID[i] != 0; i++)
383+
pDHCPMSG->OPT[k++] = VENDOR_ID[i];
384+
pDHCPMSG->OPT[k - (i+1)] = i;
385+
377386
// Client identifier
378387
pDHCPMSG->OPT[k++] = dhcpClientIdentifier;
379388
pDHCPMSG->OPT[k++] = 0x07;
@@ -460,6 +469,14 @@ void send_DHCP_REQUEST(void)
460469
pDHCPMSG->OPT[k++] = 0x01;
461470
pDHCPMSG->OPT[k++] = DHCP_REQUEST;
462471

472+
// Class identifier
473+
pDHCPMSG->OPT[k++] = dhcpClassIdentifier;
474+
pDHCPMSG->OPT[k++] = 0; // fill zero length for class identifier
475+
for(i = 0 ; VENDOR_ID[i] != 0; i++)
476+
pDHCPMSG->OPT[k++] = VENDOR_ID[i];
477+
pDHCPMSG->OPT[k - (i+1)] = i;
478+
479+
// Client identifier
463480
pDHCPMSG->OPT[k++] = dhcpClientIdentifier;
464481
pDHCPMSG->OPT[k++] = 0x07;
465482
pDHCPMSG->OPT[k++] = 0x01;

Internet/DHCP/dhcp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ extern "C" {
7070

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

73+
#define DHCP_VENDOR_ID "WIZnetSE" ///< Vendor ID used for DHCP requests, using Class-Id (option 60)
74+
7375
#define DCHP_HOST_NAME "WIZnet\0"
7476

7577
/*

0 commit comments

Comments
 (0)