diff options
author | mbr <mbr@FreeBSD.org> | 2004-06-26 10:37:42 +0000 |
---|---|---|
committer | mbr <mbr@FreeBSD.org> | 2004-06-26 10:37:42 +0000 |
commit | 4e40f399fecf9d0f0e8ca17159648ad46ea9f86c (patch) | |
tree | d903be4110c281897d6065df90848bd752b88210 /contrib/isc-dhcp/client/dhclient.c | |
parent | 1255e60c4d80338ad1bef8f82845886b69b802bf (diff) | |
download | FreeBSD-src-4e40f399fecf9d0f0e8ca17159648ad46ea9f86c.zip FreeBSD-src-4e40f399fecf9d0f0e8ca17159648ad46ea9f86c.tar.gz |
Resolve conflicts.
Diffstat (limited to 'contrib/isc-dhcp/client/dhclient.c')
-rw-r--r-- | contrib/isc-dhcp/client/dhclient.c | 80 |
1 files changed, 43 insertions, 37 deletions
diff --git a/contrib/isc-dhcp/client/dhclient.c b/contrib/isc-dhcp/client/dhclient.c index da64326..cc4061a 100644 --- a/contrib/isc-dhcp/client/dhclient.c +++ b/contrib/isc-dhcp/client/dhclient.c @@ -3,35 +3,26 @@ DHCP Client. */ /* - * Copyright (c) 1995-2002 Internet Software Consortium. - * All rights reserved. + * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 1995-2003 by Internet Software Consortium * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Internet Software Consortium nor the names - * of its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND - * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * Internet Systems Consortium, Inc. + * 950 Charter Street + * Redwood City, CA 94063 + * <info@isc.org> + * http://www.isc.org/ * * This code is based on the original client state machine that was * written by Elliot Poger. The code has been extensively hacked on @@ -42,7 +33,7 @@ #ifndef lint static char ocopyright[] = "$FreeBSD$\n" -"$Id: dhclient.c,v 1.129.2.16 2003/04/26 21:51:39 dhankins Exp $ Copyright (c) 1995-2002 Internet Software Consortium. All rights reserved.\n"; +"$Id: dhclient.c,v 1.129.2.18 2004/06/10 17:59:12 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -79,9 +70,9 @@ struct in_addr giaddr; assert (state_is == state_shouldbe). */ #define ASSERT_STATE(state_is, state_shouldbe) {} -static char copyright[] = "Copyright 1995-2002 Internet Software Consortium."; +static char copyright[] = "Copyright 2004 Internet Systems Consortium."; static char arr [] = "All rights reserved."; -static char message [] = "Internet Software Consortium DHCP Client"; +static char message [] = "Internet Systems Consortium DHCP Client"; static char url [] = "For info, please visit http://www.isc.org/products/DHCP"; u_int16_t local_port=0; @@ -847,11 +838,15 @@ void dhcpack (packet) /* If it wasn't specified by the server, calculate it. */ if (!client -> new -> renewal) - client -> new -> renewal = - client -> new -> expiry / 2; + client -> new -> renewal = client -> new -> expiry / 2 + 1; + + if (client -> new -> renewal <= 0) + client -> new -> renewal = TIME_MAX; /* Now introduce some randomness to the renewal time: */ - client -> new -> renewal = (((client -> new -> renewal + 3) * 3 / 4) + + if (client -> new -> renewal <= TIME_MAX / 3 - 3) + client -> new -> renewal = + (((client -> new -> renewal + 3) * 3 / 4) + (random () % /* XXX NUMS */ ((client -> new -> renewal + 3) / 4))); @@ -870,14 +865,25 @@ void dhcpack (packet) } else client -> new -> rebind = 0; - if (!client -> new -> rebind) - client -> new -> rebind = - (client -> new -> expiry * 7) / 8; /* XXX NUMS */ + if (client -> new -> rebind <= 0) { + if (client -> new -> expiry <= TIME_MAX / 7) + client -> new -> rebind = + client -> new -> expiry * 7 / 8; + else + client -> new -> rebind = + client -> new -> expiry / 8 * 7; + } /* Make sure our randomness didn't run the renewal time past the rebind time. */ - if (client -> new -> renewal > client -> new -> rebind) - client -> new -> renewal = (client -> new -> rebind * 3) / 4; + if (client -> new -> renewal > client -> new -> rebind) { + if (client -> new -> rebind <= TIME_MAX / 3) + client -> new -> renewal = + client -> new -> rebind * 3 / 4; + else + client -> new -> renewal = + client -> new -> rebind / 4 * 3; + } client -> new -> expiry += cur_time; /* Lease lengths can never be negative. */ |