summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2015-07-06 13:39:14 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2015-07-14 18:07:14 +0200
commite4d21958c8351b8282a3a079bb934c486cd1e0f6 (patch)
treed163210a5f937ffd39e98601c4a0313f9da2dc79
parent0701d46571f9c4238a600d6fcd981add503a1ba9 (diff)
rule: add do_list_tables()
Wrap code to list existing tables in a function. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--src/rule.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/rule.c b/src/rule.c
index 993f9704..1e712a55 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -900,6 +900,21 @@ static int do_list_ruleset(struct netlink_ctx *ctx, struct cmd *cmd)
return 0;
}
+static int do_list_tables(struct netlink_ctx *ctx, struct cmd *cmd)
+{
+ struct table *table;
+
+ if (netlink_list_tables(ctx, &cmd->handle, &cmd->location) < 0)
+ return -1;
+
+ list_for_each_entry(table, &table_list, list)
+ printf("table %s %s\n",
+ family2str(table->handle.family),
+ table->handle.table);
+
+ return 0;
+}
+
static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd)
{
struct table *table = NULL;
@@ -917,21 +932,8 @@ static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd)
switch (cmd->obj) {
case CMD_OBJ_TABLE:
- if (!cmd->handle.table) {
- /* List all existing tables */
- struct table *table;
-
- if (netlink_list_tables(ctx, &cmd->handle,
- &cmd->location) < 0)
- return -1;
-
- list_for_each_entry(table, &ctx->list, list) {
- printf("table %s %s\n",
- family2str(table->handle.family),
- table->handle.table);
- }
- return 0;
- }
+ if (!cmd->handle.table)
+ return do_list_tables(ctx, cmd);
return do_list_table(ctx, cmd, table);
case CMD_OBJ_CHAIN:
return do_list_table(ctx, cmd, table);