shutdown.c revision 160002
118334Speter
252284Sobrien/*
318334Speter * shutdown.c
418334Speter *
518334Speter * Copyright (c) 1996-1999 Whistle Communications, Inc.
618334Speter * All rights reserved.
718334Speter *
818334Speter * Subject to the following obligations and disclaimer of warranty, use and
918334Speter * redistribution of this software, in source or object code forms, with or
1018334Speter * without modifications are expressly permitted by Whistle Communications;
1118334Speter * provided, however, that:
1218334Speter * 1. Any and all reproductions of the source or object code must include the
1318334Speter *    copyright notice above and the following disclaimer of warranties; and
1418334Speter * 2. No rights are granted, in any manner or form, to use Whistle
1518334Speter *    Communications, Inc. trademarks, including the mark "WHISTLE
1618334Speter *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
1718334Speter *    such appears in the above copyright notice or in the software.
1818334Speter *
1918334Speter * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
2018334Speter * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
2118334Speter * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
2218334Speter * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
2350397Sobrien * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
2450397Sobrien * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
2550397Sobrien * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
2650397Sobrien * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
2718334Speter * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
2818334Speter * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
2918334Speter * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
3018334Speter * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
3118334Speter * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
3218334Speter * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3318334Speter * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3418334Speter * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
3552284Sobrien * OF SUCH DAMAGE.
3618334Speter *
3718334Speter * $FreeBSD: head/usr.sbin/ngctl/shutdown.c 160002 2006-06-28 10:38:38Z glebius $
3818334Speter */
3918334Speter
4050397Sobrien#include <err.h>
4118334Speter#include <netgraph.h>
4252284Sobrien#include <unistd.h>
4352284Sobrien
4452284Sobrien#include "ngctl.h"
4552284Sobrien
4618334Speterstatic int ShutdownCmd(int ac, char **av);
4718334Speter
4818334Speterconst struct ngcmd shutdown_cmd = {
4918334Speter	ShutdownCmd,
5018334Speter	"shutdown <path>",
5118334Speter	"Shutdown the node at <path>",
5218334Speter	NULL,
5318334Speter	{ "kill", "rmnode" }
5418334Speter};
5518334Speter
5618334Speterstatic int
5718334SpeterShutdownCmd(int ac, char **av)
5818334Speter{
5918334Speter	char *path;
6018334Speter
6152284Sobrien	/* Get arguments */
6252284Sobrien	switch (ac) {
6352284Sobrien	case 2:
6452284Sobrien		path = av[1];
6518334Speter		break;
6618334Speter	default:
6718334Speter		return (CMDRTN_USAGE);
6818334Speter	}
6918334Speter
7018334Speter	/* Shutdown node */
7118334Speter	if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
7218334Speter	    NGM_SHUTDOWN, NULL, 0) < 0) {
7318334Speter		warn("shutdown");
7418334Speter		return (CMDRTN_ERROR);
7518334Speter	}
7618334Speter	return (CMDRTN_OK);
7718334Speter}
7818334Speter
7918334Speter
8018334Speter