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 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef AGENT_H 27 #define AGENT_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #include <sys/types.h> 32 #include <libinetutil.h> 33 #include <dhcpagent_ipc.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 state machines to manage for DHCP_INACTIVITY_WAIT 53 * seconds. `grandparent' is the pid of the original process when in 54 * adopt mode. `rtsock_fd' is the global routing socket file descriptor. 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 extern int rtsock_fd; 64 65 boolean_t drain_script(iu_eh_t *, void *); 66 boolean_t check_cmd_allowed(DHCPSTATE, dhcp_ipc_type_t); 67 68 /* 69 * global tunable parameters. an `I' in the preceding comment indicates 70 * an implementation artifact; a `R' in the preceding comment indicates 71 * that the value was suggested (or required) by RFC2131. 72 */ 73 74 /* I: how many seconds to wait before restarting DHCP on an interface */ 75 #define DHCP_RESTART_WAIT 10 76 77 /* 78 * I: the maximum number of milliseconds to wait before SELECTING on an 79 * interface. RFC2131 recommends a random wait of between one and ten seconds, 80 * to speed up DHCP at boot we wait between zero and two seconds. 81 */ 82 #define DHCP_SELECT_WAIT 2000 83 84 /* R: how many seconds before lease expiration we give up trying to rebind */ 85 #define DHCP_REBIND_MIN 60 86 87 /* I: seconds to wait retrying dhcp_expire() if uncancellable async event */ 88 #define DHCP_EXPIRE_WAIT 10 89 90 /* R: approximate percentage of lease time to wait until RENEWING state */ 91 #define DHCP_T1_FACT .5 92 93 /* R: approximate percentage of lease time to wait until REBINDING state */ 94 #define DHCP_T2_FACT .875 95 96 /* I: number of REQUEST attempts before assuming something is awry */ 97 #define DHCP_MAX_REQUESTS 4 98 99 /* I: epsilon in seconds used to check if old and new lease times are same */ 100 #define DHCP_LEASE_EPS 30 101 102 /* I: if lease is not being extended, seconds left before alerting user */ 103 #define DHCP_LEASE_ERROR_THRESH (60*60) /* one hour */ 104 105 /* I: how many seconds before bailing out if there's no work to do */ 106 #define DHCP_INACTIVITY_WAIT (60*3) /* three minutes */ 107 108 /* I: the maximum amount of seconds we use an adopted lease */ 109 #define DHCP_ADOPT_LEASE_MAX (60*60) /* one hour */ 110 111 /* I: number of seconds grandparent waits for child to finish adoption. */ 112 #define DHCP_ADOPT_SLEEP 30 113 114 /* I: the maximum amount of milliseconds to wait for an ipc request */ 115 #define DHCP_IPC_REQUEST_WAIT (3*1000) /* three seconds */ 116 117 /* 118 * DHCPv6 timer and retransmit values from RFC 3315. 119 */ 120 #define DHCPV6_SOL_MAX_DELAY 1000 /* Max delay of first Solicit; 1s */ 121 #define DHCPV6_CNF_MAX_DELAY 1000 /* Max delay of first Confirm; 1s */ 122 #define DHCPV6_INF_MAX_DELAY 1000 /* Max delay of first Info-req; 1s */ 123 #define DHCPV6_SOL_TIMEOUT 1000 /* Initial Solicit timeout; 1s */ 124 #define DHCPV6_REQ_TIMEOUT 1000 /* Initial Request timeout; 1s */ 125 #define DHCPV6_CNF_TIMEOUT 1000 /* Initial Confirm timeout; 1s */ 126 #define DHCPV6_REN_TIMEOUT 10000 /* Initial Renew timeout; 10s */ 127 #define DHCPV6_REB_TIMEOUT 10000 /* Initial Rebind timeout; 10s */ 128 #define DHCPV6_INF_TIMEOUT 1000 /* Initial Info-req timeout; 1s */ 129 #define DHCPV6_REL_TIMEOUT 1000 /* Initial Release timeout; 1s */ 130 #define DHCPV6_DEC_TIMEOUT 1000 /* Initial Decline timeout; 1s */ 131 #define DHCPV6_SOL_MAX_RT 120000 /* Max Solicit timeout; 2m */ 132 #define DHCPV6_REQ_MAX_RT 30000 /* Max Request timeout; 30s */ 133 #define DHCPV6_CNF_MAX_RT 4000 /* Max Confirm timeout; 4s */ 134 #define DHCPV6_REN_MAX_RT 600000 /* Max Renew timeout; 5m */ 135 #define DHCPV6_REB_MAX_RT 600000 /* Max Rebind timeout; 5m */ 136 #define DHCPV6_INF_MAX_RT 120000 /* Max Info-req timeout; 2m */ 137 #define DHCPV6_CNF_MAX_RD 10000 /* Max Confirm duration; 10s */ 138 #define DHCPV6_REQ_MAX_RC 10 /* Max Request attempts */ 139 #define DHCPV6_REL_MAX_RC 5 /* Max Release attempts */ 140 #define DHCPV6_DEC_MAX_RC 5 /* Max Decline attempts */ 141 142 /* 143 * reasons for why iu_handle_events() returned 144 */ 145 enum { DHCP_REASON_INACTIVITY, DHCP_REASON_SIGNAL, DHCP_REASON_TERMINATE }; 146 147 #ifdef __cplusplus 148 } 149 #endif 150 151 #endif /* AGENT_H */ 152