From d3f143727c308ff303ea9404945e71138a7792a1 Mon Sep 17 00:00:00 2001 From: Serhey Popovych Date: Thu, 1 Mar 2018 13:03:12 +0200 Subject: xtables: Introduce and use common function to print val[/mask] arguments There are number of places where argument is in val[/mask] format printed in extensions and some of them may print corresponding symbolic name. By introducing common function for this task we eliminate custom code parts in extensions to perform printing of arguments in required formats. Use xtables_print_mark_mask() helper for extensions without symbolic name for val[/mask]. Signed-off-by: Serhey Popovych Signed-off-by: Florian Westphal --- extensions/libxt_connmark.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'extensions/libxt_connmark.c') diff --git a/extensions/libxt_connmark.c b/extensions/libxt_connmark.c index be3499b6..cb4264e5 100644 --- a/extensions/libxt_connmark.c +++ b/extensions/libxt_connmark.c @@ -69,14 +69,6 @@ static void connmark_parse(struct xt_option_call *cb) markinfo->invert = 1; } -static void print_mark(unsigned int mark, unsigned int mask) -{ - if (mask != 0xffffffffU) - printf(" 0x%x/0x%x", mark, mask); - else - printf(" 0x%x", mark); -} - static void connmark_print(const void *ip, const struct xt_entry_match *match, int numeric) { @@ -85,7 +77,8 @@ connmark_print(const void *ip, const struct xt_entry_match *match, int numeric) printf(" CONNMARK match "); if (info->invert) printf("!"); - print_mark(info->mark, info->mask); + + xtables_print_mark_mask(info->mark, info->mask); } static void @@ -97,7 +90,8 @@ connmark_mt_print(const void *ip, const struct xt_entry_match *match, printf(" connmark match "); if (info->invert) printf("!"); - print_mark(info->mark, info->mask); + + xtables_print_mark_mask(info->mark, info->mask); } static void connmark_save(const void *ip, const struct xt_entry_match *match) @@ -108,7 +102,7 @@ static void connmark_save(const void *ip, const struct xt_entry_match *match) printf(" !"); printf(" --mark"); - print_mark(info->mark, info->mask); + xtables_print_mark_mask(info->mark, info->mask); } static void @@ -120,7 +114,7 @@ connmark_mt_save(const void *ip, const struct xt_entry_match *match) printf(" !"); printf(" --mark"); - print_mark(info->mark, info->mask); + xtables_print_mark_mask(info->mark, info->mask); } static void print_mark_xlate(unsigned int mark, unsigned int mask, -- cgit v1.2.3