2 * The olsr.org Optimized Link-State Routing daemon(olsrd)
3 * Copyright (c) 2004, Andreas T�¸nnesen(andreto@olsr.org)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of olsr.org, olsrd nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
33 * Visit http://www.olsr.org for more information.
35 * If you find this software useful feel free to make a donation
36 * to the project. For more information see the website or contact
37 * the copyright holders.
42 #ifndef _OLSRD_CFGPARSER_H
43 #define _OLSRD_CFGPARSER_H
45 #include "olsr_types.h"
47 #ifndef LINUX_POLICY_ROUTING
49 # define LINUX_POLICY_ROUTING 1
51 # define LINUX_POLICY_ROUTING 0
55 /* Default values not declared in olsr_protocol.h */
56 #define DEF_POLLRATE 0.05
57 #define DEF_NICCHGPOLLRT 2.5
58 #define DEF_WILL_AUTO OLSR_TRUE
59 #define DEF_ALLOW_NO_INTS OLSR_TRUE
61 #define DEF_DEBUGLVL 1
62 #define DEF_IPC_CONNECTIONS 0
63 #define DEF_USE_HYST OLSR_FALSE
64 #define DEF_FIB_METRIC FIBM_FLAT
65 #define DEF_LQ_LEVEL 2
67 #define DEF_LQ_DIJK_LIMIT 255
68 #define DEF_LQ_DIJK_INTER 0.0
69 #define DEF_LQ_NAT_THRESH 1.0
70 #define DEF_LQ_WSIZE 12
71 #define DEF_CLEAR_SCREEN OLSR_FALSE
75 #define MIN_INTERVAL 0.01
77 #define MAX_POLLRATE 10.0
78 #define MIN_POLLRATE 0.01
79 #define MAX_NICCHGPOLLRT 100.0
80 #define MIN_NICCHGPOLLRT 1.0
81 #define MAX_DEBUGLVL 9
82 #define MIN_DEBUGLVL 0
85 #define MAX_WILLINGNESS 7
86 #define MIN_WILLINGNESS 0
87 #define MAX_MPR_COVERAGE 20
88 #define MIN_MPR_COVERAGE 1
89 #define MAX_TC_REDUNDANCY 2
90 #define MIN_TC_REDUNDANCY 0
91 #define MAX_HYST_PARAM 1.0
92 #define MIN_HYST_PARAM 0.0
93 #define MAX_LQ_LEVEL 2
94 #define MIN_LQ_LEVEL 0
95 #define MAX_LQ_WSIZE 128
96 #define MIN_LQ_WSIZE 3
99 #define CFG_FIBM_FLAT "flat"
100 #define CFG_FIBM_CORRECT "correct"
101 #define CFG_FIBM_APPROX "approx"
103 #ifndef IPV6_ADDR_SITELOCAL
104 #define IPV6_ADDR_SITELOCAL 0x0040U
107 #include "interfaces.h"
109 struct olsr_msg_params
111 float emission_interval;
117 union olsr_ip_addr addr;
119 struct olsr_lq_mult *next;
122 struct olsr_if_weight
128 struct if_config_options
130 union olsr_ip_addr ipv4_broadcast;
132 union olsr_ip_addr ipv6_multi_site;
133 union olsr_ip_addr ipv6_multi_glbl;
134 struct olsr_if_weight weight;
135 struct olsr_msg_params hello_params;
136 struct olsr_msg_params tc_params;
137 struct olsr_msg_params mid_params;
138 struct olsr_msg_params hna_params;
139 struct olsr_lq_mult *lq_mult;
140 olsr_bool autodetect_chg;
149 olsr_bool configured;
151 union olsr_ip_addr hemu_ip;
152 struct interface *interf;
153 struct if_config_options *cnf;
154 struct olsr_if *next;
157 struct ip_prefix_list
159 struct olsr_ip_prefix net;
160 struct ip_prefix_list *next;
174 struct plugin_param *next;
180 struct plugin_param *params;
181 struct plugin_entry *next;
189 } olsr_fib_metric_options;
201 olsr_bool allow_no_interfaces;
204 olsr_u8_t rttable_default;
205 olsr_u8_t willingness;
206 olsr_bool willingness_auto;
208 olsr_bool use_hysteresis;
209 olsr_fib_metric_options fib_metric;
210 struct hyst_param hysteresis_param;
211 struct plugin_entry *plugins;
212 struct ip_prefix_list *hna_entries;
213 struct ip_prefix_list *ipc_nets;
214 struct olsr_if *interfaces;
216 float nic_chgs_pollrate;
217 olsr_bool clear_screen;
218 olsr_u8_t tc_redundancy;
219 olsr_u8_t mpr_coverage;
226 /* Stuff set by olsrd */
227 olsr_u16_t system_tick_divider; /* Tick resolution */
228 olsr_u8_t maxplen; /* maximum prefix len */
229 size_t ipsize; /* Size of address */
230 olsr_bool del_gws; /* Delete InternetGWs at startup */
231 union olsr_ip_addr main_addr; /* Main address of this node */
234 int exit_value; /* Global return value for process termination */
237 int ioctl_s; /* Socket used for ioctl calls */
238 #if LINUX_POLICY_ROUTING
239 int rtnl_s; /* Socket used for rtnetlink messages */
242 #if defined __FreeBSD__ || defined __MacOSX__ || defined __NetBSD__ || defined __OpenBSD__
243 int rts; /* Socket used for route changes on BSDs */
248 #if defined __cplusplus
257 void ip_prefix_list_add(struct ip_prefix_list **, const union olsr_ip_addr *, olsr_u8_t);
259 int ip_prefix_list_remove(struct ip_prefix_list **, const union olsr_ip_addr *, olsr_u8_t);
261 struct ip_prefix_list *ip_prefix_list_find(struct ip_prefix_list *, const union olsr_ip_addr *net, olsr_u8_t prefix_len);
265 * Interface to parser
268 struct olsrd_config *
269 olsrd_parse_cnf(const char *);
272 olsrd_sanity_check_cnf(struct olsrd_config *);
275 olsrd_free_cnf(struct olsrd_config *);
278 olsrd_print_cnf(struct olsrd_config *);
281 olsrd_write_cnf(struct olsrd_config *, const char *);
284 olsrd_write_cnf_buf(struct olsrd_config *, char *, olsr_u32_t);
286 struct if_config_options *
287 get_default_if_config(void);
289 struct olsrd_config *
290 olsrd_get_default_cnf(void);
294 win32_stdio_hack(unsigned int);
297 win32_olsrd_malloc(size_t size);
300 win32_olsrd_free(void* ptr);
303 #if defined __cplusplus