separate the reason and result codes in a bind_ack. This is needed for
[jelmer/samba4-debian.git] / source / 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         unsigned flags;
41 };
42
43 /* dcerpc packet types */
44 #define DCERPC_PKT_REQUEST   0
45 #define DCERPC_PKT_RESPONSE  2
46 #define DCERPC_PKT_BIND     11
47 #define DCERPC_PKT_BIND_ACK 12
48 #define DCERPC_PKT_BIND_NAK 13
49
50 /* hdr.pfc_flags */
51 #define DCERPC_PFC_FLAG_FIRST   0x01
52 #define DCERPC_PFC_FLAG_LAST    0x02
53 #define DCERPC_PFC_FLAG_NOCALL  0x20
54
55 /* dcerpc pipe flags */
56 #define DCERPC_DEBUG_PRINT_IN 1
57 #define DCERPC_DEBUG_PRINT_OUT 2
58 #define DCERPC_DEBUG_PRINT_BOTH (DCERPC_DEBUG_PRINT_IN | DCERPC_DEBUG_PRINT_OUT)
59
60 /*
61   all dcerpc packets use this structure. 
62 */
63 struct dcerpc_packet {
64         /* all requests and responses contain a dcerpc header */
65         struct dcerpc_hdr {
66                 uint8 rpc_vers;         /* RPC version */
67                 uint8 rpc_vers_minor;   /* Minor version */
68                 uint8 ptype;            /* Packet type */
69                 uint8 pfc_flags;        /* Fragmentation flags */
70                 uint8 drep[4];          /* NDR data representation */
71                 uint16 frag_length;     /* Total length of fragment */
72                 uint16 auth_length;     /* authenticator length */
73                 uint32 call_id;         /* Call identifier */
74         } hdr;
75
76         union {
77                 struct dcerpc_bind {
78                         uint16 max_xmit_frag;
79                         uint16 max_recv_frag;
80                         uint32 assoc_group_id;
81                         uint8 num_contexts;
82                         struct {
83                                 uint16 context_id;
84                                 uint8 num_transfer_syntaxes;
85                                 struct dcerpc_syntax_id {
86                                         const char *uuid_str;
87                                         uint32 if_version;
88                                 } abstract_syntax;
89                                 const struct dcerpc_syntax_id *transfer_syntaxes;
90                         } *ctx_list;
91                         DATA_BLOB auth_verifier;
92                 } bind;
93
94                 struct dcerpc_request {
95                         uint32 alloc_hint;
96                         uint16 context_id;
97                         uint16 opnum;
98                         DATA_BLOB stub_data;
99                         DATA_BLOB auth_verifier;
100                 } request;
101         } in;
102
103         union {
104                 struct dcerpc_bind_ack {
105                         uint16 max_xmit_frag;
106                         uint16 max_recv_frag;
107                         uint32 assoc_group_id;
108                         const char *secondary_address;
109                         uint8 num_results;
110                         struct {
111                                 uint16 result;
112                                 uint16 reason;
113                                 struct dcerpc_syntax_id syntax;
114                         } *ctx_list;
115                         DATA_BLOB auth_verifier;
116                 } bind_ack;
117
118                 struct dcerpc_bind_nak {
119                         uint16 reject_reason;
120                         uint32 num_versions;
121                         uint32 *versions;
122                 } bind_nak;
123
124                 struct dcerpc_response {
125                         uint32 alloc_hint;
126                         uint16 context_id;
127                         uint8 cancel_count;
128                         DATA_BLOB stub_data;
129                         DATA_BLOB auth_verifier;                
130                 } response;
131         } out;
132 };
133