diff options
author | Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> | 2011-09-23 14:43:34 +0300 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-09-29 17:52:59 +0200 |
commit | da35161e6452fff93a5d1281bbc856a1ee3e89f3 (patch) | |
tree | 16d0db6643f299db55f7898bca7100b0f0ed4fbd /src/iptables.c | |
parent | 4380ea04afa4ba80e2f272bd02996bb2f93875a4 (diff) | |
download | connman-da35161e6452fff93a5d1281bbc856a1ee3e89f3.tar.gz connman-da35161e6452fff93a5d1281bbc856a1ee3e89f3.tar.bz2 connman-da35161e6452fff93a5d1281bbc856a1ee3e89f3.zip |
iptables: find_chain_head/find_chain_tail code factorization
Diffstat (limited to 'src/iptables.c')
-rw-r--r-- | src/iptables.c | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/src/iptables.c b/src/iptables.c index e852e01c..45c71cdd 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -242,38 +242,16 @@ static GList *find_chain_head(struct connman_iptables *table, static GList *find_chain_tail(struct connman_iptables *table, char *chain_name) { + struct connman_iptables_entry *tail; GList *chain_head, *list; - struct connman_iptables_entry *head, *tail; - struct ipt_entry *entry; - struct xt_entry_target *target; - int builtin; - - /* First we look for the head */ - for (list = table->entries; list; list = list->next) { - head = list->data; - entry = head->entry; - - /* Buit-in chain */ - builtin = head->builtin; - if (builtin >= 0 && !strcmp(hooknames[builtin], chain_name)) - break; - /* User defined chain */ - target = ipt_get_target(entry); - if (!strcmp(target->u.user.name, IPT_ERROR_TARGET) && - !strcmp((char *)target->data, chain_name)) - break; - } - - if (list == NULL) + chain_head = find_chain_head(table, chain_name); + if (chain_head == NULL) return NULL; - chain_head = list; - /* Then we look for the next chain */ for (list = chain_head->next; list; list = list->next) { tail = list->data; - entry = tail->entry; if (is_chain(table, tail)) return list; |