shutdown.c revision 53913
122514Sdarrenr
222514Sdarrenr/*
322514Sdarrenr * shutdown.c
422514Sdarrenr *
522514Sdarrenr * Copyright (c) 1996-1999 Whistle Communications, Inc.
622514Sdarrenr * All rights reserved.
722514Sdarrenr *
822514Sdarrenr * Subject to the following obligations and disclaimer of warranty, use and
922514Sdarrenr * redistribution of this software, in source or object code forms, with or
1022514Sdarrenr * without modifications are expressly permitted by Whistle Communications;
1122514Sdarrenr * provided, however, that:
1222514Sdarrenr * 1. Any and all reproductions of the source or object code must include the
1322514Sdarrenr *    copyright notice above and the following disclaimer of warranties; and
1422514Sdarrenr * 2. No rights are granted, in any manner or form, to use Whistle
1522514Sdarrenr *    Communications, Inc. trademarks, including the mark "WHISTLE
1622514Sdarrenr *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
1722514Sdarrenr *    such appears in the above copyright notice or in the software.
1822514Sdarrenr *
1922514Sdarrenr * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
2022514Sdarrenr * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
2122514Sdarrenr * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
2222514Sdarrenr * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
2322514Sdarrenr * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
2422514Sdarrenr * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
2522514Sdarrenr * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
2622514Sdarrenr * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
2722514Sdarrenr * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
2822514Sdarrenr * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
2922514Sdarrenr * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
3022514Sdarrenr * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
3122514Sdarrenr * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
3222514Sdarrenr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3322514Sdarrenr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3422514Sdarrenr * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
3522514Sdarrenr * OF SUCH DAMAGE.
3622514Sdarrenr *
3722514Sdarrenr * $FreeBSD: head/usr.sbin/ngctl/shutdown.c 53913 1999-11-30 02:45:32Z archie $
3822514Sdarrenr */
3922514Sdarrenr
4022514Sdarrenr#include "ngctl.h"
4122514Sdarrenr
4222514Sdarrenrstatic int ShutdownCmd(int ac, char **av);
4322514Sdarrenr
4422514Sdarrenrconst struct ngcmd shutdown_cmd = {
4522514Sdarrenr	ShutdownCmd,
4622514Sdarrenr	"shutdown <path>",
4722514Sdarrenr	"Shutdown the node at <path>",
4822514Sdarrenr	NULL,
4922514Sdarrenr	{ "kill", "rmnode" }
5022514Sdarrenr};
5122514Sdarrenr
5222514Sdarrenrstatic int
5322514SdarrenrShutdownCmd(int ac, char **av)
5422514Sdarrenr{
5522514Sdarrenr	char *path;
5622514Sdarrenr
5722514Sdarrenr	/* Get arguments */
5822514Sdarrenr	switch (ac) {
5922514Sdarrenr	case 2:
6022514Sdarrenr		path = av[1];
6122514Sdarrenr		break;
62	default:
63		return(CMDRTN_USAGE);
64	}
65
66	/* Shutdown node */
67	if (NgSendMsg(csock, path, NGM_GENERIC_COOKIE,
68	    NGM_SHUTDOWN, NULL, 0) < 0) {
69		warn("shutdown");
70		return(CMDRTN_ERROR);
71	}
72	return(CMDRTN_OK);
73}
74
75
76