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