コード例 #1
0
ファイル: nl-neightbl-list.c プロジェクト: Happy-Ferret/libnl
int main(int argc, char *argv[])
{
	struct nl_sock *sock;
	struct nl_cache *neightbl_cache;
	struct nl_dump_params params = {
		.dp_type = NL_DUMP_LINE,
		.dp_fd = stdout,
	};

	sock = nl_cli_alloc_socket();
	nl_cli_connect(sock, NETLINK_ROUTE);
	nl_cli_link_alloc_cache(sock);
	neightbl_cache = nl_cli_alloc_cache(sock, "neighbour table",
					    rtnl_neightbl_alloc_cache);

	for (;;) {
		int c, optidx = 0;
		static struct option long_opts[] = {
			{ "format", 1, 0, 'f' },
			{ "help", 0, 0, 'h' },
			{ "version", 0, 0, 'v' },
			{ 0, 0, 0, 0 }
		};

		c = getopt_long(argc, argv, "f:hv", long_opts, &optidx);
		if (c == -1)
			break;

		switch (c) {
		case 'f': params.dp_type = nl_cli_parse_dumptype(optarg); break;
		case 'h': print_usage(); break;
		case 'v': nl_cli_print_version(); break;
		}
	}

	nl_cache_dump(neightbl_cache, &params);

	return 0;
}
コード例 #2
0
static struct nl_cache *alloc_genl_family_cache(struct nl_sock *sk)
{
	return nl_cli_alloc_cache(sk, "generic netlink family",
			   genl_ctrl_alloc_cache);
}
コード例 #3
0
ファイル: ct.c プロジェクト: Distrotech/libnl
struct nl_cache *nl_cli_ct_alloc_cache(struct nl_sock *sk)
{
	return nl_cli_alloc_cache(sk, "conntrack", nfnl_ct_alloc_cache);
}