2 Unix SMB/CIFS implementation.
3 SMB parameters and setup
4 Copyright (C) Andrew Tridgell 1992-1997
5 Copyright (C) Luke Kenneth Casson Leighton 1996-1997
6 Copyright (C) Paul Ashton 1997
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.
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.
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.
23 #ifndef _DCE_RPC_H /* _DCE_RPC_H */
26 #include "rpc_misc.h" /* this only pulls in STRHDR */
29 /* DCE/RPC packet types */
39 RPC_ALTCONTRESP
= 0x0F,
40 RPC_BINDRESP
= 0x10 /* not the real name! this is undocumented! */
44 #define RPC_FLG_FIRST 0x01
45 #define RPC_FLG_LAST 0x02
46 #define RPC_FLG_NOCALL 0x20
48 #define SMBD_NTLMSSP_NEG_FLAGS 0x000082b1 /* ALWAYS_SIGN|NEG_NTLM|NEG_LM|NEG_SEAL|NEG_SIGN|NEG_UNICODE */
50 /* NTLMSSP signature version */
51 #define NTLMSSP_SIGN_VERSION 0x01
53 /* NTLMSSP auth type */
54 #define NTLMSSP_AUTH_TYPE 0xa
56 /* DCE-RPC standard identifiers to indicate
57 signing or sealing of an RPC pipe */
58 #define RPC_PIPE_AUTH_SIGN_LEVEL 0x5
59 #define RPC_PIPE_AUTH_SEAL_LEVEL 0x6
61 /* Netlogon schannel auth type and level */
62 #define NETSEC_AUTH_TYPE 0x44
63 #define NETSEC_SIGN_SIGNATURE { 0x77, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 }
64 #define NETSEC_SEAL_SIGNATURE { 0x77, 0x00, 0x7a, 0x00, 0xff, 0xff, 0x00, 0x00 }
66 #define RPC_AUTH_NETSEC_SIGN_OR_SEAL_CHK_LEN 0x20
67 #define RPC_AUTH_NETSEC_SIGN_ONLY_CHK_LEN 0x18
69 /* SPNEGO auth type. */
70 #define SPNEGO_AUTH_TYPE 0x9
72 /* The 7 here seems to be required to get Win2k not to downgrade us
73 to NT4. Actually, anything other than 1ff would seem to do... */
74 #define NETLOGON_NEG_AUTH2_FLAGS 0x000701ff
76 #define NETLOGON_NEG_SCHANNEL 0x40000000
77 #define NETLOGON_NEG_DOMAIN_TRUST_ACCOUNT 0x2010b000
79 enum netsec_direction
{
84 /* Internal Flags to indicate what type of authentication on the pipe */
85 #define AUTH_PIPE_SIGN 0x0001
86 #define AUTH_PIPE_SEAL 0x0002
87 #define AUTH_PIPE_NTLMSSP 0x0004
88 #define AUTH_PIPE_NETSEC 0x0008
90 /* Maximum PDU fragment size. */
91 /* #define MAX_PDU_FRAG_LEN 0x1630 this is what wnt sets */
92 #define MAX_PDU_FRAG_LEN 0x10b8 /* this is what w2k sets */
95 typedef struct rpc_iface_info
{
96 struct uuid uuid
; /* 16 bytes of rpc interface identification */
97 uint32 version
; /* the interface version number */
100 #define RPC_IFACE_LEN (UUID_SIZE + 4)
102 struct pipe_id_info
{
103 /* the names appear not to matter: the syntaxes _do_ matter */
105 const char *client_pipe
;
106 RPC_IFACE abstr_syntax
; /* this one is the abstract syntax id */
108 const char *server_pipe
; /* this one is the secondary syntax name */
109 RPC_IFACE trans_syntax
; /* this one is the primary syntax id */
112 /* RPC_HDR - dce rpc header */
113 typedef struct rpc_hdr_info
{
114 uint8 major
; /* 5 - RPC major version */
115 uint8 minor
; /* 0 - RPC minor version */
116 uint8 pkt_type
; /* RPC_PKT_TYPE - RPC response packet */
117 uint8 flags
; /* DCE/RPC flags */
118 uint8 pack_type
[4]; /* 0x1000 0000 - little-endian packed data representation */
119 uint16 frag_len
; /* fragment length - data size (bytes) inc header and tail. */
120 uint16 auth_len
; /* 0 - authentication length */
121 uint32 call_id
; /* call identifier. matches 12th uint32 of incoming RPC data. */
124 #define RPC_HEADER_LEN 16
126 /* RPC_HDR_REQ - ms request rpc header */
127 typedef struct rpc_hdr_req_info
{
128 uint32 alloc_hint
; /* allocation hint - data size (bytes) minus header and tail. */
129 uint16 context_id
; /* presentation context identifier */
130 uint16 opnum
; /* opnum */
133 #define RPC_HDR_REQ_LEN 8
135 /* RPC_HDR_RESP - ms response rpc header */
136 typedef struct rpc_hdr_resp_info
{
137 uint32 alloc_hint
; /* allocation hint - data size (bytes) minus header and tail. */
138 uint16 context_id
; /* 0 - presentation context identifier */
139 uint8 cancel_count
; /* 0 - cancel count */
140 uint8 reserved
; /* 0 - reserved. */
143 #define RPC_HDR_RESP_LEN 8
145 /* RPC_HDR_FAULT - fault rpc header */
146 typedef struct rpc_hdr_fault_info
{
148 uint32 reserved
; /* 0x0000 0000 */
151 #define RPC_HDR_FAULT_LEN 8
153 /* this seems to be the same string name depending on the name of the pipe,
154 * but is more likely to be linked to the interface name
155 * "srvsvc", "\\PIPE\\ntsvcs"
156 * "samr", "\\PIPE\\lsass"
157 * "wkssvc", "\\PIPE\\wksvcs"
158 * "NETLOGON", "\\PIPE\\NETLOGON"
161 typedef struct rpc_addr_info
{
162 uint16 len
; /* length of the string including null terminator */
163 fstring str
; /* the string above in single byte, null terminated form */
167 typedef struct rpc_hdr_bba_info
{
168 uint16 max_tsize
; /* maximum transmission fragment size (0x1630) */
169 uint16 max_rsize
; /* max receive fragment size (0x1630) */
170 uint32 assoc_gid
; /* associated group id (0x0) */
173 #define RPC_HDR_BBA_LEN 8
176 typedef struct rpc_hdr_auth_info
{
177 uint8 auth_type
; /* See XXX_AUTH_TYPE above. */
178 uint8 auth_level
; /* See RPC_PIPE_AUTH_XXX_LEVEL above. */
181 uint32 auth_context_id
;
184 #define RPC_HDR_AUTH_LEN 8
187 typedef struct rpc_hdr_autha_info
{
188 uint16 max_tsize
; /* maximum transmission fragment size (0x1630) */
189 uint16 max_rsize
; /* max receive fragment size (0x1630) */
193 #define RPC_HDR_AUTHA_LEN (RPC_HDR_AUTH_LEN+4)
195 /* this is TEMPORARILY coded up as a specific structure */
196 /* this structure comes after the bind request */
197 /* RPC_AUTH_NETSEC_NEG */
198 typedef struct rpc_auth_netsec_neg_info
{
199 uint32 type1
; /* Always zero ? */
200 uint32 type2
; /* Types 0x3 and 0x13 seen. Check AcquireSecurityContext() docs.... */
201 fstring domain
; /* calling workstations's domain */
202 fstring myname
; /* calling workstation's name */
203 } RPC_AUTH_NETSEC_NEG
;
205 /* attached to the end of encrypted rpc requests and responses */
206 /* RPC_AUTH_NETSEC_CHK */
207 typedef struct rpc_auth_netsec_chk_info
{
208 uint8 sig
[8]; /* 77 00 7a 00 ff ff 00 00 */
209 uint8 packet_digest
[8]; /* checksum over the packet, MD5'ed with session key */
210 uint8 seq_num
[8]; /* verifier, seq num */
211 uint8 confounder
[8]; /* random 8-byte nonce */
212 } RPC_AUTH_NETSEC_CHK
;
214 struct netsec_auth_struct
{
220 typedef struct rpc_context
{
221 uint16 context_id
; /* presentation context identifier. */
222 uint8 num_transfer_syntaxes
; /* the number of syntaxes */
223 RPC_IFACE abstract
; /* num and vers. of interface client is using */
224 RPC_IFACE
*transfer
; /* Array of transfer interfaces. */
227 /* RPC_BIND_REQ - ms req bind */
228 typedef struct rpc_bind_req_info
{
230 uint8 num_contexts
; /* the number of contexts */
231 RPC_CONTEXT
*rpc_context
;
235 * The following length is 8 bytes RPC_HDR_BBA_LEN +
236 * 4 bytes size of context count +
237 * (context_count * (4 bytes of context_id, size of transfer syntax count + RPC_IFACE_LEN bytes +
238 * (transfer_syntax_count * RPC_IFACE_LEN bytes)))
241 #define RPC_HDR_RB_LEN(rpc_hdr_rb) (RPC_HDR_BBA_LEN + 4 + \
242 ((rpc_hdr_rb)->num_contexts) * (4 + RPC_IFACE_LEN + (((rpc_hdr_rb)->rpc_context->num_transfer_syntaxes)*RPC_IFACE_LEN)))
244 /* RPC_RESULTS - can only cope with one reason, right now... */
245 typedef struct rpc_results_info
{
246 /* uint8[] # 4-byte alignment padding, against SMB header */
248 uint8 num_results
; /* the number of results (0x01) */
250 /* uint8[] # 4-byte alignment padding, against SMB header */
252 uint16 result
; /* result (0x00 = accept) */
253 uint16 reason
; /* reason (0x00 = no reason specified) */
257 typedef struct rpc_hdr_ba_info
{
260 RPC_ADDR_STR addr
; /* the secondary address string, as described earlier */
261 RPC_RESULTS res
; /* results and reasons */
262 RPC_IFACE transfer
; /* the transfer syntax from the request */
265 /* RPC_AUTH_VERIFIER */
266 typedef struct rpc_auth_verif_info
{
267 fstring signature
; /* "NTLMSSP".. Ok, not quite anymore */
268 uint32 msg_type
; /* NTLMSSP_MESSAGE_TYPE (1,2,3) and 5 for schannel */
271 /* this is TEMPORARILY coded up as a specific structure */
272 /* this structure comes after the bind request */
273 /* RPC_AUTH_NTLMSSP_NEG */
275 typedef struct rpc_auth_ntlmssp_neg_info
{
276 uint32 neg_flgs
; /* 0x0000 b2b3 */
278 STRHDR hdr_myname
; /* offset is against START of this structure */
279 STRHDR hdr_domain
; /* offset is against START of this structure */
281 fstring myname
; /* calling workstation's name */
282 fstring domain
; /* calling workstations's domain */
283 } RPC_AUTH_NTLMSSP_NEG
;
285 /* this is TEMPORARILY coded up as a specific structure */
286 /* this structure comes after the bind acknowledgement */
287 /* RPC_AUTH_NTLMSSP_CHAL */
288 typedef struct rpc_auth_ntlmssp_chal_info
{
289 uint32 unknown_1
; /* 0x0000 0000 */
290 uint32 unknown_2
; /* 0x0000 0028 */
291 uint32 neg_flags
; /* 0x0000 82b1 */
293 uint8 challenge
[8]; /* ntlm challenge */
294 uint8 reserved
[8]; /* zeros */
295 } RPC_AUTH_NTLMSSP_CHAL
;
298 /* RPC_AUTH_NTLMSSP_RESP */
299 typedef struct rpc_auth_ntlmssp_resp_info
{
300 STRHDR hdr_lm_resp
; /* 24 byte response */
301 STRHDR hdr_nt_resp
; /* 24 byte response */
305 STRHDR hdr_sess_key
; /* NULL unless negotiated */
306 uint32 neg_flags
; /* 0x0000 82b1 */
314 } RPC_AUTH_NTLMSSP_RESP
;
316 /* attached to the end of encrypted rpc requests and responses */
317 /* RPC_AUTH_NTLMSSP_CHK */
318 typedef struct rpc_auth_ntlmssp_chk_info
{
319 uint32 ver
; /* 0x0000 0001 */
321 uint32 crc32
; /* checksum using 0xEDB8 8320 as a polynomial */
323 } RPC_AUTH_NTLMSSP_CHK
;
325 #define RPC_AUTH_NTLMSSP_CHK_LEN 16
327 #endif /* _DCE_RPC_H */