17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5d04ccbb3Scarlsonj * Common Development and Distribution License (the "License"). 6d04ccbb3Scarlsonj * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*3644994cSmeem * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef SCRIPT_HANDLER_H 277c478bd9Sstevel@tonic-gate #define SCRIPT_HANDLER_H 287c478bd9Sstevel@tonic-gate 29d04ccbb3Scarlsonj #include "common.h" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate /* 367c478bd9Sstevel@tonic-gate * The signal SIGTERM is sent to a script process if it does not exit after 377c478bd9Sstevel@tonic-gate * SCRIPT_TIMEOUT seconds; and the signal SIGKILL is sent if it is still alive 387c478bd9Sstevel@tonic-gate * SCRIPT_TIMEOUT_GRACE seconds after SIGTERM is sent. (SCRIPT_TIMEOUT + 397c478bd9Sstevel@tonic-gate * SCRIPT_TIMEOUT_GRACE) should be less than DHCP_ASYNC_WAIT. 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate #define SCRIPT_TIMEOUT 55 427c478bd9Sstevel@tonic-gate #define SCRIPT_TIMEOUT_GRACE 3 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * script exit status as dhcpagent sees it, for debug purpose only. 467c478bd9Sstevel@tonic-gate * 477c478bd9Sstevel@tonic-gate * SCRIPT_OK: script exits ok, no timeout 487c478bd9Sstevel@tonic-gate * SCRIPT_KILLED: script timeout, killed 497c478bd9Sstevel@tonic-gate * SCRIPT_FAILED: unknown status 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate enum { SCRIPT_OK, SCRIPT_KILLED, SCRIPT_FAILED }; 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate /* 557c478bd9Sstevel@tonic-gate * event names for script. 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate #define EVENT_BOUND "BOUND" 587c478bd9Sstevel@tonic-gate #define EVENT_EXTEND "EXTEND" 597c478bd9Sstevel@tonic-gate #define EVENT_EXPIRE "EXPIRE" 607c478bd9Sstevel@tonic-gate #define EVENT_DROP "DROP" 61d04ccbb3Scarlsonj #define EVENT_INFORM "INFORM" 627c478bd9Sstevel@tonic-gate #define EVENT_RELEASE "RELEASE" 637c478bd9Sstevel@tonic-gate 64d04ccbb3Scarlsonj #define EVENT_BOUND6 "BOUND6" 65d04ccbb3Scarlsonj #define EVENT_EXTEND6 "EXTEND6" 66d04ccbb3Scarlsonj #define EVENT_EXPIRE6 "EXPIRE6" 67d04ccbb3Scarlsonj #define EVENT_DROP6 "DROP6" 68d04ccbb3Scarlsonj #define EVENT_INFORM6 "INFORM6" 69d04ccbb3Scarlsonj #define EVENT_LOSS6 "LOSS6" 70d04ccbb3Scarlsonj #define EVENT_RELEASE6 "RELEASE6" 71d04ccbb3Scarlsonj 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * script location. 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate #define SCRIPT_PATH "/etc/dhcp/eventhook" 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* 787c478bd9Sstevel@tonic-gate * the number of running scripts. 797c478bd9Sstevel@tonic-gate */ 807c478bd9Sstevel@tonic-gate extern unsigned int script_count; 817c478bd9Sstevel@tonic-gate 82*3644994cSmeem void script_init(dhcp_smach_t *); 83d04ccbb3Scarlsonj boolean_t script_start(dhcp_smach_t *, const char *, script_callback_t *, 84d04ccbb3Scarlsonj void *, int *); 85d04ccbb3Scarlsonj void script_stop(dhcp_smach_t *); 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate #ifdef __cplusplus 887c478bd9Sstevel@tonic-gate } 897c478bd9Sstevel@tonic-gate #endif 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate #endif /* SCRIPT_HANDLER_H */ 92