More rpcclient merge issues:
[samba.git] / source / include / ntdomain.h
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    SMB parameters and setup
5    Copyright (C) Andrew Tridgell 1992-1997
6    Copyright (C) Luke Kenneth Casson Leighton 1996-1997
7    Copyright (C) Paul Ashton 1997
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 2 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, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #ifndef _NT_DOMAIN_H /* _NT_DOMAIN_H */
25 #define _NT_DOMAIN_H 
26
27
28 /* dce/rpc support */
29 #include "rpc_dce.h"
30
31 /* miscellaneous structures / defines */
32 #include "rpc_misc.h"
33
34 #include "rpc_creds.h"
35
36 /*
37  * A bunch of stuff that was put into smb.h
38  * in the NTDOM branch - it didn't belong there.
39  */
40
41 #define CHECK_STRUCT(data) \
42 { \
43         if ((data)->struct_start != 0xfefefefe || \
44             (data)->struct_end != 0xdcdcdcdc) \
45         { \
46                 DEBUG(0,("uninitialised structure (%s, %d)\n", \
47                 FUNCTION_MACRO, __LINE__)); \
48                 sleep(30); \
49         } \
50 }
51
52  
53 typedef struct _prs_struct 
54 {
55         BOOL io; /* parsing in or out of data stream */
56         /* 
57          * If the (incoming) data is big-endian. On output we are
58          * always little-endian.
59          */ 
60         BOOL bigendian_data;
61         uint8 align; /* data alignment */
62         BOOL is_dynamic; /* Do we own this memory or not ? */
63         uint32 data_offset; /* Current working offset into data. */
64         uint32 buffer_size; /* Current allocated size of the buffer. */
65         uint32 grow_size; /* size requested via prs_grow() calls */
66         char *data_p; /* The buffer itself. */
67 } prs_struct;
68
69 /*
70  * Defines for io member of prs_struct.
71  */
72
73 #define MARSHALL 0
74 #define UNMARSHALL 1
75
76 #define MARSHALLING(ps) (!(ps)->io)
77 #define UNMARSHALLING(ps) ((ps)->io)
78
79 typedef struct _output_data {
80         /*
81          * Raw RPC output data. This does not include RPC headers or footers.
82          */
83         prs_struct rdata;
84
85         /* The amount of data sent from the current rdata struct. */
86         uint32 data_sent_length;
87
88         /*
89          * The current PDU being returned. This inclues
90          * headers, data and authentication footer.
91          */
92         unsigned char current_pdu[MAX_PDU_FRAG_LEN];
93
94         /* The amount of data in the current_pdu buffer. */
95         uint32 current_pdu_len;
96
97         /* The amount of data sent from the current PDU. */
98         uint32 current_pdu_sent;
99 } output_data;
100
101 typedef struct _input_data {
102     /*
103      * This is the current incoming pdu. The data here
104      * is collected via multiple writes until a complete
105      * pdu is seen, then the data is copied into the in_data
106      * structure. The maximum size of this is 0x1630 (MAX_PDU_FRAG_LEN).
107      */
108     unsigned char current_in_pdu[MAX_PDU_FRAG_LEN];
109
110     /*
111      * The amount of data needed to complete the in_pdu.
112      * If this is zero, then we are at the start of a new
113      * pdu.
114      */
115     uint32 pdu_needed_len;
116
117     /*
118      * The amount of data received so far in the in_pdu.
119      * If this is zero, then we are at the start of a new
120      * pdu.
121      */
122     uint32 pdu_received_len;
123
124     /*
125      * This is the collection of input data with all
126      * the rpc headers and auth footers removed.
127      * The maximum length of this (1Mb) is strictly enforced.
128      */
129     prs_struct data;
130 } input_data;
131
132 struct msrpc_state
133 {
134         fstring pipe_name;
135         struct user_creds usr;
136         struct ntdom_info nt;
137
138         int fd;
139         BOOL redirect;
140         BOOL initialised;
141         char *inbuf;
142         char *outbuf;
143
144         uint32 pid;
145 };
146
147 typedef struct pipes_struct
148 {
149         struct pipes_struct *next, *prev;
150         int pnum;
151         connection_struct *conn;
152         uint16 vuid;
153         BOOL open; /* open connection */
154         uint16 device_state;
155         uint16 priority;
156         fstring name;
157         fstring pipe_srv_name;
158
159         RPC_HDR hdr; /* Incoming RPC header. */
160         RPC_HDR_REQ hdr_req; /* Incoming request header. */
161
162         uint32 ntlmssp_chal_flags; /* Client challenge flags. */
163         BOOL ntlmssp_auth_requested; /* If the client wanted authenticated rpc. */
164         BOOL ntlmssp_auth_validated; /* If the client *got* authenticated rpc. */
165         unsigned char challenge[8];
166         unsigned char ntlmssp_hash[258];
167         uint32 ntlmssp_seq_num;
168
169         /*
170          * Windows user info.
171          */
172         fstring user_name;
173         fstring domain;
174         fstring wks;
175
176         /*
177          * Unix user name and credentials.
178          */
179
180         fstring pipe_user_name;
181         struct current_user pipe_user;
182
183         /*
184          * Set to true when an RPC bind has been done on this pipe.
185          */
186         
187         BOOL pipe_bound;
188         
189         /*
190          * Set to true when we should return fault PDU's for everything.
191          */
192         
193         BOOL fault_state;
194         
195         /*
196          * Struct to deal with multiple pdu inputs.
197          */
198
199         input_data in_data;
200
201         /*
202          * Struct to deal with multiple pdu outputs.
203          */
204
205         output_data out_data;
206
207         /* When replying to an SMBtrans, this is the maximum amount of
208            data that can be sent in the initial reply. */
209         int max_trans_reply;
210
211         /* remote, server-side rpc redirection */
212         struct msrpc_state *m;
213
214 } pipes_struct;
215
216 struct api_struct
217 {  
218   char *name;
219   uint8 opnum;
220   BOOL (*fn) (pipes_struct *);
221 };
222
223 typedef struct
224 {  
225         uint32 rid;
226         char *name;
227
228 } rid_name;
229
230 struct acct_info
231 {
232     fstring acct_name; /* account name */
233     uint32 smb_userid; /* domain-relative RID */
234 };
235
236 struct cli_connection;
237
238 typedef struct cli_auth_fns
239 {
240         /* these three will do for now.  they *should* match with server-side */
241         BOOL (*create_bind_req) (struct cli_connection *, prs_struct *,
242                                  uint32, RPC_IFACE *, RPC_IFACE *);
243         BOOL (*decode_bind_resp) (struct cli_connection *, prs_struct *);
244         BOOL (*create_bind_cont) (struct cli_connection *, prs_struct *,
245                                   uint32);
246         /* creates an authenticated PDU */
247         BOOL (*cli_create_pdu) (struct cli_connection *, uint8,
248                                 prs_struct *, int, int *,
249                                 prs_struct *, uint8 *);
250         /* decodes an authenticated PDU */
251         BOOL (*cli_decode_pdu) (struct cli_connection *, prs_struct *,
252                                 int, int);
253
254 }
255 cli_auth_fns;
256
257
258 /* security descriptor structures */
259 #include "rpc_secdes.h"
260
261 /* different dce/rpc pipes */
262 #include "rpc_lsa.h"
263 #include "rpc_netlogon.h"
264 #include "rpc_reg.h"
265 #if OLD_NTDOMAIN
266 #include "rpc_samr_old.h"
267 #else
268 #include "rpc_samr.h"
269 #endif
270 #include "rpc_srvsvc.h"
271 #include "rpc_wkssvc.h"
272 #include "rpc_spoolss.h"
273 #include "rpc_dfs.h"
274 #include "sids.h"
275
276 #endif /* _NT_DOMAIN_H */