]>
git.proxmox.com Git - mirror_iproute2.git/blob - tipc/peer.c
2 * peer.c TIPC peer functionality.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Richard Alpe <richard.alpe@ericsson.com>
17 #include <linux/tipc_netlink.h>
18 #include <linux/tipc.h>
19 #include <linux/genetlink.h>
20 #include <libmnl/libmnl.h>
27 static int cmd_peer_rm_addr(struct nlmsghdr
*nlh
, const struct cmd
*cmd
,
28 struct cmdl
*cmdl
, void *data
)
33 char buf
[MNL_SOCKET_BUFFER_SIZE
];
35 if ((cmdl
->argc
!= cmdl
->optind
+ 1) || help_flag
) {
36 fprintf(stderr
, "Usage: %s peer remove address ADDRESS\n",
41 str
= shift_cmdl(cmdl
);
43 /* First try legacy Z.C.N format, then integer format */
50 if (!(nlh
= msg_init(buf
, TIPC_NL_PEER_REMOVE
))) {
51 fprintf(stderr
, "error, message initialisation failed\n");
55 nest
= mnl_attr_nest_start(nlh
, TIPC_NLA_NET
);
56 mnl_attr_put_u32(nlh
, TIPC_NLA_NET_ADDR
, addr
);
57 mnl_attr_nest_end(nlh
, nest
);
59 return msg_doit(nlh
, NULL
, NULL
);
62 static void cmd_peer_rm_help(struct cmdl
*cmdl
)
64 fprintf(stderr
, "Usage: %s peer remove address ADDRESS\n",
68 static int cmd_peer_rm(struct nlmsghdr
*nlh
, const struct cmd
*cmd
,
69 struct cmdl
*cmdl
, void *data
)
71 const struct cmd cmds
[] = {
72 { "address", cmd_peer_rm_addr
, cmd_peer_rm_help
},
76 return run_cmd(nlh
, cmd
, cmds
, cmdl
, NULL
);
79 void cmd_peer_help(struct cmdl
*cmdl
)
82 "Usage: %s peer COMMAND [ARGS] ...\n\n"
84 " remove - Remove an offline peer node\n",
88 int cmd_peer(struct nlmsghdr
*nlh
, const struct cmd
*cmd
, struct cmdl
*cmdl
,
91 const struct cmd cmds
[] = {
92 { "remove", cmd_peer_rm
, cmd_peer_rm_help
},
96 return run_cmd(nlh
, cmd
, cmds
, cmdl
, NULL
);