source: azure_iot_hub/trunk/asp3_dcre/tinet/netapp/dhcp4.h@ 388

Last change on this file since 388 was 388, checked in by coas-nagasima, 5 years ago

Azure IoT Hub Device C SDK を使ったサンプルの追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr
File size: 10.5 KB
Line 
1/*
2 * TINET (TCP/IP Protocol Stack)
3 *
4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
5 * Tomakomai National College of Technology, JAPAN
6 *
7 * 上記著作権者
8は,以下の (1)~(4) の条件か,Free Software Foundation
9 * によってå…
10¬è¡¨ã•ã‚Œã¦ã„ã‚‹ GNU General Public License の Version 2 に記
11 * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
12 * を改変したものを含む.以下同じ)を使用・複製・改変・再é…
13å¸ƒï¼ˆä»¥ä¸‹ï¼Œ
14 * 利用と呼ぶ)することを無償で許諾する.
15 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
16 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
17 * スコード中に含まれていること.
18 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
19 * 用できる形で再é…
20å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œå†é…
21å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨
22 * 者
23マニュアルなど)に,上記の著作権表示,この利用条件および下記
24 * の無保証規定を掲載すること.
25 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
26 * 用できない形で再é…
27å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œæ¬¡ã®ã„ずれかの条件を満たすこ
28 * と.
29 * (a) 再é…
30å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨è€…
31マニュアルなど)に,上記の著
32 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
33 * (b) 再é…
34å¸ƒã®å½¢æ…
35‹ã‚’,別に定める方法によって,TOPPERSプロジェクトに
36 * 報告すること.
37 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
38 * 害からも,上記著作権者
39およびTOPPERSプロジェクトをå…
40è²¬ã™ã‚‹ã“と.
41 *
42 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者
43お
44 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
45 * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
46 * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
47 *
48 * @(#) $Id: dhcp4.h 388 2019-05-22 11:25:18Z coas-nagasima $
49 */
50
51#ifndef DHCP4_H
52#define DHCP4_H
53
54/*
55 * DHCP に関する定義
56 *
57 * RFC2131
58 */
59
60/*
61 * DHCP メッセージの定数の定義
62 */
63
64#define DHCP4_CHADDR_LEN 16
65#define DHCP4_SNAME_LEN 64
66#define DHCP4_FILE_LEN 128
67#define DHCP4_DFLT_OPT_LEN 312
68#define DHCP4_UDP_MSG_LENGTH (sizeof(uint32_t)*7+DHCP4_CHADDR_LEN \
69 +DHCP4_SNAME_LEN+DHCP4_FILE_LEN+DHCP4_DFLT_OPT_LEN)
70#define DHCP4_SNAME_OFFSET (sizeof(uint32_t)*7+DHCP4_CHADDR_LEN)
71#define DHCP4_FILE_OFFSET (DHCP4_SNAME_OFFSET+DHCP4_SNAME_LEN)
72#define DHCP4_OPTION_OFFSET (DHCP4_FILE_OFFSET+DHCP4_FILE_LEN)
73#define DHCP4_TIME_INFINITY UINT_C(0xffffffff)
74
75/*
76 * DHCP メッセージ
77 */
78
79typedef struct dhcp4_msg {
80 uint8_t op; /* packet type */
81 uint8_t htype; /* hardware address type */
82 uint8_t hlen; /* hardware address length */
83 uint8_t hops; /* gateway hops */
84 uint32_t xid; /* transaction ID */
85 uint16_t secs; /* seconds since boot began */
86 uint16_t flags;
87 uint32_t ciaddr; /* client IP address */
88 uint32_t yiaddr; /* your IP address */
89 uint32_t siaddr; /* server IP address */
90 uint32_t giaddr; /* relay agent IP address */
91 uint8_t chaddr [DHCP4_CHADDR_LEN]; /* client hardware address */
92 uint8_t sname [DHCP4_SNAME_LEN]; /* server host name */
93 uint8_t file [DHCP4_FILE_LEN]; /* boot file name */
94 uint8_t options[DHCP4_DFLT_OPT_LEN]; /* optional parameters field */
95 } __attribute__((packed)) T_DHCP4_MSG;
96
97/* packet type の定義 */
98
99#define DHCP4_REQUEST UINT_C(1)
100#define DHCP4_REPLY UINT_C(2)
101
102/* hardware address type の定義 */
103
104#define DHCP4_HWA_TYPE_ETHER UINT_C(1)
105#define DHCP4_HWA_TYPE_IEEE802 UINT_C(6)
106
107/*
108 * DHCP オプション
109 *
110 * RFC1533
111 */
112
113/*
114 * オプションの穴埋め
115 */
116#define DHCP4_OPT_PAD UINT_C(0)
117
118/*
119 * サブネットマスク
120 *
121 * code len subnet mask
122 * +------+-----+-----+-----+-----+-----+
123 * | 1 | 4 | m1 | m2 | m3 | m4 |
124 * +------+-----+-----+-----+-----+-----+
125 */
126#define DHCP4_OPT_SUBNET_MASK UINT_C(1)
127
128/*
129 * ルータ
130 *
131 * code len addres #1 address #2
132 * +------+-----+-----+-----+-----+-----+-----+-----+---
133 * | 3 | n | a1 | a2 | a3 | a4 | a1 | a2 | ...
134 * +------+-----+-----+-----+-----+-----+-----+-----+---
135 */
136#define DHCP4_OPT_ROUTER UINT_C(3)
137
138/*
139 * DNS サーバ
140 *
141 * code len addres #1 address #2
142 * +------+-----+-----+-----+-----+-----+-----+-----+---
143 * | 6 | n | a1 | a2 | a3 | a4 | a1 | a2 | ...
144 * +------+-----+-----+-----+-----+-----+-----+-----+---
145 */
146#define DHCP4_OPT_DNS_SERVER UINT_C(6)
147
148/*
149 * ホスト名
150 *
151 * code len host name
152 * +------+-----+-----+-----+-----+-----+---
153 * | 12 | n | h1 | h2 | h3 | h4 | ...
154 * +------+-----+-----+-----+-----+-----+---
155 */
156#define DHCP4_OPT_HOST_NAME UINT_C(12)
157
158/*
159 * ドメイン名
160 *
161 * code len domain name
162 * +------+-----+-----+-----+-----+-----+---
163 * | 15 | n | d1 | d2 | d3 | d4 | ...
164 * +------+-----+-----+-----+-----+-----+---
165 */
166#define DHCP4_OPT_DOMAIN_NAME UINT_C(15)
167
168/*
169 * ルータ探索
170 *
171 * code len value
172 * +------+-----+-----+
173 * | 31 | 1 | 0/1 |
174 * +------+-----+-----+
175 */
176#define DHCP4_OPT_RTR_DISOVERY UINT_C(31)
177
178/*
179 * 静的経路
180 *
181 * code len destination #1 router #1
182 * +------+-----+-----+-----+-----+-----+-----+-----+---
183 * | 33 | n | d1 | d2 | d3 | d4 | r1 | r2 | ...
184 * +------+-----+-----+-----+-----+-----+-----+-----+---
185 */
186#define DHCP4_OPT_STATIC_ROUTE UINT_C(33)
187
188/*
189 * ベンダー固有情
190å ±
191 *
192 * code len vendor-specific informations
193 * +------+-----+-----+-----+-----+---
194 * | 43 | n | i1 | i2 | i3 | ...
195 * +------+-----+-----+-----+-----+---
196 *
197 */
198#define DHCP4_OPT_VENDOR_INFO UINT_C(43)
199
200/*
201 * NetBIOS over TCP/IP ネームサーバ
202 *
203 * code len addres #1 address #2
204 * +------+-----+-----+-----+-----+-----+-----+-----+---
205 * | 44 | n | a1 | a2 | a3 | a4 | a1 | a2 | ...
206 * +------+-----+-----+-----+-----+-----+-----+-----+---
207 */
208#define DHCP4_OPT_NETBIOS_NS UINT_C(44)
209
210/*
211 * NetBIOS over TCP/IP ノードタイプ
212 *
213 * code len type
214 * +------+-----+-----+
215 * | 46 | 1 | type|
216 * +------+-----+-----+
217 */
218#define DHCP4_OPT_NETBIOS_NODE UINT_C(46)
219
220/*
221 * NetBIOS over TCP/IP スコープ
222 *
223 * code len NetBIOS scope
224 * +------+-----+-----+-----+-----+-----+---
225 * | 44 | n | s1 | s2 | s3 | s4 | ...
226 * +------+-----+-----+-----+-----+-----+---
227 */
228#define DHCP4_OPT_NETBIOS_SCOPE UINT_C(47)
229
230/*
231 * 特定の IPv4 アドレス要求
232 *
233 * code len IPv4 address
234 * +------+-----+-----+-----+-----+-----+
235 * | 50 | 4 | a1 | a2 | a3 | a4 |
236 * +------+-----+-----+-----+-----+-----+
237 */
238#define DHCP4_OPT_REQ_IPV4 UINT_C(50)
239
240/*
241 * リース時間
242 *
243 * code len lease time
244 * +------+-----+-----+-----+-----+-----+
245 * | 51 | 4 | t1 | t2 | t3 | t4 |
246 * +------+-----+-----+-----+-----+-----+
247 */
248#define DHCP4_OPT_LEASE_TIME UINT_C(51)
249
250/*
251 * オプションオーバーロード
252 *
253 * code len value
254 * +------+-----+-----+
255 * | 52 | 1 | 1-3 |
256 * +------+-----+-----+
257 */
258#define DHCP4_OPT_OPT_OVERLOAD UINT_C(52)
259
260/* value の定義 */
261
262#define DHCP4_OPTOL_FILE UINT_C(0x01)
263#define DHCP4_OPTOL_SNAME UINT_C(0x02)
264#define DHCP4_OPTOL_BOTH UINT_C(0x03)
265
266/*
267 * DHCP メッセージタイプ
268 *
269 * code len type
270 * +------+-----+-----+
271 * | 53 | 1 | 1-7 |
272 * +------+-----+-----+
273 */
274#define DHCP4_OPT_MSG_TYPE UINT_C(53)
275
276/* type の定義 */
277
278#define DHCP4_MTYPE_BOOTP UINT_C(0)
279#define DHCP4_MTYPE_DISCOVER UINT_C(1)
280#define DHCP4_MTYPE_OFFER UINT_C(2)
281#define DHCP4_MTYPE_REQUEST UINT_C(3)
282#define DHCP4_MTYPE_DECLINE UINT_C(4)
283#define DHCP4_MTYPE_ACK UINT_C(5)
284#define DHCP4_MTYPE_NAK UINT_C(6)
285#define DHCP4_MTYPE_RELEASE UINT_C(7)
286#define DHCP4_MTYPE_INFOMATION UINT_C(8)
287
288/*
289 * サーバ ID
290 *
291 * code len IPv4 address
292 * +------+-----+-----+-----+-----+-----+
293 * | 54 | 4 | a1 | a2 | a3 | a4 |
294 * +------+-----+-----+-----+-----+-----+
295 */
296#define DHCP4_OPT_SERVER_ID UINT_C(54)
297
298/*
299 * 要求パラメータリスト
300 *
301 * code len option code
302 * +------+-----+-----+-----+-----+---
303 * | 55 | n | c1 | c2 | c3 | ...
304 * +------+-----+-----+-----+-----+---
305 *
306 */
307#define DHCP4_OPT_REQ_PARAM UINT_C(55)
308
309/*
310 * Renewal (T1) 時間
311 *
312 * code len T1 interval
313 * +------+-----+-----+-----+-----+-----+
314 * | 58 | 4 | t1 | t2 | t3 | t4 |
315 * +------+-----+-----+-----+-----+-----+
316 */
317#define DHCP4_OPT_RENEWAL_T1 UINT_C(58)
318
319/*
320 * Rebinding (T2) 時間
321 *
322 * code len T2 interval
323 * +------+-----+-----+-----+-----+-----+
324 * | 59 | 4 | t1 | t2 | t3 | t4 |
325 * +------+-----+-----+-----+-----+-----+
326 */
327#define DHCP4_OPT_REBINDING_T2 UINT_C(59)
328
329/*
330 * ベンダークラス ID(RFC2132)
331 *
332 * code len vendor class ID
333 * +------+-----+-----+-----+-----+---
334 * | 60 | n | i1 | i2 | i3 | ...
335 * +------+-----+-----+-----+-----+---
336 *
337 */
338#define DHCP4_OPT_VCLASS_ID UINT_C(60)
339
340/*
341 * クライアント ID
342 *
343 * code len type client ID
344 * +------+-----+-----+-----+-----+---
345 * | 61 | n | type| i1 | i2 | ...
346 * +------+-----+-----+-----+-----+---
347 *
348 * type : ハードウェアアドレスタイプ
349 * i1, i2, ...: 通常 MAC アドレス
350 */
351#define DHCP4_OPT_CLIENT_ID UINT_C(61)
352
353/*
354 * クラスなし静的経路(RFC3442)
355 *
356 * code len destination #1 router #1
357 * +------+-----+-----+------+-----+-----+-----+-----+---
358 * | 121 | n | d1 | ... | dN | r1 | r2 | r3 | ...
359 * +------+-----+-----+------+-----+-----+-----+-----+---
360 */
361#define DHCP4_OPT_CLASSLESS_RTE UINT_C(121)
362
363/*
364 * オプションの終了
365 */
366#define DHCP4_OPT_END UINT_C(255)
367
368/*
369 * magic 番号(RFC1048)
370 */
371
372#define DHCP4_RFC1048_MAGIC { UINT_C(99), UINT_C(130), UINT_C(83), UINT_C(99), }
373#define DHCP4_MAGIC_LEN 4
374
375/*
376 * UDP ポート番号
377 */
378
379#ifndef DHCP4_SRV_CFG_PORTNO
380#define DHCP4_SRV_CFG_PORTNO 67 /* server */
381#endif
382
383#ifndef DHCP4_CLI_CFG_PORTNO
384#define DHCP4_CLI_CFG_PORTNO 68 /* client */
385#endif
386
387#endif /* of #ifndef DHCP4_H */
Note: See TracBrowser for help on using the repository browser.