select.c revision cfb9c9abdc2696bc174bb10a3a28552dc917b98f
/*
* 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
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* SELECTING state of the client state machine.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <time.h>
#include <limits.h>
#include <dhcpmsg.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;
}
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;
}
/*
* dhcp_collect_dlpi(): collects incoming OFFERs, ACKs, and NAKs via DLPI.
*
* input: iu_eh_t *: unused
* int: the file descriptor the mesage arrived on
* short: unused
* iu_event_id_t: the id of this event callback with the handler
* void *: the physical interface that received the message
* output: void
*/
/* ARGSUSED */
void
void *arg)
{
const char *pname;
return;
/*
* DHCP_PUNTYPED messages are BOOTP server responses.
*/
if (!pkt_v4_match(recv_type,
return;
}
/*
* Loop through the state machines that match on XID to find one that's
* interested in this offer. If there are none, then discard.
*/
/*
* Find state machine on correct interface.
*/
break;
}
"machine for %s packet XID %#x received via DLPI on %s",
return;
}
/*
* Ignore state machines that aren't looking for DLPI messages.
*/
if (!dsmp->dsm_using_dlpi) {
"machine for %s packet XID %#x received via DLPI on %s",
return;
}
return;
}
} else {
}
}
/*
* 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);
}