2 * src/nl-neigh-delete.c Delete a neighbour
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 int main(int argc, char *argv[])
16 struct nl_handle *nlh;
17 struct rtnl_neigh *neigh;
21 if (nltool_init(argc, argv) < 0)
24 if (argc < 3 || !strcmp(argv[1], "-h")) {
25 printf("Usage: nl-neigh-delete <addr> <ifindex>\n");
29 nlh = nltool_alloc_handle();
33 neigh = rtnl_neigh_alloc();
37 if (nl_connect(nlh, NETLINK_ROUTE) < 0) {
38 fprintf(stderr, "%s\n", nl_geterror());
42 addr = nl_addr_parse(argv[1], AF_UNSPEC);
44 fprintf(stderr, "Invalid address \"%s\"\n", argv[1]);
47 rtnl_neigh_set_dst(neigh, addr);
50 rtnl_neigh_set_ifindex(neigh, strtoul(argv[2], NULL, 0));
52 if (rtnl_neigh_delete(nlh, neigh, 0) < 0) {
53 fprintf(stderr, "%s\n", nl_geterror());
62 rtnl_neigh_put(neigh);
64 nl_handle_destroy(nlh);