renew.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <time.h>
#include <unistd.h>
#include <libinetutil.h>
#include <dhcpmsg.h>
#include <string.h>
#include "packet.h"
#include "agent.h"
#include "script_handler.h"
#include "interface.h"
#include "states.h"
#include "util.h"
/*
* next_extend_time(): returns the next time an EXTEND request should be sent
*
* input: monosec_t: the absolute time when the next state is entered
* output: uint32_t: the number of seconds in the future to send the next
* EXTEND request
*/
static uint32_t
{
return (0);
}
/*
* dhcp_renew(): attempts to renew a DHCP lease
*
* input: iu_tq_t *: unused
* void *: the ifslist to renew the lease on
* output: void
*/
/* ARGSUSED */
void
{
(void) release_ifs(ifsp);
return;
}
/*
* sanity check: don't send packets if we're past t2.
*/
return;
/*
* if there isn't an async event pending, then try to renew.
*/
if (!async_pending(ifsp))
/*
* try to send extend. if we don't succeed,
* async_timeout() will clean us up.
*/
(void) dhcp_extending(ifsp);
/*
* if we're within DHCP_REBIND_MIN seconds of REBINDING, don't
* reschedule ourselves.
*/
if (next == 0)
return;
/*
* no big deal if we can't reschedule; we still have the REBIND
* state to save us.
*/
}
/*
* dhcp_rebind(): attempts to renew a DHCP lease from the REBINDING state
*
* input: iu_tq_t *: unused
* void *: the ifslist to renew the lease on
* output: void
*/
/* ARGSUSED */
void
{
(void) release_ifs(ifsp);
return;
}
/*
* sanity check: don't send packets if we've already expired.
*/
return;
/*
* if this is our first venture into the REBINDING state, then
* reset the server address. we know the renew timer has
* already been cancelled (or we wouldn't be here).
*/
}
/*
* if there isn't an async event pending, then try to rebind.
*/
if (!async_pending(ifsp))
/*
* try to send extend. if we don't succeed,
* async_timeout() will clean us up.
*/
(void) dhcp_extending(ifsp);
/*
* if we're within DHCP_REBIND_MIN seconds of EXPIRE, don't
* reschedule ourselves.
*/
if (next == 0) {
return;
}
/*
* we'll just end up in dhcp_expire(), but it sure sucks.
*/
}
/*
* dhcp_restart(): callback function to script_start
*
* input: struct ifslist *: the interface to be restarted
* const char *: unused
* output: int: always 1
*/
/* ARGSUSED */
static int
{
/*
* in the case where the lease is less than DHCP_REBIND_MIN
* seconds, we will never enter dhcp_renew() and thus the packet
* counters will not be reset. in that case, reset them here.
*/
ifsp->if_bad_offers = 0;
ifsp->if_received = 0;
}
(void) canonize_ifs(ifsp);
/* reset_ifs() in dhcp_selecting() will clean up any leftover state */
return (1);
}
/*
* dhcp_expire(): expires a lease on a given interface and restarts DHCP
*
* input: iu_tq_t *: unused
* void *: the ifslist to expire the lease on
* output: void
*/
/* ARGSUSED */
void
{
(void) release_ifs(ifsp);
return;
}
if (async_pending(ifsp))
if (async_cancel(ifsp) == 0) {
"current asynchronous command against %s",
/*
* try to schedule ourselves for callback.
* we're really situation critical here
* there's not much hope for us if this fails.
*/
ifsp) != -1) {
return;
}
"dhcp_expire to get called back, proceeding...");
}
/*
* just march on if this fails; at worst someone will be able
* to async_start() while we're actually busy with our own
* asynchronous transaction. better than not having a lease.
*/
}
/*
* dhcp_extending(): sends a REQUEST to extend a lease on a given interface
*
* input: struct ifslist *: the interface to send the REQUEST on
* output: int: 1 if the extension request was sent, 0 otherwise
*/
int
{
ifsp->if_bad_offers = 0;
ifsp->if_received = 0;
}
if (register_acknak(ifsp) == 0) {
"dhcp_acknak for %s, not sending renew request",
return (0);
}
/*
* assemble DHCPREQUEST message. The max dhcp message size
* option is set to the interface max, minus the size of the udp and
* ip headers.
*/
sizeof (struct udpiphdr)));
/*
* if_reqhost was set for this interface in dhcp_selecting()
* if the REQUEST_HOSTNAME option was set and a host name was
* found.
*/
}
/*
* if we can't send the packet, leave the event handler registered
* anyway, since we're not expecting to get any other types of
*/
}