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_IPV4MULTICAST
232 %token TOK_IP4BROADCAST
233 %token TOK_IPV4BROADCAST
234 %token TOK_IPV6MULTICAST
246 %token TOK_AUTODETCHG
274 | irttable_defaultolsr_priority
275 | irttable_tunnel_priority
276 | irttable_default_priority
297 | bsmart_gw_allow_nat
299 | bsmart_gw_uplink_nat
306 block: TOK_HNA4 hna4body
314 hna4body: TOK_OPEN hna4stmts TOK_CLOSE
317 hna4stmts: | hna4stmts hna4stmt
324 hna6body: TOK_OPEN hna6stmts TOK_CLOSE
327 hna6stmts: | hna6stmts hna6stmt
334 ipcbody: TOK_OPEN ipcstmts TOK_CLOSE
337 ipcstmts: | ipcstmts ipcstmt
346 ifblock: ifstart ifnicks
349 ifnicks: | ifnicks ifnick
352 ifbody: TOK_OPEN ifstmts TOK_CLOSE
355 ifdbody: TOK_OPEN ifstmts TOK_CLOSE
357 struct olsr_if *in = olsr_cnf->interfaces;
358 printf("\nInterface Defaults");
359 /*remove Interface Defaults from Interface list as they are no interface!*/
360 olsr_cnf->interfaces = in->next;
362 /*free interface but keep its config intact?*/
369 ifstmts: | ifstmts ifstmt
375 | TOK_IP4BROADCAST isetipv4mc
376 | TOK_IPV4BROADCAST isetipv4mc
377 | TOK_IPV4MULTICAST isetipv4mc
393 plbody: TOK_OPEN plstmts TOK_CLOSE
396 plstmts: | plstmts plstmt
403 ifdblock: TOK_INTERFACE_DEFAULTS
405 struct olsr_if *in = malloc(sizeof(*in));
408 fprintf(stderr, "Out of memory(ADD IF)\n");
412 in->cnf = get_default_if_config();
413 in->cnfi = get_default_if_config();
415 if (in->cnf == NULL || in->cnfi == NULL) {
416 fprintf(stderr, "Out of memory(ADD DEFIFRULE)\n");
420 //should not need a name any more, as we free it on "}" again
421 //in->name = strdup(interface_defaults_name);
423 olsr_cnf->interface_defaults = in->cnf;
426 in->next = olsr_cnf->interfaces;
427 olsr_cnf->interfaces = in;
434 imaxipc: TOK_MAXIPC TOK_INTEGER
436 olsr_cnf->ipc_connections = $2->integer;
441 ipchost: TOK_HOSTLABEL TOK_IPV4_ADDR
443 union olsr_ip_addr ipaddr;
444 PARSER_DEBUG_PRINTF("\tIPC host: %s\n", $2->string);
446 if (inet_aton($2->string, &ipaddr.v4) == 0) {
447 fprintf(stderr, "Failed converting IP address IPC %s\n", $2->string);
451 ip_prefix_list_add(&olsr_cnf->ipc_nets, &ipaddr, olsr_cnf->maxplen);
458 ipcnet: TOK_NETLABEL TOK_IPV4_ADDR TOK_IPV4_ADDR
460 union olsr_ip_addr ipaddr, netmask;
462 PARSER_DEBUG_PRINTF("\tIPC net: %s/%s\n", $2->string, $3->string);
464 if (inet_pton(AF_INET, $2->string, &ipaddr.v4) == 0) {
465 fprintf(stderr, "Failed converting IP net IPC %s\n", $2->string);
469 if (inet_pton(AF_INET, $3->string, &netmask.v4) == 0) {
470 fprintf(stderr, "Failed converting IP mask IPC %s\n", $3->string);
474 ip_prefix_list_add(&olsr_cnf->ipc_nets, &ipaddr, olsr_netmask_to_prefix(&netmask));
481 | TOK_NETLABEL TOK_IPV4_ADDR TOK_SLASH TOK_INTEGER
483 union olsr_ip_addr ipaddr;
485 PARSER_DEBUG_PRINTF("\tIPC net: %s/%s\n", $2->string, $3->string);
487 if (inet_pton(AF_INET, $2->string, &ipaddr.v4) == 0) {
488 fprintf(stderr, "Failed converting IP net IPC %s\n", $2->string);
492 if ($4->integer > olsr_cnf->maxplen) {
493 fprintf(stderr, "ipcnet: Prefix len %u > %d is not allowed!\n", $4->integer, olsr_cnf->maxplen);
497 ip_prefix_list_add(&olsr_cnf->ipc_nets, &ipaddr, $4->integer);
505 iifweight: TOK_IFWEIGHT TOK_INTEGER
507 int ifcnt = ifs_in_curr_cfg;
508 struct olsr_if *ifs = olsr_cnf->interfaces;
510 PARSER_DEBUG_PRINTF("Fixed willingness: %d\n", $2->integer);
513 ifs->cnf->weight.value = $2->integer;
514 ifs->cnf->weight.fixed = true;
515 ifs->cnfi->weight.value = $2->integer;
516 ifs->cnfi->weight.fixed = true;
526 isetifmode: TOK_IFMODE TOK_STRING
528 int ifcnt = ifs_in_curr_cfg;
529 struct olsr_if *ifs = olsr_cnf->interfaces;
530 int mode = (strcmp($2->string, "ether") == 0)?IF_MODE_ETHER:IF_MODE_MESH;
532 PARSER_DEBUG_PRINTF("\tMode: %s\n", $2->string);
534 SET_IFS_CONF(ifs, ifcnt, mode, mode);
541 /* called if prepended with TOK_IPV4MULTICAST TOK_IP4BROADCAST TOK_IPV4BROADCAST */
542 isetipv4mc: TOK_IPV4_ADDR
545 int ifcnt = ifs_in_curr_cfg;
546 struct olsr_if *ifs = olsr_cnf->interfaces;
548 PARSER_DEBUG_PRINTF("\tIPv4 broadcast: %s\n", $1->string);
550 if (inet_aton($1->string, &in) == 0) {
551 fprintf(stderr, "isetipv4br: Failed converting IP address %s\n", $1->string);
555 SET_IFS_CONF(ifs, ifcnt, ipv4_multicast.v4, in);
562 isetipv6mc: TOK_IPV6MULTICAST TOK_IPV6_ADDR
565 int ifcnt = ifs_in_curr_cfg;
566 struct olsr_if *ifs = olsr_cnf->interfaces;
568 PARSER_DEBUG_PRINTF("\tIPv6 multicast: %s\n", $2->string);
570 if (inet_pton(AF_INET6, $2->string, &in6) <= 0) {
571 fprintf(stderr, "isetipv6mc: Failed converting IP address %s\n", $2->string);
575 SET_IFS_CONF(ifs, ifcnt, ipv6_multicast.v6, in6);
582 isetipv4src: TOK_IPV4SRC TOK_IPV4_ADDR
585 int ifcnt = ifs_in_curr_cfg;
586 struct olsr_if *ifs = olsr_cnf->interfaces;
588 PARSER_DEBUG_PRINTF("\tIPv4 src: %s\n", $2->string);
590 if (inet_aton($2->string, &in) == 0) {
591 fprintf(stderr, "isetipv4src: Failed converting IP address %s\n", $2->string);
595 SET_IFS_CONF(ifs, ifcnt, ipv4_src.v4, in);
602 isetipv6src: TOK_IPV6SRC TOK_IPV6_ADDR
604 struct olsr_ip_prefix pr6;
605 int ifcnt = ifs_in_curr_cfg;
606 struct olsr_if *ifs = olsr_cnf->interfaces;
608 PARSER_DEBUG_PRINTF("\tIPv6 src prefix: %s\n", $2->string);
610 if (olsr_string_to_prefix(AF_INET6, &pr6, $2->string)) {
611 fprintf(stderr, "isetipv6src: Failed converting IP prefix %s\n", $2->string);
615 SET_IFS_CONF(ifs, ifcnt, ipv6_src, pr6);
622 isethelloint: TOK_HELLOINT TOK_FLOAT
624 int ifcnt = ifs_in_curr_cfg;
625 struct olsr_if *ifs = olsr_cnf->interfaces;
627 PARSER_DEBUG_PRINTF("\tHELLO interval: %0.2f\n", $2->floating);
629 SET_IFS_CONF(ifs, ifcnt, hello_params.emission_interval, $2->floating);
634 isethelloval: TOK_HELLOVAL TOK_FLOAT
636 int ifcnt = ifs_in_curr_cfg;
637 struct olsr_if *ifs = olsr_cnf->interfaces;
639 PARSER_DEBUG_PRINTF("\tHELLO validity: %0.2f\n", $2->floating);
641 SET_IFS_CONF(ifs, ifcnt, hello_params.validity_time, $2->floating);
646 isettcint: TOK_TCINT TOK_FLOAT
648 int ifcnt = ifs_in_curr_cfg;
649 struct olsr_if *ifs = olsr_cnf->interfaces;
651 PARSER_DEBUG_PRINTF("\tTC interval: %0.2f\n", $2->floating);
653 SET_IFS_CONF(ifs, ifcnt, tc_params.emission_interval, $2->floating);
658 isettcval: TOK_TCVAL TOK_FLOAT
660 int ifcnt = ifs_in_curr_cfg;
661 struct olsr_if *ifs = olsr_cnf->interfaces;
663 PARSER_DEBUG_PRINTF("\tTC validity: %0.2f\n", $2->floating);
665 SET_IFS_CONF(ifs, ifcnt, tc_params.validity_time, $2->floating);
670 isetmidint: TOK_MIDINT TOK_FLOAT
672 int ifcnt = ifs_in_curr_cfg;
673 struct olsr_if *ifs = olsr_cnf->interfaces;
676 PARSER_DEBUG_PRINTF("\tMID interval: %0.2f\n", $2->floating);
678 SET_IFS_CONF(ifs, ifcnt, mid_params.emission_interval, $2->floating);
683 isetmidval: TOK_MIDVAL TOK_FLOAT
685 int ifcnt = ifs_in_curr_cfg;
686 struct olsr_if *ifs = olsr_cnf->interfaces;
688 PARSER_DEBUG_PRINTF("\tMID validity: %0.2f\n", $2->floating);
690 SET_IFS_CONF(ifs, ifcnt, mid_params.validity_time, $2->floating);
695 isethnaint: TOK_HNAINT TOK_FLOAT
697 int ifcnt = ifs_in_curr_cfg;
698 struct olsr_if *ifs = olsr_cnf->interfaces;
700 PARSER_DEBUG_PRINTF("\tHNA interval: %0.2f\n", $2->floating);
702 SET_IFS_CONF(ifs, ifcnt, hna_params.emission_interval, $2->floating);
707 isethnaval: TOK_HNAVAL TOK_FLOAT
709 int ifcnt = ifs_in_curr_cfg;
710 struct olsr_if *ifs = olsr_cnf->interfaces;
712 PARSER_DEBUG_PRINTF("\tHNA validity: %0.2f\n", $2->floating);
714 SET_IFS_CONF(ifs, ifcnt, hna_params.validity_time, $2->floating);
719 isetautodetchg: TOK_AUTODETCHG TOK_BOOLEAN
721 int ifcnt = ifs_in_curr_cfg;
722 struct olsr_if *ifs = olsr_cnf->interfaces;
724 PARSER_DEBUG_PRINTF("\tAutodetect changes: %s\n", $2->boolean ? "YES" : "NO");
726 SET_IFS_CONF(ifs, ifcnt, autodetect_chg, $2->boolean);
732 isetlqmult: TOK_LQ_MULT TOK_DEFAULT TOK_FLOAT
734 if (lq_mult_helper($2, $3) < 0) {
739 | TOK_LQ_MULT TOK_IPV4_ADDR TOK_FLOAT
741 if (lq_mult_helper($2, $3) < 0) {
746 | TOK_LQ_MULT TOK_IPV6_ADDR TOK_FLOAT
748 if (lq_mult_helper($2, $3) < 0) {
754 idebug: TOK_DEBUGLEVEL TOK_INTEGER
756 olsr_cnf->debug_level = $2->integer;
757 PARSER_DEBUG_PRINTF("Debug level: %d\n", olsr_cnf->debug_level);
763 iipversion: TOK_IPVERSION TOK_INTEGER
765 if ($2->integer == 4) {
766 olsr_cnf->ip_version = AF_INET;
767 olsr_cnf->ipsize = sizeof(struct in_addr);
768 olsr_cnf->maxplen = 32;
769 } else if ($2->integer == 6) {
770 olsr_cnf->ip_version = AF_INET6;
771 olsr_cnf->ipsize = sizeof(struct in6_addr);
772 olsr_cnf->maxplen = 128;
774 fprintf(stderr, "IPversion must be 4 or 6!\n");
778 PARSER_DEBUG_PRINTF("IpVersion: %d\n", $2->integer);
783 fibmetric: TOK_FIBMETRIC TOK_STRING
786 PARSER_DEBUG_PRINTF("FIBMetric: %s\n", $2->string);
787 for (i=0; i<FIBM_CNT; i++) {
788 if (strcmp($2->string, FIB_METRIC_TXT[i]) == 0) {
789 olsr_cnf->fib_metric = i;
794 fprintf(stderr, "Bad FIBMetric value: %s\n", $2->string);
803 ihna4entry: TOK_IPV4_ADDR TOK_IPV4_ADDR
805 union olsr_ip_addr ipaddr, netmask;
807 if (olsr_cnf->ip_version == AF_INET6) {
808 fprintf(stderr, "IPv4 addresses can only be used if \"IpVersion\" == 4, skipping HNA.\n");
809 olsr_startup_sleep(3);
812 PARSER_DEBUG_PRINTF("HNA IPv4 entry: %s/%s\n", $1->string, $2->string);
814 if (inet_pton(AF_INET, $1->string, &ipaddr.v4) <= 0) {
815 fprintf(stderr, "ihna4entry: Failed converting IP address %s\n", $1->string);
818 if (inet_pton(AF_INET, $2->string, &netmask.v4) <= 0) {
819 fprintf(stderr, "ihna4entry: Failed converting IP address %s\n", $1->string);
823 /* check that the given IP address is actually a network address */
824 if ((ipaddr.v4.s_addr & ~netmask.v4.s_addr) != 0) {
825 fprintf(stderr, "ihna4entry: The ipaddress \"%s\" is not a network address!\n", $1->string);
830 ip_prefix_list_add(&olsr_cnf->hna_entries, &ipaddr, olsr_netmask_to_prefix(&netmask));
837 | TOK_IPV4_ADDR TOK_SLASH TOK_INTEGER
839 union olsr_ip_addr ipaddr, netmask;
841 if (olsr_cnf->ip_version == AF_INET6) {
842 fprintf(stderr, "IPv4 addresses can only be used if \"IpVersion\" == 4, skipping HNA.\n");
843 olsr_startup_sleep(3);
846 PARSER_DEBUG_PRINTF("HNA IPv4 entry: %s/%d\n", $1->string, $3->integer);
848 if (inet_pton(AF_INET, $1->string, &ipaddr.v4) <= 0) {
849 fprintf(stderr, "ihna4entry: Failed converting IP address %s\n", $1->string);
852 if ($3->integer > olsr_cnf->maxplen) {
853 fprintf(stderr, "ihna4entry: Prefix len %u > %d is not allowed!\n", $3->integer, olsr_cnf->maxplen);
857 /* check that the given IP address is actually a network address */
858 olsr_prefix_to_netmask(&netmask, $3->integer);
859 if ((ipaddr.v4.s_addr & ~netmask.v4.s_addr) != 0) {
860 fprintf(stderr, "ihna4entry: The ipaddress \"%s\" is not a network address!\n", $1->string);
865 ip_prefix_list_add(&olsr_cnf->hna_entries, &ipaddr, $3->integer);
873 ihna6entry: TOK_IPV6_ADDR TOK_INTEGER
875 if (add_ipv6_addr($1, $2)) {
879 | TOK_IPV6_ADDR TOK_SLASH TOK_INTEGER
881 if (add_ipv6_addr($1, $3)) {
887 ifstart: TOK_INTERFACE
889 PARSER_DEBUG_PRINTF("setting ifs_in_curr_cfg = 0\n");
896 struct olsr_if *in, *last;
897 in = olsr_cnf->interfaces;
900 if (strcmp(in->name, $1->string) == 0) {
909 /* remove old interface from list to add it later at the beginning */
911 last->next = in->next;
914 olsr_cnf->interfaces = in->next;
918 in = malloc(sizeof(*in));
920 fprintf(stderr, "Out of memory(ADD IF)\n");
923 memset(in, 0, sizeof(*in));
925 in->cnf = malloc(sizeof(*in->cnf));
926 if (in->cnf == NULL) {
927 fprintf(stderr, "Out of memory(ADD IFRULE)\n");
930 memset(in->cnf, 0x00, sizeof(*in->cnf));
932 in->cnfi = malloc(sizeof(*in->cnfi));
933 if (in->cnf == NULL) {
934 fprintf(stderr, "Out of memory(ADD IFRULE)\n");
937 memset(in->cnfi, 0xFF, sizeof(*in->cnfi));
938 in->cnfi->orig_lq_mult_cnt=0;
940 in->name = $1->string;
943 in->next = olsr_cnf->interfaces;
944 olsr_cnf->interfaces = in;
950 bnoint: TOK_NOINT TOK_BOOLEAN
952 PARSER_DEBUG_PRINTF("Noint set to %d\n", $2->boolean);
953 olsr_cnf->allow_no_interfaces = $2->boolean;
958 atos: TOK_TOS TOK_INTEGER
960 PARSER_DEBUG_PRINTF("TOS: %d\n", $2->integer);
961 olsr_cnf->tos = $2->integer;
967 aolsrport: TOK_OLSRPORT TOK_INTEGER
969 PARSER_DEBUG_PRINTF("OlsrPort: %d\n", $2->integer);
970 olsr_cnf->olsrport = $2->integer;
975 irtproto: TOK_RTPROTO TOK_INTEGER
977 PARSER_DEBUG_PRINTF("RtProto: %d\n", $2->integer);
978 olsr_cnf->rt_proto = $2->integer;
983 irttable: TOK_RTTABLE TOK_INTEGER
985 PARSER_DEBUG_PRINTF("RtTable: %d\n", $2->integer);
986 olsr_cnf->rt_table = $2->integer;
989 | TOK_RTTABLE TOK_AUTO
991 PARSER_DEBUG_PRINTF("RtTable: auto\n");
992 olsr_cnf->rt_table = DEF_RT_AUTO;
997 irttable_default: TOK_RTTABLE_DEFAULT TOK_INTEGER
999 PARSER_DEBUG_PRINTF("RtTableDefault: %d\n", $2->integer);
1000 olsr_cnf->rt_table_default = $2->integer;
1003 | TOK_RTTABLE_DEFAULT TOK_AUTO
1005 PARSER_DEBUG_PRINTF("RtTableDefault: auto\n");
1006 olsr_cnf->rt_table_default = DEF_RT_AUTO;
1011 irttable_tunnel: TOK_RTTABLE_TUNNEL TOK_INTEGER
1013 PARSER_DEBUG_PRINTF("RtTableTunnel: %d\n", $2->integer);
1014 olsr_cnf->rt_table_tunnel = $2->integer;
1017 | TOK_RTTABLE_TUNNEL TOK_AUTO
1019 PARSER_DEBUG_PRINTF("RtTableTunnel: auto\n");
1020 olsr_cnf->rt_table_tunnel = DEF_RT_AUTO;
1025 irttable_priority: TOK_RTTABLE_PRIORITY TOK_INTEGER
1027 PARSER_DEBUG_PRINTF("RtTablePriority: %d\n", $2->integer);
1028 olsr_cnf->rt_table_pri = $2->integer;
1031 | TOK_RTTABLE_PRIORITY TOK_AUTO
1033 PARSER_DEBUG_PRINTF("RtTablePriority: auto\n");
1034 olsr_cnf->rt_table_pri = DEF_RT_AUTO;
1037 | TOK_RTTABLE_PRIORITY TOK_NONE
1039 PARSER_DEBUG_PRINTF("RtTablePriority: none\n");
1040 olsr_cnf->rt_table_pri = DEF_RT_NONE;
1045 irttable_default_priority: TOK_RTTABLE_DEFAULT_PRIORITY TOK_INTEGER
1047 PARSER_DEBUG_PRINTF("RtTableDefaultPriority: %d\n", $2->integer);
1048 olsr_cnf->rt_table_default_pri = $2->integer;
1051 | TOK_RTTABLE_DEFAULT_PRIORITY TOK_AUTO
1053 PARSER_DEBUG_PRINTF("RtTableDefaultPriority: auto\n");
1054 olsr_cnf->rt_table_default_pri = DEF_RT_AUTO;
1057 | TOK_RTTABLE_DEFAULT_PRIORITY TOK_NONE
1059 PARSER_DEBUG_PRINTF("RtTableDefaultPriority: none\n");
1060 olsr_cnf->rt_table_default_pri = DEF_RT_NONE;
1065 irttable_tunnel_priority: TOK_RTTABLE_TUNNEL_PRIORITY TOK_INTEGER
1067 PARSER_DEBUG_PRINTF("RtTableTunnelPriority: %d\n", $2->integer);
1068 olsr_cnf->rt_table_tunnel_pri = $2->integer;
1071 | TOK_RTTABLE_TUNNEL_PRIORITY TOK_AUTO
1073 PARSER_DEBUG_PRINTF("RtTableTunnelPriority: auto\n");
1074 olsr_cnf->rt_table_tunnel_pri = DEF_RT_AUTO;
1077 | TOK_RTTABLE_TUNNEL_PRIORITY TOK_NONE
1079 PARSER_DEBUG_PRINTF("RtTableTunnelPriority: none\n");
1080 olsr_cnf->rt_table_tunnel_pri = DEF_RT_NONE;
1085 irttable_defaultolsr_priority: TOK_RTTABLE_DEFAULTOLSR_PRIORITY TOK_INTEGER
1087 PARSER_DEBUG_PRINTF("RtTableDefaultOlsrPriority: %d\n", $2->integer);
1088 olsr_cnf->rt_table_defaultolsr_pri = $2->integer;
1091 | TOK_RTTABLE_DEFAULTOLSR_PRIORITY TOK_AUTO
1093 PARSER_DEBUG_PRINTF("RtTableDefaultOlsrPriority: auto\n");
1094 olsr_cnf->rt_table_defaultolsr_pri = DEF_RT_AUTO;
1097 | TOK_RTTABLE_DEFAULTOLSR_PRIORITY TOK_NONE
1099 PARSER_DEBUG_PRINTF("RtTableDefaultOlsrPriority: none\n");
1100 olsr_cnf->rt_table_defaultolsr_pri = DEF_RT_NONE;
1105 awillingness: TOK_WILLINGNESS TOK_INTEGER
1107 PARSER_DEBUG_PRINTF("Willingness: %d\n", $2->integer);
1108 olsr_cnf->willingness_auto = false;
1109 olsr_cnf->willingness = $2->integer;
1114 busehyst: TOK_USEHYST TOK_BOOLEAN
1116 olsr_cnf->use_hysteresis = $2->boolean;
1117 PARSER_DEBUG_PRINTF("Hysteresis %s\n", olsr_cnf->use_hysteresis ? "enabled" : "disabled");
1122 fhystscale: TOK_HYSTSCALE TOK_FLOAT
1124 olsr_cnf->hysteresis_param.scaling = $2->floating;
1125 PARSER_DEBUG_PRINTF("Hysteresis Scaling: %0.2f\n", $2->floating);
1130 fhystupper: TOK_HYSTUPPER TOK_FLOAT
1132 olsr_cnf->hysteresis_param.thr_high = $2->floating;
1133 PARSER_DEBUG_PRINTF("Hysteresis UpperThr: %0.2f\n", $2->floating);
1138 fhystlower: TOK_HYSTLOWER TOK_FLOAT
1140 olsr_cnf->hysteresis_param.thr_low = $2->floating;
1141 PARSER_DEBUG_PRINTF("Hysteresis LowerThr: %0.2f\n", $2->floating);
1146 fpollrate: TOK_POLLRATE TOK_FLOAT
1148 PARSER_DEBUG_PRINTF("Pollrate %0.2f\n", $2->floating);
1149 olsr_cnf->pollrate = $2->floating;
1154 fnicchgspollrt: TOK_NICCHGSPOLLRT TOK_FLOAT
1156 PARSER_DEBUG_PRINTF("NIC Changes Pollrate %0.2f\n", $2->floating);
1157 olsr_cnf->nic_chgs_pollrate = $2->floating;
1162 atcredundancy: TOK_TCREDUNDANCY TOK_INTEGER
1164 PARSER_DEBUG_PRINTF("TC redundancy %d\n", $2->integer);
1165 olsr_cnf->tc_redundancy = $2->integer;
1170 amprcoverage: TOK_MPRCOVERAGE TOK_INTEGER
1172 PARSER_DEBUG_PRINTF("MPR coverage %d\n", $2->integer);
1173 olsr_cnf->mpr_coverage = $2->integer;
1178 alq_level: TOK_LQ_LEVEL TOK_INTEGER
1180 PARSER_DEBUG_PRINTF("Link quality level %d\n", $2->integer);
1181 olsr_cnf->lq_level = $2->integer;
1186 alq_fish: TOK_LQ_FISH TOK_INTEGER
1188 PARSER_DEBUG_PRINTF("Link quality fish eye %d\n", $2->integer);
1189 olsr_cnf->lq_fish = $2->integer;
1194 alq_aging: TOK_LQ_AGING TOK_FLOAT
1196 PARSER_DEBUG_PRINTF("Link quality aging factor %f\n", $2->floating);
1197 olsr_cnf->lq_aging = $2->floating;
1202 amin_tc_vtime: TOK_MIN_TC_VTIME TOK_FLOAT
1204 PARSER_DEBUG_PRINTF("Minimum TC validity time %f\n", $2->floating);
1205 olsr_cnf->min_tc_vtime = $2->floating;
1210 alock_file: TOK_LOCK_FILE TOK_STRING
1212 PARSER_DEBUG_PRINTF("Lock file %s\n", $2->string);
1213 olsr_cnf->lock_file = $2->string;
1217 alq_plugin: TOK_LQ_PLUGIN TOK_STRING
1219 olsr_cnf->lq_algorithm = $2->string;
1220 PARSER_DEBUG_PRINTF("LQ Algorithm: %s\n", $2->string);
1225 anat_thresh: TOK_LQ_NAT_THRESH TOK_FLOAT
1227 PARSER_DEBUG_PRINTF("NAT threshold %0.2f\n", $2->floating);
1228 olsr_cnf->lq_nat_thresh = $2->floating;
1233 bclear_screen: TOK_CLEAR_SCREEN TOK_BOOLEAN
1235 PARSER_DEBUG_PRINTF("Clear screen %s\n", $2->boolean ? "enabled" : "disabled");
1236 olsr_cnf->clear_screen = $2->boolean;
1241 suse_niit: TOK_USE_NIIT TOK_BOOLEAN
1243 PARSER_DEBUG_PRINTF("Use NIIT ip translation: %s\n", $2->boolean ? "enabled" : "disabled");
1244 olsr_cnf->use_niit = $2->boolean;
1249 bsmart_gw: TOK_SMART_GW TOK_BOOLEAN
1251 PARSER_DEBUG_PRINTF("Smart gateway system: %s\n", $2->boolean ? "enabled" : "disabled");
1252 olsr_cnf->smart_gw_active = $2->boolean;
1257 bsmart_gw_allow_nat: TOK_SMART_GW_ALLOW_NAT TOK_BOOLEAN
1259 PARSER_DEBUG_PRINTF("Smart gateway allow client nat: %s\n", $2->boolean ? "yes" : "no");
1260 olsr_cnf->smart_gw_allow_nat = $2->boolean;
1265 ssmart_gw_uplink: TOK_SMART_GW_UPLINK TOK_STRING
1267 PARSER_DEBUG_PRINTF("Smart gateway uplink: %s\n", $2->string);
1268 if (strcasecmp($2->string, GW_UPLINK_TXT[GW_UPLINK_NONE]) == 0) {
1269 olsr_cnf->smart_gw_type = GW_UPLINK_NONE;
1271 if (strcasecmp($2->string, GW_UPLINK_TXT[GW_UPLINK_IPV4]) == 0) {
1272 olsr_cnf->smart_gw_type = GW_UPLINK_IPV4;
1274 else if (strcasecmp($2->string, GW_UPLINK_TXT[GW_UPLINK_IPV6]) == 0) {
1275 olsr_cnf->smart_gw_type = GW_UPLINK_IPV6;
1277 else if (strcasecmp($2->string, GW_UPLINK_TXT[GW_UPLINK_IPV46]) == 0) {
1278 olsr_cnf->smart_gw_type = GW_UPLINK_IPV46;
1281 fprintf(stderr, "Bad gateway uplink type: %s\n", $2->string);
1288 ismart_gw_speed: TOK_SMART_GW_SPEED TOK_INTEGER TOK_INTEGER
1290 PARSER_DEBUG_PRINTF("Smart gateway speed: %u uplink/%u downlink kbit/s\n", $2->integer, $3->integer);
1291 olsr_cnf->smart_gw_uplink = $2->integer;
1292 olsr_cnf->smart_gw_downlink = $3->integer;
1298 bsmart_gw_uplink_nat: TOK_SMART_GW_UPLINK_NAT TOK_BOOLEAN
1300 PARSER_DEBUG_PRINTF("Smart gateway uplink nat: %s\n", $2->boolean ? "yes" : "no");
1301 olsr_cnf->smart_gw_uplink_nat = $2->boolean;
1306 ismart_gw_prefix: TOK_SMART_GW_PREFIX TOK_IPV6_ADDR TOK_INTEGER
1308 PARSER_DEBUG_PRINTF("Smart gateway prefix: %s %u\n", $2->string, $3->integer);
1309 if (inet_pton(olsr_cnf->ip_version, $2->string, &olsr_cnf->smart_gw_prefix.prefix) == 0) {
1310 fprintf(stderr, "Bad IP part of gateway prefix: %s\n", $2->string);
1313 olsr_cnf->smart_gw_prefix.prefix_len = (uint8_t)$3->integer;
1318 | TOK_SMART_GW_PREFIX TOK_IPV6_ADDR TOK_SLASH TOK_INTEGER
1320 PARSER_DEBUG_PRINTF("Smart gateway prefix: %s %u\n", $2->string, $4->integer);
1321 if (inet_pton(olsr_cnf->ip_version, $2->string, &olsr_cnf->smart_gw_prefix.prefix) == 0) {
1322 fprintf(stderr, "Bad IP part of gateway prefix: %s\n", $2->string);
1325 olsr_cnf->smart_gw_prefix.prefix_len = (uint8_t)$4->integer;
1332 bsrc_ip_routes: TOK_SRC_IP_ROUTES TOK_BOOLEAN
1334 PARSER_DEBUG_PRINTF("Use originator for routes src-ip: %s\n", $2->boolean ? "yes" : "no");
1335 olsr_cnf->use_src_ip_routes = $2->boolean;
1340 amain_ip: TOK_MAIN_IP TOK_IPV4_ADDR
1342 PARSER_DEBUG_PRINTF("Fixed Main IP: %s\n", $2->string);
1344 if (olsr_cnf->ip_version != AF_INET
1345 || inet_pton(olsr_cnf->ip_version, $2->string, &olsr_cnf->main_addr) != 1) {
1346 fprintf(stderr, "Bad main IP: %s\n", $2->string);
1351 | TOK_MAIN_IP TOK_IPV6_ADDR
1353 PARSER_DEBUG_PRINTF("Fixed Main IP: %s\n", $2->string);
1355 if (olsr_cnf->ip_version != AF_INET6
1356 || inet_pton(olsr_cnf->ip_version, $2->string, &olsr_cnf->main_addr) != 1) {
1357 fprintf(stderr, "Bad main IP: %s\n", $2->string);
1363 plblock: TOK_PLUGIN TOK_STRING
1365 struct plugin_entry *pe, *last;
1367 pe = olsr_cnf->plugins;
1369 while (pe != NULL) {
1370 if (strcmp(pe->name, $2->string) == 0) {
1379 /* remove old plugin from list to add it later at the beginning */
1381 last->next = pe->next;
1384 olsr_cnf->plugins = pe->next;
1388 pe = malloc(sizeof(*pe));
1391 fprintf(stderr, "Out of memory(ADD PL)\n");
1395 pe->name = $2->string;
1398 PARSER_DEBUG_PRINTF("Plugin: %s\n", $2->string);
1402 pe->next = olsr_cnf->plugins;
1403 olsr_cnf->plugins = pe;
1409 plparam: TOK_PLPARAM TOK_STRING TOK_STRING
1411 struct plugin_param *pp = malloc(sizeof(*pp));
1414 fprintf(stderr, "Out of memory(ADD PP)\n");
1418 PARSER_DEBUG_PRINTF("Plugin param key:\"%s\" val: \"%s\"\n", $2->string, $3->string);
1420 pp->key = $2->string;
1421 pp->value = $3->string;
1424 pp->next = olsr_cnf->plugins->params;
1425 olsr_cnf->plugins->params = pp;
1432 vcomment: TOK_COMMENT
1434 //PARSER_DEBUG_PRINTF("Comment\n");
1442 void yyerror (const char *string)
1444 fprintf(stderr, "Config line %d: %s\n", current_line, string);