Hi,

the attached patches work with busybox-1.17.1 in squeeze and busybox-1.18.4 in unstable. They are based on the patch in http://www.grid.ie/pypxeboot/pypxeboot-0.0.3.tar.gz

Would be great if they could be included, so that we can have paravirtualized pxe bootable domUs in xen!

Regards,
Bjoern

diff -urN busybox-1.17.1-debianorig//include/usage.src.h 
busybox-1.17.1-patched//include/usage.src.h
--- busybox-1.17.1-debianorig//include/usage.src.h      2010-07-25 
00:12:43.000000000 +0200
+++ busybox-1.17.1-patched//include/usage.src.h 2011-05-12 14:47:10.601425094 
+0200
@@ -4522,6 +4522,7 @@
      "\n       -p,--pidfile FILE       Create pidfile" \
      "\n       -r,--request IP         IP address to request" \
      "\n       -s,--script PROG        Run PROG at DHCP events (default 
"CONFIG_UDHCPC_DEFAULT_SCRIPT")" \
+     "\n       -M,--mac MAC            MAC address to use instead of HW MAC 
(example: 00:13:37:c0:ff:ee)" \
      "\n       -t,--retries N          Send up to N discover packets" \
      "\n       -T,--timeout N          Pause between packets (default 3 
seconds)" \
      "\n       -A,--tryagain N         Wait N seconds after failure (default 
20)" \
@@ -4553,6 +4554,7 @@
      "\n       -p FILE         Create pidfile" \
      "\n       -r IP           IP address to request" \
      "\n       -s PROG         Run PROG at DHCP events (default 
