]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: use ':' instead of '=>' in dictionaries
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 16 Jan 2014 17:31:16 +0000 (18:31 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 16 Jan 2014 18:48:29 +0000 (19:48 +0100)
Replace => by : to make it easier for most shell users, as
> implies a redirection, let's avoid possible confusion that
may result if you forget to escape it.

This works fine if you don't forget to add space between the
key and the value. If you forget to add the space, depending
on the case, the scanner may recognize it correctly or process
it as a string.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
files/examples/sets_and_maps
include/expression.h
src/expression.c
src/parser.y
src/rule.c
src/scanner.l
tests/dictionary
tests/loop-detect.3
tests/loop-detect.4
tests/verdict-maps

index adfc6884cf387e9d630ab9884bb408d86518ab68..a05199ae18fa84c74e5b031ddd50699c206c0042 100755 (executable)
@@ -25,13 +25,13 @@ table filter {
                type ifindex
        }
 
-       # named map of type ifindex => ipv4_address
+       # named map of type ifindex : ipv4_address
        map nat_map {
-               type ifindex => ipv4_address
+               type ifindex : ipv4_address
        }
 
        map jump_map {
-               type ifindex => verdict
+               type ifindex : verdict
        }
 
        chain input_1 { counter; }
@@ -48,6 +48,6 @@ table filter {
                meta iif @local_ifs counter
                meta iif vmap @jump_map
 
-               #meta iif vmap { eth0 => jump input1, eth1 => jump input2 }
+               #meta iif vmap { eth0 : jump input1, eth1 : jump input2 }
        }
 }
index f0eb7993570b4e5b9f933bfba3b530114af6ef06..a167cf597309d9705f936cab514dc6737d02012a 100644 (file)
@@ -27,7 +27,7 @@
  * @EXPR_LIST:         list of expressions
  * @EXPR_SET:          literal set
  * @EXPR_SET_REF:      set reference
- * @EXPR_MAPPING:      a single mapping (key => value)
+ * @EXPR_MAPPING:      a single mapping (key : value)
  * @EXPR_MAP:          map operation (expr map { EXPR_MAPPING, ... })
  * @EXPR_UNARY:                byteorder conversion, generated during evaluation
  * @EXPR_BINOP:                binary operations (bitwise, shifts)
index a12133c8d052099f7c3e7726fbb5dba8deba68df..c856622436ebe2790059172992ec1cbccde440c8 100644 (file)
@@ -644,7 +644,7 @@ struct expr *set_expr_alloc(const struct location *loc)
 static void mapping_expr_print(const struct expr *expr)
 {
        expr_print(expr->left);
-       printf(" => ");
+       printf(" : ");
        expr_print(expr->right);
 }
 
index d4a79291bb3ffb4c0cfa81d667768e036401351e..5cd8ef678fd66167993636da074653d4ad0ad7f5 100644 (file)
@@ -150,7 +150,6 @@ static void location_update(struct location *loc, struct location *rhs, int n)
 %token ASTERISK                        "*"
 %token DASH                    "-"
 %token AT                      "@"
-%token ARROW                   "=>"
 %token VMAP                    "vmap"
 
 %token INCLUDE                 "include"
@@ -751,7 +750,7 @@ map_block           :       /* empty */     { $$ = $<set>-1; }
                        |       map_block       common_block
                        |       map_block       stmt_seperator
                        |       map_block       TYPE
