return results on prs_xxxxx() and all xxx_io_xxx() routines.
[samba.git] / source / include / rpc_misc.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 _RPC_MISC_H /* _RPC_MISC_H */
25 #define _RPC_MISC_H 
26
27 /*
28  * macros to wrap prs_xxxx routines.
29  */
30 #define prs_uint8(name, ps, depth, data8) \
31         if (!_prs_uint8(name, ps, depth, data8)) return False
32 #define prs_uint16(name, ps, depth, data16) \
33         if (!_prs_uint16(name, ps, depth, data16)) return False
34 #define prs_hash1(ps, offset, sess_key) \
35         if (!_prs_hash1(ps, offset, sess_key)) return False
36 #define prs_uint32(name, ps, depth, data32) \
37         if (!_prs_uint32(name, ps, depth, data32)) return False
38 #define prs_uint8s(charmode, name, ps, depth, data8s, len) \
39         if (!_prs_uint8s(charmode, name, ps, depth, data8s, len)) return False
40 #define prs_uint16s(charmode, name, ps, depth, data16s, len) \
41         if (!_prs_uint16s(charmode, name, ps, depth, data16s, len)) return False
42 #define prs_uint32s(charmode, name, ps, depth, data32s, len) \
43         if (!_prs_uint32s(charmode, name, ps, depth, data32s, len)) return False
44 #define prs_buffer2(charmode, name, ps, depth, str) \
45         if (!_prs_buffer2(charmode, name, ps, depth, str)) return False
46 #define prs_string2(charmode, name, ps, depth, str) \
47         if (!_prs_string2(charmode, name, ps, depth, str)) return False
48 #define prs_unistr2(charmode, name, ps, depth, str) \
49         if (!_prs_unistr2(charmode, name, ps, depth, str)) return False
50 #define prs_unistr3(charmode, name, str, ps, depth) \
51         if (!_prs_unistr3(charmode, name, str, ps, depth)) return False
52 #define prs_unistr(name, ps, depth, str) \
53         if (!_prs_unistr(name, ps, depth, str)) return False
54 #define prs_string(name, ps, depth, str, len, max_buf_size) \
55         if (!_prs_string(name, ps, depth, str, len, max_buf_size)) return False
56 #define prs_uint16_pre(name, ps, depth, data16, offset) \
57         if (!_prs_uint16_pre(name, ps, depth, data16, offset)) return False
58 #define prs_uint16_post(name, ps, depth, data16, ptr_uint16, data_size) \
59         if (!_prs_uint16_post(name, ps, depth, data16, ptr_uint16, data_size)) return False
60 #define prs_uint32_pre(name, ps, depth, data32, offset) \
61         if (!_prs_uint32_pre(name, ps, depth, data32, offset)) return False
62 #define prs_uint32_post(name, ps, depth, data32, ptr_uint32, data_size) \
63         if (!_prs_uint32_post(name, ps, depth, data32, ptr_uint32, data_size)) return False
64
65 #include "rpc_dce.h"
66
67 /* well-known RIDs - Relative IDs */
68
69 /* RIDs - Well-known users ... */
70 #define DOMAIN_USER_RID_ADMIN          (0x000001F4L)
71 #define DOMAIN_USER_RID_GUEST          (0x000001F5L)
72
73 /* RIDs - well-known groups ... */
74 #define DOMAIN_GROUP_RID_ADMINS        (0x00000200L)
75 #define DOMAIN_GROUP_RID_USERS         (0x00000201L)
76 #define DOMAIN_GROUP_RID_GUESTS        (0x00000202L)
77
78 /* RIDs - well-known aliases ... */
79 #define BUILTIN_ALIAS_RID_ADMINS        (0x00000220L)
80 #define BUILTIN_ALIAS_RID_USERS         (0x00000221L)
81 #define BUILTIN_ALIAS_RID_GUESTS        (0x00000222L)
82 #define BUILTIN_ALIAS_RID_POWER_USERS   (0x00000223L)
83 #define BUILTIN_ALIAS_RID_ACCOUNT_OPS   (0x00000224L)
84 #define BUILTIN_ALIAS_RID_SYSTEM_OPS    (0x00000225L)
85 #define BUILTIN_ALIAS_RID_PRINT_OPS     (0x00000226L)
86 #define BUILTIN_ALIAS_RID_BACKUP_OPS    (0x00000227L)
87 #define BUILTIN_ALIAS_RID_REPLICATOR    (0x00000228L)
88
89 /*
90  * Masks for mappings between unix uid and gid types and
91  * NT RIDS.
92  */
93
94 /* Take the bottom bits. */
95 #define RID_TYPE_MASK 2
96 #define RID_MULTIPLIER 4
97
98 /* The three common types. */
99 #define RID_TYPE_USER    0
100 #define RID_TYPE_GROUP   1
101 #define RID_TYPE_ALIAS   2
102
103 /* BIGINT - NT-style 64-bit integer */
104 typedef struct bigint_info
105 {
106         uint32 low;
107         uint32 high;
108
109 } BIGINT;
110
111
112 /* ENUM_HND */
113 typedef struct enum_hnd_info
114 {
115         uint32 ptr_hnd;          /* pointer to enumeration handle */
116         uint32 handle;           /* enumeration handle */
117
118 } ENUM_HND;
119
120 /* LOOKUP_LEVEL - switch value */
121 typedef struct lookup_level_info
122 {
123   uint16 value;
124
125 } LOOKUP_LEVEL;
126
127 /* DOM_SID2 - security id */
128 typedef struct sid_info_2
129 {
130         uint32 num_auths; /* length, bytes, including length of len :-) */
131
132         DOM_SID sid;
133
134 } DOM_SID2;
135
136 /* STRHDR - string header */
137 typedef struct header_info
138 {
139   uint16 str_str_len;
140   uint16 str_max_len;
141   uint32 buffer; /* non-zero */
142
143 } STRHDR;
144
145 /* STRHDR2 - string header, 32-bit lengths */
146 typedef struct header2_info
147 {
148   uint32 str_str_len;
149   uint32 str_max_len;
150   uint32 buffer;
151
152 } STRHDR2;
153
154 /* UNIHDR - unicode string header */
155 typedef struct unihdr_info
156 {
157   uint16 uni_str_len;
158   uint16 uni_max_len;
159   uint32 buffer; /* usually has a value of 4 */
160
161 } UNIHDR;
162
163 /* UNIHDR2 - unicode string header and undocumented buffer */
164 typedef struct unihdr2_info
165 {
166   UNIHDR unihdr;
167   uint32 buffer; /* 32 bit buffer pointer */
168
169 } UNIHDR2;
170
171 /* clueless as to what maximum length should be */
172 #define MAX_UNISTRLEN 256
173 #define MAX_STRINGLEN 256
174 #define MAX_BUFFERLEN 512
175
176 /* UNISTR - unicode string size and buffer */
177 typedef struct unistr_info
178 {
179   uint16 buffer[MAX_UNISTRLEN]; /* unicode characters. ***MUST*** be null-terminated */
180
181 } UNISTR;
182
183 /* BUFHDR - buffer header */
184 typedef struct bufhdr_info
185 {
186   uint32 buf_max_len;
187   uint32 buf_len;
188
189 } BUFHDR;
190
191 /* BUFHDR2 - another buffer header, with info level */
192 typedef struct bufhdr2_info
193 {
194   uint32 info_level;
195   uint32 length; /* uint8 chars */
196   uint32 buffer;
197
198 } BUFHDR2;
199
200 /* BUFFER2 - unicode string, size (in uint8 ascii chars) and buffer */
201 /* pathetic.  some stupid team of \PIPE\winreg writers got the concept */
202 /* of a unicode string different from the other \PIPE\ writers */
203 typedef struct buffer2_info
204 {
205   uint32 buf_max_len;
206   uint32 undoc;
207   uint32 buf_len;
208   uint8 buffer[MAX_UNISTRLEN];
209
210 } BUFFER2;
211
212 /* BUFFER3 */
213 typedef struct buffer3_info
214 {
215   uint32 buf_max_len;
216   uint8  buffer[MAX_BUFFERLEN]; /* data */
217   uint32 buf_len;
218
219 } BUFFER3;
220
221 /* BUFFER4 - simple length and buffer */
222 typedef struct buffer4_info
223 {
224   uint32 buf_len;
225   uint8  buffer[MAX_BUFFERLEN];
226
227 } BUFFER4;
228
229 /* BUFFER5 */
230 typedef struct buffer5_info
231 {
232   uint32 buf_len;
233   uint16 *buffer; /* data */
234 } BUFFER5;
235
236 /* UNISTR2 - unicode string size (in uint16 unicode chars) and buffer */
237 typedef struct unistr2_info
238 {
239   uint32 uni_max_len;
240   uint32 undoc;
241   uint32 uni_str_len;
242   uint16 buffer[MAX_UNISTRLEN]; /* unicode characters. **NOT** necessarily null-terminated */
243
244 } UNISTR2;
245
246 /* STRING2 - string size (in uint8 chars) and buffer */
247 typedef struct string2_info
248 {
249   uint32 str_max_len;
250   uint32 undoc;
251   uint32 str_str_len;
252   uint8  buffer[MAX_STRINGLEN]; /* uint8 characters. **NOT** necessarily null-terminated */
253
254 } STRING2;
255
256 /* UNISTR3 - XXXX not sure about this structure */
257 typedef struct unistr3_info
258 {
259         uint32 uni_str_len;
260         UNISTR str;
261
262 } UNISTR3;
263
264
265 /* DOM_RID2 - domain RID structure for ntlsa pipe */
266 typedef struct domrid2_info
267 {
268         uint8 type; /* value is SID_NAME_USE enum */
269         uint32 rid;
270         uint32 rid_idx; /* referenced domain index */
271
272 } DOM_RID2;
273
274 /* DOM_RID3 - domain RID structure for samr pipe */
275 typedef struct domrid3_info
276 {
277         uint32 rid;        /* domain-relative (to a SID) id */
278         uint32 type1;      /* value is 0x1 */
279         uint32 ptr_type;   /* undocumented pointer */
280         uint32 type2;      /* value is 0x1 */
281         uint32 unk; /* value is 0x2 */
282
283 } DOM_RID3;
284
285 /* DOM_CLNT_SRV - client / server names */
286 typedef struct clnt_srv_info
287 {
288   uint32  undoc_buffer; /* undocumented 32 bit buffer pointer */
289   UNISTR2 uni_logon_srv; /* logon server name */
290   uint32  undoc_buffer2; /* undocumented 32 bit buffer pointer */
291   UNISTR2 uni_comp_name; /* client machine name */
292
293 } DOM_CLNT_SRV;
294
295 /* DOM_LOG_INFO - login info */
296 typedef struct log_info
297 {
298   uint32  undoc_buffer; /* undocumented 32 bit buffer pointer */
299   UNISTR2 uni_logon_srv; /* logon server name */
300   UNISTR2 uni_acct_name; /* account name */
301   uint16  sec_chan;      /* secure channel type */
302   UNISTR2 uni_comp_name; /* client machine name */
303
304 } DOM_LOG_INFO;
305
306 /* DOM_CLNT_INFO - client info */
307 typedef struct clnt_info
308 {
309   DOM_LOG_INFO login;
310   DOM_CRED     cred;
311
312 } DOM_CLNT_INFO;
313
314 /* DOM_CLNT_INFO2 - client info */
315 typedef struct clnt_info2
316 {
317   DOM_CLNT_SRV login;
318   uint32        ptr_cred;
319   DOM_CRED      cred;
320
321 } DOM_CLNT_INFO2;
322
323 /* DOM_LOGON_ID - logon id */
324 typedef struct logon_info
325 {
326   uint32 low;
327   uint32 high;
328
329 } DOM_LOGON_ID;
330
331 /* OWF INFO */
332 typedef struct owf_info
333 {
334   uint8 data[16];
335
336 } OWF_INFO;
337
338
339 /* DOM_GID - group id + user attributes */
340 typedef struct gid_info
341 {
342   uint32 g_rid;  /* a group RID */
343   uint32 attr;
344
345 } DOM_GID;
346
347 #define POL_HND_SIZE 20
348
349 /* POLICY_HND */
350 typedef struct lsa_policy_info
351 {
352   uint8 data[POL_HND_SIZE]; /* policy handle */
353
354 } POLICY_HND;
355
356 #endif /* _RPC_MISC_H */
357