if (nlt == NULL)
memory_allocation_error();
nfnl_nft_table_set_family(nlt, h->family);
- nfnl_nft_table_set_name(nlt, h->table, strlen(h->table) + 1);
+ if (h->table != NULL)
+ nfnl_nft_table_set_name(nlt, h->table, strlen(h->table) + 1);
return nlt;
}
%token HOOK "hook"
%token <val> HOOKNUM "hooknum"
%token TABLE "table"
+%token TABLES "tables"
%token CHAIN "chain"
%token RULE "rule"
%token SETS "sets"
%type <cmd> base_cmd add_cmd insert_cmd delete_cmd list_cmd flush_cmd rename_cmd
%destructor { cmd_free($$); } base_cmd add_cmd insert_cmd delete_cmd list_cmd flush_cmd rename_cmd
-%type <handle> table_spec chain_spec chain_identifier ruleid_spec
-%destructor { handle_free(&$$); } table_spec chain_spec chain_identifier ruleid_spec
+%type <handle> table_spec tables_spec chain_spec chain_identifier ruleid_spec
+%destructor { handle_free(&$$); } table_spec tables_spec chain_spec chain_identifier ruleid_spec
%type <handle> set_spec set_identifier
%destructor { handle_free(&$$); } set_spec set_identifier
%type <val> handle_spec family_spec
;
list_cmd : TABLE table_spec
+ {
+ $$ = cmd_alloc(CMD_LIST, CMD_OBJ_TABLE, &$2, NULL);
+ }
+ | TABLES tables_spec
{
$$ = cmd_alloc(CMD_LIST, CMD_OBJ_TABLE, &$2, NULL);
}
}
;
+tables_spec : family_spec
+ {
+ memset(&$$, 0, sizeof($$));
+ $$.family = $1;
+ $$.table = NULL;
+ }
+ ;
+
chain_spec : table_spec identifier
{
$$ = $1;
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) < 0)
+ return -1;
+
+ list_for_each_entry(table, &ctx->list, list) {
+ printf("table %s\n", table->handle.table);
+ }
+ return 0;
+ }
+ /* List content of this table */
if (do_list_sets(ctx, table) < 0)
return -1;
if (netlink_list_chains(ctx, &cmd->handle) < 0)