2 * The olsr.org Optimized Link-State Routing daemon(olsrd)
3 * Copyright (c) 2005, Andreas Tonnesen(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.
41 #include "olsrd_conf.h"
42 #include "builddata.h"
43 #include "../ipcalc.h"
44 #include "../net_olsr.h"
45 #include "../common/autobuf.h"
46 #include "../egressTypes.h"
52 #include <sys/types.h>
53 #include <netinet/in.h>
54 #include <arpa/inet.h>
56 int olsrd_write_cnf(struct olsrd_config *cnf, const char *fname) {
60 fd = fopen(fname, "w");
63 fprintf(stderr, "Could not open file %s for writing\n%s\n", fname, strerror(errno));
67 printf("Writing config to file \"%s\".... ", fname);
68 abuf_init(&abuf, 1024);
69 olsrd_write_cnf_autobuf(&abuf, cnf);
70 if (fwrite(abuf.buf, abuf.len, 1, fd) < (size_t)abuf.len) {
71 fprintf(stderr, "Error, could not write the complete config file.\n");
82 if_appendf(struct autobuf *autobuf, bool comments, const char *fmt, ...) __attribute__ ((format(printf, 3, 4)));
85 if_appendf(struct autobuf *autobuf, bool comments, const char *fmt, ...)
93 first = va_arg(ap, char*);
101 rv = abuf_vappendf(autobuf, fmt, ap);
106 static void olsrd_write_if_autobuf(struct autobuf *out, struct if_config_options *cnfi, bool comments) {
107 struct ipaddr_str ipbuf;
108 struct olsr_lq_mult *mult;
110 abuf_puts(out, "{\n");
111 if (comments) abuf_appendf(out,
112 " # Interface Mode is used to prevent unnecessary\n"
113 " # packet forwarding on switched ethernet interfaces\n"
114 " # valid Modes are \"mesh\" and \"ether\"\n"
115 " # (default is \"%s\")\n"
116 " \n", OLSR_IF_MODE[DEF_IF_MODE]);
117 if_appendf(out, comments, " %sMode \"%s\"\n",
118 cnfi->mode == DEF_IF_MODE ? "# " : "",
119 OLSR_IF_MODE[cnfi->mode]);
120 if (comments) abuf_puts(out,
122 " # IPv4 broadcast address for outgoing OLSR packets.\n"
123 " # One useful example would be 255.255.255.255\n"
124 " # The second useful value would be to\n"
125 " # specify the peer address of an ptp-tunnel.\n"
126 " # another name of this parameter is \"IPv4Multicast\"\n"
127 " # (default is 0.0.0.0, which triggers the usage of the\n"
128 " # interface broadcast IP)\n"
130 if_appendf(out, comments, " %sIp4Broadcast %s\n",
131 cnfi->ipv4_multicast.v4.s_addr == 0 ? "# " : "",
132 inet_ntop(AF_INET, &cnfi->ipv4_multicast, ipbuf.buf, sizeof(ipbuf)));
133 if (comments) abuf_appendf(out,
135 " # IPv6 multicast address\n"
136 " # (default is %s, the manet-router linklocal multicast)\n"
137 " \n", inet_ntop(AF_INET6, &ipv6_def_multicast, ipbuf.buf, sizeof(ipbuf)));
138 if_appendf(out, comments, " %sIPv6Multicast %s\n",
139 memcmp(&cnfi->ipv6_multicast, &ipv6_def_multicast, sizeof(ipv6_def_multicast)) == 0 ? "# " : "",
140 inet_ntop(AF_INET6, &cnfi->ipv6_multicast, ipbuf.buf, sizeof(ipbuf)));
141 if (comments) abuf_puts(out,
143 " # IPv4 src address for outgoing OLSR packages\n"
144 " # (default is 0.0.0.0, which triggers usage of the interface IP)\n"
146 if_appendf(out, comments, " %sIPv4Src %s\n",
147 cnfi->ipv4_src.v4.s_addr == 0 ? "# " : "",
148 inet_ntop(AF_INET, &cnfi->ipv4_src, ipbuf.buf, sizeof(ipbuf)));
149 if (comments) abuf_puts(out,
151 " # IPv6 src prefix. OLSRd will choose one of the interface IPs\n"
152 " # which matches the prefix of this parameter.\n"
153 " # (default is 0::/0, which triggers the usage\n"
154 " # of a not-linklocal interface IP)\n"
156 if_appendf(out, comments, " %sIPv6Src %s\n",
157 cnfi->ipv6_src.prefix_len == 0 ? "# " : "",
158 inet_ntop(AF_INET6, &cnfi->ipv6_src, ipbuf.buf, sizeof(ipbuf)));
159 if (comments) abuf_appendf(out,
161 " # Emission intervals in seconds.\n"
162 " # If not defined, Freifunk network defaults are used.\n"
163 " # (defaults: Hello = %.1f/%.1f, TC = %.1f/%.1f,\n"
164 " # MID = %.1f/%.1f, HNA = %.1f/%.1f)\n"
166 (double)HELLO_INTERVAL, (double)NEIGHB_HOLD_TIME,
167 (double)TC_INTERVAL, (double)TOP_HOLD_TIME,
168 (double)MID_INTERVAL, (double)MID_HOLD_TIME,
169 (double)HNA_INTERVAL, (double)HNA_HOLD_TIME
171 if_appendf(out, comments, " %sHelloInterval %3.1f\n",
172 cnfi->hello_params.emission_interval == HELLO_INTERVAL ? "# " : "",
173 (double)cnfi->hello_params.emission_interval);
174 if_appendf(out, comments, " %sHelloValidityTime %3.1f\n",
175 cnfi->hello_params.validity_time == NEIGHB_HOLD_TIME ? "# " : "",
176 (double)cnfi->hello_params.validity_time);
177 if_appendf(out, comments, " %sTcInterval %3.1f\n",
178 cnfi->tc_params.emission_interval == TC_INTERVAL ? "# " : "",
179 (double)cnfi->tc_params.emission_interval);
180 if_appendf(out, comments, " %sTcValidityTime %3.1f\n",
181 cnfi->tc_params.validity_time == TOP_HOLD_TIME ? "# " : "",
182 (double)cnfi->tc_params.validity_time);
183 if_appendf(out, comments, " %sMidInterval %3.1f\n",
184 cnfi->mid_params.emission_interval == MID_INTERVAL ? "# " : "",
185 (double)cnfi->mid_params.emission_interval);
186 if_appendf(out, comments, " %sMidValidityTime %3.1f\n",
187 cnfi->mid_params.validity_time == MID_HOLD_TIME ? "# " : "",
188 (double)cnfi->mid_params.validity_time);
189 if_appendf(out, comments, " %sHnaInterval %3.1f\n",
190 cnfi->hna_params.emission_interval == HNA_INTERVAL ? "# " : "",
191 (double)cnfi->hna_params.emission_interval);
192 if_appendf(out, comments, " %sHnaValidityTime %3.1f\n",
193 cnfi->hna_params.validity_time == HNA_HOLD_TIME ? "# " : "",
194 (double)cnfi->hna_params.validity_time);
195 if (comments) abuf_puts(out,
197 " # When multiple links exist between hosts\n"
198 " # the weight of interface is used to determine\n"
199 " # the link to use. Normally the weight is\n"
200 " # automatically calculated by olsrd based\n"
201 " # on the characteristics of the interface,\n"
202 " # but here you can specify a fixed value.\n"
203 " # Olsrd will choose links with the lowest value.\n"
205 " # Interface weight is used only when LinkQualityLevel is set to 0.\n"
206 " # For any other value of LinkQualityLevel, the interface ETX\n"
207 " # value is used instead.\n");
208 if_appendf(out, comments, " %sWeight %d\n",
209 !cnfi->weight.fixed ? "# " : "",
211 if (comments) abuf_puts(out,
213 " # If a certain route should be preferred\n"
214 " # or ignored by the mesh, the Link Quality\n"
215 " # value of a node can be multiplied with a factor\n"
216 " # entered here. In the example the route\n"
217 " # using 192.168.0.1 would rather be ignored.\n"
218 " # A multiplier of 0.5 will result in a small\n"
219 " # (bad) LinkQuality value and a high (bad)\n"
222 " # Link quality multiplier is used only when\n"
223 " # LinkQualityLevel is greater than 0.\n"
225 mult = cnfi->lq_mult;
228 if (comments) abuf_puts(out, " # LinkQualityMult 192.168.0.1 0.5\n");
230 while (mult != NULL) {
231 if_appendf(out, comments, " LinkQualityMult %s %0.2f\n",
232 olsr_ip_to_string(&ipbuf, &mult->addr),
233 (double)((float)(mult->value) / 65536.0f));
237 abuf_puts(out, "}\n");
240 void olsrd_write_cnf_autobuf(struct autobuf *out, struct olsrd_config *cnf) {
241 struct ip_prefix_list *hna = cnf->hna_entries;
242 struct olsr_if *interf = cnf->interfaces;
243 struct plugin_entry *plugins = cnf->plugins;
244 struct plugin_param *pl_param;
245 struct ip_prefix_list *ipc_nets = cnf->ipc_nets;
247 struct ipaddr_str ipbuf;
250 abuf_appendf(out, "#\n"
251 "# Configuration file for %s\n"
252 "# automatically generated by olsrd-cnf parser v. %s\n"
255 olsrd_version, PARSER_VERSION);
257 "# OLSR.org routing daemon config file\n"
258 "# This file contains ALL available options and explanations about them\n"
260 "# Lines starting with a # are discarded\n"
263 "#### ATTENTION for IPv6 users ####\n"
264 "# Because of limitations in the parser IPv6 addresses must NOT\n"
265 "# begin with a \":\", so please add a \"0\" as a prefix.\n"
267 "###########################\n"
268 "### Basic configuration ###\n"
269 "###########################\n"
270 "# keep this settings at the beginning of your first configuration file\n"
272 "# Debug level (0-9)\n"
273 "# If set to 0 the daemon runs in the background, unless \"NoFork\" is set to true\n"
274 "# (default is %u)\n"
276 abuf_appendf(out, "%sDebugLevel %d\n",
277 cnf->debug_level == DEF_DEBUGLVL ? "# " : "",
281 "# IP version to use (4 or 6)\n"
282 "# (default is %u)\n"
283 "\n", (DEF_IP_VERSION == AF_INET) ? 4 : 6);
284 abuf_appendf(out, "%sIpVersion %d\n",
285 cnf->ip_version == DEF_IP_VERSION ? "# " : "",
286 cnf->ip_version == AF_INET ? 4 : 6);
289 "#################################\n"
290 "### OLSRd agent configuration ###\n"
291 "#################################\n"
292 "# this parameters control the settings of the routing agent which are not\n"
293 "# related to the OLSR protocol and it's extensions\n"
295 "# Clear the screen each time the internal state changes\n"
296 "# (default is %s)\n"
297 "\n", DEF_CLEAR_SCREEN ? "yes" : "no");
298 abuf_appendf(out, "%sClearScreen %s\n",
299 cnf->clear_screen == DEF_CLEAR_SCREEN ? "# " : "",
300 cnf->clear_screen ? "yes" : "no");
303 "# Should olsrd keep on running even if there are\n"
304 "# no interfaces available? This is a good idea\n"
305 "# for a PCMCIA/USB hotswap environment.\n"
306 "# (default is %s)\n"
307 "\n", DEF_ALLOW_NO_INTS ? "yes" : "no");
308 abuf_appendf(out, "%sAllowNoInt %s\n",
309 cnf->allow_no_interfaces == DEF_ALLOW_NO_INTS ? "# " : "",
310 cnf->allow_no_interfaces ? "yes" : "no");
314 "# The lockfile is used to prevent multiple OLSR instances running at the same\n"
316 "# (Linux/BSD default is \"/var/run/olsrd-ipv(4/6).lock\")\n"
317 "# (Win32 default is \"[configfile]-ipv(4/6).lock\")\n"
320 char * lockfile_default = olsrd_get_default_lockfile(cnf);
321 abuf_appendf(out, "%sLockFile \"%s\"\n",
322 !strcmp(cnf->lock_file, lockfile_default) ? "# " : "",
324 free(lockfile_default);
328 "# Polling rate for OLSR sockets in seconds (float). \n"
329 "# (default is %.2f)\n"
330 "\n", (double)DEF_POLLRATE);
331 abuf_appendf(out, "%sPollrate %.2f\n",
332 cnf->pollrate == (float)DEF_POLLRATE ? "# " : "",
333 (double)cnf->pollrate);
336 "# Interval to poll network interfaces for configuration changes (in seconds).\n"
337 "# Linux systems can detect interface statechange via netlink sockets.\n"
338 "# (default is %.1f)\n"
339 "\n", (double)DEF_NICCHGPOLLRT);
340 abuf_appendf(out, "%sNicChgsPollInt %.1f\n",
341 cnf->nic_chgs_pollrate == (float)DEF_NICCHGPOLLRT ? "# " : "",
342 (double)cnf->nic_chgs_pollrate);
345 "# TOS(type of service) value for the IP header of control traffic.\n"
346 "# (default is %u)\n"
348 abuf_appendf(out, "%sTosValue %u\n",
349 cnf->tos == DEF_TOS ? "# " : "",
353 "# FIBMetric controls the metric value of the host-routes OLSRd sets.\n"
354 "# - \"flat\" means that the metric value is always 2(or as configured \n"
355 "# with FIBMetricDefault). This is the preferred value because it \n"
356 "# helps the linux kernel routing to clean up older routes\n"
357 "# - \"correct\" use the hopcount as the metric value.\n"
358 "# - \"approx\" use the hopcount as the metric value too, but does only update the\n"
359 "# hopcount if the nexthop changes too\n"
360 "# (default is \"%s\")\n"
361 "\n", FIB_METRIC_TXT[DEF_FIB_METRIC]);
362 abuf_appendf(out, "%sFIBMetric \"%s\"\n",
363 cnf->fib_metric == DEF_FIB_METRIC ? "# " : "",
364 FIB_METRIC_TXT[cnf->fib_metric]);
367 "# Default FIB metric.\n"
368 "# The kernel FIB does not need to know the metric of a route.\n"
369 "# This saves us from enqueuing/dequeueing hopcount only changes.\n"
370 "# (default is %u)\n"
371 "\n", DEF_FIB_METRIC_DEFAULT);
372 abuf_appendf(out, "%sFIBMetricDefault %u\n",
373 cnf->fib_metric_default == DEF_FIB_METRIC_DEFAULT? "# " : "",
374 cnf->fib_metric_default);
377 "#######################################\n"
378 "### Linux specific OLSRd extensions ###\n"
379 "#######################################\n"
380 "# these parameters are only working on linux at the moment, but might become\n"
381 "# useful on BSD in the future\n"
383 "# SrcIpRoutes tells OLSRd to set the Src flag of host routes to the originator-ip\n"
384 "# of the node. In addition to this an additional localhost device is created\n"
385 "# to make sure the returning traffic can be received.\n"
386 "# (default is \"%s\")\n"
387 "\n", DEF_USE_SRCIP_ROUTES ? "yes" : "no");
388 abuf_appendf(out, "%sSrcIpRoutes %s\n",
389 cnf->use_src_ip_routes == DEF_USE_SRCIP_ROUTES ? "# " : "",
390 cnf->use_src_ip_routes ? "yes" : "no");
393 "# Specify the proto tag to be used for routes olsr inserts into kernel\n"
394 "# currently only implemented for linux\n"
395 "# valid values under linux are 1 .. 254\n"
396 "# 1 gets remapped by olsrd to 0 UNSPECIFIED (1 is reserved for ICMP redirects)\n"
397 "# 2 KERNEL routes (not very wise to use)\n"
398 "# 3 BOOT (should in fact not be used by routing daemons)\n"
400 "# 8 .. 15 various routing daemons (gated, zebra, bird, & co)\n"
401 "# (default is %u which gets replaced by an OS-specific default value\n"
402 "# under linux 3 (BOOT) (for backward compatibility)\n"
404 abuf_appendf(out, "%sRtProto %u\n",
405 cnf->rt_proto == DEF_RTPROTO ? "# " : "",
409 "# Specifies the routing Table olsr uses\n"
410 "# RtTable is for host routes, RtTableDefault for the route to the default\n"
411 "# internet gateway (2 in case of IPv6+NIIT) and RtTableTunnel is for\n"
412 "# routes to the ipip tunnels, valid values are 1 to 254\n"
413 "# There is a special parameter \"auto\" (choose default below)\n"
414 "# (with smartgw: default is %u/%u/%u)\n"
415 "# (without smartgw: default is %u/%u/%u, linux main table)\n"
417 DEF_SGW_RT_TABLE_NR, DEF_SGW_RT_TABLE_DEFAULT_NR, DEF_SGW_RT_TABLE_TUNNEL_NR,
418 DEF_RT_TABLE_NR, DEF_RT_TABLE_DEFAULT_NR, DEF_RT_TABLE_TUNNEL_NR);
419 if (!cnf->smart_gw_active) {
420 abuf_appendf(out, "%sRtTable %u\n",
421 cnf->rt_table == DEF_RT_TABLE_NR ? "# " : "",
423 abuf_appendf(out, "%sRtTableDefault %u\n",
424 cnf->rt_table_default == DEF_RT_TABLE_DEFAULT_NR ? "# " : "",
425 cnf->rt_table_default);
426 abuf_appendf(out, "%sRtTableTunnel %u\n",
427 cnf->rt_table_tunnel == DEF_RT_TABLE_TUNNEL_NR ? "# " : "",
428 cnf->rt_table_tunnel);
430 abuf_appendf(out, "%sRtTable %u\n",
431 cnf->rt_table == DEF_SGW_RT_TABLE_NR ? "# " : "",
433 abuf_appendf(out, "%sRtTableDefault %u\n",
434 cnf->rt_table_default == DEF_SGW_RT_TABLE_DEFAULT_NR ? "# " : "",
435 cnf->rt_table_default);
436 abuf_appendf(out, "%sRtTableTunnel %u\n",
437 cnf->rt_table_tunnel == DEF_SGW_RT_TABLE_TUNNEL_NR ? "# " : "",
438 cnf->rt_table_tunnel);
442 "# Specifies the policy rule priorities for the three routing tables and\n"
443 "# a special rule for smartgateway routing (see README-Olsr-Extensions)\n"
444 "# Priorities can only be set if three different routing tables are set.\n"
445 "# if set the values must obey to condition\n"
446 "# RtTablePriority less than RtTableDefaultOlsrPriority\n"
447 "# less than RtTableTunnelPriority less than RtTableDefaultPriority\n"
448 "# There are two special parameters, \"auto\" (choose fitting to SmartGW\n"
449 "# mode) and \"none\" (do not set policy rule)\n"
450 "# (with smartgw: default is %d/%u/%u/%u)\n"
451 "# (without smartgw: default is %d/%d /%d /%d )\n"
453 DEF_SGW_RT_TABLE_PRI,
454 DEF_SGW_RT_TABLE_PRI_BASE + DEF_SGW_RT_TABLE_DEFAULTOLSR_PRI_ADDER,
455 DEF_SGW_RT_TABLE_PRI_BASE + DEF_SGW_RT_TABLE_DEFAULTOLSR_PRI_ADDER + DEF_SGW_RT_TABLE_TUNNEL_PRI_ADDER,
456 DEF_SGW_RT_TABLE_PRI_BASE + DEF_SGW_RT_TABLE_DEFAULTOLSR_PRI_ADDER + DEF_SGW_RT_TABLE_TUNNEL_PRI_ADDER + DEF_SGW_RT_TABLE_DEFAULT_PRI_ADDER,
458 DEF_RT_TABLE_DEFAULTOLSR_PRI,
459 DEF_RT_TABLE_TUNNEL_PRI,
460 DEF_RT_TABLE_DEFAULT_PRI);
461 if (!cnf->smart_gw_active) {
462 if (cnf->rt_table_pri == DEF_RT_TABLE_PRI) {
463 abuf_appendf(out, "# RtTablePriority %d\n",
466 abuf_appendf(out, "RtTablePriority %u\n",
469 if (cnf->rt_table_defaultolsr_pri == DEF_RT_TABLE_DEFAULTOLSR_PRI) {
470 abuf_appendf(out, "# RtTableDefaultOlsrPriority %d\n",
471 cnf->rt_table_defaultolsr_pri);
473 abuf_appendf(out, "RtTableDefaultOlsrPriority %u\n",
474 cnf->rt_table_defaultolsr_pri);
476 if (cnf->rt_table_tunnel_pri == DEF_RT_TABLE_TUNNEL_PRI) {
477 abuf_appendf(out, "# RtTableTunnelPriority %d\n",
478 cnf->rt_table_tunnel_pri);
480 abuf_appendf(out, "RtTableTunnelPriority %u\n",
481 cnf->rt_table_tunnel_pri);
483 if (cnf->rt_table_default_pri == DEF_RT_TABLE_DEFAULT_PRI) {
484 abuf_appendf(out, "# RtTableDefaultPriority %d\n",
485 cnf->rt_table_default_pri);
487 abuf_appendf(out, "RtTableDefaultPriority %u\n",
488 cnf->rt_table_default_pri);
491 if (cnf->rt_table_pri == DEF_SGW_RT_TABLE_PRI) {
492 abuf_appendf(out, "# RtTablePriority %d\n",
495 abuf_appendf(out, "RtTablePriority %u\n",
498 abuf_appendf(out, "%sRtTableDefaultOlsrPriority %u\n",
499 cnf->rt_table_defaultolsr_pri == (DEF_SGW_RT_TABLE_PRI_BASE + DEF_SGW_RT_TABLE_DEFAULTOLSR_PRI_ADDER) ? "# " : "",
500 cnf->rt_table_defaultolsr_pri);
501 abuf_appendf(out, "%sRtTableTunnelPriority %u\n",
502 cnf->rt_table_tunnel_pri == (DEF_SGW_RT_TABLE_PRI_BASE + DEF_SGW_RT_TABLE_DEFAULTOLSR_PRI_ADDER + DEF_SGW_RT_TABLE_TUNNEL_PRI_ADDER) ? "# " : "",
503 cnf->rt_table_tunnel_pri);
504 abuf_appendf(out, "%sRtTableDefaultPriority %u\n",
505 cnf->rt_table_default_pri == (DEF_SGW_RT_TABLE_PRI_BASE + DEF_SGW_RT_TABLE_DEFAULTOLSR_PRI_ADDER + DEF_SGW_RT_TABLE_TUNNEL_PRI_ADDER + DEF_SGW_RT_TABLE_DEFAULT_PRI_ADDER) ? "# " : "",
506 cnf->rt_table_default_pri);
510 "# Activates (in IPv6 mode) the automatic use of NIIT\n"
511 "# (see README-Olsr-Extensions)\n"
512 "# (default is \"%s\")\n"
513 "\n", DEF_USE_NIIT ? "yes" : "no");
514 abuf_appendf(out, "%sUseNiit %s\n",
515 cnf->use_niit == DEF_USE_NIIT ? "# " : "",
516 cnf->use_niit ? "yes" : "no");
519 "# Activates the smartgateway ipip tunnel feature.\n"
520 "# See README-Olsr-Extensions for a description of smartgateways.\n"
521 "# (default is \"%s\")\n"
522 "\n", DEF_SMART_GW ? "yes" : "no");
523 abuf_appendf(out, "%sSmartGateway %s\n",
524 cnf->smart_gw_active == DEF_SMART_GW ? "# " : "",
525 cnf->smart_gw_active ? "yes" : "no");
528 "# Signals that the server tunnel must always be removed on shutdown,\n"
529 "# irrespective of the interface up/down state during startup.\n"
530 "# (default is \"%s\")\n"
531 "\n", DEF_SMART_GW_ALWAYS_REMOVE_SERVER_TUNNEL ? "yes" : "no");
532 abuf_appendf(out, "%sSmartGatewayAlwaysRemoveServerTunnel %s\n",
533 cnf->smart_gw_always_remove_server_tunnel == DEF_SMART_GW_ALWAYS_REMOVE_SERVER_TUNNEL ? "# " : "",
534 cnf->smart_gw_always_remove_server_tunnel ? "yes" : "no");
537 "# Determines the maximum number of gateways that can be in use at any given\n"
538 "# time. This setting is used to mitigate the effects of breaking connections\n"
539 "# (due to the selection of a new gateway) on a dynamic network.\n"
540 "# (default is %u)\n"
541 "\n", DEF_GW_USE_COUNT);
542 abuf_appendf(out, "%sSmartGatewayUseCount %d\n",
543 cnf->smart_gw_use_count == DEF_GW_USE_COUNT ? "# " : "",
544 cnf->smart_gw_use_count);
547 "# Determines the take-down percentage for a non-current smart gateway tunnel.\n"
548 "# If the cost of the current smart gateway tunnel is less than this percentage\n"
549 "# of the cost of the non-current smart gateway tunnel, then the non-current smart\n"
550 "# gateway tunnel is taken down because it is then presumed to be 'too expensive'.\n"
551 "# This setting is only relevant when SmartGatewayUseCount is larger than 1;\n"
552 "# a value of 0 will result in the tunnels not being taken down proactively.\n"
553 "# (default is %u)\n"
554 "\n", DEF_GW_TAKEDOWN_PERCENTAGE);
555 abuf_appendf(out, "%sSmartGatewayTakeDownPercentage %d\n",
556 cnf->smart_gw_takedown_percentage == DEF_GW_TAKEDOWN_PERCENTAGE ? "# " : "",
557 cnf->smart_gw_takedown_percentage);
560 "# Determines the policy routing script that is executed during startup and\n"
561 "# shutdown of olsrd. The script is only executed when SmartGatewayUseCount\n"
562 "# is set to a value larger than 1. The script must setup policy routing\n"
563 "# rules such that multi-gateway mode works. A sample script is included.\n"
564 "# (default is not set)\n"
566 abuf_appendf(out, "%sSmartGatewayPolicyRoutingScript %s\n",
567 !cnf->smart_gw_policyrouting_script ? "# " : "",
568 !cnf->smart_gw_policyrouting_script ? "" : cnf->smart_gw_policyrouting_script);
571 "# Determines the egress interfaces that are part of the multi-gateway setup and\n"
572 "# therefore only relevant when SmartGatewayUseCount is larger than 1 (in which\n"
573 "# case it must be explicitly set).\n"
574 "# (default is not set)\n"
576 abuf_appendf(out, "%sSmartGatewayEgressInterfaces",
577 !cnf->smart_gw_egress_interfaces ? "# " : "");
579 struct sgw_egress_if * sgwegressif = olsr_cnf->smart_gw_egress_interfaces;
580 while (sgwegressif) {
581 abuf_appendf(out, " \"%s\"", sgwegressif->name);
582 sgwegressif = sgwegressif->next;
584 abuf_puts(out, "\n");
588 "# SmartGatewayEgressFile declares the file that contains the bandwidth\n"
589 "# parameters of the egress interfaces declared by SmartGatewayEgressInterfaces.\n"
590 "# Every line in the file declares bandwidth parameters of an egress interface,\n"
591 "# with the format:\n"
592 "# # this is a comment\n"
593 "# interface=upstream,downstream,pathcost,network/prefix,gateway\n"
594 "# Only the upstream and downstream fields are mandatory, the other fields are\n"
595 "# optional. An empty field signifies that its default should be used.\n"
596 "# The field defaults are:\n"
597 "# upstream = 0 (Kbps)\n"
598 "# downstream = 0 (Kbps)\n"
599 "# pathcost = 0 (dimensionless, 1024 is equivalent to 1 hop)\n"
600 "# network/prefix = no default / not set\n"
601 "# - network is an IP address\n"
602 "# - prefix is a number in the range [0, 24] for IPv4\n"
603 "# and in the range [0, 128] for IPv6\n"
604 "# gateway = no default / not set (IP address)\n"
605 "# (default is %s)\n"
606 "\n", DEF_GW_EGRESS_FILE);
608 bool def = !cnf->smart_gw_egress_file || !strcmp(cnf->smart_gw_egress_file, DEF_GW_EGRESS_FILE);
609 abuf_appendf(out, "%sSmartGatewayEgressFile %s\n",
610 def ? "# " : "", def ? DEF_GW_EGRESS_FILE : cnf->smart_gw_egress_file);
614 "# SmartGatewayEgressFilePeriod determines the period (in milliseconds) on which\n"
615 "# the SmartGatewayEgressFile is checked for changes and processed if changed.\n"
616 "# (default is %u)\n"
617 "\n", DEF_GW_EGRESS_FILE_PERIOD);
618 abuf_appendf(out, "%sSmartGatewayEgressFilePeriod %u\n",
619 cnf->smart_gw_egress_file_period == DEF_GW_EGRESS_FILE_PERIOD ? "# " : "",
620 cnf->smart_gw_egress_file_period);
623 "# Declares the file that is written by olsrd to contain the status of the smart\n"
624 "# gateways and is only relevant when SmartGatewayUseCount is larger than 1.\n"
625 "# (default is %s)\n"
628 bool def = !cnf->smart_gw_status_file || !strlen(cnf->smart_gw_status_file);
629 abuf_appendf(out, "%sSmartGatewayStatusFile %s\n",
630 def ? "# " : "", def ? "<not set>" : cnf->smart_gw_status_file);
634 "# Determines the routing tables offset for multi-gateway policy routing tables\n"
635 "# See the policy routing script for an explanation.\n"
636 "# (default is %u)\n"
637 "\n", DEF_GW_OFFSET_TABLES);
638 abuf_appendf(out, "%sSmartGatewayTablesOffset %u\n",
639 cnf->smart_gw_offset_tables == DEF_GW_OFFSET_TABLES ? "# " : "",
640 cnf->smart_gw_offset_tables);
643 "# Determines the policy routing rules offset for multi-gateway policy routing\n"
644 "# rules. See the policy routing script for an explanation.\n"
645 "# (default is %u, which indicates that the rules and tables should be aligned and\n"
646 "# puts this value at SmartGatewayTablesOffset - # egress interfaces -\n"
647 "# # olsr interfaces)\n"
648 "\n", DEF_GW_OFFSET_RULES);
649 abuf_appendf(out, "%sSmartGatewayRulesOffset %u\n",
650 cnf->smart_gw_offset_rules == DEF_GW_OFFSET_RULES ? "# " : "",
651 cnf->smart_gw_offset_rules);
654 "# Allows the selection of a smartgateway with NAT (only for IPv4)\n"
655 "# (default is \"%s\")\n"
656 "\n", DEF_GW_ALLOW_NAT ? "yes" : "no");
657 abuf_appendf(out, "%sSmartGatewayAllowNAT %s\n",
658 cnf->smart_gw_allow_nat == DEF_GW_ALLOW_NAT ? "# " : "",
659 cnf->smart_gw_allow_nat ? "yes" : "no");
662 "# Determines the period (in milliseconds) on which a new smart gateway\n"
663 "# selection is performed.\n"
664 "# (default is %u milliseconds)\n"
665 "\n", DEF_GW_PERIOD);
666 abuf_appendf(out, "%sSmartGatewayPeriod %d\n",
667 cnf->smart_gw_period == DEF_GW_PERIOD ? "# " : "",
668 cnf->smart_gw_period);
671 "# Determines the number of times the link state database must be stable\n"
672 "# before a new smart gateway is selected.\n"
673 "# (default is %u)\n"
674 "\n", DEF_GW_STABLE_COUNT);
675 abuf_appendf(out, "%sSmartGatewayStableCount %d\n",
676 cnf->smart_gw_stablecount == DEF_GW_STABLE_COUNT ? "# " : "",
677 cnf->smart_gw_stablecount);
680 "# When another gateway than the current one has a cost of less than the cost\n"
681 "# of the current gateway multiplied by SmartGatewayThreshold then the smart\n"
682 "# gateway is switched to the other gateway. The unit is percentage.\n"
683 "# (default is %u)\n"
684 "\n", DEF_GW_THRESH);
685 abuf_appendf(out, "%sSmartGatewayThreshold %d\n",
686 cnf->smart_gw_thresh == DEF_GW_THRESH ? "# " : "",
687 cnf->smart_gw_thresh);
690 "# The weighing factor for the gateway uplink bandwidth (exit link, uplink).\n"
691 "# See README-Olsr-Extensions for a description of smart gateways.\n"
692 "# (default is %lu)\n"
693 "\n", (long unsigned int)DEF_GW_WEIGHT_EXITLINK_UP);
694 abuf_appendf(out, "%sSmartGatewayWeightExitLinkUp %d\n",
695 cnf->smart_gw_weight_exitlink_up == DEF_GW_WEIGHT_EXITLINK_UP ? "# " : "",
696 cnf->smart_gw_weight_exitlink_up);
699 "# The weighing factor for the gateway downlink bandwidth (exit link, downlink).\n"
700 "# See README-Olsr-Extensions for a description of smart gateways.\n"
701 "# (default is %lu)\n"
702 "\n", (long unsigned int)DEF_GW_WEIGHT_EXITLINK_DOWN);
703 abuf_appendf(out, "%sSmartGatewayWeightExitLinkDown %d\n",
704 cnf->smart_gw_weight_exitlink_down == DEF_GW_WEIGHT_EXITLINK_DOWN ? "# " : "",
705 cnf->smart_gw_weight_exitlink_down);
708 "# The weighing factor for the ETX costs.\n"
709 "# See README-Olsr-Extensions for a description of smart gateways.\n"
710 "# (default is %u)\n"
711 "\n", DEF_GW_WEIGHT_ETX);
712 abuf_appendf(out, "%sSmartGatewayWeightEtx %d\n",
713 cnf->smart_gw_weight_etx == DEF_GW_WEIGHT_ETX ? "# " : "",
714 cnf->smart_gw_weight_etx);
717 "# The divider for the ETX costs.\n"
718 "# See README-Olsr-Extensions for a description of smart gateways.\n"
719 "# (default is %u)\n"
720 "\n", DEF_GW_DIVIDER_ETX);
721 abuf_appendf(out, "%sSmartGatewayDividerEtx %d\n",
722 cnf->smart_gw_divider_etx == DEF_GW_DIVIDER_ETX ? "# " : "",
723 cnf->smart_gw_divider_etx);
726 "# Defines what kind of Uplink this node will publish as a\n"
727 "# smartgateway. The existence of the uplink is detected by\n"
728 "# a route to 0.0.0.0/0, ::ffff:0:0/96 and/or 2000::/3.\n"
729 "# possible values are \"none\", \"ipv4\", \"ipv6\", \"both\"\n"
730 "# (default is \"%s\")\n"
731 "\n", GW_UPLINK_TXT[DEF_GW_TYPE]);
732 abuf_appendf(out, "%sSmartGatewayUplink \"%s\"\n",
733 cnf->smart_gw_type == DEF_GW_TYPE ? "# " : "",
734 GW_UPLINK_TXT[cnf->smart_gw_type]);
737 "# Specifies if the local ipv4 uplink use NAT\n"
738 "# (default is \"%s\")\n"
739 "\n", DEF_GW_UPLINK_NAT ? "yes" : "no");
740 abuf_appendf(out, "%sSmartGatewayUplinkNAT %s\n",
741 cnf->smart_gw_uplink_nat == DEF_GW_UPLINK_NAT ? "# " : "",
742 cnf->smart_gw_uplink_nat ? "yes" : "no");
745 "# Specifies the speed of the uplink in kilobit/s.\n"
746 "# First parameter is upstream, second parameter is downstream\n"
747 "# (default is %u/%u)\n"
748 "\n", DEF_UPLINK_SPEED, DEF_DOWNLINK_SPEED);
749 abuf_appendf(out, "%sSmartGatewaySpeed %d %d\n",
750 cnf->smart_gw_uplink == DEF_UPLINK_SPEED && cnf->smart_gw_downlink == DEF_DOWNLINK_SPEED ? "# " : "",
751 cnf->smart_gw_uplink, cnf->smart_gw_downlink);
754 "# Specifies the EXTERNAL ipv6 prefix of the uplink. A prefix\n"
755 "# length of more than 64 is not allowed.\n"
756 "# (default is 0::/0\n"
758 abuf_appendf(out, "%sSmartGatewayPrefix %s\n",
759 cnf->smart_gw_prefix.prefix_len == 0 ? "# " : "",
760 olsr_ip_prefix_to_string(&cnf->smart_gw_prefix));
763 "##############################\n"
764 "### OLSR protocol settings ###\n"
765 "##############################\n"
767 "# For testing purposes it may be nice to use another port for olsrd\n"
768 "# for using another port than the IANA assigned one \n"
769 "# for a production network, there should be a good reason!!\n"
770 "# valid values are integers greater than 1, please be careful with\n"
771 "# using reserved port numbers\n"
772 "# (default is %u, the IANA assigned olsr-port)\n"
774 abuf_appendf(out, "%sOlsrPort %u\n",
775 cnf->olsrport == DEF_OLSRPORT ? "# " : "",
779 "# Sets the main IP (originator ip) of the router. This IP will NEVER\n"
780 "# change during the uptime of olsrd.\n"
781 "# (default is 0.0.0.0, which triggers usage of the IP of the first interface)\n"
783 abuf_appendf(out, "MainIp %s\n",
784 olsr_ip_to_string(&ipbuf, &cnf->main_addr));
787 "# The fixed willingness to use (0-7)\n"
788 "# If not set willingness will be calculated\n"
789 "# dynamically based on battery/power status\n"
790 "# (default is %u)\n"
791 "\n", DEF_WILLINGNESS);
792 abuf_appendf(out, "%sWillingness %u\n",
793 cnf->willingness == DEF_WILLINGNESS ? "# " : "",
797 "# HNA (Host network association) allows the OLSR to announce\n"
798 "# additional IPs or IP subnets to the net that are reachable\n"
799 "# through this node.\n"
800 "# Syntax for HNA4 is \"network-address network-mask\"\n"
801 "# Syntax for HNA6 is \"network-address prefix-length\"\n"
802 "# (default is no HNA)\n");
803 abuf_appendf(out, "Hna%u\n"
805 cnf->ip_version == AF_INET ? 4 : 6);
807 struct ipaddr_str strbuf;
808 abuf_appendf(out, " %s\n", olsr_ip_prefix_to_string(&hna->net));
814 "# Hysteresis for link sensing (only for hopcount metric)\n"
815 "# Hysteresis adds more robustness to the link sensing\n"
816 "# but delays neighbor registration.\n"
817 "# (default is %s)\n"
818 "\n", DEF_USE_HYST ? "yes" : "no");
819 abuf_appendf(out, "%sUseHysteresis %s\n",
820 cnf->use_hysteresis == DEF_USE_HYST ? "# " : "",
821 cnf->use_hysteresis ? "yes" : "no");
824 "# Hysteresis parameters (only for hopcount metric)\n"
825 "# Do not alter these unless you know what you are doing!\n"
826 "# Set to auto by default. Allowed values are floating point\n"
827 "# values in the interval 0,1\n"
828 "# THR_LOW must always be lower than THR_HIGH!!\n"
829 "# (default is %.2f/%.2f/%.2f)\n"
830 "\n", (double)HYST_SCALING, (double)HYST_THRESHOLD_HIGH, (double)HYST_THRESHOLD_LOW);
831 abuf_appendf(out, "%sHystScaling %.2f\n",
832 cnf->hysteresis_param.scaling == (float)HYST_SCALING ? "# " : "",
833 (double)cnf->hysteresis_param.scaling);
834 abuf_appendf(out, "%sHystThrHigh %.2f\n",
835 cnf->hysteresis_param.thr_high == (float)HYST_THRESHOLD_HIGH ? "# " : "",
836 (double)cnf->hysteresis_param.thr_high);
837 abuf_appendf(out, "%sHystThrLow %.2f\n",
838 cnf->hysteresis_param.thr_low == (float)HYST_THRESHOLD_LOW ? "# " : "",
839 (double)cnf->hysteresis_param.thr_low);
843 "# Specifies how much neighbor info should be sent in\n"
844 "# TC messages. Because of a design problem in the 0.5.x\n"
845 "# dijkstra implementation this value must be set to 2.\n"
846 "# 2 - send all neighbors\n"
847 "# (default is %u)\n"
848 "\n", TC_REDUNDANCY);
849 abuf_appendf(out, "%sTcRedundancy %d\n",
850 cnf->tc_redundancy == TC_REDUNDANCY ? "# " : "",
854 "# MPR coverage specifies how many MPRs a node should\n"
855 "# try select to reach every 2 hop neighbor. Because of\n"
856 "# a design problem in the 0.5.x dijkstra algorithm this\n"
857 "# value should be set to 7.\n"
858 "# (default is %u)\n"
860 abuf_appendf(out, "%sMprCoverage %d\n",
861 cnf->mpr_coverage == MPR_COVERAGE ? "# " : "",
865 "################################\n"
866 "### OLSR protocol extensions ###\n"
867 "################################\n"
869 "# Link quality level switch between hopcount and \n"
870 "# cost-based (mostly ETX) routing. Because of\n"
871 "# a design problem in the 0.5.x dijkstra algorithm this\n"
872 "# value should not be set to 1.\n"
873 "# 0 = do not use link quality\n"
874 "# 2 = use link quality for MPR selection and routing\n"
875 "# (default is %u)\n"
877 abuf_appendf(out, "%sLinkQualityLevel %d\n",
878 cnf->lq_level == DEF_LQ_LEVEL ? "# " : "",
882 "# Link quality algorithm (only for lq level 2)\n"
883 "# (see README-Olsr-Extensions)\n"
884 "# - \"etx_float\", a floating point ETX with exponential aging\n"
885 "# - \"etx_fpm\", same as ext_float, but with integer arithmetic\n"
886 "# - \"etx_ff\" (ETX freifunk), an etx variant which use all OLSR\n"
887 "# traffic (instead of only hellos) for ETX calculation\n"
888 "# - \"etx_ffeth\", an incompatible variant of etx_ff that allows\n"
889 "# ethernet links with ETX 0.1.\n"
890 "# (default is \"%s\")\n"
891 "\n", DEF_LQ_ALGORITHM);
892 abuf_appendf(out, "%sLinkQualityAlgorithm \"%s\"\n",
893 cnf->lq_algorithm == NULL ? "# " : "",
894 cnf->lq_algorithm == NULL ? DEF_LQ_ALGORITHM : cnf->lq_algorithm);
897 "# Link quality aging factor (only for lq level 2)\n"
898 "# Tuning parameter for etx_float and etx_fpm, smaller values\n"
899 "# mean slower changes of ETX value. (allowed values are\n"
900 "# between 0.01 and 1.0)\n"
901 "# (default is %.2f)\n"
902 "\n", (double)DEF_LQ_AGING);
903 abuf_appendf(out, "%sLinkQualityAging %.2f\n",
904 cnf->lq_aging == (float)DEF_LQ_AGING ? "# " : "",
905 (double)cnf->lq_aging);
908 "# Fisheye mechanism for TCs (0 meansoff, 1 means on)\n"
909 "# (default is %u)\n"
911 abuf_appendf(out, "%sLinkQualityFishEye %d\n",
912 cnf->lq_fish == DEF_LQ_FISH ? "# " : "",
919 "# (currently this is only in the freifunk firmware)\n"
920 "# If the NAT-Endpoint (the preferred 0/0 HNA emitting node)\n"
921 "# is to be changed, the ETX value of the current 0/0 is \n"
922 "# multiplied with the NatThreshold value before being\n"
923 "# compared to the new one.\n"
924 "# The parameter can be a value between 0.1 and 1.0, but\n"
925 "# should be close to 1.0 if changed.\n"
926 "# WARNING: This parameter should not be used together with\n"
927 "# the etx_ffeth metric !!\n"
928 "# (default is %.1f)\n"
929 "\n", (double)DEF_LQ_NAT_THRESH);
930 abuf_appendf(out, "%sNatThreshold %.1f\n",
931 cnf->lq_nat_thresh == (float)DEF_LQ_NAT_THRESH ? "# " : "",
932 (double)cnf->lq_nat_thresh);
936 "#############################################################\n"
937 "### Configuration of the IPC to the windows GUI interface ###\n"
938 "#############################################################\n"
942 " # Determines how many simultaneously\n"
943 " # IPC connections that will be allowed\n"
944 " # Setting this to 0 disables IPC\n"
946 abuf_appendf(out, " %sMaxConnections %d\n",
947 cnf->ipc_connections == DEF_IPC_CONNECTIONS ? "# " : "",
948 cnf->ipc_connections);
951 " # By default only 127.0.0.1 is allowed\n"
952 " # to connect. Here allowed hosts and networks can\n"
957 if (ipc_nets->net.prefix_len == olsr_cnf->maxplen) {
958 abuf_appendf(out, " Host %s\n", olsr_ip_to_string(&ipbuf, &ipc_nets->net.prefix));
960 abuf_appendf(out, " Net %s\n", olsr_ip_prefix_to_string(&ipc_nets->net));
962 ipc_nets = ipc_nets->next;
967 "#####################################\n"
968 "### Example plugin configurations ###\n"
969 "#####################################\n"
970 "# Olsrd plugins to load\n"
971 "# This must be the absolute path to the file\n"
972 "# or the loader will use the following scheme:\n"
973 "# - Try the paths in the LD_LIBRARY_PATH \n"
974 "# environment variable.\n"
975 "# - The list of libraries cached in /etc/ld.so.cache\n"
976 "# - /lib, followed by /usr/lib\n"
980 abuf_appendf(out, "LoadPlugin \"%s\" {\n", plugins->name);
981 pl_param = plugins->params;
983 abuf_appendf(out, " PlParam \"%s\"\t\"%s\"\n", pl_param->key, pl_param->value);
984 pl_param = pl_param->next;
988 plugins = plugins->next;
992 "#############################################\n"
993 "### OLSRD default interface configuration ###\n"
994 "#############################################\n"
995 "# the default interface section can have the same values as the following\n"
996 "# interface configuration. It will allow you so set common options for all\n"
999 "InterfaceDefaults\n");
1000 olsrd_write_if_autobuf(out, cnf->interface_defaults, false);
1003 "######################################\n"
1004 "### OLSRd Interfaces configuration ###\n"
1005 "######################################\n"
1006 "# multiple interfaces can be specified for a single configuration block\n"
1007 "# multiple configuration blocks can be specified\n"
1011 abuf_appendf(out, "Interface \"%s\"\n", interf->name);
1012 olsrd_write_if_autobuf(out, interf->cnf, first);
1015 interf = interf->next;
1020 "# END AUTOGENERATED CONFIG\n");
1025 * indent-tabs-mode: nil