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