diff options
author | Thomas Graf <tgraf@suug.ch> | 2009-12-16 15:20:46 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2009-12-16 15:20:46 (GMT) |
commit | 8808743839b0f459394ecd00cb0f7c1896c0ab7a (patch) | |
tree | a3ab1da0c8bb02390662891bcb92e2130662b5d7 /src/lib/link.c | |
parent | ff76549013c31082d303b3feef755bbd35e13ec6 (diff) | |
download | libnl-8808743839b0f459394ecd00cb0f7c1896c0ab7a.zip libnl-8808743839b0f459394ecd00cb0f7c1896c0ab7a.tar.gz libnl-8808743839b0f459394ecd00cb0f7c1896c0ab7a.tar.bz2 |
CLI - Command Line Interface Library
Moved common code in src/ used by CLI tools to src/lib/ for possible use
by other CLI tools. Just link to libnl-cli.{so|la}
Diffstat (limited to 'src/lib/link.c')
-rw-r--r-- | src/lib/link.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/lib/link.c b/src/lib/link.c new file mode 100644 index 0000000..c192569 --- /dev/null +++ b/src/lib/link.c @@ -0,0 +1,73 @@ +/* + * src/lib/link.c CLI Link Helpers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * Copyright (c) 2008-2009 Thomas Graf <tgraf@suug.ch> + */ + +/** + * @ingroup cli + * @defgroup cli_link Links + * + * @{ + */ + +#include <netlink/cli/utils.h> +#include <netlink/cli/link.h> + +struct rtnl_link *nl_cli_link_alloc(void) +{ + struct rtnl_link *link; + + link = rtnl_link_alloc(); + if (!link) + nl_cli_fatal(ENOMEM, "Unable to allocate link object"); + + return link; +} + +void nl_cli_link_parse_family(struct rtnl_link *link, char *arg) +{ + int family; + + if ((family = nl_str2af(arg)) == AF_UNSPEC) + nl_cli_fatal(EINVAL, + "Unable to translate address family \"%s\"", arg); + + rtnl_link_set_family(link, family); +} + +void nl_cli_link_parse_name(struct rtnl_link *link, char *arg) +{ + rtnl_link_set_name(link, arg); +} + +void nl_cli_link_parse_mtu(struct rtnl_link *link, char *arg) +{ + uint32_t mtu = nl_cli_parse_u32(arg); + rtnl_link_set_mtu(link, mtu); +} + +void nl_cli_link_parse_ifindex(struct rtnl_link *link, char *arg) +{ + uint32_t index = nl_cli_parse_u32(arg); + rtnl_link_set_ifindex(link, index); +} + +void nl_cli_link_parse_txqlen(struct rtnl_link *link, char *arg) +{ + uint32_t qlen = nl_cli_parse_u32(arg); + rtnl_link_set_txqlen(link, qlen); +} + +void nl_cli_link_parse_weight(struct rtnl_link *link, char *arg) +{ + uint32_t weight = nl_cli_parse_u32(arg); + rtnl_link_set_weight(link, weight); +} + +/** @} */ |