2 * src/nl-link-set.c Set link attributes
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) 2003-2006 Thomas Graf <tgraf@suug.ch>
14 static void print_usage(void)
17 "Usage: nl-link-set <ifindex> <changes>\n"
18 " changes := [dev DEV] [mtu MTU] [txqlen TXQLEN] [weight WEIGHT] [link LINK]\n"
19 " [master MASTER] [qdisc QDISC] [addr ADDR] [broadcast BRD]\n"
20 " [{ up | down }] [{ arp | noarp }] [{ promisc | nopromisc }]\n"
21 " [{ dynamic | nodynamic }] [{ multicast | nomulticast }]\n"
22 " [{ trailers | notrailers }] [{ allmulticast | noallmulticast }]\n");
28 int main(int argc, char *argv[])
30 struct nl_handle *nlh;
31 struct nl_cache *link_cache;
32 struct rtnl_link *link, *orig;
35 if (nltool_init(argc, argv) < 0)
38 if (argc < 2 || !strcmp(argv[1], "-h"))
41 nlh = nltool_alloc_handle();
45 link = rtnl_link_alloc();
49 if (nltool_connect(nlh, NETLINK_ROUTE) < 0)
52 link_cache = nltool_alloc_link_cache(nlh);
56 ifindex = strtoul(argv[1], NULL, 0);
58 if (!(orig = rtnl_link_get(link_cache, ifindex))) {
59 fprintf(stderr, "Interface index %d does not exist\n", ifindex);
63 get_filter(link, argc, argv, 2, link_cache);
65 if (rtnl_link_change(nlh, orig, link, 0) < 0) {
66 fprintf(stderr, "Unable to change link: %s\n", nl_geterror());
75 nl_cache_free(link_cache);
81 nl_handle_destroy(nlh);