summaryrefslogtreecommitdiff
path: root/tools/iptables-test.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2010-10-29 17:28:47 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2010-10-30 00:22:21 +0200
commit19f7a884997f3ce8001a3967d9c9d4e39be2ce1e (patch)
treec44a52d669a803fb3121ab6ba03d9f98da3464ff /tools/iptables-test.c
parent7900a98aa762f07fa01537de79cef295052ea967 (diff)
downloadconnman-19f7a884997f3ce8001a3967d9c9d4e39be2ce1e.tar.gz
connman-19f7a884997f3ce8001a3967d9c9d4e39be2ce1e.tar.bz2
connman-19f7a884997f3ce8001a3967d9c9d4e39be2ce1e.zip
iptables-test: Update entries offsets properly
This is needed to set the jump targets.
Diffstat (limited to 'tools/iptables-test.c')
-rw-r--r--tools/iptables-test.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/tools/iptables-test.c b/tools/iptables-test.c
index a3de5131..c4d2cb02 100644
--- a/tools/iptables-test.c
+++ b/tools/iptables-test.c
@@ -82,9 +82,7 @@ struct ipt_error_target {
};
struct connman_iptables_entry {
- int builtin;
- int std_target;
- int jump_offset;
+ int offset;
struct ipt_entry *entry;
};
@@ -221,6 +219,28 @@ static GList *find_chain_tail(struct connman_iptables *table,
return g_list_last(table->entries);
}
+static void update_offsets(struct connman_iptables *table)
+{
+ GList *list, *prev;
+ struct connman_iptables_entry *entry, *prev_entry;
+
+ for (list = table->entries; list; list = list->next) {
+ entry = list->data;
+
+ if (list == table->entries) {
+ entry->offset = 0;
+
+ continue;
+ }
+
+ prev = list->prev;
+ prev_entry = prev->data;
+
+ entry->offset = prev_entry->offset +
+ prev_entry->entry->next_offset;
+ }
+}
+
static int connman_add_entry(struct connman_iptables *table,
struct ipt_entry *entry, GList *before)
{
@@ -239,6 +259,8 @@ static int connman_add_entry(struct connman_iptables *table,
table->num_entries++;
table->size += entry->next_offset;
+ update_offsets(table);
+
return 0;
}