s3-ntlmssp: use NTLMSSP headers from IDL and remove duplicate constants.
[Samba/bb.git] / source3 / include / rpc_dce.h
blob3dfbc1672e53602c6e5295bdfe12ade5142929be
1 /*
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 3 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, see <http://www.gnu.org/licenses/>.
22 #ifndef _DCE_RPC_H /* _DCE_RPC_H */
23 #define _DCE_RPC_H
25 /* DCE/RPC packet types */
27 enum RPC_PKT_TYPE {
28 RPC_REQUEST = 0x00, /* Ordinary request. */
29 RPC_PING = 0x01, /* Connectionless is server alive ? */
30 RPC_RESPONSE = 0x02, /* Ordinary reply. */
31 RPC_FAULT = 0x03, /* Fault in processing of call. */
32 RPC_WORKING = 0x04, /* Connectionless reply to a ping when server busy. */
33 RPC_NOCALL = 0x05, /* Connectionless reply to a ping when server has lost part of clients call. */
34 RPC_REJECT = 0x06, /* Refuse a request with a code. */
35 RPC_ACK = 0x07, /* Connectionless client to server code. */
36 RPC_CL_CANCEL= 0x08, /* Connectionless cancel. */
37 RPC_FACK = 0x09, /* Connectionless fragment ack. Both client and server send. */
38 RPC_CANCEL_ACK = 0x0A, /* Server ACK to client cancel request. */
39 RPC_BIND = 0x0B, /* Bind to interface. */
40 RPC_BINDACK = 0x0C, /* Server ack of bind. */
41 RPC_BINDNACK = 0x0D, /* Server nack of bind. */
42 RPC_ALTCONT = 0x0E, /* Alter auth. */
43 RPC_ALTCONTRESP = 0x0F, /* Reply to alter auth. */
44 RPC_AUTH3 = 0x10, /* not the real name! this is undocumented! */
45 RPC_SHUTDOWN = 0x11, /* Server to client request to shutdown. */
46 RPC_CO_CANCEL= 0x12, /* Connection-oriented cancel request. */
47 RPC_ORPHANED = 0x13 /* Client telling server it's aborting a partially sent request or telling
48 server to stop sending replies. */
51 /* DCE/RPC flags */
52 #define RPC_FLG_FIRST 0x01
53 #define RPC_FLG_LAST 0x02
54 #define RPC_FLG_NOCALL 0x20
57 #define SMBD_NTLMSSP_NEG_FLAGS 0x000082b1 /* ALWAYS_SIGN|NEG_NTLM|NEG_LM|NEG_SEAL|NEG_SIGN|NEG_UNICODE */
59 /* DCE RPC auth types - extended by Microsoft. */
60 #define RPC_ANONYMOUS_AUTH_TYPE 0
61 #define RPC_AUTH_TYPE_KRB5_1 1
62 #define RPC_SPNEGO_AUTH_TYPE 9
63 #define RPC_NTLMSSP_AUTH_TYPE 10
64 #define RPC_KRB5_AUTH_TYPE 16 /* Not yet implemented. */
65 #define RPC_SCHANNEL_AUTH_TYPE 68 /* 0x44 */
67 /* DCE-RPC standard identifiers to indicate
68 signing or sealing of an RPC pipe */
69 #define RPC_AUTH_LEVEL_NONE 1
70 #define RPC_AUTH_LEVEL_CONNECT 2
71 #define RPC_AUTH_LEVEL_CALL 3
72 #define RPC_AUTH_LEVEL_PACKET 4
73 #define RPC_AUTH_LEVEL_INTEGRITY 5
74 #define RPC_AUTH_LEVEL_PRIVACY 6
76 #if 0
77 #define RPC_PIPE_AUTH_SIGN_LEVEL 0x5
78 #define RPC_PIPE_AUTH_SEAL_LEVEL 0x6
79 #endif
81 /* Netlogon schannel auth type and level */
82 #define SCHANNEL_SIGN_SIGNATURE { 0x77, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 }
83 #define SCHANNEL_SEAL_SIGNATURE { 0x77, 0x00, 0x7a, 0x00, 0xff, 0xff, 0x00, 0x00 }
85 #define RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN 0x20
86 #define RPC_AUTH_SCHANNEL_SIGN_ONLY_CHK_LEN 0x18
89 enum schannel_direction {
90 SENDER_IS_INITIATOR,
91 SENDER_IS_ACCEPTOR
94 /* Maximum size of the signing data in a fragment. */
95 #define RPC_MAX_SIGN_SIZE 0x20 /* 32 */
97 /* Maximum PDU fragment size. */
98 /* #define MAX_PDU_FRAG_LEN 0x1630 this is what wnt sets */
99 #define RPC_MAX_PDU_FRAG_LEN 0x10b8 /* this is what w2k sets */
101 #define RPC_IFACE_LEN (UUID_SIZE + 4)
103 /* RPC_HDR - dce rpc header */
104 typedef struct rpc_hdr_info {
105 uint8 major; /* 5 - RPC major version */
106 uint8 minor; /* 0 - RPC minor version */
107 uint8 pkt_type; /* RPC_PKT_TYPE - RPC response packet */
108 uint8 flags; /* DCE/RPC flags */
109 uint8 pack_type[4]; /* 0x1000 0000 - little-endian packed data representation */
110 uint16 frag_len; /* fragment length - data size (bytes) inc header and tail. */
111 uint16 auth_len; /* 0 - authentication length */
112 uint32 call_id; /* call identifier. matches 12th uint32 of incoming RPC data. */
113 } RPC_HDR;
115 #define RPC_HEADER_LEN 16
117 /* RPC_HDR_REQ - ms request rpc header */
118 typedef struct rpc_hdr_req_info {
119 uint32 alloc_hint; /* allocation hint - data size (bytes) minus header and tail. */
120 uint16 context_id; /* presentation context identifier */
121 uint16 opnum; /* opnum */
122 } RPC_HDR_REQ;
124 #define RPC_HDR_REQ_LEN 8
126 /* RPC_HDR_RESP - ms response rpc header */
127 typedef struct rpc_hdr_resp_info {
128 uint32 alloc_hint; /* allocation hint - data size (bytes) minus header and tail. */
129 uint16 context_id; /* 0 - presentation context identifier */
130 uint8 cancel_count; /* 0 - cancel count */
131 uint8 reserved; /* 0 - reserved. */
132 } RPC_HDR_RESP;
134 #define RPC_HDR_RESP_LEN 8
136 /* RPC_HDR_FAULT - fault rpc header */
137 typedef struct rpc_hdr_fault_info {
138 NTSTATUS status;
139 uint32 reserved; /* 0x0000 0000 */
140 } RPC_HDR_FAULT;
142 #define RPC_HDR_FAULT_LEN 8
144 /* this seems to be the same string name depending on the name of the pipe,
145 * but is more likely to be linked to the interface name
146 * "srvsvc", "\\PIPE\\ntsvcs"
147 * "samr", "\\PIPE\\lsass"
148 * "wkssvc", "\\PIPE\\wksvcs"
149 * "NETLOGON", "\\PIPE\\NETLOGON"
151 /* RPC_ADDR_STR */
152 typedef struct rpc_addr_info {
153 uint16 len; /* length of the string including null terminator */
154 fstring str; /* the string above in single byte, null terminated form */
155 } RPC_ADDR_STR;
157 /* RPC_HDR_BBA - bind acknowledge, and alter context response. */
158 typedef struct rpc_hdr_bba_info {
159 uint16 max_tsize; /* maximum transmission fragment size (0x1630) */
160 uint16 max_rsize; /* max receive fragment size (0x1630) */
161 uint32 assoc_gid; /* associated group id (0x0) */
162 } RPC_HDR_BBA;
164 #define RPC_HDR_BBA_LEN 8
166 /* RPC_HDR_AUTH */
167 typedef struct rpc_hdr_auth_info {
168 uint8 auth_type; /* See XXX_AUTH_TYPE above. */
169 uint8 auth_level; /* See RPC_PIPE_AUTH_XXX_LEVEL above. */
170 uint8 auth_pad_len;
171 uint8 auth_reserved;
172 uint32 auth_context_id;
173 } RPC_HDR_AUTH;
175 #define RPC_HDR_AUTH_LEN 8
177 /* this is TEMPORARILY coded up as a specific structure */
178 /* this structure comes after the bind request */
179 /* RPC_AUTH_SCHANNEL_NEG */
180 typedef struct rpc_auth_schannel_neg_info {
181 uint32 type1; /* Always zero ? */
182 uint32 type2; /* Types 0x3 and 0x13 seen. Check AcquireSecurityContext() docs.... */
183 fstring domain; /* calling workstations's domain */
184 fstring myname; /* calling workstation's name */
185 } RPC_AUTH_SCHANNEL_NEG;
187 /* attached to the end of encrypted rpc requests and responses */
188 /* RPC_AUTH_SCHANNEL_CHK */
189 typedef struct rpc_auth_schannel_chk_info {
190 uint8 sig [8]; /* 77 00 7a 00 ff ff 00 00 */
191 uint8 packet_digest[8]; /* checksum over the packet, MD5'ed with session key */
192 uint8 seq_num[8]; /* verifier, seq num */
193 uint8 confounder[8]; /* random 8-byte nonce */
194 } RPC_AUTH_SCHANNEL_CHK;
196 typedef struct rpc_context {
197 uint16 context_id; /* presentation context identifier. */
198 uint8 num_transfer_syntaxes; /* the number of syntaxes */
199 struct ndr_syntax_id abstract; /* num and vers. of interface client is using */
200 struct ndr_syntax_id *transfer; /* Array of transfer interfaces. */
201 } RPC_CONTEXT;
203 /* RPC_BIND_REQ - ms req bind */
204 typedef struct rpc_bind_req_info {
205 RPC_HDR_BBA bba;
206 uint8 num_contexts; /* the number of contexts */
207 RPC_CONTEXT *rpc_context;
208 } RPC_HDR_RB;
211 * The following length is 8 bytes RPC_HDR_BBA_LEN +
212 * 4 bytes size of context count +
213 * (context_count * (4 bytes of context_id, size of transfer syntax count + RPC_IFACE_LEN bytes +
214 * (transfer_syntax_count * RPC_IFACE_LEN bytes)))
217 #define RPC_HDR_RB_LEN(rpc_hdr_rb) (RPC_HDR_BBA_LEN + 4 + \
218 ((rpc_hdr_rb)->num_contexts) * (4 + RPC_IFACE_LEN + (((rpc_hdr_rb)->rpc_context->num_transfer_syntaxes)*RPC_IFACE_LEN)))
220 /* RPC_RESULTS - can only cope with one reason, right now... */
221 typedef struct rpc_results_info {
222 /* uint8[] # 4-byte alignment padding, against SMB header */
224 uint8 num_results; /* the number of results (0x01) */
226 /* uint8[] # 4-byte alignment padding, against SMB header */
228 uint16 result; /* result (0x00 = accept) */
229 uint16 reason; /* reason (0x00 = no reason specified) */
230 } RPC_RESULTS;
232 /* RPC_HDR_BA */
233 typedef struct rpc_hdr_ba_info {
234 RPC_HDR_BBA bba;
236 RPC_ADDR_STR addr ; /* the secondary address string, as described earlier */
237 RPC_RESULTS res ; /* results and reasons */
238 struct ndr_syntax_id transfer; /* the transfer syntax from the request */
239 } RPC_HDR_BA;
241 /* RPC_AUTH_VERIFIER */
242 typedef struct rpc_auth_verif_info {
243 fstring signature; /* "NTLMSSP".. Ok, not quite anymore */
244 uint32 msg_type; /* NTLMSSP_MESSAGE_TYPE (1,2,3) and 5 for schannel */
245 } RPC_AUTH_VERIFIER;
247 #endif /* _DCE_RPC_H */