summaryrefslogtreecommitdiffstats
path: root/src/nl-pktloc-lookup.c
blob: 09b04b246d4adcc126c4de4313fe4732fb95a68b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;
}