"CONFIG_UDHCPC_DEFAULT_SCRIPT")" \
+     "\n       -M MAC          MAC address to use instead of HW MAC (example: 
00:13:37:c0:ff:ee)" \
      "\n       -t N            Send up to N discover packets" \
      "\n       -T N            Pause between packets (default 3 seconds)" \
      "\n       -A N            Wait N seconds (default 20) after failure" \
diff -urN busybox-1.17.1-debianorig//networking/udhcp/dhcpc.c 
busybox-1.17.1-patched//networking/udhcp/dhcpc.c
--- busybox-1.17.1-debianorig//networking/udhcp/dhcpc.c 2010-07-06 
04:25:54.000000000 +0200
+++ busybox-1.17.1-patched//networking/udhcp/dhcpc.c    2011-05-12 
17:26:44.000000000 +0200
@@ -766,7 +766,8 @@
 int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 {
        uint8_t *temp, *message;
-       const char *str_c, *str_V, *str_h, *str_F, *str_r;
+       uint8_t hwmac[6];
+       const char *str_c, *str_V, *str_h, *str_F, *str_r, *str_M;
        IF_FEATURE_UDHCP_PORT(char *str_P;)
        llist_t *list_O = NULL;
        llist_t *list_x = NULL;
@@ -801,6 +802,7 @@
                "release\0"        No_argument       "R"
                "request\0"        Required_argument "r"
                "script\0"         Required_argument "s"
+               "mac\0"            Required_argument "M"
                "timeout\0"        Required_argument "T"
                "version\0"        No_argument       "v"
                "retries\0"        Required_argument "t"
@@ -828,16 +830,17 @@
                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_x = 1 << 19,
-               OPT_f = 1 << 20,
+               OPT_M = 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_x = 1 << 20,
+               OPT_f = 1 << 21,
 /* The rest has variable bit positions, need to be clever */
-               OPTBIT_f = 20,
+               OPTBIT_f = 21,
                USE_FOR_MMU(             OPTBIT_b,)
                IF_FEATURE_UDHCPC_ARPING(OPTBIT_a,)
                IF_FEATURE_UDHCP_PORT(   OPTBIT_P,)
@@ -861,7 +864,7 @@
 #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:ox:f"
+       opt = getopt32(argv, "c:CV:H:h:F:i:np:qRr:s:M:T:t:SA:O:ox:f"
                USE_FOR_MMU("b")
                IF_FEATURE_UDHCPC_ARPING("a")
                IF_FEATURE_UDHCP_PORT("P:")
@@ -869,6 +872,7 @@
                , &str_c, &str_V, &str_h, &str_h, &str_F
                , &client_config.interface, &client_config.pidfile, &str_r /* 
i,p */
                , &client_config.script /* s */
+               , &str_M /* M */
                , &discover_timeout, &discover_retries, &tryagain_timeout /* 
T,t,A */
                , &list_O
                , &list_x
@@ -928,6 +932,17 @@
                return 1;
        }
 
+       if (opt & (OPT_M)) {
+               int nrmacfields = 0;
+                nrmacfields=sscanf(str_M,"%x:%x:%x:%x:%x:%x",
+                                        (unsigned int *)&hwmac[0],
+                                        (unsigned int *)&hwmac[1],
+                                        (unsigned int *)&hwmac[2],
+                                        (unsigned int *)&hwmac[3],
+                                        (unsigned int *)&hwmac[4],
+                                        (unsigned int *)&hwmac[5]);
+                if (nrmacfields == 6) memcpy(client_config.client_mac, hwmac, 
6);
+       }
        if (opt & OPT_c) {
                client_config.clientid = alloc_dhcp_option(DHCP_CLIENT_ID, 
str_c, 0);
        } else if (!(opt & OPT_C)) {
diff -urN busybox-1.18.4/networking/udhcp/dhcpc.c 
busybox-1.18.4-patched/networking/udhcp/dhcpc.c
--- busybox-1.18.4/networking/udhcp/dhcpc.c     2011-03-13 02:45:40.000000000 
+0100
+++ busybox-1.18.4-patched/networking/udhcp/dhcpc.c     2011-05-12 
17:55:57.765424841 +0200
@@ -856,6 +856,7 @@
 //usage:     "\n       -i,--interface IFACE    Interface to use (default eth0)"
 //usage:     "\n       -p,--pidfile FILE       Create pidfile"
 //usage:     "\n       -s,--script PROG        Run PROG at DHCP events 
(default "CONFIG_UDHCPC_DEFAULT_SCRIPT")"
+//usage:     "\n       -M,--mac MAC            MAC address to use instead of 
HW MAC (example: 00:13:37:c0:ff:ee)"
 //usage:     "\n       -t,--retries N          Send up to N discover packets"
 //usage:     "\n       -T,--timeout N          Pause between packets (default 
3 seconds)"
 //usage:     "\n       -A,--tryagain N         Wait N seconds after failure 
(default 20)"
@@ -931,7 +932,8 @@
 int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 {
        uint8_t *temp, *message;
-       const char *str_V, *str_h, *str_F, *str_r;
+       uint8_t hwmac[6];
+       const char *str_V, *str_h, *str_F, *str_r, *str_M;
        IF_FEATURE_UDHCP_PORT(char *str_P;)
        void *clientid_mac_ptr;
        llist_t *list_O = NULL;
@@ -966,6 +968,7 @@
                "release\0"        No_argument       "R"
                "request\0"        Required_argument "r"
                "script\0"         Required_argument "s"
+               "mac\0"            Required_argument "M"
                "timeout\0"        Required_argument "T"
                "version\0"        No_argument       "v"
                "retries\0"        Required_argument "t"
@@ -992,16 +995,17 @@
                OPT_R = 1 << 9,
                OPT_r = 1 << 10,
                OPT_s = 1 << 11,
-               OPT_T = 1 << 12,
-               OPT_t = 1 << 13,
-               OPT_S = 1 << 14,
-               OPT_A = 1 << 15,
-               OPT_O = 1 << 16,
-               OPT_o = 1 << 17,
-               OPT_x = 1 << 18,
-               OPT_f = 1 << 19,
+               OPT_M = 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_x = 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,)
@@ -1025,7 +1029,7 @@
 #endif
                ;
        IF_LONG_OPTS(applet_long_options = udhcpc_longopts;)
-       opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:f"
+       opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:M:T:t:SA:O:ox:f"
                USE_FOR_MMU("b")
                IF_FEATURE_UDHCPC_ARPING("a")
                IF_FEATURE_UDHCP_PORT("P:")
@@ -1033,6 +1037,7 @@
                , &str_V, &str_h, &str_h, &str_F
                , &client_config.interface, &client_config.pidfile, &str_r /* 
i,p */
                , &client_config.script /* s */
+               , &str_M /* M */
                , &discover_timeout, &discover_retries, &tryagain_timeout /* 
T,t,A */
                , &list_O
                , &list_x
@@ -1092,6 +1097,17 @@
                return 1;
        }
 
+       if (opt & (OPT_M)) {
+               int nrmacfields = 0;
+                nrmacfields=sscanf(str_M,"%x:%x:%x:%x:%x:%x",
+                                        (unsigned int *)&hwmac[0],
+                                        (unsigned int *)&hwmac[1],
+                                        (unsigned int *)&hwmac[2],
+                                        (unsigned int *)&hwmac[3],
+                                        (unsigned int *)&hwmac[4],
+                                        (unsigned int *)&hwmac[5]);
+                if (nrmacfields == 6) memcpy(client_config.client_mac, hwmac, 
6);
+       }
        clientid_mac_ptr = NULL;
        if (!(opt & OPT_C) && !udhcp_find_option(client_config.options, 
DHCP_CLIENT_ID)) {
                /* not suppressed and not set, set the default client ID */

Reply via email to