4 * The olsr.org Optimized Link-State Routing daemon(olsrd)
5 * Copyright (c) 2004, Andreas Tonnesen(andreto@olsr.org)
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of olsr.org, olsrd nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
35 * Visit http://www.olsr.org for more information.
37 * If you find this software useful feel free to make a donation
38 * to the project. For more information see the website or contact
39 * the copyright holders.
44 #include "olsrd_conf.h"
46 #include "../ipcalc.h"
47 #include "../net_olsr.h"
48 #include "../link_set.h"
54 #include <sys/types.h>
55 #include <sys/socket.h>
56 #include <netinet/in.h>
57 #include <arpa/inet.h>
60 #define PARSER_DEBUG 1
63 #define PARSER_DEBUG_PRINTF(x, args...) printf(x, ##args)
65 #define PARSER_DEBUG_PRINTF(x, args...) do { } while (0)
68 #define SET_IFS_CONF(ifs, ifcnt, field, value) do { \
69 for (; ifcnt>0; ifs=ifs->next, ifcnt--) { \
70 ifs->cnfi->field = (value); \
71 ifs->cnf->field = (value); \
75 #define YYSTYPE struct conf_token *
77 void yyerror(const char *);
80 static int ifs_in_curr_cfg = 0;
82 static int add_ipv6_addr(YYSTYPE ipaddr_arg, YYSTYPE prefixlen_arg);
84 static int lq_mult_helper(YYSTYPE ip_addr_arg, YYSTYPE mult_arg)
86 union olsr_ip_addr addr;
88 struct olsr_if *walker;
91 printf("\tLinkQualityMult %s %0.2f\n",
92 (ip_addr_arg != NULL) ? ip_addr_arg->string : "any",
96 memset(&addr, 0, sizeof(addr));
98 if (ip_addr_arg != NULL &&
99 inet_pton(olsr_cnf->ip_version, ip_addr_arg->string, &addr) <= 0) {
100 fprintf(stderr, "Cannot parse IP address %s.\n", ip_addr_arg->string);
104 walker = olsr_cnf->interfaces;
106 for (i = 0; i < ifs_in_curr_cfg; i++) {
107 struct olsr_lq_mult *mult = malloc(sizeof(*mult));
109 fprintf(stderr, "Out of memory (LQ multiplier).\n");
114 mult->value = (uint32_t)(mult_arg->floating * LINK_LOSS_MULTIPLIER);
116 mult->next = walker->cnf->lq_mult;
117 walker->cnfi->lq_mult = walker->cnf->lq_mult = mult;
118 walker->cnf->orig_lq_mult_cnt++;
119 walker->cnfi->orig_lq_mult_cnt=walker->cnf->orig_lq_mult_cnt;
121 walker = walker->next;
124 if (ip_addr_arg != NULL) {
125 free(ip_addr_arg->string);
134 static int add_ipv6_addr(YYSTYPE ipaddr_arg, YYSTYPE prefixlen_arg)
136 union olsr_ip_addr ipaddr;
137 PARSER_DEBUG_PRINTF("HNA IPv6 entry: %s/%d\n", ipaddr_arg->string, prefixlen_arg->integer);
139 if (olsr_cnf->ip_version != AF_INET6) {
140 fprintf(stderr, "IPv6 addresses can only be used if \"IpVersion\" == 6, skipping HNA6.\n");
141 olsr_startup_sleep(3);
144 if(inet_pton(AF_INET6, ipaddr_arg->string, &ipaddr) <= 0) {
145 fprintf(stderr, "ihna6entry: Failed converting IP address %s\n", ipaddr_arg->string);
149 if (prefixlen_arg->integer > 128) {
150 fprintf(stderr, "ihna6entry: Illegal IPv6 prefix length %d\n", prefixlen_arg->integer);
155 ip_prefix_list_add(&olsr_cnf->hna_entries, &ipaddr, prefixlen_arg->integer);
157 free(ipaddr_arg->string);
177 %token TOK_DEBUGLEVEL
182 %token TOK_INTERFACE_DEFAULTS
189 %token TOK_RTTABLE_DEFAULT
190 %token TOK_RTTABLE_TUNNEL
191 %token TOK_RTTABLE_PRIORITY
192 %token TOK_RTTABLE_DEFAULTOLSR_PRIORITY
193 %token TOK_RTTABLE_TUNNEL_PRIORITY
194 %token TOK_RTTABLE_DEFAULT_PRIORITY
195 %token TOK_WILLINGNESS
203 %token TOK_NICCHGSPOLLRT
204 %token TOK_TCREDUNDANCY
205 %token TOK_MPRCOVERAGE
210 %token TOK_LQ_NAT_THRESH
212 %token TOK_CLEAR_SCREEN
214 %token TOK_MIN_TC_VTIME
218 %token TOK_SMART_GW_ALLOW_NAT
219 %token TOK_SMART_GW_UPLINK
220 %token TOK_SMART_GW_UPLINK_NAT
221 %token TOK_SMART_GW_SPEED
222 %token TOK_SMART_GW_PREFIX
223 %token TOK_SRC_IP_ROUTES
231 %token TOK_IPV4BROADCAST
232 %token TOK_IPV4MULTICAST
233 %token TOK_IPV6MULTICAST
245 %token TOK_AUTODETCHG
273 | irttable_defaultolsr_priority
274 | irttable_tunnel_priority
275 | irttable_default_priority
296 | bsmart_gw_allow_nat
298 | bsmart_gw_uplink_nat
305 block: TOK_HNA4 hna4body
313 hna4body: TOK_OPEN hna4stmts TOK_CLOSE
316 hna4stmts: | hna4stmts hna4stmt
323 hna6body: TOK_OPEN hna6stmts TOK_CLOSE
326 hna6stmts: | hna6stmts hna6stmt
333 ipcbody: TOK_OPEN ipcstmts TOK_CLOSE
336 ipcstmts: | ipcstmts ipcstmt
345 ifblock: ifstart ifnicks
348 ifnicks: | ifnicks ifnick
351 ifbody: TOK_OPEN ifstmts TOK_CLOSE
354 ifdbody: TOK_OPEN ifstmts TOK_CLOSE
356 struct olsr_if *in = olsr_cnf->interfaces;
357 printf("\nInterface Defaults");
358 /*remove Interface Defaults from Interface list as they are no interface!*/
359 olsr_cnf->interfaces = in->next;
361 /*free interface but keep its config intact?*/
368 ifstmts: | ifstmts ifstmt
391 plbody: TOK_OPEN plstmts TOK_CLOSE
394 plstmts: | plstmts plstmt
401 ifdblock: TOK_INTERFACE_DEFAULTS
403 struct olsr_if *in = malloc(sizeof(*in));
406 fprintf(stderr, "Out of memory(ADD IF)\n");
410 in->cnf = get_default_if_config();
411 in->cnfi = get_default_if_config();
413 if (in->cnf == NULL || in->cnfi == NULL) {
414 fprintf(stderr, "Out of memory(ADD DEFIFRULE)\n");
418 //should not need a name any more, as we free it on "}" again
419 //in->name = strdup(interface_defaults_name);
421 olsr_cnf->interface_defaults = in->cnf;
424 in->next = olsr_cnf->interfaces;
425 olsr_cnf->interfaces = in;
432 imaxipc: TOK_MAXIPC TOK_INTEGER
434 olsr_cnf->ipc_connections = $2->integer;
439 ipchost: TOK_HOSTLABEL TOK_IPV4_ADDR
441 union olsr_ip_addr ipaddr;
442 PARSER_DEBUG_PRINTF("\tIPC host: %s\n", $2->string);
444 if (inet_aton($2->string, &ipaddr.v4) == 0) {
445 fprintf(stderr, "Failed converting IP address IPC %s\n", $2->string);
449 ip_prefix_list_add(&olsr_cnf->ipc_nets, &ipaddr, olsr_cnf->maxplen);
456 ipcnet: TOK_NETLABEL TOK_IPV4_ADDR TOK_IPV4_ADDR
458 union olsr_ip_addr ipaddr, netmask;
460 PARSER_DEBUG_PRINTF("\tIPC net: %s/%s\n", $2->string, $3->string);
462 if (inet_pton(AF_INET, $2->string, &ipaddr.v4) == 0) {
463 fprintf(stderr, "Failed converting IP net IPC %s\n", $2->string);
467 if (inet_pton(AF_INET, $3->string, &netmask.v4) == 0) {
468 fprintf(stderr, "Failed converting IP mask IPC %s\n", $3->string);
472 ip_prefix_list_add(&olsr_cnf->ipc_nets, &ipaddr, olsr_netmask_to_prefix(&netmask));
479 | TOK_NETLABEL TOK_IPV4_ADDR TOK_SLASH TOK_INTEGER
481 union olsr_ip_addr ipaddr;
483 PARSER_DEBUG_PRINTF("\tIPC net: %s/%s\n", $2->string, $3->string);
485 if (inet_pton(AF_INET, $2->string, &ipaddr.v4) == 0) {
486 fprintf(stderr, "Failed converting IP net IPC %s\n", $2->string);
490 if ($4->integer > olsr_cnf->maxplen) {
491 fprintf(stderr, "ipcnet: Prefix len %u > %d is not allowed!\n", $4->integer, olsr_cnf->maxplen);
495 ip_prefix_list_add(&olsr_cnf->ipc_nets, &ipaddr, $4->integer);
503 iifweight: TOK_IFWEIGHT TOK_INTEGER
505 int ifcnt = ifs_in_curr_cfg;
506 struct olsr_if *ifs = olsr_cnf->interfaces;
508 PARSER_DEBUG_PRINTF("Fixed willingness: %d\n", $2->integer);
511 ifs->cnf->weight.value = $2->integer;
512 ifs->cnf->weight.fixed = true;
513 ifs->cnfi->weight.value = $2->integer;
514 ifs->cnfi->weight.fixed = true;
524 isetifmode: TOK_IFMODE TOK_STRING
526 int ifcnt = ifs_in_curr_cfg;
527 struct olsr_if *ifs = olsr_cnf->interfaces;
528 int mode = (strcmp($2->string, "ether") == 0)?IF_MODE_ETHER:IF_MODE_MESH;
530 PARSER_DEBUG_PRINTF("\tMode: %s\n", $2->string);
532 SET_IFS_CONF(ifs, ifcnt, mode, mode);
539 isetipv4br: TOK_IPV4BROADCAST TOK_IPV4_ADDR
542 int ifcnt = ifs_in_curr_cfg;
543 struct olsr_if *ifs = olsr_cnf->interfaces;
545 PARSER_DEBUG_PRINTF("\tIPv4 broadcast: %s\n", $2->string);
547 if (inet_aton($2->string, &in) == 0) {
548 fprintf(stderr, "isetipv4br: Failed converting IP address %s\n", $2->string);
552 SET_IFS_CONF(ifs, ifcnt, ipv4_multicast.v4, in);
559 isetipv4mc: TOK_IPV4MULTICAST TOK_IPV4_ADDR
562 int ifcnt = ifs_in_curr_cfg;
563 struct olsr_if *ifs = olsr_cnf->interfaces;
565 PARSER_DEBUG_PRINTF("\tIPv4 broadcast: %s\n", $2->string);
567 if (inet_aton($2->string, &in) == 0) {
568 fprintf(stderr, "isetipv4br: Failed converting IP address %s\n", $2->string);
572 SET_IFS_CONF(ifs, ifcnt, ipv4_multicast.v4, in);
579 isetipv6mc: TOK_IPV6MULTICAST TOK_IPV6_ADDR
582 int ifcnt = ifs_in_curr_cfg;
583 struct olsr_if *ifs = olsr_cnf->interfaces;
585 PARSER_DEBUG_PRINTF("\tIPv6 multicast: %s\n", $2->string);
587 if (inet_pton(AF_INET6, $2->string, &in6) <= 0) {
588 fprintf(stderr, "isetipv6mc: Failed converting IP address %s\n", $2->string);
592 SET_IFS_CONF(ifs, ifcnt, ipv6_multicast.v6, in6);
599 isetipv4src: TOK_IPV4SRC TOK_IPV4_ADDR
602 int ifcnt = ifs_in_curr_cfg;
603 struct olsr_if *ifs = olsr_cnf->interfaces;
605 PARSER_DEBUG_PRINTF("\tIPv4 src: %s\n", $2->string);
607 if (inet_aton($2->string, &in) == 0) {
608 fprintf(stderr, "isetipv4src: Failed converting IP address %s\n", $2->string);
612 SET_IFS_CONF(ifs, ifcnt, ipv4_src.v4, in);
619 isetipv6src: TOK_IPV6SRC TOK_IPV6_ADDR
621 struct olsr_ip_prefix pr6;
622 int ifcnt = ifs_in_curr_cfg;
623 struct olsr_if *ifs = olsr_cnf->interfaces;
625 PARSER_DEBUG_PRINTF("\tIPv6 src prefix: %s\n", $2->string);
627 if (olsr_string_to_prefix(AF_INET6, &pr6, $2->string) <= 0) {
628 fprintf(stderr, "isetipv6src: Failed converting IP prefix %s\n", $2->string);
632 SET_IFS_CONF(ifs, ifcnt, ipv6_src, pr6);
639 isethelloint: TOK_HELLOINT TOK_FLOAT
641 int ifcnt = ifs_in_curr_cfg;
642 struct olsr_if *ifs = olsr_cnf->interfaces;
644 PARSER_DEBUG_PRINTF("\tHELLO interval: %0.2f\n", $2->floating);
646 SET_IFS_CONF(ifs, ifcnt, hello_params.emission_interval, $2->floating);
651 isethelloval: TOK_HELLOVAL TOK_FLOAT
653 int ifcnt = ifs_in_curr_cfg;
654 struct olsr_if *ifs = olsr_cnf->interfaces;
656 PARSER_DEBUG_PRINTF("\tHELLO validity: %0.2f\n", $2->floating);
658 SET_IFS_CONF(ifs, ifcnt, hello_params.validity_time, $2->floating);
663 isettcint: TOK_TCINT TOK_FLOAT
665 int ifcnt = ifs_in_curr_cfg;
666 struct olsr_if *ifs = olsr_cnf->interfaces;
668 PARSER_DEBUG_PRINTF("\tTC interval: %0.2f\n", $2->floating);
670 SET_IFS_CONF(ifs, ifcnt, tc_params.emission_interval, $2->floating);
675 isettcval: TOK_TCVAL TOK_FLOAT
677 int ifcnt = ifs_in_curr_cfg;
678 struct olsr_if *ifs = olsr_cnf->interfaces;
680 PARSER_DEBUG_PRINTF("\tTC validity: %0.2f\n", $2->floating);
682 SET_IFS_CONF(ifs, ifcnt, tc_params.validity_time, $2->floating);
687 isetmidint: TOK_MIDINT TOK_FLOAT
689 int ifcnt = ifs_in_curr_cfg;
690 struct olsr_if *ifs = olsr_cnf->interfaces;
693 PARSER_DEBUG_PRINTF("\tMID interval: %0.2f\n", $2->floating);
695 SET_IFS_CONF(ifs, ifcnt, mid_params.emission_interval, $2->floating);
700 isetmidval: TOK_MIDVAL TOK_FLOAT
702 int ifcnt = ifs_in_curr_cfg;
703 struct olsr_if *ifs = olsr_cnf->interfaces;
705 PARSER_DEBUG_PRINTF("\tMID validity: %0.2f\n", $2->floating);
707 SET_IFS_CONF(ifs, ifcnt, mid_params.validity_time, $2->floating);
712 isethnaint: TOK_HNAINT TOK_FLOAT
714 int ifcnt = ifs_in_curr_cfg;
715 struct olsr_if *ifs = olsr_cnf->interfaces;
717 PARSER_DEBUG_PRINTF("\tHNA interval: %0.2f\n", $2->floating);
719 SET_IFS_CONF(ifs, ifcnt, hna_params.emission_interval, $2->floating);
724 isethnaval: TOK_HNAVAL TOK_FLOAT
726 int ifcnt = ifs_in_curr_cfg;
727 struct olsr_if *ifs = olsr_cnf->interfaces;
729 PARSER_DEBUG_PRINTF("\tHNA validity: %0.2f\n", $2->floating);
731 SET_IFS_CONF(ifs, ifcnt, hna_params.validity_time, $2->floating);
736 isetautodetchg: TOK_AUTODETCHG TOK_BOOLEAN
738 int ifcnt = ifs_in_curr_cfg;
739 struct olsr_if *ifs = olsr_cnf->interfaces;
741 PARSER_DEBUG_PRINTF("\tAutodetect changes: %s\n", $2->boolean ? "YES" : "NO");
743 SET_IFS_CONF(ifs, ifcnt, autodetect_chg, $2->boolean);
749 isetlqmult: TOK_LQ_MULT TOK_DEFAULT TOK_FLOAT
751 if (lq_mult_helper($2, $3) < 0) {
756 | TOK_LQ_MULT TOK_IPV4_ADDR TOK_FLOAT
758 if (lq_mult_helper($2, $3) < 0) {
763 | TOK_LQ_MULT TOK_IPV6_ADDR TOK_FLOAT
765 if (lq_mult_helper($2, $3) < 0) {
771 idebug: TOK_DEBUGLEVEL TOK_INTEGER
773 olsr_cnf->debug_level = $2->integer;
774 PARSER_DEBUG_PRINTF("Debug level: %d\n", olsr_cnf->debug_level);
780 iipversion: TOK_IPVERSION TOK_INTEGER
782 if ($2->integer == 4) {
783 olsr_cnf->ip_version = AF_INET;
784 olsr_cnf->ipsize = sizeof(struct in_addr);
785 olsr_cnf->maxplen = 32;
786 } else if ($2->integer == 6) {
787 olsr_cnf->ip_version = AF_INET6;
788 olsr_cnf->ipsize = sizeof(struct in6_addr);
789 olsr_cnf->maxplen = 128;
791 fprintf(stderr, "IPversion must be 4 or 6!\n");
795 PARSER_DEBUG_PRINTF("IpVersion: %d\n", $2->integer);
800 fibmetric: TOK_FIBMETRIC TOK_STRING
803 PARSER_DEBUG_PRINTF("FIBMetric: %s\n", $2->string);
804 for (i=0; i<FIBM_CNT; i++) {
805 if (strcmp($2->string, FIB_METRIC_TXT[i]) == 0) {
806 olsr_cnf->fib_metric = i;
811 fprintf(stderr, "Bad FIBMetric value: %s\n", $2->string);
820 ihna4entry: TOK_IPV4_ADDR TOK_IPV4_ADDR
822 union olsr_ip_addr ipaddr, netmask;
824 if (olsr_cnf->ip_version == AF_INET6) {
825 fprintf(stderr, "IPv4 addresses can only be used if \"IpVersion\" == 4, skipping HNA.\n");
826 olsr_startup_sleep(3);
829 PARSER_DEBUG_PRINTF("HNA IPv4 entry: %s/%s\n", $1->string, $2->string);
831 if (inet_pton(AF_INET, $1->string, &ipaddr.v4) <= 0) {
832 fprintf(stderr, "ihna4entry: Failed converting IP address %s\n", $1->string);
835 if (inet_pton(AF_INET, $2->string, &netmask.v4) <= 0) {
836 fprintf(stderr, "ihna4entry: Failed converting IP address %s\n", $1->string);
840 /* check that the given IP address is actually a network address */
841 if ((ipaddr.v4.s_addr & ~netmask.v4.s_addr) != 0) {
842 fprintf(stderr, "ihna4entry: The ipaddress \"%s\" is not a network address!\n", $1->string);
847 ip_prefix_list_add(&olsr_cnf->hna_entries, &ipaddr, olsr_netmask_to_prefix(&netmask));
854 | TOK_IPV4_ADDR TOK_SLASH TOK_INTEGER
856 union olsr_ip_addr ipaddr, netmask;
858 if (olsr_cnf->ip_version == AF_INET6) {
859 fprintf(stderr, "IPv4 addresses can only be used if \"IpVersion\" == 4, skipping HNA.\n");
860 olsr_startup_sleep(3);
863 PARSER_DEBUG_PRINTF("HNA IPv4 entry: %s/%d\n", $1->string, $3->integer);
865 if (inet_pton(AF_INET, $1->string, &ipaddr.v4) <= 0) {
866 fprintf(stderr, "ihna4entry: Failed converting IP address %s\n", $1->string);
869 if ($3->integer > olsr_cnf->maxplen) {
870 fprintf(stderr, "ihna4entry: Prefix len %u > %d is not allowed!\n", $3->integer, olsr_cnf->maxplen);
874 /* check that the given IP address is actually a network address */
875 olsr_prefix_to_netmask(&netmask, $3->integer);
876 if ((ipaddr.v4.s_addr & ~netmask.v4.s_addr) != 0) {
877 fprintf(stderr, "ihna4entry: The ipaddress \"%s\" is not a network address!\n", $1->string);
882 ip_prefix_list_add(&olsr_cnf->hna_entries, &ipaddr, $3->integer);
890 ihna6entry: TOK_IPV6_ADDR TOK_INTEGER
892 if (add_ipv6_addr($1, $2)) {
896 | TOK_IPV6_ADDR TOK_SLASH TOK_INTEGER
898 if (add_ipv6_addr($1, $3)) {
904 ifstart: TOK_INTERFACE
906 PARSER_DEBUG_PRINTF("setting ifs_in_curr_cfg = 0\n");
913 struct olsr_if *in, *last;
914 in = olsr_cnf->interfaces;
917 if (strcmp(in->name, $1->string) == 0) {
926 /* remove old interface from list to add it later at the beginning */
928 last->next = in->next;
931 olsr_cnf->interfaces = in->next;
935 in = malloc(sizeof(*in));
937 fprintf(stderr, "Out of memory(ADD IF)\n");
940 memset(in, 0, sizeof(*in));
942 in->cnf = malloc(sizeof(*in->cnf));
943 if (in->cnf == NULL) {
944 fprintf(stderr, "Out of memory(ADD IFRULE)\n");
947 memset(in->cnf, 0x00, sizeof(*in->cnf));
949 in->cnfi = malloc(sizeof(*in->cnfi));
950 if (in->cnf == NULL) {
951 fprintf(stderr, "Out of memory(ADD IFRULE)\n");
954 memset(in->cnfi, 0xFF, sizeof(*in->cnfi));
955 in->cnfi->orig_lq_mult_cnt=0;
957 in->name = $1->string;
960 in->next = olsr_cnf->interfaces;
961 olsr_cnf->interfaces = in;
967 bnoint: TOK_NOINT TOK_BOOLEAN
969 PARSER_DEBUG_PRINTF("Noint set to %d\n", $2->boolean);
970 olsr_cnf->allow_no_interfaces = $2->boolean;
975 atos: TOK_TOS TOK_INTEGER
977 PARSER_DEBUG_PRINTF("TOS: %d\n", $2->integer);
978 olsr_cnf->tos = $2->integer;
984 aolsrport: TOK_OLSRPORT TOK_INTEGER
986 PARSER_DEBUG_PRINTF("OlsrPort: %d\n", $2->integer);
987 olsr_cnf->olsrport = $2->integer;
992 irtproto: TOK_RTPROTO TOK_INTEGER
994 PARSER_DEBUG_PRINTF("RtProto: %d\n", $2->integer);
995 olsr_cnf->rt_proto = $2->integer;
1000 irttable: TOK_RTTABLE TOK_INTEGER
1002 PARSER_DEBUG_PRINTF("RtTable: %d\n", $2->integer);
1003 olsr_cnf->rt_table = $2->integer;
1006 | TOK_RTTABLE TOK_AUTO
1008 PARSER_DEBUG_PRINTF("RtTable: auto\n");
1009 olsr_cnf->rt_table = DEF_RT_AUTO;
1014 irttable_default: TOK_RTTABLE_DEFAULT TOK_INTEGER
1016 PARSER_DEBUG_PRINTF("RtTableDefault: %d\n", $2->integer);
1017 olsr_cnf->rt_table_default = $2->integer;
1020 | TOK_RTTABLE_DEFAULT TOK_AUTO
1022 PARSER_DEBUG_PRINTF("RtTableDefault: auto\n");
1023 olsr_cnf->rt_table_default = DEF_RT_AUTO;
1028 irttable_tunnel: TOK_RTTABLE_TUNNEL TOK_INTEGER
1030 PARSER_DEBUG_PRINTF("RtTableTunnel: %d\n", $2->integer);
1031 olsr_cnf->rt_table_tunnel = $2->integer;
1034 | TOK_RTTABLE_TUNNEL TOK_AUTO
1036 PARSER_DEBUG_PRINTF("RtTableTunnel: auto\n");
1037 olsr_cnf->rt_table_tunnel = DEF_RT_AUTO;
1042 irttable_priority: TOK_RTTABLE_PRIORITY TOK_INTEGER
1044 PARSER_DEBUG_PRINTF("RtTablePriority: %d\n", $2->integer);
1045 olsr_cnf->rt_table_pri = $2->integer;
1048 | TOK_RTTABLE_PRIORITY TOK_AUTO
1050 PARSER_DEBUG_PRINTF("RtTablePriority: auto\n");
1051 olsr_cnf->rt_table_pri = DEF_RT_AUTO;
1054 | TOK_RTTABLE_PRIORITY TOK_NONE
1056 PARSER_DEBUG_PRINTF("RtTablePriority: none\n");
1057 olsr_cnf->rt_table_pri = DEF_RT_NONE;
1062 irttable_default_priority: TOK_RTTABLE_DEFAULT_PRIORITY TOK_INTEGER
1064 PARSER_DEBUG_PRINTF("RtTableDefaultPriority: %d\n", $2->integer);
1065 olsr_cnf->rt_table_default_pri = $2->integer;
1068 | TOK_RTTABLE_DEFAULT_PRIORITY TOK_AUTO
1070 PARSER_DEBUG_PRINTF("RtTableDefaultPriority: auto\n");
1071 olsr_cnf->rt_table_default_pri = DEF_RT_AUTO;
1074 | TOK_RTTABLE_DEFAULT_PRIORITY TOK_NONE
1076 PARSER_DEBUG_PRINTF("RtTableDefaultPriority: none\n");
1077 olsr_cnf->rt_table_default_pri = DEF_RT_NONE;
1082 irttable_tunnel_priority: TOK_RTTABLE_TUNNEL_PRIORITY TOK_INTEGER
1084 PARSER_DEBUG_PRINTF("RtTableTunnelPriority: %d\n", $2->integer);
1085 olsr_cnf->rt_table_tunnel_pri = $2->integer;
1088 | TOK_RTTABLE_TUNNEL_PRIORITY TOK_AUTO
1090 PARSER_DEBUG_PRINTF("RtTableTunnelPriority: auto\n");
1091 olsr_cnf->rt_table_tunnel_pri = DEF_RT_AUTO;
1094 | TOK_RTTABLE_TUNNEL_PRIORITY TOK_NONE
1096 PARSER_DEBUG_PRINTF("RtTableTunnelPriority: none\n");
1097 olsr_cnf->rt_table_tunnel_pri = DEF_RT_NONE;
1102 irttable_defaultolsr_priority: TOK_RTTABLE_DEFAULTOLSR_PRIORITY TOK_INTEGER
1104 PARSER_DEBUG_PRINTF("RtTableDefaultOlsrPriority: %d\n", $2->integer);
1105 olsr_cnf->rt_table_defaultolsr_pri = $2->integer;
1108 | TOK_RTTABLE_DEFAULTOLSR_PRIORITY TOK_AUTO
1110 PARSER_DEBUG_PRINTF("RtTableDefaultOlsrPriority: auto\n");
1111 olsr_cnf->rt_table_defaultolsr_pri = DEF_RT_AUTO;
1114 | TOK_RTTABLE_DEFAULTOLSR_PRIORITY TOK_NONE
1116 PARSER_DEBUG_PRINTF("RtTableDefaultOlsrPriority: none\n");
1117 olsr_cnf->rt_table_defaultolsr_pri = DEF_RT_NONE;
1122 awillingness: TOK_WILLINGNESS TOK_INTEGER
1124 PARSER_DEBUG_PRINTF("Willingness: %d\n", $2->integer);
1125 olsr_cnf->willingness_auto = false;
1126 olsr_cnf->willingness = $2->integer;
1131 busehyst: TOK_USEHYST TOK_BOOLEAN
1133 olsr_cnf->use_hysteresis = $2->boolean;
1134 PARSER_DEBUG_PRINTF("Hysteresis %s\n", olsr_cnf->use_hysteresis ? "enabled" : "disabled");
1139 fhystscale: TOK_HYSTSCALE TOK_FLOAT
1141 olsr_cnf->hysteresis_param.scaling = $2->floating;
1142 PARSER_DEBUG_PRINTF("Hysteresis Scaling: %0.2f\n", $2->floating);
1147 fhystupper: TOK_HYSTUPPER TOK_FLOAT
1149 olsr_cnf->hysteresis_param.thr_high = $2->floating;
1150 PARSER_DEBUG_PRINTF("Hysteresis UpperThr: %0.2f\n", $2->floating);
1155 fhystlower: TOK_HYSTLOWER TOK_FLOAT
1157 olsr_cnf->hysteresis_param.thr_low = $2->floating;
1158 PARSER_DEBUG_PRINTF("Hysteresis LowerThr: %0.2f\n", $2->floating);
1163 fpollrate: TOK_POLLRATE TOK_FLOAT
1165 PARSER_DEBUG_PRINTF("Pollrate %0.2f\n", $2->floating);
1166 olsr_cnf->pollrate = $2->floating;
1171 fnicchgspollrt: TOK_NICCHGSPOLLRT TOK_FLOAT
1173 PARSER_DEBUG_PRINTF("NIC Changes Pollrate %0.2f\n", $2->floating);
1174 olsr_cnf->nic_chgs_pollrate = $2->floating;
1179 atcredundancy: TOK_TCREDUNDANCY TOK_INTEGER
1181 PARSER_DEBUG_PRINTF("TC redundancy %d\n", $2->integer);
1182 olsr_cnf->tc_redundancy = $2->integer;
1187 amprcoverage: TOK_MPRCOVERAGE TOK_INTEGER
1189 PARSER_DEBUG_PRINTF("MPR coverage %d\n", $2->integer);
1190 olsr_cnf->mpr_coverage = $2->integer;
1195 alq_level: TOK_LQ_LEVEL TOK_INTEGER
1197 PARSER_DEBUG_PRINTF("Link quality level %d\n", $2->integer);
1198 olsr_cnf->lq_level = $2->integer;
1203 alq_fish: TOK_LQ_FISH TOK_INTEGER
1205 PARSER_DEBUG_PRINTF("Link quality fish eye %d\n", $2->integer);
1206 olsr_cnf->lq_fish = $2->integer;
1211 alq_aging: TOK_LQ_AGING TOK_FLOAT
1213 PARSER_DEBUG_PRINTF("Link quality aging factor %f\n", $2->floating);
1214 olsr_cnf->lq_aging = $2->floating;
1219 amin_tc_vtime: TOK_MIN_TC_VTIME TOK_FLOAT
1221 PARSER_DEBUG_PRINTF("Minimum TC validity time %f\n", $2->floating);
1222 olsr_cnf->min_tc_vtime = $2->floating;
1227 alock_file: TOK_LOCK_FILE TOK_STRING
1229 PARSER_DEBUG_PRINTF("Lock file %s\n", $2->string);
1230 olsr_cnf->lock_file = $2->string;
1234 alq_plugin: TOK_LQ_PLUGIN TOK_STRING
1236 olsr_cnf->lq_algorithm = $2->string;
1237 PARSER_DEBUG_PRINTF("LQ Algorithm: %s\n", $2->string);
1242 anat_thresh: TOK_LQ_NAT_THRESH TOK_FLOAT
1244 PARSER_DEBUG_PRINTF("NAT threshold %0.2f\n", $2->floating);
1245 olsr_cnf->lq_nat_thresh = $2->floating;
1250 bclear_screen: TOK_CLEAR_SCREEN TOK_BOOLEAN
1252 PARSER_DEBUG_PRINTF("Clear screen %s\n", $2->boolean ? "enabled" : "disabled");
1253 olsr_cnf->clear_screen = $2->boolean;
1258 suse_niit: TOK_USE_NIIT TOK_BOOLEAN
1260 PARSER_DEBUG_PRINTF("Use NIIT ip translation: %s\n", $2->boolean ? "enabled" : "disabled");
1261 olsr_cnf->use_niit = $2->boolean;
1266 bsmart_gw: TOK_SMART_GW TOK_BOOLEAN
1268 PARSER_DEBUG_PRINTF("Smart gateway system: %s\n", $2->boolean ? "enabled" : "disabled");
1269 olsr_cnf->smart_gw_active = $2->boolean;
1274 bsmart_gw_allow_nat: TOK_SMART_GW_ALLOW_NAT TOK_BOOLEAN
1276 PARSER_DEBUG_PRINTF("Smart gateway allow client nat: %s\n", $2->boolean ? "yes" : "no");
1277 olsr_cnf->smart_gw_allow_nat = $2->boolean;
1282 ssmart_gw_uplink: TOK_SMART_GW_UPLINK TOK_STRING
1284 PARSER_DEBUG_PRINTF("Smart gateway uplink: %s\n", $2->string);
1285 if (strcasecmp($2->string, GW_UPLINK_TXT[GW_UPLINK_NONE]) == 0) {
1286 olsr_cnf->smart_gw_type = GW_UPLINK_NONE;
1288 if (strcasecmp($2->string, GW_UPLINK_TXT[GW_UPLINK_IPV4]) == 0) {
1289 olsr_cnf->smart_gw_type = GW_UPLINK_IPV4;
1291 else if (strcasecmp($2->string, GW_UPLINK_TXT[GW_UPLINK_IPV6]) == 0) {
1292 olsr_cnf->smart_gw_type = GW_UPLINK_IPV6;
1294 else if (strcasecmp($2->string, GW_UPLINK_TXT[GW_UPLINK_IPV46]) == 0) {
1295 olsr_cnf->smart_gw_type = GW_UPLINK_IPV46;
1298 fprintf(stderr, "Bad gateway uplink type: %s\n", $2->string);
1305 ismart_gw_speed: TOK_SMART_GW_SPEED TOK_INTEGER TOK_INTEGER
1307 PARSER_DEBUG_PRINTF("Smart gateway speed: %u uplink/%u downlink kbit/s\n", $2->integer, $3->integer);
1308 olsr_cnf->smart_gw_uplink = $2->integer;
1309 olsr_cnf->smart_gw_downlink = $3->integer;
1315 bsmart_gw_uplink_nat: TOK_SMART_GW_UPLINK_NAT TOK_BOOLEAN
1317 PARSER_DEBUG_PRINTF("Smart gateway uplink nat: %s\n", $2->boolean ? "yes" : "no");
1318 olsr_cnf->smart_gw_uplink_nat = $2->boolean;
1323 ismart_gw_prefix: TOK_SMART_GW_PREFIX TOK_IPV6_ADDR TOK_INTEGER
1325 PARSER_DEBUG_PRINTF("Smart gateway prefix: %s %u\n", $2->string, $3->integer);
1326 if (inet_pton(olsr_cnf->ip_version, $2->string, &olsr_cnf->smart_gw_prefix.prefix) == 0) {
1327 fprintf(stderr, "Bad IP part of gateway prefix: %s\n", $2->string);
1330 olsr_cnf->smart_gw_prefix.prefix_len = (uint8_t)$3->integer;
1335 | TOK_SMART_GW_PREFIX TOK_IPV6_ADDR TOK_SLASH TOK_INTEGER
1337 PARSER_DEBUG_PRINTF("Smart gateway prefix: %s %u\n", $2->string, $4->integer);
1338 if (inet_pton(olsr_cnf->ip_version, $2->string, &olsr_cnf->smart_gw_prefix.prefix) == 0) {
1339 fprintf(stderr, "Bad IP part of gateway prefix: %s\n", $2->string);
1342 olsr_cnf->smart_gw_prefix.prefix_len = (uint8_t)$4->integer;
1349 bsrc_ip_routes: TOK_SRC_IP_ROUTES TOK_BOOLEAN
1351 PARSER_DEBUG_PRINTF("Use originator for routes src-ip: %s\n", $2->boolean ? "yes" : "no");
1352 olsr_cnf->use_src_ip_routes = $2->boolean;
1357 amain_ip: TOK_MAIN_IP TOK_IPV4_ADDR
1359 PARSER_DEBUG_PRINTF("Fixed Main IP: %s\n", $2->string);
1361 if (olsr_cnf->ip_version != AF_INET
1362 || inet_pton(olsr_cnf->ip_version, $2->string, &olsr_cnf->main_addr) != 1) {
1363 fprintf(stderr, "Bad main IP: %s\n", $2->string);
1368 | TOK_MAIN_IP TOK_IPV6_ADDR
1370 PARSER_DEBUG_PRINTF("Fixed Main IP: %s\n", $2->string);
1372 if (olsr_cnf->ip_version != AF_INET6
1373 || inet_pton(olsr_cnf->ip_version, $2->string, &olsr_cnf->main_addr) != 1) {
1374 fprintf(stderr, "Bad main IP: %s\n", $2->string);
1380 plblock: TOK_PLUGIN TOK_STRING
1382 struct plugin_entry *pe, *last;
1384 pe = olsr_cnf->plugins;
1386 while (pe != NULL) {
1387 if (strcmp(pe->name, $2->string) == 0) {
1396 /* remove old plugin from list to add it later at the beginning */
1398 last->next = pe->next;
1401 olsr_cnf->plugins = pe->next;
1405 pe = malloc(sizeof(*pe));
1408 fprintf(stderr, "Out of memory(ADD PL)\n");
1412 pe->name = $2->string;
1415 PARSER_DEBUG_PRINTF("Plugin: %s\n", $2->string);
1419 pe->next = olsr_cnf->plugins;
1420 olsr_cnf->plugins = pe;
1426 plparam: TOK_PLPARAM TOK_STRING TOK_STRING
1428 struct plugin_param *pp = malloc(sizeof(*pp));
1431 fprintf(stderr, "Out of memory(ADD PP)\n");
1435 PARSER_DEBUG_PRINTF("Plugin param key:\"%s\" val: \"%s\"\n", $2->string, $3->string);
1437 pp->key = $2->string;
1438 pp->value = $3->string;
1441 pp->next = olsr_cnf->plugins->params;
1442 olsr_cnf->plugins->params = pp;
1449 vcomment: TOK_COMMENT
1451 //PARSER_DEBUG_PRINTF("Comment\n");
1459 void yyerror (const char *string)
1461 fprintf(stderr, "Config line %d: %s\n", current_line, string);