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