2003-11-03 06:22:45 +00:00
/*
Unix SMB / CIFS implementation .
DCERPC interface structures
Copyright ( C ) Tim Potter 2003
Copyright ( C ) Andrew Tridgell 2003
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 2 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 , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
2004-02-10 10:22:12 +00:00
enum dcerpc_transport_t { NCACN_NP , NCACN_IP_TCP } ;
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
*/
2004-06-07 12:30:22 +00:00
struct dcerpc_pipe ;
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 */
NTSTATUS ( * session_key ) ( struct dcerpc_pipe * , DATA_BLOB * ) ;
2004-02-10 10:22:12 +00:00
} ;
2004-01-20 06:07:09 +00:00
2003-11-03 06:22:45 +00:00
struct dcerpc_pipe {
int reference_count ;
2004-05-25 16:24:13 +00:00
uint32_t call_id ;
uint32_t srv_max_xmit_frag ;
uint32_t srv_max_recv_frag ;
2004-06-01 10:12:52 +00:00
uint_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 ;
2004-07-09 12:26:34 +00:00
struct dcerpc_syntax_id syntax ;
struct dcerpc_syntax_id transfer_syntax ;
2003-11-24 11:45:33 +00:00
struct dcerpc_transport {
2004-01-20 06:07:09 +00:00
enum dcerpc_transport_t transport ;
2003-11-24 11:45:33 +00:00
void * private ;
2004-08-30 03:10:43 +00:00
2003-11-24 11:45:33 +00:00
NTSTATUS ( * shutdown_pipe ) ( struct dcerpc_pipe * ) ;
2004-08-30 03:10:43 +00:00
2003-11-24 11:45:33 +00:00
const char * ( * peer_name ) ( struct dcerpc_pipe * ) ;
2004-08-30 03:10:43 +00:00
/* send a request to the server */
2004-08-30 05:35:30 +00:00
NTSTATUS ( * send_request ) ( struct dcerpc_pipe * , DATA_BLOB * , BOOL trigger_read ) ;
2004-08-30 03:10:43 +00:00
/* send a read request to the server */
NTSTATUS ( * send_read ) ( struct dcerpc_pipe * ) ;
/* get an event context for the connection */
struct event_context * ( * event_context ) ( struct dcerpc_pipe * ) ;
/* a callback to the dcerpc code when a full fragment
has been received */
void ( * recv_data ) ( struct dcerpc_pipe * , DATA_BLOB * , NTSTATUS status ) ;
2004-09-09 14:31:27 +00:00
2003-11-24 11:45:33 +00:00
} transport ;
2003-11-27 04:02:15 +00:00
/* the last fault code from a DCERPC fault */
2004-05-25 16:24:13 +00:00
uint32_t last_fault_code ;
2004-08-30 03:10:43 +00:00
/* pending requests */
struct rpc_request * pending ;
/* private pointer for pending full requests */
void * full_request_private ;
2003-11-03 06:22:45 +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-06-06 07:14:10 +00:00
# define DCERPC_SIGN (1<<4)
# define DCERPC_SEAL (1<<5)
2003-11-26 12:29:08 +00:00
2004-06-06 07:14:10 +00:00
# define DCERPC_PUSH_BIGENDIAN (1<<6)
# define DCERPC_PULL_BIGENDIAN (1<<7)
2003-12-16 09:02:58 +00:00
2004-06-06 07:14:10 +00:00
# define DCERPC_SCHANNEL_BDC (1<<8)
# define DCERPC_SCHANNEL_WORKSTATION (1<<9)
# define DCERPC_SCHANNEL_DOMAIN (1<<10)
# define DCERPC_SCHANNEL_ANY (DCERPC_SCHANNEL_BDC| \
DCERPC_SCHANNEL_DOMAIN | \
DCERPC_SCHANNEL_WORKSTATION )
2004-06-06 07:58:16 +00:00
/* use a 128 bit session key */
# define DCERPC_SCHANNEL_128 (1<<11)
2004-06-06 07:14:10 +00:00
# define DCERPC_AUTH_OPTIONS (DCERPC_SEAL|DCERPC_SIGN|DCERPC_SCHANNEL_ANY)
2004-02-10 10:22:12 +00:00
2004-09-02 10:45:58 +00:00
/* check incoming pad bytes */
# define DCERPC_DEBUG_PAD_CHECK (1<<12)
2004-09-06 10:29:18 +00:00
/* set LIBNDR_FLAG_REF_ALLOC flag when decoding NDR */
# define DCERPC_NDR_REF_ALLOC (1<<13)
2003-11-23 13:44:19 +00:00
/*
this is used to find pointers to calls
*/
struct dcerpc_interface_call {
const char * name ;
size_t struct_size ;
NTSTATUS ( * ndr_push ) ( struct ndr_push * , int , void * ) ;
NTSTATUS ( * ndr_pull ) ( struct ndr_pull * , int , void * ) ;
void ( * ndr_print ) ( struct ndr_print * , const char * , int , void * ) ;
} ;
2003-11-28 05:20:11 +00:00
struct dcerpc_endpoint_list {
2004-05-25 16:24:13 +00:00
uint32_t count ;
2004-01-22 01:12:43 +00:00
const char * const * names ;
2003-11-28 05:20:11 +00:00
} ;
2003-11-23 13:44:19 +00:00
struct dcerpc_interface_table {
const char * name ;
2003-11-27 05:34:28 +00:00
const char * uuid ;
2004-05-25 16:24:13 +00:00
uint32_t if_version ;
2004-08-12 19:32:16 +00:00
const char * helpstring ;
2004-05-25 16:24:13 +00:00
uint32_t num_calls ;
2003-11-23 13:44:19 +00:00
const struct dcerpc_interface_call * calls ;
2003-11-28 05:20:11 +00:00
const struct dcerpc_endpoint_list * endpoints ;
2003-11-23 13:44:19 +00:00
} ;
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 ;
const char * host ;
const char * * options ;
2004-05-25 16:24:13 +00:00
uint32_t flags ;
2003-12-15 03:29:55 +00:00
} ;
2004-08-30 03:10:43 +00:00
enum rpc_request_state {
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 ;
uint_t flags ;
uint32_t fault_code ;
/* use by the ndr level async recv call */
struct rpc_request_ndr {
NTSTATUS ( * ndr_push ) ( struct ndr_push * , int , void * ) ;
NTSTATUS ( * ndr_pull ) ( struct ndr_pull * , int , void * ) ;
void * struct_ptr ;
size_t struct_size ;
TALLOC_CTX * mem_ctx ;
} ndr ;
2004-09-02 12:03:16 +00:00
struct {
void ( * callback ) ( struct rpc_request * ) ;
void * private ;
} async ;
2004-08-30 03:10:43 +00:00
} ;