diff options
author | Thomas Graf <tgraf@suug.ch> | 2010-11-11 12:57:10 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2010-11-11 12:57:10 (GMT) |
commit | 8970c5cde659d76dc10cda00bb6823b6f34d9c30 (patch) | |
tree | 79b64bc28d25c16bfc1235d8efbebabdb4a24209 /src | |
parent | 59880cb01e0609f64bf004f8226541646b652cec (diff) | |
download | libnl-8970c5cde659d76dc10cda00bb6823b6f34d9c30.zip libnl-8970c5cde659d76dc10cda00bb6823b6f34d9c30.tar.gz libnl-8970c5cde659d76dc10cda00bb6823b6f34d9c30.tar.bz2 |
link: Support IFLA_IFALIAS attribute
- parse IFLA_IFALIAS if available
- provides API to access/change ifalias
rtnl_link_get_ifalias(link)
rtnl_link_set_ifalias(link, alias)
- extends nl-link-set to test functionality
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/link.c | 13 | ||||
-rw-r--r-- | src/nl-link-set.c | 12 |
2 files changed, 20 insertions, 5 deletions
diff --git a/src/lib/link.c b/src/lib/link.c index c192569..88cea55 100644 --- a/src/lib/link.c +++ b/src/lib/link.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2008-2009 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2008-2010 Thomas Graf <tgraf@suug.ch> */ /** @@ -18,6 +18,7 @@ #include <netlink/cli/utils.h> #include <netlink/cli/link.h> +#include <linux/if.h> struct rtnl_link *nl_cli_link_alloc(void) { @@ -70,4 +71,14 @@ void nl_cli_link_parse_weight(struct rtnl_link *link, char *arg) rtnl_link_set_weight(link, weight); } +void nl_cli_link_parse_ifalias(struct rtnl_link *link, char *arg) +{ + if (strlen(arg) > IFALIASZ) + nl_cli_fatal(ERANGE, + "Link ifalias too big, must not exceed %u in length.", + IFALIASZ); + + rtnl_link_set_ifalias(link, arg); +} + /** @} */ diff --git a/src/nl-link-set.c b/src/nl-link-set.c index 94c94e7..3178a98 100644 --- a/src/nl-link-set.c +++ b/src/nl-link-set.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2009 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2010 Thomas Graf <tgraf@suug.ch> */ #include <netlink/cli/utils.h> @@ -41,6 +41,7 @@ static void print_usage(void) " --mtu=NUM MTU value\n" " --txqlen=NUM TX queue length\n" " --weight=NUM weight\n" + " --ifalias=NAME alias name (SNMP IfAlias)\n" ); exit(0); } @@ -84,6 +85,7 @@ int main(int argc, char *argv[]) ARG_MTU = 258, ARG_TXQLEN, ARG_WEIGHT, + ARG_IFALIAS, }; static struct option long_opts[] = { { "quiet", 0, 0, 'q' }, @@ -95,6 +97,7 @@ int main(int argc, char *argv[]) { "mtu", 1, 0, ARG_MTU }, { "txqlen", 1, 0, ARG_TXQLEN }, { "weight", 1, 0, ARG_WEIGHT }, + { "ifalias", 1, 0, ARG_IFALIAS }, { 0, 0, 0, 0 } }; @@ -109,9 +112,10 @@ int main(int argc, char *argv[]) case 'n': ok++; nl_cli_link_parse_name(link, optarg); break; case 'i': ok++; nl_cli_link_parse_ifindex(link, optarg); break; case ARG_RENAME: nl_cli_link_parse_name(change, optarg); break; - case ARG_MTU: nl_cli_link_parse_mtu(link, optarg); break; - case ARG_TXQLEN: nl_cli_link_parse_txqlen(link, optarg); break; - case ARG_WEIGHT: nl_cli_link_parse_weight(link, optarg); break; + case ARG_MTU: nl_cli_link_parse_mtu(change, optarg); break; + case ARG_TXQLEN: nl_cli_link_parse_txqlen(change, optarg); break; + case ARG_WEIGHT: nl_cli_link_parse_weight(change, optarg); break; + case ARG_IFALIAS: nl_cli_link_parse_ifalias(change, optarg); break; } } |