Merge commit 'opendreambox/opendreambox-1.6' into vuplus-1.6
[vuplus_openembedded] / recipes / busybox / busybox-1.15.3 / vuplus / dhcp-hostname.patch
1 diff -Naur busybox-1.11.3/networking/udhcp/dhcpc.c busybox-1.11.3_dhcp-hostname/networking/udhcp/dhcpc.c
2 --- busybox-1.11.3/networking/udhcp/dhcpc.c     2008-06-25 14:51:14.000000000 +0200
3 +++ busybox-1.11.3_dhcp-hostname/networking/udhcp/dhcpc.c       2008-12-05 11:41:36.000000000 +0100
4 @@ -145,6 +145,7 @@
5         struct timeval tv;
6         struct dhcpMessage packet;
7         fd_set rfds;
8 +       char hostbuf[256];      /* SUSv2: hostnames are <= 255 bytes */
9  
10  #if ENABLE_GETOPT_LONG
11         static const char udhcpc_longopts[] ALIGN1 =
12 @@ -210,6 +211,13 @@
13         USE_FEATURE_UDHCP_PORT(CLIENT_PORT = 68;)
14         client_config.interface = "eth0";
15         client_config.script = DEFAULT_SCRIPT;
16 +       if (gethostname (hostbuf, sizeof (hostbuf)) == 0) {
17 +               int len = strlen (hostbuf);
18 +               client_config.hostname = xmalloc (len + 2);
19 +               client_config.hostname[OPT_CODE] = DHCP_HOST_NAME;
20 +               client_config.hostname[OPT_LEN] = len;
21 +               strncpy(client_config.hostname + 2, hostbuf, len);
22 +       }
23  
24         /* Parse command line */
25         /* Cc: mutually exclusive; O: list; -T,-t,-A take numeric param */