From 21cfa9a7405f78f424c869e592d21ebdaf379803 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 16 Jan 2014 18:31:16 +0100 Subject: src: use ':' instead of '=>' in dictionaries 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 --- src/rule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rule.c') diff --git a/src/rule.c b/src/rule.c index ec8b6a48..04dd6c77 100644 --- a/src/rule.c +++ b/src/rule.c @@ -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) -- cgit v1.2.3 From 11884cfb1c0432cc455ff8e3269500e819e0c434 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 16 Jan 2014 20:01:56 +0000 Subject: set: make set flags output parsable This patch fixes two problems: - the output of "nft list table ..." is not parsable if sets are included because the parser can't parse the flags. - set flags can't be specified during set creation. To fix this, the set output is changed to: - not print each flag on a single line - prefix the flags with "flags " - only show the interval flag since all others are for internal use only The parser is changed to parse the flags specified in a set declaration. This allows to parse empty sets. The following patch will take care of parsing sets that are already populated. Signed-off-by: Patrick McHardy --- src/rule.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/rule.c') diff --git a/src/rule.c b/src/rule.c index 04dd6c77..0f7f4b51 100644 --- a/src/rule.c +++ b/src/rule.c @@ -89,6 +89,7 @@ struct set *set_lookup(const struct table *table, const char *name) void set_print(const struct set *set) { + const char *delim = ""; const char *type; type = set->flags & SET_F_MAP ? "map" : "set"; @@ -99,12 +100,14 @@ void set_print(const struct set *set) printf(" : %s", set->datatype->name); printf("\n"); - if (set->flags & SET_F_ANONYMOUS) - printf("\t\tanonymous\n"); - if (set->flags & SET_F_CONSTANT) - printf("\t\tconstant\n"); - if (set->flags & SET_F_INTERVAL) - printf("\t\tinterval\n"); + if (set->flags & (SET_F_INTERVAL)) { + printf("\t\tflags "); + if (set->flags & SET_F_INTERVAL) { + printf("%sinterval", delim); + delim = ","; + } + printf("\n"); + } if (set->init != NULL && set->init->size > 0) { printf("\t\telements = "); -- cgit v1.2.3 From bea7aab38f305bb8c2e400d575e6bd0a3c6bbc1f Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 16 Jan 2014 20:01:56 +0000 Subject: set: make set initializer parsable If a set contains elements, the output is not parsable since the elements = { ... } is not understood by the parser. Fix this and also add support for creating constant sets (which only makes sense when using an initializer). Signed-off-by: Patrick McHardy --- src/rule.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/rule.c') diff --git a/src/rule.c b/src/rule.c index 0f7f4b51..9f6c04bb 100644 --- a/src/rule.c +++ b/src/rule.c @@ -100,8 +100,12 @@ void set_print(const struct set *set) printf(" : %s", set->datatype->name); printf("\n"); - if (set->flags & (SET_F_INTERVAL)) { + if (set->flags & (SET_F_CONSTANT | SET_F_INTERVAL)) { printf("\t\tflags "); + if (set->flags & SET_F_CONSTANT) { + printf("%sconstant", delim); + delim = ","; + } if (set->flags & SET_F_INTERVAL) { printf("%sinterval", delim); delim = ","; -- cgit v1.2.3