Package: udhcpc
Version: 0.9.8cvs20050303-3

To make it possible to give the mac address manually in order
to pxe boot a xen user domain, I've applied the attached patch
against the current etch udhcp source. It only requires a change
to the changelog and two additional scripts at [3].

It's an adaptation from an original patch by Stephen Childs [1],
which was agains FC6, documentation and additional necessary
scripts at [2] and the original patch at [3].

[1] https://www.cs.tcd.ie/Stephen.Childs/
[2] https://www.cs.tcd.ie/Stephen.Childs/pypxeboot/
[3] https://www.cs.tcd.ie/Stephen.Childs/pypxeboot/pypxeboot-0.0.2.tar.gz

Sincerely,

Jan.
diff -u udhcp-0.9.8cvs20050303/README.udhcpc udhcp-0.9.8.local/README.udhcpc
--- udhcp-0.9.8cvs20050303/README.udhcpc	2007-05-30 11:21:00.000000000 +0200
+++ udhcp-0.9.8.local/README.udhcpc	2007-05-30 19:32:39.005273868 +0200
@@ -25,6 +25,7 @@
 -r, --request=IP                IP address to request (default: none)
 -s, --script=file               Run file at dhcp events (default:
                                 /etc/udhcpc/default.script)
+-M, --mac=MAC                   MAC address to use instead of HW MAC
 -v, --version                   Display version
 
 
Common subdirectories: udhcp-0.9.8cvs20050303/debian and udhcp-0.9.8.local/debian
diff -u udhcp-0.9.8cvs20050303/dhcpc.c udhcp-0.9.8.local/dhcpc.c
--- udhcp-0.9.8cvs20050303/dhcpc.c	2005-03-03 17:54:10.000000000 +0100
+++ udhcp-0.9.8.local/dhcpc.c	2007-05-30 19:29:10.576247868 +0200
@@ -62,6 +62,7 @@
 	foreground: 0,
 	quit_after_lease: 0,
 	background_if_no_lease: 0,
+   userarp: 0,
 	interface: "eth0",
 	pidfile: NULL,
 	script: DEFAULT_SCRIPT,
@@ -92,6 +93,7 @@
 "  -r, --request=IP                IP address to request (default: none)\n"
 "  -s, --script=file               Run file at dhcp events (default:\n"
 "                                  " DEFAULT_SCRIPT ")\n"
+"  -M, --mac=MAC                   MAC address to use instead of HW MAC\n"
 "  -v, --version                   Display version\n"
 	);
 	exit(0);
@@ -182,6 +184,7 @@
 #endif
 {
 	uint8_t *temp, *message;
+   unsigned char hwmac[6];
 	unsigned long t1 = 0, t2 = 0, xid = 0;
 	unsigned long start = 0, lease;
 	fd_set rfds;
@@ -208,13 +211,14 @@
 		{"request",	required_argument,	0, 'r'},
 		{"script",	required_argument,	0, 's'},
 		{"version",	no_argument,		0, 'v'},
+      {"mac",  required_argument,   0, 'M'},
 		{0, 0, 0, 0}
 	};
 
 	/* get options */
 	while (1) {
-		int option_index = 0;
-		c = getopt_long(argc, argv, "c:fbH:h:F:i:np:qr:s:v", arg_options, &option_index);
+		int option_index = 0, nrmacfields = 0;
+		c = getopt_long(argc, argv, "c:fbH:h:F:i:np:qr:s:v:M:", arg_options, &option_index);
 		if (c == -1) break;
 
 		switch (c) {
@@ -281,6 +285,16 @@
 			printf("udhcpcd, version %s\n\n", VERSION);
 			return 0;
 			break;
+      case 'M':
+         nrmacfields=sscanf(optarg,"%x:%x:%x:%x:%x:%x",
+                             (unsigned int *)&client_config.arp[0],
+                             (unsigned int *)&client_config.arp[1],
+                             (unsigned int *)&client_config.arp[2],
+                             (unsigned int *)&client_config.arp[3],
+                             (unsigned int *)&client_config.arp[4],
+                             (unsigned int *)&client_config.arp[5]);
+         if (nrmacfields == 6) client_config.userarp=1;
+         break;
 		default:
 			show_usage();
 		}
@@ -290,9 +304,11 @@
 	start_log_and_pid("udhcpc", client_config.pidfile);
 
 	if (read_interface(client_config.interface, &client_config.ifindex,
-			   NULL, client_config.arp) < 0)
+			   NULL, hwmac) < 0)
 		return 1;
 
+   if (!(client_config.userarp)) memcpy(client_config.arp, hwmac, 6);
+
 	if (!client_config.clientid) {
 		client_config.clientid = xmalloc(6 + 3);
 		client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
diff -u udhcp-0.9.8cvs20050303/dhcpc.h udhcp-0.9.8.local/dhcpc.h
--- udhcp-0.9.8cvs20050303/dhcpc.h	2007-05-30 11:21:00.000000000 +0200
+++ udhcp-0.9.8.local/dhcpc.h	2007-05-30 19:30:42.481991618 +0200
@@ -22,6 +22,7 @@
 	char quit_after_lease;		/* Quit after obtaining lease */
 	char abort_if_no_lease;		/* Abort if no lease */
 	char background_if_no_lease;	/* Fork to background if no lease */
+   char userarp;        /* Did the user give us an ARP address */
 	char *interface;		/* The name of the interface to use */
 	char *pidfile;			/* Optionally store the process ID */
 	char *script;			/* User script to run at dhcp events */
Common subdirectories: udhcp-0.9.8cvs20050303/samples and udhcp-0.9.8.local/samples

Reply via email to