xref: /onnv-gate/usr/src/cmd/cmd-inet/sbin/dhcpagent/agent.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	AGENT_H
28*0Sstevel@tonic-gate #define	AGENT_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <sys/types.h>
33*0Sstevel@tonic-gate #include <libinetutil.h>
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate /*
36*0Sstevel@tonic-gate  * agent.h contains general symbols that should be available to all
37*0Sstevel@tonic-gate  * source programs that are part of the agent.  in general, files
38*0Sstevel@tonic-gate  * specific to a given collection of code (such as interface.h or
39*0Sstevel@tonic-gate  * dhcpmsg.h) are to be preferred to this dumping ground.  use only
40*0Sstevel@tonic-gate  * when necessary.
41*0Sstevel@tonic-gate  */
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate #ifdef	__cplusplus
44*0Sstevel@tonic-gate extern "C" {
45*0Sstevel@tonic-gate #endif
46*0Sstevel@tonic-gate 
47*0Sstevel@tonic-gate /*
48*0Sstevel@tonic-gate  * global variables: `tq' and `eh' represent the global timer queue
49*0Sstevel@tonic-gate  * and event handler, as described in the README. `class_id' is our
50*0Sstevel@tonic-gate  * vendor class id set early on in main().  `inactivity_id' is the
51*0Sstevel@tonic-gate  * timer id of the global inactivity timer, which shuts down the agent
52*0Sstevel@tonic-gate  * if there are no interfaces to manage for DHCP_INACTIVITY_WAIT
53*0Sstevel@tonic-gate  * seconds. `grandparent' is the pid of the original process when in
54*0Sstevel@tonic-gate  * adopt mode.
55*0Sstevel@tonic-gate  */
56*0Sstevel@tonic-gate 
57*0Sstevel@tonic-gate extern iu_tq_t		*tq;
58*0Sstevel@tonic-gate extern iu_eh_t		*eh;
59*0Sstevel@tonic-gate extern char		*class_id;
60*0Sstevel@tonic-gate extern int		class_id_len;
61*0Sstevel@tonic-gate extern iu_timer_id_t	inactivity_id;
62*0Sstevel@tonic-gate extern pid_t		grandparent;
63*0Sstevel@tonic-gate 
64*0Sstevel@tonic-gate boolean_t	drain_script(iu_eh_t *, void *);
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate /*
67*0Sstevel@tonic-gate  * global tunable parameters.  an `I' in the preceding comment indicates
68*0Sstevel@tonic-gate  * an implementation artifact; a `R' in the preceding comment indicates
69*0Sstevel@tonic-gate  * that the value was suggested (or required) by RFC2131.
70*0Sstevel@tonic-gate  */
71*0Sstevel@tonic-gate 
72*0Sstevel@tonic-gate /* I: how many seconds to wait before restarting DHCP on an interface */
73*0Sstevel@tonic-gate #define	DHCP_RESTART_WAIT	10
74*0Sstevel@tonic-gate 
75*0Sstevel@tonic-gate /*
76*0Sstevel@tonic-gate  * I: the maximum number of milliseconds to wait before SELECTING on an
77*0Sstevel@tonic-gate  * interface. RFC2131 recommends a random wait of between one and ten seconds,
78*0Sstevel@tonic-gate  * to speed up DHCP at boot we wait between zero and two seconds.
79*0Sstevel@tonic-gate  */
80*0Sstevel@tonic-gate #define	DHCP_SELECT_WAIT	2000
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate /* R: how many seconds before lease expiration we give up trying to rebind */
83*0Sstevel@tonic-gate #define	DHCP_REBIND_MIN		60
84*0Sstevel@tonic-gate 
85*0Sstevel@tonic-gate /* I: seconds to wait retrying dhcp_expire() if uncancellable async event */
86*0Sstevel@tonic-gate #define	DHCP_EXPIRE_WAIT	10
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate /* R: approximate percentage of lease time to wait until RENEWING state */
89*0Sstevel@tonic-gate #define	DHCP_T1_FACT		.5
90*0Sstevel@tonic-gate 
91*0Sstevel@tonic-gate /* R: approximate percentage of lease time to wait until REBINDING state */
92*0Sstevel@tonic-gate #define	DHCP_T2_FACT		.875
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate /* I: number of REQUEST attempts before assuming something is awry */
95*0Sstevel@tonic-gate #define	DHCP_MAX_REQUESTS	4
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate /* I: epsilon in seconds used to check if old and new lease times are same */
98*0Sstevel@tonic-gate #define	DHCP_LEASE_EPS		30
99*0Sstevel@tonic-gate 
100*0Sstevel@tonic-gate /* I: if lease is not being extended, seconds left before alerting user */
101*0Sstevel@tonic-gate #define	DHCP_LEASE_ERROR_THRESH	(60*60*24*2)	/* two days */
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate /* I: how many seconds before bailing out if there's no work to do */
104*0Sstevel@tonic-gate #define	DHCP_INACTIVITY_WAIT	(60*3)		/* three minutes */
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate /* I: the maximum amount of seconds we use an adopted lease */
107*0Sstevel@tonic-gate #define	DHCP_ADOPT_LEASE_MAX	(60*60)		/* one hour */
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate /* I: number of seconds grandparent waits for child to finish adoption. */
110*0Sstevel@tonic-gate #define	DHCP_ADOPT_SLEEP	30
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate /* I: the maximum amount of milliseconds to wait for an ipc request */
113*0Sstevel@tonic-gate #define	DHCP_IPC_REQUEST_WAIT	(3*1000)	/* three seconds */
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate /*
116*0Sstevel@tonic-gate  * reasons for why iu_handle_events() returned
117*0Sstevel@tonic-gate  */
118*0Sstevel@tonic-gate enum { DHCP_REASON_INACTIVITY, DHCP_REASON_SIGNAL, DHCP_REASON_TERMINATE };
119*0Sstevel@tonic-gate 
120*0Sstevel@tonic-gate #ifdef	__cplusplus
121*0Sstevel@tonic-gate }
122*0Sstevel@tonic-gate #endif
123*0Sstevel@tonic-gate 
124*0Sstevel@tonic-gate #endif	/* AGENT_H */
125