mirror of
				https://git.proxmox.com/git/mirror_iproute2
				synced 2025-11-04 04:42:19 +00:00 
			
		
		
		
	This enables a user to remove an offline peer from the kernel data structures. This could for example be useful when deliberately scaling in peer nodes in a cloud environment. This functionality was first merged in:f9dec657e4(Richard Alpe tipc: add peer remove functionality) And later backed out (as the kernel counterpart was held up) in:385caeb13b(Stephen Hemminger Revert "tipc: add peer remove functionality") Signed-off-by: Richard Alpe <richard.alpe@ericsson.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Reviewed-by: Ying Xue <ying.xue@windriver.com>
		
			
				
	
	
		
			100 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			100 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * tipc.	TIPC utility frontend.
 | 
						|
 *
 | 
						|
 *		This program is free software; you can redistribute it and/or
 | 
						|
 *		modify it under the terms of the GNU General Public License
 | 
						|
 *		as published by the Free Software Foundation; either version
 | 
						|
 *		2 of the License, or (at your option) any later version.
 | 
						|
 *
 | 
						|
 * Authors:	Richard Alpe <richard.alpe@ericsson.com>
 | 
						|
 */
 | 
						|
 | 
						|
#include <stdio.h>
 | 
						|
#include <stdlib.h>
 | 
						|
#include <getopt.h>
 | 
						|
#include <unistd.h>
 | 
						|
 | 
						|
#include "bearer.h"
 | 
						|
#include "link.h"
 | 
						|
#include "nametable.h"
 | 
						|
#include "socket.h"
 | 
						|
#include "media.h"
 | 
						|
#include "node.h"
 | 
						|
#include "peer.h"
 | 
						|
#include "cmdl.h"
 | 
						|
 | 
						|
int help_flag;
 | 
						|
 | 
						|
static void about(struct cmdl *cmdl)
 | 
						|
{
 | 
						|
	fprintf(stderr,
 | 
						|
		"Transparent Inter-Process Communication Protocol\n"
 | 
						|
		"Usage: %s [OPTIONS] COMMAND [ARGS] ...\n"
 | 
						|
		"\n"
 | 
						|
		"Options:\n"
 | 
						|
		" -h, --help \t\tPrint help for last given command\n"
 | 
						|
		"\n"
 | 
						|
		"Commands:\n"
 | 
						|
		" bearer                - Show or modify bearers\n"
 | 
						|
		" link                  - Show or modify links\n"
 | 
						|
		" media                 - Show or modify media\n"
 | 
						|
		" nametable             - Show nametable\n"
 | 
						|
		" node                  - Show or modify node related parameters\n"
 | 
						|
		" peer                  - Peer related operations\n"
 | 
						|
		" socket                - Show sockets\n",
 | 
						|
		cmdl->argv[0]);
 | 
						|
}
 | 
						|
 | 
						|
int main(int argc, char *argv[])
 | 
						|
{
 | 
						|
	int i;
 | 
						|
	int res;
 | 
						|
	struct cmdl cmdl;
 | 
						|
	const struct cmd cmd = {"tipc", NULL, about};
 | 
						|
	struct option long_options[] = {
 | 
						|
		{"help", no_argument, 0, 'h'},
 | 
						|
		{0, 0, 0, 0}
 | 
						|
	};
 | 
						|
	const struct cmd cmds[] = {
 | 
						|
		{ "bearer",	cmd_bearer,	cmd_bearer_help},
 | 
						|
		{ "link",	cmd_link,	cmd_link_help},
 | 
						|
		{ "media",	cmd_media,	cmd_media_help},
 | 
						|
		{ "nametable",	cmd_nametable,	cmd_nametable_help},
 | 
						|
		{ "node",	cmd_node,	cmd_node_help},
 | 
						|
		{ "peer",	cmd_peer,	cmd_peer_help},
 | 
						|
		{ "socket",	cmd_socket,	cmd_socket_help},
 | 
						|
		{ NULL }
 | 
						|
	};
 | 
						|
 | 
						|
	do {
 | 
						|
		int option_index = 0;
 | 
						|
 | 
						|
		i = getopt_long(argc, argv, "h", long_options, &option_index);
 | 
						|
 | 
						|
		switch (i) {
 | 
						|
		case 'h':
 | 
						|
			/*
 | 
						|
			 * We want the help for the last command, so we flag
 | 
						|
			 * here in order to print later.
 | 
						|
			 */
 | 
						|
			help_flag = 1;
 | 
						|
			break;
 | 
						|
		case -1:
 | 
						|
			/* End of options */
 | 
						|
			break;
 | 
						|
		default:
 | 
						|
			/* Invalid option, error msg is printed by getopts */
 | 
						|
			return 1;
 | 
						|
		}
 | 
						|
	} while (i != -1);
 | 
						|
 | 
						|
	cmdl.optind = optind;
 | 
						|
	cmdl.argc = argc;
 | 
						|
	cmdl.argv = argv;
 | 
						|
 | 
						|
	if ((res = run_cmd(NULL, &cmd, cmds, &cmdl, NULL)) != 0)
 | 
						|
		return 1;
 | 
						|
 | 
						|
	return 0;
 | 
						|
}
 |