d4fb026c8cc91cf41d535f3c05520e7ad5cfaf75
[gd/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 interface dcerpc
12 {
13         typedef [public] struct {
14                 GUID uuid;
15                 uint32 if_version;
16         } dcerpc_syntax_id;
17
18         typedef struct {
19                 uint16 context_id;
20                 uint8 num_transfer_syntaxes;
21                 dcerpc_syntax_id abstract_syntax;
22                 dcerpc_syntax_id transfer_syntaxes[num_transfer_syntaxes];
23         } dcerpc_ctx_list;
24
25         typedef struct {
26                 uint16 max_xmit_frag;
27                 uint16 max_recv_frag;
28                 uint32 assoc_group_id;
29                 uint8  num_contexts;
30                 dcerpc_ctx_list ctx_list[num_contexts];
31                 [flag(NDR_ALIGN8)]    DATA_BLOB _pad;
32                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
33         } dcerpc_bind;
34
35
36         const uint8 DCERPC_REQUEST_LENGTH = 24;
37         const uint8 DCERPC_MAX_SIGN_SIZE  = 32;
38
39         typedef struct {
40         } dcerpc_empty;
41         
42         typedef [nodiscriminant] union {
43                 [default] dcerpc_empty empty;
44                 [case(LIBNDR_FLAG_OBJECT_PRESENT)] GUID object;
45         } dcerpc_object;
46
47         typedef struct {
48                 uint32 alloc_hint;
49                 uint16 context_id;
50                 uint16 opnum;
51                 [switch_is(ndr->flags & LIBNDR_FLAG_OBJECT_PRESENT)] dcerpc_object object;
52                 [flag(NDR_ALIGN8)]    DATA_BLOB _pad;
53                 [flag(NDR_REMAINING)] DATA_BLOB stub_and_verifier;
54         } dcerpc_request;
55
56         const int DCERPC_BIND_PROVIDER_REJECT = 2;
57         const int DCERPC_BIND_REASON_ASYNTAX  = 1;
58
59         typedef struct {
60                 uint16 result;
61                 uint16 reason;
62                 dcerpc_syntax_id syntax;
63         } dcerpc_ack_ctx;
64
65         typedef struct {
66                 uint16 max_xmit_frag;
67                 uint16 max_recv_frag;
68                 uint32 assoc_group_id;
69                 ascstr3 secondary_address;
70                 [flag(NDR_ALIGN4)]    DATA_BLOB _pad1;
71                 uint8 num_results;
72                 dcerpc_ack_ctx ctx_list[num_results];
73                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
74         } dcerpc_bind_ack;
75
76         typedef struct {
77                 uint16 reject_reason;
78                 uint32 num_versions;
79                 uint32 versions[num_versions];
80         } dcerpc_bind_nak;
81
82         const uint8 DCERPC_RESPONSE_LENGTH = 24;
83
84         typedef struct {
85                 uint32 alloc_hint;
86                 uint16 context_id;
87                 uint8 cancel_count;
88                 [flag(NDR_ALIGN8)]    DATA_BLOB _pad;
89                 [flag(NDR_REMAINING)] DATA_BLOB stub_and_verifier;
90         } dcerpc_response;
91
92
93         const int DCERPC_FAULT_OP_RNG_ERROR       = 0x1c010002;
94         const int DCERPC_FAULT_UNK_IF             = 0x1c010003;
95         const int DCERPC_FAULT_NDR                = 0x000006f7;
96         const int DCERPC_FAULT_INVALID_TAG        = 0x1c000006;
97         const int DCERPC_FAULT_CONTEXT_MISMATCH   = 0x1c00001a;
98         const int DCERPC_FAULT_OTHER              = 0x00000001;
99         const int DCERPC_FAULT_LOGON_FAILURE      = 0x00000005;
100         const int DCERPC_FAULT_CANT_PERFORM       = 0x000006d8;
101
102         /* we return this fault when we haven't yet run the test
103            to see what fault w2k3 returns in this case */
104         const int DCERPC_FAULT_TODO         = 0x00000042;
105
106         typedef struct {
107                 uint32 alloc_hint;
108                 uint16 context_id;
109                 uint8 cancel_count;
110                 uint32 status;
111         } dcerpc_fault;
112
113
114         const uint8 DCERPC_AUTH_TYPE_NONE     = 0;
115         const uint8 DCERPC_AUTH_TYPE_KRB5     = 1;
116         const uint8 DCERPC_AUTH_TYPE_SPNEGO   = 9;
117         const uint8 DCERPC_AUTH_TYPE_NTLMSSP  = 10;
118         /* I'm not 100% sure but type 16(0x10)
119          * seems to be raw krb5 --metze
120          */
121         const uint8 DCERPC_AUTH_TYPE_KRB5_16  = 16;
122         const uint8 DCERPC_AUTH_TYPE_SCHANNEL = 68;
123         const uint8 DCERPC_AUTH_TYPE_MSMQ         = 100;
124         
125         const uint8 DCERPC_AUTH_LEVEL_DEFAULT   = DCERPC_AUTH_LEVEL_CONNECT;
126         const uint8 DCERPC_AUTH_LEVEL_NONE      = 1;
127         const uint8 DCERPC_AUTH_LEVEL_CONNECT   = 2;
128         const uint8 DCERPC_AUTH_LEVEL_CALL      = 3;
129         const uint8 DCERPC_AUTH_LEVEL_PACKET    = 4;
130         const uint8 DCERPC_AUTH_LEVEL_INTEGRITY = 5;
131         const uint8 DCERPC_AUTH_LEVEL_PRIVACY   = 6;
132
133         typedef [public] struct {
134                 uint8  auth_type; 
135                 uint8  auth_level;
136                 uint8  auth_pad_length;
137                 uint8  auth_reserved;
138                 uint32 auth_context_id;
139                 [flag(NDR_REMAINING)] DATA_BLOB credentials;
140         } dcerpc_auth;
141
142         typedef [public] struct {
143                 uint32 _pad;
144                 [flag(NDR_REMAINING)] DATA_BLOB auth_info;
145         } dcerpc_auth3;
146
147         typedef [enum8bit] enum {
148                 DCERPC_PKT_REQUEST     =  0,
149                 DCERPC_PKT_PING        =  1,
150                 DCERPC_PKT_RESPONSE    =  2,
151                 DCERPC_PKT_FAULT       =  3,
152                 DCERPC_PKT_WORKING     =  4,
153                 DCERPC_PKT_NOCALL      =  5,
154                 DCERPC_PKT_REJECT      =  6,
155                 DCERPC_PKT_ACK         =  7,
156                 DCERPC_PKT_CL_CANCEL   =  8,
157                 DCERPC_PKT_FACK        =  9,
158                 DCERPC_PKT_CANCEL_ACK  = 10,
159                 DCERPC_PKT_BIND        = 11,
160                 DCERPC_PKT_BIND_ACK    = 12,
161                 DCERPC_PKT_BIND_NAK    = 13,
162                 DCERPC_PKT_ALTER       = 14,
163                 DCERPC_PKT_ALTER_RESP  = 15,
164                 DCERPC_PKT_AUTH3       = 16,
165                 DCERPC_PKT_SHUTDOWN    = 17,
166                 DCERPC_PKT_CO_CANCEL   = 18,
167                 DCERPC_PKT_ORPHANED    = 19
168         } dcerpc_pkt_type;
169
170         typedef [nodiscriminant] union {
171                 [case(DCERPC_PKT_REQUEST)]    dcerpc_request  request;
172                 [case(DCERPC_PKT_RESPONSE)]   dcerpc_response response;
173                 [case(DCERPC_PKT_BIND)]       dcerpc_bind     bind;
174                 [case(DCERPC_PKT_BIND_ACK)]   dcerpc_bind_ack bind_ack;
175                 [case(DCERPC_PKT_ALTER)]      dcerpc_bind     alter;
176                 [case(DCERPC_PKT_ALTER_RESP)] dcerpc_bind_ack alter_resp;
177                 [case(DCERPC_PKT_FAULT)]      dcerpc_fault    fault;
178                 [case(DCERPC_PKT_AUTH3)]      dcerpc_auth3    auth3;
179                 [case(DCERPC_PKT_BIND_NAK)]   dcerpc_bind_nak bind_nak;
180         } dcerpc_payload;
181
182
183         /* pfc_flags values */
184         const uint8 DCERPC_PFC_FLAG_FIRST  = 0x01;
185         const uint8 DCERPC_PFC_FLAG_LAST   = 0x02;
186         const uint8 DCERPC_PFC_FLAG_NOCALL = 0x20;
187         const uint8 DCERPC_PFC_FLAG_ORPC   = 0x80;
188
189         /* these offsets are needed by the signing code */
190         const uint8 DCERPC_DREP_OFFSET     =  4;
191         const uint8 DCERPC_FRAG_LEN_OFFSET =  8;
192         const uint8 DCERPC_AUTH_LEN_OFFSET = 10;
193
194         /* little-endian flag */
195         const uint8 DCERPC_DREP_LE  = 0x10;
196
197         typedef [public] struct {
198                 uint8 rpc_vers;         /* RPC version */
199                 uint8 rpc_vers_minor;   /* Minor version */
200                 dcerpc_pkt_type ptype;  /* Packet type */
201                 uint8 pfc_flags;        /* Fragmentation flags */
202                 uint8 drep[4];          /* NDR data representation */
203                 uint16 frag_length;     /* Total length of fragment */
204                 uint16 auth_length;     /* authenticator length */
205                 uint32 call_id;         /* Call identifier */
206                 [switch_is(ptype)] dcerpc_payload u;
207         } dcerpc_packet;
208 }