summaryrefslogtreecommitdiffstats
path: root/src/rule.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2014-01-16 20:01:56 +0000
committerPatrick McHardy <kaber@trash.net>2014-01-16 20:01:56 +0000
commit11884cfb1c0432cc455ff8e3269500e819e0c434 (patch)
tree90678c8cf7a3193a1356069a238e7bd1428bb251 /src/rule.c
parent21cfa9a7405f78f424c869e592d21ebdaf379803 (diff)
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 <kaber@trash.net>
Diffstat (limited to 'src/rule.c')
-rw-r--r--src/rule.c15
1 files changed, 9 insertions, 6 deletions
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 = ");