12 #include <netlink/cli/utils.h>
13 #include <netlink/cli/route.h>
14 #include <netlink/cli/link.h>
16 static void print_usage(
void)
18 printf(
"Usage: nl-route-get <addr>\n");
22 static void parse_cb(
struct nl_object *obj,
void *arg)
33 static int cb(
struct nl_msg *msg,
void *arg)
37 if ((err = nl_msg_parse(msg, &parse_cb, NULL)) < 0)
38 nl_cli_fatal(err,
"Unable to parse object: %s", nl_geterror(err));
43 int main(
int argc,
char *argv[])
46 struct nl_cache *link_cache, *route_cache;
50 if (argc < 2 || !strcmp(argv[1],
"-h"))
53 sock = nl_cli_alloc_socket();
54 nl_cli_connect(sock, NETLINK_ROUTE);
55 link_cache = nl_cli_link_alloc_cache(sock);
56 route_cache = nl_cli_route_alloc_cache(sock, 0);
58 dst = nl_cli_addr_parse(argv[1], AF_INET);