5816259ae73ef95fe158e970c96d7ccf5f88c0f3
[bbaumbach/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 [
12 pointer_default(unique)
13 ]
14 interface dcerpc
15 {
16         typedef [public] struct {
17                 GUID uuid;
18                 uint32 if_version;
19         } dcerpc_syntax_id;
20
21         typedef struct {
22                 uint16 context_id;
23                 uint8 num_transfer_syntaxes;
24                 dcerpc_syntax_id abstract_syntax;
25                 dcerpc_syntax_id transfer_syntaxes[num_transfer_syntaxes];
26         } dcerpc_ctx_list;
27
28         typedef struct {
29                 uint16 max_xmit_frag;
30                 uint16 max_recv_frag;
31                 uint32 assoc_group_id;
32                 uint8  num_contexts;
33                 dcerpc_ctx_list ctx_list[num_contexts];
34                 [flag(NDR_ALIGN4)]    DATA_BLOB _pad;
35                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
36         } dcerpc_bind;
37
38
39         const uint8 DCERPC_REQUEST_LENGTH = 24;
40         const uint8 DCERPC_MAX_SIGN_SIZE  = 32;
41
42         typedef struct {
43         } dcerpc_empty;
44         
45         typedef [nodiscriminant] union {
46                 [default] dcerpc_empty empty;
47                 [case(LIBNDR_FLAG_OBJECT_PRESENT)] GUID object;
48         } dcerpc_object;
49
50         typedef struct {
51                 uint32 alloc_hint;
52                 uint16 context_id;
53                 uint16 opnum;
54                 [switch_is(ndr->flags & LIBNDR_FLAG_OBJECT_PRESENT)] dcerpc_object object;
55                 [flag(NDR_ALIGN8)]    DATA_BLOB _pad;
56                 [flag(NDR_REMAINING)] DATA_BLOB stub_and_verifier;
57         } dcerpc_request;
58
59         const int DCERPC_BIND_PROVIDER_REJECT = 2;
60         const int DCERPC_BIND_REASON_ASYNTAX  = 1;
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                 uint16 reject_reason;
81                 uint32 num_versions;
82                 uint32 versions[num_versions];
83         } dcerpc_bind_nak;
84
85         const uint8 DCERPC_RESPONSE_LENGTH = 24;
86
87         typedef struct {
88                 uint32 alloc_hint;
89                 uint16 context_id;
90                 uint8 cancel_count;
91                 [flag(NDR_ALIGN8)]    DATA_BLOB _pad;
92                 [flag(NDR_REMAINING)] DATA_BLOB stub_and_verifier;
93         } dcerpc_response;
94
95
96         const int DCERPC_FAULT_OP_RNG_ERROR       = 0x1c010002;
97         const int DCERPC_FAULT_UNK_IF             = 0x1c010003;
98         const int DCERPC_FAULT_NDR                = 0x000006f7;
99         const int DCERPC_FAULT_INVALID_TAG        = 0x1c000006;
100         const int DCERPC_FAULT_CONTEXT_MISMATCH   = 0x1c00001a;
101         const int DCERPC_FAULT_OTHER              = 0x00000001;
102         const int DCERPC_FAULT_ACCESS_DENIED      = 0x00000005;
103         const int DCERPC_FAULT_CANT_PERFORM       = 0x000006d8;
104
105         /* we return this fault when we haven't yet run the test
106            to see what fault w2k3 returns in this case */
107         const int DCERPC_FAULT_TODO         = 0x00000042;
108
109         typedef struct {
110                 uint32 alloc_hint;
111                 uint16 context_id;
112                 uint8 cancel_count;
113                 uint32 status;
114         } dcerpc_fault;
115
116         /* the auth types we know about */
117         const uint8 DCERPC_AUTH_TYPE_NONE     = 0;
118         /* this seems to be not krb5! */
119         const uint8 DCERPC_AUTH_TYPE_KRB5_1   = 1;
120         const uint8 DCERPC_AUTH_TYPE_SPNEGO   = 9;
121         const uint8 DCERPC_AUTH_TYPE_NTLMSSP  = 10;
122         /* I'm not 100% sure but type 16(0x10)
123          * seems to be raw krb5 --metze
124          */
125         const uint8 DCERPC_AUTH_TYPE_KRB5     = 16;
126         const uint8 DCERPC_AUTH_TYPE_SCHANNEL = 68;
127         const uint8 DCERPC_AUTH_TYPE_MSMQ     = 100;
128
129         const uint8 DCERPC_AUTH_LEVEL_DEFAULT   = DCERPC_AUTH_LEVEL_CONNECT;
130         const uint8 DCERPC_AUTH_LEVEL_NONE      = 1;
131         const uint8 DCERPC_AUTH_LEVEL_CONNECT   = 2;
132         const uint8 DCERPC_AUTH_LEVEL_CALL      = 3;
133         const uint8 DCERPC_AUTH_LEVEL_PACKET    = 4;
134         const uint8 DCERPC_AUTH_LEVEL_INTEGRITY = 5;
135         const uint8 DCERPC_AUTH_LEVEL_PRIVACY   = 6;
136
137         typedef [public] struct {
138                 uint8  auth_type; 
139                 uint8  auth_level;
140                 uint8  auth_pad_length;
141                 uint8  auth_reserved;
142                 uint32 auth_context_id;
143                 [flag(NDR_REMAINING)] DATA_BLOB credentials;
144         } dcerpc_auth;
145
146         typedef [public] struct {
147                 uint32 _pad;
148                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
149         } dcerpc_auth3;
150
151         typedef [public] struct {
152                 uint32 _pad;
153                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
154         } dcerpc_orphaned;
155
156         typedef [public] struct {
157                 uint32 _pad;
158                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
159         } dcerpc_co_cancel;
160
161         typedef [public] struct {
162                 uint32 version;
163                 uint32 id;
164         } dcerpc_cl_cancel;
165
166         typedef [public] struct {
167                 uint32 version; 
168                 uint32 id;
169                 boolean32 server_is_accepting;
170         } dcerpc_cancel_ack;
171
172         typedef [public] struct {
173                 uint32 version;
174                 uint8 _pad1;
175                 uint16 window_size;
176                 uint32 max_tdsu;
177                 uint32 max_frag_size;
178                 uint16 serial_no;
179                 uint16 selack_size;
180                 uint32 selack[selack_size];
181         } dcerpc_fack;
182
183         typedef [public] struct {
184         } dcerpc_ack;
185
186         typedef [public] struct {
187         } dcerpc_ping;
188
189         typedef [public] struct {
190         } dcerpc_shutdown;
191         
192         typedef [public] struct {
193         } dcerpc_working;
194
195         typedef [enum8bit] enum {
196                 DCERPC_PKT_REQUEST     =  0,
197                 DCERPC_PKT_PING        =  1,
198                 DCERPC_PKT_RESPONSE    =  2,
199                 DCERPC_PKT_FAULT       =  3,
200                 DCERPC_PKT_WORKING     =  4,
201                 DCERPC_PKT_NOCALL      =  5,
202                 DCERPC_PKT_REJECT      =  6,
203                 DCERPC_PKT_ACK         =  7,
204                 DCERPC_PKT_CL_CANCEL   =  8,
205                 DCERPC_PKT_FACK        =  9,
206                 DCERPC_PKT_CANCEL_ACK  = 10,
207                 DCERPC_PKT_BIND        = 11,
208                 DCERPC_PKT_BIND_ACK    = 12,
209                 DCERPC_PKT_BIND_NAK    = 13,
210                 DCERPC_PKT_ALTER       = 14,
211                 DCERPC_PKT_ALTER_RESP  = 15,
212                 DCERPC_PKT_AUTH3       = 16,
213                 DCERPC_PKT_SHUTDOWN    = 17,
214                 DCERPC_PKT_CO_CANCEL   = 18,
215                 DCERPC_PKT_ORPHANED    = 19
216         } dcerpc_pkt_type;
217
218         typedef [nodiscriminant] union {
219                 [case(DCERPC_PKT_REQUEST)]    dcerpc_request  request;
220                 [case(DCERPC_PKT_PING)]           dcerpc_ping ping;
221                 [case(DCERPC_PKT_RESPONSE)]   dcerpc_response response;
222                 [case(DCERPC_PKT_FAULT)]          dcerpc_fault fault;
223                 [case(DCERPC_PKT_WORKING)]        dcerpc_working working;
224                 [case(DCERPC_PKT_NOCALL)]     dcerpc_fack nocall;
225                 [case(DCERPC_PKT_REJECT)]     dcerpc_fault reject;
226                 [case(DCERPC_PKT_ACK)]        dcerpc_ack ack;
227                 [case(DCERPC_PKT_CL_CANCEL)]  dcerpc_cl_cancel cl_cancel;
228                 [case(DCERPC_PKT_FACK)]       dcerpc_fack fack;
229                 [case(DCERPC_PKT_CANCEL_ACK)] dcerpc_cancel_ack cancel_ack;
230                 [case(DCERPC_PKT_BIND)]       dcerpc_bind     bind;
231                 [case(DCERPC_PKT_BIND_ACK)]   dcerpc_bind_ack bind_ack;
232                 [case(DCERPC_PKT_BIND_NAK)]   dcerpc_bind_nak bind_nak;
233                 [case(DCERPC_PKT_ALTER)]      dcerpc_bind     alter;
234                 [case(DCERPC_PKT_ALTER_RESP)] dcerpc_bind_ack alter_resp;
235                 [case(DCERPC_PKT_SHUTDOWN)]   dcerpc_shutdown shutdown;
236                 [case(DCERPC_PKT_CO_CANCEL)]  dcerpc_co_cancel co_cancel;
237                 [case(DCERPC_PKT_ORPHANED)]   dcerpc_orphaned orphaned;
238                 [case(DCERPC_PKT_AUTH3)]      dcerpc_auth3    auth3;
239         } dcerpc_payload;
240
241         /* pfc_flags values */
242         const uint8 DCERPC_PFC_FLAG_FIRST  = 0x01;
243         const uint8 DCERPC_PFC_FLAG_LAST   = 0x02;
244         const uint8 DCERPC_PFC_FLAG_NOCALL = 0x20;
245         const uint8 DCERPC_PFC_FLAG_ORPC   = 0x80;
246
247         /* these offsets are needed by the signing code */
248         const uint8 DCERPC_DREP_OFFSET     =  4;
249         const uint8 DCERPC_FRAG_LEN_OFFSET =  8;
250         const uint8 DCERPC_AUTH_LEN_OFFSET = 10;
251
252         /* little-endian flag */
253         const uint8 DCERPC_DREP_LE  = 0x10;
254
255         typedef [public] struct {
256                 uint8 rpc_vers;         /* RPC version */
257                 uint8 rpc_vers_minor;   /* Minor version */
258                 dcerpc_pkt_type ptype;  /* Packet type */
259                 uint8 pfc_flags;        /* Fragmentation flags */
260                 uint8 drep[4];          /* NDR data representation */
261                 uint16 frag_length;     /* Total length of fragment */
262                 uint16 auth_length;     /* authenticator length */
263                 uint32 call_id;         /* Call identifier */
264                 [switch_is(ptype)] dcerpc_payload u;
265         } ncacn_packet;
266
267         typedef [public] struct {
268                 uint8 rpc_vers;         /* RPC version (4) */
269                 uint8 ptype;
270                 uint8 pfc_flags;
271                 uint8 ncadg_flags;
272                 uint8 drep[3];
273                 uint8 serial_high;
274                 GUID object;
275                 GUID iface;
276                 GUID activity;
277                 uint32 server_boot; /* Server boot time */
278                 uint32 iface_version;
279                 uint32 seq_num;
280                 uint16 opnum;
281                 uint16 ihint;
282                 uint16 ahint;
283                 uint16 len;
284                 uint16 fragnum;
285                 uint8 auth_proto;
286                 uint8 serial_low;
287                 [switch_is(ptype)] dcerpc_payload u;
288         } ncadg_packet;
289 }