3 * Traakan, Inc., Los Altos, CA
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice unmodified, this list of conditions, and the following
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 ****************************************************************
43 * These make things a bit more readable and less error prone.
44 * They also foster consistency.
48 /* straight assignments */
49 #define CNVT_TO_9(PX, P9, MEMBER) ((P9)->MEMBER = (PX)->MEMBER)
50 #define CNVT_FROM_9(PX, P9, MEMBER) ((PX)->MEMBER = (P9)->MEMBER)
51 #define CNVT_TO_9x(PX, P9, MEMBERX, MEMBER9) ((P9)->MEMBER9 = (PX)->MEMBERX)
52 #define CNVT_FROM_9x(PX, P9, MEMBERX, MEMBER9) ((PX)->MEMBERX = (P9)->MEMBER9)
55 #define CNVT_E_TO_9(PX, P9, MEMBER, ENUM_CONVERSION_TABLE) \
56 ((P9)->MEMBER = convert_enum_to_9 (ENUM_CONVERSION_TABLE, (PX)->MEMBER))
58 #define CNVT_E_FROM_9(PX, P9, MEMBER, ENUM_CONVERSION_TABLE) \
59 ((PX)->MEMBER = convert_enum_from_9 (ENUM_CONVERSION_TABLE, (P9)->MEMBER))
61 #define CNVT_VUL_TO_9(PX, P9, MEMBER) \
62 convert_valid_u_long_to_9 (&(PX)->MEMBER, &(P9)->MEMBER)
64 #define CNVT_VUL_FROM_9(PX, P9, MEMBER) \
65 convert_valid_u_long_from_9 (&(PX)->MEMBER, &(P9)->MEMBER)
67 #define CNVT_VUL_TO_9x(PX, P9, MEMBERX, MEMBER9) \
68 convert_valid_u_long_to_9 (&(PX)->MEMBERX, &(P9)->MEMBER9)
70 #define CNVT_VUL_FROM_9x(PX, P9, MEMBERX, MEMBER9) \
71 convert_valid_u_long_from_9 (&(PX)->MEMBERX, &(P9)->MEMBER9)
73 #define CNVT_IUL_TO_9(P9, MEMBER) \
74 convert_invalid_u_long_9 (&(P9)->MEMBER)
76 #define CNVT_VUQ_TO_9(PX, P9, MEMBER) \
77 convert_valid_u_quad_to_9 (&(PX)->MEMBER, &(P9)->MEMBER)
79 #define CNVT_VUQ_FROM_9(PX, P9, MEMBER) \
80 convert_valid_u_quad_from_9 (&(PX)->MEMBER, &(P9)->MEMBER)
82 #define CNVT_VUQ_TO_9x(PX, P9, MEMBERX, MEMBER9) \
83 convert_valid_u_quad_to_9 (&(PX)->MEMBERX, &(P9)->MEMBER9)
85 #define CNVT_VUQ_FROM_9x(PX, P9, MEMBERX, MEMBER9) \
86 convert_valid_u_quad_from_9 (&(PX)->MEMBERX, &(P9)->MEMBER9)
88 #define CNVT_IUQ_TO_9(P9, MEMBER) \
89 convert_invalid_u_quad_9 (&(P9)->MEMBER)
91 #define CNVT_STRDUP_TO_9(PX, P9, MEMBER) \
92 convert_strdup ((PX)->MEMBER, &(P9)->MEMBER)
94 #define CNVT_STRDUP_FROM_9(PX, P9, MEMBER) \
95 convert_strdup ((P9)->MEMBER, &(PX)->MEMBER)
97 #define CNVT_STRDUP_TO_9x(PX, P9, MEMBERX, MEMBER9) \
98 convert_strdup ((PX)->MEMBERX, &(P9)->MEMBER9)
100 #define CNVT_STRDUP_FROM_9x(PX, P9, MEMBERX, MEMBER9) \
101 convert_strdup ((P9)->MEMBER9, &(PX)->MEMBERX)
106 * enum_conversion tables
107 ****************************************************************
108 * Used to make enum conversion convenient and dense.
109 * The first row is the default case in both directions,
110 * and is skipped while attempting precise conversion.
111 * The search stops with the first match.
114 struct enum_conversion {
119 #define END_ENUM_CONVERSION_TABLE { -1, -1 }
120 #define IS_END_ENUM_CONVERSION_TABLE(EC) \
121 ((EC)->enum_x == -1 && (EC)->enum_9 == -1)
125 extern int /* ndmp9_.... */
126 convert_enum_to_9 (struct enum_conversion *ectab, int enum_x);
127 extern int /* ndmpx_.... */
128 convert_enum_from_9 (struct enum_conversion *ectab, int enum_9);
130 convert_valid_u_long_to_9 (u_long *valx, ndmp9_valid_u_long *val9);
132 convert_valid_u_long_from_9 (u_long *valx, ndmp9_valid_u_long *val9);
134 convert_invalid_u_long_9 (struct ndmp9_valid_u_long *val9);
136 convert_valid_u_quad_to_9 (ndmp9_u_quad *valx, ndmp9_valid_u_quad *val9);
138 convert_valid_u_quad_from_9 (ndmp9_u_quad *valx, ndmp9_valid_u_quad *val9);
140 convert_invalid_u_quad_9 (struct ndmp9_valid_u_quad *val9);
142 convert_strdup (char *src, char **dstp);
147 * request/reply translation tables
148 ****************************************************************
151 struct reqrep_xlate {
153 ndmp9_message v9_message;
155 int (*request_xto9) (/* void *vxbody, void *v9body */);
156 int (*request_9tox) (/* void *v9body, void *vxbody */);
157 int (*reply_xto9) (/* void *vxbody, void *v9body */);
158 int (*reply_9tox) (/* void *v9body, void *vxbody */);
160 int (*free_request_xto9) (/* void *v9body */);
161 int (*free_request_9tox) (/* void *vxbody */);
162 int (*free_reply_xto9) (/* void *v9body */);
163 int (*free_reply_9tox) (/* void *vxbody */);
167 struct reqrep_xlate_version_table {
168 int protocol_version;
169 struct reqrep_xlate * reqrep_xlate_table;
172 extern struct reqrep_xlate_version_table reqrep_xlate_version_table[];
174 extern struct reqrep_xlate *reqrep_xlate_lookup_version (
175 struct reqrep_xlate_version_table *rrvt,
176 unsigned protocol_version);
178 extern struct reqrep_xlate *ndmp_reqrep_by_v9 (struct reqrep_xlate *table,
179 ndmp9_message v9_message);
180 extern struct reqrep_xlate *ndmp_reqrep_by_vx (struct reqrep_xlate *table,
183 extern int ndmp_xtox_no_arguments (void *vxbody, void *vybody);
185 extern int ndmp_xtox_no_memused (void *vxbody);
192 ****************************************************************
196 #ifndef NDMOS_OPTION_NO_NDMP2
197 #include "ndmp2_translate.h"
198 #endif /* !NDMOS_OPTION_NO_NDMP2 */
200 #ifndef NDMOS_OPTION_NO_NDMP3
201 #include "ndmp3_translate.h"
202 #endif /* !NDMOS_OPTION_NO_NDMP3 */
204 #ifndef NDMOS_OPTION_NO_NDMP4
205 #include "ndmp4_translate.h"
206 #endif /* !NDMOS_OPTION_NO_NDMP4 */