all_string_sub() is broken as it doesn't handle mb chars correctly (and
[Samba.git] / source / include / rpc_misc.h
blob0c6eee3650aba7e1ce2a3d8f304e240bd4f96ae8
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
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.
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.
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.
23 #include "ntdomain.h"
24 #include "rpc_dce.h"
26 #ifndef _RPC_MISC_H /* _RPC_MISC_H */
27 #define _RPC_MISC_H
29 #define SMB_RPC_INTERFACE_VERSION 1
31 /* well-known RIDs - Relative IDs */
33 /* RIDs - Well-known users ... */
34 #define DOMAIN_USER_RID_ADMIN (0x000001F4L)
35 #define DOMAIN_USER_RID_GUEST (0x000001F5L)
36 #define DOMAIN_USER_RID_KRBTGT (0x000001F6L)
38 /* RIDs - well-known groups ... */
39 #define DOMAIN_GROUP_RID_ADMINS (0x00000200L)
40 #define DOMAIN_GROUP_RID_USERS (0x00000201L)
41 #define DOMAIN_GROUP_RID_GUESTS (0x00000202L)
42 #define DOMAIN_GROUP_RID_COMPUTERS (0x00000203L)
44 #define DOMAIN_GROUP_RID_CONTROLLERS (0x00000204L)
45 #define DOMAIN_GROUP_RID_CERT_ADMINS (0x00000205L)
46 #define DOMAIN_GROUP_RID_SCHEMA_ADMINS (0x00000206L)
47 #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS (0x00000207L)
49 /* is the following the right number? I bet it is --simo
50 #define DOMAIN_GROUP_RID_POLICY_ADMINS (0x00000208L)
53 /* RIDs - well-known aliases ... */
54 #define BUILTIN_ALIAS_RID_ADMINS (0x00000220L)
55 #define BUILTIN_ALIAS_RID_USERS (0x00000221L)
56 #define BUILTIN_ALIAS_RID_GUESTS (0x00000222L)
57 #define BUILTIN_ALIAS_RID_POWER_USERS (0x00000223L)
59 #define BUILTIN_ALIAS_RID_ACCOUNT_OPS (0x00000224L)
60 #define BUILTIN_ALIAS_RID_SYSTEM_OPS (0x00000225L)
61 #define BUILTIN_ALIAS_RID_PRINT_OPS (0x00000226L)
62 #define BUILTIN_ALIAS_RID_BACKUP_OPS (0x00000227L)
64 #define BUILTIN_ALIAS_RID_REPLICATOR (0x00000228L)
65 #define BUILTIN_ALIAS_RID_RAS_SERVERS (0x00000229L)
66 #define BUILTIN_ALIAS_RID_PRE_2K_ACCESS (0x0000022aL)
69 * Masks for mappings between unix uid and gid types and
70 * NT RIDS.
74 #define BASE_RID (0x000003E8L)
76 /* Take the bottom bit. */
77 #define RID_TYPE_MASK 1
78 #define RID_MULTIPLIER 2
80 /* The two common types. */
81 #define USER_RID_TYPE 0
82 #define GROUP_RID_TYPE 1
84 /* ENUM_HND */
85 typedef struct enum_hnd_info
87 uint32 ptr_hnd; /* pointer to enumeration handle */
88 uint32 handle; /* enumeration handle */
89 } ENUM_HND;
91 /* LOOKUP_LEVEL - switch value */
92 typedef struct lookup_level_info
94 uint16 value;
95 } LOOKUP_LEVEL;
97 /* DOM_SID2 - security id */
98 typedef struct sid_info_2
100 uint32 num_auths; /* length, bytes, including length of len :-) */
101 DOM_SID sid;
102 } DOM_SID2;
104 /* STRHDR - string header */
105 typedef struct header_info
107 uint16 str_str_len;
108 uint16 str_max_len;
109 uint32 buffer; /* non-zero */
110 } STRHDR;
112 /* UNIHDR - unicode string header */
113 typedef struct unihdr_info
115 uint16 uni_str_len;
116 uint16 uni_max_len;
117 uint32 buffer; /* usually has a value of 4 */
118 } UNIHDR;
120 /* UNIHDR2 - unicode string header and undocumented buffer */
121 typedef struct unihdr2_info
123 UNIHDR unihdr;
124 uint32 buffer; /* 32 bit buffer pointer */
125 } UNIHDR2;
127 /* clueless as to what maximum length should be */
128 #define MAX_UNISTRLEN 256
129 #define MAX_STRINGLEN 256
130 #define MAX_BUFFERLEN 512
132 /* UNISTR - unicode string size and buffer */
133 typedef struct unistr_info
135 /* unicode characters. ***MUST*** be little-endian. ***MUST*** be null-terminated */
136 uint16 *buffer;
137 } UNISTR;
139 /* BUFHDR - buffer header */
140 typedef struct bufhdr_info
142 uint32 buf_max_len;
143 uint32 buf_len;
144 } BUFHDR;
146 /* BUFFER2 - unicode string, size (in uint8 ascii chars) and buffer */
147 /* pathetic. some stupid team of \PIPE\winreg writers got the concept */
148 /* of a unicode string different from the other \PIPE\ writers */
149 typedef struct buffer2_info
151 uint32 buf_max_len;
152 uint32 offset;
153 uint32 buf_len;
154 /* unicode characters. ***MUST*** be little-endian. **NOT** necessarily null-terminated */
155 uint16 *buffer;
156 } BUFFER2;
158 /* BUFFER3 */
159 typedef struct buffer3_info
161 uint32 buf_max_len;
162 uint8 *buffer; /* Data */
163 uint32 buf_len;
164 } BUFFER3;
166 /* BUFFER5 */
167 typedef struct buffer5_info
169 uint32 buf_len;
170 uint16 *buffer; /* data */
171 } BUFFER5;
173 /* UNISTR2 - unicode string size (in uint16 unicode chars) and buffer */
174 typedef struct unistr2_info
176 uint32 uni_max_len;
177 uint32 offset;
178 uint32 uni_str_len;
179 /* unicode characters. ***MUST*** be little-endian.
180 **must** be null-terminated and the uni_str_len should include
181 the NULL character */
182 uint16 *buffer;
183 } UNISTR2;
185 /* STRING2 - string size (in uint8 chars) and buffer */
186 typedef struct string2_info
188 uint32 str_max_len;
189 uint32 offset;
190 uint32 str_str_len;
191 uint8 *buffer; /* uint8 characters. **NOT** necessarily null-terminated */
192 } STRING2;
194 /* UNISTR3 - XXXX not sure about this structure */
195 typedef struct unistr3_info
197 uint32 uni_str_len;
198 UNISTR str;
200 } UNISTR3;
202 /* an element in a unicode string array */
203 typedef struct
205 uint16 length;
206 uint16 size;
207 uint32 ref_id;
208 UNISTR2 string;
209 } UNISTR2_ARRAY_EL;
211 /* an array of unicode strings */
212 typedef struct
214 uint32 ref_id;
215 uint32 count;
216 UNISTR2_ARRAY_EL *strings;
217 } UNISTR2_ARRAY;
220 /* an element in a sid array */
221 typedef struct
223 uint32 ref_id;
224 DOM_SID2 sid;
225 } SID_ARRAY_EL;
227 /* an array of sids */
228 typedef struct
230 uint32 ref_id;
231 uint32 count;
232 SID_ARRAY_EL *sids;
233 } SID_ARRAY;
235 /* DOM_RID2 - domain RID structure for ntlsa pipe */
236 typedef struct domrid2_info
238 uint8 type; /* value is SID_NAME_USE enum */
239 uint32 rid;
240 uint32 rid_idx; /* referenced domain index */
242 } DOM_RID2;
244 /* DOM_RID3 - domain RID structure for samr pipe */
245 typedef struct domrid3_info
247 uint32 rid; /* domain-relative (to a SID) id */
248 uint32 type1; /* value is 0x1 */
249 uint32 ptr_type; /* undocumented pointer */
250 uint32 type2; /* value is 0x1 */
251 uint32 unk; /* value is 0x2 */
253 } DOM_RID3;
255 /* DOM_RID4 - rid + user attributes */
256 typedef struct domrid4_info
258 uint32 unknown;
259 uint16 attr;
260 uint32 rid; /* user RID */
261 } DOM_RID4;
263 /* DOM_CLNT_SRV - client / server names */
264 typedef struct clnt_srv_info
266 uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
267 UNISTR2 uni_logon_srv; /* logon server name */
268 uint32 undoc_buffer2; /* undocumented 32 bit buffer pointer */
269 UNISTR2 uni_comp_name; /* client machine name */
270 } DOM_CLNT_SRV;
272 /* DOM_LOG_INFO - login info */
273 typedef struct log_info
275 uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
276 UNISTR2 uni_logon_srv; /* logon server name */
277 UNISTR2 uni_acct_name; /* account name */
278 uint16 sec_chan; /* secure channel type */
279 UNISTR2 uni_comp_name; /* client machine name */
280 } DOM_LOG_INFO;
282 /* DOM_CHAL - challenge info */
283 typedef struct chal_info
285 uchar data[8]; /* credentials */
286 } DOM_CHAL;
288 /* DOM_CREDs - timestamped client or server credentials */
289 typedef struct cred_info
291 DOM_CHAL challenge; /* credentials */
292 UTIME timestamp; /* credential time-stamp */
293 } DOM_CRED;
295 /* DOM_CLNT_INFO - client info */
296 typedef struct clnt_info
298 DOM_LOG_INFO login;
299 DOM_CRED cred;
300 } DOM_CLNT_INFO;
302 /* DOM_CLNT_INFO2 - client info */
303 typedef struct clnt_info2
305 DOM_CLNT_SRV login;
306 uint32 ptr_cred;
307 DOM_CRED cred;
308 } DOM_CLNT_INFO2;
310 /* DOM_LOGON_ID - logon id */
311 typedef struct logon_info
313 uint32 low;
314 uint32 high;
315 } DOM_LOGON_ID;
317 /* OWF INFO */
318 typedef struct owf_info
320 uint8 data[16];
321 } OWF_INFO;
324 /* DOM_GID - group id + user attributes */
325 typedef struct gid_info
327 uint32 g_rid; /* a group RID */
328 uint32 attr;
329 } DOM_GID;
331 /* POLICY_HND */
332 typedef struct lsa_policy_info
334 uint32 data1;
335 uint32 data2;
336 uint16 data3;
337 uint16 data4;
338 uint8 data5[8];
339 #ifdef __INSURE__
341 /* To prevent the leakage of policy handles mallocate a bit of
342 memory when a policy handle is created and free it when the
343 handle is closed. This should cause Insure to flag an error
344 when policy handles are overwritten or fall out of scope without
345 being freed. */
347 char *marker;
348 #endif
349 } POLICY_HND;
352 * A client connection's state, pipe name,
353 * user credentials, etc...
355 typedef struct _cli_auth_fns cli_auth_fns;
356 struct user_creds;
357 struct cli_connection {
359 char *srv_name;
360 char *pipe_name;
361 struct user_creds usr_creds;
363 struct cli_state *pCli_state;
365 cli_auth_fns *auth;
367 void *auth_info;
368 void *auth_creds;
373 * Associate a POLICY_HND with a cli_connection
375 typedef struct rpc_hnd_node {
377 POLICY_HND hnd;
378 struct cli_connection *cli;
380 } RPC_HND_NODE;
382 typedef struct uint64_s
384 uint32 low;
385 uint32 high;
386 } UINT64_S;
388 /* BUFHDR2 - another buffer header, with info level */
389 typedef struct bufhdr2_info
391 uint32 info_level;
392 uint32 length; /* uint8 chars */
393 uint32 buffer;
396 BUFHDR2;
398 /* BUFFER4 - simple length and buffer */
399 typedef struct buffer4_info
401 uint32 buf_len;
402 uint8 buffer[MAX_BUFFERLEN];
405 BUFFER4;
407 enum unistr2_term_codes { UNI_FLAGS_NONE = 0, UNI_STR_TERMINATE = 1, UNI_MAXLEN_TERMINATE = 2, UNI_BROKEN_NON_NULL = 3 };
408 #endif /* _RPC_MISC_H */