xref: /titanic_52/usr/src/uts/common/smbsrv/ndl/rpcpdu.ndl (revision 0a0e9771ca0211c15f3ac4466b661c145feeb9e4)
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 _RPCPDU_NDL_
27#define _RPCPDU_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#define NDR_TRANSFER_SYNTAX_UUID	"8a885d04-1ceb-11c9-9fe8-08002b104860"
44
45/*
46 * UUID (Universal Unique IDentifier)
47 */
48/* (X/Open CAE Spec Appendix A) */
49struct ndr_dce_uuid {
50	DWORD		time_low;
51	WORD		time_mid;
52	WORD		time_hi_and_version;
53	BYTE		clock_seq_hi_and_reserved;
54	BYTE		clock_seq_low;
55	BYTE		node[6];
56};
57
58struct ndr_uuid {
59	DWORD		data1;
60	WORD		data2;
61	WORD		data3;
62	BYTE		data4[8];
63};
64typedef struct ndr_uuid ndr_uuid_t;
65
66/*
67 * Representation label -- needed for RPC header
68 * (X/Open CAE Spec Chapter 14.1)
69 *
70 * Bits   Data Type   Description
71 * ----   ---------   -----------
72 * 0-3    charset     0=ASCII
73 *                    1=EBCDIC
74 * 4-7    byte-order  0=big-endian
75 *                    1=little-endian
76 * 8-15   float       0=IEEE
77 *                    1=VAX
78 *                    2=Cray
79 *                    3=IBM
80 * 16-31  reserved
81 */
82#define NDR_REPLAB_CHAR_MASK		0x0F	/* low nibble of intg_char */
83#define NDR_REPLAB_CHAR_ASCII		0x00	/* ASCII */
84#define NDR_REPLAB_CHAR_EBCDIC		0x01	/* EBCDIC (never happen) */
85#define NDR_REPLAB_INTG_MASK		0xF0	/* hi nibble of intg_char */
86#define NDR_REPLAB_INTG_BIG_ENDIAN	0x00	/* big endian */
87#define NDR_REPLAB_INTG_LITTLE_ENDIAN	0x10	/* little endian (x86) */
88#define NDR_REPLAB_FLOAT_IEEE		0x00
89#define NDR_REPLAB_FLOAT_VAX		0x01
90#define NDR_REPLAB_FLOAT_CRAY		0x02
91#define NDR_REPLAB_FLOAT_IBM		0x03
92
93struct ndr_representation_label {
94	BYTE		intg_char_rep;		/* integer and charset */
95	BYTE		float_rep;
96	BYTE		_spare[2];
97};
98typedef struct ndr_representation_label	ndr_replab_t;
99
100
101
102/*
103 * RPC PDU (Protocol Data Unit) types
104 ****************************************************************
105 * (X/Open CAE Spec 12.1)
106 */
107
108#define NDR_PTYPE_REQUEST		0x00	/* CO/CL */
109#define NDR_PTYPE_PING			0x01	/*    CL */
110#define NDR_PTYPE_RESPONSE		0x02	/* CO/CL */
111#define NDR_PTYPE_FAULT			0x03	/* CL/CL */
112#define NDR_PTYPE_WORKING		0x04	/*    CL */
113#define NDR_PTYPE_NOCALL		0x05	/*    CL */
114#define NDR_PTYPE_REJECT		0x06	/*    CL */
115#define NDR_PTYPE_ACK			0x07	/*    CL */
116#define NDR_PTYPE_CL_CANCEL		0x08	/*    CL */
117#define NDR_PTYPE_FACK			0x09	/*    CL */
118#define NDR_PTYPE_CANCEL_ACK		0x0A	/*    CL */
119#define NDR_PTYPE_BIND			0x0B	/* CO    */
120#define NDR_PTYPE_BIND_ACK		0x0C	/* CO    */
121#define NDR_PTYPE_BIND_NAK		0x0D	/* CO    */
122#define NDR_PTYPE_ALTER_CONTEXT		0x0E	/* CO    */
123#define NDR_PTYPE_ALTER_CONTEXT_RESP	0x0F	/* CO    */
124						/* 0x10 missing from DCE/RPC */
125#define NDR_PTYPE_SHUTDOWN		0x11	/* CO    */
126#define NDR_PTYPE_CO_CANCEL		0x12	/* CO    */
127#define NDR_PTYPE_ORPHANED		0x13	/* CO    */
128
129/*
130 * Flags in the RPC header for Connection-oriented PDU data types
131 * (X/Open CAE Spec 12.6.3.1)
132 */
133#define NDR_PFC_FIRST_FRAG		0x01	/* First fragment */
134#define NDR_PFC_LAST_FRAG		0x02	/* Last framgent */
135#define NDR_PFC_PENDING_CANCEL		0x04	/* Cancel was pending@sender*/
136#define NDR_PFC_RESERVED_1		0x08	/* */
137#define NDR_PFC_CONC_MPX		0x10	/* supports concurrent muxing
138						 * of single connection */
139#define NDR_PFC_DID_NOT_EXECUTE		0x20	/* for PTYPE_FAULT, guarantee
140						 * call did not execute */
141#define NDR_PFC_MAYBE			0x40	/* "maybe" semantics req'ed*/
142#define NDR_PFC_OBJECT_UUID		0x80	/* */
143
144
145/*
146 * Header common to all Connection-oriented RPC PDUs
147 ****************************************************************
148 * (X/Open CAE Spec 12.6.3.1)
149 */
150_NO_REORDER_
151struct ndr_common_header {
152	BYTE		rpc_vers;	/* 00:01 5 */
153	BYTE		rpc_vers_minor;	/* 01:01 0 */
154	BYTE		ptype;		/* 02:01 NDR_PTYPE_... */
155	BYTE		pfc_flags;	/* 03:01 NDR_PFC_... */
156	struct ndr_representation_label
157			packed_drep;	/* 04:04 NDR representation label */
158	WORD		frag_length;	/* 08:02 total length of frag */
159	WORD		auth_length;	/* 10:02 length of auth_value */
160	DWORD		call_id;	/* 12:04 call identifier */
161					/* 16: */
162};
163typedef struct ndr_common_header	ndr_common_header_t;
164EXTERNTYPEINFO(ndr_common_header)
165
166
167/*
168 * A plethora of supporting types, only defined the ones we need
169 * (X/Open CAE Spec 12.6.3.1)
170 */
171typedef WORD	ndr_p_context_id_t;
172
173_NO_REORDER_
174struct ndr_p_syntax_id {
175	ndr_uuid_t	if_uuid;
176	DWORD		if_version;
177};
178typedef struct ndr_p_syntax_id	ndr_p_syntax_id_t;
179
180_NO_REORDER_
181struct ndr_p_cont_elem {
182	ndr_p_context_id_t	p_cont_id;
183	BYTE			n_transfer_syn;
184	BYTE			_reserved;
185	ndr_p_syntax_id_t	abstract_syntax;
186    /*SIZE_IS(n_transfer_syn)*/
187	ndr_p_syntax_id_t	transfer_syntaxes[1];
188};
189typedef struct ndr_p_cont_elem	ndr_p_cont_elem_t;
190EXTERNTYPEINFO(ndr_p_cont_elem)
191
192_NO_REORDER_
193struct ndr_p_cont_list {
194	BYTE		n_context_elem;
195	BYTE		_reserved;
196	WORD		_reserved2;
197    /*SIZE_IS(n_context_elem)*/
198	ndr_p_cont_elem_t p_cont_elem[1];
199};
200typedef struct ndr_p_cont_list	ndr_p_cont_list_t;
201EXTERNTYPEINFO(ndr_p_cont_list)
202
203typedef WORD	ndr_p_cont_def_result_t;
204#define NDR_PCDR_ACCEPTANCE					0
205#define NDR_PCDR_USER_REJECTION					1
206#define NDR_PCDR_PROVIDER_REJECTION				2
207
208typedef WORD	ndr_p_provider_reason_t;
209#define NDR_PPR_REASON_NOT_SPECIFIED				0
210#define NDR_PPR_ABSTRACT_SYNTAX_NOT_SUPPORTED			1
211#define NDR_PPR_PROPOSED_TRANSFER_SYNTAXES_NOT_SUPPORTED	2
212#define NDR_PPR_LOCAL_LIMIT_EXCEEDED				3
213
214
215_NO_REORDER_
216struct ndr_p_result {
217	ndr_p_cont_def_result_t	result;		/* NDR_PCDR_... */
218	ndr_p_provider_reason_t	reason;		/* NDR_PPR_... */
219	ndr_p_syntax_id_t		transfer_syntax; /* 0-fill if
220							  * result!=ACCEPT*/
221};
222typedef struct ndr_p_result		ndr_p_result_t;
223EXTERNTYPEINFO(ndr_p_result)
224
225_NO_REORDER_
226struct ndr_p_result_list {
227	BYTE		n_results;
228	BYTE		reserved;
229	WORD		reserved2;
230    /*SIZE_IS(n_results)*/
231	ndr_p_result_t p_results[1];
232};
233typedef struct ndr_p_result_list	ndr_p_result_list_t;
234EXTERNTYPEINFO(ndr_p_result_list)
235
236#define NDR_PORT_ANY_MAX_PORT_SPEC	30
237_NO_REORDER_
238struct ndr_port_any {
239	WORD		length;		/* always 18 */
240    /*SIZE_IS(length)*/
241	BYTE		port_spec[NDR_PORT_ANY_MAX_PORT_SPEC];
242					/* \PIPE\ntsvcs */
243	/* We cheat by using 18, and pad on the right with zeroes */
244};
245typedef struct ndr_port_any		ndr_port_any_t;
246EXTERNTYPEINFO(ndr_port_any)
247
248
249/*
250 * Alter Context PDU (0x0E)
251 * (X/Open CAE Spec 12.6.4.1)
252 */
253_NO_REORDER_
254struct ndr_alter_context_hdr {
255	ndr_common_header_t common_hdr; /* 00:16 (see above) */
256
257	WORD max_xmit_frag;		/* 16:02 ignored */
258	WORD max_recv_frag;		/* 18:02 ignored */
259	DWORD assoc_group_id;		/* 20:04 ignored */
260
261	/*
262	 * Presentation context list (see bind hdr comments).
263	 */
264	ndr_p_cont_list_t p_context_elem;	/* 24: */
265
266	/* optional authentication verifier if auth_length != 0 */
267	/* auth_verifier_co_t auth_verifier; */
268};
269typedef struct ndr_alter_context_hdr ndr_alter_context_hdr_t;
270
271
272/*
273 * Alter Context Response PDU (0x0F)
274 * (X/Open CAE Spec 12.6.4.2)
275 *
276 * We can't automatically generate an alter context response header because
277 * the sec_addr is an interior conformant (variable length) array, which is
278 * inconsistent with IDL/NDR rules.  We mark this import-extern and provide
279 * a hand-coded marshalling function.
280 */
281IMPORT_EXTERN
282_NO_REORDER_
283struct ndr_alter_context_rsp_hdr {
284	ndr_common_header_t common_hdr; /* 00:16 (see above) */
285
286	WORD max_xmit_frag;		/* 16:02 ignored */
287	WORD max_recv_frag;		/* 18:02 ignored */
288	DWORD assoc_group_id;		/* 20:04 ignored */
289	ndr_port_any_t sec_addr;	/* 24:20 ignored */
290
291	/*
292	 * Presentation context list (see bind hdr comments).
293	 */
294	ndr_p_result_list_t p_result_list; /* 44:nn */
295
296	/* optional authentication verifier if auth_length != 0 */
297	/* auth_verifier_co_t auth_verifier; */
298};
299typedef struct ndr_alter_context_rsp_hdr ndr_alter_context_rsp_hdr_t;
300
301
302/*
303 * Bind PDU (0x0B)
304 * (X/Open CAE Spec 12.6.4.3)
305 */
306_NO_REORDER_
307struct ndr_bind_hdr {
308	ndr_common_header_t	common_hdr; /* 00:16 (see above) */
309
310	WORD		max_xmit_frag;	/* 16:02 max xmit frag size, bytes */
311	WORD		max_recv_frag;	/* 18:02 max recv frag size, bytes */
312	DWORD		assoc_group_id;	/* 20:04 association group */
313					/* 24: */
314
315	/* presentation, a variable**2 list, of presentation contexts */
316	ndr_p_cont_list_t p_context_elem;
317
318	/*
319	 * This could be followed by more transfer_syntaxes[] for the
320	 * p_cont_elem[0], and subsequently followed by more p_cont_elem[],
321	 * each with one or more transfer_syntaxes[].  A single
322	 * p_cont_elem[] with a single transfer_syntaxes[] is so common,
323	 * though, we embed it in the bind_hdr but the bind processor must
324	 * walk through this tail if there is one.
325	 */
326
327	/* optional authentication verifier iff auth_length != 0 */
328	/* auth_verifier_co_t	auth_verifier; */
329};
330typedef struct ndr_bind_hdr	ndr_bind_hdr_t;
331
332
333/*
334 * Bind_Ack PDU (0x0C)
335 * (X/Open CAE Spec 12.6.4.4)
336 *
337 * We can't automatically generate a bind ack header because the sec_addr
338 * is an interior conformant (variable length) array, which is inconsistent
339 * with IDL/NDR rules.  We mark this import-extern and provide a hand-coded
340 * marshalling function.
341 */
342IMPORT_EXTERN
343_NO_REORDER_
344struct ndr_bind_ack_hdr {
345	ndr_common_header_t	common_hdr; /* 00:16 (see above) */
346
347	WORD		max_xmit_frag;	/* 16:02 max xmit frag size, bytes */
348	WORD		max_recv_frag;	/* 18:02 max recv frag size, bytes */
349	DWORD		assoc_group_id;	/* 20:04 association group */
350	ndr_port_any_t	sec_addr;	/* 24:20 */
351
352	ndr_p_result_list_t p_result_list; /* 44:nn */
353	/* This could be followed by more. See bind_hdr above */
354
355	/* optional authentication verifier iff auth_length != 0 */
356	/* auth_verifier_co_t	auth_verifier; */
357};
358typedef struct ndr_bind_ack_hdr	ndr_bind_ack_hdr_t;
359
360
361/*
362 * Request PDU (0x00)
363 ****************************************************************
364 * Two flavors, selected based on PFC_OBJECT_UUID in hdr.pfc_flags
365 *	one without the "object" (flag clear)
366 *	one with the "object" (flag set)
367 * (X/Open CAE Spec 12.6.4.9)
368 */
369
370_NO_REORDER_
371struct ndr_request_hdr {
372	ndr_common_header_t	common_hdr; /* 00:16 (see above) */
373
374	/* needed for request, response, or fault */
375	DWORD		alloc_hint;	/* 16:04 allocation hint */
376	ndr_p_context_id_t p_cont_id;	/* 20:02 pres context, i.e. data rep */
377	WORD		opnum;		/* 22:02 op number w/i interface */
378
379	/* optional field if PFC_OBJECT_UUID, not present */
380	/* ndr_uuid_t	object; */
381
382	/* stub-data, 8-octet aligned */ /* 24:nn */
383	/* nn = frag_len - sizeof(common_header) - auth_len */
384
385	/* optional authentication verifier iff auth_length != 0 */
386	/* auth_verifier_co_t	auth_verifier; */
387};
388typedef struct ndr_request_hdr	ndr_request_hdr_t;
389
390_NO_REORDER_
391struct ndr_request_hdr_with_object {
392	ndr_common_header_t	common_hdr; /* 00:16 (see above) */
393
394	/* needed for request, response, or fault */
395	DWORD		alloc_hint;	/* 16:04 allocation hint */
396	ndr_p_context_id_t p_cont_id;	/* 20:02 pres context, i.e. data rep */
397	WORD		opnum;		/* 22:02 op number w/i interface */
398
399	/* optional field if PFC_OBJECT_UUID, is present */
400	ndr_uuid_t	object;		/* 24:16 object UUID, unknown purpose*/
401
402	/* stub-data, 8-octet aligned */ /* 28:nn */
403	/* nn = frag_len - sizeof(common_header) - auth_len */
404	/* nn -= sizeof(ndr_uuid_t); */
405
406	/* optional authentication verifier iff auth_length != 0 */
407	/* auth_verifier_co_t	auth_verifier; */
408};
409
410
411/*
412 * Convenient for response header sizing and multi-fragment responses.
413 * We know the header is going to be 24 bytes.
414 */
415#define NDR_RSP_HDR_SIZE			24
416
417
418/*
419 * Response PDU (0x02)
420 * (X/Open CAE Spec 12.6.4.10)
421 */
422
423_NO_REORDER_
424struct ndr_response_hdr {
425	ndr_common_header_t	common_hdr; /* 00:16 (see above) */
426
427	/* needed for request, response, or fault */
428	DWORD		alloc_hint;	/* 16:04 allocation hint */
429	ndr_p_context_id_t p_cont_id;	/* 20:02 pres context, i.e. data rep */
430
431	/* needed for response or fault */
432	BYTE		cancel_count;	/* 22:01 cancel count */
433	BYTE		reserved;	/* 23:01 mbz */
434
435	/* stub-data, 8-octet aligned */ /* 24:nn */
436	/* nn = frag_len - sizeof(common_header) - auth_len */
437
438	/* optional authentication verifier iff auth_length != 0 */
439	/* auth_verifier_co_t	auth_verifier; */
440};
441typedef struct ndr_response_hdr	ndr_response_hdr_t;
442
443
444/*
445 * Fault PDU (0x03)
446 * (X/Open CAE Spec 12.6.4.7)
447 */
448
449_NO_REORDER_
450struct ndr_fault_hdr {
451	ndr_common_header_t	common_hdr; /* 00:16 (see above) */
452
453	DWORD		alloc_hint;	/* 16:04 allocation hint */
454	ndr_p_context_id_t p_cont_id;	/* 20:02 pres context, i.e. data rep */
455
456	/* needed for response or fault */
457	BYTE		cancel_count;	/* 22:01 cancel count */
458	BYTE		reserved;	/* 23:01 mbz */
459
460	/* fault code */
461	DWORD		status;		/* 24:04 run-time fault code or 0 */
462
463	/* pad to 8-byte alignment */
464	BYTE		reserved2[4];	/* 28:04 must-be-zero */
465
466	/* stub-data here if status==0. We do not use this mode. */
467
468	/* optional authentication verifier iff auth_length != 0 */
469	/* auth_verifier_co_t	auth_verifier; */
470};
471typedef struct ndr_fault_hdr	ndr_fault_hdr_t;
472
473
474/* Fault status code (X/Open CAE Spec Appendix E) */
475#define NDR_FAULT_NCA_RPC_VERSION_MISMATCH	0x1c000008	/* CO/CL */
476#define NDR_FAULT_NCA_UNSPEC_REJECT		0x1c000009	/* CO/CL */
477#define NDR_FAULT_NCA_S_BAD_ACTID		0x1c00000A	/*    CL */
478#define NDR_FAULT_NCA_WHO_ARE_YOU_FAILED	0x1c00000B	/*    CL */
479#define NDR_FAULT_NCA_MANAGER_NOT_ENTERED	0x1c00000C	/* CO/CL */
480#define NDR_FAULT_NCA_OP_RNG_ERROR		0x1c010002	/* CO/CL */
481#define NDR_FAULT_NCA_UNK_IF			0x1c010003	/* CO/CL */
482#define NDR_FAULT_NCA_WRONG_BOOT_TIME		0x1c010006	/*    CL */
483#define NDR_FAULT_NCA_S_YOU_CRASHED		0x1c010009	/*    CL */
484#define NDR_FAULT_NCA_PROTO_ERROR		0x1c01000B	/* CO/CL */
485#define NDR_FAULT_NCA_OUT_ARGS_TOO_BIG		0x1c010013	/* CO/CL */
486#define NDR_FAULT_NCA_SERVER_TOO_BUSY		0x1c010014	/* CO/CL */
487#define NDR_FAULT_NCA_UNSUPPORTED_TYPE		0x1c010017	/* CO/CL */
488#define NDR_FAULT_NCA_INVALID_PRES_CONTEXT_ID	0x1c00001c	/* CO    */
489#define NDR_FAULT_NCA_UNSUPPORTED_AUTHN_LEVEL	0x1c00001d	/* CO/CL */
490#define NDR_FAULT_NCA_INVALID_CHECKSUM		0x1c00001f	/* CO/CL */
491#define NDR_FAULT_NCA_INVALID_CRC		0x1c000020	/* CO/CL */
492
493
494/*
495 * The Header Union/Switch
496 ****************************************************************
497 */
498
499#define NDR_PTYPE_COMMON		999
500#define NDR_PTYPE_REQUEST_WITH		998
501
502
503INTERFACE(0)
504union ndr_hdr {
505    CASE(NDR_PTYPE_COMMON)	/* exceeds BYTE range, obtains common hdr */
506	struct ndr_common_header		common_hdr;
507
508    CASE(NDR_PTYPE_BIND)
509	struct ndr_bind_hdr			bind_hdr;
510
511    CASE(NDR_PTYPE_BIND_ACK)
512	struct ndr_bind_ack_hdr			bind_ack_hdr;
513
514    CASE(NDR_PTYPE_REQUEST)
515	struct ndr_request_hdr			request_hdr;
516
517    CASE(NDR_PTYPE_REQUEST_WITH)	/* exceeds BYTE range, ... */
518	struct ndr_request_hdr_with_object	request_hdr_with;
519
520    CASE(NDR_PTYPE_RESPONSE)
521	struct ndr_response_hdr			response_hdr;
522
523    CASE(NDR_PTYPE_ALTER_CONTEXT)
524	struct ndr_alter_context_hdr		alter_context_hdr;
525
526    CASE(NDR_PTYPE_ALTER_CONTEXT_RESP)
527	struct ndr_alter_context_rsp_hdr	alter_context_rsp_hdr;
528
529    CASE(NDR_PTYPE_FAULT)
530	struct ndr_fault_hdr			fault_hdr;
531};
532typedef union ndr_hdr	ndr_hdr_t;
533EXTERNTYPEINFO(ndr_hdr)
534
535#endif /* _RPCPDU_NDL_ */
536
537