1 /* $KAME: dhcp6.h,v 1.56 2005/03/20 06:46:09 jinmei Exp $ */
3 * Copyright (C) 1998 and 1999 WIDE Project.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the project nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #ifndef __DHCP6_H_DEFINED
32 #define __DHCP6_H_DEFINED
36 typedef uint8_t u_int8_t
;
37 #ifndef U_INT16_T_DEFINED
38 #define U_INT16_T_DEFINED
39 typedef uint16_t u_int16_t
;
41 #ifndef U_INT32_T_DEFINED
42 #define U_INT32_T_DEFINED
43 typedef uint32_t u_int32_t
;
45 typedef uint64_t u_int64_t
;
47 #define CMSG_SPACE(l) \
48 ((unsigned int)_CMSG_HDR_ALIGN(sizeof (struct cmsghdr) + (l)))
52 ((unsigned int)_CMSG_DATA_ALIGN(sizeof (struct cmsghdr)) + (l))
57 #define DH6ERR_FAILURE 16
58 #define DH6ERR_AUTHFAIL 17
59 #define DH6ERR_POORLYFORMED 18
60 #define DH6ERR_UNAVAIL 19
61 #define DH6ERR_OPTUNAVAIL 20
65 #define DH6_ADVERTISE 2
73 #define DH6_RECONFIGURE 10
74 #define DH6_INFORM_REQ 11
75 #define DH6_RELAY_FORW 12
76 #define DH6_RELAY_REPLY 13
78 /* Predefined addresses */
79 #define DH6ADDR_ALLAGENT "ff02::1:2"
80 #define DH6ADDR_ALLSERVER "ff05::1:3"
81 #define DH6PORT_DOWNSTREAM "546"
82 #define DH6PORT_UPSTREAM "547"
84 /* Protocol constants */
86 /* timer parameters (msec, unless explicitly commented) */
87 #define SOL_MAX_DELAY 1000
88 #define SOL_TIMEOUT 1000
89 #define SOL_MAX_RT 120000
90 #define INF_TIMEOUT 1000
91 #define INF_MAX_RT 120000
92 #define REQ_TIMEOUT 1000
93 #define REQ_MAX_RT 30000
94 #define REQ_MAX_RC 10 /* Max Request retry attempts */
95 #define REN_TIMEOUT 10000 /* 10secs */
96 #define REN_MAX_RT 600000 /* 600secs */
97 #define REB_TIMEOUT 10000 /* 10secs */
98 #define REB_MAX_RT 600000 /* 600secs */
99 #define REL_TIMEOUT 1000 /* 1 sec */
102 #define DHCP6_DURATION_INFINITE 0xffffffff
103 #define DHCP6_DURATION_MIN 30
105 #define DHCP6_RELAY_MULTICAST_HOPS 32
106 #define DHCP6_RELAY_HOP_COUNT_LIMIT 32
108 #define DHCP6_IRT_DEFAULT 86400 /* 1 day */
109 #define DHCP6_IRT_MINIMUM 600
111 /* DUID: DHCP unique Identifier */
113 size_t duid_len
; /* length */
114 char *duid_id
; /* variable length ID value (must be opaque) */
117 struct dhcp6_vbuf
{ /* generic variable length buffer */
122 /* option information */
123 struct dhcp6_ia
{ /* identity association */
129 struct dhcp6_prefix
{ /* IA_PA */
132 struct in6_addr addr
;
136 struct dhcp6_statefuladdr
{ /* IA_NA */
139 struct in6_addr addr
;
142 /* Internal data structure */
143 typedef enum { DHCP6_LISTVAL_NUM
= 1,
144 DHCP6_LISTVAL_STCODE
, DHCP6_LISTVAL_ADDR6
,
145 DHCP6_LISTVAL_IAPD
, DHCP6_LISTVAL_PREFIX6
,
146 DHCP6_LISTVAL_IANA
, DHCP6_LISTVAL_STATEFULADDR6
,
148 } dhcp6_listval_type_t
;
149 TAILQ_HEAD(dhcp6_list
, dhcp6_listval
);
150 struct dhcp6_listval
{
151 TAILQ_ENTRY(dhcp6_listval
) link
;
153 dhcp6_listval_type_t type
;
158 struct in6_addr uv_addr6
;
159 struct dhcp6_prefix uv_prefix6
;
160 struct dhcp6_statefuladdr uv_statefuladdr6
;
161 struct dhcp6_ia uv_ia
;
162 struct dhcp6_vbuf uv_vbuf
;
165 struct dhcp6_list sublist
;
167 #define val_num uv.uv_num
168 #define val_num16 uv.uv_num16
169 #define val_addr6 uv.uv_addr6
170 #define val_ia uv.uv_ia
171 #define val_prefix6 uv.uv_prefix6
172 #define val_statefuladdr6 uv.uv_statefuladdr6
173 #define val_vbuf uv.uv_vbuf
175 struct dhcp6_optinfo
{
176 struct duid clientID
; /* DUID */
177 struct duid serverID
; /* DUID */
179 int rapidcommit
; /* bool */
180 int pref
; /* server preference */
181 int32_t elapsed_time
; /* elapsed time (from client to server only) */
182 int64_t refreshtime
; /* info refresh time for stateless options */
184 struct dhcp6_list iapd_list
; /* list of IA_PD */
185 struct dhcp6_list iana_list
; /* list of IA_NA */
186 struct dhcp6_list reqopt_list
; /* options in option request */
187 struct dhcp6_list stcode_list
; /* status code */
188 struct dhcp6_list sip_list
; /* SIP server list */
189 struct dhcp6_list sipname_list
; /* SIP domain list */
190 struct dhcp6_list dns_list
; /* DNS server list */
191 struct dhcp6_list dnsname_list
; /* Domain Search list */
192 struct dhcp6_list ntp_list
; /* NTP server list */
193 struct dhcp6_list prefix_list
; /* prefix list */
194 struct dhcp6_list nis_list
; /* NIS server list */
195 struct dhcp6_list nisname_list
; /* NIS domain list */
196 struct dhcp6_list nisp_list
; /* NIS+ server list */
197 struct dhcp6_list nispname_list
; /* NIS+ domain list */
198 struct dhcp6_list bcmcs_list
; /* BCMC server list */
199 struct dhcp6_list bcmcsname_list
; /* BCMC domain list */
201 struct dhcp6_vbuf relay_msg
; /* relay message */
202 #define relaymsg_len relay_msg.dv_len
203 #define relaymsg_msg relay_msg.dv_buf
205 struct dhcp6_vbuf ifidopt
; /* Interface-id */
206 #define ifidopt_len ifidopt.dv_len
207 #define ifidopt_id ifidopt.dv_buf
210 #define DHCP6OPT_AUTHFLAG_NOINFO 0x1
214 /* the followings are effective only when NOINFO is unset */
219 struct dhcp6_vbuf realm
;
220 int offset
; /* offset to the HMAC field */
224 int offset
; /* offset to the HMAC field */
225 char val
[16]; /* key value */
228 #define delayedauth_keyid authinfo.aiu_delayed.keyid
229 #define delayedauth_realmlen authinfo.aiu_delayed.realm.dv_len
230 #define delayedauth_realmval authinfo.aiu_delayed.realm.dv_buf
231 #define delayedauth_offset authinfo.aiu_delayed.offset
232 #define reconfigauth_type authinfo.aiu_reconfig.type
233 #define reconfigauth_offset authinfo.aiu_reconfig.offset
234 #define reconfigauth_val authinfo.aiu_reconfig.val
237 /* DHCP6 base packet format */
244 } __attribute__ ((__packed__
));
245 #define dh6_msgtype dh6_msgtypexid.m
246 #define dh6_xid dh6_msgtypexid.x
247 #define DH6_XIDMASK 0x00ffffff
249 /* DHCPv6 relay messages */
251 u_int8_t dh6relay_msgtype
;
252 u_int8_t dh6relay_hcnt
;
253 struct in6_addr dh6relay_linkaddr
; /* XXX: badly aligned */
254 struct in6_addr dh6relay_peeraddr
; /* ditto */
256 } __attribute__ ((__packed__
));
259 #define DH6OPT_CLIENTID 1
260 #define DH6OPT_SERVERID 2
261 #define DH6OPT_IA_NA 3
262 #define DH6OPT_IA_TA 4
263 #define DH6OPT_IAADDR 5
265 #define DH6OPT_PREFERENCE 7
266 # define DH6OPT_PREF_UNDEF -1
267 # define DH6OPT_PREF_MAX 255
268 #define DH6OPT_ELAPSED_TIME 8
269 # define DH6OPT_ELAPSED_TIME_UNDEF -1
270 #define DH6OPT_RELAY_MSG 9
271 /* #define DH6OPT_SERVER_MSG 10: deprecated */
272 #define DH6OPT_AUTH 11
273 # define DH6OPT_AUTH_PROTO_DELAYED 2
274 # define DH6OPT_AUTH_RRECONFIGURE 3
275 # define DH6OPT_AUTH_ALG_HMACMD5 1
276 #define DH6OPT_UNICAST 12
277 #define DH6OPT_STATUS_CODE 13
278 # define DH6OPT_STCODE_SUCCESS 0
279 # define DH6OPT_STCODE_UNSPECFAIL 1
280 # define DH6OPT_STCODE_NOADDRSAVAIL 2
281 # define DH6OPT_STCODE_NOBINDING 3
282 # define DH6OPT_STCODE_NOTONLINK 4
283 # define DH6OPT_STCODE_USEMULTICAST 5
284 # define DH6OPT_STCODE_NOPREFIXAVAIL 6
286 #define DH6OPT_RAPID_COMMIT 14
287 #define DH6OPT_USER_CLASS 15
288 #define DH6OPT_VENDOR_CLASS 16
289 #define DH6OPT_VENDOR_OPTS 17
290 #define DH6OPT_INTERFACE_ID 18
291 #define DH6OPT_RECONF_MSG 19
293 #define DH6OPT_SIP_SERVER_D 21
294 #define DH6OPT_SIP_SERVER_A 22
295 #define DH6OPT_DNS 23
296 #define DH6OPT_DNSNAME 24
297 #define DH6OPT_IA_PD 25
298 #define DH6OPT_IA_PD_PREFIX 26
299 #define DH6OPT_NIS_SERVERS 27
300 #define DH6OPT_NISP_SERVERS 28
301 #define DH6OPT_NIS_DOMAIN_NAME 29
302 #define DH6OPT_NISP_DOMAIN_NAME 30
303 #define DH6OPT_NTP 31
304 #define DH6OPT_REFRESHTIME 32
305 #define DH6OPT_REFRESHTIME_UNDEF -1
306 #define DH6OPT_BCMCS_SERVER_D 33
307 #define DH6OPT_BCMCS_SERVER_A 34
308 #define DH6OPT_GEOCONF_CIVIC 36
309 #define DH6OPT_REMOTE_ID 37
310 #define DH6OPT_SUBSCRIBER_ID 38
311 #define DH6OPT_CLIENT_FQDN 39
313 /* The followings are KAME specific. */
316 u_int16_t dh6opt_type
;
317 u_int16_t dh6opt_len
;
318 /* type-dependent data follows */
319 } __attribute__ ((__packed__
));
321 /* DUID type 1 (DUID-LLT) */
322 struct dhcp6opt_duid_type1
{
323 u_int16_t dh6_duid1_type
;
324 u_int16_t dh6_duid1_hwtype
;
325 u_int32_t dh6_duid1_time
;
326 /* link-layer address follows */
327 } __attribute__ ((__packed__
));
329 /* DUID type 2 (DUID-EN) */
330 struct dhcp6opt_duid_type2
{
331 u_int16_t dh6_duid2_type
;
332 u_int32_t dh6_duid2_enterprise_number
;
333 /* identifier follows */
334 } __attribute__ ((__packed__
));
336 /* DUID type 3 (DUID-LL) */
337 struct dhcp6opt_duid_type3
{
338 u_int16_t dh6_duid3_type
;
339 u_int16_t dh6_duid3_hwtype
;
340 /* link-layer address follows */
341 } __attribute__ ((__packed__
));
343 union dhcp6opt_duid_type
{
344 struct dhcp6opt_duid_type1 d1
;
345 struct dhcp6opt_duid_type2 d2
;
346 struct dhcp6opt_duid_type3 d3
;
350 struct dhcp6opt_stcode
{
351 u_int16_t dh6_stcode_type
;
352 u_int16_t dh6_stcode_len
;
353 u_int16_t dh6_stcode_code
;
354 } __attribute__ ((__packed__
));
357 * General format of Identity Association.
358 * This format applies to Prefix Delegation (IA_PD) and Non-temporary Addresses
362 u_int16_t dh6_ia_type
;
363 u_int16_t dh6_ia_len
;
364 u_int32_t dh6_ia_iaid
;
367 /* sub options follow */
368 } __attribute__ ((__packed__
));
371 struct dhcp6opt_ia_addr
{
372 u_int16_t dh6_ia_addr_type
;
373 u_int16_t dh6_ia_addr_len
;
374 struct in6_addr dh6_ia_addr_addr
;
375 u_int32_t dh6_ia_addr_preferred_time
;
376 u_int32_t dh6_ia_addr_valid_time
;
377 } __attribute__ ((__packed__
));
380 struct dhcp6opt_ia_pd_prefix
{
381 u_int16_t dh6_iapd_prefix_type
;
382 u_int16_t dh6_iapd_prefix_len
;
383 u_int32_t dh6_iapd_prefix_preferred_time
;
384 u_int32_t dh6_iapd_prefix_valid_time
;
385 u_int8_t dh6_iapd_prefix_prefix_len
;
386 struct in6_addr dh6_iapd_prefix_prefix_addr
;
387 } __attribute__ ((__packed__
));
390 struct dhcp6opt_auth
{
391 u_int16_t dh6_auth_type
;
392 u_int16_t dh6_auth_len
;
393 u_int8_t dh6_auth_proto
;
394 u_int8_t dh6_auth_alg
;
395 u_int8_t dh6_auth_rdm
;
396 u_int8_t dh6_auth_rdinfo
[8];
397 /* authentication information follows */
398 } __attribute__ ((__packed__
));
400 enum { DHCP6_AUTHPROTO_UNDEF
= -1, DHCP6_AUTHPROTO_DELAYED
= 2,
401 DHCP6_AUTHPROTO_RECONFIG
= 3 };
402 enum { DHCP6_AUTHALG_UNDEF
= -1, DHCP6_AUTHALG_HMACMD5
= 1 };
403 enum { DHCP6_AUTHRDM_UNDEF
= -1, DHCP6_AUTHRDM_MONOCOUNTER
= 0 };
405 #endif /*__DHCP6_H_DEFINED*/