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 /* DCE/RPC packet types */
29 RPC_REQUEST
= 0x00, /* Ordinary request. */
30 RPC_PING
= 0x01, /* Connectionless is server alive ? */
31 RPC_RESPONSE
= 0x02, /* Ordinary reply. */
32 RPC_FAULT
= 0x03, /* Fault in processing of call. */
33 RPC_WORKING
= 0x04, /* Connectionless reply to a ping when server busy. */
34 RPC_NOCALL
= 0x05, /* Connectionless reply to a ping when server has lost part of clients call. */
35 RPC_REJECT
= 0x06, /* Refuse a request with a code. */
36 RPC_ACK
= 0x07, /* Connectionless client to server code. */
37 RPC_CL_CANCEL
= 0x08, /* Connectionless cancel. */
38 RPC_FACK
= 0x09, /* Connectionless fragment ack. Both client and server send. */
39 RPC_CANCEL_ACK
= 0x0A, /* Server ACK to client cancel request. */
40 RPC_BIND
= 0x0B, /* Bind to interface. */
41 RPC_BINDACK
= 0x0C, /* Server ack of bind. */
42 RPC_BINDNACK
= 0x0D, /* Server nack of bind. */
43 RPC_ALTCONT
= 0x0E, /* Alter auth. */
44 RPC_ALTCONTRESP
= 0x0F, /* Reply to alter auth. */
45 RPC_AUTH3
= 0x10, /* not the real name! this is undocumented! */
46 RPC_SHUTDOWN
= 0x11, /* Server to client request to shutdown. */
47 RPC_CO_CANCEL
= 0x12, /* Connection-oriented cancel request. */
48 RPC_ORPHANED
= 0x13 /* Client telling server it's aborting a partially sent request or telling
49 server to stop sending replies. */
53 #define RPC_FLG_FIRST 0x01
54 #define RPC_FLG_LAST 0x02
55 #define RPC_FLG_NOCALL 0x20
58 #define SMBD_NTLMSSP_NEG_FLAGS 0x000082b1 /* ALWAYS_SIGN|NEG_NTLM|NEG_LM|NEG_SEAL|NEG_SIGN|NEG_UNICODE */
60 /* NTLMSSP signature version */
61 #define NTLMSSP_SIGN_VERSION 0x01
63 /* DCE RPC auth types - extended by Microsoft. */
64 #define RPC_ANONYMOUS_AUTH_TYPE 0
65 #define RPC_AUTH_TYPE_KRB5_1 1
66 #define RPC_SPNEGO_AUTH_TYPE 9
67 #define RPC_NTLMSSP_AUTH_TYPE 10
68 #define RPC_KRB5_AUTH_TYPE 16 /* Not yet implemented. */
69 #define RPC_SCHANNEL_AUTH_TYPE 68 /* 0x44 */
71 /* DCE-RPC standard identifiers to indicate
72 signing or sealing of an RPC pipe */
73 #define RPC_AUTH_LEVEL_NONE 1
74 #define RPC_AUTH_LEVEL_CONNECT 2
75 #define RPC_AUTH_LEVEL_CALL 3
76 #define RPC_AUTH_LEVEL_PACKET 4
77 #define RPC_AUTH_LEVEL_INTEGRITY 5
78 #define RPC_AUTH_LEVEL_PRIVACY 6
81 #define RPC_PIPE_AUTH_SIGN_LEVEL 0x5
82 #define RPC_PIPE_AUTH_SEAL_LEVEL 0x6
85 /* Netlogon schannel auth type and level */
86 #define SCHANNEL_SIGN_SIGNATURE { 0x77, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 }
87 #define SCHANNEL_SEAL_SIGNATURE { 0x77, 0x00, 0x7a, 0x00, 0xff, 0xff, 0x00, 0x00 }
89 #define RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN 0x20
90 #define RPC_AUTH_SCHANNEL_SIGN_ONLY_CHK_LEN 0x18
93 /* The 7 here seems to be required to get Win2k not to downgrade us
94 to NT4. Actually, anything other than 1ff would seem to do... */
95 #define NETLOGON_NEG_AUTH2_FLAGS 0x000701ff
97 #define NETLOGON_NEG_SCHANNEL 0x40000000
98 #define NETLOGON_NEG_DOMAIN_TRUST_ACCOUNT 0x2010b000
100 enum schannel_direction
{
105 /* Maximum size of the signing data in a fragment. */
106 #define RPC_MAX_SIGN_SIZE 0x20 /* 32 */
108 /* Maximum PDU fragment size. */
109 /* #define MAX_PDU_FRAG_LEN 0x1630 this is what wnt sets */
110 #define RPC_MAX_PDU_FRAG_LEN 0x10b8 /* this is what w2k sets */
113 typedef struct rpc_iface_info
{
114 struct uuid uuid
; /* 16 bytes of rpc interface identification */
115 uint32 version
; /* the interface version number */
118 #define RPC_IFACE_LEN (UUID_SIZE + 4)
120 struct pipe_id_info
{
121 /* the names appear not to matter: the syntaxes _do_ matter */
123 const char *client_pipe
;
124 RPC_IFACE abstr_syntax
; /* this one is the abstract syntax id */
126 const char *server_pipe
; /* this one is the secondary syntax name */
127 RPC_IFACE trans_syntax
; /* this one is the primary syntax id */
130 /* RPC_HDR - dce rpc header */
131 typedef struct rpc_hdr_info
{
132 uint8 major
; /* 5 - RPC major version */
133 uint8 minor
; /* 0 - RPC minor version */
134 uint8 pkt_type
; /* RPC_PKT_TYPE - RPC response packet */
135 uint8 flags
; /* DCE/RPC flags */
136 uint8 pack_type
[4]; /* 0x1000 0000 - little-endian packed data representation */
137 uint16 frag_len
; /* fragment length - data size (bytes) inc header and tail. */
138 uint16 auth_len
; /* 0 - authentication length */
139 uint32 call_id
; /* call identifier. matches 12th uint32 of incoming RPC data. */
142 #define RPC_HEADER_LEN 16
144 /* RPC_HDR_REQ - ms request rpc header */
145 typedef struct rpc_hdr_req_info
{
146 uint32 alloc_hint
; /* allocation hint - data size (bytes) minus header and tail. */
147 uint16 context_id
; /* presentation context identifier */
148 uint16 opnum
; /* opnum */
151 #define RPC_HDR_REQ_LEN 8
153 /* RPC_HDR_RESP - ms response rpc header */
154 typedef struct rpc_hdr_resp_info
{
155 uint32 alloc_hint
; /* allocation hint - data size (bytes) minus header and tail. */
156 uint16 context_id
; /* 0 - presentation context identifier */
157 uint8 cancel_count
; /* 0 - cancel count */
158 uint8 reserved
; /* 0 - reserved. */
161 #define RPC_HDR_RESP_LEN 8
163 /* RPC_HDR_FAULT - fault rpc header */
164 typedef struct rpc_hdr_fault_info
{
166 uint32 reserved
; /* 0x0000 0000 */
169 #define RPC_HDR_FAULT_LEN 8
171 /* this seems to be the same string name depending on the name of the pipe,
172 * but is more likely to be linked to the interface name
173 * "srvsvc", "\\PIPE\\ntsvcs"
174 * "samr", "\\PIPE\\lsass"
175 * "wkssvc", "\\PIPE\\wksvcs"
176 * "NETLOGON", "\\PIPE\\NETLOGON"
179 typedef struct rpc_addr_info
{
180 uint16 len
; /* length of the string including null terminator */
181 fstring str
; /* the string above in single byte, null terminated form */
184 /* RPC_HDR_BBA - bind acknowledge, and alter context response. */
185 typedef struct rpc_hdr_bba_info
{
186 uint16 max_tsize
; /* maximum transmission fragment size (0x1630) */
187 uint16 max_rsize
; /* max receive fragment size (0x1630) */
188 uint32 assoc_gid
; /* associated group id (0x0) */
191 #define RPC_HDR_BBA_LEN 8
194 typedef struct rpc_hdr_auth_info
{
195 uint8 auth_type
; /* See XXX_AUTH_TYPE above. */
196 uint8 auth_level
; /* See RPC_PIPE_AUTH_XXX_LEVEL above. */
199 uint32 auth_context_id
;
202 #define RPC_HDR_AUTH_LEN 8
204 /* this is TEMPORARILY coded up as a specific structure */
205 /* this structure comes after the bind request */
206 /* RPC_AUTH_SCHANNEL_NEG */
207 typedef struct rpc_auth_schannel_neg_info
{
208 uint32 type1
; /* Always zero ? */
209 uint32 type2
; /* Types 0x3 and 0x13 seen. Check AcquireSecurityContext() docs.... */
210 fstring domain
; /* calling workstations's domain */
211 fstring myname
; /* calling workstation's name */
212 } RPC_AUTH_SCHANNEL_NEG
;
214 /* attached to the end of encrypted rpc requests and responses */
215 /* RPC_AUTH_SCHANNEL_CHK */
216 typedef struct rpc_auth_schannel_chk_info
{
217 uint8 sig
[8]; /* 77 00 7a 00 ff ff 00 00 */
218 uint8 packet_digest
[8]; /* checksum over the packet, MD5'ed with session key */
219 uint8 seq_num
[8]; /* verifier, seq num */
220 uint8 confounder
[8]; /* random 8-byte nonce */
221 } RPC_AUTH_SCHANNEL_CHK
;
223 typedef struct rpc_context
{
224 uint16 context_id
; /* presentation context identifier. */
225 uint8 num_transfer_syntaxes
; /* the number of syntaxes */
226 RPC_IFACE abstract
; /* num and vers. of interface client is using */
227 RPC_IFACE
*transfer
; /* Array of transfer interfaces. */
230 /* RPC_BIND_REQ - ms req bind */
231 typedef struct rpc_bind_req_info
{
233 uint8 num_contexts
; /* the number of contexts */
234 RPC_CONTEXT
*rpc_context
;
238 * The following length is 8 bytes RPC_HDR_BBA_LEN +
239 * 4 bytes size of context count +
240 * (context_count * (4 bytes of context_id, size of transfer syntax count + RPC_IFACE_LEN bytes +
241 * (transfer_syntax_count * RPC_IFACE_LEN bytes)))
244 #define RPC_HDR_RB_LEN(rpc_hdr_rb) (RPC_HDR_BBA_LEN + 4 + \
245 ((rpc_hdr_rb)->num_contexts) * (4 + RPC_IFACE_LEN + (((rpc_hdr_rb)->rpc_context->num_transfer_syntaxes)*RPC_IFACE_LEN)))
247 /* RPC_RESULTS - can only cope with one reason, right now... */
248 typedef struct rpc_results_info
{
249 /* uint8[] # 4-byte alignment padding, against SMB header */
251 uint8 num_results
; /* the number of results (0x01) */
253 /* uint8[] # 4-byte alignment padding, against SMB header */
255 uint16 result
; /* result (0x00 = accept) */
256 uint16 reason
; /* reason (0x00 = no reason specified) */
260 typedef struct rpc_hdr_ba_info
{
263 RPC_ADDR_STR addr
; /* the secondary address string, as described earlier */
264 RPC_RESULTS res
; /* results and reasons */
265 RPC_IFACE transfer
; /* the transfer syntax from the request */
268 /* RPC_AUTH_VERIFIER */
269 typedef struct rpc_auth_verif_info
{
270 fstring signature
; /* "NTLMSSP".. Ok, not quite anymore */
271 uint32 msg_type
; /* NTLMSSP_MESSAGE_TYPE (1,2,3) and 5 for schannel */
274 #endif /* _DCE_RPC_H */