--- networking/udhcp/dhcpc.c.orig	2010-10-11 14:15:04.000000000 +0100
+++ networking/udhcp/dhcpc.c	2010-10-11 14:15:28.000000000 +0100
@@ -145,6 +145,7 @@
 	int tryagain_timeout = 20;
 	int discover_timeout = 3;
 	int discover_retries = 3;
+	int hwtype = 1;
 	uint32_t server_addr = server_addr; /* for compiler */
 	uint32_t requested_ip = 0;
 	uint32_t xid = 0;
@@ -162,6 +163,7 @@
 #if ENABLE_LONG_OPTS
 	static const char udhcpc_longopts[] ALIGN1 =
 		"clientid\0"       Required_argument "c"
+		"clientid-hwtype\0"  Required_argument "w"
 		"clientid-none\0"  No_argument       "C"
 		"vendorclass\0"    Required_argument "V"
 		"hostname\0"       Required_argument "H"
@@ -188,27 +190,28 @@
 #endif
 	enum {
 		OPT_c = 1 << 0,
-		OPT_C = 1 << 1,
-		OPT_V = 1 << 2,
-		OPT_H = 1 << 3,
-		OPT_h = 1 << 4,
-		OPT_F = 1 << 5,
-		OPT_i = 1 << 6,
-		OPT_n = 1 << 7,
-		OPT_p = 1 << 8,
-		OPT_q = 1 << 9,
-		OPT_R = 1 << 10,
-		OPT_r = 1 << 11,
-		OPT_s = 1 << 12,
-		OPT_T = 1 << 13,
-		OPT_t = 1 << 14,
-		OPT_S = 1 << 15,
-		OPT_A = 1 << 16,
-		OPT_O = 1 << 17,
-		OPT_o = 1 << 18,
-		OPT_f = 1 << 19,
+		OPT_w = 1 << 1,
+		OPT_C = 1 << 2,
+		OPT_V = 1 << 3,
+		OPT_H = 1 << 4,
+		OPT_h = 1 << 5,
+		OPT_F = 1 << 6,
+		OPT_i = 1 << 7,
+		OPT_n = 1 << 8,
+		OPT_p = 1 << 9,
+		OPT_q = 1 << 10,
+		OPT_R = 1 << 11,
+		OPT_r = 1 << 12,
+		OPT_s = 1 << 13,
+		OPT_T = 1 << 14,
+		OPT_t = 1 << 15,
+		OPT_S = 1 << 16,
+		OPT_A = 1 << 17,
+		OPT_O = 1 << 18,
+		OPT_o = 1 << 19,
+		OPT_f = 1 << 20,
 /* The rest has variable bit positions, need to be clever */
-		OPTBIT_f = 19,
+		OPTBIT_f = 20,
 		USE_FOR_MMU(             OPTBIT_b,)
 		IF_FEATURE_UDHCPC_ARPING(OPTBIT_a,)
 		IF_FEATURE_UDHCP_PORT(   OPTBIT_P,)
@@ -225,18 +228,18 @@
 
 	/* Parse command line */
 	/* Cc: mutually exclusive; O: list; -T,-t,-A take numeric param */
-	opt_complementary = "c--C:C--c:O::T+:t+:A+"
+	opt_complementary = "c--C:C--c:O::T+:t+:A+:w+"
 #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1
 		":vv"
 #endif
 		;
 	IF_LONG_OPTS(applet_long_options = udhcpc_longopts;)
-	opt = getopt32(argv, "c:CV:H:h:F:i:np:qRr:s:T:t:SA:O:of"
+	opt = getopt32(argv, "c:w:CV:H:h:F:i:np:qRr:s:T:t:SA:O:of"
 		USE_FOR_MMU("b")
 		IF_FEATURE_UDHCPC_ARPING("a")
 		IF_FEATURE_UDHCP_PORT("P:")
 		"v"
-		, &str_c, &str_V, &str_h, &str_h, &str_F
+		, &str_c, &hwtype, &str_V, &str_h, &str_h, &str_F
 		, &client_config.interface, &client_config.pidfile, &str_r /* i,p */
 		, &client_config.script /* s */
 		, &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */
@@ -246,8 +249,14 @@
 		, &dhcp_verbose
 #endif
 		);
-	if (opt & OPT_c)
+	if (opt & OPT_c) {
+		if (opt & OPT_w) {
+			client_config.clientid = alloc_dhcp_option(DHCP_CLIENT_ID, str_c, 1);
+			client_config.clientid[2] = hwtype & 255;
+		} else {
 		client_config.clientid = alloc_dhcp_option(DHCP_CLIENT_ID, str_c, 0);
+		}
+    }
 	if (opt & OPT_V)
 		client_config.vendorclass = alloc_dhcp_option(DHCP_VENDOR, str_V, 0);
 	if (opt & (OPT_h|OPT_H))
@@ -317,7 +326,7 @@
 	/* If not set, and not suppressed, set up the default client ID */
 	if (!client_config.clientid && !(opt & OPT_C)) {
 		client_config.clientid = alloc_dhcp_option(DHCP_CLIENT_ID, "", 7);
-		client_config.clientid[OPT_DATA] = 1;
+		client_config.clientid[OPT_DATA] = hwtype & 255;
 		memcpy(client_config.clientid + OPT_DATA+1, client_config.client_mac, 6);
 	}
 
--- include/usage.h.orig	2010-10-11 14:35:42.000000000 +0100
+++ include/usage.h	2010-10-11 14:35:46.000000000 +0100
@@ -4799,6 +4799,7 @@
      "\n	-H,-h,--hostname=HOSTNAME	Client hostname" \
      "\n	-c,--clientid=CLIENTID	Client identifier" \
      "\n	-C,--clientid-none	Suppress default client identifier" \
+     "\n	-w,--clentid-hwtype=N	Prefix clientid with hwtype (see RFC2132, RCF1700) " \
      "\n	-p,--pidfile=FILE	Create pidfile" \
      "\n	-r,--request=IP		IP address to request" \
      "\n	-s,--script=FILE	Run FILE at DHCP events (default "CONFIG_UDHCPC_DEFAULT_SCRIPT")" \
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to