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