1 /* $KAME: config.h,v 1.39 2005/04/01 12:43:36 jinmei Exp $ */
4 * Copyright (C) 2002 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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 project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 /* definitions of tail-queue types */
33 TAILQ_HEAD(ia_conflist
, ia_conf
);
34 TAILQ_HEAD(pifc_list
, prefix_ifconf
);
36 struct dhcp6_poolspec
{
48 struct pool_conf
*next
;
56 /* per-interface information */
58 struct dhcp6_if
*next
;
60 /* timer for the interface */
61 struct dhcp6_timer
*timer
;
64 TAILQ_HEAD(, dhcp6_event
) event_list
;
66 /* static parameters of the interface */
69 u_int32_t linkid
; /* to send link-local packets */
70 /* multiple global address configuration is not supported now */
71 struct in6_addr addr
; /* global address */
73 /* configuration parameters */
76 #define DHCIFF_INFO_ONLY 0x1
77 #define DHCIFF_RAPID_COMMIT 0x2
79 int server_pref
; /* server preference (server only) */
80 struct dhcp6_poolspec pool
; /* address pool (server only) */
81 char *scriptpath
; /* path to config script (client only) */
83 struct dhcp6_list reqopt_list
;
84 struct ia_conflist iaconf_list
;
86 /* authentication information */
87 int authproto
; /* protocol */
88 /* the followings are valid only if authproto is not UNDEF */
89 int authalgorithm
; /* algorithm */
90 int authrdm
; /* replay attack detection method */
93 /* run-time authentication parameters */
100 #define AUTHPARAM_FLAGS_NOPREVRD 0x1
102 u_int64_t prevrd
; /* previous RD value provided by the peer */
106 TAILQ_ENTRY(dhcp6_event
) link
;
108 struct dhcp6_if
*ifp
;
109 struct dhcp6_timer
*timer
;
111 struct duid serverid
;
113 struct timeval tv_start
; /* timestamp when the 1st msg is sent */
115 /* internal timer parameters */
118 long max_retrans_cnt
;
119 long max_retrans_time
;
120 long max_retrans_dur
;
121 int timeouts
; /* number of timeouts */
123 u_int32_t xid
; /* current transaction ID */
126 /* list of known servers */
127 struct dhcp6_serverinfo
*current_server
;
128 struct dhcp6_serverinfo
*servers
;
130 /* authentication parameters */
131 struct authparam
*authparam
;
133 TAILQ_HEAD(, dhcp6_eventdata
) data_list
;
136 typedef enum { DHCP6_EVDATA_IAPD
, DHCP6_EVDATA_IANA
} dhcp6_eventdata_t
;
138 struct dhcp6_eventdata
{
139 TAILQ_ENTRY(dhcp6_eventdata
) link
;
141 struct dhcp6_event
*event
;
142 dhcp6_eventdata_t type
;
145 void (*destructor
) __P((struct dhcp6_eventdata
*));
149 struct dhcp6_serverinfo
{
150 struct dhcp6_serverinfo
*next
;
152 /* option information provided in the advertisement */
153 struct dhcp6_optinfo optinfo
;
155 int pref
; /* preference */
156 int active
; /* bool; if this server is active or not */
158 struct authparam
*authparam
; /* authentication parameters */
160 /* TODO: remember available information from the server */
163 /* client status code */
164 enum {DHCP6S_INIT
, DHCP6S_SOLICIT
, DHCP6S_INFOREQ
, DHCP6S_REQUEST
,
165 DHCP6S_RENEW
, DHCP6S_REBIND
, DHCP6S_RELEASE
, DHCP6S_IDLE
};
167 struct prefix_ifconf
{
168 TAILQ_ENTRY(prefix_ifconf
) link
;
170 char *ifname
; /* interface name such as ne0 */
171 int sla_len
; /* SLA ID length in bits */
172 u_int32_t sla_id
; /* need more than 32bits? */
173 int ifid_len
; /* interface ID length in bits */
174 int ifid_type
; /* EUI-64 and manual (unused?) */
175 char ifid
[16]; /* Interface ID, up to 128bits */
177 #define IFID_LEN_DEFAULT 64
178 #define SLA_LEN_DEFAULT 16
180 typedef enum { IATYPE_PD
, IATYPE_NA
} iatype_t
;
182 TAILQ_ENTRY(ia_conf
) link
;
183 /*struct ia_conf *next;*/
187 TAILQ_HEAD(, ia
) iadata
; /* struct ia is an opaque type */
189 /* type dependent values follow */
193 struct ia_conf iapd_ia
;
195 /* type dependent values follow */
196 struct dhcp6_list iapd_prefix_list
;
197 struct pifc_list iapd_pif_list
;
199 #define iapd_next iapd_ia.next
200 #define iapd_type iapd_ia.type
201 #define iapd_id iapd_ia.iaid
204 struct ia_conf iana_ia
;
206 /* type dependent values follow */
207 struct dhcp6_list iana_address_list
;
209 #define iana_next iana_ia.next
211 /* per-host configuration */
213 struct host_conf
*next
;
215 char *name
; /* host name to identify the host */
216 struct duid duid
; /* DUID for the host */
218 /* prefixes to be delegated to the host */
219 struct dhcp6_list prefix_list
;
220 /* address to be assigned for the host */
221 struct dhcp6_list addr_list
;
222 /* address pool from which addresses are assigned for the host */
223 struct dhcp6_poolspec pool
;
225 /* secret key shared with the client for delayed authentication */
226 struct keyinfo
*delayedkey
;
227 /* previous replay detection value from the client */
228 int saw_previous_rd
; /* if we remember the previous value */
229 u_int64_t previous_rd
;
232 /* DHCPv6 authentication information */
234 struct authinfo
*next
;
236 char *name
; /* auth info name */
238 int protocol
; /* authentication protocol */
239 int algorithm
; /* authentication algorithm */
240 int rdm
; /* random attack detection method */
242 /* keys specific to this info? */
245 /* structures and definitions used in the config file parser */
247 struct cf_namelist
*next
;
249 int line
; /* the line number of the config file */
250 struct cf_list
*params
;
254 struct cf_list
*next
;
255 struct cf_list
*tail
;
257 int line
; /* the line number of the config file */
259 /* type dependent values: */
261 struct cf_list
*list
;
265 enum { DECL_SEND
, DECL_ALLOW
, DECL_INFO_ONLY
, DECL_REQUEST
, DECL_DUID
,
266 DECL_PREFIX
, DECL_PREFERENCE
, DECL_SCRIPT
, DECL_DELAYEDKEY
,
268 DECL_RANGE
, DECL_ADDRESSPOOL
,
269 IFPARAM_SLA_ID
, IFPARAM_SLA_LEN
,
270 DHCPOPT_RAPID_COMMIT
, DHCPOPT_AUTHINFO
,
271 DHCPOPT_DNS
, DHCPOPT_DNSNAME
,
272 DHCPOPT_IA_PD
, DHCPOPT_IA_NA
, DHCPOPT_NTP
,
274 DHCPOPT_NIS
, DHCPOPT_NISNAME
,
275 DHCPOPT_NISP
, DHCPOPT_NISPNAME
,
276 DHCPOPT_BCMCS
, DHCPOPT_BCMCSNAME
,
278 IACONF_PIF
, IACONF_PREFIX
, IACONF_ADDR
,
279 DHCPOPT_SIP
, DHCPOPT_SIPNAME
,
280 AUTHPARAM_PROTO
, AUTHPARAM_ALG
, AUTHPARAM_RDM
, AUTHPARAM_KEY
,
281 KEYPARAM_REALM
, KEYPARAM_KEYID
, KEYPARAM_SECRET
, KEYPARAM_EXPIRE
};
283 typedef enum {DHCP6_MODE_SERVER
, DHCP6_MODE_CLIENT
, DHCP6_MODE_RELAY
}
286 extern const dhcp6_mode_t dhcp6_mode
;
288 extern struct dhcp6_if
*dhcp6_if
;
289 extern struct dhcp6_ifconf
*dhcp6_iflist
;
290 extern struct prefix_ifconf
*prefix_ifconflist
;
291 extern struct dhcp6_list siplist
;
292 extern struct dhcp6_list sipnamelist
;
293 extern struct dhcp6_list dnslist
;
294 extern struct dhcp6_list dnsnamelist
;
295 extern struct dhcp6_list ntplist
;
296 extern struct dhcp6_list nislist
;
297 extern struct dhcp6_list nisnamelist
;
298 extern struct dhcp6_list nisplist
;
299 extern struct dhcp6_list nispnamelist
;
300 extern struct dhcp6_list bcmcslist
;
301 extern struct dhcp6_list bcmcsnamelist
;
302 extern long long optrefreshtime
;
304 extern struct dhcp6_if
*ifinit
__P((char *));
305 extern int ifreset
__P((struct dhcp6_if
*));
306 extern int configure_interface
__P((struct cf_namelist
*));
307 extern int configure_host
__P((struct cf_namelist
*));
308 extern int configure_keys
__P((struct cf_namelist
*));
309 extern int configure_authinfo
__P((struct cf_namelist
*));
310 extern int configure_ia
__P((struct cf_namelist
*, iatype_t
));
311 extern int configure_global_option
__P((void));
312 extern void configure_cleanup
__P((void));
313 extern void configure_commit
__P((void));
314 extern int cfparse
__P((char *));
315 extern struct dhcp6_if
*find_ifconfbyname
__P((char *));
316 extern struct dhcp6_if
*find_ifconfbyid
__P((unsigned int));
317 extern struct prefix_ifconf
*find_prefixifconf
__P((char *));
318 extern struct host_conf
*find_hostconf
__P((struct duid
*));
319 extern struct authinfo
*find_authinfo
__P((struct authinfo
*, char *));
320 extern struct dhcp6_prefix
*find_prefix6
__P((struct dhcp6_list
*,
321 struct dhcp6_prefix
*));
322 extern struct ia_conf
*find_iaconf
__P((struct ia_conflist
*, int, u_int32_t
));
323 extern struct keyinfo
*find_key
__P((char *, size_t, u_int32_t
));
324 extern int configure_pool
__P((struct cf_namelist
*));
325 extern struct pool_conf
*find_pool
__P((const char *));
326 extern int is_available_in_pool
__P((struct pool_conf
*, struct in6_addr
*));
327 extern int get_free_address_from_pool
__P((struct pool_conf
*,
329 struct host_conf
*create_dynamic_hostconf
__P((struct duid
*,
330 struct dhcp6_poolspec
*));
331 extern char *qstrdup
__P((char *));