[U-Boot-Users] [PATCH] Add client id and class id to dhcp options
Kylo Ginsberg
kylo at veriwave.com
Wed Mar 30 03:42:08 CEST 2005
This patch adds the client identifier and class identifier options to
dhcp. The former permits consistent address assignment from servers
that key off the client identifier; the latter aids in debugging.
Index: net/bootp.c
===================================================================
RCS file: /cvsroot/u-boot/u-boot/net/bootp.c,v
retrieving revision 1.14
diff -u -r1.14 bootp.c
--- net/bootp.c 15 Apr 2004 21:48:49 -0000 1.14
+++ net/bootp.c 30 Mar 2005 01:14:17 -0000
@@ -378,8 +378,11 @@
* Initialize BOOTP extension fields in the request.
*/
#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
-static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID,
IPaddr_t RequestedIP)
+static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID,
IPaddr_t RequestedIP,
+ char *EtherAddr)
{
+ char *class_id = "U-boot";
+ int len;
u8 *start = e;
u8 *cnt;
@@ -404,6 +407,23 @@
*e++ = (576 - 312 + OPT_SIZE) >> 8;
*e++ = (576 - 312 + OPT_SIZE) & 0xff;
+ *e++ = 61; /* Client Identifier, use the MAC */
+ *e++ = 7;
+ *e++ = 1;
+ *e++ = EtherAddr[0];
+ *e++ = EtherAddr[1];
+ *e++ = EtherAddr[2];
+ *e++ = EtherAddr[3];
+ *e++ = EtherAddr[4];
+ *e++ = EtherAddr[5];
+
+ *e++ = 60; /* Class Identifier */
+ len = strlen(class_id);
+ *e++ = len;
+ /* don't use strcpy, we don't want the terminating 0 */
+ memcpy(e, class_id, len);
+ e += len;
+
if (ServerID) {
int tmp = ntohl (ServerID);
@@ -671,7 +691,7 @@
/* Request additional information from the BOOTP/DHCP server */
#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
- ext_len = DhcpExtended(bp->bp_vend, DHCP_DISCOVER, 0, 0);
+ ext_len = DhcpExtended(bp->bp_vend, DHCP_DISCOVER, 0, 0,
NetOurEther);
#else
ext_len = BootpExtended(bp->bp_vend);
#endif /* CFG_CMD_DHCP */
@@ -817,7 +837,7 @@
* Copy options from OFFER packet if present
*/
NetCopyIP(&OfferedIP, &bp->bp_yiaddr);
- extlen = DhcpExtended(bp->bp_vend, DHCP_REQUEST,
NetDHCPServerIP, OfferedIP);
+ extlen = DhcpExtended(bp->bp_vend, DHCP_REQUEST,
NetDHCPServerIP, OfferedIP, NetOurEther);
pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + extlen;
iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
More information about the U-Boot
mailing list