2 * src/f_addr.c Address 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>
12 static void get_filter(struct rtnl_addr *addr, int argc, char **argv, int idx,
13 struct nl_cache *link_cache)
18 if (arg_match("dev")) {
20 int ifindex = rtnl_link_name2i(link_cache, argv[idx++]);
21 if (ifindex == RTNL_LINK_NOT_FOUND)
23 rtnl_addr_set_ifindex(addr, ifindex);
25 } else if (arg_match("family")) {
27 int family = nl_str2af(argv[idx++]);
28 if (family == AF_UNSPEC)
30 rtnl_addr_set_family(addr, family);
32 } else if (arg_match("label")) {
34 rtnl_addr_set_label(addr, argv[idx++]);
35 } else if (arg_match("scope")) {
37 int scope = rtnl_str2scope(argv[idx++]);
40 rtnl_addr_set_scope(addr, scope);
42 } else if (arg_match("local")) {
44 a = nl_addr_parse(argv[idx++],
45 rtnl_addr_get_family(addr));
48 rtnl_addr_set_local(addr, a);
51 } else if (arg_match("peer")) {
53 a = nl_addr_parse(argv[idx++],
54 rtnl_addr_get_family(addr));
57 rtnl_addr_set_peer(addr, a);
60 } else if (arg_match("broadcast")) {
62 a = nl_addr_parse(argv[idx++],
63 rtnl_addr_get_family(addr));
66 rtnl_addr_set_broadcast(addr, a);
69 } else if (arg_match("multicast")) {
71 a = nl_addr_parse(argv[idx++],
72 rtnl_addr_get_family(addr));
75 rtnl_addr_set_multicast(addr, a);
78 } else if (arg_match("anycast")) {
80 a = nl_addr_parse(argv[idx++],
81 rtnl_addr_get_family(addr));
84 rtnl_addr_set_anycast(addr, a);
88 fprintf(stderr, "What is '%s'?\n", argv[idx]);
96 fprintf(stderr, "Unknown link %s\n", argv[idx-1]);
99 fprintf(stderr, "Invalid scope name \"%s\".\n", argv[idx-1]);
102 fprintf(stderr, "Invalid address family \"%s\"\n", argv[idx-1]);
105 fprintf(stderr, "Invalid address \"%s\": %s\n", argv[idx-1], nl_geterror());