2 * src/f_link.c Link Filter
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 get_filter(struct rtnl_link *l, int ac, char **av, int idx,
15 struct nl_cache *cache)
18 if (!strcasecmp(av[idx], "dev")) {
20 int ifindex = rtnl_link_name2i(cache, av[idx++]);
21 if (ifindex == RTNL_LINK_NOT_FOUND)
23 rtnl_link_set_ifindex(l, ifindex);
25 } else if (!strcasecmp(av[idx], "mtu")) {
27 rtnl_link_set_mtu(l, strtoul(av[idx++], NULL, 0));
28 } else if (!strcasecmp(av[idx], "txqlen")) {
30 rtnl_link_set_txqlen(l, strtoul(av[idx++], NULL, 0));
31 } else if (!strcasecmp(av[idx], "weight")) {
33 rtnl_link_set_weight(l, strtoul(av[idx++], NULL, 0));
34 } else if (!strcasecmp(av[idx], "link")) {
36 int ifindex = rtnl_link_name2i(cache, av[idx++]);
37 if (ifindex == RTNL_LINK_NOT_FOUND)
39 rtnl_link_set_link(l, ifindex);
41 } else if (!strcasecmp(av[idx], "master")) {
43 int ifindex = rtnl_link_name2i(cache, av[idx++]);
44 if (ifindex == RTNL_LINK_NOT_FOUND)
46 rtnl_link_set_master(l, ifindex);
48 } else if (!strcasecmp(av[idx], "qdisc")) {
50 rtnl_link_set_qdisc(l, av[idx++]);
51 } else if (!strcasecmp(av[idx], "name")) {
53 rtnl_link_set_name(l, av[idx++]);
54 } else if (!strcasecmp(av[idx], "addr")) {
56 struct nl_addr *a = nl_addr_parse(av[idx++], AF_UNSPEC);
59 rtnl_link_set_addr(l, a);
62 } else if (!strcasecmp(av[idx], "broadcast")) {
64 struct nl_addr *a = nl_addr_parse(av[idx++], AF_UNSPEC);
67 rtnl_link_set_broadcast(l, a);
71 #define MFLAG(STR, FLAG) \
72 else if (!strcasecmp(av[idx], STR)) { \
73 rtnl_link_set_flags(l, FLAG); idx++; }
74 #define MNOFLAG(STR, FLAG) \
75 else if (!strcasecmp(av[idx], STR)) { \
76 rtnl_link_unset_flags(l, FLAG); idx++; }
79 MNOFLAG("down", IFF_UP)
80 MFLAG("noarp", IFF_NOARP)
81 MNOFLAG("arp", IFF_NOARP)
82 MFLAG("promisc", IFF_PROMISC)
83 MNOFLAG("nopromisc", IFF_PROMISC)
84 MFLAG("dynamic", IFF_DYNAMIC)
85 MNOFLAG("nodynamic", IFF_DYNAMIC)
86 MFLAG("multicast", IFF_MULTICAST)
87 MNOFLAG("nomulticast", IFF_MULTICAST)
88 MFLAG("allmulticast", IFF_ALLMULTI)
89 MNOFLAG("noallmulticast", IFF_ALLMULTI)
93 fprintf(stderr, "What is '%s'?\n", av[idx]);
101 fprintf(stderr, "Unknown link %s\n", av[idx-1]);
104 fprintf(stderr, "%s\n", nl_geterror());