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.
39 * $Id: olsrd_conf.c,v 1.33 2005/02/17 17:21:24 kattemat Exp $
47 #include <sys/types.h>
48 #include <sys/socket.h>
49 #include <netinet/in.h>
50 #include <arpa/inet.h>
52 #include "olsrd_conf.h"
56 extern int yyparse(void);
58 static char copyright_string[] = "The olsr.org Optimized Link-State Routing daemon(olsrd) Copyright (c) 2004, Andreas Tønnesen(andreto@olsr.org) All rights reserved.";
64 void __attribute__ ((constructor))
67 void __attribute__ ((destructor))
77 /* Print plugin info to stdout */
78 printf("olsrd config file parser %s loaded\n", PARSER_VERSION);
89 printf("See you around!\n");
97 /* Build as standalone binary */
99 main(int argc, char *argv[])
101 struct olsrd_config *cnf;
105 fprintf(stderr, "Usage: olsrd_cfgparser [filename] -print\n\n");
109 if((cnf = olsrd_parse_cnf(argv[1])) != NULL)
111 if((argc > 2) && (!strcmp(argv[2], "-print")))
113 olsrd_print_cnf(cnf);
114 olsrd_write_cnf(cnf, "./out.conf");
117 printf("Use -print to view parsed values\n");
118 printf("Configfile parsed OK\n");
122 printf("Failed parsing \"%s\"\n", argv[1]);
130 /* Build as part of olsrd */
137 struct olsrd_config *
138 olsrd_parse_cnf(const char *filename)
140 struct olsr_if *in, *new_ifqueue, *in_tmp;
142 /* Stop the compiler from complaining */
143 strlen(copyright_string);
145 cnf = malloc(sizeof(struct olsrd_config));
148 fprintf(stderr, "Out of memory %s\n", __func__);
152 set_default_cnf(cnf);
154 printf("Parsing file: \"%s\"\n", filename);
156 yyin = fopen(filename, "r");
160 fprintf(stderr, "Cannot open configuration file '%s': %s.\n",
161 filename, strerror(errno));
177 /* Reverse the queue (added by user request) */
178 in = cnf->interfaces;
186 in_tmp->next = new_ifqueue;
187 new_ifqueue = in_tmp;
190 cnf->interfaces = new_ifqueue;
192 in = cnf->interfaces;
196 /* set various stuff */
197 in->index = cnf->ifcnt++;
198 in->configured = OLSR_FALSE;
209 olsrd_sanity_check_cnf(struct olsrd_config *cnf)
211 struct olsr_if *in = cnf->interfaces;
212 struct if_config_options *io;
215 if(cnf->debug_level < MIN_DEBUGLVL ||
216 cnf->debug_level > MAX_DEBUGLVL)
218 fprintf(stderr, "Debuglevel %d is not allowed\n", cnf->debug_level);
223 if(cnf->ip_version != AF_INET &&
224 cnf->ip_version != AF_INET6)
226 fprintf(stderr, "Ipversion %d not allowed!\n", cnf->ip_version);
231 if(//cnf->tos < MIN_TOS ||
234 fprintf(stderr, "TOS %d is not allowed\n", cnf->tos);
238 if(cnf->willingness_auto == OLSR_FALSE &&
239 (cnf->willingness < MIN_WILLINGNESS ||
240 cnf->willingness > MAX_WILLINGNESS))
242 fprintf(stderr, "Willingness %d is not allowed\n", cnf->willingness);
247 if(cnf->use_hysteresis == OLSR_TRUE)
249 if(cnf->hysteresis_param.scaling < MIN_HYST_PARAM ||
250 cnf->hysteresis_param.scaling > MAX_HYST_PARAM)
252 fprintf(stderr, "Hyst scaling %0.2f is not allowed\n", cnf->hysteresis_param.scaling);
256 if(cnf->hysteresis_param.thr_high <= cnf->hysteresis_param.thr_low)
258 fprintf(stderr, "Hyst upper(%0.2f) thr must be bigger than lower(%0.2f) threshold!\n", cnf->hysteresis_param.thr_high, cnf->hysteresis_param.thr_low);
262 if(cnf->hysteresis_param.thr_high < MIN_HYST_PARAM ||
263 cnf->hysteresis_param.thr_high > MAX_HYST_PARAM)
265 fprintf(stderr, "Hyst upper thr %0.2f is not allowed\n", cnf->hysteresis_param.thr_high);
269 if(cnf->hysteresis_param.thr_low < MIN_HYST_PARAM ||
270 cnf->hysteresis_param.thr_low > MAX_HYST_PARAM)
272 fprintf(stderr, "Hyst lower thr %0.2f is not allowed\n", cnf->hysteresis_param.thr_low);
279 if(cnf->pollrate < MIN_POLLRATE ||
280 cnf->pollrate > MAX_POLLRATE)
282 fprintf(stderr, "Pollrate %0.2f is not allowed\n", cnf->pollrate);
288 if(//cnf->tc_redundancy < MIN_TC_REDUNDANCY ||
289 cnf->tc_redundancy > MAX_TC_REDUNDANCY)
291 fprintf(stderr, "TC redundancy %d is not allowed\n", cnf->tc_redundancy);
296 if(cnf->mpr_coverage < MIN_MPR_COVERAGE ||
297 cnf->mpr_coverage > MAX_MPR_COVERAGE)
299 fprintf(stderr, "MPR coverage %d is not allowed\n", cnf->mpr_coverage);
303 /* Link Q and hysteresis cannot be activated at the same time */
304 if(cnf->use_hysteresis == OLSR_TRUE && cnf->lq_level)
306 fprintf(stderr, "Hysteresis and LinkQuality cannot both be active! Deactivate one of them.\n");
310 /* Link quality level */
312 if(cnf->lq_level > MAX_LQ_LEVEL)
314 fprintf(stderr, "LQ level %d is not allowed\n", cnf->lq_level);
318 /* Link quality window size */
319 if(cnf->lq_level && (cnf->lq_wsize < MIN_LQ_WSIZE || cnf->lq_wsize > MAX_LQ_WSIZE))
321 fprintf(stderr, "LQ window size %d is not allowed\n", cnf->lq_wsize);
327 fprintf(stderr, "No interfaces configured!\n");
336 if(in->name == NULL || !strlen(in->name))
338 fprintf(stderr, "Interface has no name!\n");
344 fprintf(stderr, "Interface %s has no configuration!\n", in->name);
349 if(io->hello_params.emission_interval < cnf->pollrate ||
350 io->hello_params.emission_interval > io->hello_params.validity_time)
352 fprintf(stderr, "Bad HELLO parameters! (em: %0.2f, vt: %0.2f)\n", io->hello_params.emission_interval, io->hello_params.validity_time);
357 if(io->tc_params.emission_interval < cnf->pollrate ||
358 io->tc_params.emission_interval > io->tc_params.validity_time)
360 fprintf(stderr, "Bad TC parameters! (em: %0.2f, vt: %0.2f)\n", io->tc_params.emission_interval, io->tc_params.validity_time);
365 if(io->mid_params.emission_interval < cnf->pollrate ||
366 io->mid_params.emission_interval > io->mid_params.validity_time)
368 fprintf(stderr, "Bad MID parameters! (em: %0.2f, vt: %0.2f)\n", io->mid_params.emission_interval, io->mid_params.validity_time);
373 if(io->hna_params.emission_interval < cnf->pollrate ||
374 io->hna_params.emission_interval > io->hna_params.validity_time)
376 fprintf(stderr, "Bad HNA parameters! (em: %0.2f, vt: %0.2f)\n", io->hna_params.emission_interval, io->hna_params.validity_time);
388 olsrd_free_cnf(struct olsrd_config *cnf)
390 struct hna4_entry *h4d, *h4 = cnf->hna4_entries;
391 struct hna6_entry *h6d, *h6 = cnf->hna6_entries;
392 struct olsr_if *ind, *in = cnf->interfaces;
393 struct plugin_entry *ped, *pe = cnf->plugins;
394 struct olsr_lq_mult *mult, *next_mult;
412 for (mult = in->cnf->lq_mult; mult != NULL; mult = next_mult)
414 next_mult = mult->next;
439 struct olsrd_config *
440 olsrd_get_default_cnf()
442 cnf = malloc(sizeof(struct olsrd_config));
445 fprintf(stderr, "Out of memory %s\n", __func__);
449 set_default_cnf(cnf);
458 set_default_cnf(struct olsrd_config *cnf)
460 memset(cnf, 0, sizeof(struct olsrd_config));
462 cnf->debug_level = DEF_DEBUGLVL;
463 cnf->ip_version = AF_INET;
464 cnf->allow_no_interfaces = DEF_ALLOW_NO_INTS;
466 cnf->willingness_auto = DEF_WILL_AUTO;
467 cnf->ipc_connections = DEF_IPC_CONNECTIONS;
468 cnf->open_ipc = cnf->ipc_connections ? OLSR_TRUE : OLSR_FALSE;
470 cnf->use_hysteresis = DEF_USE_HYST;
471 cnf->hysteresis_param.scaling = HYST_SCALING;
472 cnf->hysteresis_param.thr_high = HYST_THRESHOLD_HIGH;
473 cnf->hysteresis_param.thr_low = HYST_THRESHOLD_LOW;
475 cnf->pollrate = DEF_POLLRATE;
477 cnf->tc_redundancy = TC_REDUNDANCY;
478 cnf->mpr_coverage = MPR_COVERAGE;
479 cnf->lq_level = DEF_LQ_LEVEL;
480 cnf->lq_wsize = DEF_LQ_WSIZE;
481 cnf->clear_screen = DEF_CLEAR_SCREEN;
487 struct if_config_options *
488 get_default_if_config()
490 struct if_config_options *io = malloc(sizeof(struct if_config_options));
493 memset(io, 0, sizeof(struct if_config_options));
495 io->ipv6_addrtype = 1; /* XXX - FixMe */
497 if(inet_pton(AF_INET6, OLSR_IPV6_MCAST_SITE_LOCAL, &in6) < 0)
499 fprintf(stderr, "Failed converting IP address %s\n", OLSR_IPV6_MCAST_SITE_LOCAL);
502 memcpy(&io->ipv6_multi_site.v6, &in6, sizeof(struct in6_addr));
504 if(inet_pton(AF_INET6, OLSR_IPV6_MCAST_GLOBAL, &in6) < 0)
506 fprintf(stderr, "Failed converting IP address %s\n", OLSR_IPV6_MCAST_GLOBAL);
509 memcpy(&io->ipv6_multi_glbl.v6, &in6, sizeof(struct in6_addr));
513 io->weight.fixed = OLSR_FALSE;
514 io->weight.value = 0;
516 io->hello_params.emission_interval = HELLO_INTERVAL;
517 io->hello_params.validity_time = NEIGHB_HOLD_TIME;
518 io->tc_params.emission_interval = TC_INTERVAL;
519 io->tc_params.validity_time = TOP_HOLD_TIME;
520 io->mid_params.emission_interval = MID_INTERVAL;
521 io->mid_params.validity_time = MID_HOLD_TIME;
522 io->hna_params.emission_interval = HNA_INTERVAL;
523 io->hna_params.validity_time = HNA_HOLD_TIME;
534 olsrd_write_cnf(struct olsrd_config *cnf, const char *fname)
536 struct hna4_entry *h4 = cnf->hna4_entries;
537 struct hna6_entry *h6 = cnf->hna6_entries;
538 struct olsr_if *in = cnf->interfaces;
539 struct plugin_entry *pe = cnf->plugins;
540 struct plugin_param *pp;
541 struct ipc_host *ih = cnf->ipc_hosts;
542 struct ipc_net *ie = cnf->ipc_nets;
543 struct olsr_lq_mult *mult;
545 char ipv6_buf[100]; /* buffer for IPv6 inet_htop */
550 fd = fopen(fname, "w");
554 fprintf(stderr, "Could not open file %s for writing\n%s\n", fname, strerror(errno));
558 printf("Writing config to file \"%s\".... ", fname);
560 fprintf(fd, "#\n# Configuration file for olsr.org olsrd\n# automatically generated by olsrd-cnf %s\n#\n\n\n", PARSER_VERSION);
563 fprintf(fd, "# Debug level(0-9)\n# If set to 0 the daemon runs in the background\n\nDebugLevel\t%d\n\n", cnf->debug_level);
566 if(cnf->ip_version == AF_INET6)
567 fprintf(fd, "# IP version to use (4 or 6)\n\nIpVersion\t6\n\n");
569 fprintf(fd, "# IP version to use (4 or 6)\n\nIpVersion\t4\n\n");
573 fprintf(fd, "# HNA IPv4 routes\n# syntax: netaddr netmask\n# Example Internet gateway:\n# 0.0.0.0 0.0.0.0\n\nHna4\n{\n");
576 in4.s_addr = h4->net.v4;
577 fprintf(fd, " %s ", inet_ntoa(in4));
578 in4.s_addr = h4->netmask.v4;
579 fprintf(fd, "%s\n", inet_ntoa(in4));
582 fprintf(fd, "}\n\n");
586 fprintf(fd, "# HNA IPv6 routes\n# syntax: netaddr prefix\n# Example Internet gateway:\nHna6\n{\n");
589 fprintf(fd, " %s/%d\n", (char *)inet_ntop(AF_INET6, &h6->net.v6, ipv6_buf, sizeof(ipv6_buf)), h6->prefix_len);
593 fprintf(fd, "}\n\n");
596 fprintf(fd, "# Should olsrd keep on running even if there are\n# no interfaces available? This is a good idea\n# for a PCMCIA/USB hotswap environment.\n# \"yes\" OR \"no\"\n\nAllowNoInt\t");
597 if(cnf->allow_no_interfaces)
598 fprintf(fd, "yes\n\n");
600 fprintf(fd, "no\n\n");
603 fprintf(fd, "# TOS(type of service) value for\n# the IP header of control traffic.\n# default is 16\n\n");
604 fprintf(fd, "TosValue\t%d\n\n", cnf->tos);
607 fprintf(fd, "# The fixed willingness to use(0-7)\n# If not set willingness will be calculated\n# dynammically based on battery/power status\n\n");
608 if(cnf->willingness_auto)
609 fprintf(fd, "#Willingness\t4\n\n");
611 fprintf(fd, "Willingness%d\n\n", cnf->willingness);
614 fprintf(fd, "# Allow processes like the GUI front-end\n# to connect to the daemon.\n\n");
615 fprintf(fd, "IpcConnect\n{\n");
616 fprintf(fd, " MaxConnections %d\n\n", cnf->ipc_connections);
620 in4.s_addr = ih->host.v4;
621 fprintf(fd, " Host %s\n", inet_ntoa(in4));
627 in4.s_addr = ie->net.v4;
628 fprintf(fd, " Net %s ", inet_ntoa(in4));
629 in4.s_addr = ie->mask.v4;
630 fprintf(fd, "%s\n", inet_ntoa(in4));
634 fprintf(fd, "}\n\n");
639 fprintf(fd, "# Wether to use hysteresis or not\n# Hysteresis adds more robustness to the\n# link sensing but delays neighbor registration.\n# Used by default. 'yes' or 'no'\n\n");
641 if(cnf->use_hysteresis)
643 fprintf(fd, "UseHysteresis\tyes\n\n");
644 fprintf(fd, "# Hysteresis parameters\n# Do not alter these unless you know \n# what you are doing!\n# Set to auto by default. Allowed\n# values are floating point values\n# in the interval 0,1\n# THR_LOW must always be lower than\n# THR_HIGH!!\n\n");
645 fprintf(fd, "HystScaling\t%0.2f\n", cnf->hysteresis_param.scaling);
646 fprintf(fd, "HystThrHigh\t%0.2f\n", cnf->hysteresis_param.thr_high);
647 fprintf(fd, "HystThrLow\t%0.2f\n", cnf->hysteresis_param.thr_low);
650 fprintf(fd, "UseHysteresis\tno\n\n");
655 fprintf(fd, "# Polling rate in seconds(float).\n# Auto uses default value 0.05 sec\n\n");
656 fprintf(fd, "Pollrate\t%0.2f\n", cnf->pollrate);
659 fprintf(fd, "# TC redundancy\n# Specifies how much neighbor info should\n# be sent in TC messages\n# Possible values are:\n# 0 - only send MPR selectors\n# 1 - send MPR selectors and MPRs\n# 2 - send all neighbors\n#\n# defaults to 0\n\n");
660 fprintf(fd, "TcRedundancy\t%d\n\n", cnf->tc_redundancy);
663 fprintf(fd, "# MPR coverage\n# Specifies how many MPRs a node should\n# try select to reach every 2 hop neighbor\n# Can be set to any integer >0\n# defaults to 1\n\n");
665 fprintf(fd, "MprCoverage\t%d\n\n", cnf->mpr_coverage);
667 fprintf(fd, "# Link quality level\n# 0 = do not use link quality\n# 1 = use link quality for MPR selection\n# 2 = use link quality for MPR selection and routing\n\n");
668 fprintf(fd, "LinkQualityLevel\t%d\n\n", cnf->lq_level);
670 fprintf(fd, "# Link quality window size\n\n");
671 fprintf(fd, "LinkQualityWinSize\t%d\n\n", cnf->lq_wsize);
673 fprintf(fd, "# Clear screen when printing debug output?\n\n");
674 fprintf(fd, "ClearScreen\t%s\n\n", cnf->clear_screen ? "yes" : "no");
677 fprintf(fd, "# Olsrd plugins to load\n# This must be the absolute path to the file\n# or the loader will use the following scheme:\n# - Try the paths in the LD_LIBRARY_PATH \n# environment variable.\n# - The list of libraries cached in /etc/ld.so.cache\n# - /lib, followed by /usr/lib\n\n");
682 fprintf(fd, "LoadPlugin \"%s\"\n{\n", pe->name);
686 fprintf(fd, " PlParam \"%s\" \"%s\"\n", pp->key, pp->value);
699 fprintf(fd, "# Interfaces\n\n");
705 fprintf(fd, "Interface \"%s\"\n{\n", in->name);
708 fprintf(fd, " # IPv4 broadcast address to use. The\n # one usefull example would be 255.255.255.255\n # If not defined the broadcastaddress\n # every card is configured with is used\n\n");
710 if(in->cnf->ipv4_broadcast.v4)
712 in4.s_addr = in->cnf->ipv4_broadcast.v4;
713 fprintf(fd, " Ip4Broadcast\t %s\n\n", inet_ntoa(in4));
717 fprintf(fd, " #Ip4Broadcast\t255.255.255.255\n\n");
721 fprintf(fd, " # IPv6 address scope to use.\n # Must be 'site-local' or 'global'\n\n");
722 if(in->cnf->ipv6_addrtype)
723 fprintf(fd, " Ip6AddrType \tsite-local\n\n");
725 fprintf(fd, " Ip6AddrType \tglobal\n\n");
727 fprintf(fd, " # IPv6 multicast address to use when\n # using site-local addresses.\n # If not defined, ff05::15 is used\n");
728 fprintf(fd, " Ip6MulticastSite\t%s\n\n", (char *)inet_ntop(AF_INET6, &in->cnf->ipv6_multi_site.v6, ipv6_buf, sizeof(ipv6_buf)));
729 fprintf(fd, " # IPv6 multicast address to use when\n # using global addresses\n # If not defined, ff0e::1 is used\n");
730 fprintf(fd, " Ip6MulticastGlobal\t%s\n\n", (char *)inet_ntop(AF_INET6, &in->cnf->ipv6_multi_glbl.v6, ipv6_buf, sizeof(ipv6_buf)));
734 fprintf(fd, " # Emission and validity intervals.\n # If not defined, RFC proposed values will\n # in most cases be used.\n\n");
737 if(in->cnf->hello_params.emission_interval != HELLO_INTERVAL)
738 fprintf(fd, " HelloInterval\t%0.2f\n", in->cnf->hello_params.emission_interval);
740 fprintf(fd, " #HelloInterval\t%0.2f\n", in->cnf->hello_params.emission_interval);
741 if(in->cnf->hello_params.validity_time != NEIGHB_HOLD_TIME)
742 fprintf(fd, " HelloValidityTime\t%0.2f\n", in->cnf->hello_params.validity_time);
744 fprintf(fd, " #HelloValidityTime\t%0.2f\n", in->cnf->hello_params.validity_time);
745 if(in->cnf->tc_params.emission_interval != TC_INTERVAL)
746 fprintf(fd, " TcInterval\t\t%0.2f\n", in->cnf->tc_params.emission_interval);
748 fprintf(fd, " #TcInterval\t\t%0.2f\n", in->cnf->tc_params.emission_interval);
749 if(in->cnf->tc_params.validity_time != TOP_HOLD_TIME)
750 fprintf(fd, " TcValidityTime\t%0.2f\n", in->cnf->tc_params.validity_time);
752 fprintf(fd, " #TcValidityTime\t%0.2f\n", in->cnf->tc_params.validity_time);
753 if(in->cnf->mid_params.emission_interval != MID_INTERVAL)
754 fprintf(fd, " MidInterval\t\t%0.2f\n", in->cnf->mid_params.emission_interval);
756 fprintf(fd, " #MidInterval\t%0.2f\n", in->cnf->mid_params.emission_interval);
757 if(in->cnf->mid_params.validity_time != MID_HOLD_TIME)
758 fprintf(fd, " MidValidityTime\t%0.2f\n", in->cnf->mid_params.validity_time);
760 fprintf(fd, " #MidValidityTime\t%0.2f\n", in->cnf->mid_params.validity_time);
761 if(in->cnf->hna_params.emission_interval != HNA_INTERVAL)
762 fprintf(fd, " HnaInterval\t\t%0.2f\n", in->cnf->hna_params.emission_interval);
764 fprintf(fd, " #HnaInterval\t%0.2f\n", in->cnf->hna_params.emission_interval);
765 if(in->cnf->hna_params.validity_time != HNA_HOLD_TIME)
766 fprintf(fd, " HnaValidityTime\t%0.2f\n", in->cnf->hna_params.validity_time);
768 fprintf(fd, " #HnaValidityTime\t%0.2f\n", in->cnf->hna_params.validity_time);
770 mult = in->cnf->lq_mult;
773 fprintf(fd, " #LinkQualityMult\tdefault 1.0\n");
779 inet_ntop(cnf->ip_version, &mult->addr, ipv6_buf,
782 fprintf(fd, " LinkQualityMult\t%s %0.2f\n",
783 ipv6_buf, mult->val);
789 fprintf(fd, "}\n\n");
796 fprintf(fd, "\n# END AUTOGENERATED CONFIG\n");
809 olsrd_print_cnf(struct olsrd_config *cnf)
811 struct hna4_entry *h4 = cnf->hna4_entries;
812 struct hna6_entry *h6 = cnf->hna6_entries;
813 struct olsr_if *in = cnf->interfaces;
814 struct plugin_entry *pe = cnf->plugins;
815 struct ipc_host *ih = cnf->ipc_hosts;
816 struct ipc_net *ie = cnf->ipc_nets;
817 struct olsr_lq_mult *mult;
818 char ipv6_buf[100]; /* buffer for IPv6 inet_htop */
821 printf(" *** olsrd configuration ***\n");
823 printf("Debug Level : %d\n", cnf->debug_level);
824 if(cnf->ip_version == AF_INET6)
825 printf("IpVersion : 6\n");
827 printf("IpVersion : 4\n");
828 if(cnf->allow_no_interfaces)
829 printf("No interfaces : ALLOWED\n");
831 printf("No interfaces : NOT ALLOWED\n");
832 printf("TOS : 0x%02x\n", cnf->tos);
833 if(cnf->willingness_auto)
834 printf("Willingness : AUTO\n");
836 printf("Willingness : %d\n", cnf->willingness);
838 printf("IPC connections : %d\n", cnf->ipc_connections);
842 in4.s_addr = ih->host.v4;
843 printf("\tHost %s\n", inet_ntoa(in4));
849 in4.s_addr = ie->net.v4;
850 printf("\tNet %s/", inet_ntoa(in4));
851 in4.s_addr = ie->mask.v4;
852 printf("%s\n", inet_ntoa(in4));
857 printf("Pollrate : %0.2f\n", cnf->pollrate);
859 printf("TC redundancy : %d\n", cnf->tc_redundancy);
861 printf("MPR coverage : %d\n", cnf->mpr_coverage);
863 printf("LQ level : %d\n", cnf->lq_level);
865 printf("LQ window size : %d\n", cnf->lq_wsize);
867 printf("Clear screen : %s\n", cnf->clear_screen ? "yes" : "no");
872 printf("Interfaces:\n");
875 printf(" dev: \"%s\"\n", in->name);
877 if(in->cnf->ipv4_broadcast.v4)
879 in4.s_addr = in->cnf->ipv4_broadcast.v4;
880 printf("\tIPv4 broadcast : %s\n", inet_ntoa(in4));
884 printf("\tIPv4 broadcast : AUTO\n");
887 if(in->cnf->ipv6_addrtype)
888 printf("\tIPv6 addrtype : %s\n", in->cnf->ipv6_addrtype ? "site-local" : "global");
890 //union olsr_ip_addr ipv6_multi_site;
891 //union olsr_ip_addr ipv6_multi_glbl;
892 printf("\tIPv6 multicast site/glbl : %s", (char *)inet_ntop(AF_INET6, &in->cnf->ipv6_multi_site.v6, ipv6_buf, sizeof(ipv6_buf)));
893 printf("/%s\n", (char *)inet_ntop(AF_INET6, &in->cnf->ipv6_multi_glbl.v6, ipv6_buf, sizeof(ipv6_buf)));
895 printf("\tHELLO emission/validity : %0.2f/%0.2f\n", in->cnf->hello_params.emission_interval, in->cnf->hello_params.validity_time);
896 printf("\tTC emission/validity : %0.2f/%0.2f\n", in->cnf->tc_params.emission_interval, in->cnf->tc_params.validity_time);
897 printf("\tMID emission/validity : %0.2f/%0.2f\n", in->cnf->mid_params.emission_interval, in->cnf->mid_params.validity_time);
898 printf("\tHNA emission/validity : %0.2f/%0.2f\n", in->cnf->hna_params.emission_interval, in->cnf->hna_params.validity_time);
900 for (mult = in->cnf->lq_mult; mult != NULL; mult = mult->next)
902 inet_ntop(cnf->ip_version, &mult->addr, ipv6_buf,
905 printf("\tLinkQualityMult : %s %0.2f\n",
906 ipv6_buf, mult->val);
919 printf("Plugins:\n");
923 printf("\tName: \"%s\"\n", pe->name);
929 if(cnf->use_hysteresis)
931 printf("Using hysteresis:\n");
932 printf("\tScaling : %0.2f\n", cnf->hysteresis_param.scaling);
933 printf("\tThr high/low : %0.2f/%0.2f\n", cnf->hysteresis_param.thr_high, cnf->hysteresis_param.thr_low);
936 printf("Not using hysteresis\n");
942 printf("HNA4 entries:\n");
945 in4.s_addr = h4->net.v4;
946 printf("\t%s/", inet_ntoa(in4));
947 in4.s_addr = h4->netmask.v4;
948 printf("%s\n", inet_ntoa(in4));
957 printf("HNA6 entries:\n");
960 printf("\t%s/%d\n", (char *)inet_ntop(AF_INET6, &h6->net.v6, ipv6_buf, sizeof(ipv6_buf)), h6->prefix_len);
966 void *olsrd_cnf_malloc(unsigned int len)
971 void olsrd_cnf_free(void *addr)
976 #if defined WIN32_STDIO_HACK
983 CRITICAL_SECTION lock;
986 void win32_stdio_hack(unsigned int handle)
989 struct ioinfo **info;
991 lib = LoadLibrary("msvcrt.dll");
993 info = (struct ioinfo **)GetProcAddress(lib, "__pioinfo");
995 // (*info)[1].handle = handle;
996 // (*info)[1].attr = 0x89; // FOPEN | FTEXT | FPIPE;
998 (*info)[2].handle = handle;
999 (*info)[2].attr = 0x89;
1001 // stdout->_file = 1;
1004 // setbuf(stdout, NULL);
1005 setbuf(stderr, NULL);
1008 void win32_stdio_hack(unsigned int handle) {}