LCOV - code coverage report
Current view: top level - source4/libcli/rap - rap.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 415 1021 40.6 %
Date: 2024-04-21 15:09:00 Functions: 25 42 59.5 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    RAP client
       4             :    Copyright (C) Volker Lendecke 2004
       5             :    Copyright (C) Tim Potter 2005
       6             :    Copyright (C) Jelmer Vernooij 2007
       7             :    Copyright (C) Guenther Deschner 2010-2011
       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 3 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, see <http://www.gnu.org/licenses/>.
      21             : */
      22             : 
      23             : #include "includes.h"
      24             : #include "libcli/libcli.h"
      25             : #include "../librpc/gen_ndr/ndr_rap.h"
      26             : #include "libcli/rap/rap.h"
      27             : #include "librpc/ndr/libndr.h"
      28             : 
      29          90 : struct rap_call *new_rap_cli_call(TALLOC_CTX *mem_ctx, uint16_t callno)
      30             : {
      31           0 :         struct rap_call *call;
      32             : 
      33          90 :         call = talloc_zero(mem_ctx, struct rap_call);
      34          90 :         if (call == NULL) {
      35           0 :                 return NULL;
      36             :         }
      37             : 
      38          90 :         call->callno = callno;
      39          90 :         call->rcv_paramlen = 4;
      40             : 
      41          90 :         call->ndr_push_param = ndr_push_init_ctx(call);
      42          90 :         if (call->ndr_push_param == NULL) {
      43           0 :                 talloc_free(call);
      44           0 :                 return NULL;
      45             :         }
      46          90 :         call->ndr_push_param->flags = RAPNDR_FLAGS;
      47             : 
      48          90 :         call->ndr_push_data = ndr_push_init_ctx(call);
      49          90 :         if (call->ndr_push_data == NULL) {
      50           0 :                 talloc_free(call);
      51           0 :                 return NULL;
      52             :         }
      53          90 :         call->ndr_push_data->flags = RAPNDR_FLAGS;
      54             : 
      55          90 :         call->pull_mem_ctx = mem_ctx;
      56             : 
      57          90 :         return call;
      58             : }
      59             : 
      60         430 : static void rap_cli_push_paramdesc(struct rap_call *call, char desc)
      61             : {
      62         430 :         int len = 0;
      63             : 
      64         430 :         if (call->paramdesc != NULL)
      65         340 :                 len = strlen(call->paramdesc);
      66             : 
      67         430 :         call->paramdesc = talloc_realloc(call,
      68             :                                          call->paramdesc,
      69             :                                          char,
      70             :                                          len+2);
      71             : 
      72         430 :         call->paramdesc[len] = desc;
      73         430 :         call->paramdesc[len+1] = '\0';
      74         430 : }
      75             : 
      76         102 : static void rap_cli_push_word(struct rap_call *call, uint16_t val)
      77             : {
      78         102 :         rap_cli_push_paramdesc(call, 'W');
      79         102 :         ndr_push_uint16(call->ndr_push_param, NDR_SCALARS, val);
      80         102 : }
      81             : 
      82           4 : static void rap_cli_push_dword(struct rap_call *call, uint32_t val)
      83             : {
      84           4 :         rap_cli_push_paramdesc(call, 'D');
      85           4 :         ndr_push_uint32(call->ndr_push_param, NDR_SCALARS, val);
      86           4 : }
      87             : 
      88          66 : static void rap_cli_push_rcvbuf(struct rap_call *call, int len)
      89             : {
      90          66 :         rap_cli_push_paramdesc(call, 'r');
      91          66 :         rap_cli_push_paramdesc(call, 'L');
      92          66 :         ndr_push_uint16(call->ndr_push_param, NDR_SCALARS, len);
      93          66 :         call->rcv_datalen = len;
      94          66 : }
      95             : 
      96          12 : static void rap_cli_push_sendbuf(struct rap_call *call, int len)
      97             : {
      98          12 :         rap_cli_push_paramdesc(call, 's');
      99          12 :         rap_cli_push_paramdesc(call, 'T');
     100          12 :         ndr_push_uint16(call->ndr_push_param, NDR_SCALARS, len);
     101          12 : }
     102             : 
     103           0 : static void rap_cli_push_param(struct rap_call *call, uint16_t val)
     104             : {
     105           0 :         rap_cli_push_paramdesc(call, 'P');
     106           0 :         ndr_push_uint16(call->ndr_push_param, NDR_SCALARS, val);
     107           0 : }
     108             : 
     109          16 : static void rap_cli_expect_multiple_entries(struct rap_call *call)
     110             : {
     111          16 :         rap_cli_push_paramdesc(call, 'e');
     112          16 :         rap_cli_push_paramdesc(call, 'h');
     113          16 :         call->rcv_paramlen += 4; /* uint16_t entry count, uint16_t total */
     114          16 : }
     115             : 
     116          46 : static void rap_cli_expect_word(struct rap_call *call)
     117             : {
     118          46 :         rap_cli_push_paramdesc(call, 'h');
     119          46 :         call->rcv_paramlen += 2;
     120          46 : }
     121             : 
     122          42 : static void rap_cli_push_string(struct rap_call *call, const char *str)
     123             : {
     124          42 :         if (str == NULL) {
     125           4 :                 rap_cli_push_paramdesc(call, 'O');
     126           4 :                 return;
     127             :         }
     128          38 :         rap_cli_push_paramdesc(call, 'z');
     129          38 :         ndr_push_string(call->ndr_push_param, NDR_SCALARS, str);
     130             : }
     131             : 
     132          90 : static void rap_cli_expect_format(struct rap_call *call, const char *format)
     133             : {
     134          90 :         call->datadesc = format;
     135          90 : }
     136             : 
     137           8 : static void rap_cli_expect_extra_format(struct rap_call *call, const char *format)
     138             : {
     139           8 :         call->auxdatadesc = format;
     140           8 : }
     141             : 
     142         178 : static NTSTATUS rap_pull_string(TALLOC_CTX *mem_ctx, struct ndr_pull *ndr,
     143             :                                 uint16_t convert, const char **dest)
     144             : {
     145           0 :         uint16_t string_offset;
     146           0 :         uint16_t ignore;
     147           0 :         const char *p;
     148           0 :         size_t len;
     149             : 
     150         178 :         NDR_RETURN(ndr_pull_uint16(ndr, NDR_SCALARS, &string_offset));
     151         178 :         NDR_RETURN(ndr_pull_uint16(ndr, NDR_SCALARS, &ignore));
     152             : 
     153         178 :         string_offset -= convert;
     154             : 
     155         178 :         if (string_offset+1 > ndr->data_size)
     156           0 :                 return NT_STATUS_INVALID_PARAMETER;
     157             : 
     158         178 :         p = (const char *)(ndr->data + string_offset);
     159         178 :         len = strnlen(p, ndr->data_size-string_offset);
     160             : 
     161         178 :         if ( string_offset + len + 1 >  ndr->data_size )
     162           0 :                 return NT_STATUS_INVALID_PARAMETER;
     163             : 
     164         178 :         *dest = talloc_zero_array(mem_ctx, char, len+1);
     165         178 :         pull_string(discard_const_p(char, *dest), p, len+1, len, STR_ASCII);
     166             : 
     167         178 :         return NT_STATUS_OK;
     168             : }
     169             : 
     170          90 : NTSTATUS rap_cli_do_call(struct smbcli_tree *tree,
     171             :                          struct rap_call *call)
     172             : {
     173           0 :         NTSTATUS result;
     174           0 :         DATA_BLOB param_blob;
     175           0 :         DATA_BLOB data_blob;
     176           0 :         struct ndr_push *params;
     177           0 :         struct ndr_push *data;
     178           0 :         struct smb_trans2 trans;
     179             : 
     180          90 :         params = ndr_push_init_ctx(call);
     181             : 
     182          90 :         if (params == NULL)
     183           0 :                 return NT_STATUS_NO_MEMORY;
     184             : 
     185          90 :         params->flags = RAPNDR_FLAGS;
     186             : 
     187          90 :         data = ndr_push_init_ctx(call);
     188             : 
     189          90 :         if (data == NULL)
     190           0 :                 return NT_STATUS_NO_MEMORY;
     191             : 
     192          90 :         data->flags = RAPNDR_FLAGS;
     193             : 
     194          90 :         trans.in.max_param = call->rcv_paramlen;
     195          90 :         trans.in.max_data = call->rcv_datalen;
     196          90 :         trans.in.max_setup = 0;
     197          90 :         trans.in.flags = 0;
     198          90 :         trans.in.timeout = 0;
     199          90 :         trans.in.setup_count = 0;
     200          90 :         trans.in.setup = NULL;
     201          90 :         trans.in.trans_name = "\\PIPE\\LANMAN";
     202             : 
     203          90 :         NDR_RETURN(ndr_push_uint16(params, NDR_SCALARS, call->callno));
     204          90 :         if (call->paramdesc)
     205          90 :                 NDR_RETURN(ndr_push_string(params, NDR_SCALARS, call->paramdesc));
     206          90 :         if (call->datadesc)
     207          90 :                 NDR_RETURN(ndr_push_string(params, NDR_SCALARS, call->datadesc));
     208             : 
     209          90 :         param_blob = ndr_push_blob(call->ndr_push_param);
     210          90 :         NDR_RETURN(ndr_push_bytes(params, param_blob.data,
     211             :                                  param_blob.length));
     212             : 
     213          90 :         data_blob = ndr_push_blob(call->ndr_push_data);
     214          90 :         NDR_RETURN(ndr_push_bytes(data, data_blob.data,
     215             :                                  data_blob.length));
     216             : 
     217          90 :         if (call->auxdatadesc)
     218           8 :                 NDR_RETURN(ndr_push_string(params, NDR_SCALARS, call->auxdatadesc));
     219             : 
     220          90 :         trans.in.params = ndr_push_blob(params);
     221          90 :         trans.in.data = ndr_push_blob(data);
     222             : 
     223          90 :         result = smb_raw_trans(tree, call, &trans);
     224             : 
     225          90 :         if (!NT_STATUS_IS_OK(result))
     226           0 :                 return result;
     227             : 
     228          90 :         call->ndr_pull_param = ndr_pull_init_blob(&trans.out.params, call);
     229          90 :         call->ndr_pull_param->flags = RAPNDR_FLAGS;
     230          90 :         call->ndr_pull_param->current_mem_ctx = call->pull_mem_ctx;
     231          90 :         call->ndr_pull_data = ndr_pull_init_blob(&trans.out.data, call);
     232          90 :         call->ndr_pull_data->flags = RAPNDR_FLAGS;
     233          90 :         call->ndr_pull_data->current_mem_ctx = call->pull_mem_ctx;
     234             : 
     235          90 :         return result;
     236             : }
     237             : 
     238             : 
     239           4 : NTSTATUS smbcli_rap_netshareenum(struct smbcli_tree *tree,
     240             :                                  TALLOC_CTX *mem_ctx,
     241             :                                  struct rap_NetShareEnum *r)
     242             : {
     243           0 :         struct rap_call *call;
     244           4 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     245           0 :         int i;
     246             : 
     247           4 :         call = new_rap_cli_call(tree, RAP_WshareEnum);
     248             : 
     249           4 :         if (call == NULL)
     250           0 :                 return NT_STATUS_NO_MEMORY;
     251             : 
     252           4 :         rap_cli_push_word(call, r->in.level); /* Level */
     253           4 :         rap_cli_push_rcvbuf(call, r->in.bufsize);
     254           4 :         rap_cli_expect_multiple_entries(call);
     255             : 
     256           4 :         switch(r->in.level) {
     257           0 :         case 0:
     258           0 :                 rap_cli_expect_format(call, "B13");
     259           0 :                 break;
     260           4 :         case 1:
     261           4 :                 rap_cli_expect_format(call, "B13BWz");
     262           4 :                 break;
     263             :         }
     264             : 
     265           4 :         if (DEBUGLEVEL >= 10) {
     266           0 :                 NDR_PRINT_IN_DEBUG(rap_NetShareEnum, r);
     267             :         }
     268             : 
     269           4 :         result = rap_cli_do_call(tree, call);
     270             : 
     271           4 :         if (!NT_STATUS_IS_OK(result))
     272           0 :                 goto done;
     273             : 
     274           4 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
     275           4 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
     276           4 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.count));
     277           4 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.available));
     278             : 
     279           4 :         r->out.info = talloc_array(mem_ctx, union rap_share_info, r->out.count);
     280             : 
     281           4 :         if (r->out.info == NULL) {
     282           0 :                 result = NT_STATUS_NO_MEMORY;
     283           0 :                 goto done;
     284             :         }
     285             : 
     286         174 :         for (i=0; i<r->out.count; i++) {
     287         170 :                 switch(r->in.level) {
     288           0 :                 case 0:
     289           0 :                         NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
     290             :                                                 r->out.info[i].info0.share_name, 13));
     291           0 :                         break;
     292         170 :                 case 1:
     293         170 :                         NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
     294             :                                                 r->out.info[i].info1.share_name, 13));
     295         170 :                         NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
     296             :                                                 &r->out.info[i].info1.reserved1, 1));
     297         170 :                         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_data,
     298             :                                                NDR_SCALARS, &r->out.info[i].info1.share_type));
     299         170 :                         RAP_GOTO(rap_pull_string(mem_ctx, call->ndr_pull_data,
     300             :                                                r->out.convert,
     301             :                                                &r->out.info[i].info1.comment));
     302         170 :                         break;
     303             :                 }
     304             :         }
     305             : 
     306           4 :         if (DEBUGLEVEL >= 10) {
     307           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetShareEnum, r);
     308             :         }
     309           4 :         result = NT_STATUS_OK;
     310             : 
     311           4 :  done:
     312           4 :         talloc_free(call);
     313           4 :         return result;
     314             : }
     315             : 
     316           4 : NTSTATUS smbcli_rap_netserverenum2(struct smbcli_tree *tree,
     317             :                                    TALLOC_CTX *mem_ctx,
     318             :                                    struct rap_NetServerEnum2 *r)
     319             : {
     320           0 :         struct rap_call *call;
     321           4 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     322           0 :         int i;
     323             : 
     324           4 :         call = new_rap_cli_call(mem_ctx, RAP_NetServerEnum2);
     325             : 
     326           4 :         if (call == NULL)
     327           0 :                 return NT_STATUS_NO_MEMORY;
     328             : 
     329           4 :         rap_cli_push_word(call, r->in.level);
     330           4 :         rap_cli_push_rcvbuf(call, r->in.bufsize);
     331           4 :         rap_cli_expect_multiple_entries(call);
     332           4 :         rap_cli_push_dword(call, r->in.servertype);
     333           4 :         rap_cli_push_string(call, r->in.domain);
     334             : 
     335           4 :         switch(r->in.level) {
     336           4 :         case 0:
     337           4 :                 rap_cli_expect_format(call, "B16");
     338           4 :                 break;
     339           0 :         case 1:
     340           0 :                 rap_cli_expect_format(call, "B16BBDz");
     341           0 :                 break;
     342             :         }
     343             : 
     344           4 :         if (DEBUGLEVEL >= 10) {
     345           0 :                 NDR_PRINT_IN_DEBUG(rap_NetServerEnum2, r);
     346             :         }
     347             : 
     348           4 :         result = rap_cli_do_call(tree, call);
     349             : 
     350           4 :         if (!NT_STATUS_IS_OK(result))
     351           0 :                 goto done;
     352             : 
     353           4 :         result = NT_STATUS_INVALID_PARAMETER;
     354             : 
     355           4 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
     356           4 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
     357           4 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.count));
     358           4 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.available));
     359             : 
     360           4 :         r->out.info = talloc_array(mem_ctx, union rap_server_info, r->out.count);
     361             : 
     362           4 :         if (r->out.info == NULL) {
     363           0 :                 result = NT_STATUS_NO_MEMORY;
     364           0 :                 goto done;
     365             :         }
     366             : 
     367          12 :         for (i=0; i<r->out.count; i++) {
     368           8 :                 switch(r->in.level) {
     369           8 :                 case 0:
     370           8 :                         NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
     371             :                                                 r->out.info[i].info0.name, 16));
     372           8 :                         break;
     373           0 :                 case 1:
     374           0 :                         NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
     375             :                                                 r->out.info[i].info1.name, 16));
     376           0 :                         NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
     377             :                                               &r->out.info[i].info1.version_major, 1));
     378           0 :                         NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
     379             :                                               &r->out.info[i].info1.version_minor, 1));
     380           0 :                         NDR_GOTO(ndr_pull_uint32(call->ndr_pull_data,
     381             :                                                NDR_SCALARS, &r->out.info[i].info1.servertype));
     382           0 :                         RAP_GOTO(rap_pull_string(mem_ctx, call->ndr_pull_data,
     383             :                                                r->out.convert,
     384             :                                                &r->out.info[i].info1.comment));
     385             :                 }
     386             :         }
     387             : 
     388           4 :         if (DEBUGLEVEL >= 10) {
     389           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetServerEnum2, r);
     390             :         }
     391             : 
     392           4 :         result = NT_STATUS_OK;
     393             : 
     394           4 :  done:
     395           4 :         talloc_free(call);
     396           4 :         return result;
     397             : }
     398             : 
     399          24 : NTSTATUS smbcli_rap_netservergetinfo(struct smbcli_tree *tree,
     400             :                                      TALLOC_CTX *mem_ctx,
     401             :                                      struct rap_WserverGetInfo *r)
     402             : {
     403           0 :         struct rap_call *call;
     404          24 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     405             : 
     406          24 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WserverGetInfo))) {
     407           0 :                 return NT_STATUS_NO_MEMORY;
     408             :         }
     409             : 
     410          24 :         rap_cli_push_word(call, r->in.level);
     411          24 :         rap_cli_push_rcvbuf(call, r->in.bufsize);
     412          24 :         rap_cli_expect_word(call);
     413             : 
     414          24 :         switch(r->in.level) {
     415          16 :         case 0:
     416          16 :                 rap_cli_expect_format(call, "B16");
     417          16 :                 break;
     418           8 :         case 1:
     419           8 :                 rap_cli_expect_format(call, "B16BBDz");
     420           8 :                 break;
     421           0 :         default:
     422           0 :                 result = NT_STATUS_INVALID_PARAMETER;
     423           0 :                 goto done;
     424             :         }
     425             : 
     426          24 :         if (DEBUGLEVEL >= 10) {
     427           0 :                 NDR_PRINT_IN_DEBUG(rap_WserverGetInfo, r);
     428             :         }
     429             : 
     430          24 :         result = rap_cli_do_call(tree, call);
     431             : 
     432          24 :         if (!NT_STATUS_IS_OK(result))
     433           0 :                 goto done;
     434             : 
     435          24 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
     436          24 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
     437          24 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.available));
     438             : 
     439          24 :         switch(r->in.level) {
     440          16 :         case 0:
     441          16 :                 NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
     442             :                                         r->out.info.info0.name, 16));
     443          16 :                 break;
     444           8 :         case 1:
     445           8 :                 NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
     446             :                                         r->out.info.info1.name, 16));
     447           8 :                 NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
     448             :                                       &r->out.info.info1.version_major, 1));
     449           8 :                 NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
     450             :                                       &r->out.info.info1.version_minor, 1));
     451           8 :                 NDR_GOTO(ndr_pull_uint32(call->ndr_pull_data,
     452             :                                        NDR_SCALARS, &r->out.info.info1.servertype));
     453           8 :                 RAP_GOTO(rap_pull_string(mem_ctx, call->ndr_pull_data,
     454             :                                        r->out.convert,
     455             :                                        &r->out.info.info1.comment));
     456             :         }
     457             : 
     458          24 :         if (DEBUGLEVEL >= 10) {
     459           0 :                 NDR_PRINT_OUT_DEBUG(rap_WserverGetInfo, r);
     460             :         }
     461          24 :  done:
     462          24 :         talloc_free(call);
     463          24 :         return result;
     464             : }
     465             : 
     466           0 : static enum ndr_err_code ndr_pull_rap_NetPrintQEnum_data(struct ndr_pull *ndr, struct rap_NetPrintQEnum *r)
     467             : {
     468           0 :         uint32_t cntr_info_0;
     469           0 :         TALLOC_CTX *_mem_save_info_0;
     470             : 
     471           0 :         NDR_PULL_ALLOC_N(ndr, r->out.info, r->out.count);
     472           0 :         _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
     473           0 :         NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0);
     474           0 :         for (cntr_info_0 = 0; cntr_info_0 < r->out.count; cntr_info_0++) {
     475           0 :                 NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level));
     476           0 :                 NDR_CHECK(ndr_pull_rap_printq_info(ndr, NDR_SCALARS, &r->out.info[cntr_info_0]));
     477             :         }
     478           0 :         for (cntr_info_0 = 0; cntr_info_0 < r->out.count; cntr_info_0++) {
     479           0 :                 NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level));
     480           0 :                 NDR_CHECK(ndr_pull_rap_printq_info(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0]));
     481             :         }
     482           0 :         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0);
     483             : 
     484           0 :         return NDR_ERR_SUCCESS;
     485             : }
     486             : 
     487           0 : NTSTATUS smbcli_rap_netprintqenum(struct smbcli_tree *tree,
     488             :                                   TALLOC_CTX *mem_ctx,
     489             :                                   struct rap_NetPrintQEnum *r)
     490             : {
     491           0 :         struct rap_call *call;
     492           0 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     493             : 
     494           0 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WPrintQEnum))) {
     495           0 :                 return NT_STATUS_NO_MEMORY;
     496             :         }
     497             : 
     498           0 :         rap_cli_push_word(call, r->in.level);
     499           0 :         rap_cli_push_rcvbuf(call, r->in.bufsize);
     500           0 :         rap_cli_expect_multiple_entries(call);
     501             : 
     502           0 :         switch(r->in.level) {
     503           0 :         case 0:
     504           0 :                 rap_cli_expect_format(call, "B13");
     505           0 :                 break;
     506           0 :         case 1:
     507           0 :                 rap_cli_expect_format(call, "B13BWWWzzzzzWW");
     508           0 :                 break;
     509           0 :         case 2:
     510           0 :                 rap_cli_expect_format(call, "B13BWWWzzzzzWN");
     511           0 :                 rap_cli_expect_extra_format(call, "WB21BB16B10zWWzDDz");
     512           0 :                 break;
     513           0 :         case 3:
     514           0 :                 rap_cli_expect_format(call, "zWWWWzzzzWWzzl");
     515           0 :                 break;
     516           0 :         case 4:
     517           0 :                 rap_cli_expect_format(call, "zWWWWzzzzWNzzl");
     518           0 :                 rap_cli_expect_extra_format(call, "WWzWWDDzz");
     519             :                 /* no mention of extra format in MS-RAP */
     520           0 :                 break;
     521           0 :         case 5:
     522           0 :                 rap_cli_expect_format(call, "z");
     523           0 :                 break;
     524           0 :         default:
     525           0 :                 result = NT_STATUS_INVALID_PARAMETER;
     526           0 :                 goto done;
     527             :         }
     528             : 
     529           0 :         if (DEBUGLEVEL >= 10) {
     530           0 :                 NDR_PRINT_IN_DEBUG(rap_NetPrintQEnum, r);
     531             :         }
     532             : 
     533           0 :         result = rap_cli_do_call(tree, call);
     534             : 
     535           0 :         if (!NT_STATUS_IS_OK(result))
     536           0 :                 goto done;
     537             : 
     538           0 :         result = NT_STATUS_INVALID_PARAMETER;
     539             : 
     540           0 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
     541           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
     542           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.count));
     543           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.available));
     544             : 
     545           0 :         call->ndr_pull_data->relative_rap_convert = r->out.convert;
     546             : 
     547           0 :         NDR_GOTO(ndr_pull_rap_NetPrintQEnum_data(call->ndr_pull_data, r));
     548             : 
     549           0 :         r->out.info = talloc_steal(mem_ctx, r->out.info);
     550             : 
     551           0 :         if (DEBUGLEVEL >= 10) {
     552           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetPrintQEnum, r);
     553             :         }
     554             : 
     555           0 :         result = NT_STATUS_OK;
     556             : 
     557           0 :  done:
     558           0 :         talloc_free(call);
     559           0 :         return result;
     560             : }
     561             : 
     562           0 : NTSTATUS smbcli_rap_netprintqgetinfo(struct smbcli_tree *tree,
     563             :                                      TALLOC_CTX *mem_ctx,
     564             :                                      struct rap_NetPrintQGetInfo *r)
     565             : {
     566           0 :         struct rap_call *call;
     567           0 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     568             : 
     569           0 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WPrintQGetInfo))) {
     570           0 :                 return NT_STATUS_NO_MEMORY;
     571             :         }
     572             : 
     573           0 :         rap_cli_push_string(call, r->in.PrintQueueName);
     574           0 :         rap_cli_push_word(call, r->in.level);
     575           0 :         rap_cli_push_rcvbuf(call, r->in.bufsize);
     576           0 :         rap_cli_expect_word(call);
     577             : 
     578           0 :         switch(r->in.level) {
     579           0 :         case 0:
     580           0 :                 rap_cli_expect_format(call, "B13");
     581           0 :                 break;
     582           0 :         case 1:
     583           0 :                 rap_cli_expect_format(call, "B13BWWWzzzzzWW");
     584           0 :                 break;
     585           0 :         case 2:
     586           0 :                 rap_cli_expect_format(call, "B13BWWWzzzzzWN");
     587           0 :                 rap_cli_expect_extra_format(call, "WB21BB16B10zWWzDDz");
     588           0 :                 break;
     589           0 :         case 3:
     590           0 :                 rap_cli_expect_format(call, "zWWWWzzzzWWzzl");
     591           0 :                 break;
     592           0 :         case 4:
     593           0 :                 rap_cli_expect_format(call, "zWWWWzzzzWNzzl");
     594           0 :                 rap_cli_expect_extra_format(call, "WWzWWDDzz");
     595             :                 /* no mention of extra format in MS-RAP */
     596           0 :                 break;
     597           0 :         case 5:
     598           0 :                 rap_cli_expect_format(call, "z");
     599           0 :                 break;
     600           0 :         default:
     601           0 :                 result = NT_STATUS_INVALID_PARAMETER;
     602           0 :                 goto done;
     603             :         }
     604             : 
     605           0 :         if (DEBUGLEVEL >= 10) {
     606           0 :                 NDR_PRINT_IN_DEBUG(rap_NetPrintQGetInfo, r);
     607             :         }
     608             : 
     609           0 :         result = rap_cli_do_call(tree, call);
     610             : 
     611           0 :         if (!NT_STATUS_IS_OK(result))
     612           0 :                 goto done;
     613             : 
     614           0 :         result = NT_STATUS_INVALID_PARAMETER;
     615             : 
     616           0 :         ZERO_STRUCT(r->out);
     617             : 
     618           0 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
     619           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
     620           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.available));
     621             : 
     622           0 :         if (r->out.status == 0) {
     623           0 :                 call->ndr_pull_data->relative_rap_convert = r->out.convert;
     624             : 
     625           0 :                 NDR_GOTO(ndr_pull_set_switch_value(call->ndr_pull_data, &r->out.info, r->in.level));
     626           0 :                 NDR_GOTO(ndr_pull_rap_printq_info(call->ndr_pull_data, NDR_SCALARS|NDR_BUFFERS, &r->out.info));
     627             :         }
     628             : 
     629           0 :         if (DEBUGLEVEL >= 10) {
     630           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetPrintQGetInfo, r);
     631             :         }
     632             : 
     633           0 :         result = NT_STATUS_OK;
     634           0 :  done:
     635           0 :         talloc_free(call);
     636           0 :         return result;
     637             : }
     638             : 
     639           0 : NTSTATUS smbcli_rap_netprintjobpause(struct smbcli_tree *tree,
     640             :                                      TALLOC_CTX *mem_ctx,
     641             :                                      struct rap_NetPrintJobPause *r)
     642             : {
     643           0 :         struct rap_call *call;
     644           0 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     645             : 
     646           0 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WPrintJobPause))) {
     647           0 :                 return NT_STATUS_NO_MEMORY;
     648             :         }
     649             : 
     650           0 :         rap_cli_push_word(call, r->in.JobID);
     651             : 
     652           0 :         rap_cli_expect_format(call, "W");
     653             : 
     654           0 :         if (DEBUGLEVEL >= 10) {
     655           0 :                 NDR_PRINT_IN_DEBUG(rap_NetPrintJobPause, r);
     656             :         }
     657             : 
     658           0 :         result = rap_cli_do_call(tree, call);
     659             : 
     660           0 :         if (!NT_STATUS_IS_OK(result))
     661           0 :                 goto done;
     662             : 
     663           0 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
     664           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
     665             : 
     666           0 :         if (DEBUGLEVEL >= 10) {
     667           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobPause, r);
     668             :         }
     669             : 
     670           0 :  done:
     671           0 :         talloc_free(call);
     672           0 :         return result;
     673             : }
     674             : 
     675           0 : NTSTATUS smbcli_rap_netprintjobcontinue(struct smbcli_tree *tree,
     676             :                                         TALLOC_CTX *mem_ctx,
     677             :                                         struct rap_NetPrintJobContinue *r)
     678             : {
     679           0 :         struct rap_call *call;
     680           0 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     681             : 
     682           0 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WPrintJobContinue))) {
     683           0 :                 return NT_STATUS_NO_MEMORY;
     684             :         }
     685             : 
     686           0 :         rap_cli_push_word(call, r->in.JobID);
     687             : 
     688           0 :         rap_cli_expect_format(call, "W");
     689             : 
     690           0 :         if (DEBUGLEVEL >= 10) {
     691           0 :                 NDR_PRINT_IN_DEBUG(rap_NetPrintJobContinue, r);
     692             :         }
     693             : 
     694           0 :         result = rap_cli_do_call(tree, call);
     695             : 
     696           0 :         if (!NT_STATUS_IS_OK(result))
     697           0 :                 goto done;
     698             : 
     699           0 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
     700           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
     701             : 
     702           0 :         if (DEBUGLEVEL >= 10) {
     703           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobContinue, r);
     704             :         }
     705             : 
     706           0 :  done:
     707           0 :         talloc_free(call);
     708           0 :         return result;
     709             : }
     710             : 
     711           0 : NTSTATUS smbcli_rap_netprintjobdelete(struct smbcli_tree *tree,
     712             :                                       TALLOC_CTX *mem_ctx,
     713             :                                       struct rap_NetPrintJobDelete *r)
     714             : {
     715           0 :         struct rap_call *call;
     716           0 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     717             : 
     718           0 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WPrintJobDel))) {
     719           0 :                 return NT_STATUS_NO_MEMORY;
     720             :         }
     721             : 
     722           0 :         rap_cli_push_word(call, r->in.JobID);
     723             : 
     724           0 :         rap_cli_expect_format(call, "W");
     725             : 
     726           0 :         if (DEBUGLEVEL >= 10) {
     727           0 :                 NDR_PRINT_IN_DEBUG(rap_NetPrintJobDelete, r);
     728             :         }
     729             : 
     730           0 :         result = rap_cli_do_call(tree, call);
     731             : 
     732           0 :         if (!NT_STATUS_IS_OK(result))
     733           0 :                 goto done;
     734             : 
     735           0 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
     736           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
     737             : 
     738           0 :         if (DEBUGLEVEL >= 10) {
     739           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobDelete, r);
     740             :         }
     741             : 
     742           0 :  done:
     743           0 :         talloc_free(call);
     744           0 :         return result;
     745             : }
     746             : 
     747           0 : NTSTATUS smbcli_rap_netprintqueuepause(struct smbcli_tree *tree,
     748             :                                        TALLOC_CTX *mem_ctx,
     749             :                                        struct rap_NetPrintQueuePause *r)
     750             : {
     751           0 :         struct rap_call *call;
     752           0 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     753             : 
     754           0 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WPrintQPause))) {
     755           0 :                 return NT_STATUS_NO_MEMORY;
     756             :         }
     757             : 
     758           0 :         rap_cli_push_string(call, r->in.PrintQueueName);
     759             : 
     760           0 :         rap_cli_expect_format(call, "");
     761             : 
     762           0 :         if (DEBUGLEVEL >= 10) {
     763           0 :                 NDR_PRINT_IN_DEBUG(rap_NetPrintQueuePause, r);
     764             :         }
     765             : 
     766           0 :         result = rap_cli_do_call(tree, call);
     767             : 
     768           0 :         if (!NT_STATUS_IS_OK(result))
     769           0 :                 goto done;
     770             : 
     771           0 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
     772           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
     773             : 
     774           0 :         if (DEBUGLEVEL >= 10) {
     775           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueuePause, r);
     776             :         }
     777             : 
     778           0 :  done:
     779           0 :         talloc_free(call);
     780           0 :         return result;
     781             : }
     782             : 
     783           0 : NTSTATUS smbcli_rap_netprintqueueresume(struct smbcli_tree *tree,
     784             :                                         TALLOC_CTX *mem_ctx,
     785             :                                         struct rap_NetPrintQueueResume *r)
     786             : {
     787           0 :         struct rap_call *call;
     788           0 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     789             : 
     790           0 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WPrintQContinue))) {
     791           0 :                 return NT_STATUS_NO_MEMORY;
     792             :         }
     793             : 
     794           0 :         rap_cli_push_string(call, r->in.PrintQueueName);
     795             : 
     796           0 :         rap_cli_expect_format(call, "");
     797             : 
     798           0 :         if (DEBUGLEVEL >= 10) {
     799           0 :                 NDR_PRINT_IN_DEBUG(rap_NetPrintQueueResume, r);
     800             :         }
     801             : 
     802           0 :         result = rap_cli_do_call(tree, call);
     803             : 
     804           0 :         if (!NT_STATUS_IS_OK(result))
     805           0 :                 goto done;
     806             : 
     807           0 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
     808           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
     809             : 
     810           0 :         if (DEBUGLEVEL >= 10) {
     811           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueueResume, r);
     812             :         }
     813             : 
     814           0 :  done:
     815           0 :         talloc_free(call);
     816           0 :         return result;
     817             : }
     818             : 
     819           0 : NTSTATUS smbcli_rap_netprintqueuepurge(struct smbcli_tree *tree,
     820             :                                        TALLOC_CTX *mem_ctx,
     821             :                                        struct rap_NetPrintQueuePurge *r)
     822             : {
     823           0 :         struct rap_call *call;
     824           0 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     825             : 
     826           0 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WPrintQPurge))) {
     827           0 :                 return NT_STATUS_NO_MEMORY;
     828             :         }
     829             : 
     830           0 :         rap_cli_push_string(call, r->in.PrintQueueName);
     831             : 
     832           0 :         rap_cli_expect_format(call, "");
     833             : 
     834           0 :         if (DEBUGLEVEL >= 10) {
     835           0 :                 NDR_PRINT_IN_DEBUG(rap_NetPrintQueuePurge, r);
     836             :         }
     837             : 
     838           0 :         result = rap_cli_do_call(tree, call);
     839             : 
     840           0 :         if (!NT_STATUS_IS_OK(result))
     841           0 :                 goto done;
     842             : 
     843           0 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
     844           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
     845             : 
     846           0 :         if (DEBUGLEVEL >= 10) {
     847           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueuePurge, r);
     848             :         }
     849             : 
     850           0 :  done:
     851           0 :         talloc_free(call);
     852           0 :         return result;
     853             : }
     854             : 
     855           0 : static enum ndr_err_code ndr_pull_rap_NetPrintJobEnum_data(struct ndr_pull *ndr, struct rap_NetPrintJobEnum *r)
     856             : {
     857           0 :         uint32_t cntr_info_0;
     858           0 :         TALLOC_CTX *_mem_save_info_0;
     859             : 
     860           0 :         NDR_PULL_ALLOC_N(ndr, r->out.info, r->out.count);
     861           0 :         _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
     862           0 :         NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0);
     863           0 :         for (cntr_info_0 = 0; cntr_info_0 < r->out.count; cntr_info_0++) {
     864           0 :                 NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level));
     865           0 :                 NDR_CHECK(ndr_pull_rap_printj_info(ndr, NDR_SCALARS, &r->out.info[cntr_info_0]));
     866             :         }
     867           0 :         for (cntr_info_0 = 0; cntr_info_0 < r->out.count; cntr_info_0++) {
     868           0 :                 NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level));
     869           0 :                 NDR_CHECK(ndr_pull_rap_printj_info(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0]));
     870             :         }
     871           0 :         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0);
     872             : 
     873           0 :         return NDR_ERR_SUCCESS;
     874             : }
     875             : 
     876           0 : NTSTATUS smbcli_rap_netprintjobenum(struct smbcli_tree *tree,
     877             :                                     TALLOC_CTX *mem_ctx,
     878             :                                     struct rap_NetPrintJobEnum *r)
     879             : {
     880           0 :         struct rap_call *call;
     881           0 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     882             : 
     883           0 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WPrintJobEnum))) {
     884           0 :                 return NT_STATUS_NO_MEMORY;
     885             :         }
     886             : 
     887           0 :         rap_cli_push_string(call, r->in.PrintQueueName);
     888           0 :         rap_cli_push_word(call, r->in.level);
     889           0 :         rap_cli_push_rcvbuf(call, r->in.bufsize);
     890           0 :         rap_cli_expect_multiple_entries(call);
     891             : 
     892           0 :         switch(r->in.level) {
     893           0 :         case 0:
     894           0 :                 rap_cli_expect_format(call, "W");
     895           0 :                 break;
     896           0 :         case 1:
     897           0 :                 rap_cli_expect_format(call, "WB21BB16B10zWWzDDz");
     898           0 :                 break;
     899           0 :         case 2:
     900           0 :                 rap_cli_expect_format(call, "WWzWWDDzz");
     901           0 :                 break;
     902           0 :         case 3:
     903           0 :                 rap_cli_expect_format(call, "WWzWWDDzzzzzzzzzzlz");
     904           0 :                 break;
     905           0 :         case 4:
     906           0 :                 rap_cli_expect_format(call, "WWzWWDDzzzzzDDDDDDD");
     907           0 :                 break;
     908           0 :         default:
     909           0 :                 result = NT_STATUS_INVALID_PARAMETER;
     910           0 :                 goto done;
     911             :         }
     912             : 
     913           0 :         if (DEBUGLEVEL >= 10) {
     914           0 :                 NDR_PRINT_IN_DEBUG(rap_NetPrintJobEnum, r);
     915             :         }
     916             : 
     917           0 :         result = rap_cli_do_call(tree, call);
     918             : 
     919           0 :         if (!NT_STATUS_IS_OK(result))
     920           0 :                 goto done;
     921             : 
     922           0 :         result = NT_STATUS_INVALID_PARAMETER;
     923             : 
     924           0 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
     925           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
     926           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.count));
     927           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.available));
     928             : 
     929           0 :         call->ndr_pull_data->relative_rap_convert = r->out.convert;
     930             : 
     931           0 :         NDR_GOTO(ndr_pull_rap_NetPrintJobEnum_data(call->ndr_pull_data, r));
     932             : 
     933           0 :         if (DEBUGLEVEL >= 10) {
     934           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobEnum, r);
     935             :         }
     936             : 
     937           0 :         r->out.info = talloc_steal(mem_ctx, r->out.info);
     938             : 
     939           0 :         result = NT_STATUS_OK;
     940             : 
     941           0 :  done:
     942           0 :         talloc_free(call);
     943           0 :         return result;
     944             : }
     945             : 
     946           0 : NTSTATUS smbcli_rap_netprintjobgetinfo(struct smbcli_tree *tree,
     947             :                                        TALLOC_CTX *mem_ctx,
     948             :                                        struct rap_NetPrintJobGetInfo *r)
     949             : {
     950           0 :         struct rap_call *call;
     951           0 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     952             : 
     953           0 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WPrintJobGetInfo))) {
     954           0 :                 return NT_STATUS_NO_MEMORY;
     955             :         }
     956             : 
     957           0 :         rap_cli_push_word(call, r->in.JobID);
     958           0 :         rap_cli_push_word(call, r->in.level);
     959           0 :         rap_cli_push_rcvbuf(call, r->in.bufsize);
     960           0 :         rap_cli_expect_word(call);
     961             : 
     962           0 :         switch(r->in.level) {
     963           0 :         case 0:
     964           0 :                 rap_cli_expect_format(call, "W");
     965           0 :                 break;
     966           0 :         case 1:
     967           0 :                 rap_cli_expect_format(call, "WB21BB16B10zWWzDDz");
     968           0 :                 break;
     969           0 :         case 2:
     970           0 :                 rap_cli_expect_format(call, "WWzWWDDzz");
     971           0 :                 break;
     972           0 :         case 3:
     973           0 :                 rap_cli_expect_format(call, "WWzWWDDzzzzzzzzzzlz");
     974           0 :                 break;
     975           0 :         case 4:
     976           0 :                 rap_cli_expect_format(call, "WWzWWDDzzzzzDDDDDDD");
     977           0 :                 break;
     978           0 :         default:
     979           0 :                 result = NT_STATUS_INVALID_PARAMETER;
     980           0 :                 goto done;
     981             :         }
     982             : 
     983           0 :         if (DEBUGLEVEL >= 10) {
     984           0 :                 NDR_PRINT_IN_DEBUG(rap_NetPrintJobGetInfo, r);
     985             :         }
     986             : 
     987           0 :         result = rap_cli_do_call(tree, call);
     988             : 
     989           0 :         if (!NT_STATUS_IS_OK(result))
     990           0 :                 goto done;
     991             : 
     992           0 :         result = NT_STATUS_INVALID_PARAMETER;
     993             : 
     994           0 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
     995           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
     996           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.available));
     997             : 
     998           0 :         call->ndr_pull_data->relative_rap_convert = r->out.convert;
     999             : 
    1000           0 :         NDR_GOTO(ndr_pull_set_switch_value(call->ndr_pull_data, &r->out.info, r->in.level));
    1001           0 :         NDR_GOTO(ndr_pull_rap_printj_info(call->ndr_pull_data, NDR_SCALARS|NDR_BUFFERS, &r->out.info));
    1002             : 
    1003           0 :         if (DEBUGLEVEL >= 10) {
    1004           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobGetInfo, r);
    1005             :         }
    1006             : 
    1007           0 :         result = NT_STATUS_OK;
    1008             : 
    1009           0 :  done:
    1010           0 :         talloc_free(call);
    1011           0 :         return result;
    1012             : }
    1013             : 
    1014           0 : NTSTATUS smbcli_rap_netprintjobsetinfo(struct smbcli_tree *tree,
    1015             :                                        TALLOC_CTX *mem_ctx,
    1016             :                                        struct rap_NetPrintJobSetInfo *r)
    1017             : {
    1018           0 :         struct rap_call *call;
    1019           0 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    1020             : 
    1021           0 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WPrintJobSetInfo))) {
    1022           0 :                 return NT_STATUS_NO_MEMORY;
    1023             :         }
    1024             : 
    1025           0 :         rap_cli_push_word(call, r->in.JobID);
    1026           0 :         rap_cli_push_word(call, r->in.level);
    1027           0 :         rap_cli_push_sendbuf(call, r->in.bufsize);
    1028           0 :         rap_cli_push_param(call, r->in.ParamNum);
    1029             : 
    1030           0 :         switch (r->in.ParamNum) {
    1031           0 :         case RAP_PARAM_JOBNUM:
    1032             :         case RAP_PARAM_JOBPOSITION:
    1033             :         case RAP_PARAM_JOBSTATUS:
    1034           0 :                 NDR_GOTO(ndr_push_uint16(call->ndr_push_param, NDR_SCALARS, r->in.Param.value));
    1035           0 :                 break;
    1036           0 :         case RAP_PARAM_USERNAME:
    1037             :         case RAP_PARAM_NOTIFYNAME:
    1038             :         case RAP_PARAM_DATATYPE:
    1039             :         case RAP_PARAM_PARAMETERS_STRING:
    1040             :         case RAP_PARAM_JOBSTATUSSTR:
    1041             :         case RAP_PARAM_JOBCOMMENT:
    1042           0 :                 NDR_GOTO(ndr_push_string(call->ndr_push_param, NDR_SCALARS, r->in.Param.string));
    1043           0 :                 break;
    1044           0 :         case RAP_PARAM_TIMESUBMITTED:
    1045             :         case RAP_PARAM_JOBSIZE:
    1046           0 :                 NDR_GOTO(ndr_push_uint32(call->ndr_push_param, NDR_SCALARS, r->in.Param.value4));
    1047           0 :                 break;
    1048           0 :         default:
    1049           0 :                 result = NT_STATUS_INVALID_PARAMETER;
    1050           0 :                 break;
    1051             :         }
    1052             : 
    1053             :         /* not really sure if this is correct */
    1054           0 :         rap_cli_expect_format(call, "WB21BB16B10zWWzDDz");
    1055             : 
    1056           0 :         if (DEBUGLEVEL >= 10) {
    1057           0 :                 NDR_PRINT_IN_DEBUG(rap_NetPrintJobSetInfo, r);
    1058             :         }
    1059             : 
    1060           0 :         result = rap_cli_do_call(tree, call);
    1061             : 
    1062           0 :         if (!NT_STATUS_IS_OK(result))
    1063           0 :                 goto done;
    1064             : 
    1065           0 :         result = NT_STATUS_INVALID_PARAMETER;
    1066             : 
    1067           0 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
    1068           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
    1069             : 
    1070           0 :         result = NT_STATUS_OK;
    1071             : 
    1072           0 :         if (!NT_STATUS_IS_OK(result)) {
    1073           0 :                 goto done;
    1074             :         }
    1075             : 
    1076           0 :         if (DEBUGLEVEL >= 10) {
    1077           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobSetInfo, r);
    1078             :         }
    1079             : 
    1080           0 :  done:
    1081           0 :         talloc_free(call);
    1082           0 :         return result;
    1083             : }
    1084             : 
    1085           0 : static enum ndr_err_code ndr_pull_rap_NetPrintDestEnum_data(struct ndr_pull *ndr, struct rap_NetPrintDestEnum *r)
    1086             : {
    1087           0 :         uint32_t cntr_info_0;
    1088           0 :         TALLOC_CTX *_mem_save_info_0;
    1089             : 
    1090           0 :         NDR_PULL_ALLOC_N(ndr, r->out.info, r->out.count);
    1091           0 :         _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
    1092           0 :         NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0);
    1093           0 :         for (cntr_info_0 = 0; cntr_info_0 < r->out.count; cntr_info_0++) {
    1094           0 :                 NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level));
    1095           0 :                 NDR_CHECK(ndr_pull_rap_printdest_info(ndr, NDR_SCALARS, &r->out.info[cntr_info_0]));
    1096             :         }
    1097           0 :         for (cntr_info_0 = 0; cntr_info_0 < r->out.count; cntr_info_0++) {
    1098           0 :                 NDR_CHECK(ndr_pull_rap_printdest_info(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0]));
    1099             :         }
    1100           0 :         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0);
    1101             : 
    1102           0 :         return NDR_ERR_SUCCESS;
    1103             : }
    1104             : 
    1105             : 
    1106           0 : NTSTATUS smbcli_rap_netprintdestenum(struct smbcli_tree *tree,
    1107             :                                      TALLOC_CTX *mem_ctx,
    1108             :                                      struct rap_NetPrintDestEnum *r)
    1109             : {
    1110           0 :         struct rap_call *call;
    1111           0 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    1112             : 
    1113           0 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WPrintDestEnum))) {
    1114           0 :                 return NT_STATUS_NO_MEMORY;
    1115             :         }
    1116             : 
    1117           0 :         rap_cli_push_word(call, r->in.level);
    1118           0 :         rap_cli_push_rcvbuf(call, r->in.bufsize);
    1119           0 :         rap_cli_expect_multiple_entries(call);
    1120             : 
    1121           0 :         switch(r->in.level) {
    1122           0 :         case 0:
    1123           0 :                 rap_cli_expect_format(call, "B9");
    1124           0 :                 break;
    1125           0 :         case 1:
    1126           0 :                 rap_cli_expect_format(call, "B9B21WWzW");
    1127           0 :                 break;
    1128           0 :         case 2:
    1129           0 :                 rap_cli_expect_format(call, "z");
    1130           0 :                 break;
    1131           0 :         case 3:
    1132           0 :                 rap_cli_expect_format(call, "zzzWWzzzWW");
    1133           0 :                 break;
    1134           0 :         default:
    1135           0 :                 result = NT_STATUS_INVALID_PARAMETER;
    1136           0 :                 goto done;
    1137             :         }
    1138             : 
    1139           0 :         if (DEBUGLEVEL >= 10) {
    1140           0 :                 NDR_PRINT_IN_DEBUG(rap_NetPrintDestEnum, r);
    1141             :         }
    1142             : 
    1143           0 :         result = rap_cli_do_call(tree, call);
    1144             : 
    1145           0 :         if (!NT_STATUS_IS_OK(result))
    1146           0 :                 goto done;
    1147             : 
    1148           0 :         result = NT_STATUS_INVALID_PARAMETER;
    1149             : 
    1150           0 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
    1151           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
    1152           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.count));
    1153           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.available));
    1154             : 
    1155           0 :         call->ndr_pull_data->relative_rap_convert = r->out.convert;
    1156             : 
    1157           0 :         NDR_GOTO(ndr_pull_rap_NetPrintDestEnum_data(call->ndr_pull_data, r));
    1158             : 
    1159           0 :         r->out.info = talloc_steal(mem_ctx, r->out.info);
    1160             : 
    1161           0 :         if (DEBUGLEVEL >= 10) {
    1162           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetPrintDestEnum, r);
    1163             :         }
    1164             : 
    1165           0 :         result = NT_STATUS_OK;
    1166             : 
    1167           0 :  done:
    1168           0 :         talloc_free(call);
    1169           0 :         return result;
    1170             : }
    1171             : 
    1172           0 : NTSTATUS smbcli_rap_netprintdestgetinfo(struct smbcli_tree *tree,
    1173             :                                         TALLOC_CTX *mem_ctx,
    1174             :                                         struct rap_NetPrintDestGetInfo *r)
    1175             : {
    1176           0 :         struct rap_call *call;
    1177           0 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    1178             : 
    1179           0 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WPrintDestGetInfo))) {
    1180           0 :                 return NT_STATUS_NO_MEMORY;
    1181             :         }
    1182             : 
    1183           0 :         rap_cli_push_string(call, r->in.PrintDestName);
    1184           0 :         rap_cli_push_word(call, r->in.level);
    1185           0 :         rap_cli_push_rcvbuf(call, r->in.bufsize);
    1186           0 :         rap_cli_expect_word(call);
    1187             : 
    1188           0 :         switch(r->in.level) {
    1189           0 :         case 0:
    1190           0 :                 rap_cli_expect_format(call, "B9");
    1191           0 :                 break;
    1192           0 :         case 1:
    1193           0 :                 rap_cli_expect_format(call, "B9B21WWzW");
    1194           0 :                 break;
    1195           0 :         case 2:
    1196           0 :                 rap_cli_expect_format(call, "z");
    1197           0 :                 break;
    1198           0 :         case 3:
    1199           0 :                 rap_cli_expect_format(call, "zzzWWzzzWW");
    1200           0 :                 break;
    1201           0 :         default:
    1202           0 :                 result = NT_STATUS_INVALID_PARAMETER;
    1203           0 :                 goto done;
    1204             :         }
    1205             : 
    1206           0 :         if (DEBUGLEVEL >= 10) {
    1207           0 :                 NDR_PRINT_IN_DEBUG(rap_NetPrintDestGetInfo, r);
    1208             :         }
    1209             : 
    1210           0 :         result = rap_cli_do_call(tree, call);
    1211             : 
    1212           0 :         if (!NT_STATUS_IS_OK(result))
    1213           0 :                 goto done;
    1214             : 
    1215           0 :         result = NT_STATUS_INVALID_PARAMETER;
    1216             : 
    1217           0 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
    1218           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
    1219           0 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.available));
    1220             : 
    1221           0 :         call->ndr_pull_data->relative_rap_convert = r->out.convert;
    1222             : 
    1223           0 :         NDR_GOTO(ndr_pull_set_switch_value(call->ndr_pull_data, &r->out.info, r->in.level));
    1224           0 :         NDR_GOTO(ndr_pull_rap_printdest_info(call->ndr_pull_data, NDR_SCALARS|NDR_BUFFERS, &r->out.info));
    1225             : 
    1226           0 :         if (DEBUGLEVEL >= 10) {
    1227           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetPrintDestGetInfo, r);
    1228             :         }
    1229             : 
    1230           0 :         result = NT_STATUS_OK;
    1231             : 
    1232           0 :  done:
    1233           0 :         talloc_free(call);
    1234           0 :         return result;
    1235             : }
    1236             : 
    1237           8 : NTSTATUS smbcli_rap_netuserpasswordset2(struct smbcli_tree *tree,
    1238             :                                         TALLOC_CTX *mem_ctx,
    1239             :                                         struct rap_NetUserPasswordSet2 *r)
    1240             : {
    1241           0 :         struct rap_call *call;
    1242           8 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    1243             : 
    1244           8 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WUserPasswordSet2))) {
    1245           0 :                 return NT_STATUS_NO_MEMORY;
    1246             :         }
    1247             : 
    1248           8 :         rap_cli_push_string(call, r->in.UserName);
    1249           8 :         rap_cli_push_paramdesc(call, 'b');
    1250           8 :         rap_cli_push_paramdesc(call, '1');
    1251           8 :         rap_cli_push_paramdesc(call, '6');
    1252           8 :         ndr_push_array_uint8(call->ndr_push_param, NDR_SCALARS, r->in.OldPassword, 16);
    1253           8 :         rap_cli_push_paramdesc(call, 'b');
    1254           8 :         rap_cli_push_paramdesc(call, '1');
    1255           8 :         rap_cli_push_paramdesc(call, '6');
    1256           8 :         ndr_push_array_uint8(call->ndr_push_param, NDR_SCALARS, r->in.NewPassword, 16);
    1257           8 :         rap_cli_push_word(call, r->in.EncryptedPassword);
    1258           8 :         rap_cli_push_word(call, r->in.RealPasswordLength);
    1259             : 
    1260           8 :         rap_cli_expect_format(call, "");
    1261             : 
    1262           8 :         if (DEBUGLEVEL >= 10) {
    1263           0 :                 NDR_PRINT_IN_DEBUG(rap_NetUserPasswordSet2, r);
    1264             :         }
    1265             : 
    1266           8 :         result = rap_cli_do_call(tree, call);
    1267             : 
    1268           8 :         if (!NT_STATUS_IS_OK(result))
    1269           0 :                 goto done;
    1270             : 
    1271           8 :         result = NT_STATUS_INVALID_PARAMETER;
    1272             : 
    1273           8 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
    1274           8 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
    1275             : 
    1276           8 :         result = NT_STATUS_OK;
    1277             : 
    1278           8 :         if (!NT_STATUS_IS_OK(result)) {
    1279           0 :                 goto done;
    1280             :         }
    1281             : 
    1282           8 :         if (DEBUGLEVEL >= 10) {
    1283           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetUserPasswordSet2, r);
    1284             :         }
    1285             : 
    1286           8 :  done:
    1287           8 :         talloc_free(call);
    1288           8 :         return result;
    1289             : }
    1290             : 
    1291           4 : NTSTATUS smbcli_rap_netoemchangepassword(struct smbcli_tree *tree,
    1292             :                                          TALLOC_CTX *mem_ctx,
    1293             :                                          struct rap_NetOEMChangePassword *r)
    1294             : {
    1295           0 :         struct rap_call *call;
    1296           4 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    1297             : 
    1298           4 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_SamOEMChgPasswordUser2_P))) {
    1299           0 :                 return NT_STATUS_NO_MEMORY;
    1300             :         }
    1301             : 
    1302           4 :         rap_cli_push_string(call, r->in.UserName);
    1303           4 :         rap_cli_push_sendbuf(call, 532);
    1304           4 :         ndr_push_array_uint8(call->ndr_push_data, NDR_SCALARS, r->in.crypt_password, 516);
    1305           4 :         ndr_push_array_uint8(call->ndr_push_data, NDR_SCALARS, r->in.password_hash, 16);
    1306             : 
    1307           4 :         rap_cli_expect_format(call, "B516B16");
    1308             : 
    1309           4 :         if (DEBUGLEVEL >= 10) {
    1310           0 :                 NDR_PRINT_IN_DEBUG(rap_NetOEMChangePassword, r);
    1311             :         }
    1312             : 
    1313           4 :         result = rap_cli_do_call(tree, call);
    1314             : 
    1315           4 :         if (!NT_STATUS_IS_OK(result))
    1316           0 :                 goto done;
    1317             : 
    1318           4 :         result = NT_STATUS_INVALID_PARAMETER;
    1319             : 
    1320           4 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
    1321           4 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
    1322             : 
    1323           4 :         result = NT_STATUS_OK;
    1324             : 
    1325           4 :         if (!NT_STATUS_IS_OK(result)) {
    1326           0 :                 goto done;
    1327             :         }
    1328             : 
    1329           4 :         if (DEBUGLEVEL >= 10) {
    1330           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetOEMChangePassword, r);
    1331             :         }
    1332             : 
    1333           4 :  done:
    1334           4 :         talloc_free(call);
    1335           4 :         return result;
    1336             : }
    1337             : 
    1338          20 : NTSTATUS smbcli_rap_netusergetinfo(struct smbcli_tree *tree,
    1339             :                                    TALLOC_CTX *mem_ctx,
    1340             :                                    struct rap_NetUserGetInfo *r)
    1341             : {
    1342           0 :         struct rap_call *call;
    1343          20 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    1344             : 
    1345          20 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WUserGetInfo))) {
    1346           0 :                 return NT_STATUS_NO_MEMORY;
    1347             :         }
    1348             : 
    1349          20 :         rap_cli_push_string(call, r->in.UserName);
    1350          20 :         rap_cli_push_word(call, r->in.level);
    1351          20 :         rap_cli_push_rcvbuf(call, r->in.bufsize);
    1352          20 :         rap_cli_expect_word(call);
    1353             : 
    1354          20 :         switch(r->in.level) {
    1355           4 :         case 0:
    1356           4 :                 rap_cli_expect_format(call, "B21");
    1357           4 :                 break;
    1358           4 :         case 1:
    1359           4 :                 rap_cli_expect_format(call, "B21BB16DWzzWz");
    1360           4 :                 break;
    1361           4 :         case 2:
    1362           4 :                 rap_cli_expect_format(call, "B21BB16DWzzWzDzzzzDDDDWb21WWzWW");
    1363           4 :                 break;
    1364           4 :         case 10:
    1365           4 :                 rap_cli_expect_format(call, "B21Bzzz");
    1366           4 :                 break;
    1367           4 :         case 11:
    1368           4 :                 rap_cli_expect_format(call, "B21BzzzWDDzzDDWWzWzDWb21W");
    1369           4 :                 break;
    1370           0 :         default:
    1371           0 :                 result = NT_STATUS_INVALID_PARAMETER;
    1372           0 :                 goto done;
    1373             :         }
    1374             : 
    1375          20 :         if (DEBUGLEVEL >= 10) {
    1376           0 :                 NDR_PRINT_IN_DEBUG(rap_NetUserGetInfo, r);
    1377             :         }
    1378             : 
    1379          20 :         result = rap_cli_do_call(tree, call);
    1380             : 
    1381          20 :         if (!NT_STATUS_IS_OK(result))
    1382           0 :                 goto done;
    1383             : 
    1384          20 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
    1385          20 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
    1386          20 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.available));
    1387             : 
    1388          20 :         call->ndr_pull_data->relative_rap_convert = r->out.convert;
    1389             : 
    1390          20 :         NDR_GOTO(ndr_pull_set_switch_value(call->ndr_pull_data, &r->out.info, r->in.level));
    1391          20 :         NDR_GOTO(ndr_pull_rap_netuser_info(call->ndr_pull_data, NDR_SCALARS|NDR_BUFFERS, &r->out.info));
    1392             : 
    1393          20 :         if (DEBUGLEVEL >= 10) {
    1394           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetUserGetInfo, r);
    1395             :         }
    1396             : 
    1397          20 :         result = NT_STATUS_OK;
    1398             : 
    1399          20 :  done:
    1400          20 :         talloc_free(call);
    1401          20 :         return result;
    1402             : }
    1403             : 
    1404             : 
    1405           8 : static enum ndr_err_code ndr_pull_rap_NetSessionEnum_data(struct ndr_pull *ndr, struct rap_NetSessionEnum *r)
    1406             : {
    1407           0 :         uint32_t cntr_info_0;
    1408           0 :         TALLOC_CTX *_mem_save_info_0;
    1409             : 
    1410           8 :         NDR_PULL_ALLOC_N(ndr, r->out.info, r->out.count);
    1411           8 :         _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
    1412           8 :         NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0);
    1413          12 :         for (cntr_info_0 = 0; cntr_info_0 < r->out.count; cntr_info_0++) {
    1414           4 :                 NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level));
    1415           4 :                 NDR_CHECK(ndr_pull_rap_session_info(ndr, NDR_SCALARS, &r->out.info[cntr_info_0]));
    1416             :         }
    1417          12 :         for (cntr_info_0 = 0; cntr_info_0 < r->out.count; cntr_info_0++) {
    1418           4 :                 NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level));
    1419           4 :                 NDR_CHECK(ndr_pull_rap_session_info(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0]));
    1420             :         }
    1421           8 :         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0);
    1422             : 
    1423           8 :         return NDR_ERR_SUCCESS;
    1424             : }
    1425             : 
    1426             : 
    1427           8 : NTSTATUS smbcli_rap_netsessionenum(struct smbcli_tree *tree,
    1428             :                                    TALLOC_CTX *mem_ctx,
    1429             :                                    struct rap_NetSessionEnum *r)
    1430             : {
    1431           0 :         struct rap_call *call;
    1432           8 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    1433             : 
    1434           8 :         call = new_rap_cli_call(tree, RAP_WsessionEnum);
    1435             : 
    1436           8 :         if (call == NULL)
    1437           0 :                 return NT_STATUS_NO_MEMORY;
    1438             : 
    1439           8 :         rap_cli_push_word(call, r->in.level);
    1440           8 :         rap_cli_push_rcvbuf(call, r->in.bufsize);
    1441           8 :         rap_cli_expect_multiple_entries(call);
    1442             : 
    1443           8 :         switch(r->in.level) {
    1444           8 :         case 2:
    1445           8 :                 rap_cli_expect_format(call, "zzWWWDDDz");
    1446           8 :                 break;
    1447           0 :         default:
    1448           0 :                 result = NT_STATUS_INVALID_PARAMETER;
    1449           0 :                 goto done;
    1450             :         }
    1451             : 
    1452           8 :         if (DEBUGLEVEL >= 10) {
    1453           0 :                 NDR_PRINT_IN_DEBUG(rap_NetSessionEnum, r);
    1454             :         }
    1455             : 
    1456           8 :         result = rap_cli_do_call(tree, call);
    1457             : 
    1458           8 :         if (!NT_STATUS_IS_OK(result))
    1459           0 :                 goto done;
    1460             : 
    1461           8 :         result = NT_STATUS_INVALID_PARAMETER;
    1462             : 
    1463           8 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
    1464           8 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
    1465           8 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.count));
    1466           8 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.available));
    1467             : 
    1468           8 :         call->ndr_pull_data->relative_rap_convert = r->out.convert;
    1469             : 
    1470           8 :         NDR_GOTO(ndr_pull_rap_NetSessionEnum_data(call->ndr_pull_data, r));
    1471             : 
    1472           8 :         r->out.info = talloc_steal(mem_ctx, r->out.info);
    1473             : 
    1474           8 :         if (DEBUGLEVEL >= 10) {
    1475           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetSessionEnum, r);
    1476             :         }
    1477             : 
    1478           8 :         result = NT_STATUS_OK;
    1479             : 
    1480           8 :  done:
    1481           8 :         talloc_free(call);
    1482           8 :         return result;
    1483             : }
    1484             : 
    1485           2 : NTSTATUS smbcli_rap_netsessiongetinfo(struct smbcli_tree *tree,
    1486             :                                       TALLOC_CTX *mem_ctx,
    1487             :                                       struct rap_NetSessionGetInfo *r)
    1488             : {
    1489           0 :         struct rap_call *call;
    1490           2 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    1491             : 
    1492           2 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WsessionGetInfo))) {
    1493           0 :                 return NT_STATUS_NO_MEMORY;
    1494             :         }
    1495             : 
    1496           2 :         rap_cli_push_string(call, r->in.SessionName);
    1497           2 :         rap_cli_push_word(call, r->in.level);
    1498           2 :         rap_cli_push_rcvbuf(call, r->in.bufsize);
    1499           2 :         rap_cli_expect_word(call);
    1500             : 
    1501           2 :         switch(r->in.level) {
    1502           2 :         case 2:
    1503           2 :                 rap_cli_expect_format(call, "zzWWWDDDz");
    1504           2 :                 break;
    1505           0 :         default:
    1506           0 :                 result = NT_STATUS_INVALID_PARAMETER;
    1507           0 :                 break;
    1508             :         }
    1509             : 
    1510           2 :         if (DEBUGLEVEL >= 10) {
    1511           0 :                 NDR_PRINT_IN_DEBUG(rap_NetSessionGetInfo, r);
    1512             :         }
    1513             : 
    1514           2 :         result = rap_cli_do_call(tree, call);
    1515             : 
    1516           2 :         if (!NT_STATUS_IS_OK(result))
    1517           0 :                 goto done;
    1518             : 
    1519           2 :         result = NT_STATUS_INVALID_PARAMETER;
    1520             : 
    1521           2 :         ZERO_STRUCT(r->out);
    1522             : 
    1523           2 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
    1524           2 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
    1525           2 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.available));
    1526             : 
    1527           0 :         if (r->out.status == 0 && r->out.available) {
    1528           0 :                 call->ndr_pull_data->relative_rap_convert = r->out.convert;
    1529             : 
    1530           0 :                 NDR_GOTO(ndr_pull_set_switch_value(call->ndr_pull_data, &r->out.info, r->in.level));
    1531           0 :                 NDR_GOTO(ndr_pull_rap_session_info(call->ndr_pull_data, NDR_SCALARS|NDR_BUFFERS, &r->out.info));
    1532             :         }
    1533             : 
    1534           0 :         if (DEBUGLEVEL >= 10) {
    1535           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetSessionGetInfo, r);
    1536             :         }
    1537             : 
    1538           0 :         result = NT_STATUS_OK;
    1539           2 :  done:
    1540           2 :         talloc_free(call);
    1541           2 :         return result;
    1542             : }
    1543             : 
    1544             : 
    1545           8 : NTSTATUS smbcli_rap_netuseradd(struct smbcli_tree *tree,
    1546             :                                TALLOC_CTX *mem_ctx,
    1547             :                                struct rap_NetUserAdd *r)
    1548             : {
    1549           0 :         struct rap_call *call;
    1550           8 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    1551             : 
    1552           8 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WUserAdd2))) {
    1553           0 :                 return NT_STATUS_NO_MEMORY;
    1554             :         }
    1555             : 
    1556           8 :         rap_cli_push_word(call, r->in.level);
    1557           8 :         rap_cli_push_sendbuf(call, r->in.bufsize);
    1558           8 :         rap_cli_push_word(call, r->in.pwdlength);
    1559           8 :         rap_cli_push_word(call, r->in.unknown);
    1560             : 
    1561           8 :         switch (r->in.level) {
    1562           8 :         case 1:
    1563           8 :                 rap_cli_expect_format(call, "B21BB16DWzzWz");
    1564           8 :                 break;
    1565           0 :         default:
    1566           0 :                 result = NT_STATUS_INVALID_PARAMETER;
    1567           0 :                 break;
    1568             :         }
    1569             : 
    1570           8 :         if (DEBUGLEVEL >= 10) {
    1571           0 :                 NDR_PRINT_IN_DEBUG(rap_NetUserAdd, r);
    1572             :         }
    1573             : 
    1574           8 :         NDR_GOTO(ndr_push_set_switch_value(call->ndr_push_data, &r->in.info, r->in.level));
    1575           8 :         NDR_GOTO(ndr_push_rap_netuser_info(call->ndr_push_data, NDR_SCALARS|NDR_BUFFERS, &r->in.info));
    1576             : 
    1577           8 :         result = rap_cli_do_call(tree, call);
    1578             : 
    1579           8 :         if (!NT_STATUS_IS_OK(result))
    1580           0 :                 goto done;
    1581             : 
    1582           8 :         result = NT_STATUS_INVALID_PARAMETER;
    1583             : 
    1584           8 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
    1585           8 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
    1586             : 
    1587           8 :         result = NT_STATUS_OK;
    1588             : 
    1589           8 :         if (!NT_STATUS_IS_OK(result)) {
    1590           0 :                 goto done;
    1591             :         }
    1592             : 
    1593           8 :         if (DEBUGLEVEL >= 10) {
    1594           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetUserAdd, r);
    1595             :         }
    1596             : 
    1597           8 :  done:
    1598           8 :         talloc_free(call);
    1599           8 :         return result;
    1600             : }
    1601             : 
    1602           4 : NTSTATUS smbcli_rap_netuserdelete(struct smbcli_tree *tree,
    1603             :                                   TALLOC_CTX *mem_ctx,
    1604             :                                   struct rap_NetUserDelete *r)
    1605             : {
    1606           0 :         struct rap_call *call;
    1607           4 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    1608             : 
    1609           4 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_WUserDel))) {
    1610           0 :                 return NT_STATUS_NO_MEMORY;
    1611             :         }
    1612             : 
    1613           4 :         rap_cli_push_string(call, r->in.UserName);
    1614             : 
    1615           4 :         rap_cli_expect_format(call, "");
    1616           4 :         rap_cli_expect_extra_format(call, "");
    1617             : 
    1618           4 :         if (DEBUGLEVEL >= 10) {
    1619           0 :                 NDR_PRINT_IN_DEBUG(rap_NetUserDelete, r);
    1620             :         }
    1621             : 
    1622           4 :         result = rap_cli_do_call(tree, call);
    1623             : 
    1624           4 :         if (!NT_STATUS_IS_OK(result))
    1625           0 :                 goto done;
    1626             : 
    1627           4 :         result = NT_STATUS_INVALID_PARAMETER;
    1628             : 
    1629           4 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
    1630           4 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
    1631             : 
    1632           4 :         result = NT_STATUS_OK;
    1633             : 
    1634           4 :         if (!NT_STATUS_IS_OK(result)) {
    1635           0 :                 goto done;
    1636             :         }
    1637             : 
    1638           4 :         if (DEBUGLEVEL >= 10) {
    1639           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetUserDelete, r);
    1640             :         }
    1641             : 
    1642           4 :  done:
    1643           4 :         talloc_free(call);
    1644           4 :         return result;
    1645             : }
    1646             : 
    1647           4 : NTSTATUS smbcli_rap_netremotetod(struct smbcli_tree *tree,
    1648             :                                   TALLOC_CTX *mem_ctx,
    1649             :                                   struct rap_NetRemoteTOD *r)
    1650             : {
    1651           0 :         struct rap_call *call;
    1652           4 :         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    1653             : 
    1654           4 :         if (!(call = new_rap_cli_call(mem_ctx, RAP_NetRemoteTOD))) {
    1655           0 :                 return NT_STATUS_NO_MEMORY;
    1656             :         }
    1657             : 
    1658           4 :         rap_cli_push_rcvbuf(call, r->in.bufsize);
    1659             : 
    1660           4 :         rap_cli_expect_format(call, "DDBBBBWWBBWB");
    1661           4 :         rap_cli_expect_extra_format(call, "");
    1662             : 
    1663           4 :         if (DEBUGLEVEL >= 10) {
    1664           0 :                 NDR_PRINT_IN_DEBUG(rap_NetRemoteTOD, r);
    1665             :         }
    1666             : 
    1667           4 :         result = rap_cli_do_call(tree, call);
    1668             : 
    1669           4 :         if (!NT_STATUS_IS_OK(result))
    1670           0 :                 goto done;
    1671             : 
    1672           4 :         result = NT_STATUS_INVALID_PARAMETER;
    1673             : 
    1674           4 :         NDR_GOTO(ndr_pull_rap_status(call->ndr_pull_param, NDR_SCALARS, &r->out.status));
    1675           4 :         NDR_GOTO(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &r->out.convert));
    1676             : 
    1677           4 :         NDR_GOTO(ndr_pull_rap_TimeOfDayInfo(call->ndr_pull_data, NDR_SCALARS|NDR_BUFFERS, &r->out.tod));
    1678             : 
    1679           4 :         result = NT_STATUS_OK;
    1680             : 
    1681           4 :         if (!NT_STATUS_IS_OK(result)) {
    1682           0 :                 goto done;
    1683             :         }
    1684             : 
    1685           4 :         if (DEBUGLEVEL >= 10) {
    1686           0 :                 NDR_PRINT_OUT_DEBUG(rap_NetRemoteTOD, r);
    1687             :         }
    1688             : 
    1689           4 :  done:
    1690           4 :         talloc_free(call);
    1691           4 :         return result;
    1692             : }

Generated by: LCOV version 1.14