2 Unix SMB/CIFS implementation.
3 test suite for various RAP operations
4 Copyright (C) Volker Lendecke 2004
5 Copyright (C) Tim Potter 2005
6 Copyright (C) Jelmer Vernooij 2007
7 Copyright (C) Guenther Deschner 2010
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 3 of the License, or
12 (at your option) any later version.
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.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "libcli/libcli.h"
25 #include "torture/smbtorture.h"
26 #include "torture/util.h"
27 #include "../librpc/gen_ndr/ndr_rap.h"
28 #include "librpc/ndr/libndr.h"
29 #include "param/param.h"
30 #include "torture/rap/proto.h"
32 #define RAP_GOTO(call) do { \
35 if (!NT_STATUS_IS_OK(_status)) { \
41 #define RAP_RETURN(call) do { \
44 if (!NT_STATUS_IS_OK(_status)) { \
50 #define NDR_GOTO(call) do { \
51 enum ndr_err_code _ndr_err; \
53 if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \
54 result = ndr_map_error2ntstatus(_ndr_err); \
59 #define NDR_RETURN(call) do { \
60 enum ndr_err_code _ndr_err; \
62 if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \
63 return ndr_map_error2ntstatus(_ndr_err); \
71 const char *auxdatadesc
;
76 uint16_t rcv_paramlen
, rcv_datalen
;
78 struct ndr_push
*ndr_push_param
;
79 struct ndr_push
*ndr_push_data
;
80 struct ndr_pull
*ndr_pull_param
;
81 struct ndr_pull
*ndr_pull_data
;
84 #define RAPNDR_FLAGS (LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
86 static struct rap_call
*new_rap_cli_call(TALLOC_CTX
*mem_ctx
, uint16_t callno
)
88 struct rap_call
*call
;
90 call
= talloc(mem_ctx
, struct rap_call
);
95 call
->callno
= callno
;
96 call
->rcv_paramlen
= 4;
98 call
->paramdesc
= NULL
;
99 call
->datadesc
= NULL
;
100 call
->auxdatadesc
= NULL
;
102 call
->ndr_push_param
= ndr_push_init_ctx(mem_ctx
);
103 call
->ndr_push_param
->flags
= RAPNDR_FLAGS
;
105 call
->ndr_push_data
= ndr_push_init_ctx(mem_ctx
);
106 call
->ndr_push_data
->flags
= RAPNDR_FLAGS
;
111 static void rap_cli_push_paramdesc(struct rap_call
*call
, char desc
)
115 if (call
->paramdesc
!= NULL
)
116 len
= strlen(call
->paramdesc
);
118 call
->paramdesc
= talloc_realloc(call
,
123 call
->paramdesc
[len
] = desc
;
124 call
->paramdesc
[len
+1] = '\0';
127 static void rap_cli_push_word(struct rap_call
*call
, uint16_t val
)
129 rap_cli_push_paramdesc(call
, 'W');
130 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, val
);
133 static void rap_cli_push_dword(struct rap_call
*call
, uint32_t val
)
135 rap_cli_push_paramdesc(call
, 'D');
136 ndr_push_uint32(call
->ndr_push_param
, NDR_SCALARS
, val
);
139 static void rap_cli_push_rcvbuf(struct rap_call
*call
, int len
)
141 rap_cli_push_paramdesc(call
, 'r');
142 rap_cli_push_paramdesc(call
, 'L');
143 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, len
);
144 call
->rcv_datalen
= len
;
147 static void rap_cli_push_sendbuf(struct rap_call
*call
, int len
)
149 rap_cli_push_paramdesc(call
, 's');
150 rap_cli_push_paramdesc(call
, 'T');
151 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, len
);
154 static void rap_cli_push_param(struct rap_call
*call
, uint16_t val
)
156 rap_cli_push_paramdesc(call
, 'P');
157 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, val
);
160 static void rap_cli_expect_multiple_entries(struct rap_call
*call
)
162 rap_cli_push_paramdesc(call
, 'e');
163 rap_cli_push_paramdesc(call
, 'h');
164 call
->rcv_paramlen
+= 4; /* uint16_t entry count, uint16_t total */
167 static void rap_cli_expect_word(struct rap_call
*call
)
169 rap_cli_push_paramdesc(call
, 'h');
170 call
->rcv_paramlen
+= 2;
173 static void rap_cli_push_string(struct rap_call
*call
, const char *str
)
176 rap_cli_push_paramdesc(call
, 'O');
179 rap_cli_push_paramdesc(call
, 'z');
180 ndr_push_string(call
->ndr_push_param
, NDR_SCALARS
, str
);
183 static void rap_cli_expect_format(struct rap_call
*call
, const char *format
)
185 call
->datadesc
= format
;
188 static void rap_cli_expect_extra_format(struct rap_call
*call
, const char *format
)
190 call
->auxdatadesc
= format
;
193 static NTSTATUS
rap_pull_string(TALLOC_CTX
*mem_ctx
, struct ndr_pull
*ndr
,
194 uint16_t convert
, const char **dest
)
196 uint16_t string_offset
;
201 NDR_RETURN(ndr_pull_uint16(ndr
, NDR_SCALARS
, &string_offset
));
202 NDR_RETURN(ndr_pull_uint16(ndr
, NDR_SCALARS
, &ignore
));
204 string_offset
-= convert
;
206 if (string_offset
+1 > ndr
->data_size
)
207 return NT_STATUS_INVALID_PARAMETER
;
209 p
= (const char *)(ndr
->data
+ string_offset
);
210 len
= strnlen(p
, ndr
->data_size
-string_offset
);
212 if ( string_offset
+ len
+ 1 > ndr
->data_size
)
213 return NT_STATUS_INVALID_PARAMETER
;
215 *dest
= talloc_zero_array(mem_ctx
, char, len
+1);
216 pull_string(discard_const_p(char, *dest
), p
, len
+1, len
, STR_ASCII
);
221 static NTSTATUS
rap_cli_do_call(struct smbcli_tree
*tree
,
222 struct rap_call
*call
)
225 DATA_BLOB param_blob
;
227 struct ndr_push
*params
;
228 struct ndr_push
*data
;
229 struct smb_trans2 trans
;
231 params
= ndr_push_init_ctx(call
);
234 return NT_STATUS_NO_MEMORY
;
236 params
->flags
= RAPNDR_FLAGS
;
238 data
= ndr_push_init_ctx(call
);
241 return NT_STATUS_NO_MEMORY
;
243 data
->flags
= RAPNDR_FLAGS
;
245 trans
.in
.max_param
= call
->rcv_paramlen
;
246 trans
.in
.max_data
= call
->rcv_datalen
;
247 trans
.in
.max_setup
= 0;
249 trans
.in
.timeout
= 0;
250 trans
.in
.setup_count
= 0;
251 trans
.in
.setup
= NULL
;
252 trans
.in
.trans_name
= "\\PIPE\\LANMAN";
254 NDR_RETURN(ndr_push_uint16(params
, NDR_SCALARS
, call
->callno
));
256 NDR_RETURN(ndr_push_string(params
, NDR_SCALARS
, call
->paramdesc
));
258 NDR_RETURN(ndr_push_string(params
, NDR_SCALARS
, call
->datadesc
));
260 param_blob
= ndr_push_blob(call
->ndr_push_param
);
261 NDR_RETURN(ndr_push_bytes(params
, param_blob
.data
,
264 data_blob
= ndr_push_blob(call
->ndr_push_data
);
265 NDR_RETURN(ndr_push_bytes(data
, data_blob
.data
,
268 if (call
->auxdatadesc
)
269 NDR_RETURN(ndr_push_string(params
, NDR_SCALARS
, call
->auxdatadesc
));
271 trans
.in
.params
= ndr_push_blob(params
);
272 trans
.in
.data
= ndr_push_blob(data
);
274 result
= smb_raw_trans(tree
, call
, &trans
);
276 if (!NT_STATUS_IS_OK(result
))
279 call
->ndr_pull_param
= ndr_pull_init_blob(&trans
.out
.params
, call
);
280 call
->ndr_pull_param
->flags
= RAPNDR_FLAGS
;
282 call
->ndr_pull_data
= ndr_pull_init_blob(&trans
.out
.data
, call
);
283 call
->ndr_pull_data
->flags
= RAPNDR_FLAGS
;
289 static NTSTATUS
smbcli_rap_netshareenum(struct smbcli_tree
*tree
,
291 struct rap_NetShareEnum
*r
)
293 struct rap_call
*call
;
294 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
297 call
= new_rap_cli_call(tree
, RAP_WshareEnum
);
300 return NT_STATUS_NO_MEMORY
;
302 rap_cli_push_word(call
, r
->in
.level
); /* Level */
303 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
304 rap_cli_expect_multiple_entries(call
);
306 switch(r
->in
.level
) {
308 rap_cli_expect_format(call
, "B13");
311 rap_cli_expect_format(call
, "B13BWz");
315 if (DEBUGLEVEL
>= 10) {
316 NDR_PRINT_IN_DEBUG(rap_NetShareEnum
, r
);
319 result
= rap_cli_do_call(tree
, call
);
321 if (!NT_STATUS_IS_OK(result
))
324 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
325 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
326 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
327 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
329 r
->out
.info
= talloc_array(mem_ctx
, union rap_share_info
, r
->out
.count
);
331 if (r
->out
.info
== NULL
) {
332 result
= NT_STATUS_NO_MEMORY
;
336 for (i
=0; i
<r
->out
.count
; i
++) {
337 switch(r
->in
.level
) {
339 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
340 r
->out
.info
[i
].info0
.share_name
, 13));
343 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
344 r
->out
.info
[i
].info1
.share_name
, 13));
345 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
346 &r
->out
.info
[i
].info1
.reserved1
, 1));
347 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_data
,
348 NDR_SCALARS
, &r
->out
.info
[i
].info1
.share_type
));
349 RAP_GOTO(rap_pull_string(mem_ctx
, call
->ndr_pull_data
,
351 &r
->out
.info
[i
].info1
.comment
));
356 if (DEBUGLEVEL
>= 10) {
357 NDR_PRINT_OUT_DEBUG(rap_NetShareEnum
, r
);
359 result
= NT_STATUS_OK
;
366 static bool test_netshareenum(struct torture_context
*tctx
,
367 struct smbcli_state
*cli
)
369 struct rap_NetShareEnum r
;
375 torture_assert_ntstatus_ok(tctx
,
376 smbcli_rap_netshareenum(cli
->tree
, tctx
, &r
), "");
378 for (i
=0; i
<r
.out
.count
; i
++) {
379 printf("%s %d %s\n", r
.out
.info
[i
].info1
.share_name
,
380 r
.out
.info
[i
].info1
.share_type
,
381 r
.out
.info
[i
].info1
.comment
);
387 static NTSTATUS
smbcli_rap_netserverenum2(struct smbcli_tree
*tree
,
389 struct rap_NetServerEnum2
*r
)
391 struct rap_call
*call
;
392 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
395 call
= new_rap_cli_call(mem_ctx
, RAP_NetServerEnum2
);
398 return NT_STATUS_NO_MEMORY
;
400 rap_cli_push_word(call
, r
->in
.level
);
401 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
402 rap_cli_expect_multiple_entries(call
);
403 rap_cli_push_dword(call
, r
->in
.servertype
);
404 rap_cli_push_string(call
, r
->in
.domain
);
406 switch(r
->in
.level
) {
408 rap_cli_expect_format(call
, "B16");
411 rap_cli_expect_format(call
, "B16BBDz");
415 if (DEBUGLEVEL
>= 10) {
416 NDR_PRINT_IN_DEBUG(rap_NetServerEnum2
, r
);
419 result
= rap_cli_do_call(tree
, call
);
421 if (!NT_STATUS_IS_OK(result
))
424 result
= NT_STATUS_INVALID_PARAMETER
;
426 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
427 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
428 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
429 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
431 r
->out
.info
= talloc_array(mem_ctx
, union rap_server_info
, r
->out
.count
);
433 if (r
->out
.info
== NULL
) {
434 result
= NT_STATUS_NO_MEMORY
;
438 for (i
=0; i
<r
->out
.count
; i
++) {
439 switch(r
->in
.level
) {
441 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
442 r
->out
.info
[i
].info0
.name
, 16));
445 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
446 r
->out
.info
[i
].info1
.name
, 16));
447 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
448 &r
->out
.info
[i
].info1
.version_major
, 1));
449 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
450 &r
->out
.info
[i
].info1
.version_minor
, 1));
451 NDR_GOTO(ndr_pull_uint32(call
->ndr_pull_data
,
452 NDR_SCALARS
, &r
->out
.info
[i
].info1
.servertype
));
453 RAP_GOTO(rap_pull_string(mem_ctx
, call
->ndr_pull_data
,
455 &r
->out
.info
[i
].info1
.comment
));
459 if (DEBUGLEVEL
>= 10) {
460 NDR_PRINT_OUT_DEBUG(rap_NetServerEnum2
, r
);
463 result
= NT_STATUS_OK
;
470 static bool test_netserverenum(struct torture_context
*tctx
,
471 struct smbcli_state
*cli
)
473 struct rap_NetServerEnum2 r
;
478 r
.in
.servertype
= 0xffffffff;
479 r
.in
.servertype
= 0x80000000;
482 torture_assert_ntstatus_ok(tctx
,
483 smbcli_rap_netserverenum2(cli
->tree
, tctx
, &r
), "");
485 for (i
=0; i
<r
.out
.count
; i
++) {
486 switch (r
.in
.level
) {
488 printf("%s\n", r
.out
.info
[i
].info0
.name
);
491 printf("%s %x %s\n", r
.out
.info
[i
].info1
.name
,
492 r
.out
.info
[i
].info1
.servertype
,
493 r
.out
.info
[i
].info1
.comment
);
501 NTSTATUS
smbcli_rap_netservergetinfo(struct smbcli_tree
*tree
,
503 struct rap_WserverGetInfo
*r
)
505 struct rap_call
*call
;
506 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
508 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WserverGetInfo
))) {
509 return NT_STATUS_NO_MEMORY
;
512 rap_cli_push_word(call
, r
->in
.level
);
513 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
514 rap_cli_expect_word(call
);
516 switch(r
->in
.level
) {
518 rap_cli_expect_format(call
, "B16");
521 rap_cli_expect_format(call
, "B16BBDz");
524 result
= NT_STATUS_INVALID_PARAMETER
;
528 if (DEBUGLEVEL
>= 10) {
529 NDR_PRINT_IN_DEBUG(rap_WserverGetInfo
, r
);
532 result
= rap_cli_do_call(tree
, call
);
534 if (!NT_STATUS_IS_OK(result
))
537 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
538 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
539 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
541 switch(r
->in
.level
) {
543 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
544 r
->out
.info
.info0
.name
, 16));
547 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
548 r
->out
.info
.info1
.name
, 16));
549 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
550 &r
->out
.info
.info1
.version_major
, 1));
551 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
552 &r
->out
.info
.info1
.version_minor
, 1));
553 NDR_GOTO(ndr_pull_uint32(call
->ndr_pull_data
,
554 NDR_SCALARS
, &r
->out
.info
.info1
.servertype
));
555 RAP_GOTO(rap_pull_string(mem_ctx
, call
->ndr_pull_data
,
557 &r
->out
.info
.info1
.comment
));
560 if (DEBUGLEVEL
>= 10) {
561 NDR_PRINT_OUT_DEBUG(rap_WserverGetInfo
, r
);
568 static enum ndr_err_code
ndr_pull_rap_NetPrintQEnum_data(struct ndr_pull
*ndr
, struct rap_NetPrintQEnum
*r
)
570 uint32_t cntr_info_0
;
571 TALLOC_CTX
*_mem_save_info_0
;
573 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
574 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
575 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
576 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
577 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
578 NDR_CHECK(ndr_pull_rap_printq_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
580 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
581 NDR_CHECK(ndr_pull_rap_printq_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
583 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
585 return NDR_ERR_SUCCESS
;
588 NTSTATUS
smbcli_rap_netprintqenum(struct smbcli_tree
*tree
,
590 struct rap_NetPrintQEnum
*r
)
592 struct rap_call
*call
;
593 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
595 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQEnum
))) {
596 return NT_STATUS_NO_MEMORY
;
599 rap_cli_push_word(call
, r
->in
.level
);
600 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
601 rap_cli_expect_multiple_entries(call
);
603 switch(r
->in
.level
) {
605 rap_cli_expect_format(call
, "B13");
608 rap_cli_expect_format(call
, "B13BWWWzzzzzWW");
611 rap_cli_expect_format(call
, "B13BWWWzzzzzWN");
612 rap_cli_expect_extra_format(call
, "WB21BB16B10zWWzDDz");
615 rap_cli_expect_format(call
, "zWWWWzzzzWWzzl");
618 rap_cli_expect_format(call
, "zWWWWzzzzWNzzl");
619 rap_cli_expect_extra_format(call
, "WWzWWDDzz");
620 /* no mention of extra format in MS-RAP */
623 rap_cli_expect_format(call
, "z");
626 result
= NT_STATUS_INVALID_PARAMETER
;
630 if (DEBUGLEVEL
>= 10) {
631 NDR_PRINT_IN_DEBUG(rap_NetPrintQEnum
, r
);
634 result
= rap_cli_do_call(tree
, call
);
636 if (!NT_STATUS_IS_OK(result
))
639 result
= NT_STATUS_INVALID_PARAMETER
;
641 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
642 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
643 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
644 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
646 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
648 NDR_GOTO(ndr_pull_rap_NetPrintQEnum_data(call
->ndr_pull_data
, r
));
650 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
652 if (DEBUGLEVEL
>= 10) {
653 NDR_PRINT_OUT_DEBUG(rap_NetPrintQEnum
, r
);
656 result
= NT_STATUS_OK
;
663 NTSTATUS
smbcli_rap_netprintqgetinfo(struct smbcli_tree
*tree
,
665 struct rap_NetPrintQGetInfo
*r
)
667 struct rap_call
*call
;
668 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
670 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQGetInfo
))) {
671 return NT_STATUS_NO_MEMORY
;
674 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
675 rap_cli_push_word(call
, r
->in
.level
);
676 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
677 rap_cli_expect_word(call
);
679 switch(r
->in
.level
) {
681 rap_cli_expect_format(call
, "B13");
684 rap_cli_expect_format(call
, "B13BWWWzzzzzWW");
687 rap_cli_expect_format(call
, "B13BWWWzzzzzWN");
688 rap_cli_expect_extra_format(call
, "WB21BB16B10zWWzDDz");
691 rap_cli_expect_format(call
, "zWWWWzzzzWWzzl");
694 rap_cli_expect_format(call
, "zWWWWzzzzWNzzl");
695 rap_cli_expect_extra_format(call
, "WWzWWDDzz");
696 /* no mention of extra format in MS-RAP */
699 rap_cli_expect_format(call
, "z");
702 result
= NT_STATUS_INVALID_PARAMETER
;
706 if (DEBUGLEVEL
>= 10) {
707 NDR_PRINT_IN_DEBUG(rap_NetPrintQGetInfo
, r
);
710 result
= rap_cli_do_call(tree
, call
);
712 if (!NT_STATUS_IS_OK(result
))
715 result
= NT_STATUS_INVALID_PARAMETER
;
719 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
720 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
721 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
723 if (r
->out
.status
== 0) {
724 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
726 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
727 NDR_GOTO(ndr_pull_rap_printq_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
730 if (DEBUGLEVEL
>= 10) {
731 NDR_PRINT_OUT_DEBUG(rap_NetPrintQGetInfo
, r
);
734 result
= NT_STATUS_OK
;
740 NTSTATUS
smbcli_rap_netprintjobpause(struct smbcli_tree
*tree
,
742 struct rap_NetPrintJobPause
*r
)
744 struct rap_call
*call
;
745 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
747 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobPause
))) {
748 return NT_STATUS_NO_MEMORY
;
751 rap_cli_push_word(call
, r
->in
.JobID
);
753 rap_cli_expect_format(call
, "W");
755 if (DEBUGLEVEL
>= 10) {
756 NDR_PRINT_IN_DEBUG(rap_NetPrintJobPause
, r
);
759 result
= rap_cli_do_call(tree
, call
);
761 if (!NT_STATUS_IS_OK(result
))
764 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
765 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
767 if (DEBUGLEVEL
>= 10) {
768 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobPause
, r
);
776 NTSTATUS
smbcli_rap_netprintjobcontinue(struct smbcli_tree
*tree
,
778 struct rap_NetPrintJobContinue
*r
)
780 struct rap_call
*call
;
781 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
783 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobContinue
))) {
784 return NT_STATUS_NO_MEMORY
;
787 rap_cli_push_word(call
, r
->in
.JobID
);
789 rap_cli_expect_format(call
, "W");
791 if (DEBUGLEVEL
>= 10) {
792 NDR_PRINT_IN_DEBUG(rap_NetPrintJobContinue
, r
);
795 result
= rap_cli_do_call(tree
, call
);
797 if (!NT_STATUS_IS_OK(result
))
800 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
801 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
803 if (DEBUGLEVEL
>= 10) {
804 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobContinue
, r
);
812 NTSTATUS
smbcli_rap_netprintjobdelete(struct smbcli_tree
*tree
,
814 struct rap_NetPrintJobDelete
*r
)
816 struct rap_call
*call
;
817 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
819 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobDel
))) {
820 return NT_STATUS_NO_MEMORY
;
823 rap_cli_push_word(call
, r
->in
.JobID
);
825 rap_cli_expect_format(call
, "W");
827 if (DEBUGLEVEL
>= 10) {
828 NDR_PRINT_IN_DEBUG(rap_NetPrintJobDelete
, r
);
831 result
= rap_cli_do_call(tree
, call
);
833 if (!NT_STATUS_IS_OK(result
))
836 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
837 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
839 if (DEBUGLEVEL
>= 10) {
840 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobDelete
, r
);
848 NTSTATUS
smbcli_rap_netprintqueuepause(struct smbcli_tree
*tree
,
850 struct rap_NetPrintQueuePause
*r
)
852 struct rap_call
*call
;
853 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
855 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQPause
))) {
856 return NT_STATUS_NO_MEMORY
;
859 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
861 rap_cli_expect_format(call
, "");
863 if (DEBUGLEVEL
>= 10) {
864 NDR_PRINT_IN_DEBUG(rap_NetPrintQueuePause
, r
);
867 result
= rap_cli_do_call(tree
, call
);
869 if (!NT_STATUS_IS_OK(result
))
872 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
873 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
875 if (DEBUGLEVEL
>= 10) {
876 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueuePause
, r
);
884 NTSTATUS
smbcli_rap_netprintqueueresume(struct smbcli_tree
*tree
,
886 struct rap_NetPrintQueueResume
*r
)
888 struct rap_call
*call
;
889 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
891 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQContinue
))) {
892 return NT_STATUS_NO_MEMORY
;
895 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
897 rap_cli_expect_format(call
, "");
899 if (DEBUGLEVEL
>= 10) {
900 NDR_PRINT_IN_DEBUG(rap_NetPrintQueueResume
, r
);
903 result
= rap_cli_do_call(tree
, call
);
905 if (!NT_STATUS_IS_OK(result
))
908 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
909 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
911 if (DEBUGLEVEL
>= 10) {
912 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueueResume
, r
);
920 NTSTATUS
smbcli_rap_netprintqueuepurge(struct smbcli_tree
*tree
,
922 struct rap_NetPrintQueuePurge
*r
)
924 struct rap_call
*call
;
925 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
927 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQPurge
))) {
928 return NT_STATUS_NO_MEMORY
;
931 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
933 rap_cli_expect_format(call
, "");
935 if (DEBUGLEVEL
>= 10) {
936 NDR_PRINT_IN_DEBUG(rap_NetPrintQueuePurge
, r
);
939 result
= rap_cli_do_call(tree
, call
);
941 if (!NT_STATUS_IS_OK(result
))
944 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
945 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
947 if (DEBUGLEVEL
>= 10) {
948 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueuePurge
, r
);
956 static enum ndr_err_code
ndr_pull_rap_NetPrintJobEnum_data(struct ndr_pull
*ndr
, struct rap_NetPrintJobEnum
*r
)
958 uint32_t cntr_info_0
;
959 TALLOC_CTX
*_mem_save_info_0
;
961 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
962 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
963 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
964 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
965 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
966 NDR_CHECK(ndr_pull_rap_printj_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
968 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
969 NDR_CHECK(ndr_pull_rap_printj_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
971 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
973 return NDR_ERR_SUCCESS
;
976 NTSTATUS
smbcli_rap_netprintjobenum(struct smbcli_tree
*tree
,
978 struct rap_NetPrintJobEnum
*r
)
980 struct rap_call
*call
;
981 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
983 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobEnum
))) {
984 return NT_STATUS_NO_MEMORY
;
987 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
988 rap_cli_push_word(call
, r
->in
.level
);
989 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
990 rap_cli_expect_multiple_entries(call
);
992 switch(r
->in
.level
) {
994 rap_cli_expect_format(call
, "W");
997 rap_cli_expect_format(call
, "WB21BB16B10zWWzDDz");
1000 rap_cli_expect_format(call
, "WWzWWDDzz");
1003 rap_cli_expect_format(call
, "WWzWWDDzzzzzzzzzzlz");
1006 rap_cli_expect_format(call
, "WWzWWDDzzzzzDDDDDDD");
1009 result
= NT_STATUS_INVALID_PARAMETER
;
1013 if (DEBUGLEVEL
>= 10) {
1014 NDR_PRINT_IN_DEBUG(rap_NetPrintJobEnum
, r
);
1017 result
= rap_cli_do_call(tree
, call
);
1019 if (!NT_STATUS_IS_OK(result
))
1022 result
= NT_STATUS_INVALID_PARAMETER
;
1024 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1025 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1026 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
1027 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1029 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1031 NDR_GOTO(ndr_pull_rap_NetPrintJobEnum_data(call
->ndr_pull_data
, r
));
1033 if (DEBUGLEVEL
>= 10) {
1034 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobEnum
, r
);
1037 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
1039 result
= NT_STATUS_OK
;
1046 NTSTATUS
smbcli_rap_netprintjobgetinfo(struct smbcli_tree
*tree
,
1047 TALLOC_CTX
*mem_ctx
,
1048 struct rap_NetPrintJobGetInfo
*r
)
1050 struct rap_call
*call
;
1051 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1053 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobGetInfo
))) {
1054 return NT_STATUS_NO_MEMORY
;
1057 rap_cli_push_word(call
, r
->in
.JobID
);
1058 rap_cli_push_word(call
, r
->in
.level
);
1059 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1060 rap_cli_expect_word(call
);
1062 switch(r
->in
.level
) {
1064 rap_cli_expect_format(call
, "W");
1067 rap_cli_expect_format(call
, "WB21BB16B10zWWzDDz");
1070 rap_cli_expect_format(call
, "WWzWWDDzz");
1073 rap_cli_expect_format(call
, "WWzWWDDzzzzzzzzzzlz");
1076 rap_cli_expect_format(call
, "WWzWWDDzzzzzDDDDDDD");
1079 result
= NT_STATUS_INVALID_PARAMETER
;
1083 if (DEBUGLEVEL
>= 10) {
1084 NDR_PRINT_IN_DEBUG(rap_NetPrintJobGetInfo
, r
);
1087 result
= rap_cli_do_call(tree
, call
);
1089 if (!NT_STATUS_IS_OK(result
))
1092 result
= NT_STATUS_INVALID_PARAMETER
;
1094 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1095 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1096 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1098 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1100 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
1101 NDR_GOTO(ndr_pull_rap_printj_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
1103 if (DEBUGLEVEL
>= 10) {
1104 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobGetInfo
, r
);
1107 result
= NT_STATUS_OK
;
1114 NTSTATUS
smbcli_rap_netprintjobsetinfo(struct smbcli_tree
*tree
,
1115 TALLOC_CTX
*mem_ctx
,
1116 struct rap_NetPrintJobSetInfo
*r
)
1118 struct rap_call
*call
;
1119 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1121 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobSetInfo
))) {
1122 return NT_STATUS_NO_MEMORY
;
1125 rap_cli_push_word(call
, r
->in
.JobID
);
1126 rap_cli_push_word(call
, r
->in
.level
);
1127 rap_cli_push_sendbuf(call
, r
->in
.bufsize
);
1128 rap_cli_push_param(call
, r
->in
.ParamNum
);
1130 switch (r
->in
.ParamNum
) {
1131 case RAP_PARAM_JOBNUM
:
1132 case RAP_PARAM_JOBPOSITION
:
1133 case RAP_PARAM_JOBSTATUS
:
1134 NDR_GOTO(ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.Param
.value
));
1136 case RAP_PARAM_USERNAME
:
1137 case RAP_PARAM_NOTIFYNAME
:
1138 case RAP_PARAM_DATATYPE
:
1139 case RAP_PARAM_PARAMETERS_STRING
:
1140 case RAP_PARAM_JOBSTATUSSTR
:
1141 case RAP_PARAM_JOBCOMMENT
:
1142 NDR_GOTO(ndr_push_string(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.Param
.string
));
1144 case RAP_PARAM_TIMESUBMITTED
:
1145 case RAP_PARAM_JOBSIZE
:
1146 NDR_GOTO(ndr_push_uint32(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.Param
.value4
));
1149 result
= NT_STATUS_INVALID_PARAMETER
;
1153 /* not really sure if this is correct */
1154 rap_cli_expect_format(call
, "WB21BB16B10zWWzDDz");
1156 if (DEBUGLEVEL
>= 10) {
1157 NDR_PRINT_IN_DEBUG(rap_NetPrintJobSetInfo
, r
);
1160 result
= rap_cli_do_call(tree
, call
);
1162 if (!NT_STATUS_IS_OK(result
))
1165 result
= NT_STATUS_INVALID_PARAMETER
;
1167 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1168 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1170 result
= NT_STATUS_OK
;
1172 if (!NT_STATUS_IS_OK(result
)) {
1176 if (DEBUGLEVEL
>= 10) {
1177 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobSetInfo
, r
);
1185 static enum ndr_err_code
ndr_pull_rap_NetPrintDestEnum_data(struct ndr_pull
*ndr
, struct rap_NetPrintDestEnum
*r
)
1187 uint32_t cntr_info_0
;
1188 TALLOC_CTX
*_mem_save_info_0
;
1190 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
1191 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
1192 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
1193 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1194 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
1195 NDR_CHECK(ndr_pull_rap_printdest_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
1197 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1198 NDR_CHECK(ndr_pull_rap_printdest_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
1200 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
1202 return NDR_ERR_SUCCESS
;
1206 NTSTATUS
smbcli_rap_netprintdestenum(struct smbcli_tree
*tree
,
1207 TALLOC_CTX
*mem_ctx
,
1208 struct rap_NetPrintDestEnum
*r
)
1210 struct rap_call
*call
;
1211 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1213 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintDestEnum
))) {
1214 return NT_STATUS_NO_MEMORY
;
1217 rap_cli_push_word(call
, r
->in
.level
);
1218 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1219 rap_cli_expect_multiple_entries(call
);
1221 switch(r
->in
.level
) {
1223 rap_cli_expect_format(call
, "B9");
1226 rap_cli_expect_format(call
, "B9B21WWzW");
1229 rap_cli_expect_format(call
, "z");
1232 rap_cli_expect_format(call
, "zzzWWzzzWW");
1235 result
= NT_STATUS_INVALID_PARAMETER
;
1239 if (DEBUGLEVEL
>= 10) {
1240 NDR_PRINT_IN_DEBUG(rap_NetPrintDestEnum
, r
);
1243 result
= rap_cli_do_call(tree
, call
);
1245 if (!NT_STATUS_IS_OK(result
))
1248 result
= NT_STATUS_INVALID_PARAMETER
;
1250 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1251 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1252 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
1253 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1255 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1257 NDR_GOTO(ndr_pull_rap_NetPrintDestEnum_data(call
->ndr_pull_data
, r
));
1259 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
1261 if (DEBUGLEVEL
>= 10) {
1262 NDR_PRINT_OUT_DEBUG(rap_NetPrintDestEnum
, r
);
1265 result
= NT_STATUS_OK
;
1272 NTSTATUS
smbcli_rap_netprintdestgetinfo(struct smbcli_tree
*tree
,
1273 TALLOC_CTX
*mem_ctx
,
1274 struct rap_NetPrintDestGetInfo
*r
)
1276 struct rap_call
*call
;
1277 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1279 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintDestGetInfo
))) {
1280 return NT_STATUS_NO_MEMORY
;
1283 rap_cli_push_string(call
, r
->in
.PrintDestName
);
1284 rap_cli_push_word(call
, r
->in
.level
);
1285 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1286 rap_cli_expect_word(call
);
1288 switch(r
->in
.level
) {
1290 rap_cli_expect_format(call
, "B9");
1293 rap_cli_expect_format(call
, "B9B21WWzW");
1296 rap_cli_expect_format(call
, "z");
1299 rap_cli_expect_format(call
, "zzzWWzzzWW");
1302 result
= NT_STATUS_INVALID_PARAMETER
;
1306 if (DEBUGLEVEL
>= 10) {
1307 NDR_PRINT_IN_DEBUG(rap_NetPrintDestGetInfo
, r
);
1310 result
= rap_cli_do_call(tree
, call
);
1312 if (!NT_STATUS_IS_OK(result
))
1315 result
= NT_STATUS_INVALID_PARAMETER
;
1317 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1318 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1319 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1321 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1323 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
1324 NDR_GOTO(ndr_pull_rap_printdest_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
1326 if (DEBUGLEVEL
>= 10) {
1327 NDR_PRINT_OUT_DEBUG(rap_NetPrintDestGetInfo
, r
);
1330 result
= NT_STATUS_OK
;
1337 NTSTATUS
smbcli_rap_netuserpasswordset2(struct smbcli_tree
*tree
,
1338 struct smb_iconv_convenience
*iconv_convenience
,
1339 TALLOC_CTX
*mem_ctx
,
1340 struct rap_NetUserPasswordSet2
*r
)
1342 struct rap_call
*call
;
1343 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1345 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserPasswordSet2
))) {
1346 return NT_STATUS_NO_MEMORY
;
1349 rap_cli_push_string(call
, r
->in
.UserName
);
1350 rap_cli_push_paramdesc(call
, 'b');
1351 rap_cli_push_paramdesc(call
, '1');
1352 rap_cli_push_paramdesc(call
, '6');
1353 ndr_push_array_uint8(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.OldPassword
, 16);
1354 rap_cli_push_paramdesc(call
, 'b');
1355 rap_cli_push_paramdesc(call
, '1');
1356 rap_cli_push_paramdesc(call
, '6');
1357 ndr_push_array_uint8(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.NewPassword
, 16);
1358 rap_cli_push_word(call
, r
->in
.EncryptedPassword
);
1359 rap_cli_push_word(call
, r
->in
.RealPasswordLength
);
1361 rap_cli_expect_format(call
, "");
1363 if (DEBUGLEVEL
>= 10) {
1364 NDR_PRINT_IN_DEBUG(rap_NetUserPasswordSet2
, r
);
1367 result
= rap_cli_do_call(tree
, call
);
1369 if (!NT_STATUS_IS_OK(result
))
1372 result
= NT_STATUS_INVALID_PARAMETER
;
1374 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1375 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1377 result
= NT_STATUS_OK
;
1379 if (!NT_STATUS_IS_OK(result
)) {
1383 if (DEBUGLEVEL
>= 10) {
1384 NDR_PRINT_OUT_DEBUG(rap_NetUserPasswordSet2
, r
);
1392 NTSTATUS
smbcli_rap_netoemchangepassword(struct smbcli_tree
*tree
,
1393 struct smb_iconv_convenience
*iconv_convenience
,
1394 TALLOC_CTX
*mem_ctx
,
1395 struct rap_NetOEMChangePassword
*r
)
1397 struct rap_call
*call
;
1398 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1400 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_SamOEMChgPasswordUser2_P
))) {
1401 return NT_STATUS_NO_MEMORY
;
1404 rap_cli_push_string(call
, r
->in
.UserName
);
1405 rap_cli_push_sendbuf(call
, 532);
1406 ndr_push_array_uint8(call
->ndr_push_data
, NDR_SCALARS
, r
->in
.crypt_password
, 516);
1407 ndr_push_array_uint8(call
->ndr_push_data
, NDR_SCALARS
, r
->in
.password_hash
, 16);
1409 rap_cli_expect_format(call
, "B516B16");
1411 if (DEBUGLEVEL
>= 10) {
1412 NDR_PRINT_IN_DEBUG(rap_NetOEMChangePassword
, r
);
1415 result
= rap_cli_do_call(tree
, call
);
1417 if (!NT_STATUS_IS_OK(result
))
1420 result
= NT_STATUS_INVALID_PARAMETER
;
1422 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1423 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1425 result
= NT_STATUS_OK
;
1427 if (!NT_STATUS_IS_OK(result
)) {
1431 if (DEBUGLEVEL
>= 10) {
1432 NDR_PRINT_OUT_DEBUG(rap_NetOEMChangePassword
, r
);
1440 NTSTATUS
smbcli_rap_netusergetinfo(struct smbcli_tree
*tree
,
1441 TALLOC_CTX
*mem_ctx
,
1442 struct rap_NetUserGetInfo
*r
)
1444 struct rap_call
*call
;
1445 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1447 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserGetInfo
))) {
1448 return NT_STATUS_NO_MEMORY
;
1451 rap_cli_push_string(call
, r
->in
.UserName
);
1452 rap_cli_push_word(call
, r
->in
.level
);
1453 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1454 rap_cli_expect_word(call
);
1456 switch(r
->in
.level
) {
1458 rap_cli_expect_format(call
, "B21");
1461 rap_cli_expect_format(call
, "B21BB16DWzzWz");
1464 rap_cli_expect_format(call
, "B21BB16DWzzWzDzzzzDDDDWb21WWzWW");
1467 rap_cli_expect_format(call
, "B21Bzzz");
1470 rap_cli_expect_format(call
, "B21BzzzWDDzzDDWWzWzDWb21W");
1473 result
= NT_STATUS_INVALID_PARAMETER
;
1477 if (DEBUGLEVEL
>= 10) {
1478 NDR_PRINT_IN_DEBUG(rap_NetUserGetInfo
, r
);
1481 result
= rap_cli_do_call(tree
, call
);
1483 if (!NT_STATUS_IS_OK(result
))
1486 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1487 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1488 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1490 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1492 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
1493 NDR_GOTO(ndr_pull_rap_netuser_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
1495 if (DEBUGLEVEL
>= 10) {
1496 NDR_PRINT_OUT_DEBUG(rap_NetUserGetInfo
, r
);
1499 result
= NT_STATUS_OK
;
1507 static bool test_netservergetinfo(struct torture_context
*tctx
,
1508 struct smbcli_state
*cli
)
1510 struct rap_WserverGetInfo r
;
1513 r
.in
.bufsize
= 0xffff;
1516 torture_assert_ntstatus_ok(tctx
,
1517 smbcli_rap_netservergetinfo(cli
->tree
, tctx
, &r
),
1518 "rap_netservergetinfo level 0 failed");
1519 torture_assert_werr_ok(tctx
, W_ERROR(r
.out
.status
),
1520 "rap_netservergetinfo level 0 failed");
1523 torture_assert_ntstatus_ok(tctx
,
1524 smbcli_rap_netservergetinfo(cli
->tree
, tctx
, &r
),
1525 "rap_netservergetinfo level 1 failed");
1526 torture_assert_werr_ok(tctx
, W_ERROR(r
.out
.status
),
1527 "rap_netservergetinfo level 1 failed");
1532 static enum ndr_err_code
ndr_pull_rap_NetSessionEnum_data(struct ndr_pull
*ndr
, struct rap_NetSessionEnum
*r
)
1534 uint32_t cntr_info_0
;
1535 TALLOC_CTX
*_mem_save_info_0
;
1537 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
1538 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
1539 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
1540 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1541 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
1542 NDR_CHECK(ndr_pull_rap_session_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
1544 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1545 NDR_CHECK(ndr_pull_rap_session_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
1547 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
1549 return NDR_ERR_SUCCESS
;
1553 static NTSTATUS
smbcli_rap_netsessionenum(struct smbcli_tree
*tree
,
1554 TALLOC_CTX
*mem_ctx
,
1555 struct rap_NetSessionEnum
*r
)
1557 struct rap_call
*call
;
1558 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1560 call
= new_rap_cli_call(tree
, RAP_WsessionEnum
);
1563 return NT_STATUS_NO_MEMORY
;
1565 rap_cli_push_word(call
, r
->in
.level
);
1566 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1567 rap_cli_expect_multiple_entries(call
);
1569 switch(r
->in
.level
) {
1571 rap_cli_expect_format(call
, "zzWWWDDDz");
1574 result
= NT_STATUS_INVALID_PARAMETER
;
1578 if (DEBUGLEVEL
>= 10) {
1579 NDR_PRINT_IN_DEBUG(rap_NetSessionEnum
, r
);
1582 result
= rap_cli_do_call(tree
, call
);
1584 if (!NT_STATUS_IS_OK(result
))
1587 result
= NT_STATUS_INVALID_PARAMETER
;
1589 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1590 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1591 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
1592 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1594 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1596 NDR_GOTO(ndr_pull_rap_NetSessionEnum_data(call
->ndr_pull_data
, r
));
1598 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
1600 if (DEBUGLEVEL
>= 10) {
1601 NDR_PRINT_OUT_DEBUG(rap_NetSessionEnum
, r
);
1604 result
= NT_STATUS_OK
;
1611 static bool test_netsessionenum(struct torture_context
*tctx
,
1612 struct smbcli_state
*cli
)
1614 struct rap_NetSessionEnum r
;
1616 uint16_t levels
[] = { 2 };
1618 for (i
=0; i
< ARRAY_SIZE(levels
); i
++) {
1620 r
.in
.level
= levels
[i
];
1621 r
.in
.bufsize
= 8192;
1623 torture_comment(tctx
,
1624 "Testing rap_NetSessionEnum level %d\n", r
.in
.level
);
1626 torture_assert_ntstatus_ok(tctx
,
1627 smbcli_rap_netsessionenum(cli
->tree
, tctx
, &r
),
1628 "smbcli_rap_netsessionenum failed");
1634 bool torture_rap_scan(struct torture_context
*torture
, struct smbcli_state
*cli
)
1638 for (callno
= 0; callno
< 0xffff; callno
++) {
1639 struct rap_call
*call
= new_rap_cli_call(torture
, callno
);
1642 result
= rap_cli_do_call(cli
->tree
, call
);
1644 if (!NT_STATUS_EQUAL(result
, NT_STATUS_INVALID_PARAMETER
))
1647 printf("callno %d is RAP call\n", callno
);
1653 NTSTATUS
torture_rap_init(void)
1655 struct torture_suite
*suite
= torture_suite_create(talloc_autofree_context(), "rap");
1656 struct torture_suite
*suite_basic
= torture_suite_create(suite
, "basic");
1658 torture_suite_add_suite(suite
, suite_basic
);
1659 torture_suite_add_suite(suite
, torture_rap_rpc(suite
));
1660 torture_suite_add_suite(suite
, torture_rap_printing(suite
));
1661 torture_suite_add_suite(suite
, torture_rap_sam(suite
));
1663 torture_suite_add_1smb_test(suite_basic
, "netserverenum",
1664 test_netserverenum
);
1665 torture_suite_add_1smb_test(suite_basic
, "netshareenum",
1667 torture_suite_add_1smb_test(suite_basic
, "netservergetinfo",
1668 test_netservergetinfo
);
1669 torture_suite_add_1smb_test(suite_basic
, "netsessionenum",
1670 test_netsessionenum
);
1672 torture_suite_add_1smb_test(suite
, "scan", torture_rap_scan
);
1674 suite
->description
= talloc_strdup(suite
,
1675 "Remote Administration Protocol tests");
1677 torture_register_suite(suite
);
1679 return NT_STATUS_OK
;