add another alias for IPv4Multicast (and clean up parser a bit) issue #11
authorMarkus Kittenberger <Markus.Kittenberger@gmx.at>
Wed, 16 Jun 2010 13:05:08 +0000 (15:05 +0200)
committerMarkus Kittenberger <Markus.Kittenberger@gmx.at>
Wed, 16 Jun 2010 13:05:08 +0000 (15:05 +0200)
src/cfgparser/oparse.y
src/cfgparser/oscan.lex

index 42ac7ca..618719a 100644 (file)
@@ -228,8 +228,9 @@ static int add_ipv6_addr(YYSTYPE ipaddr_arg, YYSTYPE prefixlen_arg)
 %token TOK_MAXIPC
 
 %token TOK_IFMODE
-%token TOK_IPV4BROADCAST
 %token TOK_IPV4MULTICAST
+%token TOK_IP4BROADCAST
+%token TOK_IPV4BROADCAST
 %token TOK_IPV6MULTICAST
 %token TOK_IPV4SRC
 %token TOK_IPV6SRC
@@ -371,8 +372,9 @@ ifstmts:   | ifstmts ifstmt
 ifstmt:      vcomment
              | iifweight
              | isetifmode
-             | isetipv4br
-             | isetipv4mc
+             | TOK_IP4BROADCAST isetipv4mc
+             | TOK_IPV4BROADCAST isetipv4mc
+             | TOK_IPV4MULTICAST isetipv4mc
              | isetipv6mc
              | isetipv4src
              | isetipv6src
@@ -536,43 +538,24 @@ isetifmode: TOK_IFMODE TOK_STRING
 }
 ;
 
-isetipv4br: TOK_IPV4BROADCAST TOK_IPV4_ADDR
-{
-  struct in_addr in;
-  int ifcnt = ifs_in_curr_cfg;
-  struct olsr_if *ifs = olsr_cnf->interfaces;
-
-  PARSER_DEBUG_PRINTF("\tIPv4 broadcast: %s\n", $2->string);
-
-  if (inet_aton($2->string, &in) == 0) {
-    fprintf(stderr, "isetipv4br: Failed converting IP address %s\n", $2->string);
-    YYABORT;
-  }
-
-       SET_IFS_CONF(ifs, ifcnt, ipv4_multicast.v4, in);
-
-  free($2->string);
-  free($2);
-}
-;
-
-isetipv4mc: TOK_IPV4MULTICAST TOK_IPV4_ADDR
+/* called if prepended with TOK_IPV4MULTICAST TOK_IP4BROADCAST TOK_IPV4BROADCAST */
+isetipv4mc: TOK_IPV4_ADDR
 {
   struct in_addr in;
   int ifcnt = ifs_in_curr_cfg;
   struct olsr_if *ifs = olsr_cnf->interfaces;
 
-  PARSER_DEBUG_PRINTF("\tIPv4 broadcast: %s\n", $2->string);
+  PARSER_DEBUG_PRINTF("\tIPv4 broadcast: %s\n", $1->string);
 
-  if (inet_aton($2->string, &in) == 0) {
-    fprintf(stderr, "isetipv4br: Failed converting IP address %s\n", $2->string);
+  if (inet_aton($1->string, &in) == 0) {
+    fprintf(stderr, "isetipv4br: Failed converting IP address %s\n", $1->string);
     YYABORT;
   }
 
        SET_IFS_CONF(ifs, ifcnt, ipv4_multicast.v4, in);
 
-  free($2->string);
-  free($2);
+  free($1->string);
+  free($1);
 }
 ;
 
index cd32baf..52342aa 100644 (file)
@@ -503,6 +503,10 @@ IPV6ADDR {IPV6PAT1}|{IPV6PAT2}|{IPV6PAT3}|{IPV6PAT4}|{IPV6PAT5}|{IPV6PAT6}|{IPV6
     return TOK_MAIN_IP;
 }
 "Ip4Broadcast" {
+    yylval = NULL;
+    return TOK_IP4BROADCAST;
+}
+"IPv4Broadcast" {
     yylval = NULL;
     return TOK_IPV4BROADCAST;
 }