2 * src/nl-addr-delete.c Delete addresses
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_addr *addr;
18 struct nl_addr *local;
21 if (argc < 3 || !strcmp(argv[1], "-h")) {
22 printf("Usage: nl-addr-delete <addr> <ifindex>\n");
26 if (nltool_init(argc, argv) < 0)
29 nlh = nl_handle_alloc_nondefault(nltool_cbset);
33 addr = rtnl_addr_alloc();
35 goto errout_free_handle;
37 if (nltool_connect(nlh, NETLINK_ROUTE) < 0)
38 goto errout_free_addr;
40 local = nltool_addr_parse(argv[1]);
44 if (rtnl_addr_set_local(addr, local) < 0) {
45 fprintf(stderr, "Unable to set local address: %s\n",
50 rtnl_addr_set_ifindex(addr, strtoul(argv[2], NULL, 0));
52 if (rtnl_addr_delete(nlh, addr, 0) < 0) {
53 fprintf(stderr, "Unable to delete address: %s\n",
67 nl_handle_destroy(nlh);