xref: /onnv-gate/usr/src/cmd/cmd-inet/sbin/dhcpagent/script_handler.h (revision 3431:9f2d277dcffa)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*3431Scarlsonj  * Common Development and Distribution License (the "License").
6*3431Scarlsonj  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*3431Scarlsonj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	SCRIPT_HANDLER_H
270Sstevel@tonic-gate #define	SCRIPT_HANDLER_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
31*3431Scarlsonj #include "common.h"
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #ifdef	__cplusplus
340Sstevel@tonic-gate extern "C" {
350Sstevel@tonic-gate #endif
360Sstevel@tonic-gate 
370Sstevel@tonic-gate /*
380Sstevel@tonic-gate  * The signal SIGTERM is sent to a script process if it does not exit after
390Sstevel@tonic-gate  * SCRIPT_TIMEOUT seconds; and the signal SIGKILL is sent if it is still alive
400Sstevel@tonic-gate  * SCRIPT_TIMEOUT_GRACE seconds after SIGTERM is sent. (SCRIPT_TIMEOUT +
410Sstevel@tonic-gate  * SCRIPT_TIMEOUT_GRACE) should be less than DHCP_ASYNC_WAIT.
420Sstevel@tonic-gate  */
430Sstevel@tonic-gate #define	SCRIPT_TIMEOUT		55
440Sstevel@tonic-gate #define	SCRIPT_TIMEOUT_GRACE	3
450Sstevel@tonic-gate 
460Sstevel@tonic-gate /*
470Sstevel@tonic-gate  * script exit status as dhcpagent sees it, for debug purpose only.
480Sstevel@tonic-gate  *
490Sstevel@tonic-gate  * SCRIPT_OK:		script exits ok, no timeout
500Sstevel@tonic-gate  * SCRIPT_KILLED:	script timeout, killed
510Sstevel@tonic-gate  * SCRIPT_FAILED:	unknown status
520Sstevel@tonic-gate  */
530Sstevel@tonic-gate 
540Sstevel@tonic-gate enum { SCRIPT_OK, SCRIPT_KILLED, SCRIPT_FAILED };
550Sstevel@tonic-gate 
560Sstevel@tonic-gate /*
570Sstevel@tonic-gate  * event names for script.
580Sstevel@tonic-gate  */
590Sstevel@tonic-gate #define	EVENT_BOUND	"BOUND"
600Sstevel@tonic-gate #define	EVENT_EXTEND	"EXTEND"
610Sstevel@tonic-gate #define	EVENT_EXPIRE	"EXPIRE"
620Sstevel@tonic-gate #define	EVENT_DROP	"DROP"
63*3431Scarlsonj #define	EVENT_INFORM	"INFORM"
640Sstevel@tonic-gate #define	EVENT_RELEASE	"RELEASE"
650Sstevel@tonic-gate 
66*3431Scarlsonj #define	EVENT_BOUND6	"BOUND6"
67*3431Scarlsonj #define	EVENT_EXTEND6	"EXTEND6"
68*3431Scarlsonj #define	EVENT_EXPIRE6	"EXPIRE6"
69*3431Scarlsonj #define	EVENT_DROP6	"DROP6"
70*3431Scarlsonj #define	EVENT_INFORM6	"INFORM6"
71*3431Scarlsonj #define	EVENT_LOSS6	"LOSS6"
72*3431Scarlsonj #define	EVENT_RELEASE6	"RELEASE6"
73*3431Scarlsonj 
740Sstevel@tonic-gate /*
750Sstevel@tonic-gate  * script location.
760Sstevel@tonic-gate  */
770Sstevel@tonic-gate #define	SCRIPT_PATH	"/etc/dhcp/eventhook"
780Sstevel@tonic-gate 
790Sstevel@tonic-gate /*
800Sstevel@tonic-gate  * the number of running scripts.
810Sstevel@tonic-gate  */
820Sstevel@tonic-gate extern unsigned int	script_count;
830Sstevel@tonic-gate 
84*3431Scarlsonj boolean_t	script_start(dhcp_smach_t *, const char *, script_callback_t *,
85*3431Scarlsonj 		    void *, int *);
86*3431Scarlsonj void		script_stop(dhcp_smach_t *);
870Sstevel@tonic-gate 
880Sstevel@tonic-gate #ifdef	__cplusplus
890Sstevel@tonic-gate }
900Sstevel@tonic-gate #endif
910Sstevel@tonic-gate 
920Sstevel@tonic-gate #endif	/* SCRIPT_HANDLER_H */
93