Commit 1e264abc authored by Stephen Hemminger's avatar Stephen Hemminger

ip: add iec formatted option and cleanup code

Add a new -iec option in addition to -human.
Cleanup code so the formatting of numbers is done in one function,
not 2 ways and 2 sizes.
parent b68d9837
......@@ -12,6 +12,7 @@
extern int preferred_family;
extern int human_readable;
extern int use_iec;
extern int show_stats;
extern int show_details;
extern int show_raw;
......
......@@ -25,6 +25,7 @@
int preferred_family = AF_UNSPEC;
int human_readable = 0;
int use_iec = 0;
int show_stats = 0;
int show_details = 0;
int resolve_hosts = 0;
......@@ -48,7 +49,7 @@ static void usage(void)
" tunnel | tuntap | maddr | mroute | mrule | monitor | xfrm |\n"
" netns | l2tp | tcp_metrics | token | netconf }\n"
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
" -h[uman-readable] |\n"
" -h[uman-readable] | -iec |\n"
" -f[amily] { inet | inet6 | ipx | dnet | bridge | link } |\n"
" -4 | -6 | -I | -D | -B | -0 |\n"
" -l[oops] { maximum-addr-flush-attempts } |\n"
......@@ -217,6 +218,8 @@ int main(int argc, char **argv)
} else if (matches(opt, "-human") == 0 ||
matches(opt, "-human-readable") == 0) {
++human_readable;
} else if (matches(opt, "-iec") == 0) {
++use_iec;
} else if (matches(opt, "-stats") == 0 ||
matches(opt, "-statistics") == 0) {
++show_stats;
......
This diff is collapsed.
......@@ -661,11 +661,23 @@ specifies what group of devices to show.
.B up
only display running interfaces.
.SH "NOTES"
Human readable values are calculated with SI prefixes, so with a decimal
base, not binary. (This is unlike
.BR ifconfig (8)
, with uses binary prefix.) 1,000 bytes are 1 kB, 1,000 kB are 1 MB, ...
The show command has additional formatting options:
.TP
.BR "\-s" , " \-stats", " \-statistics"
output more statistics about packet usage.
.TP
.BR "\-d", " \-details"
output more detailed information.
.TP
.BR "\-h", " \-human", " \-human-readble"
output statistics with human readable values number followed by suffix
.TP
.BR "\-iec"
print human readable rates in IEC units (ie. 1K = 1024).
.SH "EXAMPLES"
.PP
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment