2 Unix SMB/CIFS implementation.
5 Copyright (C) Andrew Tridgell 1992-1998,
6 Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
7 Copyright (C) Paul Ashton 1997-1998.
8 Copyright (C) Jeremy Allison 1999,
9 Copyright (C) Simo Sorce 2001,
10 Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 /* Shutdown a server */
31 NTSTATUS cli_shutdown_init(struct cli_state * cli, TALLOC_CTX *mem_ctx,
32 const char *msg, uint32 timeout, BOOL do_reboot,
39 WERROR result = WERR_GENERAL_FAILURE;
42 return NT_STATUS_INVALID_PARAMETER;
47 prs_init(&qbuf , MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
48 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
50 /* Marshall data and send request */
52 init_shutdown_q_init(&q_s, msg, timeout, do_reboot, force);
54 if (!shutdown_io_q_init("", &q_s, &qbuf, 0) ||
55 !rpc_api_pipe_req(cli, PI_SHUTDOWN, SHUTDOWN_INIT, &qbuf, &rbuf))
58 /* Unmarshall response */
60 if(shutdown_io_r_init("", &r_s, &rbuf, 0))
67 return werror_to_ntstatus(result);
70 /* Shutdown a server */
72 NTSTATUS cli_shutdown_init_ex(struct cli_state * cli, TALLOC_CTX *mem_ctx,
73 const char *msg, uint32 timeout, BOOL do_reboot,
74 BOOL force, uint32 reason)
78 SHUTDOWN_Q_INIT_EX q_s;
79 SHUTDOWN_R_INIT_EX r_s;
80 WERROR result = WERR_GENERAL_FAILURE;
83 return NT_STATUS_INVALID_PARAMETER;
88 prs_init(&qbuf , MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
89 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
91 /* Marshall data and send request */
93 init_shutdown_q_init_ex(&q_s, msg, timeout, do_reboot, force, reason);
95 if (!shutdown_io_q_init_ex("", &q_s, &qbuf, 0) ||
96 !rpc_api_pipe_req(cli, PI_SHUTDOWN, SHUTDOWN_INIT_EX, &qbuf, &rbuf))
99 /* Unmarshall response */
101 if(shutdown_io_r_init_ex("", &r_s, &rbuf, 0))
108 return werror_to_ntstatus(result);
112 /* Abort a server shutdown */
114 NTSTATUS cli_shutdown_abort(struct cli_state * cli, TALLOC_CTX *mem_ctx)
118 SHUTDOWN_Q_ABORT q_s;
119 SHUTDOWN_R_ABORT r_s;
120 WERROR result = WERR_GENERAL_FAILURE;
125 prs_init(&qbuf , MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
126 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
128 /* Marshall data and send request */
130 init_shutdown_q_abort(&q_s);
132 if (!shutdown_io_q_abort("", &q_s, &qbuf, 0) ||
133 !rpc_api_pipe_req(cli, PI_SHUTDOWN, SHUTDOWN_ABORT, &qbuf, &rbuf))
136 /* Unmarshall response */
138 if (shutdown_io_r_abort("", &r_s, &rbuf, 0))
143 prs_mem_free(&qbuf );
145 return werror_to_ntstatus(result);