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