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 2009 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 *
25 * Copyright 2020 Tintri by DDN, Inc. All rights reserved.
26 */
27
28#ifndef _NDRTYPES_NDL_
29#define _NDRTYPES_NDL_
30
31/*
32 * Type definitions (and related) used in NDL files and the
33 * NDL run-time support libraries.  See also: libmlrpc.h
34 */
35
36#define TYPEINFO(TYPE)  ndt__##TYPE
37
38#ifdef NDRGEN
39
40#define ALIGN(X)	[align(X)]
41#define OPERATION(X)	[operation(X)]
42#define IN		[in]
43#define OUT		[out]
44#define INOUT		[in out]
45#define FAKE		[fake]
46
47#define STRING		[string]
48#define SIZE_IS(X)	[size_is(X)]
49
50#define SWITCH(X)	[switch_is(X)]
51#define CASE(X)		[case(X)]
52#define DEFAULT		[default]
53
54#define INTERFACE(X)	[interface(X)]
55#define UUID(X)		[uuid(X)]
56
57#define ARG_IS(X)	[arg_is(X)]
58
59#define REFERENCE	[reference]
60#define REF		[reference]
61#define UNIQUE		[unique]
62#define PTR		[ptr]
63#define POINTER_DEFAULT(X)	[pointer_default(X)]
64
65#define ANY_SIZE_ARRAY	*
66
67#define IMPORT_EXTERN	[extern]
68
69#define BYTE	uchar
70#define WORD	ushort
71#define DWORD	ulong
72#define ntstatus_t	ulong
73
74#define LPTSTR	STRING wchar *
75
76#define LPBYTE  uchar *
77#define LPWORD  ushort *
78#define LPDWORD ulong *
79
80#define EXTERNTYPEINFO(TYPE)
81
82#else /* NDRGEN */
83
84#define ALIGN(X)
85#define OPERATION(X)
86#define IN
87#define OUT
88#define INOUT
89#define FAKE
90
91#define STRING
92#define SIZE_IS(X)
93
94#define SWITCH(X)
95#define CASE(X)
96#define DEFAULT
97
98#define INTERFACE(X)
99#define UUID(X)
100
101#define ARG_IS(X)
102
103#define REFERENCE
104#define REF
105#define UNIQUE
106#define PTR
107#define POINTER_DEFAULT(X)
108
109#define IMPORT_EXTERN
110
111/*
112 * When not using ndrgen, get BYTE, WORD, DWORD definitions from wintypes.h.
113 */
114#include <smb/wintypes.h>
115
116#define EXTERNTYPEINFO(TYPE)	extern struct ndr_typeinfo TYPEINFO(TYPE);
117
118
119/*
120 ***********************************************************************
121 * There is a bug in the way that midl and the marshalling code handles
122 * unions so we need to fix some of the data offsets at runtime. The
123 * following macros and the fixup function handle the correction.
124 ***********************************************************************
125 */
126
127/*
128 * DECL_FIXUP_STRUCT allows us to declare external references to data
129 * structures generated by ndrgen in the _ndr.c file.
130 */
131#define DECL_FIXUP_STRUCT(NAME)	extern struct ndr_typeinfo ndt__##NAME
132
133/*
134 * CASE_INFO_ENT is intended to simplify the declaration of the case
135 * statement in the fixup function. Assuming you have followed the
136 * convention for naming the individual structures all you have to do
137 * is add a single line to the fixup function for each new case.
138 */
139#define CASE_INFO_ENT(NAME,N) \
140			case N: size1 = sizeof (struct NAME##N); \
141			break
142
143/*
144 * FIXUP_PDU_SIZE is used to patch the appropriate structures (identified
145 * by DECL_FIXUP_STRUCT) at runtime. The values are based on the
146 * switch_index.
147 */
148#define FIXUP_PDU_SIZE(NAME,SIZE) { \
149	ndt__##NAME.pdu_size_fixed_part = SIZE; \
150	ndt__##NAME.c_size_fixed_part = SIZE; \
151}
152
153
154#endif /* NDRGEN */
155
156/*
157 * UNION_INFO_ENT is intended to simplify adding new entries to a union.
158 * If the entry structures are named using the form FunctionNameX,
159 * where X is the sitch_value, you can just add a single line. Note
160 * that you must also update the fixup function in mlsvc_xxx.c.
161 */
162#define UNION_INFO_ENT(N,NAME) CASE(N) struct NAME##N info##N
163#define UNION_INFO_PTR(N,NAME) CASE(N) struct NAME##N *info##N
164
165/*
166 * Opaque context handle.
167 */
168#ifndef CONTEXT_HANDLE
169#define CONTEXT_HANDLE(NAME)	\
170	struct NAME {		\
171		DWORD data1;    \
172		DWORD data2;    \
173		WORD  data3[2]; \
174		BYTE  data4[8];	\
175	};			\
176	typedef struct NAME
177#endif /* CONTEXT_HANDLE */
178
179#endif /* _NDRTYPES_NDL_ */
180