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 AGENT_H 28 #define AGENT_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/types.h> 33 #include <libinetutil.h> 34 35 /* 36 * agent.h contains general symbols that should be available to all 37 * source programs that are part of the agent. in general, files 38 * specific to a given collection of code (such as interface.h or 39 * dhcpmsg.h) are to be preferred to this dumping ground. use only 40 * when necessary. 41 */ 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /* 48 * global variables: `tq' and `eh' represent the global timer queue 49 * and event handler, as described in the README. `class_id' is our 50 * vendor class id set early on in main(). `inactivity_id' is the 51 * timer id of the global inactivity timer, which shuts down the agent 52 * if there are no interfaces to manage for DHCP_INACTIVITY_WAIT 53 * seconds. `grandparent' is the pid of the original process when in 54 * adopt mode. 55 */ 56 57 extern iu_tq_t *tq; 58 extern iu_eh_t *eh; 59 extern char *class_id; 60 extern int class_id_len; 61 extern iu_timer_id_t inactivity_id; 62 extern pid_t grandparent; 63 64 boolean_t drain_script(iu_eh_t *, void *); 65 66 /* 67 * global tunable parameters. an `I' in the preceding comment indicates 68 * an implementation artifact; a `R' in the preceding comment indicates 69 * that the value was suggested (or required) by RFC2131. 70 */ 71 72 /* I: how many seconds to wait before restarting DHCP on an interface */ 73 #define DHCP_RESTART_WAIT 10 74 75 /* 76 * I: the maximum number of milliseconds to wait before SELECTING on an 77 * interface. RFC2131 recommends a random wait of between one and ten seconds, 78 * to speed up DHCP at boot we wait between zero and two seconds. 79 */ 80 #define DHCP_SELECT_WAIT 2000 81 82 /* R: how many seconds before lease expiration we give up trying to rebind */ 83 #define DHCP_REBIND_MIN 60 84 85 /* I: seconds to wait retrying dhcp_expire() if uncancellable async event */ 86 #define DHCP_EXPIRE_WAIT 10 87 88 /* R: approximate percentage of lease time to wait until RENEWING state */ 89 #define DHCP_T1_FACT .5 90 91 /* R: approximate percentage of lease time to wait until REBINDING state */ 92 #define DHCP_T2_FACT .875 93 94 /* I: number of REQUEST attempts before assuming something is awry */ 95 #define DHCP_MAX_REQUESTS 4 96 97 /* I: epsilon in seconds used to check if old and new lease times are same */ 98 #define DHCP_LEASE_EPS 30 99 100 /* I: if lease is not being extended, seconds left before alerting user */ 101 #define DHCP_LEASE_ERROR_THRESH (60*60*24*2) /* two days */ 102 103 /* I: how many seconds before bailing out if there's no work to do */ 104 #define DHCP_INACTIVITY_WAIT (60*3) /* three minutes */ 105 106 /* I: the maximum amount of seconds we use an adopted lease */ 107 #define DHCP_ADOPT_LEASE_MAX (60*60) /* one hour */ 108 109 /* I: number of seconds grandparent waits for child to finish adoption. */ 110 #define DHCP_ADOPT_SLEEP 30 111 112 /* I: the maximum amount of milliseconds to wait for an ipc request */ 113 #define DHCP_IPC_REQUEST_WAIT (3*1000) /* three seconds */ 114 115 /* 116 * reasons for why iu_handle_events() returned 117 */ 118 enum { DHCP_REASON_INACTIVITY, DHCP_REASON_SIGNAL, DHCP_REASON_TERMINATE }; 119 120 #ifdef __cplusplus 121 } 122 #endif 123 124 #endif /* AGENT_H */ 125