276ddd878f5264923a2166c08caf8cc37707417b
[metze/samba-autobuild/.git] / 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 [C706 - DCE 1.1: Remote Procedure Call] for the OpenGroup
9   DCERPC specification:
10   http://pubs.opengroup.org/onlinepubs/9629399/toc.htm
11
12   See C706 - Chapter 12: RPC PDU Encodings for packet layouts:
13   http://www.opengroup.org/onlinepubs/9629399/chap12.htm
14
15   See also [MS-RPCE] for the Microsoft
16   "Remote Procedure Call Protocol Extensions".
17   http://msdn.microsoft.com/en-us/library/cc243560.aspx
18
19 */
20 import "misc.idl";
21
22 cpp_quote("extern const uint8_t DCERPC_SEC_VT_MAGIC[8];")
23
24 interface dcerpc
25 {
26         typedef struct {
27                 uint16 context_id;
28                 uint8 num_transfer_syntaxes;
29                 ndr_syntax_id abstract_syntax;
30                 ndr_syntax_id transfer_syntaxes[num_transfer_syntaxes];
31         } dcerpc_ctx_list;
32
33         typedef [public] struct {
34                 uint16 max_xmit_frag;
35                 uint16 max_recv_frag;
36                 uint32 assoc_group_id;
37                 uint8  num_contexts;
38                 dcerpc_ctx_list ctx_list[num_contexts];
39                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
40         } dcerpc_bind;
41
42         const uint8 DCERPC_REQUEST_LENGTH = 24;
43
44         typedef struct {
45         } dcerpc_empty;
46
47         typedef [nodiscriminant] union {
48                 [default] dcerpc_empty empty;
49                 [case(LIBNDR_FLAG_OBJECT_PRESENT)] GUID object;
50         } dcerpc_object;
51
52         typedef struct {
53                 uint32 alloc_hint;
54                 uint16 context_id;
55                 uint16 opnum;
56                 [switch_is(ndr->flags & LIBNDR_FLAG_OBJECT_PRESENT)] dcerpc_object object;
57                 [flag(NDR_ALIGN8)]    DATA_BLOB _pad;
58                 [flag(NDR_REMAINING)] DATA_BLOB stub_and_verifier;
59         } dcerpc_request;
60
61         const int DCERPC_BIND_REASON_ASYNTAX                 = 1;
62         const int DCERPC_BIND_PROVIDER_REJECT                = 2;
63         const int DECRPC_BIND_PROTOCOL_VERSION_NOT_SUPPORTED = 4;
64         const int DCERPC_BIND_REASON_INVALID_AUTH_TYPE       = 8;
65
66         typedef struct {
67                 uint16 result;
68                 uint16 reason;
69                 ndr_syntax_id syntax;
70         } dcerpc_ack_ctx;
71
72         typedef struct {
73                 uint16 max_xmit_frag;
74                 uint16 max_recv_frag;
75                 uint32 assoc_group_id;
76                 [value(strlen(secondary_address)+1)] uint16 secondary_address_size;
77                 [charset(DOS)] uint8 secondary_address[secondary_address_size];
78                 [flag(NDR_ALIGN4)]    DATA_BLOB _pad1;
79                 uint8 num_results;
80                 dcerpc_ack_ctx ctx_list[num_results];
81                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
82         } dcerpc_bind_ack;
83
84         typedef struct {
85                 uint32 num_versions;
86                 uint32 versions[num_versions];
87         } dcerpc_bind_nak_versions;
88
89         typedef [nodiscriminant] union {
90                 [case(DECRPC_BIND_PROTOCOL_VERSION_NOT_SUPPORTED)] dcerpc_bind_nak_versions v;
91                 [default] ;
92         } dcerpc_bind_nak_versions_ctr;
93
94         typedef struct {
95                 uint16 reject_reason;
96                 [switch_is(reject_reason)] dcerpc_bind_nak_versions_ctr versions;
97         } dcerpc_bind_nak;
98
99         const uint8 DCERPC_RESPONSE_LENGTH = 24;
100
101         typedef struct {
102                 uint32 alloc_hint;
103                 uint16 context_id;
104                 uint8 cancel_count;
105                 [flag(NDR_ALIGN8)]    DATA_BLOB _pad;
106                 [flag(NDR_REMAINING)] DATA_BLOB stub_and_verifier;
107         } dcerpc_response;
108
109         typedef [v1_enum] enum {
110                 DCERPC_NCA_S_COMM_FAILURE               = 0x1C010001,
111                 DCERPC_NCA_S_OP_RNG_ERROR               = 0x1C010002,
112                 DCERPC_NCA_S_UNKNOWN_IF                 = 0x1C010003,
113                 DCERPC_NCA_S_WRONG_BOOT_TIME            = 0x1C010006,
114                 DCERPC_NCA_S_YOU_CRASHED                = 0x1C010009,
115                 DCERPC_NCA_S_PROTO_ERROR                = 0x1C01000B,
116                 DCERPC_NCA_S_OUT_ARGS_TOO_BIG           = 0x1C010013,
117                 DCERPC_NCA_S_SERVER_TOO_BUSY            = 0x1C010014,
118                 DCERPC_NCA_S_FAULT_STRING_TOO_LARGE     = 0x1C010015,
119                 DCERPC_NCA_S_UNSUPPORTED_TYPE           = 0x1C010017,
120                 DCERPC_NCA_S_FAULT_INT_DIV_BY_ZERO      = 0x1C000001,
121                 DCERPC_NCA_S_FAULT_ADDR_ERROR           = 0x1C000002,
122                 DCERPC_NCA_S_FAULT_FP_DIV_BY_ZERO       = 0x1C000003,
123                 DCERPC_NCA_S_FAULT_FP_UNDERFLOW         = 0x1C000004,
124                 DCERPC_NCA_S_FAULT_FP_OVERRFLOW         = 0x1C000005,
125                 DCERPC_NCA_S_FAULT_INVALID_TAG          = 0x1C000006,
126                 DCERPC_NCA_S_FAULT_INVALID_BOUND        = 0x1C000007,
127                 DCERPC_NCA_S_FAULT_RPC_VERSION_MISMATCH = 0x1C000008,
128                 DCERPC_NCA_S_FAULT_UNSPEC_REJECT        = 0x1C000009,
129                 DCERPC_NCA_S_FAULT_BAD_ACTID            = 0x1C00000A,
130                 DCERPC_NCA_S_FAULT_WHO_ARE_YOU_FAILED   = 0x1C00000B,
131                 DCERPC_NCA_S_FAULT_MANAGER_NOT_ENTERED  = 0x1C00000C,
132                 DCERPC_NCA_S_FAULT_CANCEL               = 0x1C00000D,
133                 DCERPC_NCA_S_FAULT_ILL_INST             = 0x1C00000E,
134                 DCERPC_NCA_S_FAULT_FP_ERROR             = 0x1C00000F,
135                 DCERPC_NCA_S_FAULT_INT_OVERFLOW         = 0x1C000010,
136                 DCERPC_NCA_S_UNUSED_1C000011            = 0x1C000011,
137                 DCERPC_NCA_S_FAULT_UNSPEC               = 0x1C000012,
138                 DCERPC_NCA_S_FAULT_REMOTE_COMM_FAILURE  = 0x1C000013,
139                 DCERPC_NCA_S_FAULT_PIPE_EMPTY           = 0x1C000014,
140                 DCERPC_NCA_S_FAULT_PIPE_CLOSED          = 0x1C000015,
141                 DCERPC_NCA_S_FAULT_PIPE_ORDER           = 0x1C000016,
142                 DCERPC_NCA_S_FAULT_PIPE_DISCIPLINE      = 0x1C000017,
143                 DCERPC_NCA_S_FAULT_PIPE_COMM_ERROR      = 0x1C000018,
144                 DCERPC_NCA_S_FAULT_PIPE_MEMORY          = 0x1C000019,
145                 DCERPC_NCA_S_FAULT_CONTEXT_MISMATCH     = 0x1C00001A,
146                 DCERPC_NCA_S_FAULT_REMOTE_NO_MEMORY     = 0x1C00001B,
147                 DCERPC_NCA_S_INVALID_PRES_CONTEXT_ID    = 0x1C00001C,
148                 DCERPC_NCA_S_UNSUPPORTED_AUTHN_LEVEL    = 0x1C00001D,
149                 DCERPC_NCA_S_UNUSED_1C00001E            = 0x1C00001E,
150                 DCERPC_NCA_S_INVALID_CHECKSUM           = 0x1C00001F,
151                 DCERPC_NCA_S_INVALID_CRC                = 0x1C000020,
152                 DCERPC_NCA_S_FAULT_USER_DEFINED         = 0x1C000021,
153                 DCERPC_NCA_S_FAULT_TX_OPEN_FAILED       = 0x1C000022,
154                 DCERPC_NCA_S_FAULT_CODESET_CONV_ERROR   = 0x1C000023,
155                 DCERPC_NCA_S_FAULT_OBJECT_NOT_FOUND     = 0x1C000024,
156                 DCERPC_NCA_S_FAULT_NO_CLIENT_STUB       = 0x1C000025
157         } dcerpc_nca_status;
158
159         const int DCERPC_FAULT_OP_RNG_ERROR       = 0x1c010002;
160         const int DCERPC_FAULT_UNK_IF             = 0x1c010003;
161         const int DCERPC_FAULT_NDR                = 0x000006f7;
162         const int DCERPC_FAULT_INVALID_TAG        = 0x1c000006;
163         const int DCERPC_FAULT_CONTEXT_MISMATCH   = 0x1c00001a;
164         const int DCERPC_FAULT_OTHER              = 0x00000001;
165         const int DCERPC_FAULT_ACCESS_DENIED      = 0x00000005;
166         const int DCERPC_FAULT_CANT_PERFORM       = 0x000006d8;
167         const int DCERPC_FAULT_SEC_PKG_ERROR      = 0x00000721;
168
169         /* we return this fault when we haven't yet run the test
170            to see what fault w2k3 returns in this case */
171         const int DCERPC_FAULT_TODO         = 0x00000042;
172
173         typedef struct {
174                 uint32 alloc_hint;
175                 uint16 context_id;
176                 uint8 cancel_count;
177                 dcerpc_nca_status status;
178                 [flag(NDR_REMAINING)] DATA_BLOB _pad;
179         } dcerpc_fault;
180
181         /* the auth types we know about */
182         typedef [enum8bit] enum {
183                 DCERPC_AUTH_TYPE_NONE     = 0,
184                 /* this seems to be not krb5! */
185                 DCERPC_AUTH_TYPE_KRB5_1   = 1,
186                 DCERPC_AUTH_TYPE_SPNEGO   = 9,
187                 DCERPC_AUTH_TYPE_NTLMSSP  = 10,
188                 DCERPC_AUTH_TYPE_KRB5     = 16,
189                 DCERPC_AUTH_TYPE_DPA      = 17,
190                 DCERPC_AUTH_TYPE_MSN      = 18,
191                 DCERPC_AUTH_TYPE_DIGEST   = 21,
192                 DCERPC_AUTH_TYPE_SCHANNEL = 68,
193                 DCERPC_AUTH_TYPE_MSMQ     = 100,
194                 DCERPC_AUTH_TYPE_NCALRPC_AS_SYSTEM = 200
195         } dcerpc_AuthType;
196
197         typedef [enum8bit] enum {
198                 DCERPC_AUTH_LEVEL_NONE      = 1,
199                 DCERPC_AUTH_LEVEL_CONNECT   = 2,
200                 DCERPC_AUTH_LEVEL_CALL      = 3,
201                 DCERPC_AUTH_LEVEL_PACKET    = 4,
202                 DCERPC_AUTH_LEVEL_INTEGRITY = 5,
203                 DCERPC_AUTH_LEVEL_PRIVACY   = 6
204         } dcerpc_AuthLevel;
205
206         const uint8 DCERPC_AUTH_LEVEL_DEFAULT   = DCERPC_AUTH_LEVEL_CONNECT;
207
208         typedef [public] struct {
209                 dcerpc_AuthType auth_type;
210                 dcerpc_AuthLevel auth_level;
211                 uint8  auth_pad_length;
212                 uint8  auth_reserved;
213                 uint32 auth_context_id;
214                 [flag(NDR_REMAINING)] DATA_BLOB credentials;
215         } dcerpc_auth;
216
217         const uint8 DCERPC_AUTH_TRAILER_LENGTH = 8;
218
219         typedef [public] struct {
220                 [value(0)]            uint32    _pad;
221                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
222         } dcerpc_auth3;
223
224         typedef [public] struct {
225                 [value(0)]            uint32    _pad;
226                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
227         } dcerpc_orphaned;
228
229         typedef [public] struct {
230                 [value(0)]            uint32    _pad;
231                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
232         } dcerpc_co_cancel;
233
234         typedef [public] struct {
235                 uint32 version;
236                 uint32 id;
237         } dcerpc_cl_cancel;
238
239         typedef [public] struct {
240                 uint32 version;
241                 uint32 id;
242                 boolean32 server_is_accepting;
243         } dcerpc_cancel_ack;
244
245         typedef [public] struct {
246                 uint32 version;
247                 uint8 _pad1;
248                 uint16 window_size;
249                 uint32 max_tdsu;
250                 uint32 max_frag_size;
251                 uint16 serial_no;
252                 uint16 selack_size;
253                 uint32 selack[selack_size];
254         } dcerpc_fack;
255
256         typedef [public] struct {
257         } dcerpc_ack;
258
259         typedef [public] struct {
260         } dcerpc_ping;
261
262         typedef [public] struct {
263         } dcerpc_shutdown;
264
265         typedef [public] struct {
266         } dcerpc_working;
267
268         /* RTS data structures */
269         typedef [public] struct {
270                 GUID            Cookie;
271         } RTSCookie;
272
273         typedef [v1_enum,public] enum {
274                 RTS_IPV4        = 0,
275                 RTS_IPV6        = 1
276         } AddressType;
277
278         typedef [nodiscriminant] union {
279                 [case(RTS_IPV4)] ipv4address    ClientAddressIPV4;
280                 [case(RTS_IPV6)] ipv6address    ClientAddressIPV6;
281         } ClientAddressType;
282
283         typedef [public] struct {
284                 AddressType                                     AddressType;
285                 [switch_is(AddressType)] ClientAddressType      ClientAddress;
286                 uint8                                           Padding[12];
287         } ClientAddress;
288
289         typedef [v1_enum, public] enum {
290                 FDClient        = 0,
291                 FDInProxy       = 1,
292                 FDServer        = 2,
293                 FDOutProxy      = 3
294         } ForwardDestination;
295
296         typedef [public] struct {
297                 uint32          BytesReceived;
298                 uint32          AvailableWindow;
299                 RTSCookie       ChannelCookie;
300         } FlowControlAcknowledgment;
301
302         /* RTS commands */
303
304         /* RTS command: 0x0 */
305         typedef [public] struct {
306                 [range(0x2000,0x40000)] uint32  ReceiveWindowSize;
307         } dcerpc_rts_cmd_ReceiveWindowSize;
308
309         /* RTS command: 0x1 */
310         typedef [public] struct {
311                 FlowControlAcknowledgment       Ack;
312         } dcerpc_rts_cmd_FlowControlAck;
313
314         /* RTS command: 0x2 */
315         typedef [public] struct {
316                 [range(0x1D4C0,0xDBBA00)] uint32        ConnectionTimeout;
317         } dcerpc_rts_cmd_ConnectionTimeout;
318
319         /* RTS command: 0x3 */
320         typedef [public] struct {
321                 RTSCookie       Cookie;
322         } dcerpc_rts_cmd_Cookie;
323
324         /* RTS command: 0x4 */
325         typedef [public] struct {
326                 [range(0x20000,0x80000000)] uint32      ChannelLifetime;
327         } dcerpc_rts_cmd_ChannelLifetime;
328
329         /* RTS command: 0x5 */
330         typedef [public] struct {
331                 uint32          ClientKeepalive;
332         } dcerpc_rts_cmd_ClientKeepalive;
333
334         /* RTS command: 0x6 */
335         typedef [public] struct {
336                 uint32          Version;
337         } dcerpc_rts_cmd_Version;
338
339         /* RTS command: 0x7 */
340         typedef [public] struct {
341         } dcerpc_rts_cmd_Empty;
342
343         /* RTS command: 0x8 */
344         typedef [public] struct {
345                 [range(0x0,0xFFFF)] uint32      ConformanceCount;
346                 uint8                           Padding[ConformanceCount];
347         } dcerpc_rts_cmd_Padding;
348
349         /* RTS command: 0x9 */
350         typedef [public] struct {
351         } dcerpc_rts_cmd_NegativeANCE;
352
353         /* RTS Command: 0xA */
354         typedef [public] struct {
355         } dcerpc_rts_cmd_ANCE;
356
357         /* RTS command: 0xB */
358         typedef [public] struct {
359                 ClientAddress   ClientAddress;
360         } dcerpc_rts_cmd_ClientAddress;
361
362         /* RTS command: 0xC */
363         typedef [public] struct {
364                 RTSCookie       AssociationGroupId;
365         } dcerpc_rts_cmd_AssociationGroupId;
366
367         /* RTS command: 0xD */
368         typedef [public] struct {
369                 ForwardDestination      ForwardDestination;
370         } dcerpc_rts_cmd_Destination;
371
372         /* RTS command: 0xE */
373         typedef [public] struct {
374                 uint32  PingTrafficSent;
375         } dcerpc_rts_cmd_PingTrafficSentNotify;
376
377         typedef [nodiscriminant] union {
378                 [case(0x0)] dcerpc_rts_cmd_ReceiveWindowSize            ReceiveWindowSize;
379                 [case(0x1)] dcerpc_rts_cmd_FlowControlAck               FlowControlAck;
380                 [case(0x2)] dcerpc_rts_cmd_ConnectionTimeout            ConnectionTimeout;
381                 [case(0x3)] dcerpc_rts_cmd_Cookie                       Cookie;
382                 [case(0x4)] dcerpc_rts_cmd_ChannelLifetime              ChannelLifetime;
383                 [case(0x5)] dcerpc_rts_cmd_ClientKeepalive              ClientKeepalive;
384                 [case(0x6)] dcerpc_rts_cmd_Version                      Version;
385                 [case(0x7)] dcerpc_rts_cmd_Empty                        Empty;
386                 [case(0x8)] dcerpc_rts_cmd_Padding                      Padding;
387                 [case(0x9)] dcerpc_rts_cmd_NegativeANCE                 NegativeANCE;
388                 [case(0xA)] dcerpc_rts_cmd_ANCE                         ANCE;
389                 [case(0xB)] dcerpc_rts_cmd_ClientAddress                ClientAddress;
390                 [case(0xC)] dcerpc_rts_cmd_AssociationGroupId           AssociationGroupId;
391                 [case(0xD)] dcerpc_rts_cmd_Destination                  Destination;
392                 [case(0xE)] dcerpc_rts_cmd_PingTrafficSentNotify        PingTrafficSentNotify;
393         } dcerpc_rts_cmds;
394
395         typedef [public] struct {
396                 uint32                                          CommandType;
397                 [switch_is(CommandType)] dcerpc_rts_cmds        Command;
398         } dcerpc_rts_cmd;
399
400         /* The RTS flags */
401         typedef [public, bitmap16bit] bitmap {
402                 RTS_FLAG_NONE                   =       0x0000,
403                 RTS_FLAG_PING                   =       0x0001,
404                 RTS_FLAG_OTHER_CMD              =       0x0002,
405                 RTS_FLAG_RECYCLE_CHANNEL        =       0x0004,
406                 RTS_FLAG_IN_CHANNEL             =       0x0008,
407                 RTS_FLAG_OUT_CHANNEL            =       0x0010,
408                 RTS_FLAG_EOF                    =       0x0020,
409                 RTS_FLAG_ECHO                   =       0x0040
410         } dcerpc_rts_flags;
411
412         typedef [public] struct {
413                 dcerpc_rts_flags        Flags;
414                 uint16                  NumberOfCommands;
415                 dcerpc_rts_cmd          Commands[NumberOfCommands];
416         } dcerpc_rts;
417
418         typedef [enum8bit] enum {
419                 DCERPC_PKT_REQUEST     =  0,    /* Ordinary request. */
420                 DCERPC_PKT_PING        =  1,    /* Connectionless is server alive ? */
421                 DCERPC_PKT_RESPONSE    =  2,    /* Ordinary reply. */
422                 DCERPC_PKT_FAULT       =  3,    /* Fault in processing of call. */
423                 DCERPC_PKT_WORKING     =  4,    /* Connectionless reply to a ping when server busy. */
424                 DCERPC_PKT_NOCALL      =  5,    /* Connectionless reply to a ping when server has lost part of clients call. */
425                 DCERPC_PKT_REJECT      =  6,    /* Refuse a request with a code. */
426                 DCERPC_PKT_ACK         =  7,    /* Connectionless client to server code. */
427                 DCERPC_PKT_CL_CANCEL   =  8,    /* Connectionless cancel. */
428                 DCERPC_PKT_FACK        =  9,    /* Connectionless fragment ack. Both client and server send. */
429                 DCERPC_PKT_CANCEL_ACK  = 10,    /* Server ACK to client cancel request. */
430                 DCERPC_PKT_BIND        = 11,    /* Bind to interface. */
431                 DCERPC_PKT_BIND_ACK    = 12,    /* Server ack of bind. */
432                 DCERPC_PKT_BIND_NAK    = 13,    /* Server nack of bind. */
433                 DCERPC_PKT_ALTER       = 14,    /* Alter auth. */
434                 DCERPC_PKT_ALTER_RESP  = 15,    /* Reply to alter auth. */
435                 DCERPC_PKT_AUTH3       = 16,    /* not the real name!  this is undocumented! */
436                 DCERPC_PKT_SHUTDOWN    = 17,    /* Server to client request to shutdown. */
437                 DCERPC_PKT_CO_CANCEL   = 18,    /* Connection-oriented cancel request. */
438                 DCERPC_PKT_ORPHANED    = 19,    /* Client telling server it's aborting a partially sent request or telling server to stop sending replies. */
439                 DCERPC_PKT_RTS         = 20     /* RTS packets used in ncacn_http */
440         } dcerpc_pkt_type;
441
442         typedef [nodiscriminant] union {
443                 [case(DCERPC_PKT_REQUEST)]    dcerpc_request  request;
444                 [case(DCERPC_PKT_PING)]           dcerpc_ping ping;
445                 [case(DCERPC_PKT_RESPONSE)]   dcerpc_response response;
446                 [case(DCERPC_PKT_FAULT)]          dcerpc_fault fault;
447                 [case(DCERPC_PKT_WORKING)]        dcerpc_working working;
448                 [case(DCERPC_PKT_NOCALL)]     dcerpc_fack nocall;
449                 [case(DCERPC_PKT_REJECT)]     dcerpc_fault reject;
450                 [case(DCERPC_PKT_ACK)]        dcerpc_ack ack;
451                 [case(DCERPC_PKT_CL_CANCEL)]  dcerpc_cl_cancel cl_cancel;
452                 [case(DCERPC_PKT_FACK)]       dcerpc_fack fack;
453                 [case(DCERPC_PKT_CANCEL_ACK)] dcerpc_cancel_ack cancel_ack;
454                 [case(DCERPC_PKT_BIND)]       dcerpc_bind     bind;
455                 [case(DCERPC_PKT_BIND_ACK)]   dcerpc_bind_ack bind_ack;
456                 [case(DCERPC_PKT_BIND_NAK)]   dcerpc_bind_nak bind_nak;
457                 [case(DCERPC_PKT_ALTER)]      dcerpc_bind     alter;
458                 [case(DCERPC_PKT_ALTER_RESP)] dcerpc_bind_ack alter_resp;
459                 [case(DCERPC_PKT_SHUTDOWN)]   dcerpc_shutdown shutdown;
460                 [case(DCERPC_PKT_CO_CANCEL)]  dcerpc_co_cancel co_cancel;
461                 [case(DCERPC_PKT_ORPHANED)]   dcerpc_orphaned orphaned;
462                 [case(DCERPC_PKT_AUTH3)]      dcerpc_auth3    auth3;
463                 [case(DCERPC_PKT_RTS)]        dcerpc_rts      rts;
464         } dcerpc_payload;
465
466         /* pfc_flags values */
467         const uint8 DCERPC_PFC_FLAG_FIRST               = 0x01; /* First fragment */
468         const uint8 DCERPC_PFC_FLAG_LAST                = 0x02; /* Last fragment */
469         const uint8 DCERPC_PFC_FLAG_PENDING_CANCEL      = 0x04; /* Cancel was pending at sender */
470         const uint8 DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN = DCERPC_PFC_FLAG_PENDING_CANCEL; /* depends on the pdu type */
471         const uint8 DCERPC_PFC_FLAG_CONC_MPX            = 0x10; /* supports concurrent multiplexing of a single connection. */
472         const uint8 DCERPC_PFC_FLAG_DID_NOT_EXECUTE     = 0x20; /* on a fault it means the server hasn't done anything */
473         const uint8 DCERPC_PFC_FLAG_MAYBE               = 0x40; /* `maybe' call semantics requested */
474         const uint8 DCERPC_PFC_FLAG_OBJECT_UUID         = 0x80; /* on valid guid is in the optional object field */
475
476         /* these offsets are needed by the signing code */
477         const uint8 DCERPC_PFC_OFFSET      =  3;
478         const uint8 DCERPC_DREP_OFFSET     =  4;
479         const uint8 DCERPC_FRAG_LEN_OFFSET =  8;
480         const uint8 DCERPC_AUTH_LEN_OFFSET = 10;
481         const uint8 DCERPC_NCACN_PAYLOAD_OFFSET = 16;
482
483         /* little-endian flag */
484         const uint8 DCERPC_DREP_LE  = 0x10;
485
486         typedef [public] struct {
487                 uint8 rpc_vers;         /* RPC version */
488                 uint8 rpc_vers_minor;   /* Minor version */
489                 dcerpc_pkt_type ptype;  /* Packet type */
490                 uint8 pfc_flags;        /* Fragmentation flags */
491                 uint8 drep[4];          /* NDR data representation */
492                 uint16 frag_length;     /* Total length of fragment */
493                 uint16 auth_length;     /* authenticator length */
494                 uint32 call_id;         /* Call identifier */
495                 [switch_is(ptype)] dcerpc_payload u;
496         } ncacn_packet;
497
498         typedef [public] struct {
499                 uint8 rpc_vers;         /* RPC version (4) */
500                 uint8 ptype;
501                 uint8 pfc_flags;
502                 uint8 ncadg_flags;
503                 uint8 drep[3];
504                 uint8 serial_high;
505                 GUID object;
506                 GUID iface;
507                 GUID activity;
508                 uint32 server_boot; /* Server boot time */
509                 uint32 iface_version;
510                 uint32 seq_num;
511                 uint16 opnum;
512                 uint16 ihint;
513                 uint16 ahint;
514                 uint16 len;
515                 uint16 fragnum;
516                 uint8 auth_proto;
517                 uint8 serial_low;
518                 [switch_is(ptype)] dcerpc_payload u;
519         } ncadg_packet;
520
521         typedef [bitmap16bit] bitmap {
522                 DCERPC_SEC_VT_COMMAND_ENUM  = 0x3FFF,
523                 DCERPC_SEC_VT_COMMAND_END   = 0x4000,
524                 DCERPC_SEC_VT_MUST_PROCESS  = 0x8000
525         } dcerpc_sec_vt_command;
526
527         typedef [enum16bit] enum {
528                 DCERPC_SEC_VT_COMMAND_BITMASK1  = 0x0001,
529                 DCERPC_SEC_VT_COMMAND_PCONTEXT  = 0x0002,
530                 DCERPC_SEC_VT_COMMAND_HEADER2   = 0x0003
531         } dcerpc_sec_vt_command_enum;
532
533         typedef [bitmap32bit] bitmap {
534                 DCERPC_SEC_VT_CLIENT_SUPPORTS_HEADER_SIGNING = 0x00000001
535         } dcerpc_sec_vt_bitmask1;
536
537         typedef struct {
538                 ndr_syntax_id abstract_syntax;
539                 ndr_syntax_id transfer_syntax;
540         } dcerpc_sec_vt_pcontext;
541
542         typedef struct {
543                 dcerpc_pkt_type ptype;  /* Packet type */
544                 [value(0)] uint8 reserved1;
545                 [value(0)] uint16 reserved2;
546                 uint8 drep[4];          /* NDR data representation */
547                 uint32 call_id;         /* Call identifier */
548                 uint16 context_id;
549                 uint16 opnum;
550         } dcerpc_sec_vt_header2;
551
552         typedef [switch_type(dcerpc_sec_vt_command_enum),nodiscriminant] union {
553         [case(DCERPC_SEC_VT_COMMAND_BITMASK1)] dcerpc_sec_vt_bitmask1 bitmask1;
554         [case(DCERPC_SEC_VT_COMMAND_PCONTEXT)] dcerpc_sec_vt_pcontext pcontext;
555         [case(DCERPC_SEC_VT_COMMAND_HEADER2)] dcerpc_sec_vt_header2 header2;
556         [default,flag(NDR_REMAINING)] DATA_BLOB _unknown;
557         } dcerpc_sec_vt_union;
558
559         typedef struct {
560                 dcerpc_sec_vt_command command;
561                 [switch_is(command & DCERPC_SEC_VT_COMMAND_ENUM)]
562                         [subcontext(2),flag(NDR_SUBCONTEXT_NO_UNREAD_BYTES)]
563                         dcerpc_sec_vt_union u;
564         } dcerpc_sec_vt;
565
566         typedef [public,nopush,nopull] struct {
567                 uint16 count;
568         } dcerpc_sec_vt_count;
569
570         /*
571          * We assume that the whole verification trailer fits into
572          * the last 1024 bytes after the stub data.
573          *
574          * There're currently only 3 commands defined and each should
575          * only be used once.
576          */
577         const uint16 DCERPC_SEC_VT_MAX_SIZE = 1024;
578
579         typedef [public,flag(NDR_PAHEX)] struct {
580                 [flag(NDR_ALIGN4)] DATA_BLOB _pad;
581                 [value(DCERPC_SEC_VT_MAGIC)] uint8 magic[8];
582                 dcerpc_sec_vt_count count;
583                 dcerpc_sec_vt commands[count.count];
584         } dcerpc_sec_verification_trailer;
585 }