2002-08-17 20:05:44 +04:00
/*
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.
2005-09-30 21:13:37 +04:00
Copyright ( C ) Jeremy Allison 2005.
2002-08-17 20:05:44 +04:00
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
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2002-08-17 20:05:44 +04:00
( 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
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2002-08-17 20:05:44 +04:00
*/
2000-09-26 01:05:18 +04:00
# include "includes.h"
2002-03-15 11:14:10 +03:00
/*
* SPOOLSS Client RPC ' s used by servers as the notification
2002-08-17 20:05:44 +04:00
* back channel .
2002-03-15 11:14:10 +03:00
*/
2002-08-17 20:05:44 +04:00
/* 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 . */
2000-09-26 01:05:18 +04:00
2005-09-30 21:13:37 +04:00
WERROR rpccli_spoolss_reply_open_printer ( struct rpc_pipe_client * cli , TALLOC_CTX * mem_ctx ,
2002-11-07 05:15:35 +03:00
const char * printer , uint32 printerlocal , uint32 type ,
2002-08-17 20:05:44 +04:00
POLICY_HND * handle )
2000-09-26 01:05:18 +04:00
{
2002-08-17 20:05:44 +04:00
prs_struct qbuf , rbuf ;
SPOOL_Q_REPLYOPENPRINTER q ;
SPOOL_R_REPLYOPENPRINTER r ;
2002-04-11 05:50:18 +04:00
WERROR result = W_ERROR ( ERRgeneral ) ;
2002-03-15 11:14:10 +03:00
2002-08-17 20:05:44 +04:00
/* Initialise input parameters */
2000-09-26 01:05:18 +04:00
2002-08-17 20:05:44 +04:00
make_spoolss_q_replyopenprinter ( & q , printer , printerlocal , type ) ;
2000-09-26 01:05:18 +04:00
2002-08-17 20:05:44 +04:00
/* Marshall data and send request */
2000-09-26 01:05:18 +04:00
2005-09-30 21:13:37 +04:00
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 ) ;
2002-08-17 20:05:44 +04:00
/* Return result */
2000-09-26 01:05:18 +04:00
2002-08-17 20:05:44 +04:00
memcpy ( handle , & r . handle , sizeof ( r . handle ) ) ;
result = r . status ;
2000-09-26 01:05:18 +04:00
2002-03-15 11:14:10 +03:00
return result ;
2000-09-26 01:05:18 +04:00
}
2002-08-17 20:05:44 +04:00
/* Close a back-channel notification connection */
2000-09-26 01:05:18 +04:00
2005-09-30 21:13:37 +04:00
WERROR rpccli_spoolss_reply_close_printer ( struct rpc_pipe_client * cli , TALLOC_CTX * mem_ctx ,
2002-08-17 20:05:44 +04:00
POLICY_HND * handle )
2000-09-26 01:05:18 +04:00
{
2002-08-17 20:05:44 +04:00
prs_struct qbuf , rbuf ;
SPOOL_Q_REPLYCLOSEPRINTER q ;
SPOOL_R_REPLYCLOSEPRINTER r ;
2002-04-11 05:50:18 +04:00
WERROR result = W_ERROR ( ERRgeneral ) ;
2000-09-26 01:05:18 +04:00
2002-08-17 20:05:44 +04:00
/* Initialise input parameters */
2000-09-26 01:05:18 +04:00
2002-08-17 20:05:44 +04:00
make_spoolss_q_reply_closeprinter ( & q , handle ) ;
2000-09-26 01:05:18 +04:00
2002-08-17 20:05:44 +04:00
/* Marshall data and send request */
2000-09-26 01:05:18 +04:00
2005-09-30 21:13:37 +04:00
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 ) ;
2002-08-17 20:05:44 +04:00
/* Return result */
2002-03-15 11:14:10 +03:00
2002-08-17 20:05:44 +04:00
result = r . status ;
2002-03-15 11:14:10 +03:00
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 ( )
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
WERROR rpccli_spoolss_routerreplyprinter ( struct rpc_pipe_client * cli , TALLOC_CTX * mem_ctx ,
2002-08-17 20:05:44 +04:00
POLICY_HND * pol , uint32 condition , uint32 change_id )
2002-03-15 11:14:10 +03:00
{
prs_struct qbuf , rbuf ;
SPOOL_Q_ROUTERREPLYPRINTER q ;
SPOOL_R_ROUTERREPLYPRINTER r ;
2002-04-11 05:50:18 +04:00
WERROR result = W_ERROR ( ERRgeneral ) ;
2002-03-15 11:14:10 +03:00
/* Initialise input parameters */
2002-08-17 20:05:44 +04:00
make_spoolss_q_routerreplyprinter ( & q , pol , condition , change_id ) ;
2002-03-15 11:14:10 +03:00
/* Marshall data and send request */
2005-09-30 21:13:37 +04:00
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 ) ;
2002-03-15 11:14:10 +03:00
/* Return output parameters */
2002-08-17 20:05:44 +04:00
2002-04-11 05:50:18 +04:00
result = r . status ;
2002-03-15 11:14:10 +03:00
return result ;
}
2000-09-26 01:05:18 +04:00
2002-03-15 11:14:10 +03:00
/*********************************************************************
2002-08-17 20:05:44 +04:00
This SPOOLSS_REPLY_RRPCN function is used to send a change
2002-03-15 11:14:10 +03:00
notification event when the registration * * did * * use
SPOOL_NOTIFY_OPTION_TYPE structure to specify the events to monitor
Also see cli_spoolss_routereplyprinter ( )
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2000-09-26 01:05:18 +04:00
2005-09-30 21:13:37 +04:00
WERROR rpccli_spoolss_rrpcn ( struct rpc_pipe_client * cli , TALLOC_CTX * mem_ctx ,
2002-08-17 20:05:44 +04:00
POLICY_HND * pol , uint32 notify_data_len ,
SPOOL_NOTIFY_INFO_DATA * notify_data ,
uint32 change_low , uint32 change_high )
2000-09-26 01:05:18 +04:00
{
2002-08-17 20:05:44 +04:00
prs_struct qbuf , rbuf ;
SPOOL_Q_REPLY_RRPCN q ;
SPOOL_R_REPLY_RRPCN r ;
WERROR result = W_ERROR ( ERRgeneral ) ;
2002-03-15 11:14:10 +03:00
SPOOL_NOTIFY_INFO notify_info ;
2000-09-26 01:05:18 +04:00
2002-08-17 20:05:44 +04:00
ZERO_STRUCT ( q ) ;
ZERO_STRUCT ( r ) ;
2002-03-15 11:14:10 +03:00
ZERO_STRUCT ( notify_info ) ;
2000-09-26 01:05:18 +04:00
2002-08-17 20:05:44 +04:00
/* Initialise input parameters */
2002-03-15 11:14:10 +03:00
notify_info . version = 0x2 ;
notify_info . flags = 0x00020000 ; /* ?? */
2002-08-17 20:05:44 +04:00
notify_info . count = notify_data_len ;
2002-03-15 11:14:10 +03:00
notify_info . data = notify_data ;
/* create and send a MSRPC command with api */
2000-09-26 01:05:18 +04:00
/* store the parameters */
2002-03-15 11:14:10 +03:00
2002-08-17 20:05:44 +04:00
make_spoolss_q_reply_rrpcn ( & q , pol , change_low , change_high ,
& notify_info ) ;
2000-09-26 01:05:18 +04:00
2002-08-17 20:05:44 +04:00
/* Marshall data and send request */
2000-09-26 01:05:18 +04:00
2005-09-30 21:13:37 +04:00
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 ) ;
2002-03-15 11:14:10 +03:00
2002-08-17 20:05:44 +04:00
if ( r . unknown0 = = 0x00080000 )
2002-03-15 11:14:10 +03:00
DEBUG ( 8 , ( " cli_spoolss_reply_rrpcn: I think the spooler resonded that the notification was ignored. \n " ) ) ;
2003-01-11 05:38:36 +03:00
else if ( r . unknown0 ! = 0x0 )
DEBUG ( 8 , ( " cli_spoolss_reply_rrpcn: unknown0 is non-zero [0x%x] \n " , r . unknown0 ) ) ;
2000-09-26 01:05:18 +04:00
2002-08-17 20:05:44 +04:00
result = r . status ;
2002-03-15 11:14:10 +03:00
return result ;
2000-09-26 01:05:18 +04:00
}
2002-03-15 11:14:10 +03:00
2002-09-25 19:19:00 +04:00
/*********************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
WERROR rpccli_spoolss_rffpcnex ( struct rpc_pipe_client * cli , TALLOC_CTX * mem_ctx ,
2002-08-17 20:05:44 +04:00
POLICY_HND * pol , uint32 flags , uint32 options ,
2002-11-07 05:15:35 +03:00
const char * localmachine , uint32 printerlocal ,
2002-08-17 20:05:44 +04:00
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 */
2005-09-30 21:13:37 +04:00
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 ) ;
2002-08-17 20:05:44 +04:00
result = r . status ;
return result ;
}