xref: /titanic_51/usr/src/uts/common/smbsrv/ndl/rpcpdu.ndl (revision fc3af78a71855c71878866a294572d00e6720533)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#ifndef _MLRPCPDU_NDL_
27#define _MLRPCPDU_NDL_
28
29#include "ndrtypes.ndl"
30
31/*
32 * Normally, constructs are (un)marshalled atoms first, then
33 * constructs, then pointers. This can be confusing sometimes
34 * when debugging. We know that everything in here can be
35 * safely (un)marshalled in member order, so we say so.
36 */
37#ifdef NDRGEN
38#define _NO_REORDER_ [_no_reorder]
39#else
40#define _NO_REORDER_
41#endif
42
43/*
44 * UUID (Universal Unique IDentifier)
45 */
46/* (X/Open CAE Spec Appendix A) */
47struct ndr_dce_uuid {
48	DWORD		time_low;
49	WORD		time_mid;
50	WORD		time_hi_and_version;
51	BYTE		clock_seq_hi_and_reserved;
52	BYTE		clock_seq_low;
53	BYTE		node[6];
54};
55
56struct ndr_uuid {
57	DWORD		data1;
58	WORD		data2;
59	WORD		data3;
60	BYTE		data4[8];
61};
62typedef struct ndr_uuid ndr_uuid_t;
63
64/*
65 * Representation label -- needed for RPC header
66 * (X/Open CAE Spec Chapter 14.1)
67 *
68 * Bits   Data Type   Description
69 * ----   ---------   -----------
70 * 0-3    charset     0=ASCII
71 *                    1=EBCDIC
72 * 4-7    byte-order  0=big-endian
73 *                    1=little-endian
74 * 8-15   float       0=IEEE
75 *                    1=VAX
76 *                    2=Cray
77 *                    3=IBM
78 * 16-31  reserved
79 */
80#define MLRPC_REPLAB_CHAR_MASK		0x0F	/* low nibble of intg_char */
81#define MLRPC_REPLAB_CHAR_ASCII		0x00	/* ASCII */
82#define MLRPC_REPLAB_CHAR_EBCDIC	0x01	/* EBCDIC (never happen) */
83#define MLRPC_REPLAB_INTG_MASK		0xF0	/* hi nibble of intg_char */
84#define MLRPC_REPLAB_INTG_BIG_ENDIAN	0x00	/* big endian */
85#define MLRPC_REPLAB_INTG_LITTLE_ENDIAN	0x10	/* little endian (x86) */
86#define MLRPC_REPLAB_FLOAT_IEEE		0x00
87#define MLRPC_REPLAB_FLOAT_VAX		0x01
88#define MLRPC_REPLAB_FLOAT_CRAY		0x02
89#define MLRPC_REPLAB_FLOAT_IBM		0x03
90
91struct mlrpc_representation_label {
92	BYTE		intg_char_rep;		/* integer and charset */
93	BYTE		float_rep;
94	BYTE		_spare[2];
95};
96
97
98
99/*
100 * RPC PDU (Protocol Data Unit) types
101 ****************************************************************
102 * (X/Open CAE Spec 12.1)
103 */
104
105#define MLRPC_PTYPE_REQUEST		0x00	/* CO/CL */
106#define MLRPC_PTYPE_PING		0x01	/*    CL */
107#define MLRPC_PTYPE_RESPONSE		0x02	/* CO/CL */
108#define MLRPC_PTYPE_FAULT		0x03	/* CL/CL */
109#define MLRPC_PTYPE_WORKING		0x04	/*    CL */
110#define MLRPC_PTYPE_NOCALL		0x05	/*    CL */
111#define MLRPC_PTYPE_REJECT		0x06	/*    CL */
112#define MLRPC_PTYPE_ACK			0x07	/*    CL */
113#define MLRPC_PTYPE_CL_CANCEL		0x08	/*    CL */
114#define MLRPC_PTYPE_FACK		0x09	/*    CL */
115#define MLRPC_PTYPE_CANCEL_ACK		0x0A	/*    CL */
116#define MLRPC_PTYPE_BIND		0x0B	/* CO    */
117#define MLRPC_PTYPE_BIND_ACK		0x0C	/* CO    */
118#define MLRPC_PTYPE_BIND_NAK		0x0D	/* CO    */
119#define MLRPC_PTYPE_ALTER_CONTEXT	0x0E	/* CO    */
120#define MLRPC_PTYPE_ALTER_CONTEXT_RESP	0x0F	/* CO    */
121						/* 0x10 missing from DCE/RPC */
122#define MLRPC_PTYPE_SHUTDOWN		0x11	/* CO    */
123#define MLRPC_PTYPE_CO_CANCEL		0x12	/* CO    */
124#define MLRPC_PTYPE_ORPHANED		0x13	/* CO    */
125
126/*
127 * Flags in the RPC header for Connection-oriented PDU data types
128 * (X/Open CAE Spec 12.6.3.1)
129 */
130#define MLRPC_PFC_FIRST_FRAG		0x01	/* First fragment */
131#define MLRPC_PFC_LAST_FRAG		0x02	/* Last framgent */
132#define MLRPC_PFC_PENDING_CANCEL	0x04	/* Cancel was pending@sender*/
133#define MLRPC_PFC_RESERVED_1		0x08	/* */
134#define MLRPC_PFC_CONC_MPX		0x10	/* supports concurrent muxing
135						 * of single connection */
136#define MLRPC_PFC_DID_NOT_EXECUTE	0x20	/* for PTYPE_FAULT, guarantee
137						 * call did not execute */
138#define MLRPC_PFC_MAYBE			0x40	/* "maybe" semantics req'ed*/
139#define MLRPC_PFC_OBJECT_UUID		0x80	/* */
140
141
142/*
143 * Header common to all Connection-oriented RPC PDUs
144 ****************************************************************
145 * (X/Open CAE Spec 12.6.3.1)
146 */
147_NO_REORDER_
148struct ndr_common_header {
149	BYTE		rpc_vers;	/* 00:01 5 */
150	BYTE		rpc_vers_minor;	/* 01:01 0 */
151	BYTE		ptype;		/* 02:01 MLRPC_PTYPE_... */
152	BYTE		pfc_flags;	/* 03:01 MLRPC_PFC_... */
153	struct mlrpc_representation_label
154			packed_drep;	/* 04:04 NDR representation label */
155	WORD		frag_length;	/* 08:02 total length of frag */
156	WORD		auth_length;	/* 10:02 length of auth_value */
157	DWORD		call_id;	/* 12:04 call identifier */
158					/* 16: */
159};
160typedef struct ndr_common_header	ndr_common_header_t;
161EXTERNTYPEINFO(ndr_common_header)
162
163
164/*
165 * A plethora of supporting types, only defined the ones we need
166 * (X/Open CAE Spec 12.6.3.1)
167 */
168typedef WORD	mlrpc_p_context_id_t;
169
170_NO_REORDER_
171struct mlrpc_p_syntax_id {
172	ndr_uuid_t	if_uuid;
173	DWORD		if_version;
174};
175typedef struct mlrpc_p_syntax_id	mlrpc_p_syntax_id_t;
176
177_NO_REORDER_
178struct mlrpc_p_cont_elem {
179	mlrpc_p_context_id_t	p_cont_id;
180	BYTE			n_transfer_syn;
181	BYTE			_reserved;
182	mlrpc_p_syntax_id_t	abstract_syntax;
183    /*SIZE_IS(n_transfer_syn)*/
184	mlrpc_p_syntax_id_t	transfer_syntaxes[1];
185};
186typedef struct mlrpc_p_cont_elem	mlrpc_p_cont_elem_t;
187EXTERNTYPEINFO(mlrpc_p_cont_elem)
188
189_NO_REORDER_
190struct mlrpc_p_cont_list {
191	BYTE		n_context_elem;
192	BYTE		_reserved;
193	WORD		_reserved2;
194    /*SIZE_IS(n_context_elem)*/
195	mlrpc_p_cont_elem_t p_cont_elem[1];
196};
197typedef struct mlrpc_p_cont_list	mlrpc_p_cont_list_t;
198EXTERNTYPEINFO(mlrpc_p_cont_list)
199
200typedef WORD	mlrpc_p_cont_def_result_t;
201#define MLRPC_PCDR_ACCEPTANCE		0
202#define MLRPC_PCDR_USER_REJECTION	1
203#define MLRPC_PCDR_PROVIDER_REJECTION	2
204
205typedef WORD	mlrpc_p_provider_reason_t;
206#define MLRPC_PPR_REASON_NOT_SPECIFIED		0
207#define MLRPC_PPR_ABSTRACT_SYNTAX_NOT_SUPPORTED	1
208#define MLRPC_PPR_PROPOSED_TRANSFER_SYNTAXES_NOT_SUPPORTED 2
209#define MLRPC_PPR_LOCAL_LIMIT_EXCEEDED		3
210
211
212_NO_REORDER_
213struct mlrpc_p_result {
214	mlrpc_p_cont_def_result_t	result;		/* MLRPC_PCDR_... */
215	mlrpc_p_provider_reason_t	reason;		/* MLRPC_PPR_... */
216	mlrpc_p_syntax_id_t		transfer_syntax; /* 0-fill if
217							  * result!=ACCEPT*/
218};
219typedef struct mlrpc_p_result		mlrpc_p_result_t;
220EXTERNTYPEINFO(mlrpc_p_result)
221
222_NO_REORDER_
223struct mlrpc_p_result_list {
224	BYTE		n_results;
225	BYTE		reserved;
226	WORD		reserved2;
227    /*SIZE_IS(n_results)*/
228	mlrpc_p_result_t p_results[1];
229};
230typedef struct mlrpc_p_result_list	mlrpc_p_result_list_t;
231EXTERNTYPEINFO(mlrpc_p_result_list)
232
233#define MLRPC_PORT_ANY_MAX_PORT_SPEC	30
234_NO_REORDER_
235struct mlrpc_port_any {
236	WORD		length;		/* always 18 */
237    /*SIZE_IS(length)*/
238	BYTE		port_spec[MLRPC_PORT_ANY_MAX_PORT_SPEC];
239					/* \PIPE\ntsvcs */
240	/* We cheat by using 18, and pad on the right with zeroes */
241};
242typedef struct mlrpc_port_any		mlrpc_port_any_t;
243EXTERNTYPEINFO(mlrpc_port_any)
244
245
246/*
247 * Alter Context PDU (0x0E)
248 * (X/Open CAE Spec 12.6.4.1)
249 */
250_NO_REORDER_
251struct ndr_alter_context_hdr {
252	ndr_common_header_t common_hdr; /* 00:16 (see above) */
253
254	WORD max_xmit_frag;		/* 16:02 ignored */
255	WORD max_recv_frag;		/* 18:02 ignored */
256	DWORD assoc_group_id;		/* 20:04 ignored */
257
258	/*
259	 * Presentation context list (see bind hdr comments).
260	 */
261	mlrpc_p_cont_list_t p_context_elem;	/* 24: */
262
263	/* optional authentication verifier if auth_length != 0 */
264	/* auth_verifier_co_t auth_verifier; */
265};
266typedef struct ndr_alter_context_hdr ndr_alter_context_hdr_t;
267
268
269/*
270 * Alter Context Response PDU (0x0F)
271 * (X/Open CAE Spec 12.6.4.2)
272 *
273 * We can't automatically generate an alter context response header because
274 * the sec_addr is an interior conformant (variable length) array, which is
275 * inconsistent with IDL/NDR rules.  We mark this import-extern and provide
276 * a hand-coded marshalling function.
277 */
278IMPORT_EXTERN
279_NO_REORDER_
280struct ndr_alter_context_rsp_hdr {
281	ndr_common_header_t common_hdr; /* 00:16 (see above) */
282
283	WORD max_xmit_frag;		/* 16:02 ignored */
284	WORD max_recv_frag;		/* 18:02 ignored */
285	DWORD assoc_group_id;		/* 20:04 ignored */
286	mlrpc_port_any_t sec_addr;	/* 24:20 ignored */
287
288	/*
289	 * Presentation context list (see bind hdr comments).
290	 */
291	mlrpc_p_result_list_t p_result_list; /* 44:nn */
292
293	/* optional authentication verifier if auth_length != 0 */
294	/* auth_verifier_co_t auth_verifier; */
295};
296typedef struct ndr_alter_context_rsp_hdr ndr_alter_context_rsp_hdr_t;
297
298
299/*
300 * Bind PDU (0x0B)
301 * (X/Open CAE Spec 12.6.4.3)
302 */
303_NO_REORDER_
304struct ndr_bind_hdr {
305	ndr_common_header_t	common_hdr; /* 00:16 (see above) */
306
307	WORD		max_xmit_frag;	/* 16:02 max xmit frag size, bytes */
308	WORD		max_recv_frag;	/* 18:02 max recv frag size, bytes */
309	DWORD		assoc_group_id;	/* 20:04 association group */
310					/* 24: */
311
312	/* presentation, a variable**2 list, of presentation contexts */
313	mlrpc_p_cont_list_t p_context_elem;
314
315	/*
316	 * This could be followed by more transfer_syntaxes[] for the
317	 * p_cont_elem[0], and subsequently followed by more p_cont_elem[],
318	 * each with one or more transfer_syntaxes[].  A single
319	 * p_cont_elem[] with a single transfer_syntaxes[] is so common,
320	 * though, we embed it in the bind_hdr but the bind processor must
321	 * walk through this tail if there is one.
322	 */
323
324	/* optional authentication verifier iff auth_length != 0 */
325	/* auth_verifier_co_t	auth_verifier; */
326};
327typedef struct ndr_bind_hdr	ndr_bind_hdr_t;
328
329
330/*
331 * Bind_Ack PDU (0x0C)
332 * (X/Open CAE Spec 12.6.4.4)
333 *
334 * We can't automatically generate a bind ack header because the sec_addr
335 * is an interior conformant (variable length) array, which is inconsistent
336 * with IDL/NDR rules.  We mark this import-extern and provide a hand-coded
337 * marshalling function.
338 */
339IMPORT_EXTERN
340_NO_REORDER_
341struct ndr_bind_ack_hdr {
342	ndr_common_header_t	common_hdr; /* 00:16 (see above) */
343
344	WORD		max_xmit_frag;	/* 16:02 max xmit frag size, bytes */
345	WORD		max_recv_frag;	/* 18:02 max recv frag size, bytes */
346	DWORD		assoc_group_id;	/* 20:04 association group */
347	mlrpc_port_any_t sec_addr;	/* 24:20 */
348
349	mlrpc_p_result_list_t p_result_list; /* 44:nn */
350	/* This could be followed by more. See bind_hdr above */
351
352	/* optional authentication verifier iff auth_length != 0 */
353	/* auth_verifier_co_t	auth_verifier; */
354};
355typedef struct ndr_bind_ack_hdr	ndr_bind_ack_hdr_t;
356
357
358/*
359 * Request PDU (0x00)
360 ****************************************************************
361 * Two flavors, selected based on MLRPC_PFC_OBJECT_UUID in hdr.pfc_flags
362 *	one without the "object" (flag clear)
363 *	one with the "object" (flag set)
364 * (X/Open CAE Spec 12.6.4.9)
365 */
366
367_NO_REORDER_
368struct ndr_request_hdr {
369	ndr_common_header_t	common_hdr; /* 00:16 (see above) */
370
371	/* needed for request, response, or fault */
372	DWORD		alloc_hint;	/* 16:04 allocation hint */
373	mlrpc_p_context_id_t p_cont_id;	/* 20:02 pres context, i.e. data rep */
374	WORD		opnum;		/* 22:02 op number w/i interface */
375
376	/* optional field if PFC_OBJECT_UUID, not present */
377	/* ndr_uuid_t	object; */
378
379	/* stub-data, 8-octet aligned */ /* 24:nn */
380	/* nn = frag_len - sizeof(common_header) - auth_len */
381
382	/* optional authentication verifier iff auth_length != 0 */
383	/* auth_verifier_co_t	auth_verifier; */
384};
385typedef struct ndr_request_hdr	ndr_request_hdr_t;
386
387_NO_REORDER_
388struct ndr_request_hdr_with_object {
389	ndr_common_header_t	common_hdr; /* 00:16 (see above) */
390
391	/* needed for request, response, or fault */
392	DWORD		alloc_hint;	/* 16:04 allocation hint */
393	mlrpc_p_context_id_t p_cont_id;	/* 20:02 pres context, i.e. data rep */
394	WORD		opnum;		/* 22:02 op number w/i interface */
395
396	/* optional field if PFC_OBJECT_UUID, is present */
397	ndr_uuid_t	object;		/* 24:16 object UUID, unknown purpose*/
398
399	/* stub-data, 8-octet aligned */ /* 28:nn */
400	/* nn = frag_len - sizeof(common_header) - auth_len */
401	/* nn -= sizeof(ndr_uuid_t); */
402
403	/* optional authentication verifier iff auth_length != 0 */
404	/* auth_verifier_co_t	auth_verifier; */
405};
406
407
408
409/*
410 * Hack for response header sizing and multi-fragment responses.
411 * We know the header is going to be 24 bytes.
412 */
413#define MLRPC_RSP_HDR_SIZE			24
414
415
416/*
417 * Response PDU (0x02)
418 * (X/Open CAE Spec 12.6.4.10)
419 */
420
421_NO_REORDER_
422struct ndr_response_hdr {
423	ndr_common_header_t	common_hdr; /* 00:16 (see above) */
424
425	/* needed for request, response, or fault */
426	DWORD		alloc_hint;	/* 16:04 allocation hint */
427	mlrpc_p_context_id_t p_cont_id;	/* 20:02 pres context, i.e. data rep */
428
429	/* needed for response or fault */
430	BYTE		cancel_count;	/* 22:01 cancel count */
431	BYTE		reserved;	/* 23:01 mbz */
432
433	/* stub-data, 8-octet aligned */ /* 24:nn */
434	/* nn = frag_len - sizeof(common_header) - auth_len */
435
436	/* optional authentication verifier iff auth_length != 0 */
437	/* auth_verifier_co_t	auth_verifier; */
438};
439typedef struct ndr_response_hdr	ndr_response_hdr_t;
440
441
442
443/*
444 * Fault PDU (0x03)
445 * (X/Open CAE Spec 12.6.4.7)
446 */
447
448_NO_REORDER_
449struct ndr_fault_hdr {
450	ndr_common_header_t	common_hdr; /* 00:16 (see above) */
451
452	DWORD		alloc_hint;	/* 16:04 allocation hint */
453	mlrpc_p_context_id_t p_cont_id;	/* 20:02 pres context, i.e. data rep */
454
455	/* needed for response or fault */
456	BYTE		cancel_count;	/* 22:01 cancel count */
457	BYTE		reserved;	/* 23:01 mbz */
458
459	/* fault code */
460	DWORD		status;		/* 24:04 run-time fault code or 0 */
461
462	/* pad to 8-byte alignment */
463	BYTE		reserved2[4];	/* 28:04 must-be-zero */
464
465	/* stub-data here if status==0. We do not use this mode. */
466
467	/* optional authentication verifier iff auth_length != 0 */
468	/* auth_verifier_co_t	auth_verifier; */
469};
470typedef struct ndr_fault_hdr	ndr_fault_hdr_t;
471
472
473/* Fault status code (X/Open CAE Spec Appendix E) */
474#define MLRPC_FAULT_NCA_RPC_VERSION_MISMATCH	0x1c000008	/* CO/CL */
475#define MLRPC_FAULT_NCA_UNSPEC_REJECT		0x1c000009	/* CO/CL */
476#define MLRPC_FAULT_NCA_S_BAD_ACTID		0x1c00000A	/*    CL */
477#define MLRPC_FAULT_NCA_WHO_ARE_YOU_FAILED	0x1c00000B	/*    CL */
478#define MLRPC_FAULT_NCA_MANAGER_NOT_ENTERED	0x1c00000C	/* CO/CL */
479#define MLRPC_FAULT_NCA_OP_RNG_ERROR		0x1c010002	/* CO/CL */
480#define MLRPC_FAULT_NCA_UNK_IF			0x1c010003	/* CO/CL */
481#define MLRPC_FAULT_NCA_WRONG_BOOT_TIME		0x1c010006	/*    CL */
482#define MLRPC_FAULT_NCA_S_YOU_CRASHED		0x1c010009	/*    CL */
483#define MLRPC_FAULT_NCA_PROTO_ERROR		0x1c01000B	/* CO/CL */
484#define MLRPC_FAULT_NCA_OUT_ARGS_TOO_BIG	0x1c010013	/* CO/CL */
485#define MLRPC_FAULT_NCA_SERVER_TOO_BUSY		0x1c010014	/* CO/CL */
486#define MLRPC_FAULT_NCA_UNSUPPORTED_TYPE	0x1c010017	/* CO/CL */
487#define MLRPC_FAULT_NCA_INVALID_PRES_CONTEXT_ID	0x1c00001c	/* CO    */
488#define MLRPC_FAULT_NCA_UNSUPPORTED_AUTHN_LEVEL	0x1c00001d	/* CO/CL */
489#define MLRPC_FAULT_NCA_INVALID_CHECKSUM	0x1c00001f	/* CO/CL */
490#define MLRPC_FAULT_NCA_INVALID_CRC		0x1c000020	/* CO/CL */
491
492
493
494
495/*
496 * The Header Union/Switch
497 ****************************************************************
498 */
499
500#define MLRPC_PTYPE_COMMON		999
501#define MLRPC_PTYPE_REQUEST_WITH	998
502
503
504INTERFACE(0)
505union ndr_hdr {
506    CASE(MLRPC_PTYPE_COMMON)	/* exceeds BYTE range, obtains common hdr */
507	struct ndr_common_header		common_hdr;
508
509    CASE(MLRPC_PTYPE_BIND)
510	struct ndr_bind_hdr			bind_hdr;
511
512    CASE(MLRPC_PTYPE_BIND_ACK)
513	struct ndr_bind_ack_hdr			bind_ack_hdr;
514
515    CASE(MLRPC_PTYPE_REQUEST)
516	struct ndr_request_hdr			request_hdr;
517
518    CASE(MLRPC_PTYPE_REQUEST_WITH)	/* exceeds BYTE range, ... */
519	struct ndr_request_hdr_with_object	request_hdr_with;
520
521    CASE(MLRPC_PTYPE_RESPONSE)
522	struct ndr_response_hdr			response_hdr;
523
524    CASE(MLRPC_PTYPE_ALTER_CONTEXT)
525	struct ndr_alter_context_hdr		alter_context_hdr;
526
527    CASE(MLRPC_PTYPE_ALTER_CONTEXT_RESP)
528	struct ndr_alter_context_rsp_hdr	alter_context_rsp_hdr;
529
530    CASE(MLRPC_PTYPE_FAULT)
531	struct ndr_fault_hdr			fault_hdr;
532};
533typedef union ndr_hdr	ndr_hdr_t;
534EXTERNTYPEINFO(ndr_hdr)
535
536#endif /* _MLRPCPDU_NDL_ */
537
538