r21515: add some more PFC_FLAGS from the DCERPC spec, and fix some names
[kai/samba-autobuild/.git] / source4 / librpc / idl / dcerpc.idl
1 #include "idl_types.h"
2
3 /*
4   the base dcerpc packet definitions - not traditionally coded as IDL,
5   but given that pidl can handle it nicely it simplifies things a lot
6   to do it this way
7
8   see http://www.opengroup.org/onlinepubs/9629399/chap12.htm for packet
9   layouts
10 */
11 import "misc.idl";
12
13 interface dcerpc
14 {
15         typedef [public] struct {
16                 GUID uuid;
17                 uint32 if_version;
18         } dcerpc_syntax_id;
19
20         typedef struct {
21                 uint16 context_id;
22                 uint8 num_transfer_syntaxes;
23                 dcerpc_syntax_id abstract_syntax;
24                 dcerpc_syntax_id transfer_syntaxes[num_transfer_syntaxes];
25         } dcerpc_ctx_list;
26
27         typedef struct {
28                 uint16 max_xmit_frag;
29                 uint16 max_recv_frag;
30                 uint32 assoc_group_id;
31                 uint8  num_contexts;
32                 dcerpc_ctx_list ctx_list[num_contexts];
33                 [flag(NDR_ALIGN4)]    DATA_BLOB _pad;
34                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
35         } dcerpc_bind;
36
37         const uint8 DCERPC_REQUEST_LENGTH = 24;
38         const uint8 DCERPC_MAX_SIGN_SIZE  = 32;
39
40         typedef struct {
41         } dcerpc_empty;
42         
43         typedef [nodiscriminant] union {
44                 [default] dcerpc_empty empty;
45                 [case(LIBNDR_FLAG_OBJECT_PRESENT)] GUID object;
46         } dcerpc_object;
47
48         typedef struct {
49                 uint32 alloc_hint;
50                 uint16 context_id;
51                 uint16 opnum;
52                 [switch_is(ndr->flags & LIBNDR_FLAG_OBJECT_PRESENT)] dcerpc_object object;
53                 [flag(NDR_ALIGN8)]    DATA_BLOB _pad;
54                 [flag(NDR_REMAINING)] DATA_BLOB stub_and_verifier;
55         } dcerpc_request;
56
57         const int DCERPC_BIND_REASON_ASYNTAX                 = 1;
58         const int DCERPC_BIND_PROVIDER_REJECT                = 2;
59         const int DECRPC_BIND_PROTOCOL_VERSION_NOT_SUPPORTED = 4;
60         const int DCERPC_BIND_REASON_INVALID_AUTH_TYPE       = 8;
61
62         typedef struct {
63                 uint16 result;
64                 uint16 reason;
65                 dcerpc_syntax_id syntax;
66         } dcerpc_ack_ctx;
67
68         typedef struct {
69                 uint16 max_xmit_frag;
70                 uint16 max_recv_frag;
71                 uint32 assoc_group_id;
72                 ascstr3 secondary_address;
73                 [flag(NDR_ALIGN4)]    DATA_BLOB _pad1;
74                 uint8 num_results;
75                 dcerpc_ack_ctx ctx_list[num_results];
76                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
77         } dcerpc_bind_ack;
78
79         typedef struct {
80                 uint32 num_versions;
81                 uint32 versions[num_versions];
82         } dcerpc_bind_nak_versions;
83         
84         typedef [nodiscriminant] union {
85                 [case(DECRPC_BIND_PROTOCOL_VERSION_NOT_SUPPORTED)] dcerpc_bind_nak_versions v;
86                 [default] ;
87         } dcerpc_bind_nak_versions_ctr;
88
89         typedef struct {
90                 uint16 reject_reason;
91                 [switch_is(reject_reason)] dcerpc_bind_nak_versions_ctr versions;
92         } dcerpc_bind_nak;
93
94         const uint8 DCERPC_RESPONSE_LENGTH = 24;
95
96         typedef struct {
97                 uint32 alloc_hint;
98                 uint16 context_id;
99                 uint8 cancel_count;
100                 [flag(NDR_ALIGN8)]    DATA_BLOB _pad;
101                 [flag(NDR_REMAINING)] DATA_BLOB stub_and_verifier;
102         } dcerpc_response;
103
104
105         const int DCERPC_FAULT_OP_RNG_ERROR       = 0x1c010002;
106         const int DCERPC_FAULT_UNK_IF             = 0x1c010003;
107         const int DCERPC_FAULT_NDR                = 0x000006f7;
108         const int DCERPC_FAULT_INVALID_TAG        = 0x1c000006;
109         const int DCERPC_FAULT_CONTEXT_MISMATCH   = 0x1c00001a;
110         const int DCERPC_FAULT_OTHER              = 0x00000001;
111         const int DCERPC_FAULT_ACCESS_DENIED      = 0x00000005;
112         const int DCERPC_FAULT_CANT_PERFORM       = 0x000006d8;
113
114         /* we return this fault when we haven't yet run the test
115            to see what fault w2k3 returns in this case */
116         const int DCERPC_FAULT_TODO         = 0x00000042;
117
118         typedef struct {
119                 uint32 alloc_hint;
120                 uint16 context_id;
121                 uint8 cancel_count;
122                 uint32 status;
123         } dcerpc_fault;
124
125         /* the auth types we know about */
126         const uint8 DCERPC_AUTH_TYPE_NONE     = 0;
127         /* this seems to be not krb5! */
128         const uint8 DCERPC_AUTH_TYPE_KRB5_1   = 1;
129         const uint8 DCERPC_AUTH_TYPE_SPNEGO   = 9;
130         const uint8 DCERPC_AUTH_TYPE_NTLMSSP  = 10;
131         const uint8 DCERPC_AUTH_TYPE_KRB5     = 16;
132         const uint8 DCERPC_AUTH_TYPE_SCHANNEL = 68;
133         const uint8 DCERPC_AUTH_TYPE_MSMQ     = 100;
134
135         const uint8 DCERPC_AUTH_LEVEL_DEFAULT   = DCERPC_AUTH_LEVEL_CONNECT;
136         const uint8 DCERPC_AUTH_LEVEL_NONE      = 1;
137         const uint8 DCERPC_AUTH_LEVEL_CONNECT   = 2;
138         const uint8 DCERPC_AUTH_LEVEL_CALL      = 3;
139         const uint8 DCERPC_AUTH_LEVEL_PACKET    = 4;
140         const uint8 DCERPC_AUTH_LEVEL_INTEGRITY = 5;
141         const uint8 DCERPC_AUTH_LEVEL_PRIVACY   = 6;
142
143         typedef [public] struct {
144                 uint8  auth_type; 
145                 uint8  auth_level;
146                 uint8  auth_pad_length;
147                 uint8  auth_reserved;
148                 uint32 auth_context_id;
149                 [flag(NDR_REMAINING)] DATA_BLOB credentials;
150         } dcerpc_auth;
151
152         typedef [public] struct {
153                 uint32 _pad;
154                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
155         } dcerpc_auth3;
156
157         typedef [public] struct {
158                 uint32 _pad;
159                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
160         } dcerpc_orphaned;
161
162         typedef [public] struct {
163                 uint32 _pad;
164                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
165         } dcerpc_co_cancel;
166
167         typedef [public] struct {
168                 uint32 version;
169                 uint32 id;
170         } dcerpc_cl_cancel;
171
172         typedef [public] struct {
173                 uint32 version; 
174                 uint32 id;
175                 boolean32 server_is_accepting;
176         } dcerpc_cancel_ack;
177
178         typedef [public] struct {
179                 uint32 version;
180                 uint8 _pad1;
181                 uint16 window_size;
182                 uint32 max_tdsu;
183                 uint32 max_frag_size;
184                 uint16 serial_no;
185                 uint16 selack_size;
186                 uint32 selack[selack_size];
187         } dcerpc_fack;
188
189         typedef [public] struct {
190         } dcerpc_ack;
191
192         typedef [public] struct {
193         } dcerpc_ping;
194
195         typedef [public] struct {
196         } dcerpc_shutdown;
197         
198         typedef [public] struct {
199         } dcerpc_working;
200
201         typedef [enum8bit] enum {
202                 DCERPC_PKT_REQUEST     =  0,
203                 DCERPC_PKT_PING        =  1,
204                 DCERPC_PKT_RESPONSE    =  2,
205                 DCERPC_PKT_FAULT       =  3,
206                 DCERPC_PKT_WORKING     =  4,
207                 DCERPC_PKT_NOCALL      =  5,
208                 DCERPC_PKT_REJECT      =  6,
209                 DCERPC_PKT_ACK         =  7,
210                 DCERPC_PKT_CL_CANCEL   =  8,
211                 DCERPC_PKT_FACK        =  9,
212                 DCERPC_PKT_CANCEL_ACK  = 10,
213                 DCERPC_PKT_BIND        = 11,
214                 DCERPC_PKT_BIND_ACK    = 12,
215                 DCERPC_PKT_BIND_NAK    = 13,
216                 DCERPC_PKT_ALTER       = 14,
217                 DCERPC_PKT_ALTER_RESP  = 15,
218                 DCERPC_PKT_AUTH3       = 16,
219                 DCERPC_PKT_SHUTDOWN    = 17,
220                 DCERPC_PKT_CO_CANCEL   = 18,
221                 DCERPC_PKT_ORPHANED    = 19
222         } dcerpc_pkt_type;
223
224         typedef [nodiscriminant] union {
225                 [case(DCERPC_PKT_REQUEST)]    dcerpc_request  request;
226                 [case(DCERPC_PKT_PING)]           dcerpc_ping ping;
227                 [case(DCERPC_PKT_RESPONSE)]   dcerpc_response response;
228                 [case(DCERPC_PKT_FAULT)]          dcerpc_fault fault;
229                 [case(DCERPC_PKT_WORKING)]        dcerpc_working working;
230                 [case(DCERPC_PKT_NOCALL)]     dcerpc_fack nocall;
231                 [case(DCERPC_PKT_REJECT)]     dcerpc_fault reject;
232                 [case(DCERPC_PKT_ACK)]        dcerpc_ack ack;
233                 [case(DCERPC_PKT_CL_CANCEL)]  dcerpc_cl_cancel cl_cancel;
234                 [case(DCERPC_PKT_FACK)]       dcerpc_fack fack;
235                 [case(DCERPC_PKT_CANCEL_ACK)] dcerpc_cancel_ack cancel_ack;
236                 [case(DCERPC_PKT_BIND)]       dcerpc_bind     bind;
237                 [case(DCERPC_PKT_BIND_ACK)]   dcerpc_bind_ack bind_ack;
238                 [case(DCERPC_PKT_BIND_NAK)]   dcerpc_bind_nak bind_nak;
239                 [case(DCERPC_PKT_ALTER)]      dcerpc_bind     alter;
240                 [case(DCERPC_PKT_ALTER_RESP)] dcerpc_bind_ack alter_resp;
241                 [case(DCERPC_PKT_SHUTDOWN)]   dcerpc_shutdown shutdown;
242                 [case(DCERPC_PKT_CO_CANCEL)]  dcerpc_co_cancel co_cancel;
243                 [case(DCERPC_PKT_ORPHANED)]   dcerpc_orphaned orphaned;
244                 [case(DCERPC_PKT_AUTH3)]      dcerpc_auth3    auth3;
245         } dcerpc_payload;
246
247         /* pfc_flags values */
248         const uint8 DCERPC_PFC_FLAG_FIRST               = 0x01; /* First fragment */
249         const uint8 DCERPC_PFC_FLAG_LAST                = 0x02; /* Last fragment */
250         const uint8 DCERPC_PFC_FLAG_PENDING_CANCEL      = 0x04; /* Cancel was pending at sender */
251         const uint8 DCERPC_PFC_FLAG_CONC_MPX            = 0x10; /* supports concurrent multiplexing of a single connection. */
252         const uint8 DCERPC_PFC_FLAG_DID_NOT_EXECUTE     = 0x20; /* on a fault it means the server hasn't done anything */
253         const uint8 DCERPC_PFC_FLAG_MAYBE               = 0x40; /* `maybe' call semantics requested */
254         const uint8 DCERPC_PFC_FLAG_OBJECT_UUID         = 0x80; /* on valid guid is in the optional object field */
255
256         /* these offsets are needed by the signing code */
257         const uint8 DCERPC_DREP_OFFSET     =  4;
258         const uint8 DCERPC_FRAG_LEN_OFFSET =  8;
259         const uint8 DCERPC_AUTH_LEN_OFFSET = 10;
260
261         /* little-endian flag */
262         const uint8 DCERPC_DREP_LE  = 0x10;
263
264         typedef [public] struct {
265                 uint8 rpc_vers;         /* RPC version */
266                 uint8 rpc_vers_minor;   /* Minor version */
267                 dcerpc_pkt_type ptype;  /* Packet type */
268                 uint8 pfc_flags;        /* Fragmentation flags */
269                 uint8 drep[4];          /* NDR data representation */
270                 uint16 frag_length;     /* Total length of fragment */
271                 uint16 auth_length;     /* authenticator length */
272                 uint32 call_id;         /* Call identifier */
273                 [switch_is(ptype)] dcerpc_payload u;
274         } ncacn_packet;
275
276         typedef [public] struct {
277                 uint8 rpc_vers;         /* RPC version (4) */
278                 uint8 ptype;
279                 uint8 pfc_flags;
280                 uint8 ncadg_flags;
281                 uint8 drep[3];
282                 uint8 serial_high;
283                 GUID object;
284                 GUID iface;
285                 GUID activity;
286                 uint32 server_boot; /* Server boot time */
287                 uint32 iface_version;
288                 uint32 seq_num;
289                 uint16 opnum;
290                 uint16 ihint;
291                 uint16 ahint;
292                 uint16 len;
293                 uint16 fragnum;
294                 uint8 auth_proto;
295                 uint8 serial_low;
296                 [switch_is(ptype)] dcerpc_payload u;
297         } ncadg_packet;
298 }