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 = nl_handle_alloc_nondefault(nltool_cbset);
31 neigh = rtnl_neigh_alloc();
35 if (nl_connect(nlh, NETLINK_ROUTE) < 0) {
36 fprintf(stderr, "%s\n", nl_geterror());
40 addr = nl_addr_parse(argv[1], AF_UNSPEC);
42 fprintf(stderr, "Invalid address \"%s\"\n", argv[1]);
45 rtnl_neigh_set_dst(neigh, addr);
48 rtnl_neigh_set_ifindex(neigh, strtoul(argv[2], NULL, 0));
50 if (rtnl_neigh_delete(nlh, neigh, 0) < 0) {
51 fprintf(stderr, "%s\n", nl_geterror());
60 rtnl_neigh_put(neigh);
62 nl_handle_destroy(nlh);