diff options
Diffstat (limited to 'src/nl-pktloc-lookup.c')
-rw-r--r-- | src/nl-pktloc-lookup.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/nl-pktloc-lookup.c b/src/nl-pktloc-lookup.c new file mode 100644 index 0000000..09b04b2 --- /dev/null +++ b/src/nl-pktloc-lookup.c @@ -0,0 +1,37 @@ +/* + * src/nl-pktloc-lookup.c Lookup packet location alias + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * Copyright (c) 2010 Thomas Graf <tgraf@suug.ch> + */ + +#include <netlink/cli/utils.h> +#include <netlink/route/pktloc.h> + +static void print_usage(void) +{ + printf("Usage: nl-pktloc-lookup <name>\n"); + exit(0); +} + +int main(int argc, char *argv[]) +{ + struct rtnl_pktloc *loc; + int err; + + if (argc < 2) + print_usage(); + + if ((err = rtnl_pktloc_lookup(argv[1], &loc)) < 0) + nl_cli_fatal(err, "Unable to lookup packet location: %s", + nl_geterror(err)); + + printf("%s: %u %u+%u 0x%x %u\n", loc->name, loc->align, + loc->layer, loc->offset, loc->mask, loc->flags); + + return 0; +} |