2 * src/lib/neigh.c CLI Neighbour Helpers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation version 2.1
9 * Copyright (c) 2008-2009 Thomas Graf <tgraf@suug.ch>
14 * @defgroup cli_neigh Neighbour
19 #include <netlink/cli/utils.h>
20 #include <netlink/cli/neigh.h>
22 struct rtnl_neigh *nl_cli_neigh_alloc(void)
24 struct rtnl_neigh *neigh;
26 neigh = rtnl_neigh_alloc();
28 nl_cli_fatal(ENOMEM, "Unable to allocate neighbout object");
33 void nl_cli_neigh_parse_dst(struct rtnl_neigh *neigh, char *arg)
38 a = nl_cli_addr_parse(arg, rtnl_neigh_get_family(neigh));
39 if ((err = rtnl_neigh_set_dst(neigh, a)) < 0)
40 nl_cli_fatal(err, "Unable to set local address: %s",
46 void nl_cli_neigh_parse_lladdr(struct rtnl_neigh *neigh, char *arg)
50 a = nl_cli_addr_parse(arg, AF_UNSPEC);
51 rtnl_neigh_set_lladdr(neigh, a);
55 void nl_cli_neigh_parse_dev(struct rtnl_neigh *neigh,
56 struct nl_cache *link_cache, char *arg)
60 if (!(ival = rtnl_link_name2i(link_cache, arg)))
61 nl_cli_fatal(ENOENT, "Link \"%s\" does not exist", arg);
63 rtnl_neigh_set_ifindex(neigh, ival);
66 void nl_cli_neigh_parse_family(struct rtnl_neigh *neigh, char *arg)
70 if ((family = nl_str2af(arg)) == AF_UNSPEC)
72 "Unable to translate address family \"%s\"", arg);
74 rtnl_neigh_set_family(neigh, family);
77 void nl_cli_neigh_parse_state(struct rtnl_neigh *neigh, char *arg)
81 if ((state = rtnl_neigh_str2state(arg)) < 0)
82 nl_cli_fatal(state, "Unable to translate state \"%s\": %s",
85 rtnl_neigh_set_state(neigh, state);