another major bit of restructuring of rpc in Samba4. Mostly moving
[nivanova/samba-autobuild/.git] / source4 / librpc / rpc / dcerpc.h
1 /* 
2    Unix SMB/CIFS implementation.
3    DCERPC interface structures
4
5    Copyright (C) Tim Potter 2003
6    Copyright (C) Andrew Tridgell 2003
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 /*
24   see http://www.opengroup.org/onlinepubs/9629399/chap12.htm for details
25   of these structures
26
27   note that the structure definitions here don't include some of the
28   fields that are wire-artifacts. Those are put on the wire by the
29   marshalling/unmarshalling routines in decrpc.c
30 */
31
32 struct dcerpc_pipe {
33         TALLOC_CTX *mem_ctx;
34         uint16 fnum;
35         int reference_count;
36         uint32 call_id;
37         uint32 srv_max_xmit_frag;
38         uint32 srv_max_recv_frag;
39         struct cli_tree *tree;
40 };
41
42 /* dcerpc packet types */
43 #define DCERPC_PKT_REQUEST   0
44 #define DCERPC_PKT_RESPONSE  2
45 #define DCERPC_PKT_BIND     11
46 #define DCERPC_PKT_BIND_ACK 12
47 #define DCERPC_PKT_BIND_NAK 13
48
49 /* hdr.pfc_flags */
50 #define DCERPC_PFC_FLAG_FIRST   0x01
51 #define DCERPC_PFC_FLAG_LAST    0x02
52 #define DCERPC_PFC_FLAG_NOCALL  0x20
53
54 /*
55   all dcerpc packets use this structure. 
56 */
57 struct dcerpc_packet {
58         /* all requests and responses contain a dcerpc header */
59         struct dcerpc_hdr {
60                 uint8 rpc_vers;         /* RPC version */
61                 uint8 rpc_vers_minor;   /* Minor version */
62                 uint8 ptype;            /* Packet type */
63                 uint8 pfc_flags;        /* Fragmentation flags */
64                 uint8 drep[4];          /* NDR data representation */
65                 uint16 frag_length;     /* Total length of fragment */
66                 uint16 auth_length;     /* authenticator length */
67                 uint32 call_id;         /* Call identifier */
68         } hdr;
69
70         union {
71                 struct dcerpc_bind {
72                         uint16 max_xmit_frag;
73                         uint16 max_recv_frag;
74                         uint32 assoc_group_id;
75                         uint8 num_contexts;
76                         struct {
77                                 uint16 context_id;
78                                 uint8 num_transfer_syntaxes;
79                                 struct dcerpc_syntax_id {
80                                         const char *uuid_str;
81                                         uint32 if_version;
82                                 } abstract_syntax;
83                                 const struct dcerpc_syntax_id *transfer_syntaxes;
84                         } *ctx_list;
85                         DATA_BLOB auth_verifier;
86                 } bind;
87
88                 struct dcerpc_request {
89                         uint32 alloc_hint;
90                         uint16 context_id;
91                         uint16 opnum;
92                         DATA_BLOB stub_data;
93                         DATA_BLOB auth_verifier;
94                 } request;
95         } in;
96
97         union {
98                 struct dcerpc_bind_ack {
99                         uint16 max_xmit_frag;
100                         uint16 max_recv_frag;
101                         uint32 assoc_group_id;
102                         const char *secondary_address;
103                         uint8 num_results;
104                         struct {
105                                 uint32 result;
106                                 struct dcerpc_syntax_id syntax;
107                         } *ctx_list;
108                         DATA_BLOB auth_verifier;
109                 } bind_ack;
110
111                 struct dcerpc_bind_nak {
112                         uint16 reject_reason;
113                         uint32 num_versions;
114                         uint32 *versions;
115                 } bind_nak;
116
117                 struct dcerpc_response {
118                         uint32 alloc_hint;
119                         uint16 context_id;
120                         uint8 cancel_count;
121                         DATA_BLOB stub_data;
122                         DATA_BLOB auth_verifier;                
123                 } response;
124         } out;
125 };
126
127 /* this seems to be the only transfer syntax used */
128 #define DCERPC_TRANSFER_SYNTAX_V2 {"8a885d04-1ceb-11c9-9fe8-08002b104860", 2}
129