oops, I ot the return type of putenv() wrong
[Samba/gbeck.git] / source / include / rpc_dce.h
blobc6499853d6a53a8b7753fbd28407441d40853fc6
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
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.
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.
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.
24 #ifndef _DCE_RPC_H /* _DCE_RPC_H */
25 #define _DCE_RPC_H
27 #include "rpc_misc.h" /* this only pulls in STRHDR */
30 /* DCE/RPC packet types */
32 enum RPC_PKT_TYPE
34 RPC_REQUEST = 0x00,
35 RPC_RESPONSE = 0x02,
36 RPC_BIND = 0x0B,
37 RPC_BINDACK = 0x0C,
38 RPC_BINDRESP = 0x10 /* not the real name! this is undocumented! */
41 /* DCE/RPC flags */
42 #define RPC_FLG_FIRST 0x01
43 #define RPC_FLG_LAST 0x02
45 /* NTLMSSP message types */
46 enum NTLM_MESSAGE_TYPE
48 NTLMSSP_NEGOTIATE = 1,
49 NTLMSSP_CHALLENGE = 2,
50 NTLMSSP_AUTH = 3,
51 NTLMSSP_UNKNOWN = 4
54 /* NTLMSSP negotiation flags */
55 #define NTLMSSP_NEGOTIATE_UNICODE 0x00000001
56 #define NTLMSSP_NEGOTIATE_OEM 0x00000002
57 #define NTLMSSP_REQUEST_TARGET 0x00000004
58 #define NTLMSSP_NEGOTIATE_SIGN 0x00000010
59 #define NTLMSSP_NEGOTIATE_SEAL 0x00000020
60 #define NTLMSSP_NEGOTIATE_LM_KEY 0x00000080
61 #define NTLMSSP_NEGOTIATE_NTLM 0x00000200
62 #define NTLMSSP_NEGOTIATE_00001000 0x00001000
63 #define NTLMSSP_NEGOTIATE_00002000 0x00002000
64 #define NTLMSSP_NEGOTIATE_ALWAYS_SIGN 0x00008000
65 #define NTLMSSP_NEGOTIATE_NTLM2 0x00080000
66 #define NTLMSSP_NEGOTIATE_TARGET_INFO 0x00800000
67 #define NTLMSSP_NEGOTIATE_128 0x20000000
68 #define NTLMSSP_NEGOTIATE_KEY_EXCH 0x40000000
70 /* NTLMSSP signature version */
71 #define NTLMSSP_SIGN_VERSION 0x01
74 /* RPC_IFACE */
75 typedef struct rpc_iface_info
77 uint8 data[16]; /* 16 bytes of rpc interface identification */
78 uint32 version; /* the interface version number */
80 } RPC_IFACE;
82 struct pipe_id_info
84 /* the names appear not to matter: the syntaxes _do_ matter */
86 char *client_pipe;
87 RPC_IFACE abstr_syntax; /* this one is the abstract syntax id */
89 char *server_pipe; /* this one is the secondary syntax name */
90 RPC_IFACE trans_syntax; /* this one is the primary syntax id */
93 /* RPC_HDR - dce rpc header */
94 typedef struct rpc_hdr_info
96 uint8 major; /* 5 - RPC major version */
97 uint8 minor; /* 0 - RPC minor version */
98 uint8 pkt_type; /* RPC_PKT_TYPE - RPC response packet */
99 uint8 flags; /* DCE/RPC flags */
100 uint32 pack_type; /* 0x1000 0000 - packed data representation */
101 uint16 frag_len; /* fragment length - data size (bytes) inc header and tail. */
102 uint16 auth_len; /* 0 - authentication length */
103 uint32 call_id; /* call identifier. matches 12th uint32 of incoming RPC data. */
105 } RPC_HDR;
107 /* RPC_HDR_REQ - ms request rpc header */
108 typedef struct rpc_hdr_req_info
110 uint32 alloc_hint; /* allocation hint - data size (bytes) minus header and tail. */
111 uint16 context_id; /* 0 - presentation context identifier */
112 uint16 opnum; /* opnum */
114 } RPC_HDR_REQ;
116 /* RPC_HDR_RESP - ms response rpc header */
117 typedef struct rpc_hdr_resp_info
119 uint32 alloc_hint; /* allocation hint - data size (bytes) minus header and tail. */
120 uint16 context_id; /* 0 - presentation context identifier */
121 uint8 cancel_count; /* 0 - cancel count */
122 uint8 reserved; /* 0 - reserved. */
124 } RPC_HDR_RESP;
126 /* this seems to be the same string name depending on the name of the pipe,
127 * but is more likely to be linked to the interface name
128 * "srvsvc", "\\PIPE\\ntsvcs"
129 * "samr", "\\PIPE\\lsass"
130 * "wkssvc", "\\PIPE\\wksvcs"
131 * "NETLOGON", "\\PIPE\\NETLOGON"
133 /* RPC_ADDR_STR */
134 typedef struct rpc_addr_info
136 uint16 len; /* length of the string including null terminator */
137 fstring str; /* the string above in single byte, null terminated form */
139 } RPC_ADDR_STR;
141 /* RPC_HDR_BBA */
142 typedef struct rpc_hdr_bba_info
144 uint16 max_tsize; /* maximum transmission fragment size (0x1630) */
145 uint16 max_rsize; /* max receive fragment size (0x1630) */
146 uint32 assoc_gid; /* associated group id (0x0) */
148 } RPC_HDR_BBA;
150 /* RPC_HDR_AUTHA */
151 typedef struct rpc_hdr_autha_info
153 uint16 max_tsize; /* maximum transmission fragment size (0x1630) */
154 uint16 max_rsize; /* max receive fragment size (0x1630) */
156 uint8 auth_type; /* 0x0a */
157 uint8 auth_level; /* 0x06 */
158 uint8 stub_type_len; /* don't know */
159 uint8 padding; /* padding */
161 uint32 unknown; /* 0x0014a0c0 */
163 } RPC_HDR_AUTHA;
165 /* RPC_HDR_AUTH */
166 typedef struct rpc_hdr_auth_info
168 uint8 auth_type; /* 0x0a */
169 uint8 auth_level; /* 0x06 */
170 uint8 stub_type_len; /* don't know */
171 uint8 padding; /* padding */
173 uint32 unknown; /* pointer */
175 } RPC_HDR_AUTH;
177 /* RPC_BIND_REQ - ms req bind */
178 typedef struct rpc_bind_req_info
180 RPC_HDR_BBA bba;
182 uint32 num_elements; /* the number of elements (0x1) */
183 uint16 context_id; /* presentation context identifier (0x0) */
184 uint8 num_syntaxes; /* the number of syntaxes (has always been 1?)(0x1) */
186 RPC_IFACE abstract; /* num and vers. of interface client is using */
187 RPC_IFACE transfer; /* num and vers. of interface to use for replies */
189 } RPC_HDR_RB;
191 /* RPC_RESULTS - can only cope with one reason, right now... */
192 typedef struct rpc_results_info
194 /* uint8[] # 4-byte alignment padding, against SMB header */
196 uint8 num_results; /* the number of results (0x01) */
198 /* uint8[] # 4-byte alignment padding, against SMB header */
200 uint16 result; /* result (0x00 = accept) */
201 uint16 reason; /* reason (0x00 = no reason specified) */
203 } RPC_RESULTS;
205 /* RPC_HDR_BA */
206 typedef struct rpc_hdr_ba_info
208 RPC_HDR_BBA bba;
210 RPC_ADDR_STR addr ; /* the secondary address string, as described earlier */
211 RPC_RESULTS res ; /* results and reasons */
212 RPC_IFACE transfer; /* the transfer syntax from the request */
214 } RPC_HDR_BA;
216 /* RPC_AUTH_VERIFIER */
217 typedef struct rpc_auth_verif_info
219 fstring signature; /* "NTLMSSP" */
220 uint32 msg_type; /* NTLMSSP_MESSAGE_TYPE (1,2,3) */
222 } RPC_AUTH_VERIFIER;
224 /* this is TEMPORARILY coded up as a specific structure */
225 /* this structure comes after the bind request */
226 /* RPC_AUTH_NTLMSSP_NEG */
227 typedef struct rpc_auth_ntlmssp_neg_info
229 uint32 neg_flgs; /* 0x0000 b2b3 */
231 STRHDR hdr_myname; /* offset is against START of this structure */
232 STRHDR hdr_domain; /* offset is against START of this structure */
234 fstring myname; /* calling workstation's name */
235 fstring domain; /* calling workstations's domain */
237 } RPC_AUTH_NTLMSSP_NEG;
239 /* this is TEMPORARILY coded up as a specific structure */
240 /* this structure comes after the bind acknowledgement */
241 /* RPC_AUTH_NTLMSSP_CHAL */
242 typedef struct rpc_auth_ntlmssp_chal_info
244 uint32 unknown_1; /* 0x0000 0000 */
245 uint32 unknown_2; /* 0x0000 0028 */
246 uint32 neg_flags; /* 0x0000 82b1 */
248 uint8 challenge[8]; /* ntlm challenge */
249 uint8 reserved [8]; /* zeros */
251 } RPC_AUTH_NTLMSSP_CHAL;
254 /* RPC_AUTH_NTLMSSP_RESP */
255 typedef struct rpc_auth_ntlmssp_resp_info
257 STRHDR hdr_lm_resp; /* 24 byte response */
258 STRHDR hdr_nt_resp; /* 24 byte response */
259 STRHDR hdr_domain;
260 STRHDR hdr_usr;
261 STRHDR hdr_wks;
262 STRHDR hdr_sess_key; /* NULL unless negotiated */
263 uint32 neg_flags; /* 0x0000 82b1 */
265 fstring sess_key;
266 fstring wks;
267 fstring user;
268 fstring domain;
269 fstring nt_resp;
270 fstring lm_resp;
272 } RPC_AUTH_NTLMSSP_RESP;
275 /* attached to the end of encrypted rpc requests and responses */
276 /* RPC_AUTH_NTLMSSP_CHK */
277 typedef struct rpc_auth_ntlmssp_chk_info
279 uint32 ver; /* 0x0000 0001 */
280 uint32 reserved;
281 uint32 crc32; /* checksum using 0xEDB8 8320 as a polynomial */
282 uint32 seq_num;
284 } RPC_AUTH_NTLMSSP_CHK;
286 #endif /* _DCE_RPC_H */