1 /*
2  * Copyright (c) 1998,1999,2000
3  *      Traakan, Inc., Los Altos, CA
4  *      All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice unmodified, this list of conditions, and the following
11  *    disclaimer.
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.
15  *
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
26  * SUCH DAMAGE.
27  */
28 
29 /*
30  * Project:  NDMJOB
31  * Ident:    $Id: $
32  *
33  * Description:
34  *
35  */
36 
37 
38 #include "ndmos.h"
39 #include "ndmprotocol.h"
40 
41 
42 #ifndef NDMOS_OPTION_NO_NDMP2
43 
44 
45 #define xdr_ndmp2_connect_close_request xdr_void
46 #define xdr_ndmp2_connect_close_reply xdr_void
47 #define xdr_ndmp2_config_get_host_info_request xdr_void
48 #define xdr_ndmp2_config_get_mover_type_request xdr_void
49 #define xdr_ndmp2_scsi_close_request xdr_void
50 #define xdr_ndmp2_scsi_get_state_request xdr_void
51 #define xdr_ndmp2_scsi_reset_device_request xdr_void
52 #define xdr_ndmp2_scsi_reset_bus_request xdr_void
53 #define xdr_ndmp2_tape_close_request xdr_void
54 #define xdr_ndmp2_tape_get_state_request xdr_void
55 #define xdr_ndmp2_data_get_state_request xdr_void
56 
57 #define xdr_ndmp2_data_abort_request xdr_void
58 #define xdr_ndmp2_data_get_env_request xdr_void
59 #define xdr_ndmp2_data_stop_request xdr_void
60 #define xdr_ndmp2_notify_data_halted_reply 0
61 #define xdr_ndmp2_notify_connected_reply 0
62 #define xdr_ndmp2_notify_mover_halted_reply 0
63 #define xdr_ndmp2_notify_mover_paused_reply 0
64 #define xdr_ndmp2_notify_data_read_reply 0
65 #define xdr_ndmp2_log_log_reply 0
66 #define xdr_ndmp2_log_debug_reply 0
67 #define xdr_ndmp2_log_file_reply 0
68 #define xdr_ndmp2_fh_add_unix_path_reply 0
69 #define xdr_ndmp2_fh_add_unix_dir_reply 0
70 #define xdr_ndmp2_fh_add_unix_node_reply 0
71 #define xdr_ndmp2_mover_get_state_request xdr_void
72 #define xdr_ndmp2_mover_continue_request xdr_void
73 #define xdr_ndmp2_mover_abort_request xdr_void
74 #define xdr_ndmp2_mover_stop_request xdr_void
75 #define xdr_ndmp2_mover_close_request xdr_void
76 
77 
78 struct ndmp_xdr_message_table ndmp2_xdr_message_table[] = {
79     {
80         NDMP2_CONNECT_OPEN,
81         xdr_ndmp2_connect_open_request,
82         xdr_ndmp2_connect_open_reply,
83     },
84     {
85         NDMP2_CONNECT_CLIENT_AUTH,
86         xdr_ndmp2_connect_client_auth_request,
87         xdr_ndmp2_connect_client_auth_reply,
88     },
89     {
90         NDMP2_CONNECT_CLOSE,
91         xdr_ndmp2_connect_close_request,
92         xdr_ndmp2_connect_close_reply,
93     },
94     {
95         NDMP2_CONNECT_SERVER_AUTH,
96         xdr_ndmp2_connect_server_auth_request,
97         xdr_ndmp2_connect_server_auth_reply,
98     },
99     {
100         NDMP2_CONFIG_GET_HOST_INFO,
101         xdr_ndmp2_config_get_host_info_request,
102         xdr_ndmp2_config_get_host_info_reply,
103     },
104     {
105         NDMP2_CONFIG_GET_BUTYPE_ATTR,
106         xdr_ndmp2_config_get_butype_attr_request,
107         xdr_ndmp2_config_get_butype_attr_reply,
108     },
109     {
110         NDMP2_CONFIG_GET_MOVER_TYPE,
111         xdr_ndmp2_config_get_mover_type_request,
112         xdr_ndmp2_config_get_mover_type_reply,
113     },
114     {
115         NDMP2_CONFIG_GET_AUTH_ATTR,
116         xdr_ndmp2_config_get_auth_attr_request,
117         xdr_ndmp2_config_get_auth_attr_reply,
118     },
119     {
120         NDMP2_SCSI_OPEN,
121         xdr_ndmp2_scsi_open_request,
122         xdr_ndmp2_scsi_open_reply,
123     },
124     {
125         NDMP2_SCSI_CLOSE,
126         xdr_ndmp2_scsi_close_request,
127         xdr_ndmp2_scsi_close_reply,
128     },
129     {
130         NDMP2_SCSI_GET_STATE,
131         xdr_ndmp2_scsi_get_state_request,
132         xdr_ndmp2_scsi_get_state_reply,
133     },
134     {
135         NDMP2_SCSI_SET_TARGET,
136         xdr_ndmp2_scsi_set_target_request,
137         xdr_ndmp2_scsi_set_target_reply,
138     },
139     {
140         NDMP2_SCSI_RESET_DEVICE,
141         xdr_ndmp2_scsi_reset_device_request,
142         xdr_ndmp2_scsi_reset_device_reply,
143     },
144     {
145         NDMP2_SCSI_RESET_BUS,
146         xdr_ndmp2_scsi_reset_bus_request,
147         xdr_ndmp2_scsi_reset_bus_reply,
148     },
149     {
150         NDMP2_SCSI_EXECUTE_CDB,
151         xdr_ndmp2_scsi_execute_cdb_request,
152         xdr_ndmp2_scsi_execute_cdb_reply,
153     },
154     {
155         NDMP2_TAPE_OPEN,
156         xdr_ndmp2_tape_open_request,
157         xdr_ndmp2_tape_open_reply,
158     },
159     {
160         NDMP2_TAPE_CLOSE,
161         xdr_ndmp2_tape_close_request,
162         xdr_ndmp2_tape_close_reply,
163     },
164     {
165         NDMP2_TAPE_GET_STATE,
166         xdr_ndmp2_tape_get_state_request,
167         xdr_ndmp2_tape_get_state_reply,
168     },
169     {
170         NDMP2_TAPE_MTIO,
171         xdr_ndmp2_tape_mtio_request,
172         xdr_ndmp2_tape_mtio_reply,
173     },
174     {
175         NDMP2_TAPE_WRITE,
176         xdr_ndmp2_tape_write_request,
177         xdr_ndmp2_tape_write_reply,
178     },
179     {
180         NDMP2_TAPE_READ,
181         xdr_ndmp2_tape_read_request,
182         xdr_ndmp2_tape_read_reply,
183     },
184     {
185         NDMP2_TAPE_EXECUTE_CDB,
186         xdr_ndmp2_tape_execute_cdb_request,
187         xdr_ndmp2_tape_execute_cdb_reply,
188     },
189     {
190         NDMP2_DATA_GET_STATE,
191         xdr_ndmp2_data_get_state_request,
192         xdr_ndmp2_data_get_state_reply,
193     },
194     {
195         NDMP2_DATA_START_BACKUP,
196         xdr_ndmp2_data_start_backup_request,
197         xdr_ndmp2_data_start_backup_reply,
198     },
199     {
200         NDMP2_DATA_START_RECOVER,
201         xdr_ndmp2_data_start_recover_request,
202         xdr_ndmp2_data_start_recover_reply,
203     },
204     {
205         NDMP2_DATA_ABORT,
206         xdr_ndmp2_data_abort_request,
207         xdr_ndmp2_data_abort_reply,
208     },
209     {
210         NDMP2_DATA_GET_ENV,
211         xdr_ndmp2_data_get_env_request,
212         xdr_ndmp2_data_get_env_reply,
213     },
214     {
215         NDMP2_DATA_STOP,
216         xdr_ndmp2_data_stop_request,
217         xdr_ndmp2_data_stop_reply,
218     },
219     {
220         NDMP2_DATA_START_RECOVER_FILEHIST,
221         xdr_ndmp2_data_start_recover_filehist_request,
222         xdr_ndmp2_data_start_recover_filehist_reply,
223     },
224     {
225         NDMP2_NOTIFY_DATA_HALTED,
226         xdr_ndmp2_notify_data_halted_request,
227         xdr_ndmp2_notify_data_halted_reply,
228     },
229     {
230         NDMP2_NOTIFY_CONNECTED,
231         xdr_ndmp2_notify_connected_request,
232         xdr_ndmp2_notify_connected_reply,
233     },
234     {
235         NDMP2_NOTIFY_MOVER_HALTED,
236         xdr_ndmp2_notify_mover_halted_request,
237         xdr_ndmp2_notify_mover_halted_reply,
238     },
239     {
240         NDMP2_NOTIFY_MOVER_PAUSED,
241         xdr_ndmp2_notify_mover_paused_request,
242         xdr_ndmp2_notify_mover_paused_reply,
243     },
244     {
245         NDMP2_NOTIFY_DATA_READ,
246         xdr_ndmp2_notify_data_read_request,
247         xdr_ndmp2_notify_data_read_reply,
248     },
249     {
250         NDMP2_LOG_LOG,
251         xdr_ndmp2_log_log_request,
252         xdr_ndmp2_log_log_reply,
253     },
254     {
255         NDMP2_LOG_DEBUG,
256         xdr_ndmp2_log_debug_request,
257         xdr_ndmp2_log_debug_reply,
258     },
259     {
260         NDMP2_LOG_FILE,
261         xdr_ndmp2_log_file_request,
262         xdr_ndmp2_log_file_reply,
263     },
264     {
265         NDMP2_FH_ADD_UNIX_PATH,
266         xdr_ndmp2_fh_add_unix_path_request,
267         xdr_ndmp2_fh_add_unix_path_reply,
268     },
269     {
270         NDMP2_FH_ADD_UNIX_DIR,
271         xdr_ndmp2_fh_add_unix_dir_request,
272         xdr_ndmp2_fh_add_unix_dir_reply,
273     },
274     {
275         NDMP2_FH_ADD_UNIX_NODE,
276         xdr_ndmp2_fh_add_unix_node_request,
277         xdr_ndmp2_fh_add_unix_node_reply,
278     },
279     {
280         NDMP2_MOVER_GET_STATE,
281         xdr_ndmp2_mover_get_state_request,
282         xdr_ndmp2_mover_get_state_reply,
283     },
284     {
285         NDMP2_MOVER_LISTEN,
286         xdr_ndmp2_mover_listen_request,
287         xdr_ndmp2_mover_listen_reply,
288     },
289     {
290         NDMP2_MOVER_CONTINUE,
291         xdr_ndmp2_mover_continue_request,
292         xdr_ndmp2_mover_continue_reply,
293     },
294     {
295         NDMP2_MOVER_ABORT,
296         xdr_ndmp2_mover_abort_request,
297         xdr_ndmp2_mover_abort_reply,
298     },
299     {
300         NDMP2_MOVER_STOP,
301         xdr_ndmp2_mover_stop_request,
302         xdr_ndmp2_mover_stop_reply,
303     },
304     {
305         NDMP2_MOVER_SET_WINDOW,
306         xdr_ndmp2_mover_set_window_request,
307         xdr_ndmp2_mover_set_window_reply,
308     },
309     {
310         NDMP2_MOVER_READ,
311         xdr_ndmp2_mover_read_request,
312         xdr_ndmp2_mover_read_reply,
313     },
314     {
315         NDMP2_MOVER_CLOSE,
316         xdr_ndmp2_mover_close_request,
317         xdr_ndmp2_mover_close_reply,
318     },
319     {
320         NDMP2_MOVER_SET_RECORD_SIZE,
321         xdr_ndmp2_mover_set_record_size_request,
322         xdr_ndmp2_mover_set_record_size_reply,
323     },
324     {0}};
325 
326 
327 /*
328  * XDR unsigned long integers
329  * same as xdr_long - open coded to save a proc call!
330  */
xdr_ndmp2_u_quad(register XDR * xdrs,ndmp2_u_quad * objp)331 bool_t xdr_ndmp2_u_quad(register XDR* xdrs, ndmp2_u_quad* objp)
332 {
333   uint32_t hi, lo;
334 
335   switch (xdrs->x_op) {
336     case XDR_DECODE:
337 #if defined(_LP64)
338       if (XDR_GETINT32(xdrs, (int32_t*)&hi) &&
339           XDR_GETINT32(xdrs, (int32_t*)&lo)) {
340 #else
341       if (XDR_GETLONG(xdrs, (long*)&hi) && XDR_GETLONG(xdrs, (long*)&lo)) {
342 #endif
343         *objp = ((uint64_t)hi << 32) | (lo & 0xffffffff);
344         return TRUE;
345       }
346       break;
347 
348     case XDR_ENCODE:
349       hi = *objp >> 32;
350       lo = *objp & 0xffffffff;
351 #if defined(_LP64)
352       return XDR_PUTINT32(xdrs, (int32_t*)&hi) &&
353              XDR_PUTINT32(xdrs, (int32_t*)&lo);
354 #else
355       return XDR_PUTLONG(xdrs, (long*)&hi) && XDR_PUTLONG(xdrs, (long*)&lo);
356 #endif
357 
358     case XDR_FREE:
359       return (TRUE);
360   }
361 
362   return (FALSE);
363 }
364 
365 #endif /* !NDMOS_OPTION_NO_NDMP2 */
366