2 * src/f_route.c Routes 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_route *r, int ac, char **av, int idx,
13 struct nl_cache *cache, struct nl_cache *link_cache)
16 if (!strcasecmp(av[idx], "src")) {
18 struct nl_addr *a = nl_addr_parse(av[idx++], AF_UNSPEC);
21 rtnl_route_set_pref_src(r, a);
24 } else if (!strcasecmp(av[idx], "via")) {
26 struct nl_addr *a = nl_addr_parse(av[idx++], AF_UNSPEC);
29 rtnl_route_set_gateway(r, a);
32 } else if (!strcasecmp(av[idx], "from")) {
34 struct nl_addr *a = nl_addr_parse(av[idx++], AF_UNSPEC);
37 rtnl_route_set_src(r, a);
40 } else if (!strcasecmp(av[idx], "tos")) {
42 rtnl_route_set_tos(r, strtoul(av[idx++], NULL, 0));
43 } else if (!strcasecmp(av[idx], "prio")) {
45 rtnl_route_set_prio(r, strtoul(av[idx++], NULL, 0));
46 } else if (!strcasecmp(av[idx], "scope")) {
48 rtnl_route_set_prio(r, rtnl_str2scope(av[idx++]));
49 } else if (!strcasecmp(av[idx], "dev")) {
51 int ifindex = rtnl_link_name2i(link_cache, av[idx++]);
52 if (ifindex == RTNL_LINK_NOT_FOUND)
54 rtnl_route_set_oif(r, ifindex);
56 } else if (!strcasecmp(av[idx], "table")) {
58 rtnl_route_set_table(r, strtoul(av[idx++], NULL, 0));
60 fprintf(stderr, "What is '%s'?\n", av[idx]);
68 fprintf(stderr, "Unable to find device \"%s\"\n", av[idx-1]);
71 fprintf(stderr, "%s\n", nl_geterror());