iptables: Add __connman_iptables_dump()
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Tue, 12 Mar 2013 17:16:36 +0000 (18:16 +0100)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Mon, 18 Mar 2013 12:31:25 +0000 (14:31 +0200)
In order to allow our test tool iptables-tests to dump a table
we need an dump function. The only user will be this tool. That allows
the linker to remove this code, so no additional code size.

src/connman.h
src/iptables.c

index 19bca74..9a607fb 100644 (file)
@@ -790,6 +790,7 @@ int __connman_stats_get(struct connman_service *service,
                                connman_bool_t roaming,
                                struct connman_stats_data *data);
 
+int __connman_iptables_dump(const char *table_name);
 int __connman_iptables_new_chain(const char *table_name,
                                        const char *chain);
 int __connman_iptables_delete_chain(const char *table_name,
index ea2a52b..3fa8140 100644 (file)
@@ -2091,6 +2091,21 @@ static void cleanup_parse_context(struct parse_context *ctx)
        g_free(ctx);
 }
 
+int __connman_iptables_dump(const char *table_name)
+{
+       struct connman_iptables *table;
+
+       DBG("-t %s -L", table_name);
+
+       table = pre_load_table(table_name, NULL);
+       if (table == NULL)
+               return -EINVAL;
+
+       dump_table(table);
+
+       return 0;
+}
+
 int __connman_iptables_new_chain(const char *table_name,
                                        const char *chain)
 {