select.c revision 0a3e1f6cea71f435162ce34b86d7b0ff30795ac6
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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
*/
/*
*
* SELECTING state of the client state machine.
*/
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <time.h>
#include <limits.h>
#include <dhcpmsg.h>
#include <dhcp_hostconf.h>
#include "states.h"
#include "agent.h"
#include "util.h"
#include "interface.h"
#include "packet.h"
#include "defaults.h"
static stop_func_t stop_selecting;
/*
* dhcp_start(): starts DHCP on a state machine
*
* input: iu_tq_t *: unused
* void *: the state machine on which to start DHCP
* output: void
*/
/* ARGSUSED */
static void
{
if (verify_smach(dsmp)) {
}
}
/*
* set_start_timer(): sets a random timer to start a DHCP state machine
*
* input: dhcp_smach_t *: the state machine on which to start DHCP
* output: boolean_t: B_TRUE if a timer is now running
*/
{
return (B_TRUE);
return (B_FALSE);
return (B_TRUE);
}
/*
* dhcp_selecting(): sends a DISCOVER and sets up reception of OFFERs for
* IPv4, or sends a Solicit and sets up reception of
* Advertisements for DHCPv6.
*
* input: dhcp_smach_t *: the state machine on which to send the DISCOVER
* output: void
*/
void
{
const char *reqhost;
/*
* user-tunable number of seconds before seeing if OFFERs/
* none have come in, we continue to wait, sending out our DISCOVER/
* Solicit probes with exponential backoff. If no OFFER/Advertisement
* is ever received, we will wait forever (note that since we're
* event-driven though, we're still able to service other state
* machines).
*
* Note that we do an reset_smach() here because we may be landing in
* dhcp_selecting() as a result of restarting DHCP, so the state
* machine may not be fresh.
*/
"dhcp_selecting: cannot switch to SELECTING state; "
goto failed;
}
/* Remove the stale hostconf file, if there is any */
goto failed;
}
/*
* Assemble and send the DHCPDISCOVER or Solicit message.
*
* If this fails, we'll wait for the select timer to go off
* before trying again.
*/
"Solicit packet");
return;
}
/* Add an IA_NA option for our controlling LIF */
sizeof (d6in) - sizeof (dhcpv6_option_t));
/* Option Request option for desired information */
/* Enable Rapid-Commit */
/* xxx add Reconfigure Accept */
} else {
"DISCOVER packet");
return;
}
/*
* The max DHCP message size option is set to the interface
* MTU, minus the size of the UDP and IP headers.
*/
if (class_id_len != 0) {
}
"dhcp_selecting: DF_REQUEST_HOSTNAME");
reqhost);
else
"dhcp_selecting: cannot allocate "
"memory for host name option");
}
}
}
return;
}
/*
* stop_selecting(): decides when to stop retransmitting DISCOVERs -- only when
* abandoning the state machine. For DHCPv6, this timer may
* go off before the offer wait timer. If so, then this is a
* good time to check for valid Advertisements, so cancel the
* timer and go check.
*
* input: dhcp_smach_t *: the state machine DISCOVERs are being sent on
* unsigned int: the number of DISCOVERs sent so far
* output: boolean_t: B_TRUE if retransmissions should stop
*/
/* ARGSUSED1 */
static boolean_t
{
/*
* If we're using v4 and the underlying LIF we're trying to configure
* has been touched by the user, then bail out.
*/
return (B_TRUE);
}
return (B_TRUE);
}
return (B_FALSE);
}