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