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$
|
---|
49 | */
|
---|
50 |
|
---|
51 | #ifndef DHCP6_H
|
---|
52 | #define DHCP6_H
|
---|
53 |
|
---|
54 | /*
|
---|
55 | * DHCPv6 ã«é¢ããå®ç¾©
|
---|
56 | *
|
---|
57 | * RFC3315
|
---|
58 | */
|
---|
59 |
|
---|
60 | /*
|
---|
61 | * DHCPv6 ã¡ãã»ã¼ã¸ã®å®æ°ã®å®ç¾©
|
---|
62 | */
|
---|
63 |
|
---|
64 | #define DHCP6_XID_LEN 3
|
---|
65 | #define DHCP6_OPTION_LEN (512-(1+DHCP6_XID_LEN))
|
---|
66 |
|
---|
67 | /*
|
---|
68 | * DHCPv6 ã¡ãã»ã¼ã¸
|
---|
69 | */
|
---|
70 |
|
---|
71 | typedef struct dhcp6_msg_hdr {
|
---|
72 | uint8_t type; /* message type */
|
---|
73 | uint8_t xid[DHCP6_XID_LEN]; /* transaction ID */
|
---|
74 | } T_DHCP6_MSG_HDR;
|
---|
75 |
|
---|
76 | typedef struct dhcp6_msg {
|
---|
77 | T_DHCP6_MSG_HDR hdr;
|
---|
78 | uint8_t options[DHCP6_OPTION_LEN]; /* options */
|
---|
79 | } T_DHCP6_MSG;
|
---|
80 |
|
---|
81 | /* message type ã®å®ç¾© */
|
---|
82 |
|
---|
83 | #define DHCP6_SOLICIT UINT_C(1)
|
---|
84 | #define DHCP6_ADVERTISE UINT_C(2)
|
---|
85 | #define DHCP6_REQUEST UINT_C(3)
|
---|
86 | #define DHCP6_CONFIRM UINT_C(4)
|
---|
87 | #define DHCP6_RENEW UINT_C(5)
|
---|
88 | #define DHCP6_REBIND UINT_C(6)
|
---|
89 | #define DHCP6_REPLY UINT_C(7)
|
---|
90 | #define DHCP6_RELEASE UINT_C(8)
|
---|
91 | #define DHCP6_DECLINE UINT_C(9)
|
---|
92 | #define DHCP6_RECONFIGURE UINT_C(10)
|
---|
93 | #define DHCP6_INFO_REQ UINT_C(11)
|
---|
94 | #define DHCP6_RELAY_FORW UINT_C(12)
|
---|
95 | #define DHCP6_RELAY_REPL UINT_C(13)
|
---|
96 |
|
---|
97 | /*
|
---|
98 | * DHCPv6 ãªãã·ã§ã³
|
---|
99 | */
|
---|
100 |
|
---|
101 | #define DHCP6_OPT_CLIENTID UINT_C(1)
|
---|
102 | #define DHCP6_OPT_SERVERID UINT_C(2)
|
---|
103 | #define DHCP6_OPT_IA_NA UINT_C(3)
|
---|
104 | #define DHCP6_OPT_IA_TA UINT_C(4)
|
---|
105 | #define DHCP6_OPT_IAADDR UINT_C(5)
|
---|
106 | #define DHCP6_OPT_ORO UINT_C(6)
|
---|
107 | #define DHCP6_OPT_PREFERENCE UINT_C(7)
|
---|
108 | #define DHCP6_OPT_UNICAST UINT_C(12)
|
---|
109 | #define DHCP6_OPT_STATUS_CODE UINT_C(13)
|
---|
110 | #define DHCP6_OPT_RAPID_COMMIT UINT_C(14)
|
---|
111 | #define DHCP6_OPT_NAME_SERVERS UINT_C(23)
|
---|
112 | #define DHCP6_OPT_DOMAIN_SEARCH UINT_C(24)
|
---|
113 | #define DHCP6_OPT_IA_PD UINT_C(25)
|
---|
114 |
|
---|
115 | /* hardware address type ã®å®ç¾© */
|
---|
116 |
|
---|
117 | #define DHCP6_HWA_TYPE_ETHER UINT_C(1)
|
---|
118 | #define DHCP6_HWA_TYPE_IEEE802 UINT_C(6)
|
---|
119 |
|
---|
120 | /* STATUS CODE ã®å®ç¾© */
|
---|
121 |
|
---|
122 | #define DHCP6_STAT_SUCCESS UINT_C(0)
|
---|
123 | #define DHCP6_STAT_UNSPECIFID UINT_C(1)
|
---|
124 | #define DHCP6_STAT_NO_AVAIL UINT_C(2)
|
---|
125 | #define DHCP6_STAT_NO_BINDING UINT_C(3)
|
---|
126 | #define DHCP6_STAT_NO_ONLINK UINT_C(4)
|
---|
127 | #define DHCP6_STAT_USE_MCAST UINT_C(5)
|
---|
128 |
|
---|
129 | /* æéå®æ°[s]ã®å®ç¾© */
|
---|
130 |
|
---|
131 | #define DHCP6_MAX_TIME UINT_C(0xffffffff)
|
---|
132 |
|
---|
133 | /*
|
---|
134 | * ãªãã·ã§ã³ã®ãããé¨ã®å®ç¾©
|
---|
135 | */
|
---|
136 |
|
---|
137 | /* ãªãã·ã§ã³ã®å
|
---|
138 | ±éé¨ */
|
---|
139 |
|
---|
140 | typedef struct dhcp6_option {
|
---|
141 | uint16_t code; /* option code */
|
---|
142 | uint16_t len; /* option length */
|
---|
143 | } T_DHCP6_OPTION;
|
---|
144 |
|
---|
145 | /* ãªãã·ã§ã³ã®å
|
---|
146 | ±éé¨ */
|
---|
147 |
|
---|
148 | /* CLIENTID ãªãã·ã§ã³ */
|
---|
149 |
|
---|
150 | typedef struct dhcp6_opt_clientid {
|
---|
151 | uint16_t code; /* option code */
|
---|
152 | uint16_t len; /* option length */
|
---|
153 | } T_DHCP6_OPT_CLIENTID;
|
---|
154 |
|
---|
155 | /* SERVERID ãªãã·ã§ã³ */
|
---|
156 |
|
---|
157 | typedef struct dhcp6_opt_serverid {
|
---|
158 | uint16_t code; /* option code */
|
---|
159 | uint16_t len; /* option length */
|
---|
160 | } T_DHCP6_OPT_SERVERID;
|
---|
161 |
|
---|
162 | /* IA_NA/IA_PD ãªãã·ã§ã³ */
|
---|
163 |
|
---|
164 | typedef struct dhcp6_opt_ia_na_pd {
|
---|
165 | uint16_t code; /* option code */
|
---|
166 | uint16_t len; /* option length */
|
---|
167 | uint32_t iaid; /* IA ID */
|
---|
168 | uint32_t renew; /* renew timeout (T1) */
|
---|
169 | uint32_t rebind; /* rebind timeout (T2) */
|
---|
170 | } T_DHCP6_OPT_IA_NA_PD;
|
---|
171 |
|
---|
172 | /* IA_TA ãªãã·ã§ã³ */
|
---|
173 |
|
---|
174 | typedef struct dhcp6_opt_ia_ta {
|
---|
175 | uint16_t code; /* option code */
|
---|
176 | uint16_t len; /* option length */
|
---|
177 | uint32_t iaid; /* IA ID */
|
---|
178 | } T_DHCP6_OPT_IA_TA;
|
---|
179 |
|
---|
180 | /* IAADDR ãªãã·ã§ã³ */
|
---|
181 |
|
---|
182 | #ifdef T_IN6_ADDR_DEFINED
|
---|
183 |
|
---|
184 | typedef struct dhcp6_opt_iaaddr {
|
---|
185 | uint16_t code; /* option code */
|
---|
186 | uint16_t len; /* option length */
|
---|
187 | T_IN6_ADDR addr; /* IPv6 address */
|
---|
188 | uint32_t prefer; /* preferred lifetime */
|
---|
189 | uint32_t valid; /* valid lifetime */
|
---|
190 | } T_DHCP6_OPT_IAADDR;
|
---|
191 |
|
---|
192 | #endif /* of #ifdef T_IN6_ADDR_DEFINED */
|
---|
193 |
|
---|
194 | /* ORO ãªãã·ã§ã³ */
|
---|
195 |
|
---|
196 | typedef struct dhcp6_opt_oro {
|
---|
197 | uint16_t code; /* option code */
|
---|
198 | uint16_t len; /* option length */
|
---|
199 | } T_DHCP6_OPT_ORO;
|
---|
200 |
|
---|
201 | /* PREFERENCE ãªãã·ã§ã³ */
|
---|
202 |
|
---|
203 | typedef struct dhcp6_opt_preference {
|
---|
204 | uint16_t code; /* option code */
|
---|
205 | uint16_t len; /* option length */
|
---|
206 | uint8_t prefer; /* preference value */
|
---|
207 | } T_DHCP6_OPT_PREFERENCE;
|
---|
208 |
|
---|
209 | /* UNICAST ãªãã·ã§ã³ */
|
---|
210 |
|
---|
211 | #ifdef T_IN6_ADDR_DEFINED
|
---|
212 |
|
---|
213 | typedef struct dhcp6_opt_unicast {
|
---|
214 | uint16_t code; /* option code */
|
---|
215 | uint16_t len; /* option length */
|
---|
216 | T_IN6_ADDR addr; /* IPv6 address for server*/
|
---|
217 | } T_DHCP6_OPT_UNICAST;
|
---|
218 |
|
---|
219 | #endif /* of #ifdef T_IN6_ADDR_DEFINED */
|
---|
220 |
|
---|
221 | /* STATUS CODE ãªãã·ã§ã³ */
|
---|
222 |
|
---|
223 | typedef struct dhcp6_opt_status_code {
|
---|
224 | uint16_t code; /* option code */
|
---|
225 | uint16_t len; /* option length */
|
---|
226 | uint16_t status; /* status code */
|
---|
227 | } T_DHCP6_OPT_STATUS_CODE;
|
---|
228 |
|
---|
229 | /* NAME SERVERS ãªãã·ã§ã³ */
|
---|
230 |
|
---|
231 | typedef struct dhcp6_opt_name_servers {
|
---|
232 | uint16_t code; /* option code */
|
---|
233 | uint16_t len; /* option length */
|
---|
234 | T_IN6_ADDR addrs[1]; /* IPv6 address */
|
---|
235 | } T_DHCP6_OPT_NAME_SERVERS;
|
---|
236 |
|
---|
237 | /* DOMAIN SEARCH ãªãã·ã§ã³ */
|
---|
238 |
|
---|
239 | typedef struct dhcp6_opt_domain_search {
|
---|
240 | uint16_t code; /* option code */
|
---|
241 | uint16_t len; /* option length */
|
---|
242 | uint8_t name[1]; /* domain search */
|
---|
243 | } T_DHCP6_OPT_DOMAIN_SEARCH;
|
---|
244 |
|
---|
245 | /*
|
---|
246 | * DHCPv6 ã¿ã¤ãã³ã°å®æ°ãRFC3315 5.5 åç
|
---|
247 | §ã
|
---|
248 | * ãã®ä»ã®ã¿ã¤ãã³ã°å®æ°ã¯ dhcp6_cli.h åç
|
---|
249 | §
|
---|
250 | */
|
---|
251 |
|
---|
252 | #ifdef SYSTIM_HZ
|
---|
253 |
|
---|
254 | #define TMO_SOL_MAX_DELAY (1*SYSTIM_HZ) /* 1[s] */
|
---|
255 | #define TMO_SOL_TIMEOUT (1*SYSTIM_HZ) /* 1[s] */
|
---|
256 | #define TMO_SOL_MAX_RT (120*SYSTIM_HZ) /* 120[s] */
|
---|
257 | #define TMO_REQ_TIMEOUT (1*SYSTIM_HZ) /* 1[s] */
|
---|
258 | #define TMO_REQ_MAX_RT (30*SYSTIM_HZ) /* 30[s] */
|
---|
259 | #define TMO_REQ_MAX_RC 10 /* åéä¿¡åæ° */
|
---|
260 | #define TMO_CNF_MAX_DELAY (1*SYSTIM_HZ) /* 1[s] */
|
---|
261 | #define TMO_CNF_TIMEOUT (1*SYSTIM_HZ) /* 1[s] */
|
---|
262 | #define TMO_CNF_MAX_RT (4*SYSTIM_HZ) /* 4[s] */
|
---|
263 | #define TMO_CNF_MAX_RD (10*SYSTIM_HZ) /* 10[s] */
|
---|
264 | #define TMO_REN_TIMEOUT (10*SYSTIM_HZ) /* 10[s] */
|
---|
265 | #define TMO_REN_MAX_RT (600*SYSTIM_HZ) /* 600[s] */
|
---|
266 | #define TMO_REB_TIMEOUT (10*SYSTIM_HZ) /* 10[s] */
|
---|
267 | #define TMO_REB_MAX_RT (600*SYSTIM_HZ) /* 600[s] */
|
---|
268 | #define TMO_INF_MAX_DELAY (1*SYSTIM_HZ) /* 1[s] */
|
---|
269 | #define TMO_INF_TIMEOUT (1*SYSTIM_HZ) /* 1[s] */
|
---|
270 | #define TMO_INF_MAX_RT (120*SYSTIM_HZ) /* 120[s] */
|
---|
271 | #define TMO_REL_TIMEOUT (1*SYSTIM_HZ) /* 1[s] */
|
---|
272 | #define TMO_REL_MAX_RC 5 /* åéä¿¡åæ° */
|
---|
273 | #define TMO_DEC_TIMEOUT (1*SYSTIM_HZ) /* 1[s] */
|
---|
274 | #define TMO_DEC_MAX_RC 5 /* åéä¿¡åæ° */
|
---|
275 | #define TMO_REC_TIMEOUT (2*SYSTIM_HZ) /* 2[s] */
|
---|
276 | #define TMO_REC_MAX_RC 8 /* åéä¿¡åæ° */
|
---|
277 |
|
---|
278 | #endif /* of #ifdef SYSTIM_HZ */
|
---|
279 |
|
---|
280 | /*
|
---|
281 | * DUID -- DHCP Unique ID
|
---|
282 | */
|
---|
283 |
|
---|
284 | /* DUID_LLT æ§é ä½ */
|
---|
285 |
|
---|
286 | typedef struct dhcp6_duid_llt_hdr {
|
---|
287 | uint16_t code; /* DUID code */
|
---|
288 | uint16_t type; /* hardware type */
|
---|
289 | uint32_t time; /* time */
|
---|
290 | } T_DHCP6_DUID_LLT_HDR;
|
---|
291 |
|
---|
292 | /* DUID_LL æ§é ä½ */
|
---|
293 |
|
---|
294 | typedef struct dhcp6_duid_ll_hdr {
|
---|
295 | uint16_t code; /* DUID code */
|
---|
296 | uint16_t type; /* hardware type */
|
---|
297 | } T_DHCP6_DUID_LL_HDR;
|
---|
298 |
|
---|
299 | /* DUID ã¿ã¤ããRFC3315 9åç
|
---|
300 | §ã*/
|
---|
301 |
|
---|
302 | #define DUID_LLT 1
|
---|
303 | #define DUID_EN 2
|
---|
304 | #define DUID_LL 3
|
---|
305 |
|
---|
306 | /*
|
---|
307 | * DUID æéã®èª¿æ´
|
---|
308 | * DUID æéã®éå§ã¯ 2001/1/1
|
---|
309 | */
|
---|
310 |
|
---|
311 | #define DUID_TIME_EPOCH 0
|
---|
312 |
|
---|
313 | /* ãªã¬ã¼è»¢éã®æ大ãããæ° */
|
---|
314 |
|
---|
315 | #define HOP_COUNT_LIMIT 32
|
---|
316 |
|
---|
317 | /*
|
---|
318 | * IPv6 ã¢ãã¬ã¹
|
---|
319 | */
|
---|
320 |
|
---|
321 | #define IPV6_ADDR_ALL_DHCP_RELAY_SERVERS_INIT \
|
---|
322 | {{{ UINT_C(0xff), UINT_C(0x02), UINT_C(0x00), UINT_C(0x00), \
|
---|
323 | UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
|
---|
324 | UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
|
---|
325 | UINT_C(0x00), UINT_C(0x01), UINT_C(0x00), UINT_C(0x02) }}}
|
---|
326 |
|
---|
327 | #define IPV6_ADDR_ALL_DHCP_SERVERS_INIT \
|
---|
328 | {{{ UINT_C(0xff), UINT_C(0x05), UINT_C(0x00), UINT_C(0x00), \
|
---|
329 | UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
|
---|
330 | UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
|
---|
331 | UINT_C(0x00), UINT_C(0x01), UINT_C(0x00), UINT_C(0x03) }}}
|
---|
332 |
|
---|
333 | /*
|
---|
334 | * UDP ãã¼ãçªå·
|
---|
335 | */
|
---|
336 |
|
---|
337 | #ifndef DHCP6_SRV_CFG_PORTNO
|
---|
338 | #define DHCP6_SRV_CFG_PORTNO 547 /* server */
|
---|
339 | #endif
|
---|
340 |
|
---|
341 | #ifndef DHCP6_CLI_CFG_PORTNO
|
---|
342 | #define DHCP6_CLI_CFG_PORTNO 546 /* client */
|
---|
343 | #endif
|
---|
344 |
|
---|
345 | #endif /* of #ifndef DHCP6_H */
|
---|