forked from pool/udhcp
108 lines
4.0 KiB
Diff
108 lines
4.0 KiB
Diff
diff -u udhcp-0.9.8/dhcpc.c udhcp-0.9.8.mod/dhcpc.c
|
|
--- udhcp-0.9.8/dhcpc.c 2002-10-19 02:10:43.000000000 +0100
|
|
+++ udhcp-0.9.8.mod/dhcpc.c 2007-02-02 14:41:11.000000000 +0000
|
|
@@ -67,6 +67,7 @@
|
|
foreground: 0,
|
|
quit_after_lease: 0,
|
|
background_if_no_lease: 0,
|
|
+ userarp: 0,
|
|
interface: "eth0",
|
|
pidfile: NULL,
|
|
script: DEFAULT_SCRIPT,
|
|
@@ -95,6 +96,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);
|
|
@@ -132,6 +134,7 @@
|
|
state = INIT_SELECTING;
|
|
break;
|
|
case INIT_SELECTING:
|
|
+ break;
|
|
}
|
|
|
|
/* start things over */
|
|
@@ -207,6 +210,7 @@
|
|
#endif
|
|
{
|
|
unsigned char *temp, *message;
|
|
+ unsigned char hwmac[6];
|
|
unsigned long t1 = 0, t2 = 0, xid = 0;
|
|
unsigned long start = 0, lease;
|
|
fd_set rfds;
|
|
@@ -233,14 +237,15 @@
|
|
{"request", required_argument, 0, 'r'},
|
|
{"script", required_argument, 0, 's'},
|
|
{"version", no_argument, 0, 'v'},
|
|
+ {"mac", required_argument, 0, 'M'},
|
|
{"help", no_argument, 0, '?'},
|
|
{0, 0, 0, 0}
|
|
};
|
|
|
|
/* get options */
|
|
while (1) {
|
|
- int option_index = 0;
|
|
- c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index);
|
|
+ int option_index = 0, nrmacfields=0;
|
|
+ c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v:M:", arg_options, &option_index);
|
|
if (c == -1) break;
|
|
|
|
switch (c) {
|
|
@@ -290,6 +295,16 @@
|
|
printf("udhcpcd, version %s\n\n", VERSION);
|
|
exit_client(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();
|
|
}
|
|
@@ -302,9 +317,11 @@
|
|
pidfile_write_release(pid_fd);
|
|
|
|
if (read_interface(client_config.interface, &client_config.ifindex,
|
|
- NULL, client_config.arp) < 0)
|
|
+ NULL, hwmac) < 0)
|
|
exit_client(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.8/dhcpc.h udhcp-0.9.8.mod/dhcpc.h
|
|
--- udhcp-0.9.8/dhcpc.h 2002-09-20 21:36:15.000000000 +0100
|
|
+++ udhcp-0.9.8.mod/dhcpc.h 2007-02-02 14:13:52.000000000 +0000
|
|
@@ -19,6 +19,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 */
|
|
diff -u udhcp-0.9.8/README.udhcpc udhcp-0.9.8.mod/README.udhcpc
|
|
--- udhcp-0.9.8/README.udhcpc 2002-10-31 18:02:09.000000000 +0000
|
|
+++ udhcp-0.9.8.mod/README.udhcpc 2007-02-02 14:12:47.000000000 +0000
|
|
@@ -24,6 +24,7 @@
|
|
-r, --request=IP IP address to request (default: none)
|
|
-s, --script=file Run file at dhcp events (default:
|
|
/usr/share/udhcpc/default.script)
|
|
+-M, --mac=MAC MAC address to use instead of HW MAC
|
|
-v, --version Display version
|
|
|
|
|
|
Common subdirectories: udhcp-0.9.8/samples and udhcp-0.9.8.mod/samples
|