source: branches/samba-3.0/source/rpc_client/cli_shutdown.c

Last change on this file was 1, checked in by Paul Smedley, 18 years ago

Initial code import

File size: 2.9 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 RPC Pipe client
4
5 Copyright (C) Andrew Tridgell 1992-1998,
6 Largely rewritten by Jeremy Allison (C) 2005.
7 Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*/
23
24#include "includes.h"
25
26/* Shutdown a server */
27
28NTSTATUS rpccli_shutdown_init(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
29 const char *msg, uint32 timeout, BOOL do_reboot,
30 BOOL force)
31{
32 prs_struct qbuf;
33 prs_struct rbuf;
34 SHUTDOWN_Q_INIT q;
35 SHUTDOWN_R_INIT r;
36 WERROR result = WERR_GENERAL_FAILURE;
37
38 if (msg == NULL)
39 return NT_STATUS_INVALID_PARAMETER;
40
41 ZERO_STRUCT (q);
42 ZERO_STRUCT (r);
43
44 /* Marshall data and send request */
45
46 init_shutdown_q_init(&q, msg, timeout, do_reboot, force);
47
48 CLI_DO_RPC(cli, mem_ctx, PI_SHUTDOWN, SHUTDOWN_INIT,
49 q, r,
50 qbuf, rbuf,
51 shutdown_io_q_init,
52 shutdown_io_r_init,
53 NT_STATUS_UNSUCCESSFUL);
54
55 result = r.status;
56 return werror_to_ntstatus(result);
57}
58
59/* Shutdown a server */
60
61NTSTATUS rpccli_shutdown_init_ex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
62 const char *msg, uint32 timeout, BOOL do_reboot,
63 BOOL force, uint32 reason)
64{
65 prs_struct qbuf;
66 prs_struct rbuf;
67 SHUTDOWN_Q_INIT_EX q;
68 SHUTDOWN_R_INIT_EX r;
69 WERROR result = WERR_GENERAL_FAILURE;
70
71 if (msg == NULL)
72 return NT_STATUS_INVALID_PARAMETER;
73
74 ZERO_STRUCT (q);
75 ZERO_STRUCT (r);
76
77 /* Marshall data and send request */
78
79 init_shutdown_q_init_ex(&q, msg, timeout, do_reboot, force, reason);
80
81 CLI_DO_RPC(cli, mem_ctx, PI_SHUTDOWN, SHUTDOWN_INIT_EX,
82 q, r,
83 qbuf, rbuf,
84 shutdown_io_q_init_ex,
85 shutdown_io_r_init_ex,
86 NT_STATUS_UNSUCCESSFUL);
87
88 result = r.status;
89 return werror_to_ntstatus(result);
90}
91
92
93/* Abort a server shutdown */
94
95NTSTATUS rpccli_shutdown_abort(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx)
96{
97 prs_struct rbuf;
98 prs_struct qbuf;
99 SHUTDOWN_Q_ABORT q;
100 SHUTDOWN_R_ABORT r;
101 WERROR result = WERR_GENERAL_FAILURE;
102
103 ZERO_STRUCT (q);
104 ZERO_STRUCT (r);
105
106 /* Marshall data and send request */
107
108 init_shutdown_q_abort(&q);
109
110 CLI_DO_RPC(cli, mem_ctx, PI_SHUTDOWN, SHUTDOWN_ABORT,
111 q, r,
112 qbuf, rbuf,
113 shutdown_io_q_abort,
114 shutdown_io_r_abort,
115 NT_STATUS_UNSUCCESSFUL);
116
117 result = r.status;
118 return werror_to_ntstatus(result);
119}
Note: See TracBrowser for help on using the repository browser.