nft: use xtables_print_num
So we can kill our own implementation.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
diff --git a/iptables/nft-shared.c b/iptables/nft-shared.c
index e981c0d..9e57b36 100644
--- a/iptables/nft-shared.c
+++ b/iptables/nft-shared.c
@@ -489,30 +489,6 @@
cs->jumpto = "";
}
-void print_num(uint64_t number, unsigned int format)
-{
- if (format & FMT_KILOMEGAGIGA) {
- if (number > 99999) {
- number = (number + 500) / 1000;
- if (number > 9999) {
- number = (number + 500) / 1000;
- if (number > 9999) {
- number = (number + 500) / 1000;
- if (number > 9999) {
- number = (number + 500) / 1000;
- printf(FMT("%4lluT ","%lluT "), (unsigned long long)number);
- }
- else printf(FMT("%4lluG ","%lluG "), (unsigned long long)number);
- }
- else printf(FMT("%4lluM ","%lluM "), (unsigned long long)number);
- } else
- printf(FMT("%4lluK ","%lluK "), (unsigned long long)number);
- } else
- printf(FMT("%5llu ","%llu "), (unsigned long long)number);
- } else
- printf(FMT("%8llu ","%llu "), (unsigned long long)number);
-}
-
void print_firewall_details(const struct iptables_command_state *cs,
const char *targname, uint8_t flags,
uint8_t invflags, uint8_t proto,
@@ -522,8 +498,8 @@
printf(FMT("%-4u ", "%u "), num);
if (!(format & FMT_NOCOUNTS)) {
- print_num(cs->counters.pcnt, format);
- print_num(cs->counters.bcnt, format);
+ xtables_print_num(cs->counters.pcnt, format);
+ xtables_print_num(cs->counters.bcnt, format);
}
if (!(format & FMT_NOTARGET))
@@ -613,8 +589,8 @@
{
if (!(format & FMT_NOCOUNTS)) {
printf("-c ");
- print_num(cs->counters.pcnt, format);
- print_num(cs->counters.bcnt, format);
+ xtables_print_num(cs->counters.pcnt, format);
+ xtables_print_num(cs->counters.bcnt, format);
}
if (iniface != NULL) {
diff --git a/iptables/nft-shared.h b/iptables/nft-shared.h
index 6e45538..861b6db 100644
--- a/iptables/nft-shared.h
+++ b/iptables/nft-shared.h
@@ -86,7 +86,6 @@
void *data, size_t dlen, bool *inv);
void nft_rule_to_iptables_command_state(struct nft_rule *r,
struct iptables_command_state *cs);
-void print_num(uint64_t number, unsigned int format);
void print_firewall_details(const struct iptables_command_state *cs,
const char *targname, uint8_t flags,
uint8_t invflags, uint8_t proto,
diff --git a/iptables/nft.c b/iptables/nft.c
index 3b393cc..5c79455 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -1817,9 +1817,9 @@
printf(" (policy %s", pol);
if (!(format & FMT_NOCOUNTS)) {
fputc(' ', stdout);
- print_num(counters->pcnt, (format|FMT_NOTABLE));
+ xtables_print_num(counters->pcnt, (format|FMT_NOTABLE));
fputs("packets, ", stdout);
- print_num(counters->bcnt, (format|FMT_NOTABLE));
+ xtables_print_num(counters->bcnt, (format|FMT_NOTABLE));
fputs("bytes", stdout);
}
printf(")\n");