2 * src/nl-route-del.c Delete Routes
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-route-del [<filter>]\n");
23 int main(int argc, char *argv[])
25 struct nl_handle *nlh;
26 struct nl_cache *link_cache, *route_cache;
27 struct rtnl_route *route;
30 if (nltool_init(argc, argv) < 0)
33 if (argc < 2 || !strcmp(argv[1], "-h"))
36 nlh = nltool_alloc_handle();
40 route = rtnl_route_alloc();
44 if (nltool_connect(nlh, NETLINK_ROUTE) < 0)
47 link_cache = nltool_alloc_link_cache(nlh);
51 route_cache = nltool_alloc_route_cache(nlh);
53 goto errout_link_cache;
55 get_filter(route, argc, argv, 1, route_cache, link_cache);
57 if (rtnl_route_del(nlh, route, 0) < 0) {
58 fprintf(stderr, "rtnl_route_del failed: %s\n",
60 goto errout_route_cache;
66 nl_cache_free(route_cache);
68 nl_cache_free(link_cache);
72 rtnl_route_put(route);
74 nl_handle_destroy(nlh);