-                                               identifier      ARROW   identifier
+                                               identifier      COLON   identifier
                                                stmt_seperator
                        {
                                $1->keytype = datatype_lookup_byname($3);
@@ -1243,11 +1242,11 @@ set_list_member_expr    :       opt_newline     expr    opt_newline
                        {
                                $$ = $2;
                        }
-                       |       opt_newline     map_lhs_expr    ARROW   concat_expr     opt_newline
+                       |       opt_newline     map_lhs_expr    COLON   concat_expr     opt_newline
                        {
                                $$ = mapping_expr_alloc(&@$, $2, $4);
                        }
-                       |       opt_newline     map_lhs_expr    ARROW   verdict_expr    opt_newline
+                       |       opt_newline     map_lhs_expr    COLON   verdict_expr    opt_newline
                        {
                                $$ = mapping_expr_alloc(&@$, $2, $4);
                        }
index ec8b6a48763bda8892190ea76df041b506d97f49..04dd6c77de89307292367172d2ab316e42e509e8 100644 (file)
@@ -96,7 +96,7 @@ void set_print(const struct set *set)
 
        printf("\t\ttype %s", set->keytype->name);
        if (set->flags & SET_F_MAP)
-               printf(" => %s", set->datatype->name);
+               printf(" : %s", set->datatype->name);
        printf("\n");
 
        if (set->flags & SET_F_ANONYMOUS)
index 936c035eee6107f826bc23fe23d4e2275da19710..25fbc610e46d58a5597bedcd043b97cbb24e2aaf 100644 (file)
@@ -221,7 +221,6 @@ addrstring  ({macaddr}|{ip4addr}|{ip6addr})
 "@"                    { return AT; }
 "$"                    { return '$'; }
 "="                    { return '='; }
-"=>"                   { return ARROW; }
 "vmap"                 { return VMAP; }
 
 "include"              { return INCLUDE; }
index 4193529563a142821ea951e644d1e2fbf9e57212..b4e6c52159eed0c9f956393641ea9da80fe5fc1b 100644 (file)
@@ -21,32 +21,32 @@ add rule ip filter OUTPUT tcp dport { \
        192.168.0.1, \
 }
 
-# must succeed: expr { expr => verdict, ... }
+# must succeed: expr { expr : verdict, ... }
 add rule ip filter OUTPUT tcp dport vmap { \
-       22 => jump chain1, \
-       23 => jump chain2, \
+       22 : jump chain1, \
+       23 : jump chain2, \
 }
 
-# must fail: expr { expr => verdict, expr => expr, ... }
+# must fail: expr { expr : verdict, expr : expr, ... }
 add rule ip filter OUTPUT tcp dport vmap { \
-       22 => jump chain1, \
-       23 => 0x100, \
+       22 : jump chain1, \
+       23 : 0x100, \
 }
 
-# must fail: expr { expr => expr, ...}
+# must fail: expr { expr : expr, ...}
 add rule ip filter OUTPUT tcp dport vmap { \
-       22 => 0x100, \
-       23 => 0x200, \
+       22 : 0x100, \
+       23 : 0x200, \
 }
 
-# must succeed: expr MAP { expr => expr, ... } expr
+# must succeed: expr MAP { expr : expr, ... } expr
 add rule ip filter OUTPUT meta mark set tcp dport map { \
-       22 => 1, \
-       23 => 2, \
+       22 : 1, \
+       23 : 2, \
 }
 
-# must fail: expr MAP { expr => type1, expr => type2, .. } expr
+# must fail: expr MAP { expr : type1, expr : type2, .. } expr
 add rule ip filter OUTPUT meta mark set tcp dport map { \
-       22 => 1, \
-       23 => 192.168.0.1, \
+       22 : 1, \
+       23 : 192.168.0.1, \
 }
index 3b83ef1220334a2337a00ea0d4bbb6226a443cbd..80f7fc5a0939286046c6ef19a83b2897eede91e5 100644 (file)
@@ -4,4 +4,4 @@
 flush table filter
 add filter chain1 jump chain2
 add filter chain2 jump chain3
-add filter chain3 ip daddr vmap { 10.0.0.1 => continue, 192.168.0.1 => jump chain1 }
+add filter chain3 ip daddr vmap { 10.0.0.1 : continue, 192.168.0.1 : jump chain1 }
index f6f4d572d65f30a14656961f7282ab00fbe109fb..acd9a3427a16e922dd0e62afeff4d85671e8d86b 100644 (file)
@@ -3,5 +3,5 @@
 # Circular jump with an intermediate anonymous verdict map: chain1 -> chain2 -> chain3 -> chain1
 flush table filter
 add filter chain1 jump chain2
-add filter chain2 ip daddr vmap { 10.0.0.1 => continue, 192.168.0.1 => jump chain3 }
+add filter chain2 ip daddr vmap { 10.0.0.1 : continue, 192.168.0.1 : jump chain3 }
 add filter chain3 jump chain1
index 72ef98f98d7234bd9c08f482b1dd3e9904f594ea..c1630ce355d4901909cda3200dfc8079fa92e55f 100644 (file)
@@ -14,7 +14,7 @@ add chain ip filter chain3
 add filter chain3 counter
 
 add filter input ip saddr vmap { \
-       10.0.0.0/24 => jump chain1, \
-       10.0.0.0/8  => jump chain2, \
-       8.8.8.8 => jump chain3 \
+       10.0.0.0/24 : jump chain1, \
+       10.0.0.0/8  : jump chain2, \
+       8.8.8.8 : jump chain3 \
 }