2005-06-05 06:53:07 +00:00
/*
Unix SMB / CIFS implementation .
Samba internal rpc code - header
Copyright ( C ) Andrew Tridgell 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
2007-07-10 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2005-06-05 06:53:07 +00: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 02:07:03 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2005-06-05 06:53:07 +00:00
*/
2005-09-25 13:01:26 +00:00
# include "librpc/gen_ndr/irpc.h"
2005-06-05 06:53:07 +00:00
/*
an incoming irpc message
*/
struct irpc_message {
2007-01-10 10:52:09 +00:00
struct server_id from ;
2005-06-06 05:47:14 +00:00
void * private ;
2005-09-25 13:01:26 +00:00
struct irpc_header header ;
struct ndr_pull * ndr ;
2007-08-27 18:10:19 +00:00
bool defer_reply ;
2005-09-25 13:01:26 +00:00
struct messaging_context * msg_ctx ;
struct irpc_list * irpc ;
void * data ;
2005-09-25 13:17:03 +00:00
struct event_context * ev ;
2005-06-05 06:53:07 +00:00
} ;
/* don't allow calls to take too long */
2005-08-02 16:58:52 +00:00
# define IRPC_CALL_TIMEOUT 10
2005-06-05 06:53:07 +00:00
/* the server function type */
typedef NTSTATUS ( * irpc_function_t ) ( struct irpc_message * , void * r ) ;
/* register a server function with the irpc messaging system */
2005-06-06 05:47:14 +00:00
# define IRPC_REGISTER(msg_ctx, pipename, funcname, function, private) \
2007-08-19 21:23:03 +00:00
irpc_register ( msg_ctx , & ndr_table_ # # pipename , \
2007-08-19 22:09:21 +00:00
NDR_ # # funcname , \
2005-06-06 05:47:14 +00:00
( irpc_function_t ) function , private )
2005-06-05 06:53:07 +00:00
/* make a irpc call */
2005-08-01 17:33:43 +00:00
# define IRPC_CALL(msg_ctx, server_id, pipename, funcname, ptr, ctx) \
2007-08-19 22:09:21 +00:00
irpc_call ( msg_ctx , server_id , & ndr_table_ # # pipename , NDR_ # # funcname , ptr , ctx )
2005-06-05 06:53:07 +00:00
2005-08-01 17:33:43 +00:00
# define IRPC_CALL_SEND(msg_ctx, server_id, pipename, funcname, ptr, ctx) \
2007-08-19 22:09:21 +00:00
irpc_call_send ( msg_ctx , server_id , & ndr_table_ # # pipename , NDR_ # # funcname , ptr , ctx )
2005-06-05 07:30:44 +00:00
2005-06-05 06:53:07 +00:00
/*
a pending irpc call
*/
struct irpc_request {
struct messaging_context * msg_ctx ;
2007-08-19 20:46:45 +00:00
const struct ndr_interface_table * table ;
2005-06-05 06:53:07 +00:00
int callnum ;
int callid ;
void * r ;
NTSTATUS status ;
2007-08-27 18:10:19 +00:00
bool done ;
bool reject_free ;
2005-08-01 17:33:43 +00:00
TALLOC_CTX * mem_ctx ;
2005-06-05 06:53:07 +00:00
struct {
void ( * fn ) ( struct irpc_request * ) ;
void * private ;
} async ;
} ;
2006-04-12 06:08:24 +00:00
typedef void ( * msg_callback_t ) ( struct messaging_context * msg , void * private ,
2007-01-10 10:52:09 +00:00
uint32_t msg_type ,
struct server_id server_id , DATA_BLOB * data ) ;
2005-06-05 06:53:07 +00:00
2007-01-10 10:52:09 +00:00
struct messaging_context * messaging_init ( TALLOC_CTX * mem_ctx ,
struct server_id server_id ,
2005-06-05 06:53:07 +00:00
struct event_context * ev ) ;
2007-01-10 10:52:09 +00:00
NTSTATUS messaging_send ( struct messaging_context * msg , struct server_id server ,
2005-06-05 06:53:07 +00:00
uint32_t msg_type , DATA_BLOB * data ) ;
2006-04-12 06:08:24 +00:00
NTSTATUS messaging_register ( struct messaging_context * msg , void * private ,
uint32_t msg_type ,
msg_callback_t fn ) ;
NTSTATUS messaging_register_tmp ( struct messaging_context * msg , void * private ,
msg_callback_t fn , uint32_t * msg_type ) ;
2007-01-10 10:52:09 +00:00
struct messaging_context * messaging_init ( TALLOC_CTX * mem_ctx ,
struct server_id server_id ,
2005-06-05 06:53:07 +00:00
struct event_context * ev ) ;
2006-02-03 22:30:30 +00:00
struct messaging_context * messaging_client_init ( TALLOC_CTX * mem_ctx ,
struct event_context * ev ) ;
2007-01-10 10:52:09 +00:00
NTSTATUS messaging_send_ptr ( struct messaging_context * msg , struct server_id server ,
2005-06-05 06:53:07 +00:00
uint32_t msg_type , void * ptr ) ;
void messaging_deregister ( struct messaging_context * msg , uint32_t msg_type , void * private ) ;
NTSTATUS irpc_register ( struct messaging_context * msg_ctx ,
2007-08-19 20:46:45 +00:00
const struct ndr_interface_table * table ,
2005-06-06 05:47:14 +00:00
int call , irpc_function_t fn , void * private ) ;
2005-06-05 06:53:07 +00:00
struct irpc_request * irpc_call_send ( struct messaging_context * msg_ctx ,
2007-01-10 10:52:09 +00:00
struct server_id server_id ,
2007-08-19 20:46:45 +00:00
const struct ndr_interface_table * table ,
2005-08-01 17:33:43 +00:00
int callnum , void * r , TALLOC_CTX * ctx ) ;
2005-06-05 06:53:07 +00:00
NTSTATUS irpc_call_recv ( struct irpc_request * irpc ) ;
NTSTATUS irpc_call ( struct messaging_context * msg_ctx ,
2007-01-10 10:52:09 +00:00
struct server_id server_id ,
2007-08-19 20:46:45 +00:00
const struct ndr_interface_table * table ,
2005-08-01 17:33:43 +00:00
int callnum , void * r , TALLOC_CTX * ctx ) ;
2005-06-05 06:53:07 +00:00
2005-07-10 04:54:21 +00:00
NTSTATUS irpc_add_name ( struct messaging_context * msg_ctx , const char * name ) ;
2007-05-07 15:19:53 +00:00
struct server_id * irpc_servers_byname ( struct messaging_context * msg_ctx , TALLOC_CTX * mem_ctx , const char * name ) ;
2005-07-10 04:54:21 +00:00
void irpc_remove_name ( struct messaging_context * msg_ctx , const char * name ) ;
2005-09-25 13:17:03 +00:00
NTSTATUS irpc_send_reply ( struct irpc_message * m , NTSTATUS status ) ;
2005-09-25 13:01:26 +00:00
2005-07-10 04:54:21 +00:00