summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Graf <tgr@lsx.(none)>2010-07-02 12:06:59 (GMT)
committerThomas Graf <tgr@lsx.(none)>2010-07-02 12:06:59 (GMT)
commitdb5bd57899affbcaf42ac0b93c5c7be8f51ca390 (patch)
treeca9e9cc76aad8662a7ac4005f7807ae6d476e3c7 /src
parentd378220c96c3c8b6f27dca33e7d8ba03318f9c2d (diff)
downloadlibnl-db5bd57899affbcaf42ac0b93c5c7be8f51ca390.zip
libnl-db5bd57899affbcaf42ac0b93c5c7be8f51ca390.tar.gz
libnl-db5bd57899affbcaf42ac0b93c5c7be8f51ca390.tar.bz2
Packet Location Interface
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am6
-rw-r--r--src/nl-pktloc-lookup.c37
2 files changed, 42 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index ca37843..4e2b57c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,7 +20,8 @@ noinst_PROGRAMS = \
nl-route-add nl-route-delete nl-route-get nl-route-list \
nl-fib-lookup \
nl-list-caches nl-list-sockets \
- nl-util-addr
+ nl-util-addr \
+ nl-pktloc-lookup
genl_ctrl_list_SOURCES = genl-ctrl-list.c
genl_ctrl_list_LDADD = -lnl-genl -lnl-route
@@ -95,3 +96,6 @@ nl_list_sockets_LDADD = -lnl-route
nl_util_addr_SOURCES = nl-util-addr.c
nl_util_addr_LDADD = -lnl-route
+
+nl_pktloc_lookup_SOURCES = nl-pktloc-lookup.c
+nl_pktloc_lookup_LDADD = -lnl-route
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;
+}