Imported Upstream version 3.1.0
[debian/amanda] / ndmp-src / ndmp2_xmt.c
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
79
80 struct ndmp_xdr_message_table   ndmp2_xdr_message_table[] = {
81    { NDMP2_CONNECT_OPEN,
82      xdr_ndmp2_connect_open_request,
83      xdr_ndmp2_connect_open_reply,
84    },
85    { NDMP2_CONNECT_CLIENT_AUTH,
86      xdr_ndmp2_connect_client_auth_request,
87      xdr_ndmp2_connect_client_auth_reply,
88    },
89    { NDMP2_CONNECT_CLOSE,
90      xdr_ndmp2_connect_close_request,
91      xdr_ndmp2_connect_close_reply,
92    },
93    { NDMP2_CONNECT_SERVER_AUTH,
94      xdr_ndmp2_connect_server_auth_request,
95      xdr_ndmp2_connect_server_auth_reply,
96    },
97    { NDMP2_CONFIG_GET_HOST_INFO,
98      xdr_ndmp2_config_get_host_info_request,
99      xdr_ndmp2_config_get_host_info_reply,
100    },
101    { NDMP2_CONFIG_GET_BUTYPE_ATTR,
102      xdr_ndmp2_config_get_butype_attr_request,
103      xdr_ndmp2_config_get_butype_attr_reply,
104    },
105    { NDMP2_CONFIG_GET_MOVER_TYPE,
106      xdr_ndmp2_config_get_mover_type_request,
107      xdr_ndmp2_config_get_mover_type_reply,
108    },
109    { NDMP2_CONFIG_GET_AUTH_ATTR,
110      xdr_ndmp2_config_get_auth_attr_request,
111      xdr_ndmp2_config_get_auth_attr_reply,
112    },
113    { NDMP2_SCSI_OPEN,
114      xdr_ndmp2_scsi_open_request,
115      xdr_ndmp2_scsi_open_reply,
116    },
117    { NDMP2_SCSI_CLOSE,
118      xdr_ndmp2_scsi_close_request,
119      xdr_ndmp2_scsi_close_reply,
120    },
121    { NDMP2_SCSI_GET_STATE,
122      xdr_ndmp2_scsi_get_state_request,
123      xdr_ndmp2_scsi_get_state_reply,
124    },
125    { NDMP2_SCSI_SET_TARGET,
126      xdr_ndmp2_scsi_set_target_request,
127      xdr_ndmp2_scsi_set_target_reply,
128    },
129    { NDMP2_SCSI_RESET_DEVICE,
130      xdr_ndmp2_scsi_reset_device_request,
131      xdr_ndmp2_scsi_reset_device_reply,
132    },
133    { NDMP2_SCSI_RESET_BUS,
134      xdr_ndmp2_scsi_reset_bus_request,
135      xdr_ndmp2_scsi_reset_bus_reply,
136    },
137    { NDMP2_SCSI_EXECUTE_CDB,
138      xdr_ndmp2_scsi_execute_cdb_request,
139      xdr_ndmp2_scsi_execute_cdb_reply,
140    },
141    { NDMP2_TAPE_OPEN,
142      xdr_ndmp2_tape_open_request,
143      xdr_ndmp2_tape_open_reply,
144    },
145    { NDMP2_TAPE_CLOSE,
146      xdr_ndmp2_tape_close_request,
147      xdr_ndmp2_tape_close_reply,
148    },
149    { NDMP2_TAPE_GET_STATE,
150      xdr_ndmp2_tape_get_state_request,
151      xdr_ndmp2_tape_get_state_reply,
152    },
153    { NDMP2_TAPE_MTIO,
154      xdr_ndmp2_tape_mtio_request,
155      xdr_ndmp2_tape_mtio_reply,
156    },
157    { NDMP2_TAPE_WRITE,
158      xdr_ndmp2_tape_write_request,
159      xdr_ndmp2_tape_write_reply,
160    },
161    { NDMP2_TAPE_READ,
162      xdr_ndmp2_tape_read_request,
163      xdr_ndmp2_tape_read_reply,
164    },
165    { NDMP2_TAPE_EXECUTE_CDB,
166      xdr_ndmp2_tape_execute_cdb_request,
167      xdr_ndmp2_tape_execute_cdb_reply,
168    },
169    { NDMP2_DATA_GET_STATE,
170      xdr_ndmp2_data_get_state_request,
171      xdr_ndmp2_data_get_state_reply,
172    },
173    { NDMP2_DATA_START_BACKUP,
174      xdr_ndmp2_data_start_backup_request,
175      xdr_ndmp2_data_start_backup_reply,
176    },
177    { NDMP2_DATA_START_RECOVER,
178      xdr_ndmp2_data_start_recover_request,
179      xdr_ndmp2_data_start_recover_reply,
180    },
181    { NDMP2_DATA_ABORT,
182      xdr_ndmp2_data_abort_request,
183      xdr_ndmp2_data_abort_reply,
184    },
185    { NDMP2_DATA_GET_ENV,
186      xdr_ndmp2_data_get_env_request,
187      xdr_ndmp2_data_get_env_reply,
188    },
189    { NDMP2_DATA_STOP,
190      xdr_ndmp2_data_stop_request,
191      xdr_ndmp2_data_stop_reply,
192    },
193    { NDMP2_DATA_START_RECOVER_FILEHIST,
194      xdr_ndmp2_data_start_recover_filehist_request,
195      xdr_ndmp2_data_start_recover_filehist_reply,
196    },
197    { NDMP2_NOTIFY_DATA_HALTED,
198      xdr_ndmp2_notify_data_halted_request,
199      xdr_ndmp2_notify_data_halted_reply,
200    },
201    { NDMP2_NOTIFY_CONNECTED,
202      xdr_ndmp2_notify_connected_request,
203      xdr_ndmp2_notify_connected_reply,
204    },
205    { NDMP2_NOTIFY_MOVER_HALTED,
206      xdr_ndmp2_notify_mover_halted_request,
207      xdr_ndmp2_notify_mover_halted_reply,
208    },
209    { NDMP2_NOTIFY_MOVER_PAUSED,
210      xdr_ndmp2_notify_mover_paused_request,
211      xdr_ndmp2_notify_mover_paused_reply,
212    },
213    { NDMP2_NOTIFY_DATA_READ,
214      xdr_ndmp2_notify_data_read_request,
215      xdr_ndmp2_notify_data_read_reply,
216    },
217    { NDMP2_LOG_LOG,
218      xdr_ndmp2_log_log_request,
219      xdr_ndmp2_log_log_reply,
220    },
221    { NDMP2_LOG_DEBUG,
222      xdr_ndmp2_log_debug_request,
223      xdr_ndmp2_log_debug_reply,
224    },
225    { NDMP2_LOG_FILE,
226      xdr_ndmp2_log_file_request,
227      xdr_ndmp2_log_file_reply,
228    },
229    { NDMP2_FH_ADD_UNIX_PATH,
230      xdr_ndmp2_fh_add_unix_path_request,
231      xdr_ndmp2_fh_add_unix_path_reply,
232    },
233    { NDMP2_FH_ADD_UNIX_DIR,
234      xdr_ndmp2_fh_add_unix_dir_request,
235      xdr_ndmp2_fh_add_unix_dir_reply,
236    },
237    { NDMP2_FH_ADD_UNIX_NODE,
238      xdr_ndmp2_fh_add_unix_node_request,
239      xdr_ndmp2_fh_add_unix_node_reply,
240    },
241    { NDMP2_MOVER_GET_STATE,
242      xdr_ndmp2_mover_get_state_request,
243      xdr_ndmp2_mover_get_state_reply,
244    },
245    { NDMP2_MOVER_LISTEN,
246      xdr_ndmp2_mover_listen_request,
247      xdr_ndmp2_mover_listen_reply,
248    },
249    { NDMP2_MOVER_CONTINUE,
250      xdr_ndmp2_mover_continue_request,
251      xdr_ndmp2_mover_continue_reply,
252    },
253    { NDMP2_MOVER_ABORT,
254      xdr_ndmp2_mover_abort_request,
255      xdr_ndmp2_mover_abort_reply,
256    },
257    { NDMP2_MOVER_STOP,
258      xdr_ndmp2_mover_stop_request,
259      xdr_ndmp2_mover_stop_reply,
260    },
261    { NDMP2_MOVER_SET_WINDOW,
262      xdr_ndmp2_mover_set_window_request,
263      xdr_ndmp2_mover_set_window_reply,
264    },
265    { NDMP2_MOVER_READ,
266      xdr_ndmp2_mover_read_request,
267      xdr_ndmp2_mover_read_reply,
268    },
269    { NDMP2_MOVER_CLOSE,
270      xdr_ndmp2_mover_close_request,
271      xdr_ndmp2_mover_close_reply,
272    },
273    { NDMP2_MOVER_SET_RECORD_SIZE,
274      xdr_ndmp2_mover_set_record_size_request,
275      xdr_ndmp2_mover_set_record_size_reply,
276    },
277    {0}
278 };
279
280
281
282 /*
283  * XDR unsigned long integers
284  * same as xdr_long - open coded to save a proc call!
285  */
286 bool_t
287 xdr_ndmp2_u_quad(xdrs, objp)
288         register XDR *xdrs;
289         ndmp2_u_quad *objp;
290 {
291         u_long          hi, lo;
292
293         switch (xdrs->x_op) {
294         case XDR_DECODE:
295                 if (XDR_GETLONG(xdrs, (long*)&hi)
296                  && XDR_GETLONG(xdrs, (long*)&lo)) {
297                         *objp = ((unsigned long long)hi << 32) | (lo & 0xffffffff);
298                         return TRUE;
299                 }
300                 break;
301
302         case XDR_ENCODE:
303                 hi = *objp >> 32;
304                 lo = *objp;
305                 return XDR_PUTLONG(xdrs, (long*)&hi)
306                     && XDR_PUTLONG(xdrs, (long*)&lo);
307
308         case XDR_FREE:
309                 return (TRUE);
310         }
311
312         return (FALSE);
313 }
314
315 #endif /* !NDMOS_OPTION_NO_NDMP2 */