r5555: current with 3.0 tree as of r5548; getting ready for 3.0.12pre1
[Samba.git] / source / rpc_client / cli_wkssvc.c
blobaea474439887d78190271fe8cc73771509568b82
1 /*
2 Unix SMB/CIFS implementation.
3 NT Domain Authentication SMB / MSRPC client
4 Copyright (C) Andrew Tridgell 1994-2000
5 Copyright (C) Luke Kenneth Casson Leighton 1996-2000
6 Copyright (C) Tim Potter 2001
7 Copytight (C) Rafal Szczesniak 2002
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "includes.h"
26 /**
27 * WksQueryInfo rpc call (like query for server's capabilities)
29 * @param initialised client structure with \PIPE\wkssvc opened
30 * @param mem_ctx memory context assigned to this rpc binding
31 * @param wks100 WksQueryInfo structure
33 * @return NTSTATUS of rpc call
36 NTSTATUS cli_wks_query_info(struct cli_state *cli, TALLOC_CTX *mem_ctx,
37 WKS_INFO_100 *wks100)
39 prs_struct buf;
40 prs_struct rbuf;
41 WKS_Q_QUERY_INFO q_o;
42 WKS_R_QUERY_INFO r_o;
44 if (cli == NULL || wks100 == NULL)
45 return NT_STATUS_UNSUCCESSFUL;
47 /* init rpc parse structures */
48 prs_init(&buf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
49 prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
51 DEBUG(4, ("WksQueryInfo\n"));
53 /* init query structure with rpc call arguments */
54 init_wks_q_query_info(&q_o, cli->desthost, 100);
56 /* marshall data */
57 if (!wks_io_q_query_info("", &q_o, &buf, 0)) {
58 prs_mem_free(&buf);
59 prs_mem_free(&rbuf);
60 return NT_STATUS_UNSUCCESSFUL;
63 /* actual rpc call over \PIPE\wkssvc */
64 if (!rpc_api_pipe_req(cli, PI_WKSSVC, WKS_QUERY_INFO, &buf, &rbuf)) {
65 prs_mem_free(&buf);
66 prs_mem_free(&rbuf);
67 return NT_STATUS_UNSUCCESSFUL;
70 prs_mem_free(&buf);
72 r_o.wks100 = wks100;
74 /* get call results from response buffer */
75 if (!wks_io_r_query_info("", &r_o, &rbuf, 0)) {
76 prs_mem_free(&rbuf);
77 return NT_STATUS_UNSUCCESSFUL;
80 /* check returnet status code */
81 if (NT_STATUS_IS_ERR(r_o.status)) {
82 /* report the error */
83 DEBUG(0,("WKS_R_QUERY_INFO: %s\n", nt_errstr(r_o.status)));
84 prs_mem_free(&rbuf);
85 return r_o.status;
88 /* do clean up */
89 prs_mem_free(&rbuf);
91 return NT_STATUS_OK;