xref: /titanic_52/usr/src/cmd/cmd-inet/sbin/dhcpagent/agent.h (revision 9512fe850e98fdd448c638ca63fdd92a8a510255)
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 2006 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 
34 /*
35  * agent.h contains general symbols that should be available to all
36  * source programs that are part of the agent.  in general, files
37  * specific to a given collection of code (such as interface.h or
38  * dhcpmsg.h) are to be preferred to this dumping ground.  use only
39  * when necessary.
40  */
41 
42 #ifdef	__cplusplus
43 extern "C" {
44 #endif
45 
46 /*
47  * global variables: `tq' and `eh' represent the global timer queue
48  * and event handler, as described in the README. `class_id' is our
49  * vendor class id set early on in main().  `inactivity_id' is the
50  * timer id of the global inactivity timer, which shuts down the agent
51  * if there are no interfaces to manage for DHCP_INACTIVITY_WAIT
52  * seconds. `grandparent' is the pid of the original process when in
53  * adopt mode.  `rtsock_fd' is the global routing socket file descriptor.
54  */
55 
56 extern iu_tq_t		*tq;
57 extern iu_eh_t		*eh;
58 extern char		*class_id;
59 extern int		class_id_len;
60 extern iu_timer_id_t	inactivity_id;
61 extern pid_t		grandparent;
62 extern int		rtsock_fd;
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)	/* one hour */
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