remoevd a misplaced comma
[tprouty/samba.git] / source / include / rpc_dce.h
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    SMB parameters and setup
5    Copyright (C) Andrew Tridgell 1992-1997
6    Copyright (C) Luke Kenneth Casson Leighton 1996-1997
7    Copyright (C) Paul Ashton 1997
8    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #ifndef _DCE_RPC_H /* _DCE_RPC_H */
25 #define _DCE_RPC_H 
26
27 #include "rpc_misc.h" /* this only pulls in STRHDR */
28
29
30 /* DCE/RPC packet types */
31
32 enum RPC_PKT_TYPE
33 {
34         RPC_REQUEST = 0x00,
35         RPC_RESPONSE = 0x02,
36         RPC_BIND     = 0x0B,
37         RPC_BINDACK  = 0x0C
38 };
39
40 /* DCE/RPC flags */
41 #define RPC_FLG_FIRST 0x01
42 #define RPC_FLG_LAST  0x02
43
44 /* NTLMSSP message types */
45 enum NTLM_MESSAGE_TYPE
46 {
47         NTLMSSP_NEGOTIATE = 1,
48         NTLMSSP_CHALLENGE = 2,
49         NTLMSSP_AUTH      = 3,
50         NTLMSSP_UNKNOWN   = 4
51 };
52
53 /* NTLMSSP negotiation flags */
54 #define NTLMSSP_NEGOTIATE_UNICODE          0x00000001
55 #define NTLMSSP_NEGOTIATE_OEM              0x00000002
56 #define NTLMSSP_REQUEST_TARGET             0x00000004
57 #define NTLMSSP_NEGOTIATE_SIGN             0x00000010
58 #define NTLMSSP_NEGOTIATE_SEAL             0x00000020
59 #define NTLMSSP_NEGOTIATE_LM_KEY           0x00000080
60 #define NTLMSSP_NEGOTIATE_NTLM             0x00000200
61 #define NTLMSSP_NEGOTIATE_ALWAYS_SIGN      0x00008000
62 #define NTLMSSP_NEGOTIATE_NTLM2            0x00080000
63 #define NTLMSSP_NEGOTIATE_TARGET_INFO      0x00800000
64 #define NTLMSSP_NEGOTIATE_128              0x20000000
65 #define NTLMSSP_NEGOTIATE_KEY_EXCH         0x40000000
66
67 /* RPC_IFACE */
68 typedef struct rpc_iface_info
69 {
70   uint8 data[16];    /* 16 bytes of rpc interface identification */
71   uint32 version;    /* the interface version number */
72
73 } RPC_IFACE;
74
75 struct pipe_id_info
76 {
77         /* the names appear not to matter: the syntaxes _do_ matter */
78
79         char *client_pipe;
80         RPC_IFACE abstr_syntax; /* this one is the abstract syntax id */
81
82         char *server_pipe;  /* this one is the secondary syntax name */
83         RPC_IFACE trans_syntax; /* this one is the primary syntax id */
84 };
85
86 /* RPC_HDR - dce rpc header */
87 typedef struct rpc_hdr_info
88 {
89   uint8  major; /* 5 - RPC major version */
90   uint8  minor; /* 0 - RPC minor version */
91   uint8  pkt_type; /* RPC_PKT_TYPE - RPC response packet */
92   uint8  flags; /* DCE/RPC flags */
93   uint32 pack_type; /* 0x1000 0000 - packed data representation */
94   uint16 frag_len; /* fragment length - data size (bytes) inc header and tail. */
95   uint16 auth_len; /* 0 - authentication length  */
96   uint32 call_id; /* call identifier.  matches 12th uint32 of incoming RPC data. */
97
98 } RPC_HDR;
99
100 /* RPC_HDR_REQ - ms request rpc header */
101 typedef struct rpc_hdr_req_info
102 {
103   uint32 alloc_hint;   /* allocation hint - data size (bytes) minus header and tail. */
104   uint16 context_id;   /* 0 - presentation context identifier */
105   uint16  opnum;        /* opnum */
106
107 } RPC_HDR_REQ;
108
109 /* RPC_HDR_RESP - ms response rpc header */
110 typedef struct rpc_hdr_resp_info
111 {
112   uint32 alloc_hint;   /* allocation hint - data size (bytes) minus header and tail. */
113   uint16 context_id;   /* 0 - presentation context identifier */
114   uint8  cancel_count; /* 0 - cancel count */
115   uint8  reserved;     /* 0 - reserved. */
116
117 } RPC_HDR_RESP;
118
119 /* this seems to be the same string name depending on the name of the pipe,
120  * but is more likely to be linked to the interface name
121  * "srvsvc", "\\PIPE\\ntsvcs"
122  * "samr", "\\PIPE\\lsass"
123  * "wkssvc", "\\PIPE\\wksvcs"
124  * "NETLOGON", "\\PIPE\\NETLOGON"
125  */
126 /* RPC_ADDR_STR */
127 typedef struct rpc_addr_info
128 {
129   uint16 len;   /* length of the string including null terminator */
130   fstring str; /* the string above in single byte, null terminated form */
131
132 } RPC_ADDR_STR;
133
134 /* RPC_HDR_BBA */
135 typedef struct rpc_hdr_bba_info
136 {
137   uint16 max_tsize;       /* maximum transmission fragment size (0x1630) */
138   uint16 max_rsize;       /* max receive fragment size (0x1630) */
139   uint32 assoc_gid;       /* associated group id (0x0) */
140
141 } RPC_HDR_BBA;
142
143 /* RPC_BIND_REQ - ms req bind */
144 typedef struct rpc_bind_req_info
145 {
146   RPC_HDR_BBA bba;
147
148   uint32 num_elements;    /* the number of elements (0x1) */
149   uint16 context_id;      /* presentation context identifier (0x0) */
150   uint8 num_syntaxes;     /* the number of syntaxes (has always been 1?)(0x1) */
151
152   RPC_IFACE abstract;     /* num and vers. of interface client is using */
153   RPC_IFACE transfer;     /* num and vers. of interface to use for replies */
154   
155 } RPC_HDR_RB;
156
157 /* RPC_RESULTS - can only cope with one reason, right now... */
158 typedef struct rpc_results_info
159 {
160 /* uint8[] # 4-byte alignment padding, against SMB header */
161
162   uint8 num_results; /* the number of results (0x01) */
163
164 /* uint8[] # 4-byte alignment padding, against SMB header */
165
166   uint16 result; /* result (0x00 = accept) */
167   uint16 reason; /* reason (0x00 = no reason specified) */
168
169 } RPC_RESULTS;
170
171 /* RPC_HDR_BA */
172 typedef struct rpc_hdr_ba_info
173 {
174   RPC_HDR_BBA bba;
175
176   RPC_ADDR_STR addr    ;  /* the secondary address string, as described earlier */
177   RPC_RESULTS  res     ; /* results and reasons */
178   RPC_IFACE    transfer; /* the transfer syntax from the request */
179
180 } RPC_HDR_BA;
181
182 /* this is TEMPORARY */
183 /* RPC_AUTH_VERIFIER */
184 typedef struct rpc_auth_verif_info
185 {
186         uint8 auth_type; /* 0x0a */
187         uint8 auth_level; /* 0x06 */
188         uint8 stub_type_len; /* don't know */
189         uint8 padding; /* padding */
190
191         uint32 ptr_0; /* non-zero pointer to something */
192
193         fstring signature; /* "NTLMSSP" */
194         uint32  msg_type; /* NTLMSSP_MESSAGE_TYPE (1,2,3) */
195
196 } RPC_AUTH_VERIFIER;
197
198 /* this is TEMPORARILY coded up as a specific structure */
199 /* this structure comes after the bind request */
200 /* RPC_AUTH_NTLMSSP_NEG */
201 typedef struct rpc_auth_ntlmssp_neg_info
202 {
203         uint32  neg_flgs; /* 0x0000 b2b3 */
204
205         STRHDR hdr_myname; /* offset is against START of this structure */
206         STRHDR hdr_domain; /* offset is against START of this structure */
207
208         fstring myname; /* calling workstation's name */
209         fstring domain; /* calling workstations's domain */
210
211 } RPC_AUTH_NTLMSSP_NEG;
212
213 /* this is TEMPORARILY coded up as a specific structure */
214 /* this structure comes after the bind acknowledgement */
215 /* RPC_AUTH_NTLMSSP_CHAL */
216 typedef struct rpc_auth_ntlmssp_chal_info
217 {
218         uint32 unknown_1; /* 0x0000 0000 */
219         uint32 unknown_2; /* 0x0000 0028 */
220         uint32 neg_flags; /* 0x0000 82b1 */
221
222         uint8 challenge[8]; /* ntlm challenge */
223         uint8 reserved [8]; /* zeros */
224
225 } RPC_AUTH_NTLMSSP_CHAL;
226
227
228 /* RPC_AUTH_NTLMSSP_RESP */
229 typedef struct rpc_auth_ntlmssp_resp_info
230 {
231         STRHDR hdr_lm_resp; /* 24 byte response */
232         STRHDR hdr_nt_resp; /* 24 byte response */
233         STRHDR hdr_domain;
234         UNIHDR hdr_usr;
235         UNIHDR hdr_wks;
236         UNIHDR hdr_sess_key; /* NULL unless negotiated */
237         uint32 neg_flags; /* 0x0000 82b1 */
238
239         fstring uni_sess_key;
240         fstring uni_wks;
241         fstring uni_usr;
242         fstring uni_domain;
243         fstring str_nt_resp;
244         fstring str_lm_resp;
245
246 } RPC_AUTH_NTLMSSP_RESP;
247
248
249 /* attached to the end of encrypted rpc requests and responses */
250 /* RPC_AUTH_NTLMSSP_CHK */
251 typedef struct rpc_auth_ntlmssp_chk_info
252 {
253         uint32 ver; /* 0x0000 0001 */
254         uint8  crc32[8]; /* checksum using 0xEDB8 8320 as a polynomial */
255         uint32 seq_num;
256
257 } RPC_AUTH_NTLMSSP_CHK;
258
259 #endif /* _DCE_RPC_H */
260