summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2010-11-01 14:20:43 (GMT)
committerThomas Graf <tgraf@suug.ch>2010-11-01 14:20:43 (GMT)
commitdf36c25bbfb864d8ecf040163e91bbf363f0bf93 (patch)
tree0f235d0c59d9aba82b14af30112390c46c0c89ba /src
parent54e2539ce1a04d0c53ffbdfe3e2766b8e669c6ea (diff)
downloadlibnl-df36c25bbfb864d8ecf040163e91bbf363f0bf93.zip
libnl-df36c25bbfb864d8ecf040163e91bbf363f0bf93.tar.gz
libnl-df36c25bbfb864d8ecf040163e91bbf363f0bf93.tar.bz2
nl-classid-lookup: Added --raw option to print classid without pretty printing it
Diffstat (limited to 'src')
-rw-r--r--src/nl-classid-lookup.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/nl-classid-lookup.c b/src/nl-classid-lookup.c
index faa65dd..1d45d0b 100644
--- a/src/nl-classid-lookup.c
+++ b/src/nl-classid-lookup.c
@@ -20,6 +20,7 @@ static void print_usage(void)
" -h, --help Show this help text.\n"
" -v, --version Show versioning information.\n"
" -r, --reverse Do a reverse lookup, i.e. classid to name.\n"
+" --raw Print the raw classid, not pretty printed.\n"
"\n"
"EXAMPLE\n"
" $ nl-classid-lookup low_latency\n"
@@ -33,14 +34,18 @@ int main(int argc, char *argv[])
{
uint32_t classid;
char *name;
- int err, reverse = 0;
+ int err, reverse = 0, raw = 0;
for (;;) {
int c, optidx = 0;
+ enum {
+ ARG_RAW = 257,
+ };
static struct option long_opts[] = {
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'v' },
{ "reverse", 0, 0, 'r' },
+ { "raw", 0, 0, ARG_RAW },
{ 0, 0, 0, 0 }
};
@@ -52,6 +57,7 @@ int main(int argc, char *argv[])
case 'h': print_usage(); break;
case 'v': nl_cli_print_version(); break;
case 'r': reverse = 1; break;
+ case ARG_RAW: raw = 1; break;
}
}
@@ -72,7 +78,9 @@ int main(int argc, char *argv[])
if (reverse) {
char buf[64];
printf("%s\n", rtnl_tc_handle2str(classid, buf, sizeof(buf)));
- } else
+ } else if (raw)
+ printf("%#x\n", classid);
+ else
printf("%x:%x\n", TC_H_MAJ(classid) >> 16, TC_H_MIN(classid));
return 0;