libnl 2.0
|
00001 /* 00002 * src/lib/link.c CLI Link Helpers 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation version 2.1 00007 * of the License. 00008 * 00009 * Copyright (c) 2008-2009 Thomas Graf <tgraf@suug.ch> 00010 */ 00011 00012 /** 00013 * @ingroup cli 00014 * @defgroup cli_link Links 00015 * 00016 * @{ 00017 */ 00018 00019 #include <netlink/cli/utils.h> 00020 #include <netlink/cli/link.h> 00021 00022 struct rtnl_link *nl_cli_link_alloc(void) 00023 { 00024 struct rtnl_link *link; 00025 00026 link = rtnl_link_alloc(); 00027 if (!link) 00028 nl_cli_fatal(ENOMEM, "Unable to allocate link object"); 00029 00030 return link; 00031 } 00032 00033 void nl_cli_link_parse_family(struct rtnl_link *link, char *arg) 00034 { 00035 int family; 00036 00037 if ((family = nl_str2af(arg)) == AF_UNSPEC) 00038 nl_cli_fatal(EINVAL, 00039 "Unable to translate address family \"%s\"", arg); 00040 00041 rtnl_link_set_family(link, family); 00042 } 00043 00044 void nl_cli_link_parse_name(struct rtnl_link *link, char *arg) 00045 { 00046 rtnl_link_set_name(link, arg); 00047 } 00048 00049 void nl_cli_link_parse_mtu(struct rtnl_link *link, char *arg) 00050 { 00051 uint32_t mtu = nl_cli_parse_u32(arg); 00052 rtnl_link_set_mtu(link, mtu); 00053 } 00054 00055 void nl_cli_link_parse_ifindex(struct rtnl_link *link, char *arg) 00056 { 00057 uint32_t index = nl_cli_parse_u32(arg); 00058 rtnl_link_set_ifindex(link, index); 00059 } 00060 00061 void nl_cli_link_parse_txqlen(struct rtnl_link *link, char *arg) 00062 { 00063 uint32_t qlen = nl_cli_parse_u32(arg); 00064 rtnl_link_set_txqlen(link, qlen); 00065 } 00066 00067 void nl_cli_link_parse_weight(struct rtnl_link *link, char *arg) 00068 { 00069 uint32_t weight = nl_cli_parse_u32(arg); 00070 rtnl_link_set_weight(link, weight); 00071 } 00072 00073 /** @} */