xref: /titanic_41/usr/src/cmd/cmd-inet/sbin/dhcpagent/script_handler.h (revision 058561cbaa119a6f2659bc27ef343e1b47266bb2)
1 /*
2  * CDDL HEADER START
3  *
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 #ifndef	SCRIPT_HANDLER_H
27 #define	SCRIPT_HANDLER_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include "common.h"
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38  * The signal SIGTERM is sent to a script process if it does not exit after
39  * SCRIPT_TIMEOUT seconds; and the signal SIGKILL is sent if it is still alive
40  * SCRIPT_TIMEOUT_GRACE seconds after SIGTERM is sent. (SCRIPT_TIMEOUT +
41  * SCRIPT_TIMEOUT_GRACE) should be less than DHCP_ASYNC_WAIT.
42  */
43 #define	SCRIPT_TIMEOUT		55
44 #define	SCRIPT_TIMEOUT_GRACE	3
45 
46 /*
47  * script exit status as dhcpagent sees it, for debug purpose only.
48  *
49  * SCRIPT_OK:		script exits ok, no timeout
50  * SCRIPT_KILLED:	script timeout, killed
51  * SCRIPT_FAILED:	unknown status
52  */
53 
54 enum { SCRIPT_OK, SCRIPT_KILLED, SCRIPT_FAILED };
55 
56 /*
57  * event names for script.
58  */
59 #define	EVENT_BOUND	"BOUND"
60 #define	EVENT_EXTEND	"EXTEND"
61 #define	EVENT_EXPIRE	"EXPIRE"
62 #define	EVENT_DROP	"DROP"
63 #define	EVENT_INFORM	"INFORM"
64 #define	EVENT_RELEASE	"RELEASE"
65 
66 #define	EVENT_BOUND6	"BOUND6"
67 #define	EVENT_EXTEND6	"EXTEND6"
68 #define	EVENT_EXPIRE6	"EXPIRE6"
69 #define	EVENT_DROP6	"DROP6"
70 #define	EVENT_INFORM6	"INFORM6"
71 #define	EVENT_LOSS6	"LOSS6"
72 #define	EVENT_RELEASE6	"RELEASE6"
73 
74 /*
75  * script location.
76  */
77 #define	SCRIPT_PATH	"/etc/dhcp/eventhook"
78 
79 /*
80  * the number of running scripts.
81  */
82 extern unsigned int	script_count;
83 
84 boolean_t	script_start(dhcp_smach_t *, const char *, script_callback_t *,
85 		    void *, int *);
86 void		script_stop(dhcp_smach_t *);
87 
88 #ifdef	__cplusplus
89 }
90 #endif
91 
92 #endif	/* SCRIPT_HANDLER_H */
93