[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH 3/5] udhcpc: calculate broadcast address if not given by server
From:       Andreas Oberritter <obi () opendreambox ! org>
Date:       2013-04-22 8:48:58
Message-ID: 5174F97A.3020309 () opendreambox ! org
[Download RAW message or body]

Ping.

On 20.03.2013 15:31, Andreas Oberritter wrote:
> * This is more efficient than doing it in the scripts
> 
> Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
> ---
>  networking/udhcp/common.h |    2 +-
>  networking/udhcp/dhcpc.c  |   17 +++++++++++++++++
>  2 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
> index 0e8e45f..af8c105 100644
> --- a/networking/udhcp/common.h
> +++ b/networking/udhcp/common.h
> @@ -126,7 +126,7 @@ enum {
>  //#define DHCP_ROOT_PATH        0x11
>  //#define DHCP_IP_TTL           0x17
>  //#define DHCP_MTU              0x1a
> -//#define DHCP_BROADCAST        0x1c
> +#define DHCP_BROADCAST          0x1c
>  //#define DHCP_ROUTES           0x21
>  //#define DHCP_NIS_DOMAIN       0x28
>  //#define DHCP_NIS_SERVER       0x29
> diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
> index 0862288..fe2e681 100644
> --- a/networking/udhcp/dhcpc.c
> +++ b/networking/udhcp/dhcpc.c
> @@ -533,6 +533,23 @@ static char **fill_envp(struct dhcp_packet *packet)
>  		i++;
>  	}
>  
> +	/* Calculate the broadcast address, if it wasn't provided
> +	 * by the server, but a subnet mask of /30 or lower was given.
> +	 */
> +	if (udhcp_get_option(packet, DHCP_BROADCAST) == NULL) {
> +		temp = udhcp_get_option(packet, DHCP_SUBNET);
> +		if (temp) {
> +			uint32_t subnet;
> +			move_from_unaligned32(subnet, temp);
> +			if (ntohl(subnet) <= 0xfffffffc) {
> +				uint32_t broadcast = packet->yiaddr | ~subnet;
> +				*curr = xmalloc(sizeof("broadcast=255.255.255.255"));
> +				sprint_nip(*curr, "broadcast=", (uint8_t *)&broadcast);
> +				putenv(*curr++);
> +			}
> +		}
> +	}
> +
>  	return envp;
>  }
>  
> 

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic