4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
24 * INFORM_SENT state of the client state machine.
27 #include <sys/types.h>
29 #include <sys/socket.h>
30 #include <netinet/in.h>
31 #include <netinet/udp.h>
32 #include <netinet/ip_var.h>
33 #include <netinet/udp_var.h>
38 #include "interface.h"
41 static boolean_t
stop_informing(dhcp_smach_t
*, unsigned int);
44 * dhcp_inform(): sends an INFORM packet and sets up reception for an ACK
46 * input: dhcp_smach_t *: the state machine to use
48 * note: the INFORM cannot be sent successfully if the interface
49 * does not have an IP address (this is mostly an issue for IPv4).
50 * We switch into INFORM_SENT state before sending the packet so
51 * that the packet-sending subsystem uses regular sockets and sets
52 * the source address. (See set_smach_state.)
56 dhcp_inform(dhcp_smach_t
*dsmp
)
60 if (!set_smach_state(dsmp
, INFORM_SENT
))
64 dpkt
= init_pkt(dsmp
, DHCPV6_MSG_INFO_REQ
);
66 /* Add required Option Request option */
67 (void) add_pkt_prl(dpkt
, dsmp
);
68 dsmp
->dsm_server
= ipv6_all_dhcp_relay_and_servers
;
69 (void) send_pkt_v6(dsmp
, dpkt
, dsmp
->dsm_server
,
70 stop_informing
, DHCPV6_INF_TIMEOUT
, DHCPV6_INF_MAX_RT
);
75 * Assemble a DHCPREQUEST packet, without the Server ID option.
76 * Fill in ciaddr, since we know this. dsm_server will be set
77 * to the server's IP address, which will be the broadcast
78 * address if we don't know it. The max DHCP message size
79 * option is set to the interface max, minus the size of the
83 dpkt
= init_pkt(dsmp
, INFORM
);
84 IN6_V4MAPPED_TO_INADDR(&dsmp
->dsm_lif
->lif_v6addr
,
87 (void) add_pkt_opt16(dpkt
, CD_MAX_DHCP_SIZE
,
88 htons(dsmp
->dsm_lif
->lif_pif
->pif_max
-
89 sizeof (struct udpiphdr
)));
90 if (class_id_len
!= 0) {
91 (void) add_pkt_opt(dpkt
, CD_CLASS_ID
, class_id
,
94 (void) add_pkt_prl(dpkt
, dsmp
);
95 (void) add_pkt_opt(dpkt
, CD_END
, NULL
, 0);
97 IN6_V4MAPPED_TO_IPADDR(&dsmp
->dsm_server
, server
);
98 if (!send_pkt(dsmp
, dpkt
, server
, stop_informing
)) {
99 dhcpmsg(MSG_ERROR
, "dhcp_inform: send_pkt failed");
107 dsmp
->dsm_dflags
|= DHCP_IF_FAILED
;
108 ipc_action_finish(dsmp
, DHCP_IPC_E_INT
);
109 (void) set_smach_state(dsmp
, INIT
);
113 * stop_informing(): decides when to stop retransmitting Information-Requests
115 * input: dhcp_smach_t *: the state machine Info-Reqs are being sent from
116 * unsigned int: the number of requests sent so far
117 * output: boolean_t: B_TRUE if retransmissions should stop
122 stop_informing(dhcp_smach_t
*dsmp
, unsigned int n_requests
)