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 | * 上記著作権者は,以下の (1)~(4) の条件か,Free Software Foundation
|
---|
98 | * によって公表されている GNU General Public License の Version 2 に記
|
---|
99 | * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
|
---|
100 | * を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下,
|
---|
101 | * 利用と呼ぶ)することを無償で許諾する.
|
---|
102 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
103 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
104 | * スコード中に含まれていること.
|
---|
105 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
106 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
107 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
108 | * の無保証規定を掲載すること.
|
---|
109 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
110 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
111 | * と.
|
---|
112 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
113 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
114 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
115 | * 報告すること.
|
---|
116 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
117 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
118 | *
|
---|
119 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
120 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
|
---|
121 | * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
|
---|
122 | * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
|
---|
123 | *
|
---|
124 | * @(#) $Id: dhcp4_cli.h 315 2017-07-23 05:29:40Z coas-nagasima $
|
---|
125 | */
|
---|
126 |
|
---|
127 | #ifndef DHCP4_CLI_H
|
---|
128 | #define DHCP4_CLI_H
|
---|
129 |
|
---|
130 | #include <netapp/dhcp4.h>
|
---|
131 |
|
---|
132 | /*
|
---|
133 | * DHCP クライアントのスタックサイズ
|
---|
134 | */
|
---|
135 |
|
---|
136 | #define DHCP4_CLI_STACK_SIZE 1024 /* DHCP クライアントタスクのスタックサイズ */
|
---|
137 |
|
---|
138 | /*
|
---|
139 | * DHCP クライアントの優先度
|
---|
140 | */
|
---|
141 |
|
---|
142 | #define DHCP4_CLI_MAIN_PRIORITY 5 /* DHCP クライアントタスクの優先度 */
|
---|
143 |
|
---|
144 | /* 推奨度の定義 */
|
---|
145 | #define DHCP4_CLI_CFG_PREFER_ADDR 100 /* アドレスの推奨度 */
|
---|
146 |
|
---|
147 | /* DHCP クライアントメッセージの受信リストサイズ(2以上指定すること) */
|
---|
148 | #define NUM_DHCP4_MSG_LIST 3
|
---|
149 |
|
---|
150 | /*
|
---|
151 | * DHCP クライアントメッセージ構造体数【変更禁止】
|
---|
152 | * +1 は送信用
|
---|
153 | */
|
---|
154 | #define NUM_MPF_DHCP4_CLI_MSG (NUM_DHCP4_MSG_LIST+1)
|
---|
155 |
|
---|
156 | /*
|
---|
157 | * コンパイル時コンフィギュレーション
|
---|
158 | */
|
---|
159 |
|
---|
160 | /* DHCP 必須オプションリスト */
|
---|
161 |
|
---|
162 | #ifndef DHCP4_CLI_CFG_REQUIRED_OLIST
|
---|
163 |
|
---|
164 | #define DHCP4_CLI_CFG_REQUIRED_OLIST { \
|
---|
165 | DHCP4_OPT_SUBNET_MASK, \
|
---|
166 | DHCP4_OPT_ROUTER, \
|
---|
167 | }
|
---|
168 |
|
---|
169 | #endif /* of #ifndef DHCP4_CLI_CFG_REQUIRED_OLIST */
|
---|
170 |
|
---|
171 | /* DHCP 要求オプションリスト */
|
---|
172 |
|
---|
173 | #ifndef DHCP4_CLI_CFG_REQUEST_OLIST
|
---|
174 |
|
---|
175 | #if defined(USE_RESOLVER)
|
---|
176 |
|
---|
177 | #define DHCP4_CLI_CFG_REQUEST_OLIST { \
|
---|
178 | DHCP4_OPT_DNS_SERVER, \
|
---|
179 | DHCP4_OPT_DOMAIN_NAME, \
|
---|
180 | }
|
---|
181 |
|
---|
182 | #endif /* of #if defined(USE_RESOLVER) */
|
---|
183 |
|
---|
184 | #endif /* of #ifndef DHCP4_CLI_CFG_REQUEST_OLIST */
|
---|
185 |
|
---|
186 | /*
|
---|
187 | * タイムアウト値
|
---|
188 | */
|
---|
189 |
|
---|
190 | /* 受信タイムアウト */
|
---|
191 | #define TMO_DHCP4C_OFFER ULONG_C(120*1000) /* OFFER メッセージ */
|
---|
192 | #define TMO_DHCP4C_ACK ULONG_C(60*1000) /* ACK/NAK メッセージ */
|
---|
193 |
|
---|
194 | /* リース時間の既定値 */
|
---|
195 | #define TMO_DHCP4C_DEF_LEASE ULONG_C(12*60*60*1000) /* 標準時間 */
|
---|
196 | #define TMO_DHCP4C_MIN_LEASE ULONG_C(60*1000) /* 最小時間 */
|
---|
197 |
|
---|
198 | /* メッセージの送信周期 */
|
---|
199 | #define TMO_DHCP4C_INIT_INTVL ULONG_C(3*1000) /* 初期値 */
|
---|
200 | #define TMO_DHCP4C_MAX_BACKOFF ULONG_C(15*1000) /* 制限値 */
|
---|
201 |
|
---|
202 | /* DHCP サーバへの UDP 送信タイムアウト */
|
---|
203 | #define TMO_DHCP4C_UDP_SND ULONG_C(1000)
|
---|
204 |
|
---|
205 | /* メッセージ構造体獲得タイムアウト */
|
---|
206 | #define TMO_DHCP4C_MPF_GET ULONG_C(1000)
|
---|
207 |
|
---|
208 | /* ARP 要求を送信してからの待ち時間 */
|
---|
209 | #define TMO_DHCP4C_ARP_WAIT ULONG_C(1000)
|
---|
210 |
|
---|
211 | /* RELEASE メッセージを送信してからの待ち時間 */
|
---|
212 | #define TMO_DHCP4C_SND_REL_WAIT ULONG_C(1000)
|
---|
213 |
|
---|
214 | #ifndef _MACRO_ONLY
|
---|
215 |
|
---|
216 | #ifdef T_IPV4EP_DEFINED
|
---|
217 |
|
---|
218 | /*
|
---|
219 | * DHCP クライアントメッセージ構造体
|
---|
220 | */
|
---|
221 |
|
---|
222 | typedef struct dhcp4_cli_msg {
|
---|
223 | /* 4バイト境界にアラインする。*/
|
---|
224 | T_DHCP4_MSG msg; /* DHCP メッセージ構造体 */
|
---|
225 | struct dhcp4_cli_msg *next; /* リストの次のメッセージ構造体 */
|
---|
226 | T_IPV4EP srv; /* サーバのIPv4アドレス/ポート番号 */
|
---|
227 | uint16_t len; /* msg の有効長 */
|
---|
228 | uint16_t prefer; /* msg の推奨度 */
|
---|
229 | uint8_t type; /* メッセージタイプ */
|
---|
230 | } T_DHCP4_CLI_MSG;
|
---|
231 |
|
---|
232 | #endif /*of #ifdef T_IPV4EP_DEFINED */
|
---|
233 |
|
---|
234 | /*
|
---|
235 | * コールバック関数
|
---|
236 | */
|
---|
237 |
|
---|
238 | extern ER callback_nblk_dhcp4_cli (ID cepid, FN fncd, void *p_parblk);
|
---|
239 |
|
---|
240 | /*
|
---|
241 | * タスク
|
---|
242 | */
|
---|
243 |
|
---|
244 | extern void dhcp4_cli_task(intptr_t exinf);
|
---|
245 |
|
---|
246 | /*
|
---|
247 | * 関数
|
---|
248 | */
|
---|
249 |
|
---|
250 | #ifdef T_IN4_ADDR_DEFINED
|
---|
251 |
|
---|
252 | extern ER dhcp4c_rel_info (void);
|
---|
253 | extern ER dhcp4c_renew_info (void);
|
---|
254 | extern ER dhcp4c_get_info (T_IN4_ADDR *addr, uint32_t *expire, uint32_t *renew,
|
---|
255 | uint32_t *rebind, SYSTIM *bind_start);
|
---|
256 |
|
---|
257 | #endif /* of #ifdef T_IN4_ADDR_DEFINED */
|
---|
258 |
|
---|
259 | #endif /* of #ifndef _MACRO_ONLY */
|
---|
260 |
|
---|
261 | #endif /* of #ifndef DHCP4_CLI_H */
|
---|