r874: This patch is a pile of work on NTLMSSP:
[nivanova/samba-autobuild/.git] / source4 / librpc / rpc / dcerpc.h
1 /* 
2    Unix SMB/CIFS implementation.
3    DCERPC interface structures
4
5    Copyright (C) Tim Potter 2003
6    Copyright (C) Andrew Tridgell 2003
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 enum dcerpc_transport_t {NCACN_NP, NCACN_IP_TCP};
24
25 /*
26   this defines a generic security context for signed/sealed dcerpc pipes.
27 */
28 struct dcerpc_security {
29         void *private;
30         NTSTATUS (*unseal_packet)(struct dcerpc_security *, 
31                                   TALLOC_CTX *mem_ctx, 
32                                   uchar *data, size_t length, DATA_BLOB *sig);
33         NTSTATUS (*check_packet)(struct dcerpc_security *, 
34                                  TALLOC_CTX *mem_ctx, 
35                                  const uchar *data, size_t length, const DATA_BLOB *sig);
36         NTSTATUS (*seal_packet)(struct dcerpc_security *, 
37                                 TALLOC_CTX *mem_ctx, 
38                                 uchar *data, size_t length, DATA_BLOB *sig);
39         NTSTATUS (*sign_packet)(struct dcerpc_security *, 
40                                 TALLOC_CTX *mem_ctx, 
41                                 const uchar *data, size_t length, DATA_BLOB *sig);
42         NTSTATUS (*session_key)(struct dcerpc_security *, DATA_BLOB *session_key);
43         void (*security_end)(struct dcerpc_security *);
44 };
45
46
47 struct dcerpc_pipe {
48         TALLOC_CTX *mem_ctx;
49         int reference_count;
50         uint32 call_id;
51         uint32 srv_max_xmit_frag;
52         uint32 srv_max_recv_frag;
53         unsigned flags;
54         struct dcerpc_security *security_state;
55         struct dcerpc_auth *auth_info;
56         const char *binding_string;
57         
58         struct dcerpc_transport {
59                 enum dcerpc_transport_t transport;
60                 void *private;
61                 NTSTATUS (*full_request)(struct dcerpc_pipe *, 
62                                          TALLOC_CTX *, DATA_BLOB *, DATA_BLOB *);
63                 NTSTATUS (*secondary_request)(struct dcerpc_pipe *, TALLOC_CTX *, DATA_BLOB *);
64                 NTSTATUS (*initial_request)(struct dcerpc_pipe *, TALLOC_CTX *, DATA_BLOB *);
65                 NTSTATUS (*shutdown_pipe)(struct dcerpc_pipe *);
66                 const char *(*peer_name)(struct dcerpc_pipe *);
67         } transport;
68
69         /* the last fault code from a DCERPC fault */
70         uint32 last_fault_code;
71 };
72
73 /* dcerpc pipe flags */
74 #define DCERPC_DEBUG_PRINT_IN  (1<<0)
75 #define DCERPC_DEBUG_PRINT_OUT (1<<1)
76 #define DCERPC_DEBUG_PRINT_BOTH (DCERPC_DEBUG_PRINT_IN | DCERPC_DEBUG_PRINT_OUT)
77
78 #define DCERPC_DEBUG_VALIDATE_IN  4
79 #define DCERPC_DEBUG_VALIDATE_OUT 8
80 #define DCERPC_DEBUG_VALIDATE_BOTH (DCERPC_DEBUG_VALIDATE_IN | DCERPC_DEBUG_VALIDATE_OUT)
81
82 #define DCERPC_SIGN            16
83 #define DCERPC_SEAL            32
84
85 #define DCERPC_PUSH_BIGENDIAN   64
86 #define DCERPC_PULL_BIGENDIAN  128
87
88 #define DCERPC_SCHANNEL        256
89
90 /*
91   this is used to find pointers to calls
92 */
93 struct dcerpc_interface_call {
94         const char *name;
95         size_t struct_size;
96         NTSTATUS (*ndr_push)(struct ndr_push *, int , void *);
97         NTSTATUS (*ndr_pull)(struct ndr_pull *, int , void *);
98         void (*ndr_print)(struct ndr_print *, const char *, int, void *);       
99 };
100
101 struct dcerpc_endpoint_list {
102         uint32 count;
103         const char * const *names;
104 };
105
106 struct dcerpc_interface_table {
107         const char *name;
108         const char *uuid;
109         uint32 if_version;
110         uint32 num_calls;
111         const struct dcerpc_interface_call *calls;
112         const struct dcerpc_endpoint_list *endpoints;
113 };
114
115
116 /* this describes a binding to a particular transport/pipe */
117 struct dcerpc_binding {
118         enum dcerpc_transport_t transport;
119         const char *host;
120         const char **options;
121         uint32 flags;
122 };