| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | RPC pipe client
|
|---|
| 4 |
|
|---|
| 5 | Copyright (C) Gerald Carter 2001-2002,
|
|---|
| 6 | Copyright (C) Tim Potter 2000-2002,
|
|---|
| 7 | Copyright (C) Andrew Tridgell 1994-2000,
|
|---|
| 8 | Copyright (C) Jean-Francois Micouleau 1999-2000.
|
|---|
| 9 | Copyright (C) Jeremy Allison 2005.
|
|---|
| 10 |
|
|---|
| 11 | This program is free software; you can redistribute it and/or modify
|
|---|
| 12 | it under the terms of the GNU General Public License as published by
|
|---|
| 13 | the Free Software Foundation; either version 3 of the License, or
|
|---|
| 14 | (at your option) any later version.
|
|---|
| 15 |
|
|---|
| 16 | This program is distributed in the hope that it will be useful,
|
|---|
| 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 19 | GNU General Public License for more details.
|
|---|
| 20 |
|
|---|
| 21 | You should have received a copy of the GNU General Public License
|
|---|
| 22 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 23 | */
|
|---|
| 24 |
|
|---|
| 25 | #include "includes.h"
|
|---|
| 26 |
|
|---|
| 27 | /*
|
|---|
| 28 | * SPOOLSS Client RPC's used by servers as the notification
|
|---|
| 29 | * back channel.
|
|---|
| 30 | */
|
|---|
| 31 |
|
|---|
| 32 | /* Send a ReplyOpenPrinter request. This rpc is made by the printer
|
|---|
| 33 | server to the printer client in response to a rffpcnex request.
|
|---|
| 34 | The rrfpcnex request names a printer and a handle (the printerlocal
|
|---|
| 35 | value) and this rpc establishes a back-channel over which printer
|
|---|
| 36 | notifications are performed. */
|
|---|
| 37 |
|
|---|
| 38 | WERROR rpccli_spoolss_reply_open_printer(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 39 | const char *printer, uint32 printerlocal, uint32 type,
|
|---|
| 40 | POLICY_HND *handle)
|
|---|
| 41 | {
|
|---|
| 42 | prs_struct qbuf, rbuf;
|
|---|
| 43 | SPOOL_Q_REPLYOPENPRINTER q;
|
|---|
| 44 | SPOOL_R_REPLYOPENPRINTER r;
|
|---|
| 45 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 46 |
|
|---|
| 47 | /* Initialise input parameters */
|
|---|
| 48 |
|
|---|
| 49 | make_spoolss_q_replyopenprinter(&q, printer, printerlocal, type);
|
|---|
| 50 |
|
|---|
| 51 | /* Marshall data and send request */
|
|---|
| 52 |
|
|---|
| 53 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_REPLYOPENPRINTER,
|
|---|
| 54 | q, r,
|
|---|
| 55 | qbuf, rbuf,
|
|---|
| 56 | spoolss_io_q_replyopenprinter,
|
|---|
| 57 | spoolss_io_r_replyopenprinter,
|
|---|
| 58 | WERR_GENERAL_FAILURE );
|
|---|
| 59 |
|
|---|
| 60 | /* Return result */
|
|---|
| 61 |
|
|---|
| 62 | memcpy(handle, &r.handle, sizeof(r.handle));
|
|---|
| 63 | result = r.status;
|
|---|
| 64 |
|
|---|
| 65 | return result;
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | /* Close a back-channel notification connection */
|
|---|
| 69 |
|
|---|
| 70 | WERROR rpccli_spoolss_reply_close_printer(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 71 | POLICY_HND *handle)
|
|---|
| 72 | {
|
|---|
| 73 | prs_struct qbuf, rbuf;
|
|---|
| 74 | SPOOL_Q_REPLYCLOSEPRINTER q;
|
|---|
| 75 | SPOOL_R_REPLYCLOSEPRINTER r;
|
|---|
| 76 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 77 |
|
|---|
| 78 | /* Initialise input parameters */
|
|---|
| 79 |
|
|---|
| 80 | make_spoolss_q_reply_closeprinter(&q, handle);
|
|---|
| 81 |
|
|---|
| 82 | /* Marshall data and send request */
|
|---|
| 83 |
|
|---|
| 84 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_REPLYCLOSEPRINTER,
|
|---|
| 85 | q, r,
|
|---|
| 86 | qbuf, rbuf,
|
|---|
| 87 | spoolss_io_q_replycloseprinter,
|
|---|
| 88 | spoolss_io_r_replycloseprinter,
|
|---|
| 89 | WERR_GENERAL_FAILURE );
|
|---|
| 90 |
|
|---|
| 91 | /* Return result */
|
|---|
| 92 |
|
|---|
| 93 | result = r.status;
|
|---|
| 94 | return result;
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | /*********************************************************************
|
|---|
| 98 | This SPOOLSS_ROUTERREPLYPRINTER function is used to send a change
|
|---|
| 99 | notification event when the registration **did not** use
|
|---|
| 100 | SPOOL_NOTIFY_OPTION_TYPE structure to specify the events to monitor.
|
|---|
| 101 | Also see cli_spolss_reply_rrpcn()
|
|---|
| 102 | *********************************************************************/
|
|---|
| 103 |
|
|---|
| 104 | WERROR rpccli_spoolss_routerreplyprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 105 | POLICY_HND *pol, uint32 condition, uint32 change_id)
|
|---|
| 106 | {
|
|---|
| 107 | prs_struct qbuf, rbuf;
|
|---|
| 108 | SPOOL_Q_ROUTERREPLYPRINTER q;
|
|---|
| 109 | SPOOL_R_ROUTERREPLYPRINTER r;
|
|---|
| 110 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 111 |
|
|---|
| 112 | /* Initialise input parameters */
|
|---|
| 113 |
|
|---|
| 114 | make_spoolss_q_routerreplyprinter(&q, pol, condition, change_id);
|
|---|
| 115 |
|
|---|
| 116 | /* Marshall data and send request */
|
|---|
| 117 |
|
|---|
| 118 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ROUTERREPLYPRINTER,
|
|---|
| 119 | q, r,
|
|---|
| 120 | qbuf, rbuf,
|
|---|
| 121 | spoolss_io_q_routerreplyprinter,
|
|---|
| 122 | spoolss_io_r_routerreplyprinter,
|
|---|
| 123 | WERR_GENERAL_FAILURE );
|
|---|
| 124 |
|
|---|
| 125 | /* Return output parameters */
|
|---|
| 126 |
|
|---|
| 127 | result = r.status;
|
|---|
| 128 | return result;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | /*********************************************************************
|
|---|
| 132 | This SPOOLSS_REPLY_RRPCN function is used to send a change
|
|---|
| 133 | notification event when the registration **did** use
|
|---|
| 134 | SPOOL_NOTIFY_OPTION_TYPE structure to specify the events to monitor
|
|---|
| 135 | Also see cli_spoolss_routereplyprinter()
|
|---|
| 136 | *********************************************************************/
|
|---|
| 137 |
|
|---|
| 138 | WERROR rpccli_spoolss_rrpcn(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 139 | POLICY_HND *pol, uint32 notify_data_len,
|
|---|
| 140 | SPOOL_NOTIFY_INFO_DATA *notify_data,
|
|---|
| 141 | uint32 change_low, uint32 change_high)
|
|---|
| 142 | {
|
|---|
| 143 | prs_struct qbuf, rbuf;
|
|---|
| 144 | SPOOL_Q_REPLY_RRPCN q;
|
|---|
| 145 | SPOOL_R_REPLY_RRPCN r;
|
|---|
| 146 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 147 | SPOOL_NOTIFY_INFO notify_info;
|
|---|
| 148 |
|
|---|
| 149 | ZERO_STRUCT(q);
|
|---|
| 150 | ZERO_STRUCT(r);
|
|---|
| 151 |
|
|---|
| 152 | ZERO_STRUCT(notify_info);
|
|---|
| 153 |
|
|---|
| 154 | /* Initialise input parameters */
|
|---|
| 155 |
|
|---|
| 156 | notify_info.version = 0x2;
|
|---|
| 157 | notify_info.flags = 0x00020000; /* ?? */
|
|---|
| 158 | notify_info.count = notify_data_len;
|
|---|
| 159 | notify_info.data = notify_data;
|
|---|
| 160 |
|
|---|
| 161 | /* create and send a MSRPC command with api */
|
|---|
| 162 | /* store the parameters */
|
|---|
| 163 |
|
|---|
| 164 | make_spoolss_q_reply_rrpcn(&q, pol, change_low, change_high,
|
|---|
| 165 | ¬ify_info);
|
|---|
| 166 |
|
|---|
| 167 | /* Marshall data and send request */
|
|---|
| 168 |
|
|---|
| 169 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_RRPCN,
|
|---|
| 170 | q, r,
|
|---|
| 171 | qbuf, rbuf,
|
|---|
| 172 | spoolss_io_q_reply_rrpcn,
|
|---|
| 173 | spoolss_io_r_reply_rrpcn,
|
|---|
| 174 | WERR_GENERAL_FAILURE );
|
|---|
| 175 |
|
|---|
| 176 | if (r.unknown0 == 0x00080000)
|
|---|
| 177 | DEBUG(8,("cli_spoolss_reply_rrpcn: I think the spooler resonded that the notification was ignored.\n"));
|
|---|
| 178 | else if ( r.unknown0 != 0x0 )
|
|---|
| 179 | DEBUG(8,("cli_spoolss_reply_rrpcn: unknown0 is non-zero [0x%x]\n", r.unknown0));
|
|---|
| 180 |
|
|---|
| 181 | result = r.status;
|
|---|
| 182 | return result;
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | /*********************************************************************
|
|---|
| 186 | *********************************************************************/
|
|---|
| 187 |
|
|---|
| 188 | WERROR rpccli_spoolss_rffpcnex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|---|
| 189 | POLICY_HND *pol, uint32 flags, uint32 options,
|
|---|
| 190 | const char *localmachine, uint32 printerlocal,
|
|---|
| 191 | SPOOL_NOTIFY_OPTION *option)
|
|---|
| 192 | {
|
|---|
| 193 | prs_struct qbuf, rbuf;
|
|---|
| 194 | SPOOL_Q_RFFPCNEX q;
|
|---|
| 195 | SPOOL_R_RFFPCNEX r;
|
|---|
| 196 | WERROR result = W_ERROR(ERRgeneral);
|
|---|
| 197 |
|
|---|
| 198 | ZERO_STRUCT(q);
|
|---|
| 199 | ZERO_STRUCT(r);
|
|---|
| 200 |
|
|---|
| 201 | /* Initialise input parameters */
|
|---|
| 202 |
|
|---|
| 203 | make_spoolss_q_rffpcnex(
|
|---|
| 204 | &q, pol, flags, options, localmachine, printerlocal,
|
|---|
| 205 | option);
|
|---|
| 206 |
|
|---|
| 207 | /* Marshall data and send request */
|
|---|
| 208 |
|
|---|
| 209 | CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_RFFPCNEX,
|
|---|
| 210 | q, r,
|
|---|
| 211 | qbuf, rbuf,
|
|---|
| 212 | spoolss_io_q_rffpcnex,
|
|---|
| 213 | spoolss_io_r_rffpcnex,
|
|---|
| 214 | WERR_GENERAL_FAILURE );
|
|---|
| 215 |
|
|---|
| 216 | result = r.status;
|
|---|
| 217 | return result;
|
|---|
| 218 | }
|
|---|