};
struct connman_iptables_entry {
- int builtin;
- int std_target;
- int jump_offset;
+ int offset;
struct ipt_entry *entry;
};
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)
{
table->num_entries++;
table->size += entry->next_offset;
+ update_offsets(table);
+
return 0;
}