busybox: mount: don't pass option "auto" to kernel
[opendreambox.git] / meta-opendreambox / recipes-core / busybox / busybox-1.19.4 / 0009-udhcpc-calculate-broadcast-address-if-not-given-by-s.patch
1 From 7f3d0f0e58602e8d96988736d80ba28d31338ea2 Mon Sep 17 00:00:00 2001
2 From: Andreas Oberritter <obi@opendreambox.org>
3 Date: Mon, 14 May 2012 17:32:16 +0200
4 Subject: [PATCH 09/11] udhcpc: calculate broadcast address if not given by
5  server
6
7 * This is more efficient than doing it in the scripts
8
9 Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
10 ---
11  networking/udhcp/common.h |    2 +-
12  networking/udhcp/dhcpc.c  |   16 ++++++++++++++++
13  2 files changed, 17 insertions(+), 1 deletion(-)
14
15 diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
16 index ad6991c..1517498 100644
17 --- a/networking/udhcp/common.h
18 +++ b/networking/udhcp/common.h
19 @@ -122,7 +122,7 @@ enum {
20  //#define DHCP_ROOT_PATH        0x11
21  //#define DHCP_IP_TTL           0x17
22  //#define DHCP_MTU              0x1a
23 -//#define DHCP_BROADCAST        0x1c
24 +#define DHCP_BROADCAST          0x1c
25  //#define DHCP_ROUTES           0x21
26  //#define DHCP_NIS_DOMAIN       0x28
27  //#define DHCP_NIS_SERVER       0x29
28 diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
29 index 4d755e6..9fbd3b3 100644
30 --- a/networking/udhcp/dhcpc.c
31 +++ b/networking/udhcp/dhcpc.c
32 @@ -399,6 +399,22 @@ static char **fill_envp(struct dhcp_packet *packet)
33                 }
34                 i++;
35         }
36 +       /* Calculate the broadcast address, if it wasn't provided
37 +        * by the server, but a subnet mask of /30 or lower was given.
38 +        */
39 +       if (udhcp_get_option(packet, DHCP_BROADCAST) == NULL) {
40 +               temp = udhcp_get_option(packet, DHCP_SUBNET);
41 +               if (temp) {
42 +                       uint32_t subnet;
43 +                       move_from_unaligned32(subnet, temp);
44 +                       if (ntohl(subnet) <= 0xfffffffc) {
45 +                               uint32_t broadcast = packet->yiaddr | ~subnet;
46 +                               *curr = xmalloc(sizeof("broadcast=255.255.255.255"));
47 +                               sprint_nip(*curr, "broadcast=", (uint8_t *)&broadcast);
48 +                               putenv(*curr++);
49 +                       }
50 +               }
51 +       }
52         return envp;
53  }
54  
55 -- 
56 1.7.10.4
57