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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 #include <stdlib.h>
29 #include <sys/types.h>
30 #include <dhcpmsg.h>
31 #include <dhcpagent_ipc.h>
32
33 #include "agent.h"
34 #include "states.h"
35 #include "interface.h"
36 #include "ipc_action.h"
37 #include "util.h"
38
39 static iu_tq_callback_t ipc_action_timeout;
40
41 /*
42 * ipc_action_init(): initializes the ipc_action structure
43 *
89 } else {
90 iareq->ia_tid = iu_schedule_timer(tq,
91 iareq->ia_request->timeout, ipc_action_timeout, dsmp);
92
93 if (iareq->ia_tid == -1) {
94 dhcpmsg(MSG_ERROR, "ipc_action_start: failed to set "
95 "timer for %s on %s",
96 dhcp_ipc_type_to_string(iareq->ia_cmd),
97 dsmp->dsm_name);
98 return (B_FALSE);
99 }
100
101 hold_smach(dsmp);
102 }
103
104 *ia = *iareq;
105
106 /* We've taken ownership, so the input request is now invalid */
107 ipc_action_init(iareq);
108
109 dhcpmsg(MSG_DEBUG, "ipc_action_start: started %s (command %d) on %s",
110 dhcp_ipc_type_to_string(ia->ia_cmd), ia->ia_cmd, dsmp->dsm_name);
111
112 dsmp->dsm_dflags |= DHCP_IF_BUSY;
113
114 /* This cannot fail due to the async_cancel above */
115 (void) async_start(dsmp, ia->ia_cmd, B_TRUE);
116
117 return (B_TRUE);
118 }
119
120 /*
121 * ipc_action_finish(): completes an ipc_action request on an interface
122 *
123 * input: dhcp_smach_t *: the state machine to complete the action on
124 * int: the reason why the action finished (nonzero on error)
125 * output: void
126 */
127
128 void
129 ipc_action_finish(dhcp_smach_t *dsmp, int reason)
130 {
|
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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
25 */
26
27 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 #include <stdlib.h>
30 #include <sys/types.h>
31 #include <dhcpmsg.h>
32 #include <dhcpagent_ipc.h>
33
34 #include "agent.h"
35 #include "states.h"
36 #include "interface.h"
37 #include "ipc_action.h"
38 #include "util.h"
39
40 static iu_tq_callback_t ipc_action_timeout;
41
42 /*
43 * ipc_action_init(): initializes the ipc_action structure
44 *
90 } else {
91 iareq->ia_tid = iu_schedule_timer(tq,
92 iareq->ia_request->timeout, ipc_action_timeout, dsmp);
93
94 if (iareq->ia_tid == -1) {
95 dhcpmsg(MSG_ERROR, "ipc_action_start: failed to set "
96 "timer for %s on %s",
97 dhcp_ipc_type_to_string(iareq->ia_cmd),
98 dsmp->dsm_name);
99 return (B_FALSE);
100 }
101
102 hold_smach(dsmp);
103 }
104
105 *ia = *iareq;
106
107 /* We've taken ownership, so the input request is now invalid */
108 ipc_action_init(iareq);
109
110 dhcpmsg(MSG_DEBUG, "ipc_action_start: started %s (command %d) on %s,"
111 " buffer length %u",
112 dhcp_ipc_type_to_string(ia->ia_cmd), ia->ia_cmd, dsmp->dsm_name,
113 ia->ia_request == NULL ? 0 : ia->ia_request->data_length);
114
115 dsmp->dsm_dflags |= DHCP_IF_BUSY;
116
117 /* This cannot fail due to the async_cancel above */
118 (void) async_start(dsmp, ia->ia_cmd, B_TRUE);
119
120 return (B_TRUE);
121 }
122
123 /*
124 * ipc_action_finish(): completes an ipc_action request on an interface
125 *
126 * input: dhcp_smach_t *: the state machine to complete the action on
127 * int: the reason why the action finished (nonzero on error)
128 * output: void
129 */
130
131 void
132 ipc_action_finish(dhcp_smach_t *dsmp, int reason)
133 {
|