Change formatting of u32 back to default

Don't break scripts that depend on previous offset/value format.
Introduce a new -pretty flag for decoding, and (*gasp*) document
the formatting arguments.
This commit is contained in:
Stephen Hemminger 2008-05-09 15:42:34 -07:00
parent 7dec1bf88b
commit 44dcfe8201
3 changed files with 45 additions and 4 deletions

View File

@ -34,16 +34,28 @@ priority filtertype
.B flowid .B flowid
flow-id flow-id
.B tc [-s | -d ] qdisc show [ dev .B tc
.RI "[ " FORMAT " ]"
.B qdisc show [ dev
DEV DEV
.B ] .B ]
.P .P
.B tc [-s | -d ] class show dev .B tc
.RI "[ " FORMAT " ]"
.B class show dev
DEV DEV
.P .P
.B tc filter show dev .B tc filter show dev
DEV DEV
.ti -8
.IR FORMAT " := {"
\fB\-s\fR[\fItatistics\fR] |
\fB\-d\fR[\fIetails\fR] |
\fB\-r\fR[\fIaw\fR] |
\fB\-p\fR[\fIretty\fR] |
\fB\i\fR[\fIec\fR] }
.SH DESCRIPTION .SH DESCRIPTION
.B Tc .B Tc
is used to configure Traffic Control in the Linux kernel. Traffic Control consists is used to configure Traffic Control in the Linux kernel. Traffic Control consists
@ -326,6 +338,29 @@ link
Only available for qdiscs and performs a replace where the node Only available for qdiscs and performs a replace where the node
must exist already. must exist already.
.SH FORMAT
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 about rates and cell sizes.
.TP
.BR "\-r", " \-raw"
output raw hex values for handles.
.TP
.BR "\-p", " \-pretty"
decode filter offset and mask values to equivalent filter commands based on TCP/IP.
.TP
.BR "\-iec"
print rates in IEC units (ie. 1K = 1024).
.SH HISTORY .SH HISTORY
.B tc .B tc

View File

@ -25,6 +25,8 @@
#include "utils.h" #include "utils.h"
#include "tc_util.h" #include "tc_util.h"
extern int show_pretty;
static void explain(void) static void explain(void)
{ {
fprintf(stderr, "Usage: ... u32 [ match SELECTOR ... ] [ link HTID ]" fprintf(stderr, "Usage: ... u32 [ match SELECTOR ... ] [ link HTID ]"
@ -793,7 +795,7 @@ static void show_key(FILE *f, const struct tc_u32_key *key)
{ {
char abuf[256]; char abuf[256];
if (show_raw) if (!show_pretty)
goto raw; goto raw;
switch (key->off) { switch (key->off) {

View File

@ -33,6 +33,8 @@
int show_stats = 0; int show_stats = 0;
int show_details = 0; int show_details = 0;
int show_raw = 0; int show_raw = 0;
int show_pretty = 0;
int resolve_hosts = 0; int resolve_hosts = 0;
int use_iec = 0; int use_iec = 0;
int force = 0; int force = 0;
@ -182,7 +184,7 @@ static void usage(void)
fprintf(stderr, "Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n" fprintf(stderr, "Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n"
" tc [-force] -batch file\n" " tc [-force] -batch file\n"
"where OBJECT := { qdisc | class | filter | action | monitor }\n" "where OBJECT := { qdisc | class | filter | action | monitor }\n"
" OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -b[atch] [file] }\n"); " OPTIONS := { -s[tatistics] | -d[etails] | -r[aw] | -p[retty] | -b[atch] [file] }\n");
} }
static int do_cmd(int argc, char **argv) static int do_cmd(int argc, char **argv)
@ -273,6 +275,8 @@ int main(int argc, char **argv)
++show_details; ++show_details;
} else if (matches(argv[1], "-raw") == 0) { } else if (matches(argv[1], "-raw") == 0) {
++show_raw; ++show_raw;
} else if (matches(argv[1], "-pretty") == 0) {
++show_pretty;
} else if (matches(argv[1], "-Version") == 0) { } else if (matches(argv[1], "-Version") == 0) {
printf("tc utility, iproute2-ss%s\n", SNAPSHOT); printf("tc utility, iproute2-ss%s\n", SNAPSHOT);
return 0; return 0;