2003-11-03 06:22:45 +00:00
/*
Unix SMB / CIFS implementation .
2005-01-09 08:34:05 +00:00
DCERPC client side interface structures
2003-11-03 06:22:45 +00:00
Copyright ( C ) Tim Potter 2003
2005-01-09 08:34:05 +00:00
Copyright ( C ) Andrew Tridgell 2003 - 2005
2003-11-03 06:22:45 +00: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-10 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2003-11-03 06:22:45 +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/>.
2003-11-03 06:22:45 +00:00
*/
2006-01-03 13:41:17 +00:00
# ifndef __DCERPC_H__
# define __DCERPC_H__
2006-03-16 20:02:31 +00:00
# include "core.h"
2006-03-14 00:37:05 +00:00
# include "librpc/gen_ndr/dcerpc.h"
2006-03-18 15:42:57 +00:00
# include "librpc/ndr/libndr.h"
2006-03-14 00:37:05 +00:00
2004-10-21 12:47:02 +00:00
enum dcerpc_transport_t {
NCACN_NP , NCACN_IP_TCP , NCACN_IP_UDP , NCACN_VNS_IPC , NCACN_VNS_SPP ,
2004-10-24 13:22:58 +00:00
NCACN_AT_DSP , NCADG_AT_DDP , NCALRPC , NCACN_UNIX_STREAM , NCADG_UNIX_DGRAM ,
2004-10-31 18:35:47 +00:00
NCACN_HTTP , NCADG_IPX , NCACN_SPX } ;
2003-11-03 06:22:45 +00:00
2004-02-10 10:22:12 +00:00
/*
this defines a generic security context for signed / sealed dcerpc pipes .
2003-11-03 06:22:45 +00:00
*/
2005-01-09 08:34:05 +00:00
struct dcerpc_connection ;
2004-06-07 12:30:22 +00:00
struct dcerpc_security {
struct dcerpc_auth * auth_info ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 09:40:10 +00:00
struct gensec_security * generic_state ;
2004-09-11 15:11:36 +00:00
/* get the session key */
2005-01-09 08:34:05 +00:00
NTSTATUS ( * session_key ) ( struct dcerpc_connection * , DATA_BLOB * ) ;
2004-02-10 10:22:12 +00:00
} ;
2004-01-20 06:07:09 +00:00
2005-01-09 08:34:05 +00:00
/*
this holds the information that is not specific to a particular rpc context_id
*/
struct dcerpc_connection {
2004-05-25 16:24:13 +00:00
uint32_t call_id ;
uint32_t srv_max_xmit_frag ;
uint32_t srv_max_recv_frag ;
2006-01-03 13:41:17 +00:00
uint32_t flags ;
2004-06-07 12:30:22 +00:00
struct dcerpc_security security_state ;
2004-01-20 06:07:09 +00:00
const char * binding_string ;
2005-06-16 11:36:09 +00:00
struct event_context * event_ctx ;
2004-07-09 12:26:34 +00:00
2007-04-22 23:00:22 +00:00
bool dead ;
bool free_skipped ;
2003-11-24 11:45:33 +00:00
struct dcerpc_transport {
2004-01-20 06:07:09 +00:00
enum dcerpc_transport_t transport ;
2007-05-16 14:52:54 +00:00
void * private_data ;
2004-08-30 03:10:43 +00:00
2007-04-22 23:00:22 +00:00
NTSTATUS ( * shutdown_pipe ) ( struct dcerpc_connection * , NTSTATUS status ) ;
2004-08-30 03:10:43 +00:00
2005-01-09 08:34:05 +00:00
const char * ( * peer_name ) ( struct dcerpc_connection * ) ;
2004-08-30 03:10:43 +00:00
2006-03-25 11:39:09 +00:00
const char * ( * target_hostname ) ( struct dcerpc_connection * ) ;
2004-08-30 03:10:43 +00:00
/* send a request to the server */
2007-08-27 18:10:19 +00:00
NTSTATUS ( * send_request ) ( struct dcerpc_connection * , DATA_BLOB * , bool trigger_read ) ;
2004-08-30 03:10:43 +00:00
/* send a read request to the server */
2005-01-09 08:34:05 +00:00
NTSTATUS ( * send_read ) ( struct dcerpc_connection * ) ;
2004-08-30 03:10:43 +00:00
/* a callback to the dcerpc code when a full fragment
has been received */
2005-01-09 08:34:05 +00:00
void ( * recv_data ) ( struct dcerpc_connection * , DATA_BLOB * , NTSTATUS status ) ;
2003-11-24 11:45:33 +00:00
} transport ;
2003-11-27 04:02:15 +00:00
2005-11-02 05:34:17 +00:00
/* Requests that have been sent, waiting for a reply */
2004-08-30 03:10:43 +00:00
struct rpc_request * pending ;
2005-11-02 05:34:17 +00:00
/* Sync requests waiting to be shipped */
struct rpc_request * request_queue ;
2005-01-09 11:32:12 +00:00
/* the next context_id to be assigned */
uint32_t next_context_id ;
2003-11-03 06:22:45 +00:00
} ;
2005-01-09 08:34:05 +00:00
/*
this encapsulates a full dcerpc client side pipe
*/
struct dcerpc_pipe {
uint32_t context_id ;
2007-02-23 11:00:20 +00:00
uint32_t assoc_group_id ;
2007-08-18 06:57:49 +00:00
struct ndr_syntax_id syntax ;
struct ndr_syntax_id transfer_syntax ;
2005-01-09 08:34:05 +00:00
struct dcerpc_connection * conn ;
2006-01-12 09:33:49 +00:00
struct dcerpc_binding * binding ;
2005-01-09 08:34:05 +00:00
/* the last fault code from a DCERPC fault */
uint32_t last_fault_code ;
2005-06-12 02:42:40 +00:00
/* timeout for individual rpc requests, in seconds */
2006-01-03 13:41:17 +00:00
uint32_t request_timeout ;
2005-01-09 08:34:05 +00:00
} ;
2005-06-12 02:42:40 +00:00
/* default timeout for all rpc requests, in seconds */
# define DCERPC_REQUEST_TIMEOUT 60
2005-01-09 08:34:05 +00:00
2003-11-18 01:18:24 +00:00
/* dcerpc pipe flags */
2004-06-06 07:14:10 +00:00
# define DCERPC_DEBUG_PRINT_IN (1<<0)
# define DCERPC_DEBUG_PRINT_OUT (1<<1)
2003-11-18 01:18:24 +00:00
# define DCERPC_DEBUG_PRINT_BOTH (DCERPC_DEBUG_PRINT_IN | DCERPC_DEBUG_PRINT_OUT)
2004-06-06 07:14:10 +00:00
# define DCERPC_DEBUG_VALIDATE_IN (1<<2)
# define DCERPC_DEBUG_VALIDATE_OUT (1<<3)
2003-11-22 08:11:32 +00:00
# define DCERPC_DEBUG_VALIDATE_BOTH (DCERPC_DEBUG_VALIDATE_IN | DCERPC_DEBUG_VALIDATE_OUT)
2003-11-23 13:44:19 +00:00
2004-09-25 07:25:51 +00:00
# define DCERPC_CONNECT (1<<4)
# define DCERPC_SIGN (1<<5)
# define DCERPC_SEAL (1<<6)
2003-11-26 12:29:08 +00:00
2004-09-25 07:25:51 +00:00
# define DCERPC_PUSH_BIGENDIAN (1<<7)
# define DCERPC_PULL_BIGENDIAN (1<<8)
2003-12-16 09:02:58 +00:00
2005-05-01 19:29:00 +00:00
# define DCERPC_SCHANNEL (1<<9)
2004-06-06 07:14:10 +00:00
2005-01-10 07:14:12 +00:00
/* use a 128 bit session key */
# define DCERPC_SCHANNEL_128 (1<<12)
2004-09-02 10:45:58 +00:00
/* check incoming pad bytes */
2004-09-25 07:25:51 +00:00
# define DCERPC_DEBUG_PAD_CHECK (1<<13)
2004-09-02 10:45:58 +00:00
2004-09-06 10:29:18 +00:00
/* set LIBNDR_FLAG_REF_ALLOC flag when decoding NDR */
2004-09-25 07:25:51 +00:00
# define DCERPC_NDR_REF_ALLOC (1<<14)
2004-09-06 10:29:18 +00:00
2006-05-04 10:03:41 +00:00
# define DCERPC_AUTH_OPTIONS (DCERPC_SEAL|DCERPC_SIGN|DCERPC_SCHANNEL|DCERPC_AUTH_SPNEGO|DCERPC_AUTH_KRB5|DCERPC_AUTH_NTLM)
2005-01-10 08:56:55 +00:00
2006-05-04 10:03:41 +00:00
/* select spnego auth */
2005-01-10 07:14:12 +00:00
# define DCERPC_AUTH_SPNEGO (1<<15)
2006-05-04 10:03:41 +00:00
/* select krb5 auth */
2005-01-24 14:44:15 +00:00
# define DCERPC_AUTH_KRB5 (1<<16)
2005-11-25 05:25:37 +00:00
# define DCERPC_SMB2 (1<<17)
2006-05-04 10:03:41 +00:00
/* select NTLM auth */
# define DCERPC_AUTH_NTLM (1<<18)
2007-02-23 11:00:20 +00:00
/* this triggers the DCERPC_PFC_FLAG_CONC_MPX flag in the bind request */
# define DCERPC_CONCURRENT_MULTIPLEX (1<<19)
2003-12-15 03:29:55 +00:00
/* this describes a binding to a particular transport/pipe */
struct dcerpc_binding {
enum dcerpc_transport_t transport ;
2007-08-18 06:57:49 +00:00
struct ndr_syntax_id object ;
2003-12-15 03:29:55 +00:00
const char * host ;
2006-10-13 13:01:48 +00:00
const char * target_hostname ;
2004-10-24 22:46:47 +00:00
const char * endpoint ;
2003-12-15 03:29:55 +00:00
const char * * options ;
2004-05-25 16:24:13 +00:00
uint32_t flags ;
2007-02-23 11:00:20 +00:00
uint32_t assoc_group_id ;
2003-12-15 03:29:55 +00:00
} ;
2004-08-30 03:10:43 +00:00
2005-12-06 08:58:21 +00:00
struct dcerpc_pipe_connect {
struct dcerpc_pipe * pipe ;
struct dcerpc_binding * binding ;
const char * pipe_name ;
2007-08-19 20:46:45 +00:00
const struct ndr_interface_table * interface ;
2005-12-06 08:58:21 +00:00
struct cli_credentials * creds ;
} ;
2004-08-30 03:10:43 +00:00
enum rpc_request_state {
2007-03-13 03:43:16 +00:00
RPC_REQUEST_QUEUED ,
2004-08-30 03:10:43 +00:00
RPC_REQUEST_PENDING ,
RPC_REQUEST_DONE
} ;
/*
handle for an async dcerpc request
*/
struct rpc_request {
struct rpc_request * next , * prev ;
struct dcerpc_pipe * p ;
NTSTATUS status ;
uint32_t call_id ;
enum rpc_request_state state ;
DATA_BLOB payload ;
2006-01-03 13:41:17 +00:00
uint32_t flags ;
2004-08-30 03:10:43 +00:00
uint32_t fault_code ;
2006-05-10 05:57:20 +00:00
/* this is used to distinguish bind and alter_context requests
from normal requests */
void ( * recv_handler ) ( struct rpc_request * conn ,
DATA_BLOB * blob , struct ncacn_packet * pkt ) ;
2005-11-02 05:34:17 +00:00
const struct GUID * object ;
uint16_t opnum ;
DATA_BLOB request_data ;
2007-08-27 18:10:19 +00:00
bool async_call ;
bool ignore_timeout ;
2005-11-02 05:34:17 +00:00
2004-08-30 03:10:43 +00:00
/* use by the ndr level async recv call */
2004-12-07 09:26:00 +00:00
struct {
2007-08-19 20:46:45 +00:00
const struct ndr_interface_table * table ;
2004-12-07 09:26:00 +00:00
uint32_t opnum ;
2004-08-30 03:10:43 +00:00
void * struct_ptr ;
TALLOC_CTX * mem_ctx ;
} ndr ;
2004-09-02 12:03:16 +00:00
struct {
void ( * callback ) ( struct rpc_request * ) ;
2007-05-16 14:52:54 +00:00
void * private_data ;
2004-09-02 12:03:16 +00:00
} async ;
2004-08-30 03:10:43 +00:00
} ;
2005-12-28 15:38:36 +00:00
2006-01-03 17:27:33 +00:00
struct epm_tower ;
struct epm_floor ;
2006-03-14 15:22:36 +00:00
struct smbcli_tree ;
struct smb2_tree ;
struct socket_address ;
2005-12-28 15:38:36 +00:00
# include "librpc/rpc/dcerpc_proto.h"
2006-01-03 13:41:17 +00:00
# endif /* __DCERPC_H__ */