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