r6221: format cleanup (got tied of looking for related structures)
[Samba.git] / source / include / rpc_misc.h
blob3cece400db6a9a42dc286d7219048285ee638c30
1 /*
2 Unix SMB/CIFS implementation.
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) Gerald (Jerry) Carter 2005
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.
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.
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.
24 #include "ntdomain.h"
25 #include "rpc_dce.h"
27 #ifndef _RPC_MISC_H /* _RPC_MISC_H */
28 #define _RPC_MISC_H
30 #define SMB_RPC_INTERFACE_VERSION 1
31 #define PRS_POINTER_CAST BOOL (*)(const char*, prs_struct*, int, void*)
33 enum unistr2_term_codes { UNI_FLAGS_NONE = 0, UNI_STR_TERMINATE = 1, UNI_MAXLEN_TERMINATE = 2, UNI_BROKEN_NON_NULL = 3 };
37 /**********************************************************************
38 * well-known RIDs - Relative IDs
39 **********************************************************************/
41 /* RIDs - Well-known users ... */
42 #define DOMAIN_USER_RID_ADMIN (0x000001F4L)
43 #define DOMAIN_USER_RID_GUEST (0x000001F5L)
44 #define DOMAIN_USER_RID_KRBTGT (0x000001F6L)
46 /* RIDs - well-known groups ... */
47 #define DOMAIN_GROUP_RID_ADMINS (0x00000200L)
48 #define DOMAIN_GROUP_RID_USERS (0x00000201L)
49 #define DOMAIN_GROUP_RID_GUESTS (0x00000202L)
50 #define DOMAIN_GROUP_RID_COMPUTERS (0x00000203L)
52 #define DOMAIN_GROUP_RID_CONTROLLERS (0x00000204L)
53 #define DOMAIN_GROUP_RID_CERT_ADMINS (0x00000205L)
54 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS (0x00000206L)
55 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS (0x00000207L)
57 /* is the following the right number? I bet it is --simo
58 #define DOMAIN_GROUP_RID_POLICY_ADMINS (0x00000208L)
61 /* RIDs - well-known aliases ... */
62 #define BUILTIN_ALIAS_RID_ADMINS (0x00000220L)
63 #define BUILTIN_ALIAS_RID_USERS (0x00000221L)
64 #define BUILTIN_ALIAS_RID_GUESTS (0x00000222L)
65 #define BUILTIN_ALIAS_RID_POWER_USERS (0x00000223L)
67 #define BUILTIN_ALIAS_RID_ACCOUNT_OPS (0x00000224L)
68 #define BUILTIN_ALIAS_RID_SYSTEM_OPS (0x00000225L)
69 #define BUILTIN_ALIAS_RID_PRINT_OPS (0x00000226L)
70 #define BUILTIN_ALIAS_RID_BACKUP_OPS (0x00000227L)
72 #define BUILTIN_ALIAS_RID_REPLICATOR (0x00000228L)
73 #define BUILTIN_ALIAS_RID_RAS_SERVERS (0x00000229L)
74 #define BUILTIN_ALIAS_RID_PRE_2K_ACCESS (0x0000022aL)
77 /**********************************************************************
78 * Masks for mappings between unix uid and gid types and
79 * NT RIDS.
80 **********************************************************************/
82 #define BASE_RID (0x000003E8L)
84 /* Take the bottom bit. */
85 #define RID_TYPE_MASK 1
86 #define RID_MULTIPLIER 2
88 /* The two common types. */
89 #define USER_RID_TYPE 0
90 #define GROUP_RID_TYPE 1
94 /**********************************************************************
95 * RPC policy handle used pretty much everywhere
96 **********************************************************************/
98 typedef struct {
99 uint32 ptr_hnd; /* pointer to enumeration handle */
100 uint32 handle; /* enumeration handle */
101 } ENUM_HND;
105 /**********************************************************************
106 * RPC policy handle used pretty much everywhere
107 **********************************************************************/
109 typedef struct {
110 uint32 data1;
111 uint32 data2;
112 uint16 data3;
113 uint16 data4;
114 uint8 data5[8];
115 #ifdef __INSURE__
117 /* To prevent the leakage of policy handles mallocate a bit of
118 memory when a policy handle is created and free it when the
119 handle is closed. This should cause Insure to flag an error
120 when policy handles are overwritten or fall out of scope without
121 being freed. */
123 char *marker;
124 #endif
125 } POLICY_HND;
128 /**********************************************************************
129 * Buffer Headers -- use by SEC_DESC_BUF in winreg and netlogon code
130 **********************************************************************/
132 typedef struct {
133 uint32 buf_max_len;
134 uint32 buf_len;
135 } BUFHDR;
137 typedef struct {
138 uint32 info_level;
139 uint32 length; /* uint8 chars */
140 uint32 buffer;
141 } BUFHDR2;
143 typedef struct {
144 uint32 size;
145 uint32 buffer;
146 } BUFHDR4;
149 /**********************************************************************
150 * Buffers use by winreg
151 **********************************************************************/
154 OLD COMMENT:
155 BUFFER2 - unicode string, size (in uint8 ascii chars) and buffer
156 pathetic. some stupid team of \PIPE\winreg writers got the concept
157 of a unicode string different from the other \PIPE\ writers
159 NEW COMMENT:
160 buffer used by \winreg\ calls to fill in arbitrary REG_XXX values.
161 It *may* look like a UNISTR2 but it is *not*. This is not a goof
162 by the winreg developers. It is a generic buffer
165 typedef struct {
166 uint32 buf_max_len;
167 uint32 offset;
168 uint32 buf_len;
169 uint16 *buffer;
170 } REGVAL_BUFFER;
172 typedef struct buffer3_info {
173 uint32 buf_max_len;
174 uint8 *buffer; /* Data */
175 uint32 buf_len;
176 } BUFFER3;
180 /**********************************************************************
181 * Buffers use by spoolss
182 **********************************************************************/
184 typedef struct {
185 uint32 buf_len;
186 uint16 *buffer; /* data */
187 } BUFFER5;
191 /**********************************************************************
192 * Buffers use by netlogon
193 **********************************************************************/
195 typedef struct {
196 uint32 buf_len;
197 uint8 *buffer;
198 } BUFFER4;
202 /**********************************************************************
203 * Unicode and basic string headers
204 **********************************************************************/
206 typedef struct {
207 uint16 str_str_len;
208 uint16 str_max_len;
209 uint32 buffer; /* non-zero */
210 } STRHDR;
212 typedef struct {
213 uint16 uni_str_len;
214 uint16 uni_max_len;
215 uint32 buffer;
216 } UNIHDR;
218 typedef struct {
219 UNIHDR unihdr;
220 uint32 buffer; /* 32 bit buffer pointer */
221 } UNIHDR2;
225 /**********************************************************************
226 * UNICODE string variations
227 **********************************************************************/
230 typedef struct { /* UNISTR - unicode string size and buffer */
231 uint16 *buffer; /* unicode characters. ***MUST*** be
232 little-endian. ***MUST*** be null-terminated */
233 } UNISTR;
235 typedef struct { /* UNISTR2 - unicode string size (in
236 uint16 unicode chars) and buffer */
237 uint32 uni_max_len;
238 uint32 offset;
239 uint32 uni_str_len;
240 uint16 *buffer; /* unicode characters. ***MUST*** be little-endian.
241 **must** be null-terminated and the uni_str_len
242 should include the NULL character */
243 } UNISTR2;
245 typedef struct { /* UNISTR3 - XXXX not sure about this structure */
246 uint32 uni_str_len;
247 UNISTR str;
249 } UNISTR3;
251 typedef struct { /* UNIHDR + (UNISTR2*) */
252 uint16 length; /* number of bytes not counting NULL terminatation */
253 uint16 size; /* number of bytes including NULL terminatation */
254 UNISTR2 *string;
255 } UNISTR4;
257 typedef struct {
258 uint32 count;
259 UNISTR4 *strings;
260 } UNISTR4_ARRAY;
263 /**********************************************************************
264 * String variations
265 **********************************************************************/
267 typedef struct { /* STRING2 - string size (in uint8 chars) and buffer */
268 uint32 str_max_len;
269 uint32 offset;
270 uint32 str_str_len;
271 uint8 *buffer; /* uint8 characters. **NOT** necessarily null-terminated */
272 } STRING2;
277 /**********************************************************************
278 * Domain SID structures
279 **********************************************************************/
281 typedef struct {
282 uint32 num_auths; /* length, bytes, including length of len :-) */
283 DOM_SID sid;
284 } DOM_SID2;
287 /**********************************************************************
288 * Domain SID structures
289 **********************************************************************/
291 /* DOM_RID2 - domain RID structure for ntlsa pipe */
292 typedef struct {
293 uint8 type; /* value is SID_NAME_USE enum */
294 uint32 rid;
295 uint32 rid_idx; /* referenced domain index */
296 } DOM_RID2;
299 typedef struct { /* DOM_RID3 - domain RID structure for samr pipe */
300 uint32 rid; /* domain-relative (to a SID) id */
301 uint32 type1; /* value is 0x1 */
302 uint32 ptr_type; /* undocumented pointer */
303 uint32 type2; /* value is 0x1 */
304 uint32 unk; /* value is 0x2 */
305 } DOM_RID3;
307 /* DOM_RID4 - rid + user attributes */
308 typedef struct domrid4_info
310 uint32 unknown;
311 uint16 attr;
312 uint32 rid; /* user RID */
313 } DOM_RID4;
315 /* DOM_GID - group id + user attributes */
316 typedef struct {
317 uint32 g_rid; /* a group RID */
318 uint32 attr;
319 } DOM_GID;
321 /**********************************************************************
322 * ????
323 **********************************************************************/
325 /* DOM_CLNT_SRV - client / server names */
326 typedef struct clnt_srv_info
328 uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
329 UNISTR2 uni_logon_srv; /* logon server name */
330 uint32 undoc_buffer2; /* undocumented 32 bit buffer pointer */
331 UNISTR2 uni_comp_name; /* client machine name */
332 } DOM_CLNT_SRV;
334 /* DOM_LOG_INFO - login info */
335 typedef struct log_info
337 uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
338 UNISTR2 uni_logon_srv; /* logon server name */
339 UNISTR2 uni_acct_name; /* account name */
340 uint16 sec_chan; /* secure channel type */
341 UNISTR2 uni_comp_name; /* client machine name */
342 } DOM_LOG_INFO;
344 /* DOM_CHAL - challenge info */
345 typedef struct chal_info
347 uchar data[8]; /* credentials */
348 } DOM_CHAL;
350 /* DOM_CREDs - timestamped client or server credentials */
351 typedef struct cred_info
353 DOM_CHAL challenge; /* credentials */
354 UTIME timestamp; /* credential time-stamp */
355 } DOM_CRED;
357 /* DOM_CLNT_INFO - client info */
358 typedef struct clnt_info
360 DOM_LOG_INFO login;
361 DOM_CRED cred;
362 } DOM_CLNT_INFO;
364 /* DOM_CLNT_INFO2 - client info */
365 typedef struct clnt_info2
367 DOM_CLNT_SRV login;
368 uint32 ptr_cred;
369 DOM_CRED cred;
370 } DOM_CLNT_INFO2;
372 /* DOM_LOGON_ID - logon id */
373 typedef struct logon_info
375 uint32 low;
376 uint32 high;
377 } DOM_LOGON_ID;
379 /* OWF INFO */
380 typedef struct owf_info
382 uint8 data[16];
383 } OWF_INFO;
390 * A client connection's state, pipe name,
391 * user credentials, etc...
393 typedef struct _cli_auth_fns cli_auth_fns;
394 struct user_creds;
395 struct cli_connection {
397 char *srv_name;
398 char *pipe_name;
399 struct user_creds usr_creds;
401 struct cli_state *pCli_state;
403 cli_auth_fns *auth;
405 void *auth_info;
406 void *auth_creds;
411 * Associate a POLICY_HND with a cli_connection
413 typedef struct rpc_hnd_node {
415 POLICY_HND hnd;
416 struct cli_connection *cli;
418 } RPC_HND_NODE;
420 typedef struct uint64_s
422 uint32 low;
423 uint32 high;
424 } UINT64_S;
430 #endif /* _RPC_MISC_H */