2 * src/lib/link.c CLI Link 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_link Links
19 #include <netlink/cli/utils.h>
20 #include <netlink/cli/link.h>
22 struct rtnl_link *nl_cli_link_alloc(void)
24 struct rtnl_link *link;
26 link = rtnl_link_alloc();
28 nl_cli_fatal(ENOMEM, "Unable to allocate link object");
33 void nl_cli_link_parse_family(struct rtnl_link *link, char *arg)
37 if ((family = nl_str2af(arg)) == AF_UNSPEC)
39 "Unable to translate address family \"%s\"", arg);
41 rtnl_link_set_family(link, family);
44 void nl_cli_link_parse_name(struct rtnl_link *link, char *arg)
46 rtnl_link_set_name(link, arg);
49 void nl_cli_link_parse_mtu(struct rtnl_link *link, char *arg)
51 uint32_t mtu = nl_cli_parse_u32(arg);
52 rtnl_link_set_mtu(link, mtu);
55 void nl_cli_link_parse_ifindex(struct rtnl_link *link, char *arg)
57 uint32_t index = nl_cli_parse_u32(arg);
58 rtnl_link_set_ifindex(link, index);
61 void nl_cli_link_parse_txqlen(struct rtnl_link *link, char *arg)
63 uint32_t qlen = nl_cli_parse_u32(arg);
64 rtnl_link_set_txqlen(link, qlen);
67 void nl_cli_link_parse_weight(struct rtnl_link *link, char *arg)
69 uint32_t weight = nl_cli_parse_u32(arg);
70 rtnl_link_set_weight(link, weight);