1 /* 2 * src/lib/link.c CLI Link Helpers 3 * 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 7 * of the License. 8 * 9 * Copyright (c) 2008-2009 Thomas Graf <tgraf (at) suug.ch> 10 */ 11 12 /** 13 * @ingroup cli 14 * @defgroup cli_link Links 15 * 16 * @{ 17 */ 18 19 #include <netlink/cli/utils.h> 20 #include <netlink/cli/link.h> 21 22 struct rtnl_link *nl_cli_link_alloc(void) 23 { 24 struct rtnl_link *link; 25 26 link = rtnl_link_alloc(); 27 if (!link) 28 nl_cli_fatal(ENOMEM, "Unable to allocate link object"); 29 30 return link; 31 } 32 33 void nl_cli_link_parse_family(struct rtnl_link *link, char *arg) 34 { 35 int family; 36 37 if ((family = nl_str2af(arg)) == AF_UNSPEC) 38 nl_cli_fatal(EINVAL, 39 "Unable to translate address family \"%s\"", arg); 40 41 rtnl_link_set_family(link, family); 42 } 43 44 void nl_cli_link_parse_name(struct rtnl_link *link, char *arg) 45 { 46 rtnl_link_set_name(link, arg); 47 } 48 49 void nl_cli_link_parse_mtu(struct rtnl_link *link, char *arg) 50 { 51 uint32_t mtu = nl_cli_parse_u32(arg); 52 rtnl_link_set_mtu(link, mtu); 53 } 54 55 void nl_cli_link_parse_ifindex(struct rtnl_link *link, char *arg) 56 { 57 uint32_t index = nl_cli_parse_u32(arg); 58 rtnl_link_set_ifindex(link, index); 59 } 60 61 void nl_cli_link_parse_txqlen(struct rtnl_link *link, char *arg) 62 { 63 uint32_t qlen = nl_cli_parse_u32(arg); 64 rtnl_link_set_txqlen(link, qlen); 65 } 66 67 void nl_cli_link_parse_weight(struct rtnl_link *link, char *arg) 68 { 69 uint32_t weight = nl_cli_parse_u32(arg); 70 rtnl_link_set_weight(link, weight); 71 } 72 73 /** @} */ 74