1 | /*
|
---|
2 | * Unix SMB/CIFS implementation.
|
---|
3 | * RPC Pipe client / server routines
|
---|
4 | * Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
|
---|
5 | * Copyright (C) Gerald (Jerry) Carter 2002-2005.
|
---|
6 | *
|
---|
7 | * This program is free software; you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation; either version 2 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * This program is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with this program; if not, write to the Free Software
|
---|
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include "includes.h"
|
---|
23 |
|
---|
24 | #undef DBGC_CLASS
|
---|
25 | #define DBGC_CLASS DBGC_RPC_PARSE
|
---|
26 |
|
---|
27 | /*******************************************************************
|
---|
28 | Inits a structure.
|
---|
29 | ********************************************************************/
|
---|
30 |
|
---|
31 | void init_shutdown_q_init(SHUTDOWN_Q_INIT *q_s, const char *msg,
|
---|
32 | uint32 timeout, BOOL do_reboot, BOOL force)
|
---|
33 | {
|
---|
34 | q_s->server = TALLOC_P( get_talloc_ctx(), uint16 );
|
---|
35 | if (!q_s->server) {
|
---|
36 | smb_panic("init_shutdown_q_init: talloc fail.\n");
|
---|
37 | return;
|
---|
38 | }
|
---|
39 |
|
---|
40 | *q_s->server = 0x1;
|
---|
41 |
|
---|
42 | q_s->message = TALLOC_ZERO_P( get_talloc_ctx(), UNISTR4 );
|
---|
43 | if (!q_s->message) {
|
---|
44 | smb_panic("init_shutdown_q_init: talloc fail.\n");
|
---|
45 | return;
|
---|
46 | }
|
---|
47 |
|
---|
48 | if ( msg && *msg ) {
|
---|
49 | init_unistr4( q_s->message, msg, UNI_FLAGS_NONE );
|
---|
50 |
|
---|
51 | /* Win2000 is apparently very sensitive to these lengths */
|
---|
52 | /* do a special case here */
|
---|
53 |
|
---|
54 | q_s->message->string->uni_max_len++;
|
---|
55 | q_s->message->size += 2;
|
---|
56 | }
|
---|
57 |
|
---|
58 | q_s->timeout = timeout;
|
---|
59 |
|
---|
60 | q_s->reboot = do_reboot ? 1 : 0;
|
---|
61 | q_s->force = force ? 1 : 0;
|
---|
62 | }
|
---|
63 |
|
---|
64 | /*******************************************************************
|
---|
65 | ********************************************************************/
|
---|
66 |
|
---|
67 | void init_shutdown_q_init_ex(SHUTDOWN_Q_INIT_EX * q_u_ex, const char *msg,
|
---|
68 | uint32 timeout, BOOL do_reboot, BOOL force, uint32 reason)
|
---|
69 | {
|
---|
70 | SHUTDOWN_Q_INIT q_u;
|
---|
71 |
|
---|
72 | ZERO_STRUCT( q_u );
|
---|
73 |
|
---|
74 | init_shutdown_q_init( &q_u, msg, timeout, do_reboot, force );
|
---|
75 |
|
---|
76 | /* steal memory */
|
---|
77 |
|
---|
78 | q_u_ex->server = q_u.server;
|
---|
79 | q_u_ex->message = q_u.message;
|
---|
80 |
|
---|
81 | q_u_ex->reboot = q_u.reboot;
|
---|
82 | q_u_ex->force = q_u.force;
|
---|
83 |
|
---|
84 | q_u_ex->reason = reason;
|
---|
85 | }
|
---|
86 |
|
---|
87 | /*******************************************************************
|
---|
88 | reads or writes a structure.
|
---|
89 | ********************************************************************/
|
---|
90 |
|
---|
91 | BOOL shutdown_io_q_init(const char *desc, SHUTDOWN_Q_INIT *q_s, prs_struct *ps,
|
---|
92 | int depth)
|
---|
93 | {
|
---|
94 | if (q_s == NULL)
|
---|
95 | return False;
|
---|
96 |
|
---|
97 | prs_debug(ps, depth, desc, "shutdown_io_q_init");
|
---|
98 | depth++;
|
---|
99 |
|
---|
100 | if (!prs_align(ps))
|
---|
101 | return False;
|
---|
102 |
|
---|
103 | if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
|
---|
104 | return False;
|
---|
105 | if (!prs_align(ps))
|
---|
106 | return False;
|
---|
107 |
|
---|
108 | if (!prs_pointer("message", ps, depth, (void**)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
|
---|
109 | return False;
|
---|
110 |
|
---|
111 | if (!prs_align(ps))
|
---|
112 | return False;
|
---|
113 |
|
---|
114 | if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
|
---|
115 | return False;
|
---|
116 |
|
---|
117 | if (!prs_uint8("force ", ps, depth, &(q_s->force)))
|
---|
118 | return False;
|
---|
119 | if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
|
---|
120 | return False;
|
---|
121 |
|
---|
122 | return True;
|
---|
123 | }
|
---|
124 |
|
---|
125 | /*******************************************************************
|
---|
126 | reads or writes a structure.
|
---|
127 | ********************************************************************/
|
---|
128 | BOOL shutdown_io_r_init(const char *desc, SHUTDOWN_R_INIT* r_s, prs_struct *ps,
|
---|
129 | int depth)
|
---|
130 | {
|
---|
131 | if (r_s == NULL)
|
---|
132 | return False;
|
---|
133 |
|
---|
134 | prs_debug(ps, depth, desc, "shutdown_io_r_init");
|
---|
135 | depth++;
|
---|
136 |
|
---|
137 | if(!prs_align(ps))
|
---|
138 | return False;
|
---|
139 |
|
---|
140 | if(!prs_werror("status", ps, depth, &r_s->status))
|
---|
141 | return False;
|
---|
142 |
|
---|
143 | return True;
|
---|
144 | }
|
---|
145 |
|
---|
146 | /*******************************************************************
|
---|
147 | reads or writes a REG_Q_SHUTDOWN_EX structure.
|
---|
148 | ********************************************************************/
|
---|
149 |
|
---|
150 | BOOL shutdown_io_q_init_ex(const char *desc, SHUTDOWN_Q_INIT_EX * q_s, prs_struct *ps,
|
---|
151 | int depth)
|
---|
152 | {
|
---|
153 | if (q_s == NULL)
|
---|
154 | return False;
|
---|
155 |
|
---|
156 | prs_debug(ps, depth, desc, "shutdown_io_q_init_ex");
|
---|
157 | depth++;
|
---|
158 |
|
---|
159 | if (!prs_align(ps))
|
---|
160 | return False;
|
---|
161 |
|
---|
162 | if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
|
---|
163 | return False;
|
---|
164 | if (!prs_align(ps))
|
---|
165 | return False;
|
---|
166 |
|
---|
167 | if (!prs_pointer("message", ps, depth, (void**)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4))
|
---|
168 | return False;
|
---|
169 |
|
---|
170 | if (!prs_align(ps))
|
---|
171 | return False;
|
---|
172 |
|
---|
173 | if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
|
---|
174 | return False;
|
---|
175 |
|
---|
176 | if (!prs_uint8("force ", ps, depth, &(q_s->force)))
|
---|
177 | return False;
|
---|
178 | if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot)))
|
---|
179 | return False;
|
---|
180 |
|
---|
181 | if (!prs_align(ps))
|
---|
182 | return False;
|
---|
183 | if (!prs_uint32("reason", ps, depth, &(q_s->reason)))
|
---|
184 | return False;
|
---|
185 |
|
---|
186 |
|
---|
187 | return True;
|
---|
188 | }
|
---|
189 |
|
---|
190 | /*******************************************************************
|
---|
191 | reads or writes a REG_R_SHUTDOWN_EX structure.
|
---|
192 | ********************************************************************/
|
---|
193 | BOOL shutdown_io_r_init_ex(const char *desc, SHUTDOWN_R_INIT_EX * r_s, prs_struct *ps,
|
---|
194 | int depth)
|
---|
195 | {
|
---|
196 | if (r_s == NULL)
|
---|
197 | return False;
|
---|
198 |
|
---|
199 | prs_debug(ps, depth, desc, "shutdown_io_r_init_ex");
|
---|
200 | depth++;
|
---|
201 |
|
---|
202 | if(!prs_align(ps))
|
---|
203 | return False;
|
---|
204 |
|
---|
205 | if(!prs_werror("status", ps, depth, &r_s->status))
|
---|
206 | return False;
|
---|
207 |
|
---|
208 | return True;
|
---|
209 | }
|
---|
210 |
|
---|
211 |
|
---|
212 | /*******************************************************************
|
---|
213 | Inits a structure.
|
---|
214 | ********************************************************************/
|
---|
215 | void init_shutdown_q_abort(SHUTDOWN_Q_ABORT *q_s)
|
---|
216 | {
|
---|
217 | q_s->server = TALLOC_P( get_talloc_ctx(), uint16 );
|
---|
218 | if (!q_s->server) {
|
---|
219 | smb_panic("init_shutdown_q_abort: talloc fail.\n");
|
---|
220 | return;
|
---|
221 | }
|
---|
222 |
|
---|
223 | *q_s->server = 0x1;
|
---|
224 | }
|
---|
225 |
|
---|
226 | /*******************************************************************
|
---|
227 | reads or writes a structure.
|
---|
228 | ********************************************************************/
|
---|
229 | BOOL shutdown_io_q_abort(const char *desc, SHUTDOWN_Q_ABORT *q_s,
|
---|
230 | prs_struct *ps, int depth)
|
---|
231 | {
|
---|
232 | if (q_s == NULL)
|
---|
233 | return False;
|
---|
234 |
|
---|
235 | prs_debug(ps, depth, desc, "shutdown_io_q_abort");
|
---|
236 | depth++;
|
---|
237 |
|
---|
238 | if (!prs_align(ps))
|
---|
239 | return False;
|
---|
240 |
|
---|
241 | if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16))
|
---|
242 | return False;
|
---|
243 | if (!prs_align(ps))
|
---|
244 | return False;
|
---|
245 |
|
---|
246 | return True;
|
---|
247 | }
|
---|
248 |
|
---|
249 | /*******************************************************************
|
---|
250 | reads or writes a structure.
|
---|
251 | ********************************************************************/
|
---|
252 | BOOL shutdown_io_r_abort(const char *desc, SHUTDOWN_R_ABORT *r_s,
|
---|
253 | prs_struct *ps, int depth)
|
---|
254 | {
|
---|
255 | if (r_s == NULL)
|
---|
256 | return False;
|
---|
257 |
|
---|
258 | prs_debug(ps, depth, desc, "shutdown_io_r_abort");
|
---|
259 | depth++;
|
---|
260 |
|
---|
261 | if (!prs_align(ps))
|
---|
262 | return False;
|
---|
263 |
|
---|
264 | if (!prs_werror("status", ps, depth, &r_s->status))
|
---|
265 | return False;
|
---|
266 |
|
---|
267 | return True;
|
---|
268 | }
|
---|