1 /*
2 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. Use is subject
3 * to license terms.
4 */
5
6 /*
7 * BSD 3 Clause License
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are
11 * met: - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * - Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 *
18 * - Neither the name of Sun Microsystems, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY SUN MICROSYSTEMS, INC. ''AS IS'' AND ANY EXPRESS
23 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35 /*
36 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
37 */
38
39 /*
40 * The Mover Interface manages the transfer of backup stream data between a
41 * data or Tape Server and the local tape subsystem. This files implements
42 * all the mover interfaces. There are four type of methods for each
43 * interface. These methods types are extract request, extract reply, print
44 * reply and compare reply.
45 */
46
47 #include<stdio.h>
48 #include<string.h>
49 #include<stdlib.h>
50
51 #include <ndmp.h>
52 #include <ndmp_comm_lib.h>
53 #include <process_hdlr_table.h>
54 #include <mover.h>
55 #include <ndmp_connect.h>
56 #include <ndmp_conv.h>
57 #include <tape_tester.h>
58 #include <data.h>
59
60 int stop_mover(FILE *, conn_handle *);
61 int stop_data(FILE *, conn_handle *);
62
63 /*
64 * ndmp_mover_listen_reply_print(): Prints the reply object.
65 *
66 * Arguments: FILE * - Handle to the log file. void *ndmpMsg - Reply object to
67 * be printed in the log file.
68 */
69 void
70 ndmp_mover_listen_reply_print(FILE * out, void *ndmpMsg)
71 {
72 ndmp_mover_listen_reply *msg;
73 msg = (ndmp_mover_listen_reply *) ndmpMsg;
74 (void) ndmp_lprintf(out, "error = %s\n",
75 ndmpErrorCodeToStr(msg->error));
76 (void) ndmp_lprintf(out, "Connection Type : ");
77 print_ndmp_addr(out, &(msg->connect_addr));
78 }
79
80 /*
81 * ndmp_mover_stop_reply_print(): Prints the reply object.
82 *
83 * Arguments: FILE * - Handle to the log file. void *ndmpMsg - Reply object to
84 * be printed in the log file.
85 */
86 void
87 ndmp_mover_stop_reply_print(FILE * out, void *ndmpMsg)
88 {
89 ndmp_mover_listen_reply *msg;
90 msg = (ndmp_mover_listen_reply *) ndmpMsg;
91 (void) ndmp_lprintf(out, "error = %s\n",
92 ndmpErrorCodeToStr(msg->error));
93 }
94
95 /*
96 * ndmp_mover_set_record_size_reply_print(): Prints the reply object.
97 *
98 * Arguments: FILE * - Handle to the log file. void *ndmpMsg - Reply object to
99 * be printed in the log file.
100 */
101 void
102 ndmp_mover_set_record_size_reply_print(FILE * out, void *ndmpMsg)
103 {
104 ndmp_mover_set_record_size_reply *msg;
105 msg = (ndmp_mover_set_record_size_reply *) ndmpMsg;
106 (void) ndmp_lprintf(out, "error = %s\n",
107 ndmpErrorCodeToStr(msg->error));
108 }
109
110 /*
111 * ndmp_mover_set_window_reply_print(): Prints the reply object.
112 *
113 * Arguments: FILE * - Handle to the log file. void *ndmpMsg - Reply object to
114 * be printed in the log file.
115 */
116 void
117 ndmp_mover_set_window_reply_print(FILE * out, void *ndmpMsg)
118 {
119 ndmp_mover_set_window_reply *msg;
120 msg = (ndmp_mover_set_window_reply *) ndmpMsg;
121 (void) ndmp_lprintf(out, "error = %s\n",
122 ndmpErrorCodeToStr(msg->error));
123 }
124
125 /*
126 * ndmp_mover_connect_reply_print(): Prints the reply object.
127 *
128 * Arguments: FILE * - Handle to the log file. void *ndmpMsg - Reply object to
129 * be printed in the log file.
130 */
131 void
132 ndmp_mover_connect_reply_print(FILE * out, void *ndmpMsg)
133 {
134 ndmp_mover_connect_reply *msg;
135 msg = (ndmp_mover_connect_reply *) ndmpMsg;
136 (void) ndmp_lprintf(out, "error = %s\n",
137 ndmpErrorCodeToStr(msg->error));
138 }
139
140 /*
141 * ndmp_mover_read_reply_print(): Prints the reply object.
142 *
143 * Arguments: FILE * - Handle to the log file. void *ndmpMsg - Reply object to
144 * be printed in the log file.
145 */
146 void
147 ndmp_mover_read_reply_print(FILE * out, void *ndmpMsg)
148 {
149 ndmp_mover_read_reply *msg;
150 msg = (ndmp_mover_read_reply *) ndmpMsg;
151 (void) ndmp_lprintf(out, "error = %s\n",
152 ndmpErrorCodeToStr(msg->error));
153 }
154
155 /*
156 * ndmp_mover_get_state_reply_print(): Prints the reply object.
157 *
158 * Arguments: FILE * - Handle to the log file. void *ndmpMsg- Reply object to be
159 * printed in the log file.
160 */
161 void
162 ndmp_mover_get_state_reply_print(FILE * out, void *ndmpMsg)
163 {
164 ndmp_mover_get_state_reply *msg;
165 char reason[30];
166 char str_ndmp_mover_state[30];
167
168 memset(reason, '\0', 30);
169 memset(str_ndmp_mover_state, '\0', 30);
170 msg = (ndmp_mover_get_state_reply *) ndmpMsg;
171 (void) ndmp_lprintf(out, "error = %s\n",
172 ndmpErrorCodeToStr(msg->error));
173 (void) ndmp_lprintf(out, "mode = %d\n", msg->mode);
174 (void) ndmp_lprintf(out, "state = %s\n",
175 ndmpMoverStateToStr(msg->state, str_ndmp_mover_state));
176 (void) ndmp_lprintf(out, "pause_reason = %s\n",
177 ndmpMoverPauseReasonToStr(msg->pause_reason, reason));
178 memset(reason, '\0', 30);
179 (void) ndmp_lprintf(out, "halt_reason = %s\n",
180 ndmpMoverHaltReasonToStr(msg->halt_reason, reason));
181 (void) ndmp_lprintf(out, "record_size = %d\n", (int) msg->record_size);
182 (void) ndmp_lprintf(out, "record_num = %d\n", (int) msg->record_num);
183 print_ndmp_u_quad(out, msg->bytes_moved);
184 print_ndmp_u_quad(out, msg->seek_position);
185 print_ndmp_u_quad(out, msg->bytes_left_to_read);
186 print_ndmp_u_quad(out, msg->window_offset);
187 print_ndmp_u_quad(out, msg->window_length);
188 print_ndmp_addr(out, &(msg->data_connection_addr));
189 }
190
191 /*
192 * ndmp_mover_continue_reply_print(): Prints the reply object.
193 *
194 * Arguments: FILE * - Handle to the log file. void *ndmpMsg- Reply object to be
195 * printed in the log file.
196 */
197 void
198 ndmp_mover_continue_reply_print(FILE * out, void *ndmpMsg)
199 {
200 ndmp_mover_continue_reply *msg;
201 msg = (ndmp_mover_continue_reply *) ndmpMsg;
202 (void) ndmp_lprintf(out, "error = %s\n",
203 ndmpErrorCodeToStr(msg->error));
204 }
205
206 /*
207 * ndmp_mover_close_reply_print(): Prints the reply object.
208 *
209 * Arguments: FILE * - Handle to the log file. void *ndmpMsg- Reply object to be
210 * printed in the log file.
211 */
212 void
213 ndmp_mover_close_reply_print(FILE * out, void *ndmpMsg)
214 {
215 ndmp_mover_close_reply *msg;
216 msg = (ndmp_mover_close_reply *) ndmpMsg;
217 (void) ndmp_lprintf(out, "error = %s\n",
218 ndmpErrorCodeToStr(msg->error));
219 }
220
221 /*
222 * ndmp_mover_abort_reply_print(): Prints the reply object.
223 *
224 * Arguments: FILE * - Handle to the log file. void *ndmpMsg- Reply object to be
225 * printed in the log file.
226 */
227 void
228 ndmp_mover_abort_reply_print(FILE * out, void *ndmpMsg)
229 {
230 ndmp_mover_abort_reply *msg;
231 msg = (ndmp_mover_abort_reply *) ndmpMsg;
232 (void) ndmp_lprintf(out, "error = %s\n",
233 ndmpErrorCodeToStr(msg->error));
234 }
235
236 /*
237 * Code for version 2.0 starts here
238 */
239 int
240 mover_set_window_core(ndmp_error error,
241 ndmp_u_quad * offset, ndmp_u_quad * length,
242 FILE * outfile, conn_handle * conn)
243 {
244 void *reply_mem = NULL;
245 ndmp_mover_set_window_request *request =
246 (ndmp_mover_set_window_request *) malloc
247 (sizeof (ndmp_mover_set_window_request));
248 if (offset != NULL) {
249 request->offset.high = offset->high;
250 request->offset.low = offset->low;
251 } else {
252 request->offset.high = 0;
253 request->offset.low = 0;
254 }
255 if (length != NULL) {
256 request->length.high = length->high;
257 request->length.low = length->low;
258 } else {
259 request->length.high = 0;
260 request->length.low = 0;
261 }
262 ndmp_lprintf(outfile, "REQUEST : NDMP_MOVER_SET_WINDOW\n");
263 if (!process_request((void *) request,
264 NDMP_MOVER_SET_WINDOW, conn, &reply_mem, outfile)) {
265 if (reply_mem != NULL && error ==
266 ((ndmp_mover_set_window_reply *) reply_mem)->error) {
267 ndmp_mover_set_window_reply_print(outfile,
268 ((ndmp_mover_set_window_reply *) reply_mem));
269 return (SUCCESS);
270 }
271 }
272 return (ERROR);
273 }
274
275 int
276 mover_set_rec_size_core(ndmp_error error, ulong_t size,
277 FILE * outfile, conn_handle * conn)
278 {
279 void *reply_mem = NULL;
280 ndmp_mover_set_record_size_request *request =
281 (ndmp_mover_set_record_size_request *)
282 malloc(sizeof (ndmp_mover_set_record_size_request));
283
284 request->len = size;
285 ndmp_lprintf(outfile, "REQUEST : NDMP_MOVER_SET_RECORD_SIZE\n");
286 if (!process_request((void *) request,
287 NDMP_MOVER_SET_RECORD_SIZE, conn, &reply_mem, outfile)) {
288 if (reply_mem != NULL && error != 0)
289 ndmp_mover_set_record_size_reply_print(outfile,
290 ((ndmp_mover_set_record_size_reply *) reply_mem));
291 return (SUCCESS);
292 }
293 return (ERROR);
294 }
295
296 int
297 mover_abort_core(ndmp_error error, FILE * outfile, conn_handle * conn)
298 {
299 void *reply_mem = NULL;
300 ndmp_lprintf(outfile, "REQUEST : NDMP_MOVER_ABORT\n");
301 if (!process_request(NULL,
302 NDMP_MOVER_ABORT, conn, &reply_mem, outfile)) {
303 if (reply_mem != NULL &&
304 error == ((ndmp_mover_abort_reply *)
305 reply_mem)->error) {
306 ndmp_mover_abort_reply_print(outfile,
307 ((ndmp_mover_abort_reply *) reply_mem));
308 return (SUCCESS);
309 }
310 }
311 return (ERROR);
312 }
313
314 int
315 mover_stop_core(ndmp_error error, FILE * outfile, conn_handle * conn)
316 {
317 void *reply_mem;
318 ndmp_lprintf(outfile, "REQUEST : NDMP_MOVER_STOP\n");
319 if (!process_request(NULL,
320 NDMP_MOVER_STOP, conn, &reply_mem, outfile)) {
321 if (reply_mem != NULL &&
322 error == ((ndmp_mover_stop_reply *) reply_mem)->error) {
323 ndmp_mover_stop_reply_print(outfile,
324 ((ndmp_mover_stop_reply *) reply_mem));
325 return (SUCCESS);
326 }
327 }
328 return (ERROR);
329 }
330
331 int
332 mover_listen_core(ndmp_error error,
333 ndmp_mover_mode mode, ndmp_addr_type addr_type,
334 void **tcpObj, FILE * outfile, conn_handle * conn)
335 {
336 void *obj = NULL;
337 ndmp_mover_listen_reply *reply_mem = NULL;
338 ndmp_mover_listen_request *request = NULL;
339 /*
340 * Create and print the object start
341 */
342 request = (ndmp_mover_listen_request *)
343 malloc(sizeof (ndmp_mover_listen_request));
344 request->mode = mode;
345 request->addr_type = addr_type;
346
347 switch (request->mode) {
348 case NDMP_MOVER_MODE_READ:
349 ndmp_lprintf(outfile, "Mode : NDMP_MOVER_MODE_READ\n");
350 break;
351 case NDMP_MOVER_MODE_WRITE:
352 ndmp_lprintf(outfile, "Mode : NDMP_MOVER_MODE_WRITE\n");
353 break;
354 case NDMP_MOVER_MODE_NOACTION:
355 ndmp_lprintf(outfile, "Mode : NDMP_MOVER_MODE_NOACTION\n");
356 break;
357 default:
358 ndmp_lprintf(outfile, "Unknown mode\n");
359 if (error != NDMP_ILLEGAL_ARGS_ERR)
360 return (1);
361
362 }
363 switch (request->addr_type) {
364 case NDMP_ADDR_LOCAL:
365 ndmp_lprintf(outfile, "Connection type : NDMP_ADDR_LOCAL\n");
366 break;
367 case NDMP_ADDR_TCP:
368 ndmp_lprintf(outfile, "Connection type : NDMP_ADDR_TCP\n");
369 break;
370 case NDMP_ADDR_IPC:
371 ndmp_lprintf(outfile, "Connection type : NDMP_ADDR_IPC\n");
372 break;
373 default:
374 ndmp_lprintf(outfile, "Connection type : Unknown \n");
375 if (error != NDMP_ILLEGAL_ARGS_ERR)
376 return (1);
377 }
378 ndmp_lprintf(outfile, "REQUEST : NDMP_MOVER_LISTEN\n");
379 if (!process_request((void *) request, NDMP_MOVER_LISTEN,
380 conn, (void *) &reply_mem, outfile)) {
381 if (reply_mem != NULL &&
382 error == ((ndmp_mover_listen_reply *)
383 reply_mem)->error) {
384 ndmp_mover_listen_reply_print(outfile,
385 ((ndmp_mover_listen_reply *) reply_mem));
386 if (addr_type == NDMP_ADDR_TCP) {
387 obj = &(reply_mem->connect_addr);
388 tcpObj = &obj;
389 }
390 return (SUCCESS);
391 }
392 }
393 return (ERROR);
394 }
395
396 /*
397 * mover_continue_core() : This request is used by the DMA to instruct the
398 * mover to transition from the PAUSED state to the ACTIVE state and to
399 * resume the transfer of data stream between the data connection and the
400 * tape subsystem.
401 *
402 * Arguments : ndmp_error - Error message. FILE * - handle to log file.
403 * Connection * - Connection handle. Returns : int - 0 for success and 1 for
404 * failure.
405 */
406 int
407 mover_continue_core(ndmp_error error, FILE * outfile, conn_handle * conn)
408 {
409 void *reply_mem = NULL;
410 ndmp_lprintf(outfile, "REQUEST : NDMP_MOVER_CONTINUE\n");
411 if (!process_request(NULL, NDMP_MOVER_CONTINUE,
412 conn, &reply_mem, outfile)) {
413 if (reply_mem != NULL &&
414 error == ((ndmp_mover_continue_reply *)
415 reply_mem)->error) {
416 ndmp_mover_continue_reply_print(outfile,
417 ((ndmp_mover_continue_reply *) reply_mem));
418 return (SUCCESS);
419 }
420 }
421 return (ERROR);
422 }
423
424 /*
425 * mover_close_core() : This request is used by the DMA to instruct the mover
426 * to gracefully close the current data connection and transition to the
427 * HALTED state.
428 *
429 * Arguments : ndmp_error - Error message. FILE * - handle to log file.
430 * Connection * - Connection handle. Returns : int - 0 for success and 1 for
431 * failure.
432 */
433 int
434 mover_close_core(ndmp_error error, FILE * outfile, conn_handle * conn)
435 {
436 void *reply_mem = NULL;
437 ndmp_lprintf(outfile, "REQUEST : NDMP_MOVER_CLOSE\n");
438 if (!process_request(NULL, NDMP_MOVER_CLOSE,
439 conn, &reply_mem, outfile)) {
440 if (reply_mem != NULL &&
441 error == ((ndmp_mover_close_reply *)
442 reply_mem)->error) {
443 ndmp_mover_close_reply_print(outfile,
444 ((ndmp_mover_close_reply *) reply_mem));
445 return (SUCCESS);
446 }
447 }
448 return (ERROR);
449 }
450
451 /*
452 * mover_connect_core() : This request is used by the DMA to instruct the
453 * mover to establish a data connection to a Data Server or peer mover. A
454 * connect request is only valid when the mover is in the IDLE state and
455 * requires the tape drive to be opened. A successful connect request causes
456 * the mover to transition to the ACTIVE state.
457 *
458 * Arguments : ndmp_error - Error message. FILE * - handle to log file.
459 * Connection * - Connection handle. Returns : int - 0 for success and 1 for
460 * failure.
461 */
462 int
463 mover_connect_core(ndmp_error error, ndmp_mover_mode mode,
464 ndmp_addr_type addr_type, ndmp_addr * addr,
465 FILE * outfile, conn_handle * conn)
466 {
467 void *reply_mem;
468 ndmp_mover_connect_request *request = NULL;
469 request = (ndmp_mover_connect_request *)
470 malloc(sizeof (ndmp_mover_connect_request));
471 if (error == NDMP_ILLEGAL_ARGS_ERR)
472 request->mode = 3;
473 else
474 request->mode = mode;
475 request->addr.addr_type = addr_type;
476 (void) ndmp_dprintf(outfile,
477 "mover_connect_core: tcp obj 0x%x\n", addr);
478 if (addr_type == NDMP_ADDR_TCP) {
479 if (addr != NULL)
480 request->addr = *addr;
481 else {
482 ndmp_dprintf(outfile,
483 "mover_connect_core send failed\n");
484 return (1);
485 }
486 }
487 ndmp_lprintf(outfile, "REQUEST : NDMP_MOVER_CONNECT\n");
488 if (!process_request((void *) request,
489 NDMP_MOVER_CONNECT, conn, &reply_mem, outfile)) {
490 if (reply_mem != NULL &&
491 error == ((ndmp_mover_connect_reply *)
492 reply_mem)->error) {
493 ndmp_mover_connect_reply_print(outfile,
494 ((ndmp_mover_connect_reply *) reply_mem));
495 return (SUCCESS);
496 }
497 }
498 return (ERROR);
499 }
500
501 /*
502 * get_mover_state - sends the NDMP_MOVER_GET_STATE request and returns the
503 * state of the mover machine Arguments : outfile : Log file handle conn
504 * : Pointer to the connection handle Returns : ndmp_mover_state
505 */
506 ndmp_mover_state
507 get_mover_state(FILE * logfile, conn_handle * conn)
508 {
509 ndmp_message ndmpMessage = NDMP_MOVER_GET_STATE;
510 void *reply_mem = NULL;
511 int ret;
512 /* send the request start */
513 ret = process_request(NULL,
514 ndmpMessage, conn, &reply_mem, logfile);
515 /* This code is for the server NDMP_NOT_AUTHORIZED_ERR bug. */
516 if (ret == E_MALFORMED_PACKET)
517 return (ret);
518 /* Extract ndmp_mover_state from reply and return */
519 if (reply_mem == NULL) {
520 return (ERROR);
521 } else {
522 ndmp_mover_get_state_reply *resultMsg;
523 resultMsg = (ndmp_mover_get_state_reply *) reply_mem;
524 return (resultMsg->state);
525 }
526 }
527
528 /*
529 * mover_get_state_core() : This request is used by the DMA to obtain
530 * information about the Mover's operational state as represented by the
531 * standard mover variable set.
532 *
533 * Arguments : ndmp_error - Error message. FILE * - handle to log file.
534 * Connection * - Connection handle. Returns : int - 0 for success and 1 for
535 * failure.
536 */
537 int
538 mover_get_state_core(ndmp_error error, FILE * outfile, conn_handle * conn)
539 {
540 void *reply_mem = NULL;
541 ndmp_mover_connect_request *request = NULL;
542 ndmp_lprintf(outfile, "REQUEST : NDMP_MOVER_GET_STATE\n");
543 if (!process_request((void *) request, NDMP_MOVER_GET_STATE,
544 conn, &reply_mem, outfile)) {
545 if (reply_mem != NULL &&
546 error == ((ndmp_mover_get_state_reply *)
547 reply_mem)->error) {
548 ndmp_mover_get_state_reply_print(outfile,
549 ((ndmp_mover_get_state_reply *) reply_mem));
550 return (SUCCESS);
551 }
552 }
553 return (ERROR);
554 }
555
556 /*
557 * mover_mode_read_core() : This request is used to instruct the mover to
558 * begin transferring the specified backup stream segment from the tape
559 * subsystem to the data connection. The mover MUST be in the ACTIVE state to
560 * accept and process a mover read request. Multiple outstanding read
561 * requests are not allowed
562 *
563 * Arguments : ndmp_error - Error message. FILE * - handle to log file.
564 * Connection * - Connection handle. Returns : int - 0 for success and 1 for
565 * failure.
566 */
567 int
568 mover_read_core(ndmp_error error, FILE * outfile, conn_handle * conn)
569 {
570 void *reply_mem = NULL;
571 ndmp_mover_read_request *request = (ndmp_mover_read_request *)
572 malloc(sizeof (ndmp_mover_read_request));
573 request->offset.high = 0;
574 request->offset.low = 0;
575 request->length.high = 0;
576 request->length.low = STD_REC_SIZE;
577 if (error == NDMP_ILLEGAL_ARGS_ERR) {
578 request->offset.high = 0;
579 request->offset.low = 0;
580 request->length.high = 0;
581 request->length.low = 0;
582 }
583 ndmp_lprintf(outfile, "REQUEST : NDMP_MOVER_READ\n");
584 if (!process_request((void *) request, NDMP_MOVER_READ,
585 conn, &reply_mem, outfile)) {
586 if (reply_mem != NULL &&
587 error == ((ndmp_mover_read_reply *)
588 reply_mem)->error) {
589 ndmp_mover_read_reply_print(outfile,
590 ((ndmp_mover_read_reply *) reply_mem));
591 return (SUCCESS);
592 }
593 }
594 return (ERROR);
595 }
596
597 /*
598 * Initialize and cleanup methods start from here.
599 */
600
601 /*
602 * mover_set_rec_size_intl() : Initialize the server before calling the mover
603 * set record size request.
604 *
605 * Arguemnts : ndmp_error - Error message expected. char * - Tape device name.
606 * FILE * - Handle to log file. Connection * - Handle to connection object.
607 * Returns : int - O for success and 1 for failure.
608 */
609 static int
610 mover_set_rec_size_intl(ndmp_error error, char *tape_dev,
611 FILE * outfile, conn_handle * conn)
612 {
613 ndmp_u_quad ndmpUQuadObj;
614 int ret = 0;
615 ret += tape_open_core(NDMP_NO_ERR,
616 tape_dev, "NDMP_TAPE_RDWR_MODE", outfile, conn);
617
618 /* Return if the error is not NDMP_ILLEGAL_ARGS_ERR */
619 if (error != NDMP_ILLEGAL_STATE_ERR)
620 return (ret);
621
622 ret += mover_set_rec_size_core(NDMP_NO_ERR,
623 STD_REC_SIZE, outfile, conn);
624 ndmpUQuadObj.high = 0;
625 ndmpUQuadObj.low = STD_WIN_SIZE;
626 ret += mover_set_window_core(NDMP_NO_ERR,
627 NULL, &ndmpUQuadObj, outfile, conn);
628
629 ret += mover_listen_core(NDMP_NO_ERR,
630 NDMP_MOVER_MODE_WRITE, NDMP_ADDR_LOCAL, NULL, outfile, conn);
631 return (ret);
632 }
633
634 /*
635 * mover_set_rec_size_cleanup() : Cleanup the server after calling the mover
636 * set record size request.
637 *
638 * Arguemnts : ndmp_error - Error message expected. FILE * - Handle to log file.
639 * Connection * - Handle to connection object. Returns : int - O for success
640 * and 1 for failure.
641 */
642 static int
643 mover_set_rec_size_cleanup(ndmp_error error, FILE * outfile, conn_handle * conn)
644 {
645 int ret = 0;
646 if (error == NDMP_ILLEGAL_STATE_ERR) {
647 ret += stop_mover(outfile, conn);
648 }
649 ret += tape_close_core(NDMP_NO_ERR, outfile, conn);
650 return (ret);
651 }
652
653 /*
654 * mover_set_window_size_intl() : Initialize the server before calling the
655 * mover set window size request.
656 *
657 * Arguemnts : ndmp_error - Error message expected. char * - Tape device name.
658 * FILE * - Handle to log file. Connection * - Handle to connection object.
659 * Returns : int - O for success and 1 for failure.
660 */
661 static int
662 mover_set_window_size_intl(ndmp_error error, char *tape_dev,
663 FILE * outfile, conn_handle * conn)
664 {
665 int ret = 0;
666 ret += tape_open_core(NDMP_NO_ERR,
667 tape_dev, "NDMP_TAPE_RDWR_MODE", outfile, conn);
668 if (error != NDMP_PRECONDITION_ERR)
669 ret += mover_set_rec_size_core(NDMP_NO_ERR,
670 STD_REC_SIZE, outfile, conn);
671 else
672 ret += mover_set_rec_size_core(NDMP_NO_ERR,
673 -1, outfile, conn);
674
675 /* Return if the error is not NDMP_ILLEGAL_ARGS_ERR */
676 if (error != NDMP_ILLEGAL_STATE_ERR)
677 return (ret);
678
679 ret += mover_listen_core(NDMP_NO_ERR, NDMP_MOVER_MODE_WRITE,
680 NDMP_ADDR_LOCAL, NULL, outfile, conn);
681 ret += data_connect_core(NDMP_NO_ERR, NDMP_ADDR_LOCAL,
682 NULL, outfile, conn);
683 return (ret);
684 }
685
686 /*
687 * mover_set_window_size_cleanup() : Cleanup the server after calling the
688 * mover set window size request.
689 *
690 * Arguemnts : ndmp_error - Error message expected. FILE * - Handle to log file.
691 * Connection * - Handle to connection object. Returns : int - O for success
692 * and 1 for failure.
693 */
694 static int
695 mover_set_window_size_cleanup(ndmp_error error,
696 FILE * outfile, conn_handle * conn)
697 {
698 int ret = 0;
699 if (error == NDMP_ILLEGAL_STATE_ERR) {
700 ret = stop_data(outfile, conn);
701 ret += stop_mover(outfile, conn);
702 }
703 ret += tape_close_core(NDMP_NO_ERR, outfile, conn);
704
705 return (ret);
706 }
707
708 /*
709 * mover_connect_intl() : Initialize the server before calling the mover
710 * connect request.
711 *
712 * Arguemnts : ndmp_error - Error message expected. char * - Tape device name.
713 * FILE * - Handle to log file. Connection * - Handle to connection object.
714 * Returns : int - O for success and 1 for failure.
715 */
716 static int
717 mover_connect_intl(ndmp_error error, char *tape_dev,
718 ndmp_addr_type addr_type, ndmp_addr ** tcp_obj,
719 FILE * outfile, conn_handle * conn)
720 {
721 ndmp_u_quad ndmpUQuadObj;
722 int ret = 0;
723 if (error == NDMP_DEV_NOT_OPEN_ERR)
724 return (ret);
725 if (error == NDMP_PERMISSION_ERR)
726 ret += tape_open_core(NDMP_NO_ERR,
727 tape_dev, "NDMP_TAPE_READ_MODE", outfile, conn);
728 else
729 ret += tape_open_core(NDMP_NO_ERR,
730 tape_dev, "NDMP_TAPE_RDWR_MODE", outfile, conn);
731
732 if (error != NDMP_PRECONDITION_ERR) {
733 ret += mover_set_rec_size_core(NDMP_NO_ERR,
734 STD_REC_SIZE, outfile, conn);
735 } else {
736 ret += mover_set_rec_size_core(NDMP_NO_ERR,
737 30, outfile, conn);
738 }
739 ndmpUQuadObj.high = 0;
740 if (error != NDMP_PRECONDITION_ERR) {
741 ndmpUQuadObj.low = STD_WIN_SIZE;
742 ret += mover_set_window_core(NDMP_NO_ERR,
743 NULL, &ndmpUQuadObj, outfile, conn);
744 } else {
745 ndmpUQuadObj.low = 31;
746 ret += mover_set_window_core(NDMP_NO_ERR,
747 NULL, &ndmpUQuadObj, outfile, conn);
748 }
749
750 if (error == NDMP_ILLEGAL_STATE_ERR)
751 return (ret);
752 if (addr_type != NDMP_ADDR_TCP) {
753 ndmp_dprintf(outfile,
754 "mover_connect_intl: "
755 "NDMP_ADDR_LOCAL 0x%x\n", addr_type);
756 ret += data_listen_core(NDMP_NO_ERR,
757 NDMP_ADDR_LOCAL, NULL, outfile, conn);
758 } else {
759 ret += data_listen_core(NDMP_NO_ERR,
760 NDMP_ADDR_TCP, tcp_obj, outfile, conn);
761 ndmp_dprintf(outfile,
762 "mover_connect_intl: "
763 "NDMP_ADDR_TCP tcp obj 0x%x\n", *tcp_obj);
764 }
765
766 return (ret);
767 }
768
769 /*
770 * mover_connect_cleanup() : Cleanup the server after calling the mover
771 * connect request.
772 *
773 * Arguemnts : ndmp_error - Error message expected. FILE * - Handle to log file.
774 * Connection * - Handle to connection object. Returns : int - O for success
775 * and 1 for failure.
776 */
777 static int
778 mover_connect_cleanup(ndmp_error error, FILE * outfile, conn_handle * conn)
779 {
780 int ret = 0;
781 if (error != NDMP_ILLEGAL_STATE_ERR) {
782 ret = stop_data(outfile, conn);
783 ret += stop_mover(outfile, conn);
784 }
785 ret += tape_close_core(NDMP_NO_ERR, outfile, conn);
786
787 return (ret);
788 }
789
790 /*
791 * mover_listen_intl() : Initialize the server before calling the mover
792 * listen request.
793 *
794 * Arguemnts : ndmp_error - Error message expected. char * - Tape device name.
795 * FILE * - Handle to log file. Connection * - Handle to connection object.
796 * Returns : int - O for success and 1 for failure.
797 */
798 static int
799 mover_listen_intl(ndmp_error error, char *tape_dev,
800 FILE * outfile, conn_handle * conn)
801 {
802 ndmp_u_quad ndmpUQuadObj;
803 int ret = 0;
804 ndmp_dprintf(outfile,
805 "mover_listen_intl : "
806 "start, line -> %d\n", __LINE__);
807 if (error == NDMP_DEV_NOT_OPEN_ERR) {
808 ndmp_dprintf(outfile,
809 "mover_listen_intl: line -> %d\n", __LINE__);
810 return (ret);
811 }
812 ret = tape_open_core(NDMP_NO_ERR, tape_dev,
813 "NDMP_TAPE_RDWR_MODE", outfile, conn);
814 ndmp_dprintf(outfile, "mover_listen_intl: line -> %d\n", __LINE__);
815 if (error == NDMP_PRECONDITION_ERR || error == NDMP_PERMISSION_ERR)
816 return (ret);
817 ret += mover_set_rec_size_core(NDMP_NO_ERR,
818 STD_REC_SIZE, outfile, conn);
819
820 ndmpUQuadObj.high = 0;
821 ndmpUQuadObj.low = STD_WIN_SIZE;
822 ret += mover_set_window_core(NDMP_NO_ERR,
823 NULL, &ndmpUQuadObj, outfile, conn);
824 ndmp_dprintf(outfile,
825 "mover_listen_intl : "
826 "line -> %d, ret -> %d\n", __LINE__, ret);
827
828 return (ret);
829 }
830
831 /*
832 * mover_listen_cleanup() : Cleanup the server after calling the mover listen
833 * request.
834 *
835 * Arguemnts : ndmp_error - Error message expected. FILE * - Handle to log file.
836 * Connection * - Handle to connection object. Returns : int - O for success
837 * and 1 for failure.
838 */
839 static int
840 mover_listen_cleanup(ndmp_error error, FILE * outfile, conn_handle * conn)
841 {
842 int ret = 0;
843 if (error != NDMP_ILLEGAL_STATE_ERR) {
844 ret += stop_mover(outfile, conn);
845 }
846 ret += tape_close_core(NDMP_NO_ERR, outfile, conn);
847
848 return (ret);
849 }
850
851 /*
852 * mover_read_intl() : Initialize the server before calling the mover read
853 * request.
854 *
855 * Arguemnts : ndmp_error - Error message expected. char * - Tape device name.
856 * FILE * - Handle to log file. Connection * - Handle to connection object.
857 * Returns : int - O for success and 1 for failure.
858 */
859 static int
860 mover_read_intl(ndmp_error error, char *tape_dev,
861 FILE * outfile, conn_handle * conn)
862 {
863 ndmp_u_quad ndmpUQuadObj;
864 int ret = 0;
865 if (error == NDMP_ILLEGAL_STATE_ERR)
866 return (ret);
867 ret += tape_open_core(NDMP_NO_ERR,
868 tape_dev, "NDMP_TAPE_RDWR_MODE", outfile, conn);
869 ret += mover_set_rec_size_core(NDMP_NO_ERR,
870 STD_REC_SIZE, outfile, conn);
871
872 ndmpUQuadObj.high = 0;
873 ndmpUQuadObj.low += STD_WIN_SIZE;
874 ret += mover_set_window_core(NDMP_NO_ERR,
875 NULL, &ndmpUQuadObj, outfile, conn);
876 ret += data_listen_core(NDMP_NO_ERR,
877 NDMP_ADDR_LOCAL, NULL, outfile, conn);
878 ret += mover_connect_core(NDMP_NO_ERR,
879 NDMP_MOVER_MODE_WRITE, NDMP_ADDR_LOCAL,
880 NULL, outfile, conn);
881
882 return (ret);
883 }
884
885 /*
886 * mover_read_cleanup() : Cleanup the server after calling the mover read
887 * request.
888 *
889 * Arguemnts : ndmp_error - Error message expected. FILE * - Handle to log file.
890 * Connection * - Handle to connection object. Returns : int - O for success
891 * and 1 for failure.
892 */
893 static int
894 mover_read_cleanup(ndmp_error error, FILE * outfile, conn_handle * conn)
895 {
896 int ret = 0;
897 if (error != NDMP_ILLEGAL_STATE_ERR) {
898 ret = stop_data(outfile, conn);
899 ret += stop_mover(outfile, conn);
900 }
901 ret += tape_close_core(NDMP_NO_ERR, outfile, conn);
902
903 return (ret);
904 }
905
906 /*
907 * mover_continue_intl() : Initialize the server before calling the mover
908 * continue request.
909 *
910 * Arguemnts : ndmp_error - Error message expected. char * - Tape device name.
911 * FILE * - Handle to log file. Connection * - Handle to connection object.
912 * Returns : int - O for success and 1 for failure.
913 */
914 static int
915 mover_continue_intl(ndmp_error error, char *tape_dev,
916 char *absBckDirPath, FILE * outfile, conn_handle * conn)
917 {
918 ndmp_u_quad ndmpUQuadObj;
919 int ret = 0;
920 if (error == NDMP_ILLEGAL_STATE_ERR)
921 return (ret);
922 ret += tape_open_core(NDMP_NO_ERR,
923 tape_dev, "NDMP_TAPE_RDWR_MODE", outfile, conn);
924 ret += mover_set_rec_size_core(NDMP_NO_ERR,
925 STD_REC_SIZE, outfile, conn);
926 ndmpUQuadObj.high = 0;
927 ndmpUQuadObj.low = 1;
928 ret += mover_set_window_core(NDMP_NO_ERR,
929 NULL, &ndmpUQuadObj, outfile, conn);
930 ret += mover_listen_core(NDMP_NO_ERR,
931 NDMP_MOVER_MODE_READ, NDMP_ADDR_LOCAL, NULL, outfile, conn);
932 ret += data_connect_core(NDMP_NO_ERR,
933 NDMP_ADDR_LOCAL, NULL, outfile, conn);
934 ret += data_start_backup_core(NDMP_NO_ERR,
935 absBckDirPath, NULL, outfile, conn);
936 /*
937 * Default timeout value is 5 secs.
938 */
939 if (error != NDMP_NOT_AUTHORIZED_ERR) {
940 /*
941 * Temporarily commented this code on 2nd Feb 2009. Instead
942 * of this method we need to use process_notfication method
943 */
944 notify_qrec *list = NULL;
945 ret = process_notification(conn,
946 NDMP_NOTIFY_MOVER_PAUSED, &list, outfile);
947 }
948 ndmpUQuadObj.high = 0;
949 if (error == NDMP_PRECONDITION_ERR) {
950 ndmpUQuadObj.low = 0;
951 mover_set_window_core(NDMP_NO_ERR,
952 NULL, &ndmpUQuadObj, outfile, conn);
953 } else {
954 ndmpUQuadObj.low = STD_WIN_SIZE;
955 ret += mover_set_window_core(NDMP_NO_ERR,
956 NULL, &ndmpUQuadObj, outfile, conn);
957 }
958 return (ret);
959 }
960
961 /*
962 * mover_continue_cleanup() : Cleanup the server after calling the mover
963 * continue request.
964 *
965 * Arguemnts : ndmp_error - Error message expected. FILE * - Handle to log file.
966 * Connection * - Handle to connection object. Returns : int - O for success
967 * and 1 for failure.
968 */
969 static int
970 mover_continue_cleanup(ndmp_error error, FILE * outfile, conn_handle * conn)
971 {
972 int ret = 0;
973 if (error != NDMP_ILLEGAL_STATE_ERR) {
974 ret = stop_data(outfile, conn);
975 ret += stop_mover(outfile, conn);
976 ret += tape_close_core(NDMP_NO_ERR, outfile, conn);
977 }
978 return (ret);
979 }
980
981 /*
982 * mover_close_intl() : Initialize the server before calling the mover close
983 * request.
984 *
985 * Arguemnts : ndmp_error - Error message expected. char * - Tape device name.
986 * FILE * - Handle to log file. Connection * - Handle to connection object.
987 * Returns : int - O for success and 1 for failure.
988 */
989 int
990 mover_close_intl(ndmp_error error, char *tape_dev,
991 char *absBckDirPath, FILE * outfile, conn_handle * conn)
992 {
993 ndmp_u_quad ndmpUQuadObj;
994 int ret = 0;
995 if (error == NDMP_ILLEGAL_STATE_ERR)
996 return (ret);
997 ret += tape_open_core(NDMP_NO_ERR,
998 tape_dev, "NDMP_TAPE_RDWR_MODE", outfile, conn);
999 ret += mover_set_rec_size_core(NDMP_NO_ERR,
1000 STD_REC_SIZE, outfile, conn);
1001
1002 ndmpUQuadObj.high = 0;
1003 ndmpUQuadObj.low = 1;
1004 ret += mover_set_window_core(NDMP_NO_ERR,
1005 NULL, &ndmpUQuadObj, outfile, conn);
1006
1007 ret += mover_listen_core(NDMP_NO_ERR,
1008 NDMP_MOVER_MODE_READ, NDMP_ADDR_LOCAL, NULL, outfile, conn);
1009 ret += data_connect_core(NDMP_NO_ERR,
1010 NDMP_ADDR_LOCAL, NULL, outfile, conn);
1011 ret += data_start_backup_core(NDMP_NO_ERR,
1012 absBckDirPath, NULL, outfile, conn);
1013 /*
1014 * Default timeout value is 5 secs.
1015 */
1016 if (error != NDMP_NOT_AUTHORIZED_ERR) {
1017 /*
1018 * Temporarily commented this code on 2nd Feb 2009. Instead
1019 * of this method we need to use process_notfication method
1020 */
1021 notify_qrec *list = NULL;
1022 ret = process_notification(conn,
1023 NDMP_NOTIFY_MOVER_PAUSED, &list, outfile);
1024 }
1025 return (ret);
1026 }
1027
1028 /*
1029 * mover_close_cleanup() : Cleanup the server after calling the mover close
1030 * request.
1031 *
1032 * Arguemnts : ndmp_error - Error message expected. FILE * - Handle to log file.
1033 * Connection * - Handle to connection object. Returns : int - O for success
1034 * and 1 for failure.
1035 */
1036 static int
1037 mover_close_cleanup(ndmp_error error, FILE * outfile, conn_handle * conn)
1038 {
1039 int ret = 0;
1040 if (error != NDMP_ILLEGAL_STATE_ERR) {
1041 ret = stop_data(outfile, conn);
1042 ret += stop_mover(outfile, conn);
1043 }
1044 ret += tape_close_core(NDMP_NO_ERR, outfile, conn);
1045
1046 return (ret);
1047 }
1048
1049 /*
1050 * mover_stop_intl() : Initialize the server before calling the mover stop
1051 * request.
1052 *
1053 * Arguemnts : ndmp_error - Error message expected. char * - Tape device name.
1054 * FILE * - Handle to log file. Connection * - Handle to connection object.
1055 * Returns : int - O for success and 1 for failure.
1056 */
1057 static int
1058 mover_stop_intl(ndmp_error error, char *tape_dev,
1059 FILE * outfile, conn_handle * conn)
1060 {
1061 ndmp_u_quad ndmpUQuadObj;
1062 int ret = 0;
1063 if (error == NDMP_ILLEGAL_STATE_ERR)
1064 return (ret);
1065 ret += tape_open_core(NDMP_NO_ERR,
1066 tape_dev, "NDMP_TAPE_RDWR_MODE", outfile, conn);
1067 ret += mover_set_rec_size_core(NDMP_NO_ERR,
1068 STD_REC_SIZE, outfile, conn);
1069
1070 ndmpUQuadObj.high = 0;
1071 ndmpUQuadObj.low = STD_WIN_SIZE;
1072 ret += mover_set_window_core(NDMP_NO_ERR,
1073 NULL, &ndmpUQuadObj, outfile, conn);
1074
1075 ret += mover_listen_core(NDMP_NO_ERR,
1076 NDMP_MOVER_MODE_READ, NDMP_ADDR_LOCAL, NULL, outfile, conn);
1077
1078 ret += mover_abort_core(NDMP_NO_ERR, outfile, conn);
1079
1080 return (ret);
1081 }
1082
1083 /*
1084 * mover_stop_cleanup() : Cleanup the server after calling the mover abort
1085 * request.
1086 *
1087 * Arguemnts : ndmp_error - Error message expected. FILE * - Handle to log file.
1088 * Connection * - Handle to connection object. Returns : int - O for success
1089 * and 1 for failure.
1090 */
1091 static int
1092 mover_stop_cleanup(ndmp_error error, FILE * outfile, conn_handle * conn)
1093 {
1094 int ret = 0;
1095 if (error != NDMP_ILLEGAL_STATE_ERR) {
1096 ret += tape_close_core(NDMP_NO_ERR, outfile, conn);
1097 }
1098 return (ret);
1099 }
1100
1101 /*
1102 * mover_abort_intl() : Initialize the server before calling the mover abort
1103 * request.
1104 *
1105 * Arguemnts : ndmp_error - Error message expected. char * - Tape device name.
1106 * FILE * - Handle to log file. Connection * - Handle to connection object.
1107 * Returns : int - O for success and 1 for failure.
1108 */
1109 int
1110 mover_abort_intl(ndmp_error error, char *tape_dev,
1111 FILE * outfile, conn_handle * conn)
1112 {
1113 ndmp_u_quad ndmpUQuadObj;
1114 int ret = 0;
1115 if (error == NDMP_ILLEGAL_STATE_ERR)
1116 return (ret);
1117 ret += tape_open_core(NDMP_NO_ERR,
1118 tape_dev, "NDMP_TAPE_RDWR_MODE", outfile, conn);
1119 ret += mover_set_rec_size_core(NDMP_NO_ERR,
1120 STD_REC_SIZE, outfile, conn);
1121
1122 ndmpUQuadObj.high = 0;
1123 ndmpUQuadObj.low = STD_WIN_SIZE;
1124 ret += mover_set_window_core(NDMP_NO_ERR,
1125 NULL, &ndmpUQuadObj, outfile, conn);
1126
1127 ret += mover_listen_core(NDMP_NO_ERR,
1128 NDMP_MOVER_MODE_READ, NDMP_ADDR_LOCAL, NULL, outfile, conn);
1129
1130 return (ret);
1131 }
1132
1133 /*
1134 * mover_abort_cleanup() : Cleanup the server after calling the mover abort
1135 * request.
1136 *
1137 * Arguemnts : ndmp_error - Error message expected. FILE * - Handle to log file.
1138 * Connection * - Handle to connection object. Returns : int - O for success
1139 * and 1 for failure.
1140 */
1141 static int
1142 mover_abort_cleanup(ndmp_error error, FILE * outfile, conn_handle * conn)
1143 {
1144 int ret = 0;
1145 if (error != NDMP_ILLEGAL_STATE_ERR) {
1146 ret = stop_mover(outfile, conn);
1147 }
1148 return (ret);
1149 }
1150 /*
1151 * Interface methods start here.
1152 */
1153
1154 /*
1155 * inf_mover_set_rec_size() : Executes all the steps in the test case. First
1156 * calls the initialize methods to set the test bed. Then sends the actual
1157 * request. Finally does the cleanup.
1158 *
1159 * Arguments :
1160 * ndmp_error - Error condition to test.
1161 * FILE * - Log file handle.
1162 * char * - Tape device.
1163 * char * - Record size.
1164 * conn_handle * - Connection object handle.
1165 * Return :
1166 * int - 0 for success and 1 for failure.
1167 */
1168 int
1169 inf_mover_set_rec_size(ndmp_error error, char *tape_dev,
1170 char *rec_size, FILE * outfile, conn_handle * conn)
1171 {
1172 int ret = 0, res = 0;
1173 long recSize;
1174 if (rec_size != NULL) {
1175 recSize = atol(rec_size);
1176 ndmp_dprintf(outfile,
1177 "inf_mover_set_rec_size: "
1178 "rec_size is %s %lu\n", rec_size, recSize);
1179 } else {
1180 recSize = 8192;
1181 ndmp_lprintf(outfile,
1182 "Record size is NULL, "
1183 "so setting it to" "8192\n");
1184 }
1185 (void) ndmp_fprintf(outfile,
1186 "Test case name : ndmp_mover_set_record_size\n");
1187 (void) ndmp_fprintf(outfile,
1188 "Error condition : %s\n", ndmpErrorCodeToStr(error));
1189
1190 ret = mover_set_rec_size_intl(error, tape_dev, outfile, conn);
1191 print_intl_result(ret, outfile);
1192
1193 res = mover_set_rec_size_core(error, recSize, outfile, conn);
1194 print_test_result(res, outfile);
1195
1196 ret = mover_set_rec_size_cleanup(error, outfile, conn);
1197 print_cleanup_result(ret, outfile);
1198 return (res);
1199 }
1200
1201 /*
1202 * inf_mover_set_window_size() :
1203 * This request establishes a mover window in
1204 * terms of offset and length. A mover window represents the portion of the
1205 * overall backup stream that is accessible to the mover without intervening
1206 * DMA tape manipulation.
1207 *
1208 * Executes all the steps in the test case. First calls the initialize methods
1209 * to set the test bed. Then sends the actual request. Finally does the
1210 * cleanup.
1211 *
1212 * Arguments :
1213 * ndmp_error - Error condition to test.
1214 * FILE * - Log file handle.
1215 * conn_handle * - Connection object handle.
1216 * Return :
1217 * int - 0 for success and 1 for failure.
1218 */
1219 int
1220 inf_mover_set_window_size(ndmp_error error,
1221 char *tape_dev, char *win_size, FILE * outfile, conn_handle * conn)
1222 {
1223 ndmp_u_quad ndmpUQuadObj;
1224 int ret = 0, res = 0;
1225 int winSize;
1226
1227 if (win_size != NULL)
1228 winSize = atol(win_size);
1229 else {
1230 winSize = 8192000;
1231 ndmp_lprintf(outfile,
1232 "Window size is NULL,"
1233 "so setting it to 8192000\n");
1234 }
1235 (void) ndmp_fprintf(outfile,
1236 "Test case name : ndmp_mover_set_window_size\n");
1237 (void) ndmp_fprintf(outfile,
1238 "Error condition : %s\n", ndmpErrorCodeToStr(error));
1239
1240 ret = mover_set_window_size_intl(error, tape_dev, outfile, conn);
1241 if (ret != 0 && error != NDMP_PRECONDITION_ERR) {
1242 (void) ndmp_fprintf(outfile,
1243 "Initialization failed.\n");
1244 }
1245 ndmpUQuadObj.high = 0;
1246 ndmpUQuadObj.low = winSize;
1247 switch (error) {
1248 case NDMP_NO_ERR:
1249 res = mover_set_window_core(NDMP_NO_ERR,
1250 NULL, &ndmpUQuadObj, outfile, conn);
1251 break;
1252 case NDMP_PRECONDITION_ERR:
1253 res = mover_set_window_core(NDMP_PRECONDITION_ERR,
1254 NULL, &ndmpUQuadObj, outfile, conn);
1255 break;
1256 case NDMP_ILLEGAL_ARGS_ERR:
1257 ndmpUQuadObj.low = ~(ushort_t)0;
1258 res = mover_set_window_core(NDMP_ILLEGAL_ARGS_ERR,
1259 NULL, 0, outfile, conn);
1260 break;
1261 case NDMP_ILLEGAL_STATE_ERR:
1262 res = mover_set_window_core(NDMP_ILLEGAL_STATE_ERR,
1263 NULL, &ndmpUQuadObj, outfile, conn);
1264 break;
1265 case NDMP_NOT_AUTHORIZED_ERR:
1266 res = mover_set_window_core(NDMP_NOT_AUTHORIZED_ERR,
1267 NULL, &ndmpUQuadObj, outfile, conn);
1268 break;
1269 default:
1270 break;
1271 }
1272
1273 ret = mover_set_window_size_cleanup(error, outfile, conn);
1274 if (ret != 0) {
1275 (void) ndmp_fprintf(outfile,
1276 "ndmp_mover_set_window_size cleanup failed\n");
1277 }
1278 if (res != 0) {
1279 (void) ndmp_fprintf(outfile,
1280 "Test case result : Fail\n");
1281 return (1);
1282 } else {
1283 (void) ndmp_fprintf(outfile,
1284 "Test case result : Pass\n");
1285 return (0);
1286 }
1287 }
1288
1289 /*
1290 * inf_mover_connect() :
1291 * This request is used by the DMA to instruct the
1292 * mover to establish a data connection to a Data Server or peer mover. A
1293 * connect request is only valid when the mover is in the IDLE state and
1294 * requires the tape drive to be opened. A successful connect request causes
1295 * the mover to transition to the ACTIVE state.
1296 *
1297 * Executes all the steps in the test case. First calls the initialize methods
1298 * to set the test bed. Then sends the actual request. Finally does the
1299 * cleanup.
1300 *
1301 * Arguments :
1302 * ndmp_error - Error condition to test.
1303 * char * - Tape device.
1304 * FILE * - Log file handle.
1305 * conn_handle - Connection object handle.
1306 * Return :
1307 * int - 0 for success and 1 for failure.
1308 */
1309 int
1310 inf_mover_connect(ndmp_error error, char *tape_dev, char *mover_mode,
1311 char **addr_type, FILE * outfile, conn_handle * conn)
1312 {
1313 int ret = 0, res = 0;
1314 ndmp_mover_mode mode;
1315 ndmp_addr_type addr;
1316 ndmp_addr *tcp_obj = NULL;
1317 char *addr_t = NULL;
1318 (void) ndmp_fprintf(outfile,
1319 "Test case name : ndmp_mover_connect\n");
1320 (void) ndmp_fprintf(outfile,
1321 "Error condition : %s\n", ndmpErrorCodeToStr(error));
1322 if (addr_type != NULL) {
1323 addr_t = *addr_type;
1324 if (addr_t != NULL)
1325 (void) ndmp_dprintf(stdout,
1326 "inf_mover_connect: addr_type %s\n", addr_t);
1327 else
1328 (void) ndmp_dprintf(stdout,
1329 "inf_mover_connect: addr_type is NULL\n");
1330 }
1331 if (mover_mode != NULL) {
1332 mode = convert_mover_mode(mover_mode);
1333 (void) ndmp_dprintf(outfile,
1334 "inf_mover_connect: mode is 0x%x\n", mode);
1335 } else {
1336 mode = NDMP_MOVER_MODE_READ;
1337 (void) ndmp_dprintf(outfile,
1338 "inf_mover_connect: mode is "
1339 "NDMP_MOVER_MODE_READ\n");
1340 }
1341
1342 if (addr_type != NULL) {
1343 addr = convert_addr_type(addr_t);
1344 (void) ndmp_dprintf(outfile,
1345 "inf_mover_connect: "
1346 "addr_type 0x%x\n", addr);
1347 } else {
1348 (void) ndmp_dprintf(outfile,
1349 "inf_mover_connect: "
1350 "addr_type NDMP_ADDR_LOCAL\n");
1351 addr = NDMP_ADDR_LOCAL;
1352 }
1353
1354 if (addr_t != NULL)
1355 (void) ndmp_dprintf(outfile,
1356 "inf_mover_connect: "
1357 "addr_type %s 0x%x\n", addr_t, addr);
1358
1359 ret = mover_connect_intl(error, tape_dev,
1360 addr, &tcp_obj, outfile, conn);
1361 (void) ndmp_dprintf(outfile,
1362 "inf_mover_connect: "
1363 "tcp obj 0x%x\n", tcp_obj);
1364 if (ret != 0) {
1365 (void) ndmp_fprintf(outfile,
1366 "Initialization failed. \n");
1367 }
1368 res = mover_connect_core(error, mode, addr, tcp_obj, outfile, conn);
1369 ret = mover_connect_cleanup(error, outfile, conn);
1370 if (ret != 0) {
1371 (void) ndmp_fprintf(outfile,
1372 "ndmp_mover_connect cleanup failed\n");
1373 }
1374 if (res != 0) {
1375 (void) ndmp_fprintf(outfile,
1376 "Test case result : Fail\n");
1377 return (1);
1378 } else {
1379 (void) ndmp_fprintf(outfile,
1380 "Test case result : Pass\n");
1381 return (0);
1382 }
1383 }
1384
1385 /*
1386 * inf_mover_listen():
1387 * This request is used by the DMA to instruct the mover
1388 * create a connection end point and listen for a subsequent data connection
1389 * from a Data Server or peer Tape Server (mover). This request is also used
1390 * by the DMA to obtain the address of connection end point the mover is
1391 * listening at. A listen request is only valid when the mover is in the IDLE
1392 * state.
1393 *
1394 * Executes all the steps in the test case. First calls the initialize methods
1395 * to set the test bed. Then sends the actual request. Finally does the
1396 * cleanup.
1397 *
1398 * Arguments :
1399 * ndmp_error - Error condition to test.
1400 * char * - Tape device.
1401 * FILE * - Log file handle.
1402 * conn_handle * - Connection object handle.
1403 * Return :
1404 * int - 0 for success and 1 for failure.
1405 */
1406 int
1407 inf_mover_listen(ndmp_error error, char *tape_dev, char *mover_mode,
1408 char *addr_type, FILE * outfile, conn_handle * conn)
1409 {
1410 int ret = 0, res = 0;
1411 ndmp_mover_mode mode;
1412 ndmp_addr_type addr;
1413 (void) ndmp_fprintf(outfile,
1414 "Test case name : ndmp_mover_listen\n");
1415 (void) ndmp_fprintf(outfile,
1416 "Error condition : %s\n", ndmpErrorCodeToStr(error));
1417 ret = mover_listen_intl(error, tape_dev, outfile, conn);
1418 if (ret != 0) {
1419 (void) ndmp_fprintf(outfile,
1420 "Initialization failed. \n");
1421 }
1422 if (mover_mode != NULL)
1423 mode = convert_mover_mode(mover_mode);
1424 else
1425 mode = NDMP_MOVER_MODE_READ;
1426 if (addr_type != NULL)
1427 addr = convert_addr_type(addr_type);
1428 else
1429 addr = NDMP_ADDR_LOCAL;
1430 switch (error) {
1431 case NDMP_NO_ERR:
1432 res = mover_listen_core(NDMP_NO_ERR,
1433 mode, addr, NULL, outfile, conn);
1434 break;
1435 case NDMP_PRECONDITION_ERR:
1436 res = mover_listen_core(NDMP_PRECONDITION_ERR,
1437 mode, addr, NULL, outfile, conn);
1438 break;
1439 case NDMP_ILLEGAL_STATE_ERR:
1440 res = mover_listen_core(NDMP_ILLEGAL_STATE_ERR,
1441 mode, addr, NULL, outfile, conn);
1442 res = mover_listen_core(NDMP_ILLEGAL_STATE_ERR,
1443 mode, addr, NULL, outfile, conn);
1444 break;
1445 case NDMP_ILLEGAL_ARGS_ERR:
1446 /* Mode and Addr are illegal */
1447 res = mover_listen_core(NDMP_ILLEGAL_ARGS_ERR,
1448 3, 4, NULL, outfile, conn);
1449 break;
1450 case NDMP_NOT_AUTHORIZED_ERR:
1451 res = mover_listen_core(NDMP_NOT_AUTHORIZED_ERR,
1452 mode, addr, NULL, outfile, conn);
1453 break;
1454 case NDMP_PERMISSION_ERR:
1455 res = mover_listen_core(NDMP_PERMISSION_ERR,
1456 mode, addr, NULL, outfile, conn);
1457 break;
1458 case NDMP_DEV_NOT_OPEN_ERR:
1459 res = mover_listen_core(NDMP_DEV_NOT_OPEN_ERR,
1460 mode, addr, NULL, outfile, conn);
1461 break;
1462 default:
1463 break;
1464 }
1465
1466 if (error != NDMP_ILLEGAL_STATE_ERR) {
1467 ret = mover_listen_cleanup(error, outfile, conn);
1468 if (ret != 0) {
1469 (void) ndmp_fprintf(outfile,
1470 "ndmp mover_listen cleanup failed\n");
1471 }
1472 }
1473 if (res != 0) {
1474 (void) ndmp_fprintf(outfile,
1475 "Test case result : Fail\n");
1476 return (1);
1477 } else {
1478 (void) ndmp_fprintf(outfile,
1479 "Test case result : Pass\n");
1480 return (0);
1481 }
1482 }
1483
1484 /*
1485 * inf_mover_read():
1486 * This request is used by the DMA to instruct the mover to
1487 * begin transferring the specified backup stream segment from the tape
1488 * subsystem to the data connection. The mover MUST be in the ACTIVE state to
1489 * accept and process a mover read request. Multiple outstanding read
1490 * requests are not allowed.
1491 *
1492 * Executes all the steps in the test case. First calls the initialize methods
1493 * to set the test bed. Then sends the actual request. Finally does the
1494 * cleanup.
1495 *
1496 * Arguments :
1497 * ndmp_error - Error condition to test.
1498 * char * - Tape device.
1499 * FILE * - Log file handle.
1500 * conn_handle * - Connection object handle.
1501 * Return :
1502 * int - 0 for success and 1 for failure.
1503 */
1504 int
1505 inf_mover_read(ndmp_error error, char *tape_dev,
1506 FILE * outfile, conn_handle * conn)
1507 {
1508 int ret = 0, res = 0;
1509 (void) ndmp_fprintf(outfile,
1510 "Test case name : ndmp_mover_read\n");
1511 (void) ndmp_fprintf(outfile,
1512 "Error condition : %s\n", ndmpErrorCodeToStr(error));
1513
1514 ret = mover_read_intl(error, tape_dev, outfile, conn);
1515 if (ret != 0) {
1516 (void) ndmp_fprintf(outfile,
1517 "Initialization failed. \n");
1518 }
1519 switch (error) {
1520 case NDMP_NO_ERR:
1521 res = mover_read_core(NDMP_NO_ERR, outfile, conn);
1522 break;
1523 case NDMP_ILLEGAL_ARGS_ERR:
1524 res = mover_read_core(NDMP_ILLEGAL_ARGS_ERR,
1525 outfile, conn);
1526 break;
1527 case NDMP_ILLEGAL_STATE_ERR:
1528 res = mover_read_core(NDMP_ILLEGAL_STATE_ERR,
1529 outfile, conn);
1530 break;
1531 case NDMP_READ_IN_PROGRESS_ERR:
1532 res = mover_read_core(NDMP_NO_ERR,
1533 outfile, conn);
1534 res = mover_read_core(NDMP_READ_IN_PROGRESS_ERR,
1535 outfile, conn);
1536 break;
1537 case NDMP_NOT_AUTHORIZED_ERR:
1538 res = mover_read_core(NDMP_NOT_AUTHORIZED_ERR,
1539 outfile, conn);
1540 break;
1541 default:
1542 break;
1543 }
1544
1545 ret = mover_read_cleanup(error, outfile, conn);
1546 if (ret != 0) {
1547 (void) ndmp_fprintf(outfile,
1548 "ndmp_mover_read cleanup failed\n");
1549 }
1550 if (res != 0) {
1551 (void) ndmp_fprintf(outfile,
1552 "Test case result : Fail\n");
1553 return (1);
1554 } else {
1555 (void) ndmp_fprintf(outfile,
1556 "Test case result : Pass\n");
1557 return (0);
1558 }
1559 }
1560
1561 /*
1562 * inf_mover_get_state(): This request is used by the DMA to obtain information
1563 * about the Mover's operational state as represented by the standard mover
1564 * variable set.
1565 *
1566 * Executes all the steps in the test case.
1567 *
1568 * Arguments :
1569 * ndmp_error - Error condition to test.
1570 * FILE * - Log file handle.
1571 * conn_handle * - Connection object handle.
1572 * Return : int - 0 for success and 1 for failure.
1573 */
1574 /* ARGSUSED */
1575 int
1576 inf_mover_get_state(ndmp_error error, char *tape_dev,
1577 FILE * outfile, conn_handle * conn)
1578 {
1579 int ret = 0;
1580 (void) ndmp_fprintf(outfile,
1581 "Test case name : ndmp_mover_get_state\n");
1582 (void) ndmp_fprintf(outfile,
1583 "Error condition : %s\n", ndmpErrorCodeToStr(error));
1584
1585 switch (error) {
1586 case NDMP_NO_ERR:
1587 ret = mover_get_state_core(NDMP_NO_ERR, outfile, conn);
1588 break;
1589 case NDMP_NOT_AUTHORIZED_ERR:
1590 ret = mover_get_state_core(NDMP_NOT_AUTHORIZED_ERR,
1591 outfile, conn);
1592 break;
1593 default:
1594 break;
1595 }
1596
1597 if (ret != 0) {
1598 (void) ndmp_fprintf(outfile,
1599 "Test case result : Fail\n");
1600 return (1);
1601 } else {
1602 (void) ndmp_fprintf(outfile,
1603 "Test case result : Pass\n");
1604 return (0);
1605 }
1606 }
1607
1608 /*
1609 * inf_mover_continue():
1610 * This request is used by the DMA to instruct the
1611 * mover to transition from the PAUSED state to the ACTIVE state and to
1612 * resume the transfer of data stream between the data connection and the
1613 * tape subsystem.
1614 *
1615 * Executes all the steps in the test case. First calls the initialize methods
1616 * to set the test bed. Then sends the actual request. Finally does the
1617 * cleanup.
1618 *
1619 * Arguments :
1620 * ndmp_error - Error condition to test.
1621 * char * - Tape device.
1622 * FILE * - Log file handle.
1623 * conn_handle * - Connection object handle.
1624 * Return :
1625 * int - 0 for success and 1 for failure.
1626 */
1627 int
1628 inf_mover_continue(ndmp_error error, char *tape_dev,
1629 char *absBckDirPath, FILE * outfile, conn_handle * conn)
1630 {
1631 int ret = 0, res = 0;
1632 (void) ndmp_fprintf(outfile,
1633 "Test case name : ndmp_mover_continue\n");
1634 (void) ndmp_fprintf(outfile,
1635 "Error condition : %s\n", ndmpErrorCodeToStr(error));
1636 ndmp_dprintf(stdout,
1637 "line # connhandle %d %d\n", __LINE__, conn->connhandle);
1638
1639 ret = mover_continue_intl(error, tape_dev,
1640 absBckDirPath, outfile, conn);
1641 print_intl_result(ret, outfile);
1642
1643 res = mover_continue_core(error, outfile, conn);
1644 print_test_result(res, outfile);
1645
1646 ret = mover_continue_cleanup(error, outfile, conn);
1647 print_cleanup_result(ret, outfile);
1648
1649 return (res);
1650 }
1651
1652 /*
1653 * inf_mover_close():
1654 * This request is used by the DMA to instruct the mover
1655 * to gracefully close the current data connection and transition to the
1656 * HALTED state.
1657 *
1658 * Executes all the steps in the test case. First calls the initialize methods
1659 * to set the test bed. Then sends the actual request. Finally does the
1660 * cleanup.
1661 *
1662 * Arguments :
1663 * ndmp_error - Error condition to test.
1664 * char * - Tape device.
1665 * FILE * - Log file handle.
1666 * conn_handle * - Connection object handle.
1667 * Return :
1668 * int - 0 for success and 1 for failure.
1669 */
1670 int
1671 inf_mover_close(ndmp_error error, char *tape_dev,
1672 char *absBckDirPath, FILE * outfile, conn_handle * conn)
1673 {
1674 int ret = 0, res = 0;
1675 (void) ndmp_fprintf(outfile,
1676 "Test case name : ndmp_mover_close\n");
1677 (void) ndmp_fprintf(outfile,
1678 "Error condition : %s\n", ndmpErrorCodeToStr(error));
1679
1680 ret = mover_close_intl(error, tape_dev, absBckDirPath, outfile, conn);
1681 mover_get_state_core(NDMP_NO_ERR, outfile, conn);
1682 if (ret != 0) {
1683 (void) ndmp_fprintf(outfile, "Initialization failed. \n");
1684 }
1685 switch (error) {
1686 case NDMP_NO_ERR:
1687 res = mover_close_core(NDMP_NO_ERR, outfile, conn);
1688 break;
1689 case NDMP_ILLEGAL_STATE_ERR:
1690 res = mover_close_core(NDMP_ILLEGAL_STATE_ERR,
1691 outfile, conn);
1692 break;
1693 case NDMP_NOT_AUTHORIZED_ERR:
1694 res = mover_close_core(NDMP_NOT_AUTHORIZED_ERR,
1695 outfile, conn);
1696 break;
1697 default:
1698 break;
1699 }
1700
1701 ret = mover_close_cleanup(error, outfile, conn);
1702 if (ret != 0) {
1703 (void) ndmp_fprintf(outfile,
1704 "ndmp_mover_close cleanup failed\n");
1705 }
1706 if (res != 0) {
1707 (void) ndmp_fprintf(outfile,
1708 "Test case result : Fail\n");
1709 return (1);
1710 } else {
1711 (void) ndmp_fprintf(outfile,
1712 "Test case result : Pass\n");
1713 return (0);
1714 }
1715 }
1716
1717 /*
1718 * inf_mover_abort():
1719 * This request is used by the DMA to instruct the mover
1720 * to terminate any in progress mover operation, close the data connection if
1721 * present, and transition the mover to the to the HALTED state. An abort
1722 * request can be issued from any mover state except IDLE.
1723 *
1724 * Executes all the steps in the test case. First calls the initialize methods
1725 * to set the test bed. Then sends the actual request. Finally does the
1726 * cleanup.
1727 *
1728 * Arguments :
1729 * ndmp_error - Error condition to test.
1730 * char * - Tape device.
1731 * FILE * - Log file handle.
1732 * conn_handle * - Connection object handle.
1733 * Return :
1734 * int - 0 for success and 1 for failure.
1735 */
1736 int
1737 inf_mover_abort(ndmp_error error, char *tape_dev,
1738 FILE * outfile, conn_handle * conn)
1739 {
1740 int ret = 0, res = 0;
1741 (void) ndmp_fprintf(outfile,
1742 "Test case name : ndmp_mover_abort\n");
1743 (void) ndmp_fprintf(outfile,
1744 "Error condition : %s\n", ndmpErrorCodeToStr(error));
1745
1746 ret = mover_abort_intl(error, tape_dev, outfile, conn);
1747 if (ret != 0 && error != NDMP_NOT_AUTHORIZED_ERR) {
1748 (void) ndmp_fprintf(outfile,
1749 "Initialization failed. \n");
1750 }
1751 switch (error) {
1752 case NDMP_NO_ERR:
1753 res = mover_abort_core(NDMP_NO_ERR, outfile, conn);
1754 break;
1755 case NDMP_ILLEGAL_STATE_ERR:
1756 res = mover_abort_core(NDMP_ILLEGAL_STATE_ERR,
1757 outfile, conn);
1758 break;
1759 case NDMP_NOT_AUTHORIZED_ERR:
1760 res = mover_abort_core(NDMP_NOT_AUTHORIZED_ERR,
1761 outfile, conn);
1762 break;
1763 default:
1764 break;
1765 }
1766
1767 ret = mover_abort_cleanup(error, outfile, conn);
1768 if (ret != 0) {
1769 (void) ndmp_fprintf(outfile,
1770 "ndmp_mover_abort cleanup failed\n");
1771 }
1772 if (res != 0) {
1773 (void) ndmp_fprintf(outfile,
1774 "Test case result : Fail\n");
1775 return (1);
1776 } else {
1777 (void) ndmp_fprintf(outfile,
1778 "Test case result : Pass\n");
1779 return (0);
1780 }
1781 }
1782
1783 /*
1784 * inf_mover_stop():
1785 * This request is used by the DMA to instruct the mover to
1786 * release all resources, reset all mover state variables (except
1787 * record_size), and transition the mover to the IDLE state.
1788 *
1789 * Executes all the steps in the test case. First calls the initialize methods
1790 * to set the test bed. Then sends the actual request. Finally does the
1791 * cleanup.
1792 *
1793 * Arguments :
1794 * ndmp_error - Error condition to test
1795 * char * - Tape device.
1796 * FILE * - Log file handle.
1797 * conn_handle - Connection object handle.
1798 * Return :
1799 * int - 0 for success and 1 for failure.
1800 */
1801 int
1802 inf_mover_stop(ndmp_error error, char *tape_dev,
1803 FILE * outfile, conn_handle * conn)
1804 {
1805 int ret = 0, res = 0;
1806 (void) ndmp_fprintf(outfile,
1807 "Test case name : ndmp_mover_stop\n");
1808 (void) ndmp_fprintf(outfile,
1809 "Error condition : %s\n", ndmpErrorCodeToStr(error));
1810
1811 ret = mover_stop_intl(error, tape_dev, outfile, conn);
1812 if (ret != 0) {
1813 (void) ndmp_fprintf(outfile,
1814 "Initialization failed. \n");
1815 }
1816 switch (error) {
1817 case NDMP_NO_ERR:
1818 res = mover_stop_core(NDMP_NO_ERR, outfile, conn);
1819 break;
1820 case NDMP_ILLEGAL_STATE_ERR:
1821 res = mover_stop_core(NDMP_ILLEGAL_STATE_ERR,
1822 outfile, conn);
1823 break;
1824 case NDMP_NOT_AUTHORIZED_ERR:
1825 res = mover_stop_core(NDMP_NOT_AUTHORIZED_ERR,
1826 outfile, conn);
1827 break;
1828 default:
1829 break;
1830 }
1831
1832 ret = mover_stop_cleanup(error, outfile, conn);
1833 if (ret != 0) {
1834 (void) ndmp_fprintf(outfile,
1835 "ndmp_mover_stop cleanup failed\n");
1836 }
1837 if (res != 0) {
1838 (void) ndmp_fprintf(outfile,
1839 "Test case result : Fail\n");
1840 return (1);
1841 } else {
1842 (void) ndmp_fprintf(outfile,
1843 "Test case result : Pass\n");
1844 return (0);
1845 }
1846 }
1847
1848 int
1849 unit_test_mover_get_state(char *tape_dev, host_info * host, FILE * logfile)
1850 {
1851 conn_handle conn;
1852
1853 /* Test 1: NDMP_NO_ERR */
1854 (void) ndmp_dprintf(logfile,
1855 "unit_test_mover_get_state: "
1856 "Test 1: NDMP_NO_ERR start\n");
1857 (void) open_connection(host, &conn, logfile);
1858 inf_mover_get_state(NDMP_NO_ERR,
1859 tape_dev, logfile, &conn);
1860 close_connection(&conn, logfile);
1861 (void) ndmp_dprintf(logfile,
1862 "unit_test_mover_get_state: "
1863 "Test 1: NDMP_NO_ERR end\n");
1864
1865 /* Test 2: NDMP_NOT_AUTHORIZED_ERR */
1866 (void) ndmp_dprintf(logfile,
1867 "unit_test_mover_get_state: "
1868 "Test 2: NDMP_NOT_AUTHORIZED_ERR start\n");
1869 strcpy(host->password, "admn");
1870 (void) open_connection(host, &conn, logfile);
1871 inf_mover_get_state(NDMP_NOT_AUTHORIZED_ERR,
1872 tape_dev, logfile, &conn);
1873 close_connection(&conn, logfile);
1874 strcpy(host->password, "admin");
1875 (void) ndmp_dprintf(logfile,
1876 "unit_test_mover_get_state: "
1877 "Test 2: NDMP_NOT_AUTHORIZED_ERR end\n");
1878
1879 return (1);
1880 }
1881
1882 int
1883 unit_test_mover_abort(char *tape_dev, host_info * host, FILE * logfile)
1884 {
1885 conn_handle conn;
1886
1887 /* Test 1: NDMP_NO_ERR */
1888 (void) ndmp_dprintf(logfile,
1889 "unit_test_mover_abort: "
1890 "Test 1: NDMP_NO_ERR start\n");
1891 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1892 (void) open_connection(host, &conn, logfile);
1893 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1894 inf_mover_abort(NDMP_NO_ERR, tape_dev, logfile, &conn);
1895 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1896 close_connection(&conn, logfile);
1897 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1898 (void) ndmp_dprintf(logfile,
1899 "unit_test_mover_abort: "
1900 "Test 1: NDMP_NO_ERR end\n");
1901
1902 /* Test 2: NDMP_NOT_AUTHORIZED_ERR */
1903 (void) ndmp_dprintf(logfile,
1904 "unit_test_mover_abort: "
1905 "Test 2: NDMP_NOT_AUTHORIZED_ERR start\n");
1906 strcpy(host->password, "admn");
1907 (void) open_connection(host, &conn, logfile);
1908 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1909 inf_mover_abort(NDMP_NOT_AUTHORIZED_ERR, tape_dev, logfile, &conn);
1910 close_connection(&conn, logfile);
1911 strcpy(host->password, "admin");
1912 (void) ndmp_dprintf(logfile,
1913 "unit_test_mover_abort: "
1914 "Test 2: NDMP_NOT_AUTHORIZED_ERR end\n");
1915
1916 /* Test 3: NDMP_ILLEGAL_STATE_ERR */
1917 (void) ndmp_dprintf(logfile,
1918 "unit_test_mover_abort: "
1919 "Test 3: NDMP_NO_ERR start\n");
1920 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1921 (void) open_connection(host, &conn, logfile);
1922 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1923 inf_mover_abort(NDMP_ILLEGAL_STATE_ERR, tape_dev, logfile, &conn);
1924 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1925 close_connection(&conn, logfile);
1926 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1927 (void) ndmp_dprintf(logfile,
1928 "unit_test_mover_abort: "
1929 "Test 3: NDMP_ILLEGAL_STATE_ERR end\n");
1930
1931 return (1);
1932 }
1933
1934 /* NDMP_MOVER_STOP */
1935 int
1936 unit_test_mover_stop(char *tape_dev, host_info * host, FILE * logfile)
1937 {
1938 conn_handle conn;
1939
1940 /* Test 1: NDMP_NO_ERR */
1941 (void) ndmp_dprintf(logfile,
1942 "unit_test_mover_stop: "
1943 "Test 1: NDMP_NO_ERR start\n");
1944 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1945 (void) open_connection(host, &conn, logfile);
1946 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1947 inf_mover_stop(NDMP_NO_ERR, tape_dev, logfile, &conn);
1948 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1949 close_connection(&conn, logfile);
1950 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1951 (void) ndmp_dprintf(logfile,
1952 "unit_test_mover_stop: "
1953 "Test 1: NDMP_NO_ERR end\n");
1954
1955 /*
1956 * Test 2: NDMP_NOT_AUTHORIZED_ERR
1957 */
1958 (void) ndmp_dprintf(logfile,
1959 "unit_test_mover_stop: "
1960 "Test 1: NDMP_NOT_AUTHORIZED_ERR start\n");
1961 strcpy(host->password, "admn");
1962 (void) open_connection(host, &conn, logfile);
1963 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1964 inf_mover_stop(NDMP_NOT_AUTHORIZED_ERR, tape_dev, logfile, &conn);
1965 close_connection(&conn, logfile);
1966 strcpy(host->password, "admin");
1967 (void) ndmp_dprintf(logfile,
1968 "unit_test_mover_stop: "
1969 "Test 2: NDMP_NOT_AUTHORIZED_ERR end\n");
1970
1971 /*
1972 * Test 3: NDMP_ILLEGAL_STATE_ERR
1973 */
1974 (void) ndmp_dprintf(logfile,
1975 "unit_test_mover_stop: "
1976 "Test 3: NDMP_ILLEGAL_STATE_ERR start\n");
1977 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1978 (void) open_connection(host, &conn, logfile);
1979 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1980 inf_mover_stop(NDMP_ILLEGAL_STATE_ERR, tape_dev, logfile, &conn);
1981 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1982 close_connection(&conn, logfile);
1983 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
1984 (void) ndmp_dprintf(logfile,
1985 "unit_test_mover_stop: "
1986 "Test 3: NDMP_ILLEGAL_STATE_ERR end\n");
1987
1988 return (1);
1989 }
1990
1991 /*
1992 * NDMP_MOVER_CLOSE
1993 */
1994 int
1995 unit_test_mover_close(char *tape_dev, host_info * host, FILE * logfile)
1996 {
1997 conn_handle conn;
1998 char *absBckDirPath = "/etc/cron.d";
1999
2000 /*
2001 * Test 1: NDMP_NO_ERR
2002 */
2003 (void) ndmp_dprintf(logfile,
2004 "unit_test_mover_close: "
2005 "Test 1: NDMP_NO_ERR start\n");
2006 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2007 (void) open_connection(host, &conn, logfile);
2008 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2009 inf_mover_close(NDMP_NO_ERR, tape_dev, absBckDirPath, logfile, &conn);
2010 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2011 close_connection(&conn, logfile);
2012 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2013 (void) ndmp_dprintf(logfile,
2014 "unit_test_mover_close: "
2015 "Test 1: NDMP_NO_ERR end\n");
2016
2017 /*
2018 * Test 2: NDMP_NOT_AUTHORIZED_ERR
2019 */
2020 (void) ndmp_dprintf(logfile,
2021 "unit_test_mover_close: "
2022 "Test 1: NDMP_NOT_AUTHORIZED_ERR start\n");
2023 strcpy(host->password, "admn");
2024 (void) open_connection(host, &conn, logfile);
2025 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2026 inf_mover_close(NDMP_NOT_AUTHORIZED_ERR,
2027 tape_dev, absBckDirPath, logfile, &conn);
2028 close_connection(&conn, logfile);
2029 strcpy(host->password, "admin");
2030 (void) ndmp_dprintf(logfile,
2031 "unit_test_mover_close: "
2032 "Test 2: NDMP_NOT_AUTHORIZED_ERR end\n");
2033
2034 /*
2035 * Test 3: NDMP_ILLEGAL_STATE_ERR
2036 */
2037 (void) ndmp_dprintf(logfile,
2038 "unit_test_mover_close: "
2039 "Test 3: NDMP_ILLEGAL_STATE_ERR start\n");
2040 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2041 (void) open_connection(host, &conn, logfile);
2042 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2043 inf_mover_close(NDMP_ILLEGAL_STATE_ERR,
2044 tape_dev, absBckDirPath, logfile, &conn);
2045 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2046 close_connection(&conn, logfile);
2047 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2048 (void) ndmp_dprintf(logfile,
2049 "unit_test_mover_close: "
2050 "Test 3: NDMP_ILLEGAL_STATE_ERR end\n");
2051
2052 return (1);
2053 }
2054
2055 /* NDMP_MOVER_SET_RECORD_SIZE */
2056 int
2057 unit_test_mover_set_record_size(char *tape_dev,
2058 host_info * host, FILE * logfile)
2059 {
2060 conn_handle conn;
2061 char *rec_size = "8192";
2062
2063 /* Test 1: NDMP_NO_ERR */
2064 (void) ndmp_dprintf(logfile,
2065 "unit_test_mover_set_record_size: "
2066 "Test 1: NDMP_NO_ERR start\n");
2067 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2068 (void) open_connection(host, &conn, logfile);
2069 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2070 inf_mover_set_rec_size(NDMP_NO_ERR,
2071 tape_dev, rec_size, logfile, &conn);
2072 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2073 close_connection(&conn, logfile);
2074 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2075 (void) ndmp_dprintf(logfile,
2076 "unit_test_mover_set_record_size: "
2077 "Test 1: NDMP_NO_ERR end\n");
2078
2079 /* Test 2: NDMP_NOT_AUTHORIZED_ERR */
2080 (void) ndmp_dprintf(logfile,
2081 "unit_test_mover_set_record_size: "
2082 "Test 1: NDMP_NOT_AUTHORIZED_ERR start\n");
2083 strcpy(host->password, "admn");
2084 (void) open_connection(host, &conn, logfile);
2085 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2086 inf_mover_set_rec_size(NDMP_NOT_AUTHORIZED_ERR,
2087 tape_dev, rec_size, logfile, &conn);
2088 close_connection(&conn, logfile);
2089 strcpy(host->password, "admin");
2090 (void) ndmp_dprintf(logfile,
2091 "unit_test_mover_set_record_size: "
2092 "Test 2: NDMP_NOT_AUTHORIZED_ERR end\n");
2093
2094 /* Test 3: NDMP_ILLEGAL_STATE_ERR */
2095 (void) ndmp_dprintf(logfile,
2096 "unit_test_mover_set_record_size: "
2097 "Test 3: NDMP_ILLEGAL_STATE_ERR start\n");
2098 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2099 (void) open_connection(host, &conn, logfile);
2100 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2101 inf_mover_set_rec_size(NDMP_ILLEGAL_STATE_ERR,
2102 tape_dev, rec_size, logfile, &conn);
2103 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2104 close_connection(&conn, logfile);
2105 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2106 (void) ndmp_dprintf(logfile,
2107 "unit_test_mover_set_record_size: "
2108 "Test 3: NDMP_ILLEGAL_STATE_ERR end\n");
2109
2110 /*
2111 * NDMP_ILLEGAL_ARGS_ERR
2112 */
2113 (void) ndmp_dprintf(logfile,
2114 "unit_test_mover_set_record_size: "
2115 "Test 4: NDMP_ILLEGAL_STATE_ERR start\n");
2116 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2117 (void) open_connection(host, &conn, logfile);
2118 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2119 inf_mover_set_rec_size(NDMP_ILLEGAL_ARGS_ERR,
2120 tape_dev, "-1", logfile, &conn);
2121 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2122 close_connection(&conn, logfile);
2123 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2124 (void) ndmp_dprintf(logfile,
2125 "unit_test_mover_set_record_size: "
2126 "Test 4: NDMP_ILLEGAL_ARGS_ERR end\n");
2127
2128 return (1);
2129 }
2130
2131 /* NDMP_MOVER_SET_WINDOW */
2132 int
2133 unit_test_mover_set_window_size(char *tape_dev,
2134 host_info * host, FILE * logfile)
2135 {
2136 conn_handle conn;
2137 char *win_size = "8192000";
2138
2139 /*
2140 * Test 1: NDMP_NO_ERR
2141 */
2142 (void) ndmp_dprintf(logfile,
2143 "unit_test_mover_set_window_size: "
2144 "Test 1: NDMP_NO_ERR start\n");
2145 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2146 (void) open_connection(host, &conn, logfile);
2147 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2148 inf_mover_set_window_size(NDMP_NO_ERR,
2149 tape_dev, win_size, logfile, &conn);
2150 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2151 close_connection(&conn, logfile);
2152 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2153 (void) ndmp_dprintf(logfile,
2154 "unit_test_mover_set_window_size: "
2155 "Test 1: NDMP_NO_ERR end\n");
2156
2157 /*
2158 * Test 2: NDMP_NOT_AUTHORIZED_ERR
2159 */
2160 (void) ndmp_dprintf(logfile,
2161 "unit_test_mover_set_window_size: "
2162 "Test 1: NDMP_NOT_AUTHORIZED_ERR start\n");
2163 strcpy(host->password, "admn");
2164 (void) open_connection(host, &conn, logfile);
2165 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2166 inf_mover_set_window_size(NDMP_NOT_AUTHORIZED_ERR,
2167 tape_dev, win_size, logfile, &conn);
2168 close_connection(&conn, logfile);
2169 strcpy(host->password, "admin");
2170 (void) ndmp_dprintf(logfile,
2171 "unit_test_mover_set_window_size: "
2172 "Test 2: NDMP_NOT_AUTHORIZED_ERR end\n");
2173
2174 /*
2175 * NDMP_ILLEGAL_ARGS_ERR
2176 */
2177 (void) ndmp_dprintf(logfile,
2178 "unit_test_mover_set_window_size: "
2179 "Test 3: NDMP_ILLEGAL_STATE_ERR start\n");
2180 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2181 (void) open_connection(host, &conn, logfile);
2182 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2183 inf_mover_set_window_size(NDMP_ILLEGAL_ARGS_ERR,
2184 tape_dev, 0, logfile, &conn);
2185 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2186 close_connection(&conn, logfile);
2187 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2188 (void) ndmp_dprintf(logfile,
2189 "unit_test_mover_set_window_size: "
2190 "Test 3: NDMP_ILLEGAL_STATE_ERR end\n");
2191
2192 /*
2193 * Test 4: NDMP_ILLEGAL_STATE_ERR
2194 */
2195 (void) ndmp_dprintf(logfile,
2196 "unit_test_mover_set_window_size: "
2197 "Test 4: NDMP_ILLEGAL_STATE_ERR start\n");
2198 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2199 (void) open_connection(host, &conn, logfile);
2200 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2201 inf_mover_set_window_size(NDMP_ILLEGAL_STATE_ERR,
2202 tape_dev, win_size, logfile, &conn);
2203 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2204 close_connection(&conn, logfile);
2205 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2206 (void) ndmp_dprintf(logfile,
2207 "unit_test_mover_set_window_size: "
2208 "Test 4: NDMP_ILLEGAL_STATE_ERR end\n");
2209
2210 /* Test 5: NDMP_PRECONDITION_ERR */
2211 (void) ndmp_dprintf(logfile,
2212 "unit_test_mover_set_window_size: "
2213 "Test 5: NDMP_PRECONDITION_ERR start\n");
2214 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2215 (void) open_connection(host, &conn, logfile);
2216 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2217 inf_mover_set_window_size(NDMP_PRECONDITION_ERR,
2218 tape_dev, win_size, logfile, &conn);
2219 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2220 close_connection(&conn, logfile);
2221 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2222 (void) ndmp_dprintf(logfile,
2223 "unit_test_mover_set_window_size: "
2224 "Test 5: NDMP_PRECONDITION_ERR end\n");
2225
2226 return (1);
2227 }
2228
2229 /*
2230 * NDMP_MOVER_CONNECT
2231 */
2232 int
2233 unit_test_mover_connect(char *tape_dev,
2234 host_info * host, FILE * logfile)
2235 {
2236 conn_handle conn;
2237 char *mover_mode = "NDMP_MOVER_MODE_READ";
2238 char *addr_type = "NDMP_ADDR_LOCAL";
2239 ndmp_dprintf(stdout, "addr_type 0x%x\n", addr_type);
2240 /*
2241 * Test 1: NDMP_NO_ERR
2242 */
2243 (void) ndmp_dprintf(logfile,
2244 "unit_test_mover_connect: "
2245 "Test 1: NDMP_NO_ERR start\n");
2246 (void) open_connection(host, &conn, logfile);
2247 inf_mover_connect(NDMP_NO_ERR,
2248 tape_dev, mover_mode, &addr_type, logfile, &conn);
2249 close_connection(&conn, logfile);
2250 (void) ndmp_dprintf(logfile,
2251 "unit_test_mover_connect: "
2252 "Test 1: NDMP_NO_ERR end\n");
2253
2254 /*
2255 * Test 2: NDMP_NOT_AUTHORIZED_ERR
2256 */
2257 (void) ndmp_dprintf(logfile,
2258 "unit_test_mover_connect: "
2259 "Test 1: NDMP_NOT_AUTHORIZED_ERR start\n");
2260 strcpy(host->password, "admn");
2261 (void) open_connection(host, &conn, logfile);
2262 inf_mover_connect(NDMP_NOT_AUTHORIZED_ERR,
2263 tape_dev, NULL, NULL, logfile, &conn);
2264 close_connection(&conn, logfile);
2265 strcpy(host->password, "admin");
2266 (void) ndmp_dprintf(logfile,
2267 "unit_test_mover_connect: "
2268 "Test 2: NDMP_NOT_AUTHORIZED_ERR end\n");
2269
2270 /*
2271 * Test 3: NDMP_ILLEGAL_STATE_ERR
2272 */
2273 (void) ndmp_dprintf(logfile,
2274 "unit_test_mover_connect: "
2275 "Test 3: NDMP_ILLEGAL_STATE_ERR start\n");
2276 (void) open_connection(host, &conn, logfile);
2277 inf_mover_connect(NDMP_ILLEGAL_STATE_ERR,
2278 tape_dev, NULL, NULL, logfile, &conn);
2279 close_connection(&conn, logfile);
2280 (void) ndmp_dprintf(logfile,
2281 "unit_test_mover_connect: "
2282 "Test 3: NDMP_ILLEGAL_STATE_ERR end\n");
2283
2284 /*
2285 * Test 4: NDMP_ILLEGAL_ARGS_ERR
2286 */
2287 (void) ndmp_dprintf(logfile,
2288 "unit_test_mover_connect: "
2289 "Test 4: NDMP_ILLEGAL_ARGS_ERR start\n");
2290 (void) open_connection(host, &conn, logfile);
2291 inf_mover_connect(NDMP_ILLEGAL_ARGS_ERR,
2292 tape_dev, NULL, NULL, logfile, &conn);
2293 close_connection(&conn, logfile);
2294 (void) ndmp_dprintf(logfile,
2295 "unit_test_mover_connect: "
2296 "Test 4: NDMP_ILLEGAL_ARGS_ERR end\n");
2297
2298 /*
2299 * Test 5: NDMP_PRECONDITION_ERR
2300 */
2301 (void) ndmp_dprintf(logfile,
2302 "unit_test_mover_connect: "
2303 "Test 5: NDMP_PRECONDITION_ERR start\n");
2304 (void) open_connection(host, &conn, logfile);
2305 inf_mover_connect(NDMP_PRECONDITION_ERR,
2306 tape_dev, NULL, NULL, logfile, &conn);
2307 close_connection(&conn, logfile);
2308 (void) ndmp_dprintf(logfile,
2309 "unit_test_mover_connect: "
2310 "Test 5: NDMP_PRECONDITION_ERR end\n");
2311
2312 /*
2313 * Test 6: NDMP_DEV_NOT_OPEN_ERR
2314 */
2315 (void) ndmp_dprintf(logfile,
2316 "unit_test_mover_connect: "
2317 "Test 6: NDMP_DEV_NOT_OPEN_ERR start\n");
2318 (void) open_connection(host, &conn, logfile);
2319 inf_mover_connect(NDMP_DEV_NOT_OPEN_ERR,
2320 tape_dev, NULL, NULL, logfile, &conn);
2321 close_connection(&conn, logfile);
2322 (void) ndmp_dprintf(logfile,
2323 "unit_test_mover_connect: "
2324 "Test 6: NDMP_DEV_NOT_OPEN_ERR end\n");
2325
2326 /*
2327 * Test 7: NDMP_PERMISSION_ERR
2328 */
2329 (void) ndmp_dprintf(logfile,
2330 "unit_test_mover_connect: "
2331 "Test 7: NDMP_PERMISSION_ERR start\n");
2332 (void) open_connection(host, &conn, logfile);
2333 inf_mover_connect(NDMP_PERMISSION_ERR,
2334 tape_dev, NULL, NULL, logfile, &conn);
2335 close_connection(&conn, logfile);
2336 (void) ndmp_dprintf(logfile,
2337 "unit_test_mover_connect: "
2338 "Test 7: NDMP_PERMISSION_ERR end\n");
2339
2340 return (1);
2341 }
2342
2343 /* NDMP_MOVER_LISTEN */
2344 int
2345 unit_test_mover_listen(char *tape_dev, host_info * host, FILE * logfile)
2346 {
2347 conn_handle conn;
2348 char *mover_mode = "NDMP_MOVER_MODE_READ";
2349 char *addr_type = "NDMP_ADDR_TCP";
2350
2351 /* Test 1: NDMP_NO_ERR */
2352 (void) ndmp_dprintf(logfile,
2353 "unit_test_mover_listen: "
2354 "Test 1: NDMP_NO_ERR start\n");
2355 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2356 (void) open_connection(host, &conn, logfile);
2357 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2358 inf_mover_listen(NDMP_NO_ERR,
2359 tape_dev, mover_mode, addr_type, logfile, &conn);
2360 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2361 close_connection(&conn, logfile);
2362 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2363 (void) ndmp_dprintf(logfile,
2364 "unit_test_mover_listen: "
2365 "Test 1: NDMP_NO_ERR end\n");
2366
2367 /* Test 2: NDMP_NOT_AUTHORIZED_ERR */
2368 (void) ndmp_dprintf(logfile,
2369 "unit_test_mover_listen: "
2370 "Test 2: NDMP_NOT_AUTHORIZED_ERR start\n");
2371 strcpy(host->password, "admn");
2372 (void) open_connection(host, &conn, logfile);
2373 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2374 inf_mover_listen(NDMP_NOT_AUTHORIZED_ERR,
2375 tape_dev, NULL, NULL, logfile, &conn);
2376 close_connection(&conn, logfile);
2377 strcpy(host->password, "admin");
2378 (void) ndmp_dprintf(logfile,
2379 "unit_test_mover_listen: "
2380 "Test 2: NDMP_NOT_AUTHORIZED_ERR end\n");
2381
2382 /* Test 3: NDMP_ILLEGAL_STATE_ERR */
2383 (void) ndmp_dprintf(logfile,
2384 "unit_test_mover_listen: "
2385 "Test 3: NDMP_ILLEGAL_STATE_ERR start\n");
2386 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2387 (void) open_connection(host, &conn, logfile);
2388 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2389 inf_mover_listen(NDMP_ILLEGAL_STATE_ERR,
2390 tape_dev, NULL, NULL, logfile, &conn);
2391 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2392 close_connection(&conn, logfile);
2393 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2394 (void) ndmp_dprintf(logfile,
2395 "unit_test_mover_listen: "
2396 "Test 3: NDMP_ILLEGAL_STATE_ERR end\n");
2397
2398 /*
2399 * Test 4: NDMP_ILLEGAL_ARGS_ERR
2400 */
2401 (void) ndmp_dprintf(logfile,
2402 "unit_test_mover_listen: "
2403 "Test 4: NDMP_ILLEGAL_STATE_ERR start\n");
2404 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2405 (void) open_connection(host, &conn, logfile);
2406 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2407 inf_mover_listen(NDMP_ILLEGAL_ARGS_ERR,
2408 tape_dev, NULL, NULL, logfile, &conn);
2409 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2410 close_connection(&conn, logfile);
2411 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2412 (void) ndmp_dprintf(logfile,
2413 "unit_test_mover_listen: "
2414 "Test 4: NDMP_ILLEGAL_ARGS_ERR end\n");
2415
2416 /*
2417 * Test 5: NDMP_PRECONDITION_ERR
2418 */
2419 (void) ndmp_dprintf(logfile,
2420 "unit_test_mover_listen: "
2421 "Test 5: NDMP_PRECONDITION_ERR start\n");
2422 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2423 (void) open_connection(host, &conn, logfile);
2424 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2425 inf_mover_listen(NDMP_PRECONDITION_ERR,
2426 tape_dev, NULL, NULL, logfile, &conn);
2427 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2428 close_connection(&conn, logfile);
2429 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2430 (void) ndmp_dprintf(logfile,
2431 "unit_test_mover_listen: "
2432 "Test 5: NDMP_PRECONDITION_ERR end\n");
2433
2434 /* Test 6: NDMP_DEV_NOT_OPEN_ERR */
2435 (void) ndmp_dprintf(logfile,
2436 "unit_test_mover_listen: "
2437 "Test 6: NDMP_DEV_NOT_OPEN_ERR start\n");
2438 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2439 (void) open_connection(host, &conn, logfile);
2440 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2441 inf_mover_listen(NDMP_DEV_NOT_OPEN_ERR,
2442 tape_dev, NULL, NULL, logfile, &conn);
2443 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2444 close_connection(&conn, logfile);
2445 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2446 (void) ndmp_dprintf(logfile,
2447 "unit_test_mover_listen: "
2448 "Test 6: NDMP_DEV_NOT_OPEN_ERR end\n");
2449
2450 /* Test 7: NDMP_PERMISSION_ERR */
2451 (void) ndmp_dprintf(logfile,
2452 "unit_test_mover_listen: "
2453 "Test 7: NDMP_PERMISSION_ERR start\n");
2454 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2455 (void) open_connection(host, &conn, logfile);
2456 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2457 inf_mover_listen(NDMP_PERMISSION_ERR,
2458 tape_dev, NULL, NULL, logfile, &conn);
2459 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2460 close_connection(&conn, logfile);
2461 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2462 (void) ndmp_dprintf(logfile,
2463 "unit_test_mover_listen: "
2464 "Test 7: NDMP_PERMISSION_ERR end\n");
2465
2466 return (1);
2467 }
2468
2469 /*
2470 * NDMP_MOVER_READ
2471 */
2472 int
2473 unit_test_mover_read(char *tape_dev,
2474 host_info * host, FILE * logfile)
2475 {
2476 conn_handle conn;
2477
2478 /* Test 1: NDMP_NO_ERR */
2479 (void) ndmp_dprintf(logfile,
2480 "unit_test_mover_read: "
2481 "Test 1: NDMP_NO_ERR start\n");
2482 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2483 (void) open_connection(host, &conn, logfile);
2484 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2485 inf_mover_read(NDMP_NO_ERR, tape_dev, logfile, &conn);
2486 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2487 (void) ndmp_dprintf(logfile,
2488 "unit_test_mover_read: "
2489 "Test 1: NDMP_NO_ERR end\n");
2490
2491
2492 /* Test 3: NDMP_ILLEGAL_STATE_ERR */
2493 (void) ndmp_dprintf(logfile,
2494 "unit_test_mover_read: "
2495 "Test 3: NDMP_ILLEGAL_STATE_ERR start\n");
2496 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2497 inf_mover_read(NDMP_ILLEGAL_STATE_ERR, tape_dev, logfile, &conn);
2498 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2499 (void) ndmp_dprintf(logfile,
2500 "unit_test_mover_read: "
2501 "Test 3: NDMP_ILLEGAL_STATE_ERR end\n");
2502
2503 /*
2504 * Test 4: NDMP_ILLEGAL_ARGS_ERR
2505 */
2506 (void) ndmp_dprintf(logfile,
2507 "unit_test_mover_read: "
2508 "Test 4: NDMP_ILLEGAL_STATE_ERR start\n");
2509 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2510 inf_mover_read(NDMP_ILLEGAL_ARGS_ERR,
2511 tape_dev, logfile, &conn);
2512 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2513 (void) ndmp_dprintf(logfile,
2514 "unit_test_mover_read: "
2515 "Test 4: NDMP_ILLEGAL_ARGS_ERR end\n");
2516
2517 /* Test 5: NDMP_READ_IN_PROGRESS_ERR */
2518 (void) ndmp_dprintf(logfile,
2519 "unit_test_mover_read: "
2520 "Test 5: NDMP_READ_IN_PROGRESS_ERR start\n");
2521 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2522 inf_mover_read(NDMP_READ_IN_PROGRESS_ERR,
2523 tape_dev, logfile, &conn);
2524 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2525 close_connection(&conn, logfile);
2526 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2527 (void) ndmp_dprintf(logfile,
2528 "unit_test_mover_read: "
2529 "Test 5: NDMP_READ_IN_PROGRESS_ERR end\n");
2530
2531 /* Test 2: NDMP_NOT_AUTHORIZED_ERR */
2532 (void) ndmp_dprintf(logfile,
2533 "unit_test_mover_read: "
2534 "Test 2: NDMP_NOT_AUTHORIZED_ERR start\n");
2535 strcpy(host->password, "admn");
2536 (void) open_connection(host, &conn, logfile);
2537 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2538 inf_mover_read(NDMP_NOT_AUTHORIZED_ERR,
2539 tape_dev, logfile, &conn);
2540 close_connection(&conn, logfile);
2541 strcpy(host->password, "admin");
2542 (void) ndmp_dprintf(logfile,
2543 "unit_test_mover_read: "
2544 "Test 2: NDMP_NOT_AUTHORIZED_ERR end\n");
2545
2546 return (1);
2547 }
2548
2549 /* NDMP_MOVER_CONTINUE */
2550 int
2551 unit_test_mover_continue(char *tape_dev,
2552 host_info * host, FILE * logfile)
2553 {
2554 conn_handle conn;
2555 char *absBckDirPath = "/etc/cron.d/";
2556
2557 /* Test 1: NDMP_NO_ERR */
2558 (void) ndmp_dprintf(logfile,
2559 "unit_test_mover_continue: "
2560 "Test 1: NDMP_NO_ERR start\n");
2561 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2562 (void) open_connection(host, &conn, logfile);
2563 (void) ndmp_dprintf(stdout, "%s, %d connhandle 0x%x\n",
2564 __FILE__, __LINE__, conn.connhandle);
2565 inf_mover_continue(NDMP_NO_ERR,
2566 tape_dev, absBckDirPath, logfile, &conn);
2567 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2568 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2569 (void) ndmp_dprintf(logfile,
2570 "unit_test_mover_continue: "
2571 "Test 1: NDMP_NO_ERR end\n");
2572
2573 /* Test 3: NDMP_ILLEGAL_STATE_ERR */
2574 (void) ndmp_dprintf(logfile,
2575 "unit_test_mover_continue: "
2576 "Test 3: NDMP_ILLEGAL_STATE_ERR start\n");
2577 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2578 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2579 inf_mover_continue(NDMP_ILLEGAL_STATE_ERR,
2580 tape_dev, absBckDirPath, logfile, &conn);
2581 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2582 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2583 (void) ndmp_dprintf(logfile,
2584 "unit_test_mover_continue: "
2585 "Test 3: NDMP_ILLEGAL_STATE_ERR end\n");
2586
2587 /*
2588 * Test 4: NDMP_PRECONDITION_ERR
2589 */
2590 (void) ndmp_dprintf(logfile,
2591 "unit_test_mover_continue: "
2592 "Test 4: NDMP_PRECONDITION_ERR start\n");
2593 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2594 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2595 inf_mover_continue(NDMP_PRECONDITION_ERR,
2596 tape_dev, absBckDirPath, logfile, &conn);
2597 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2598 close_connection(&conn, logfile);
2599 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2600 (void) ndmp_dprintf(logfile,
2601 "unit_test_mover_continue: "
2602 "Test 4: NDMP_PRECONDITION_ERR end\n");
2603
2604 /* Test 2: NDMP_NOT_AUTHORIZED_ERR */
2605 (void) ndmp_dprintf(logfile,
2606 "unit_test_mover_continue: "
2607 "Test 2: NDMP_NOT_AUTHORIZED_ERR start\n");
2608 strcpy(host->password, "admn");
2609 (void) open_connection(host, &conn, logfile);
2610 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2611 inf_mover_continue(NDMP_NOT_AUTHORIZED_ERR,
2612 tape_dev, absBckDirPath, logfile, &conn);
2613 close_connection(&conn, logfile);
2614 strcpy(host->password, "admin");
2615 (void) ndmp_dprintf(logfile,
2616 "unit_test_mover_continue: "
2617 "Test 2: NDMP_NOT_AUTHORIZED_ERR end\n");
2618
2619 return (1);
2620 }
2621
2622 #ifdef UNIT_TEST_MOVER
2623
2624 int
2625 main(int argc, char *argv[])
2626 {
2627 FILE *logfile = NULL;
2628 char *tape_dev = strdup("/dev/rmt/3n");
2629 host_info auth;
2630 auth.ipAddr = strdup("10.12.178.122");
2631 auth.userName = strdup("admin");
2632 auth.password = strdup("admin");
2633 auth.auth_type = NDMP_AUTH_TEXT;
2634
2635 /* Open Log file */
2636 logfile = fopen("unit_test_mover.log", "w");
2637 (void) ndmp_dprintf(logfile, "main: start\n");
2638 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2639 unit_test_mover_get_state(tape_dev, &auth, logfile);
2640 (void) ndmp_dprintf(stdout, "%s, %d \n", __FILE__, __LINE__);
2641 unit_test_mover_abort(tape_dev, &auth, logfile);
2642 unit_test_mover_stop(tape_dev, &auth, logfile);
2643 unit_test_mover_close(tape_dev, &auth, logfile);
2644 unit_test_mover_set_record_size(tape_dev, &auth, logfile);
2645 unit_test_mover_set_window_size(tape_dev, &auth, logfile);
2646 unit_test_mover_connect(tape_dev, &auth, logfile);
2647 unit_test_mover_listen(tape_dev, &auth, logfile);
2648 unit_test_mover_read(tape_dev, &auth, logfile);
2649 unit_test_mover_continue(tape_dev, &auth, logfile);
2650
2651 (void) ndmp_dprintf(stdout, "main: end\n");
2652 fclose(logfile);
2653 free(tape_dev);
2654 return (1);
2655 }
2656 #endif