s3: Add "client_id" to pipes_struct
[nivanova/samba-autobuild/.git] / source3 / include / ntdomain.h
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB parameters and setup
4    Copyright (C) Andrew Tridgell 1992-1997
5    Copyright (C) Luke Kenneth Casson Leighton 1996-1997
6    Copyright (C) Paul Ashton 1997
7    Copyright (C) Jeremy Allison 2000-2004
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #ifndef _NT_DOMAIN_H /* _NT_DOMAIN_H */
24 #define _NT_DOMAIN_H 
25
26 /*
27  * A bunch of stuff that was put into smb.h
28  * in the NTDOM branch - it didn't belong there.
29  */
30
31 typedef struct _output_data {
32         /*
33          * Raw RPC output data. This does not include RPC headers or footers.
34          */
35         DATA_BLOB rdata;
36
37         /* The amount of data sent from the current rdata struct. */
38         uint32 data_sent_length;
39
40         /*
41          * The current fragment being returned. This inclues
42          * headers, data and authentication footer.
43          */
44         DATA_BLOB frag;
45
46         /* The amount of data sent from the current PDU. */
47         uint32 current_pdu_sent;
48 } output_data;
49
50 typedef struct _input_data {
51         /*
52          * This is the current incoming pdu. The data here
53          * is collected via multiple writes until a complete
54          * pdu is seen, then the data is copied into the in_data
55          * structure. The maximum size of this is 0x1630 (RPC_MAX_PDU_FRAG_LEN).
56          * If length is zero, then we are at the start of a new
57          * pdu.
58          */
59         DATA_BLOB pdu;
60
61         /*
62          * The amount of data needed to complete the in_pdu.
63          * If this is zero, then we are at the start of a new
64          * pdu.
65          */
66         uint32 pdu_needed_len;
67
68         /*
69          * This is the collection of input data with all
70          * the rpc headers and auth footers removed.
71          * The maximum length of this (1Mb) is strictly enforced.
72          */
73         DATA_BLOB data;
74
75 } input_data;
76
77 struct handle_list;
78
79 typedef struct pipe_rpc_fns {
80
81         struct pipe_rpc_fns *next, *prev;
82
83         /* RPC function table associated with the current rpc_bind (associated by context) */
84
85         const struct api_struct *cmds;
86         int n_cmds;
87         uint32 context_id;
88
89 } PIPE_RPC_FNS;
90
91 /*
92  * Different auth types we support.
93  * Can't keep in sync with wire values as spnego wraps different auth methods.
94  */
95
96 enum pipe_auth_type_spnego {
97         PIPE_AUTH_TYPE_SPNEGO_NONE = 0,
98         PIPE_AUTH_TYPE_SPNEGO_NTLMSSP,
99         PIPE_AUTH_TYPE_SPNEGO_KRB5
100 };
101
102 struct gse_context;
103
104 /* auth state for all bind types. */
105
106 struct pipe_auth_data {
107         enum dcerpc_AuthType auth_type;
108         enum pipe_auth_type_spnego spnego_type; /* used by server only */
109         enum dcerpc_AuthLevel auth_level;
110
111         union {
112                 struct schannel_state *schannel_auth;
113                 struct auth_ntlmssp_state *auth_ntlmssp_state;
114                 struct gse_context *gssapi_state;
115                 struct spnego_context *spnego_state;
116         } a_u;
117
118         /* Only the client code uses these 3 for now */
119         char *domain;
120         char *user_name;
121         DATA_BLOB user_session_key;
122
123         void (*auth_data_free_func)(struct pipe_auth_data *);
124 };
125
126 /*
127  * DCE/RPC-specific samba-internal-specific handling of data on
128  * NamedPipes.
129  */
130
131 struct pipes_struct {
132         struct pipes_struct *next, *prev;
133
134         struct client_address *client_id;
135
136         struct auth_serversupplied_info *server_info;
137         struct messaging_context *msg_ctx;
138
139         struct ndr_syntax_id syntax;
140
141         /* linked list of rpc dispatch tables associated 
142            with the open rpc contexts */
143
144         PIPE_RPC_FNS *contexts;
145
146         struct pipe_auth_data auth;
147
148         /*
149          * Set to true when an RPC bind has been done on this pipe.
150          */
151
152         bool pipe_bound;
153
154         /*
155          * Set to true when we should return fault PDU's for everything.
156          */
157
158         bool fault_state;
159
160         /*
161          * Set to true when we should return fault PDU's for a bad handle.
162          */
163
164         bool bad_handle_fault_state;
165
166         /*
167          * Set to true when the backend does not support a call.
168          */
169
170         bool rng_fault_state;
171
172         /*
173          * Set to RPC_BIG_ENDIAN when dealing with big-endian PDU's
174          */
175
176         bool endian;
177
178         /*
179          * Struct to deal with multiple pdu inputs.
180          */
181
182         input_data in_data;
183
184         /*
185          * Struct to deal with multiple pdu outputs.
186          */
187
188         output_data out_data;
189
190         /* This context is used for PDU data and is freed between each pdu.
191                 Don't use for pipe state storage. */
192         TALLOC_CTX *mem_ctx;
193
194         /* handle database to use on this pipe. */
195         struct handle_list *pipe_handles;
196
197         /* call id retrieved from the pdu header */
198         uint32_t call_id;
199
200         /* operation number retrieved from the rpc header */
201         uint16_t opnum;
202
203         /* private data for the interface implementation */
204         void *private_data;
205
206 };
207
208 struct api_struct {  
209         const char *name;
210         uint8 opnum;
211         bool (*fn) (struct pipes_struct *);
212 };
213
214 #endif /* _NT_DOMAIN_H */