summaryrefslogtreecommitdiff
path: root/tools/iptables-test.c
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2011-09-22 15:39:32 +0300
committerSamuel Ortiz <sameo@linux.intel.com>2011-09-22 15:22:47 +0200
commitf5962b0554d0f289a5c9f2f22031880fc5d5fcac (patch)
treeb313e76df98ea7da2c0aa6cfa1bcf1fa73a0b24a /tools/iptables-test.c
parenta16d6c316722e340947219de8fea6ebb3b8dce04 (diff)
downloadconnman-f5962b0554d0f289a5c9f2f22031880fc5d5fcac.tar.gz
connman-f5962b0554d0f289a5c9f2f22031880fc5d5fcac.tar.bz2
connman-f5962b0554d0f289a5c9f2f22031880fc5d5fcac.zip
tools: Adding capability to load necessary modules into iptables-test
Diffstat (limited to 'tools/iptables-test.c')
-rw-r--r--tools/iptables-test.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/tools/iptables-test.c b/tools/iptables-test.c
index a7193c2e..887fd3ce 100644
--- a/tools/iptables-test.c
+++ b/tools/iptables-test.c
@@ -1137,9 +1137,22 @@ static int add_entry(struct ipt_entry *entry, struct connman_iptables *table)
static struct connman_iptables *connman_iptables_init(const char *table_name)
{
- struct connman_iptables *table;
+ struct connman_iptables *table = NULL;
+ char *module = NULL;
socklen_t s;
+ if (xtables_insmod("ip_tables", NULL, TRUE) != 0)
+ goto err;
+
+ module = g_strconcat("iptable_", table_name, NULL);
+ if (module == NULL)
+ goto err;
+
+ if (xtables_insmod(module, NULL, TRUE) != 0)
+ goto err;
+
+ g_free(module);
+
table = g_try_new0(struct connman_iptables, 1);
if (table == NULL)
return NULL;
@@ -1182,10 +1195,10 @@ static struct connman_iptables *connman_iptables_init(const char *table_name)
table->blob_entries->size,
add_entry, table);
-
return table;
err:
+ g_free(module);
connman_iptables_cleanup(table);