xref: /titanic_44/usr/src/cmd/cmd-inet/sbin/dhcpagent/script_handler.h (revision 18c2aff776a775d34a4c9893a4c72e0434d68e36)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	SCRIPT_HANDLER_H
28 #define	SCRIPT_HANDLER_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include "interface.h"
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * The signal SIGTERM is sent to a script process if it does not exit after
40  * SCRIPT_TIMEOUT seconds; and the signal SIGKILL is sent if it is still alive
41  * SCRIPT_TIMEOUT_GRACE seconds after SIGTERM is sent. (SCRIPT_TIMEOUT +
42  * SCRIPT_TIMEOUT_GRACE) should be less than DHCP_ASYNC_WAIT.
43  */
44 #define	SCRIPT_TIMEOUT		55
45 #define	SCRIPT_TIMEOUT_GRACE	3
46 
47 /*
48  * script exit status as dhcpagent sees it, for debug purpose only.
49  *
50  * SCRIPT_OK:		script exits ok, no timeout
51  * SCRIPT_KILLED:	script timeout, killed
52  * SCRIPT_FAILED:	unknown status
53  */
54 
55 enum { SCRIPT_OK, SCRIPT_KILLED, SCRIPT_FAILED };
56 
57 /*
58  * event names for script.
59  */
60 #define	EVENT_BOUND	"BOUND"
61 #define	EVENT_EXTEND	"EXTEND"
62 #define	EVENT_EXPIRE	"EXPIRE"
63 #define	EVENT_DROP	"DROP"
64 #define	EVENT_RELEASE	"RELEASE"
65 
66 /*
67  * script location.
68  */
69 #define	SCRIPT_PATH	"/etc/dhcp/eventhook"
70 
71 /*
72  * the number of running scripts.
73  */
74 extern unsigned int	script_count;
75 
76 int	script_start(struct ifslist *, const char *,
77 		script_callback_t *, const char *, int *);
78 void	script_stop(struct ifslist *);
79 
80 #ifdef	__cplusplus
81 }
82 #endif
83 
84 #endif	/* SCRIPT_HANDLER_H */
85