Removed version number from file header.
[kamenim/samba.git] / source3 / include / rpc_misc.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    
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 #include "ntdomain.h"
24 #include "rpc_dce.h"
25
26 #ifndef _RPC_MISC_H /* _RPC_MISC_H */
27 #define _RPC_MISC_H 
28
29
30
31 /* well-known RIDs - Relative IDs */
32
33 /* RIDs - Well-known users ... */
34 #define DOMAIN_USER_RID_ADMIN          (0x000001F4L)
35 #define DOMAIN_USER_RID_GUEST          (0x000001F5L)
36
37 /* RIDs - well-known groups ... */
38 #define DOMAIN_GROUP_RID_ADMINS        (0x00000200L)
39 #define DOMAIN_GROUP_RID_USERS         (0x00000201L)
40 #define DOMAIN_GROUP_RID_GUESTS        (0x00000202L)
41
42 /* RIDs - well-known aliases ... */
43 #define BUILTIN_ALIAS_RID_ADMINS        (0x00000220L)
44 #define BUILTIN_ALIAS_RID_USERS         (0x00000221L)
45 #define BUILTIN_ALIAS_RID_GUESTS        (0x00000222L)
46 #define BUILTIN_ALIAS_RID_POWER_USERS   (0x00000223L)
47
48 #define BUILTIN_ALIAS_RID_ACCOUNT_OPS   (0x00000224L)
49 #define BUILTIN_ALIAS_RID_SYSTEM_OPS    (0x00000225L)
50 #define BUILTIN_ALIAS_RID_PRINT_OPS     (0x00000226L)
51 #define BUILTIN_ALIAS_RID_BACKUP_OPS    (0x00000227L)
52
53 #define BUILTIN_ALIAS_RID_REPLICATOR    (0x00000228L)
54
55 /*
56  * Masks for mappings between unix uid and gid types and
57  * NT RIDS.
58  */
59
60 /* Take the bottom bit. */
61 #define RID_TYPE_MASK 1
62 #define RID_MULTIPLIER 2
63
64 /* The two common types. */
65 #define USER_RID_TYPE 0
66 #define GROUP_RID_TYPE 1
67
68 /* ENUM_HND */
69 typedef struct enum_hnd_info
70 {
71         uint32 ptr_hnd;          /* pointer to enumeration handle */
72         uint32 handle;           /* enumeration handle */
73
74 } ENUM_HND;
75
76 /* LOOKUP_LEVEL - switch value */
77 typedef struct lookup_level_info
78 {
79   uint16 value;
80
81 } LOOKUP_LEVEL;
82
83 /* DOM_SID2 - security id */
84 typedef struct sid_info_2
85 {
86         uint32 num_auths; /* length, bytes, including length of len :-) */
87
88         DOM_SID sid;
89
90 } DOM_SID2;
91
92 /* STRHDR - string header */
93 typedef struct header_info
94 {
95   uint16 str_str_len;
96   uint16 str_max_len;
97   uint32 buffer; /* non-zero */
98
99 } STRHDR;
100
101 /* UNIHDR - unicode string header */
102 typedef struct unihdr_info
103 {
104   uint16 uni_str_len;
105   uint16 uni_max_len;
106   uint32 buffer; /* usually has a value of 4 */
107
108 } UNIHDR;
109
110 /* UNIHDR2 - unicode string header and undocumented buffer */
111 typedef struct unihdr2_info
112 {
113   UNIHDR unihdr;
114   uint32 buffer; /* 32 bit buffer pointer */
115
116 } UNIHDR2;
117
118 /* clueless as to what maximum length should be */
119 #define MAX_UNISTRLEN 256
120 #define MAX_STRINGLEN 256
121 #define MAX_BUFFERLEN 512
122
123 /* UNISTR - unicode string size and buffer */
124 typedef struct unistr_info
125 {
126   /* unicode characters. ***MUST*** be little-endian. ***MUST*** be null-terminated */
127   uint16 *buffer;
128 } UNISTR;
129
130 /* BUFHDR - buffer header */
131 typedef struct bufhdr_info
132 {
133   uint32 buf_max_len;
134   uint32 buf_len;
135
136 } BUFHDR;
137
138 /* BUFFER2 - unicode string, size (in uint8 ascii chars) and buffer */
139 /* pathetic.  some stupid team of \PIPE\winreg writers got the concept */
140 /* of a unicode string different from the other \PIPE\ writers */
141 typedef struct buffer2_info
142 {
143   uint32 buf_max_len;
144   uint32 undoc;
145   uint32 buf_len;
146   /* unicode characters. ***MUST*** be little-endian. **NOT** necessarily null-terminated */
147   uint16 *buffer;
148
149 } BUFFER2;
150
151 /* BUFFER3 */
152 typedef struct buffer3_info
153 {
154   uint32 buf_max_len;
155   uint8  *buffer; /* Data */
156   uint32 buf_len;
157
158 } BUFFER3;
159
160 /* BUFFER5 */
161 typedef struct buffer5_info
162 {
163   uint32 buf_len;
164   uint16 *buffer; /* data */
165 } BUFFER5;
166
167 /* UNISTR2 - unicode string size (in uint16 unicode chars) and buffer */
168 typedef struct unistr2_info
169 {
170   uint32 uni_max_len;
171   uint32 undoc;
172   uint32 uni_str_len;
173   /* unicode characters. ***MUST*** be little-endian. 
174      **must** be null-terminated and the uni_str_len should include
175      the NULL character */
176   uint16 *buffer;
177
178 } UNISTR2;
179
180 /* STRING2 - string size (in uint8 chars) and buffer */
181 typedef struct string2_info
182 {
183   uint32 str_max_len;
184   uint32 undoc;
185   uint32 str_str_len;
186   uint8  *buffer; /* uint8 characters. **NOT** necessarily null-terminated */
187
188 } STRING2;
189
190 /* UNISTR3 - XXXX not sure about this structure */
191 typedef struct unistr3_info
192 {
193         uint32 uni_str_len;
194         UNISTR str;
195
196 } UNISTR3;
197
198
199 /* DOM_RID2 - domain RID structure for ntlsa pipe */
200 typedef struct domrid2_info
201 {
202         uint8 type; /* value is SID_NAME_USE enum */
203         uint32 rid;
204         uint32 rid_idx; /* referenced domain index */
205
206 } DOM_RID2;
207
208 /* DOM_RID3 - domain RID structure for samr pipe */
209 typedef struct domrid3_info
210 {
211         uint32 rid;        /* domain-relative (to a SID) id */
212         uint32 type1;      /* value is 0x1 */
213         uint32 ptr_type;   /* undocumented pointer */
214         uint32 type2;      /* value is 0x1 */
215         uint32 unk; /* value is 0x2 */
216
217 } DOM_RID3;
218
219 /* DOM_RID4 - rid + user attributes */
220 typedef struct domrid4_info
221 {
222   uint32 unknown;
223   uint16 attr;
224   uint32 rid;  /* user RID */
225
226 } DOM_RID4;
227
228 /* DOM_CLNT_SRV - client / server names */
229 typedef struct clnt_srv_info
230 {
231   uint32  undoc_buffer; /* undocumented 32 bit buffer pointer */
232   UNISTR2 uni_logon_srv; /* logon server name */
233   uint32  undoc_buffer2; /* undocumented 32 bit buffer pointer */
234   UNISTR2 uni_comp_name; /* client machine name */
235
236 } DOM_CLNT_SRV;
237
238 /* DOM_LOG_INFO - login info */
239 typedef struct log_info
240 {
241   uint32  undoc_buffer; /* undocumented 32 bit buffer pointer */
242   UNISTR2 uni_logon_srv; /* logon server name */
243   UNISTR2 uni_acct_name; /* account name */
244   uint16  sec_chan;      /* secure channel type */
245   UNISTR2 uni_comp_name; /* client machine name */
246
247 } DOM_LOG_INFO;
248
249 /* DOM_CHAL - challenge info */
250 typedef struct chal_info
251 {
252     uchar data[8]; /* credentials */
253 } DOM_CHAL;
254  
255 /* DOM_CREDs - timestamped client or server credentials */
256 typedef struct cred_info
257 {
258     DOM_CHAL challenge; /* credentials */
259     UTIME timestamp;    /* credential time-stamp */
260 } DOM_CRED;
261
262 /* DOM_CLNT_INFO - client info */
263 typedef struct clnt_info
264 {
265   DOM_LOG_INFO login;
266   DOM_CRED     cred;
267
268 } DOM_CLNT_INFO;
269
270 /* DOM_CLNT_INFO2 - client info */
271 typedef struct clnt_info2
272 {
273   DOM_CLNT_SRV login;
274   uint32        ptr_cred;
275   DOM_CRED      cred;
276
277 } DOM_CLNT_INFO2;
278
279 /* DOM_LOGON_ID - logon id */
280 typedef struct logon_info
281 {
282   uint32 low;
283   uint32 high;
284
285 } DOM_LOGON_ID;
286
287 /* OWF INFO */
288 typedef struct owf_info
289 {
290   uint8 data[16];
291
292 } OWF_INFO;
293
294
295 /* DOM_GID - group id + user attributes */
296 typedef struct gid_info
297 {
298   uint32 g_rid;  /* a group RID */
299   uint32 attr;
300
301 } DOM_GID;
302
303 /* POLICY_HND */
304 typedef struct lsa_policy_info
305 {
306         uint32 data1;
307         uint32 data2;
308         uint16 data3;
309         uint16 data4;
310         uint8 data5[8];
311 } POLICY_HND;
312
313 /*
314  * A client connection's state, pipe name, 
315  * user credentials, etc...
316  */
317 typedef struct _cli_auth_fns cli_auth_fns;
318 struct user_creds;
319 struct cli_connection {
320
321         char                    *srv_name;
322         char                    *pipe_name;
323         struct user_creds       usr_creds;
324
325         struct cli_state        *pCli_state;
326
327         cli_auth_fns            *auth;
328
329         void                    *auth_info;
330         void                    *auth_creds;
331 };
332
333
334 /* 
335  * Associate a POLICY_HND with a cli_connection
336  */
337 typedef struct rpc_hnd_node {
338
339         POLICY_HND              hnd;
340         struct cli_connection   *cli;
341
342 } RPC_HND_NODE;
343
344 typedef struct uint64_s
345 {
346         uint32 low;
347         uint32 high;
348 } UINT64_S;
349
350 /* BUFHDR2 - another buffer header, with info level */
351 typedef struct bufhdr2_info
352 {
353         uint32 info_level;
354         uint32 length;          /* uint8 chars */
355         uint32 buffer;
356
357 }
358 BUFHDR2;
359
360 /* BUFFER4 - simple length and buffer */
361 typedef struct buffer4_info
362 {
363         uint32 buf_len;
364         uint8 buffer[MAX_BUFFERLEN];
365
366 }
367 BUFFER4;
368
369
370 #endif /* _RPC_MISC_H */