more merging
[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 typedef struct _prs_struct 
42 {
43         BOOL io; /* parsing in or out of data stream */
44         /* 
45          * If the (incoming) data is big-endian. On output we are
46          * always little-endian.
47          */ 
48         BOOL bigendian_data;
49         uint8 align; /* data alignment */
50         BOOL is_dynamic; /* Do we own this memory or not ? */
51         uint32 data_offset; /* Current working offset into data. */
52         uint32 buffer_size; /* Current size of the buffer. */
53         char *data_p; /* The buffer itself. */
54 } prs_struct;
55
56 /*
57  * Defines for io member of prs_struct.
58  */
59
60 #define MARSHALL 0
61 #define UNMARSHALL 1
62
63 #define MARSHALLING(ps) (!(ps)->io)
64 #define UNMARSHALLING(ps) ((ps)->io)
65
66 typedef struct _output_data {
67         /*
68          * Raw RPC output data. This does not include RPC headers or footers.
69          */
70         prs_struct rdata;
71
72         /* The amount of data sent from the current rdata struct. */
73         uint32 data_sent_length;
74
75         /*
76          * The current PDU being returned. This inclues
77          * headers, data and authentication footer.
78          */
79         unsigned char current_pdu[MAX_PDU_FRAG_LEN];
80
81         /* The amount of data in the current_pdu buffer. */
82         uint32 current_pdu_len;
83
84         /* The amount of data sent from the current PDU. */
85         uint32 current_pdu_sent;
86 } output_data;
87
88 typedef struct _input_data {
89     /*
90      * This is the current incoming pdu. The data here
91      * is collected via multiple writes until a complete
92      * pdu is seen, then the data is copied into the in_data
93      * structure. The maximum size of this is 0x1630 (MAX_PDU_FRAG_LEN).
94      */
95     unsigned char current_in_pdu[MAX_PDU_FRAG_LEN];
96
97     /*
98      * The amount of data needed to complete the in_pdu.
99      * If this is zero, then we are at the start of a new
100      * pdu.
101      */
102     uint32 pdu_needed_len;
103
104     /*
105      * The amount of data received so far in the in_pdu.
106      * If this is zero, then we are at the start of a new
107      * pdu.
108      */
109     uint32 pdu_received_len;
110
111     /*
112      * This is the collection of input data with all
113      * the rpc headers and auth footers removed.
114      * The maximum length of this (1Mb) is strictly enforced.
115      */
116     prs_struct data;
117 } input_data;
118
119 struct msrpc_state
120 {
121         fstring pipe_name;
122         struct user_creds usr;
123         struct ntdom_info nt;
124
125         int fd;
126         BOOL redirect;
127         BOOL initialised;
128         char *inbuf;
129         char *outbuf;
130
131         uint32 pid;
132 };
133
134 typedef struct pipes_struct
135 {
136         struct pipes_struct *next, *prev;
137         int pnum;
138         connection_struct *conn;
139         uint16 vuid;
140         BOOL open; /* open connection */
141         uint16 device_state;
142         uint16 priority;
143         fstring name;
144         fstring pipe_srv_name;
145
146         RPC_HDR hdr; /* Incoming RPC header. */
147         RPC_HDR_REQ hdr_req; /* Incoming request header. */
148
149         uint32 ntlmssp_chal_flags; /* Client challenge flags. */
150         BOOL ntlmssp_auth_requested; /* If the client wanted authenticated rpc. */
151         BOOL ntlmssp_auth_validated; /* If the client *got* authenticated rpc. */
152         unsigned char challenge[8];
153         unsigned char ntlmssp_hash[258];
154         uint32 ntlmssp_seq_num;
155
156         /*
157          * Windows user info.
158          */
159         fstring user_name;
160         fstring domain;
161         fstring wks;
162
163         /*
164          * Unix user name and credentials.
165          */
166         fstring unix_user_name;
167         uid_t uid;
168         gid_t gid;
169
170     /*
171      * Set to true when an RPC bind has been done on this pipe.
172      */
173
174     BOOL pipe_bound;
175
176     /*
177      * Set to true when we should return fault PDU's for everything.
178      */
179
180     BOOL fault_state;
181
182         /*
183          * Struct to deal with multiple pdu inputs.
184          */
185
186         input_data in_data;
187
188         /*
189          * Struct to deal with multiple pdu outputs.
190          */
191
192         output_data out_data;
193
194         /* When replying to an SMBtrans, this is the maximum amount of
195            data that can be sent in the initial reply. */
196         int max_trans_reply;
197
198         /* remote, server-side rpc redirection */
199         struct msrpc_state *m;
200
201 } pipes_struct;
202
203 struct api_struct
204 {  
205   char *name;
206   uint8 opnum;
207   BOOL (*fn) (prs_struct*, prs_struct*);
208 };
209
210 typedef struct
211 {  
212         uint32 rid;
213         char *name;
214
215 } rid_name;
216
217 struct acct_info
218 {
219     fstring acct_name; /* account name */
220     uint32 smb_userid; /* domain-relative RID */
221 };
222
223 /* security descriptor structures */
224 #include "rpc_secdes.h"
225
226 /* different dce/rpc pipes */
227 #include "rpc_lsa.h"
228 #include "rpc_netlogon.h"
229 #include "rpc_reg.h"
230 #if OLD_NTDOMAIN
231 #include "rpc_samr_old.h"
232 #else
233 #include "rpc_samr.h"
234 #endif
235 #include "rpc_srvsvc.h"
236 #include "rpc_wkssvc.h"
237 #include "rpc_spoolss.h"
238 #include "sids.h"
239
240 #endif /* _NT_DOMAIN_H */