]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
nl-classid-lookup: Added --raw option to print classid without pretty printing it
authorThomas Graf <tgraf@suug.ch>
Mon, 1 Nov 2010 14:20:43 +0000 (15:20 +0100)
committerThomas Graf <tgraf@suug.ch>
Mon, 1 Nov 2010 14:20:43 +0000 (15:20 +0100)
man/nl-classid-lookup.8
src/nl-classid-lookup.c

index f4474613043afe482174befab04b77337a1b7634..d48e9eb76547e26650e3c5896801298e2a350b44 100644 (file)
@@ -6,6 +6,7 @@ nl\-classid\-lookup - Lookup classid definitions
 .B nl\-classid\-lookup
 .RB [ \-hv ]
 .RB [ \-r ]
+.RB [ \-\-raw ]
 .I name
 
 .SH DESCRIPTION
@@ -23,6 +24,9 @@ Print versioning information to console and exit.
 .TP
 .BR \-\^r " or " \-\-reverse
 Do a reverse lookup. Lookup a classid and print its name.
+.TP
+.B \-\-raw
+Print the raw classid in hexadecimal format, do not pretty print it.
 
 .SH USAGE
 .PP
index faa65ddcc8f2e1ee296ec9cac69311bd7ff71987..1d45d0b22858a62ba716e5fd592320344819b4f6 100644 (file)
@@ -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;