1 | /*
|
---|
2 | * Copyright 2004 Henning Brauer <henning@openbsd.org>
|
---|
3 | * Copyright (c) 1995, 1996, 1997, 1998, 1999
|
---|
4 | * The Internet Software Consortium. All rights reserved.
|
---|
5 | *
|
---|
6 | * Redistribution and use in source and binary forms, with or without
|
---|
7 | * modification, are permitted provided that the following conditions
|
---|
8 | * are met:
|
---|
9 | *
|
---|
10 | * 1. Redistributions of source code must retain the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer.
|
---|
12 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
13 | * notice, this list of conditions and the following disclaimer in the
|
---|
14 | * documentation and/or other materials provided with the distribution.
|
---|
15 | * 3. Neither the name of The Internet Software Consortium nor the names
|
---|
16 | * of its contributors may be used to endorse or promote products derived
|
---|
17 | * from this software without specific prior written permission.
|
---|
18 | *
|
---|
19 | * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
|
---|
20 | * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
---|
21 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
---|
22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
23 | * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
|
---|
24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
27 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
30 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
31 | * SUCH DAMAGE.
|
---|
32 | *
|
---|
33 | * This software has been written for the Internet Software Consortium
|
---|
34 | * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
---|
35 | * Enterprises. To learn more about the Internet Software Consortium,
|
---|
36 | * see ``http://www.vix.com/isc''. To learn more about Vixie
|
---|
37 | * Enterprises, see ``http://www.vix.com''.
|
---|
38 | *
|
---|
39 | * This client was substantially modified and enhanced by Elliot Poger
|
---|
40 | * for use on Linux while he was working on the MosquitoNet project at
|
---|
41 | * Stanford.
|
---|
42 | *
|
---|
43 | * The current version owes much to Elliot's Linux enhancements, but
|
---|
44 | * was substantially reorganized and partially rewritten by Ted Lemon
|
---|
45 | * so as to use the same networking framework that the Internet Software
|
---|
46 | * Consortium DHCP server uses. Much system-specific configuration code
|
---|
47 | * was moved into a shell script so that as support for more operating
|
---|
48 | * systems is added, it will not be necessary to port and maintain
|
---|
49 | * system-specific configuration code to these operating systems - instead,
|
---|
50 | * the shell script can invoke the native tools to accomplish the same
|
---|
51 | * purpose.
|
---|
52 | */
|
---|
53 | /*
|
---|
54 | * WIDE Project DHCP Implementation
|
---|
55 | * Copyright (c) 1995-1997 Akihiro Tominaga
|
---|
56 | * Copyright (c) 1995-1997 WIDE Project
|
---|
57 | * All rights reserved.
|
---|
58 | *
|
---|
59 | * Permission to use, copy, modify and distribute this software and its
|
---|
60 | * documentation is hereby granted, provided the following conditions
|
---|
61 | * are satisfied,
|
---|
62 | *
|
---|
63 | * 1. Both the copyright notice and this permission notice appear in
|
---|
64 | * all copies of the software, derivative works or modified versions,
|
---|
65 | * and any portions thereof, and that both notices appear in
|
---|
66 | * supporting documentation.
|
---|
67 | * 2. All advertising materials mentioning features or use of this software
|
---|
68 | * must display the following acknowledgement:
|
---|
69 | * This product includes software developed by WIDE Project and
|
---|
70 | * its contributors.
|
---|
71 | * 3. Neither the name of WIDE Project nor the names of its contributors
|
---|
72 | * may be used to endorse or promote products derived from this software
|
---|
73 | * without specific prior written permission.
|
---|
74 | *
|
---|
75 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND WIDE
|
---|
76 | * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
|
---|
77 | * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
|
---|
78 | * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
|
---|
79 | *
|
---|
80 | * Feedback of the results generated from any improvements or
|
---|
81 | * extensions made to this software would be much appreciated.
|
---|
82 | * Any such feedback should be sent to:
|
---|
83 | *
|
---|
84 | * Akihiro Tominaga
|
---|
85 | * WIDE Project
|
---|
86 | * Keio University, Endo 5322, Kanagawa, Japan
|
---|
87 | * (E-mail: dhcp-dist@wide.ad.jp)
|
---|
88 | *
|
---|
89 | * WIDE project has the rights to redistribute these changes.
|
---|
90 | */
|
---|
91 | /*
|
---|
92 | * TINET (TCP/IP Protocol Stack)
|
---|
93 | *
|
---|
94 | * Copyright (C) 2011 by Dep. of Computer Science and Engineering
|
---|
95 | * Tomakomai National College of Technology, JAPAN
|
---|
96 | *
|
---|
97 | * ä¸è¨èä½æ¨©è
|
---|
98 | ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
99 | * ã«ãã£ã¦å
|
---|
100 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
101 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
102 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
103 | å¸ï¼ä»¥ä¸ï¼
|
---|
104 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
105 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
106 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
107 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
108 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
109 | * ç¨ã§ããå½¢ã§åé
|
---|
110 | å¸ããå ´åã«ã¯ï¼åé
|
---|
111 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
112 | * è
|
---|
113 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
114 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
115 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
116 | * ç¨ã§ããªãå½¢ã§åé
|
---|
117 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
118 | * ã¨ï¼
|
---|
119 | * (a) åé
|
---|
120 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
121 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
122 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
123 | * (b) åé
|
---|
124 | å¸ã®å½¢æ
|
---|
125 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
126 | * å ±åãããã¨ï¼
|
---|
127 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
128 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
129 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
130 | 責ãããã¨ï¼
|
---|
131 | *
|
---|
132 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
133 | ã
|
---|
134 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
135 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
136 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
137 | *
|
---|
138 | * @(#) $Id$
|
---|
139 | */
|
---|
140 |
|
---|
141 | #ifndef DHCP4_CLI_VAR_H
|
---|
142 | #define DHCP4_CLI_VAR_H
|
---|
143 |
|
---|
144 | /*
|
---|
145 | * DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ããã¹ãæ§é ä½
|
---|
146 | */
|
---|
147 |
|
---|
148 | /* TIMER ã®å®ç¾© */
|
---|
149 |
|
---|
150 | #define DHCP4C_TIMER_SND_DISC 0
|
---|
151 | #define DHCP4C_TIMER_SND_REQ 1
|
---|
152 | #define DHCP4C_TIMER_SND_REL 2
|
---|
153 | #define DHCP4C_TIMER_RCV_OFFER 3
|
---|
154 | #define DHCP4C_TIMER_RCV_ACK 4
|
---|
155 | #define DHCP4C_TIMER_RENEW 5
|
---|
156 | #define DHCP4C_TIMER_REBIND 6
|
---|
157 | #define DHCP4C_TIMER_EXPIRE 7
|
---|
158 | #define NUM_DHCP4C_TIMERS 8
|
---|
159 |
|
---|
160 | #define DHCP4C_TIMER_HZ 1
|
---|
161 |
|
---|
162 | typedef struct dhcp4_cli_context {
|
---|
163 | T_DHCP4_CLI_MSG *rcv_lst; /* åä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã */
|
---|
164 | T_DHCP4_CLI_MSG *val_lst; /* æ¤è¨¼ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã */
|
---|
165 | T_DHCP4_CLI_MSG *prf_lst; /* æ¨å¥¨ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã */
|
---|
166 | T_DHCP4_CLI_MSG *snd_msg; /* éä¿¡ã¡ãã»ã¼ã¸æ§é ä½ */
|
---|
167 | T_DHCP4_CLI_MSG *off_msg; /* éç¥ããããªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ */
|
---|
168 | T_DHCP4_CLI_MSG *act_msg; /* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ */
|
---|
169 | T_IF_SOFTC *sc; /* IF ã®ã½ããã¦ã§ã¢æ
|
---|
170 | å ± */
|
---|
171 | T_IPV4EP dst; /* éä¿¡å
|
---|
172 | ã®IPã¢ãã¬ã¹/ãã¼ãçªå· */
|
---|
173 | SYSTIM snd_start; /* éä¿¡ãéå§ããæé */
|
---|
174 | SYSTIM bind_start; /* BINDãéå§ããæé */
|
---|
175 | SYSTIM expire; /* ãªã¼ã¹ã®æå¹æéï¼msï¼ */
|
---|
176 | SYSTIM renew; /* RENEWï¼T1ï¼ã¾ã§ã®æéï¼msï¼ */
|
---|
177 | SYSTIM rebind; /* REBINDï¼T2ï¼ã¾ã§ã®æéï¼msï¼ */
|
---|
178 | SYSTIM timers[NUM_DHCP4C_TIMERS];
|
---|
179 | /* ã¿ã¤ãã¼é
|
---|
180 | å */
|
---|
181 | RELTIM interval; /* éä¿¡éé */
|
---|
182 | ER_UINT error; /* ã¨ã©ã¼ã»ãã¼ã¿é· */
|
---|
183 | ID tskid; /* ã¿ã¹ã¯ID */
|
---|
184 | ID cepid; /* CEP ID */
|
---|
185 | uint32_t xid; /* ãã©ã³ã¶ã¯ã·ã§ã³ ID */
|
---|
186 | uint16_t flags; /* å種ãã©ã° */
|
---|
187 | uint16_t max_prefer; /* åä¿¡ã¡ãã»ã¼ã¸ã®æ大æ¨å¥¨åº¦ */
|
---|
188 | uint16_t secs; /* seconds since boot began */
|
---|
189 | uint8_t fsm; /* ç¾å¨ã®ç¶æ
|
---|
190 | */
|
---|
191 | uint8_t req;
|
---|
192 | uint8_t sig;
|
---|
193 | int timer;
|
---|
194 | } T_DHCP4_CLI_CONTEXT;
|
---|
195 |
|
---|
196 | /* fsmï¼ç¶æ
|
---|
197 | é·ç§»ï¼ã®å®ç¾© */
|
---|
198 |
|
---|
199 | #define DHCP4_FSM_INIT 1
|
---|
200 | #define DHCP4_FSM_SELECT 2
|
---|
201 | #define DHCP4_FSM_REQUEST 3
|
---|
202 | #define DHCP4_FSM_BOUND 4
|
---|
203 | #define DHCP4_FSM_RENEW 5
|
---|
204 | #define DHCP4_FSM_REBIND 6
|
---|
205 | #define DHCP4_FSM_INIT_REBOOT 7
|
---|
206 | #define DHCP4_FSM_REBOOT 8
|
---|
207 | #define DHCP4_FSM_REL_INFO 11 /* DHCPv4 ã® RFC2131 ã«ã¯ç¡ãã*/
|
---|
208 | #define DHCP4_FSM_SLEEP 12 /* DHCPv4 ã® RFC2131 ã«ã¯ç¡ãã*/
|
---|
209 |
|
---|
210 | /* flag ã®å®ç¾© */
|
---|
211 |
|
---|
212 | #define DHCP4C_FLAG_TMOUT_SND_DISC (DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_SND_DISC)
|
---|
213 | #define DHCP4C_FLAG_TMOUT_SND_REQ (DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_SND_REQ)
|
---|
214 | #define DHCP4C_FLAG_TMOUT_SND_REL (DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_SND_REL)
|
---|
215 | #define DHCP4C_FLAG_TMOUT_RCV_OFFER (DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_RCV_OFFER)
|
---|
216 | #define DHCP4C_FLAG_TMOUT_RCV_ACK (DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_RCV_ACK)
|
---|
217 | #define DHCP4C_FLAG_TMOUT_EXPIRE (DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_EXPIRE)
|
---|
218 | #define DHCP4C_FLAG_TMOUT_RENEW (DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_RENEW)
|
---|
219 | #define DHCP4C_FLAG_TMOUT_REBIND (DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_REBIND)
|
---|
220 | #define DHCP4C_FLAG_TMOUT_TIMER UINT_C(0x0010)
|
---|
221 | #define DHCP4C_FLAG_TMOUT_TIMER_MASK UINT_C(0x000f)
|
---|
222 | #define DHCP4C_FLAG_TMOUT_MASK UINT_C(0x001f)
|
---|
223 |
|
---|
224 | #define DHCP4C_FLAG_RCV_MSG UINT_C(0x0200)
|
---|
225 | #define DHCP4C_FLAG_RENEW UINT_C(0x0400)
|
---|
226 |
|
---|
227 | /*
|
---|
228 | * é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã
|
---|
229 | */
|
---|
230 |
|
---|
231 | /* ã¿ã¤ã ã¢ã¦ãã®è¨ç® */
|
---|
232 |
|
---|
233 | #define DHCP4C_TMOC(t) (((t)-1000)+dhcp_rand()%2000)
|
---|
234 |
|
---|
235 | /* æéæ¯è¼ */
|
---|
236 |
|
---|
237 | #define TIMEC_GT(a,b) ((int32_t)((a)-(b))>0)
|
---|
238 | #define TIMEC_GE(a,b) ((int32_t)((a)-(b))>=0)
|
---|
239 |
|
---|
240 | /* æéå®æ°ã®å¤æ */
|
---|
241 |
|
---|
242 | #define SYSTIM2TIMER(t) (((t)<SYSTIM_HZ/DHCP4C_TIMER_HZ)?(DHCP4C_TIMER_HZ):((t)*DHCP4C_TIMER_HZ)/SYSTIM_HZ)
|
---|
243 | #define SYSTIM2SEC(t) (((t)<SYSTIM_HZ)?1:((t)/SYSTIM_HZ))
|
---|
244 | #define SEC2TIMER(t) ((t)*DHCP4C_TIMER_HZ)
|
---|
245 | #define SEC2SYSTIM(t) ((t)*SYSTIM_HZ)
|
---|
246 |
|
---|
247 | #endif /* of #ifndef DHCP4_CLI_VAR_H */
|
---|