summaryrefslogtreecommitdiff
path: root/tools/iptables-test.c
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2011-09-22 15:39:19 +0300
committerSamuel Ortiz <sameo@linux.intel.com>2011-09-22 15:22:46 +0200
commit006cef4c716726eae7091f62565712dd2c5d4df5 (patch)
tree8b1e339cd03a4d3e42e17d5f9ee49efe9b80ed04 /tools/iptables-test.c
parentad8b4d1fee361e47b5dde567529e0d5259186a61 (diff)
downloadconnman-006cef4c716726eae7091f62565712dd2c5d4df5.tar.gz
connman-006cef4c716726eae7091f62565712dd2c5d4df5.tar.bz2
connman-006cef4c716726eae7091f62565712dd2c5d4df5.zip
tools: find_chain_head/find_chain_tail code factorization in iptables-test
Diffstat (limited to 'tools/iptables-test.c')
-rw-r--r--tools/iptables-test.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/tools/iptables-test.c b/tools/iptables-test.c
index bfe48031..555aa2a2 100644
--- a/tools/iptables-test.c
+++ b/tools/iptables-test.c
@@ -236,37 +236,15 @@ static GList *find_chain_tail(struct connman_iptables *table,
char *chain_name)
{
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;
+ struct connman_iptables_entry *tail;
- /* 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;