select.c revision c2934490a71fd1db5f18fa4b6f290718ef053845
/*
* 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 2006 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 <stdlib.h>
#include <stdio.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 iu_eh_callback_t dhcp_collect_offers;
static stop_func_t stop_selecting;
/*
* dhcp_start(): starts DHCP on an interface
*
* input: iu_tq_t *: unused
* void *: the interface to start DHCP on
* output: void
*/
/* ARGSUSED */
void
{
(void) release_ifs(ifsp);
return;
}
}
/*
* dhcp_selecting(): sends a DISCOVER and sets up reception for an OFFER
*
* input: struct ifslist *: the interface to send the DISCOVER on, ...
* output: void
*/
void
{
const char *reqhost;
/*
* we first set up to collect OFFER packets as they arrive.
* we then send out DISCOVER probes. then we wait at a
* user-tunable number of seconds before seeing if OFFERs have
* come in response to our DISCOVER. if none have come in, we
* continue to wait, sending out our DISCOVER probes with
* exponential backoff. if an OFFER is never received, we
* will wait forever (note that since we're event-driven
* though, we're still able to service other interfaces.)
*
* note that we do an reset_ifs() here because we may be
* landing in dhcp_selecting() as a result of restarting DHCP,
* so the ifs may not be fresh.
*/
"OFFER packets, reverting to INIT on %s",
return;
} else
"OFFER packets");
(void) release_ifs(ifsp);
}
return;
} else
/*
* Assemble DHCPDISCOVER 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)));
else
" allocate memory for host name option");
}
}
}
/*
* dhcp_collect_offers(): collects incoming OFFERs to a DISCOVER
*
* input: iu_eh_t *: unused
* int: the file descriptor the OFFER arrived on
* short: unused
* iu_event_id_t: the id of this event callback with the handler
* void *: the interface that received the OFFER
* output: void
*/
/* ARGSUSED */
static void
void *arg)
{
if (verify_ifs(ifsp) == 0) {
return;
}
/*
* DHCP_PUNTYPED messages are BOOTP server responses.
*/
}
/*
* stop_selecting(): decides when to stop retransmitting DISCOVERs (never)
*
* input: struct ifslist *: the interface DISCOVERs are being sent on
* unsigned int: the number of DISCOVERs sent so far
* output: boolean_t: B_TRUE if retransmissions should stop
*/
/* ARGSUSED */
static boolean_t
{
return (B_FALSE);
}