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