diff options
author | Serhey Popovych <serhe.popovych@gmail.com> | 2018-03-01 13:03:12 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2018-04-27 18:56:22 +0200 |
commit | d3f143727c308ff303ea9404945e71138a7792a1 (patch) | |
tree | d454846d68234640b3fdec17414ad6a69bd943cf /extensions/libipt_realm.c | |
parent | 29b1d97764d1849651388d870565b3fa815a0bd8 (diff) |
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 <serhe.popovych@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'extensions/libipt_realm.c')
-rw-r--r-- | extensions/libipt_realm.c | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/extensions/libipt_realm.c b/extensions/libipt_realm.c index 545b2580..e01d048e 100644 --- a/extensions/libipt_realm.c +++ b/extensions/libipt_realm.c @@ -47,23 +47,6 @@ static void realm_parse(struct xt_option_call *cb) ri->invert = 1; } -static void -print_realm(unsigned long id, unsigned long mask, int numeric) -{ - const char *name = NULL; - - if (mask != 0xffffffff) - printf(" 0x%lx/0x%lx", id, mask); - else { - if (numeric == 0) - name = xtables_lmap_id2name(realms, id); - if (name) - printf(" %s", name); - else - printf(" 0x%lx", id); - } -} - static void realm_print(const void *ip, const struct xt_entry_match *match, int numeric) { @@ -73,7 +56,7 @@ static void realm_print(const void *ip, const struct xt_entry_match *match, printf(" !"); printf(" realm"); - print_realm(ri->id, ri->mask, numeric); + xtables_print_val_mask(ri->id, ri->mask, numeric ? NULL : realms); } static void realm_save(const void *ip, const struct xt_entry_match *match) @@ -84,7 +67,7 @@ static void realm_save(const void *ip, const struct xt_entry_match *match) printf(" !"); printf(" --realm"); - print_realm(ri->id, ri->mask, 0); + xtables_print_val_mask(ri->id, ri->mask, realms); } static void |