File: cli_spoolss_notify.c

package info (click to toggle)
samba 2:3.2.5-4lenny15
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 124,704 kB
  • ctags: 69,181
  • sloc: ansic: 564,153; xml: 219,271; sh: 11,039; perl: 4,458; makefile: 4,301; python: 1,975; cpp: 1,224; exp: 1,147; yacc: 881; awk: 557; csh: 58; sed: 45
file content (218 lines) | stat: -rw-r--r-- 6,421 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/* 
   Unix SMB/CIFS implementation.
   RPC pipe client

   Copyright (C) Gerald Carter                2001-2002,
   Copyright (C) Tim Potter                   2000-2002,
   Copyright (C) Andrew Tridgell              1994-2000,
   Copyright (C) Jean-Francois Micouleau      1999-2000.
   Copyright (C) Jeremy Allison                    2005.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "includes.h"

/*
 * SPOOLSS Client RPC's used by servers as the notification
 * back channel.
 */

/* Send a ReplyOpenPrinter request.  This rpc is made by the printer
   server to the printer client in response to a rffpcnex request.
   The rrfpcnex request names a printer and a handle (the printerlocal
   value) and this rpc establishes a back-channel over which printer
   notifications are performed. */

WERROR rpccli_spoolss_reply_open_printer(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, 
				      const char *printer, uint32 printerlocal, uint32 type, 
				      POLICY_HND *handle)
{
	prs_struct qbuf, rbuf;
	SPOOL_Q_REPLYOPENPRINTER q;
	SPOOL_R_REPLYOPENPRINTER r;
	WERROR result = W_ERROR(ERRgeneral);
	
	/* Initialise input parameters */

	make_spoolss_q_replyopenprinter(&q, printer, printerlocal, type);

	/* Marshall data and send request */

	CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_REPLYOPENPRINTER,
		q, r,
		qbuf, rbuf,
		spoolss_io_q_replyopenprinter,
		spoolss_io_r_replyopenprinter,
		WERR_GENERAL_FAILURE );

	/* Return result */

	memcpy(handle, &r.handle, sizeof(r.handle));
	result = r.status;

	return result;
}

/* Close a back-channel notification connection */

WERROR rpccli_spoolss_reply_close_printer(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, 
				       POLICY_HND *handle)
{
	prs_struct qbuf, rbuf;
	SPOOL_Q_REPLYCLOSEPRINTER q;
	SPOOL_R_REPLYCLOSEPRINTER r;
	WERROR result = W_ERROR(ERRgeneral);

	/* Initialise input parameters */

	make_spoolss_q_reply_closeprinter(&q, handle);

	/* Marshall data and send request */

	CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_REPLYCLOSEPRINTER,
		q, r,
		qbuf, rbuf,
		spoolss_io_q_replycloseprinter,
		spoolss_io_r_replycloseprinter,
		WERR_GENERAL_FAILURE );

	/* Return result */

	result = r.status;
	return result;
}

/*********************************************************************
 This SPOOLSS_ROUTERREPLYPRINTER function is used to send a change 
 notification event when the registration **did not** use 
 SPOOL_NOTIFY_OPTION_TYPE structure to specify the events to monitor.
 Also see cli_spolss_reply_rrpcn()
 *********************************************************************/
 
WERROR rpccli_spoolss_routerreplyprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
				      POLICY_HND *pol, uint32 condition, uint32 change_id)
{
	prs_struct qbuf, rbuf;
	SPOOL_Q_ROUTERREPLYPRINTER q;
        SPOOL_R_ROUTERREPLYPRINTER r;
	WERROR result = W_ERROR(ERRgeneral);

	/* Initialise input parameters */

	make_spoolss_q_routerreplyprinter(&q, pol, condition, change_id);

	/* Marshall data and send request */

	CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ROUTERREPLYPRINTER,
		q, r,
		qbuf, rbuf,
		spoolss_io_q_routerreplyprinter,
		spoolss_io_r_routerreplyprinter,
		WERR_GENERAL_FAILURE );

	/* Return output parameters */

	result = r.status;
	return result;	
}

/*********************************************************************
 This SPOOLSS_REPLY_RRPCN function is used to send a change 
 notification event when the registration **did** use 
 SPOOL_NOTIFY_OPTION_TYPE structure to specify the events to monitor
 Also see cli_spoolss_routereplyprinter()
 *********************************************************************/

WERROR rpccli_spoolss_rrpcn(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, 
			 POLICY_HND *pol, uint32 notify_data_len,
			 SPOOL_NOTIFY_INFO_DATA *notify_data,
			 uint32 change_low, uint32 change_high)
{
	prs_struct qbuf, rbuf;
	SPOOL_Q_REPLY_RRPCN q;
	SPOOL_R_REPLY_RRPCN r;
	WERROR result = W_ERROR(ERRgeneral);
	SPOOL_NOTIFY_INFO 	notify_info;

	ZERO_STRUCT(q);
	ZERO_STRUCT(r);

	ZERO_STRUCT(notify_info);

	/* Initialise input parameters */

	notify_info.version = 0x2;
	notify_info.flags   = 0x00020000;	/* ?? */
	notify_info.count   = notify_data_len;
	notify_info.data    = notify_data;

	/* create and send a MSRPC command with api  */
	/* store the parameters */

	make_spoolss_q_reply_rrpcn(&q, pol, change_low, change_high, 
				   &notify_info);

	/* Marshall data and send request */

	CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_RRPCN,
		q, r,
		qbuf, rbuf,
		spoolss_io_q_reply_rrpcn,
		spoolss_io_r_reply_rrpcn,
		WERR_GENERAL_FAILURE );

	if (r.unknown0 == 0x00080000)
		DEBUG(8,("cli_spoolss_reply_rrpcn: I think the spooler resonded that the notification was ignored.\n"));
	else if ( r.unknown0 != 0x0 )
		DEBUG(8,("cli_spoolss_reply_rrpcn: unknown0 is non-zero [0x%x]\n", r.unknown0));
	
	result = r.status;
	return result;
}

/*********************************************************************
 *********************************************************************/
 
WERROR rpccli_spoolss_rffpcnex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
			    POLICY_HND *pol, uint32 flags, uint32 options,
			    const char *localmachine, uint32 printerlocal,
			    SPOOL_NOTIFY_OPTION *option)
{
	prs_struct qbuf, rbuf;
	SPOOL_Q_RFFPCNEX q;
	SPOOL_R_RFFPCNEX r;
	WERROR result = W_ERROR(ERRgeneral);

	ZERO_STRUCT(q);
	ZERO_STRUCT(r);

	/* Initialise input parameters */

	make_spoolss_q_rffpcnex(
		&q, pol, flags, options, localmachine, printerlocal,
		option);

	/* Marshall data and send request */

	CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_RFFPCNEX,
		q, r,
		qbuf, rbuf,
		spoolss_io_q_rffpcnex,
		spoolss_io_r_rffpcnex,
		WERR_GENERAL_FAILURE );

	result = r.status;
	return result;
}