12654012Reza Sabdar/*
2e461e79Randall Ralphs * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
32654012Reza Sabdar */
42654012Reza Sabdar
52654012Reza Sabdar/*
62654012Reza Sabdar * BSD 3 Clause License
72654012Reza Sabdar *
82654012Reza Sabdar * Copyright (c) 2007, The Storage Networking Industry Association.
92654012Reza Sabdar *
102654012Reza Sabdar * Redistribution and use in source and binary forms, with or without
112654012Reza Sabdar * modification, are permitted provided that the following conditions
122654012Reza Sabdar * are met:
13a7a204aToomas Soome *	- Redistributions of source code must retain the above copyright
142654012Reza Sabdar *	  notice, this list of conditions and the following disclaimer.
152654012Reza Sabdar *
16a7a204aToomas Soome *	- Redistributions in binary form must reproduce the above copyright
172654012Reza Sabdar *	  notice, this list of conditions and the following disclaimer in
182654012Reza Sabdar *	  the documentation and/or other materials provided with the
192654012Reza Sabdar *	  distribution.
202654012Reza Sabdar *
212654012Reza Sabdar *	- Neither the name of The Storage Networking Industry Association (SNIA)
222654012Reza Sabdar *	  nor the names of its contributors may be used to endorse or promote
232654012Reza Sabdar *	  products derived from this software without specific prior written
242654012Reza Sabdar *	  permission.
252654012Reza Sabdar *
262654012Reza Sabdar * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
272654012Reza Sabdar * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
282654012Reza Sabdar * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
292654012Reza Sabdar * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
302654012Reza Sabdar * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
312654012Reza Sabdar * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
322654012Reza Sabdar * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
332654012Reza Sabdar * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
342654012Reza Sabdar * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
352654012Reza Sabdar * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
362654012Reza Sabdar * POSSIBILITY OF SUCH DAMAGE.
372654012Reza Sabdar */
382654012Reza Sabdar#include <stdio.h>
39e461e79Randall Ralphs#include <unistd.h>
40e461e79Randall Ralphs#include <errno.h>
412654012Reza Sabdar#include <locale.h>
422654012Reza Sabdar#include <libndmp.h>
432654012Reza Sabdar#include "ndmpadm.h"
442654012Reza Sabdar
452654012Reza Sabdar/* static functions prototype */
462654012Reza Sabdarstatic void ndmp_tprint_addr(char *, ndmp_ad_type_t, char *);
472654012Reza Sabdarstatic void ndmp_print_env(ndmp_session_info_t *);
482654012Reza Sabdarstatic void ndmp_connect_print_conn(ndmp_session_info_t *);
492654012Reza Sabdarstatic void ndmp_connect_print_scsi_v2(ndmp_session_info_t *);
502654012Reza Sabdarstatic void ndmp_connect_print_tape_v2(ndmp_session_info_t *);
512654012Reza Sabdarstatic void ndmp_connect_print_mover_v2(ndmp_session_info_t *);
522654012Reza Sabdarstatic void ndmp_connect_print_data_v2(ndmp_session_info_t *);
532654012Reza Sabdarstatic void ndmp_connect_print_v2(int, ndmp_session_info_t *);
542654012Reza Sabdarstatic void ndmp_connect_print_mover_v3(ndmp_session_info_t *);
552654012Reza Sabdarstatic void ndmp_connect_print_data_v3(ndmp_session_info_t *);
562654012Reza Sabdarstatic void ndmp_connect_print_v3(int, ndmp_session_info_t *);
572654012Reza Sabdarstatic void ndmp_connection_print(int, ndmp_session_info_t *);
582654012Reza Sabdar
592654012Reza Sabdar/* Boolean to string.  */
602654012Reza Sabdar#define	B2S(b)	((b) ? "Yes" : "No")
612654012Reza Sabdar
622654012Reza Sabdar/*
632654012Reza Sabdar * Print the address type and IP address if the address type is tcp
642654012Reza Sabdar */
652654012Reza Sabdarstatic void
662654012Reza Sabdarndmp_tprint_addr(char *label, ndmp_ad_type_t addr_type, char *tcp_addr)
672654012Reza Sabdar{
682654012Reza Sabdar	if ((label == NULL) || (tcp_addr == NULL))
692654012Reza Sabdar		return;
702654012Reza Sabdar
712654012Reza Sabdar	switch (addr_type) {
722654012Reza Sabdar	case NDMP_AD_LOCAL:
732654012Reza Sabdar		(void) fprintf(stdout, gettext("\t%s type:\tLocal\n"), label);
742654012Reza Sabdar		break;
752654012Reza Sabdar	case NDMP_AD_TCP:
762654012Reza Sabdar		(void) fprintf(stdout, gettext("\t%s type:\tTCP\n"), label);
772654012Reza Sabdar		(void) fprintf(stdout, gettext("\t%s address:\t%s\n"),
782654012Reza Sabdar		    label, tcp_addr);
792654012Reza Sabdar		break;
802654012Reza Sabdar	case NDMP_AD_FC:
812654012Reza Sabdar		(void) fprintf(stdout, gettext("\t%s type:\tFC\n"), label);
822654012Reza Sabdar		break;
832654012Reza Sabdar	case NDMP_AD_IPC:
842654012Reza Sabdar		(void) fprintf(stdout, gettext("\t%s type:\tIPC\n"), label);
852654012Reza Sabdar		break;
862654012Reza Sabdar	default:
872654012Reza Sabdar		(void) fprintf(stdout,
882654012Reza Sabdar		    gettext("\t%s addr type unknown (0x%x)\n"),
892654012Reza Sabdar		    label, addr_type);
902654012Reza Sabdar	}
912654012Reza Sabdar}
922654012Reza Sabdar
932654012Reza Sabdar/*
942654012Reza Sabdar * Print all the data environment variables for the active session
952654012Reza Sabdar */
962654012Reza Sabdarstatic void
972654012Reza Sabdarndmp_print_env(ndmp_session_info_t *si)
982654012Reza Sabdar{
992654012Reza Sabdar	int i, n;
1002654012Reza Sabdar	ndmp_dt_pval_t *ep;
1012654012Reza Sabdar
1022654012Reza Sabdar	n = si->nsi_data.nd_env_len;
1032654012Reza Sabdar	ep = si->nsi_data.nd_env;
1042654012Reza Sabdar	for (i = 0; ep && i < n; i++, ep++) {
1052654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.env[%d]:\t%s: "),
1062654012Reza Sabdar		    i, ep->np_name);
107a7a204aToomas Soome		if ((ep->np_value != NULL) && (*ep->np_value != '\0'))
1082654012Reza Sabdar			(void) fprintf(stdout, "\"%s\"\n", ep->np_value);
1092654012Reza Sabdar	}
1102654012Reza Sabdar}
1112654012Reza Sabdar
1122654012Reza Sabdar/*
1132654012Reza Sabdar * Print common fields of the active connection.
1142654012Reza Sabdar */
1152654012Reza Sabdarstatic void
1162654012Reza Sabdarndmp_connect_print_conn(ndmp_session_info_t *si)
1172654012Reza Sabdar{
1182654012Reza Sabdar	(void) fprintf(stdout, gettext("\tSession Id:\t%d\n"), si->nsi_sid);
1192654012Reza Sabdar	(void) fprintf(stdout, gettext("\tProtocol version:\t%d\n"),
1202654012Reza Sabdar	    si->nsi_pver);
1212654012Reza Sabdar	(void) fprintf(stdout, gettext("\tAuthenticated:\t\t%s\n"),
1222654012Reza Sabdar	    B2S(si->nsi_auth));
1232654012Reza Sabdar	(void) fprintf(stdout, gettext("\tEOF:\t\t\t%s\n"), B2S(si->nsi_eof));
1242654012Reza Sabdar	if (si->nsi_cl_addr != NULL)
1252654012Reza Sabdar		(void) fprintf(stdout,
1262654012Reza Sabdar		    gettext("\tClient address:\t\t%s\n"), si->nsi_cl_addr);
1272654012Reza Sabdar}
1282654012Reza Sabdar
1292654012Reza Sabdar/*
1302654012Reza Sabdar * Print the connection SCSI info.
1312654012Reza Sabdar */
1322654012Reza Sabdarstatic void
1332654012Reza Sabdarndmp_connect_print_scsi_v2(ndmp_session_info_t *si)
1342654012Reza Sabdar{
1352654012Reza Sabdar	(void) fprintf(stdout, gettext("\tscsi.open:\t\t%s\n"),
1362654012Reza Sabdar	    B2S(si->nsi_scsi.ns_scsi_open != -1));
1372654012Reza Sabdar	if (si->nsi_scsi.ns_adapter_name)
1382654012Reza Sabdar		(void) fprintf(stdout, gettext("\tscsi.adapter:\t\t\"%s\"\n"),
1392654012Reza Sabdar		    si->nsi_scsi.ns_adapter_name);
1402654012Reza Sabdar	(void) fprintf(stdout, gettext("\tscsi.valid target:\t%s\n"),
1412654012Reza Sabdar	    B2S(si->nsi_scsi.ns_valid_target_set));
1422654012Reza Sabdar	if (si->nsi_scsi.ns_valid_target_set) {
1432654012Reza Sabdar		(void) fprintf(stdout,
1442654012Reza Sabdar		    gettext("\tscsi.SID:\t\t%d\n"), si->nsi_scsi.ns_scsi_id);
1452654012Reza Sabdar		(void) fprintf(stdout,
1462654012Reza Sabdar		    gettext("\tscsi.LUN:\t\t%d\n"), si->nsi_scsi.ns_lun);
1472654012Reza Sabdar	}
1482654012Reza Sabdar}
1492654012Reza Sabdar
1502654012Reza Sabdar/*
1512654012Reza Sabdar * Print the connection tape info.
1522654012Reza Sabdar */
1532654012Reza Sabdarstatic void
1542654012Reza Sabdarndmp_connect_print_tape_v2(ndmp_session_info_t *si)
1552654012Reza Sabdar{
1562654012Reza Sabdar	if (si->nsi_tape.nt_fd != -1) {
1572654012Reza Sabdar		(void) fprintf(stdout, gettext("\ttape.fd:\t\t%d\n"),
1582654012Reza Sabdar		    si->nsi_tape.nt_fd);
1592654012Reza Sabdar		(void) fprintf(stdout, gettext("\ttape.record count:\t%d\n"),
1602654012Reza Sabdar		    (int)si->nsi_tape.nt_rec_count);
1612654012Reza Sabdar
1622654012Reza Sabdar		switch (si->nsi_tape.nt_mode) {
1632654012Reza Sabdar		case NDMP_TP_READ_MODE:
1642654012Reza Sabdar			(void) fprintf(stdout,
1652654012Reza Sabdar			    gettext("\ttape.mode:\t\tRead-only\n"));
1662654012Reza Sabdar			break;
1672654012Reza Sabdar		case NDMP_TP_WRITE_MODE:
1682654012Reza Sabdar			(void) fprintf(stdout,
1692654012Reza Sabdar			    gettext("\ttape.mode:\t\tRead/Write\n"));
1702654012Reza Sabdar			break;
1712654012Reza Sabdar		case NDMP_TP_RAW1_MODE:
1722654012Reza Sabdar			(void) fprintf(stdout,
1732654012Reza Sabdar			    gettext("\ttape.mode:\t\tRaw\n"));
1742654012Reza Sabdar			break;
1752654012Reza Sabdar		default:
1762654012Reza Sabdar			(void) fprintf(stdout,
1772654012Reza Sabdar			    gettext("\ttape.mode:\t\tUnknown (0x%x)\n"),
1782654012Reza Sabdar			    si->nsi_tape.nt_mode);
1792654012Reza Sabdar		}
1802654012Reza Sabdar
1812654012Reza Sabdar		if (si->nsi_tape.nt_dev_name)
1822654012Reza Sabdar			(void) fprintf(stdout,
1832654012Reza Sabdar			    gettext("\ttape.device name:\t%s\n"),
1842654012Reza Sabdar			    si->nsi_tape.nt_dev_name);
1852654012Reza Sabdar		if (si->nsi_tape.nt_adapter_name)
1862654012Reza Sabdar			(void) fprintf(stdout,
1872654012Reza Sabdar			    gettext("\ttape.adapter name:\t\"%s\"\n"),
1882654012Reza Sabdar			    si->nsi_tape.nt_adapter_name);
1892654012Reza Sabdar		(void) fprintf(stdout,
1902654012Reza Sabdar		    gettext("\ttape.SID:\t\t%d\n"), si->nsi_tape.nt_sid);
1912654012Reza Sabdar		(void) fprintf(stdout,
1922654012Reza Sabdar		    gettext("\ttape.LUN:\t\t%d\n"), si->nsi_tape.nt_lun);
1932654012Reza Sabdar	} else
1942654012Reza Sabdar		(void) fprintf(stdout, gettext("\ttape.device:\t\tNot open\n"));
1952654012Reza Sabdar}
1962654012Reza Sabdar
1972654012Reza Sabdar/*
1982654012Reza Sabdar * Print the connection mover info.
1992654012Reza Sabdar */
2002654012Reza Sabdarstatic void
2012654012Reza Sabdarndmp_connect_print_mover_v2(ndmp_session_info_t *si)
2022654012Reza Sabdar{
2032654012Reza Sabdar	switch (si->nsi_mover.nm_state) {
2042654012Reza Sabdar	case NDMP_MV_STATE_IDLE:
2052654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.state:\t\tIdle\n"));
2062654012Reza Sabdar		break;
2072654012Reza Sabdar	case NDMP_MV_STATE_LISTEN:
2082654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.state:\t\tListen\n"));
2092654012Reza Sabdar		break;
2102654012Reza Sabdar	case NDMP_MV_STATE_ACTIVE:
2112654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.state:\t\tActive\n"));
2122654012Reza Sabdar		break;
2132654012Reza Sabdar	case NDMP_MV_STATE_PAUSED:
2142654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.state:\t\tPaused\n"));
2152654012Reza Sabdar		break;
2162654012Reza Sabdar	case NDMP_MV_STATE_HALTED:
2172654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.state:\t\tHalted\n"));
2182654012Reza Sabdar		break;
2192654012Reza Sabdar	default:
2202654012Reza Sabdar		(void) fprintf(stdout,
2212654012Reza Sabdar		    gettext("\tmover.state:\t\tUnknown (0x%x)\n"),
2222654012Reza Sabdar		    si->nsi_mover.nm_state);
2232654012Reza Sabdar	}
2242654012Reza Sabdar
2252654012Reza Sabdar	switch (si->nsi_mover.nm_mode) {
2262654012Reza Sabdar	case NDMP_MV_MODE_READ:
2272654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.mode:\t\tRead\n"));
2282654012Reza Sabdar		break;
2292654012Reza Sabdar	case NDMP_MV_MODE_WRITE:
2302654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.mode:\t\tWrite\n"));
2312654012Reza Sabdar		break;
2322654012Reza Sabdar	default:
2332654012Reza Sabdar		(void) fprintf(stdout,
2342654012Reza Sabdar		    gettext("\tmover.mode:\t\tUnknown (0x%x)\n"),
2352654012Reza Sabdar		    si->nsi_mover.nm_mode);
2362654012Reza Sabdar	}
2372654012Reza Sabdar
2382654012Reza Sabdar	switch (si->nsi_mover.nm_pause_reason) {
2392654012Reza Sabdar	case NDMP_MV_PAUSE_NA:
2402654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.pause reason:\tN/A\n"));
2412654012Reza Sabdar		break;
2422654012Reza Sabdar	case NDMP_MV_PAUSE_EOM:
2432654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.pause reason:\tEOM\n"));
2442654012Reza Sabdar		break;
2452654012Reza Sabdar	case NDMP_MV_PAUSE_EOF:
2462654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.pause reason:\tEOF\n"));
2472654012Reza Sabdar		break;
2482654012Reza Sabdar	case NDMP_MV_PAUSE_SEEK:
2492654012Reza Sabdar		(void) fprintf(stdout,
2502654012Reza Sabdar		    gettext("\tmover.pause reason:\tSeek\n"));
2512654012Reza Sabdar		break;
2522654012Reza Sabdar	case NDMP_MV_PAUSE_MEDIA_ERROR:
2532654012Reza Sabdar		(void) fprintf(stdout,
2542654012Reza Sabdar		    gettext("\tmover.pause reason:\tMedia Error\n"));
2552654012Reza Sabdar		break;
2562654012Reza Sabdar	default:
2572654012Reza Sabdar		(void) fprintf(stdout,
2582654012Reza Sabdar		    gettext("\tmover.pause reason:\tUnknown (0x%x)\n"),
2592654012Reza Sabdar		    si->nsi_mover.nm_pause_reason);
2602654012Reza Sabdar	}
2612654012Reza Sabdar
2622654012Reza Sabdar	switch (si->nsi_mover.nm_halt_reason) {
2632654012Reza Sabdar	case NDMP_MV_HALT_NA:
2642654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.halt reason:\tN/A\n"));
2652654012Reza Sabdar		break;
2662654012Reza Sabdar	case NDMP_MV_HALT_CONNECT_CLOSED:
2672654012Reza Sabdar		(void) fprintf(stdout,
2682654012Reza Sabdar		    gettext("\tmover.halt reason:\tConnection closed\n"));
2692654012Reza Sabdar		break;
2702654012Reza Sabdar	case NDMP_MV_HALT_ABORTED:
2712654012Reza Sabdar		(void) fprintf(stdout,
2722654012Reza Sabdar		    gettext("\tmover.halt reason:\tAborted\n"));
2732654012Reza Sabdar		break;
2742654012Reza Sabdar	case NDMP_MV_HALT_INTERNAL_ERROR:
2752654012Reza Sabdar		(void) fprintf(stdout,
2762654012Reza Sabdar		    gettext("\tmover.halt reason:\tInternal error\n"));
2772654012Reza Sabdar		break;
2782654012Reza Sabdar	case NDMP_MV_HALT_CONNECT_ERROR:
2792654012Reza Sabdar		(void) fprintf(stdout,
2802654012Reza Sabdar		    gettext("\tmover.halt reason:\tConnection error\n"));
2812654012Reza Sabdar		break;
2822654012Reza Sabdar	default:
2832654012Reza Sabdar		(void) fprintf(stdout,
2842654012Reza Sabdar		    gettext("\tmover.halt reason:\tUnknown (0x%x)\n"),
2852654012Reza Sabdar		    si->nsi_mover.nm_halt_reason);
2862654012Reza Sabdar	}
2872654012Reza Sabdar
2882654012Reza Sabdar	(void) fprintf(stdout, gettext("\tmover.record size:\t%d\n"),
2892654012Reza Sabdar	    (int)si->nsi_mover.nm_rec_size);
2902654012Reza Sabdar	(void) fprintf(stdout, gettext("\tmover.record number:\t%d\n"),
2912654012Reza Sabdar	    (int)si->nsi_mover.nm_rec_num);
2922654012Reza Sabdar	(void) fprintf(stdout, gettext("\tmover.pos:\t\t%lld\n"),
2932654012Reza Sabdar	    si->nsi_mover.nm_mov_pos);
2942654012Reza Sabdar	(void) fprintf(stdout, gettext("\tmover.win off:\t\t%lld\n"),
2952654012Reza Sabdar	    si->nsi_mover.nm_window_offset);
2962654012Reza Sabdar	(void) fprintf(stdout, gettext("\tmover.win len:\t\t%lld\n"),
2972654012Reza Sabdar	    si->nsi_mover.nm_window_length);
2982654012Reza Sabdar	(void) fprintf(stdout, gettext("\tmover.data socket:\t%d\n"),
2992654012Reza Sabdar	    si->nsi_mover.nm_sock);
3002654012Reza Sabdar}
3012654012Reza Sabdar
3022654012Reza Sabdar/*
3032654012Reza Sabdar * Print the connection data info.
3042654012Reza Sabdar */
3052654012Reza Sabdarstatic void
3062654012Reza Sabdarndmp_connect_print_data_v2(ndmp_session_info_t *si)
3072654012Reza Sabdar{
3082654012Reza Sabdar	int i;
3092654012Reza Sabdar	ndmp_dt_name_t *np;
3102654012Reza Sabdar
3112654012Reza Sabdar	switch (si->nsi_data.nd_oper) {
3122654012Reza Sabdar	case NDMP_DT_OP_NOACTION:
3132654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.operation:\t\tNone\n"));
3142654012Reza Sabdar		break;
3152654012Reza Sabdar	case NDMP_DT_OP_BACKUP:
3162654012Reza Sabdar		(void) fprintf(stdout,
3172654012Reza Sabdar		    gettext("\tdata.operation:\t\tBackup\n"));
3182654012Reza Sabdar		break;
3192654012Reza Sabdar	case NDMP_DT_OP_RECOVER:
3202654012Reza Sabdar		(void) fprintf(stdout,
3212654012Reza Sabdar		    gettext("\tdata.operation:\t\tRestore\n"));
3222654012Reza Sabdar		break;
3232654012Reza Sabdar	default:
3242654012Reza Sabdar		(void) fprintf(stdout,
3252654012Reza Sabdar		    gettext("\tdata.operation:\t\tUnknown (0x%x)\n"),
3262654012Reza Sabdar		    si->nsi_data.nd_oper);
3272654012Reza Sabdar	}
3282654012Reza Sabdar
3292654012Reza Sabdar	switch (si->nsi_data.nd_state) {
3302654012Reza Sabdar	case NDMP_DT_STATE_IDLE:
3312654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.state:\t\tIdle\n"));
3322654012Reza Sabdar		break;
3332654012Reza Sabdar	case NDMP_DT_STATE_ACTIVE:
3342654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.state:\t\tActive\n"));
3352654012Reza Sabdar		break;
3362654012Reza Sabdar	case NDMP_DT_STATE_HALTED:
3372654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.state:\t\tHalted\n"));
3382654012Reza Sabdar		break;
3392654012Reza Sabdar	default:
3402654012Reza Sabdar		(void) fprintf(stdout,
3412654012Reza Sabdar		    gettext("\tdata.state:\t\tUnknown (0x%x)\n"),
3422654012Reza Sabdar		    si->nsi_data.nd_state);
3432654012Reza Sabdar	}
3442654012Reza Sabdar
3452654012Reza Sabdar	switch (si->nsi_data.nd_halt_reason) {
3462654012Reza Sabdar	case NDMP_DT_HALT_NA:
3472654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.halt reason:\tN/A\n"));
3482654012Reza Sabdar		break;
3492654012Reza Sabdar	case NDMP_DT_HALT_SUCCESSFUL:
3502654012Reza Sabdar		(void) fprintf(stdout,
3512654012Reza Sabdar		    gettext("\tdata.halt reason:\tSuccessful\n"));
3522654012Reza Sabdar		break;
3532654012Reza Sabdar	case NDMP_DT_HALT_ABORTED:
3542654012Reza Sabdar		(void) fprintf(stdout,
3552654012Reza Sabdar		    gettext("\tdata.halt reason:\tAborted\n"));
3562654012Reza Sabdar		break;
3572654012Reza Sabdar	case NDMP_DT_HALT_INTERNAL_ERROR:
3582654012Reza Sabdar		(void) fprintf(stdout,
3592654012Reza Sabdar		    gettext("\tdata.halt reason:\tInternal error\n"));
3602654012Reza Sabdar		break;
3612654012Reza Sabdar	case NDMP_DT_HALT_CONNECT_ERROR:
3622654012Reza Sabdar		(void) fprintf(stdout,
3632654012Reza Sabdar		    gettext("\tdata.halt reason:\tConnection error\n"));
3642654012Reza Sabdar		break;
3652654012Reza Sabdar	default:
3662654012Reza Sabdar		(void) fprintf(stdout,
3672654012Reza Sabdar		    gettext("\tdata.halt reason:\tUnknown (0x%x)\n"),
3682654012Reza Sabdar		    si->nsi_data.nd_halt_reason);
3692654012Reza Sabdar	}
3702654012Reza Sabdar
3712654012Reza Sabdar	switch (si->nsi_data.nd_addr_type) {
3722654012Reza Sabdar	case NDMP_AD_LOCAL:
3732654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.mover type:\tLocal\n"));
3742654012Reza Sabdar		break;
3752654012Reza Sabdar	case NDMP_AD_TCP:
3762654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.mover type:\tTCP\n"));
3772654012Reza Sabdar		if (si->nsi_data.nd_tcp_addr)
3782654012Reza Sabdar			(void) fprintf(stdout,
3792654012Reza Sabdar			    gettext("\tdata.mover address:\t%s\n"),
3802654012Reza Sabdar			    si->nsi_data.nd_tcp_addr);
3812654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.sock:\t%d\n"),
3822654012Reza Sabdar		    si->nsi_data.nd_sock);
3832654012Reza Sabdar		break;
3842654012Reza Sabdar	default:
3852654012Reza Sabdar		(void) fprintf(stdout,
3862654012Reza Sabdar		    gettext("\tdata.mover type:\tUnknown (0x%x)\n"),
3872654012Reza Sabdar		    si->nsi_data.nd_addr_type);
3882654012Reza Sabdar	}
3892654012Reza Sabdar
3902654012Reza Sabdar	(void) fprintf(stdout, gettext("\tdata.aborted:\t\t%s\n"),
3912654012Reza Sabdar	    B2S(si->nsi_data.nd_abort));
3922654012Reza Sabdar	(void) fprintf(stdout, gettext("\tdata.read offset:\t%llu\n"),
3932654012Reza Sabdar	    si->nsi_data.nd_read_offset);
3942654012Reza Sabdar	(void) fprintf(stdout, gettext("\tdata.read length:\t%llu\n"),
3952654012Reza Sabdar	    si->nsi_data.nd_read_length);
3962654012Reza Sabdar	(void) fprintf(stdout, gettext("\tdata.total size:\t%llu\n"),
3972654012Reza Sabdar	    si->nsi_data.nd_total_size);
3982654012Reza Sabdar
3992654012Reza Sabdar	ndmp_print_env(si);
4002654012Reza Sabdar
4012654012Reza Sabdar	np = si->nsi_data.nd_nlist.nld_nlist;
4022654012Reza Sabdar	for (i = 0; np && i < (int)si->nsi_data.nld_nlist_len; i++, np++) {
4032654012Reza Sabdar		if ((np->nn_name) && (np->nn_dest)) {
4042654012Reza Sabdar			(void) fprintf(stdout,
4052654012Reza Sabdar			    gettext("\tdata.nlist[%d]:\tname: "
4062654012Reza Sabdar			    "\"%s\"\n\t\tdest:\"%s\"\n"),
4072654012Reza Sabdar			    i, np->nn_name, np->nn_dest);
4082654012Reza Sabdar		}
4092654012Reza Sabdar	}
4102654012Reza Sabdar}
4112654012Reza Sabdar
4122654012Reza Sabdar/*
4132654012Reza Sabdar * Print V2 connection info for the given category.
4142654012Reza Sabdar */
4152654012Reza Sabdarstatic void
4162654012Reza Sabdarndmp_connect_print_v2(int cat, ndmp_session_info_t *si)
4172654012Reza Sabdar{
4182654012Reza Sabdar		if (cat & NDMP_CAT_SCSI)
4192654012Reza Sabdar			ndmp_connect_print_scsi_v2(si);
4202654012Reza Sabdar		if (cat & NDMP_CAT_TAPE)
4212654012Reza Sabdar			ndmp_connect_print_tape_v2(si);
4222654012Reza Sabdar		if (cat & NDMP_CAT_MOVER)
4232654012Reza Sabdar			ndmp_connect_print_mover_v2(si);
4242654012Reza Sabdar		if (cat & NDMP_CAT_DATA)
4252654012Reza Sabdar			ndmp_connect_print_data_v2(si);
4262654012Reza Sabdar}
4272654012Reza Sabdar
4282654012Reza Sabdar/*
4292654012Reza Sabdar * Print the V3 connection mover info.
4302654012Reza Sabdar */
4312654012Reza Sabdarstatic void
4322654012Reza Sabdarndmp_connect_print_mover_v3(ndmp_session_info_t *si)
4332654012Reza Sabdar{
4342654012Reza Sabdar	switch (si->nsi_mover.nm_state) {
4352654012Reza Sabdar	case NDMP_MV_STATE_IDLE:
4362654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.state:\t\tIdle\n"));
4372654012Reza Sabdar		break;
4382654012Reza Sabdar	case NDMP_MV_STATE_LISTEN:
4392654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.state:\t\tListen\n"));
4402654012Reza Sabdar		break;
4412654012Reza Sabdar	case NDMP_MV_STATE_ACTIVE:
4422654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.state:\t\tActive\n"));
4432654012Reza Sabdar		break;
4442654012Reza Sabdar	case NDMP_MV_STATE_PAUSED:
4452654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.state:\t\tPaused\n"));
4462654012Reza Sabdar		break;
4472654012Reza Sabdar	case NDMP_MV_STATE_HALTED:
4482654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.state:\t\tHalted\n"));
4492654012Reza Sabdar		break;
4502654012Reza Sabdar	default:
4512654012Reza Sabdar		(void) fprintf(stdout,
4522654012Reza Sabdar		    gettext("\tmover.state:\t\tUnknown (0x%x)\n"),
4532654012Reza Sabdar		    si->nsi_mover.nm_state);
4542654012Reza Sabdar	}
4552654012Reza Sabdar
4562654012Reza Sabdar	switch (si->nsi_mover.nm_mode) {
4572654012Reza Sabdar	case NDMP_MV_MODE_READ:
4582654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.mode:\t\tRead\n"));
4592654012Reza Sabdar		break;
4602654012Reza Sabdar	case NDMP_MV_MODE_WRITE:
4612654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.mode:\t\tWrite\n"));
4622654012Reza Sabdar		break;
4632654012Reza Sabdar	default:
4642654012Reza Sabdar		(void) fprintf(stdout,
4652654012Reza Sabdar		    gettext("\tmover.mode:\t\tUnknown (0x%x)\n"),
4662654012Reza Sabdar		    si->nsi_mover.nm_mode);
4672654012Reza Sabdar	}
4682654012Reza Sabdar
4692654012Reza Sabdar	switch (si->nsi_mover.nm_pause_reason) {
4702654012Reza Sabdar	case NDMP_MV_PAUSE_NA:
4712654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.pause reason:\tN/A\n"));
4722654012Reza Sabdar		break;
4732654012Reza Sabdar	case NDMP_MV_PAUSE_EOM:
4742654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.pause reason:\tEOM\n"));
4752654012Reza Sabdar		break;
4762654012Reza Sabdar	case NDMP_MV_PAUSE_EOF:
4772654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.pause reason:\tEOF\n"));
4782654012Reza Sabdar		break;
4792654012Reza Sabdar	case NDMP_MV_PAUSE_SEEK:
4802654012Reza Sabdar		(void) fprintf(stdout,
4812654012Reza Sabdar		    gettext("\tmover.pause reason:\tSeek\n"));
4822654012Reza Sabdar		break;
4832654012Reza Sabdar	case NDMP_MV_PAUSE_MEDIA_ERROR:
4842654012Reza Sabdar		(void) fprintf(stdout,
4852654012Reza Sabdar		    gettext("\tmover.pause reason:\tMedia Error\n"));
4862654012Reza Sabdar		break;
4872654012Reza Sabdar	case NDMP_MV_PAUSE_EOW:
4882654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.pause reason:\tEOW\n"));
4892654012Reza Sabdar		break;
4902654012Reza Sabdar	default:
4912654012Reza Sabdar		(void) fprintf(stdout,
4922654012Reza Sabdar		    gettext("\tmover.pause reason:\tUnknown (0x%x)\n"),
4932654012Reza Sabdar		    si->nsi_mover.nm_pause_reason);
4942654012Reza Sabdar	}
4952654012Reza Sabdar
4962654012Reza Sabdar	switch (si->nsi_mover.nm_halt_reason) {
4972654012Reza Sabdar	case NDMP_MV_HALT_NA:
4982654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.halt reason:\tN/A\n"));
4992654012Reza Sabdar		break;
5002654012Reza Sabdar	case NDMP_MV_HALT_CONNECT_CLOSED:
5012654012Reza Sabdar		(void) fprintf(stdout,
5022654012Reza Sabdar		    gettext("\tmover.halt reason:\tConnection closed\n"));
5032654012Reza Sabdar		break;
5042654012Reza Sabdar	case NDMP_MV_HALT_ABORTED:
5052654012Reza Sabdar		(void) fprintf(stdout,
5062654012Reza Sabdar		    gettext("\tmover.halt reason:\tAborted\n"));
5072654012Reza Sabdar		break;
5082654012Reza Sabdar	case NDMP_MV_HALT_INTERNAL_ERROR:
5092654012Reza Sabdar		(void) fprintf(stdout,
5102654012Reza Sabdar		    gettext("\tmover.halt reason:\tInternal error\n"));
5112654012Reza Sabdar		break;
5122654012Reza Sabdar	case NDMP_MV_HALT_CONNECT_ERROR:
5132654012Reza Sabdar		(void) fprintf(stdout,
5142654012Reza Sabdar		    gettext("\tmover.halt reason:\tConnection error\n"));
5152654012Reza Sabdar		break;
5162654012Reza Sabdar	default:
5172654012Reza Sabdar		(void) fprintf(stdout,
5182654012Reza Sabdar		    gettext("\tmover.halt reason:\tUnknown (0x%x)\n"),
5192654012Reza Sabdar		    si->nsi_mover.nm_halt_reason);
5202654012Reza Sabdar	}
5212654012Reza Sabdar
5222654012Reza Sabdar	(void) fprintf(stdout, gettext("\tmover.record size:\t%d\n"),
5232654012Reza Sabdar	    (int)si->nsi_mover.nm_rec_size);
5242654012Reza Sabdar	(void) fprintf(stdout, gettext("\tmover.record number:\t%d\n"),
5252654012Reza Sabdar	    (int)si->nsi_mover.nm_rec_num);
5262654012Reza Sabdar	(void) fprintf(stdout, gettext("\tmover.pos:\t\t%lld\n"),
5272654012Reza Sabdar	    si->nsi_mover.nm_mov_pos, si->nsi_mover.nm_mov_pos);
5282654012Reza Sabdar
5292654012Reza Sabdar	(void) fprintf(stdout, gettext("\tmover.win len:\t\t%lld\n"),
5302654012Reza Sabdar	    si->nsi_mover.nm_window_length, si->nsi_mover.nm_window_length);
5312654012Reza Sabdar
5322654012Reza Sabdar	(void) fprintf(stdout, gettext("\tmover.win off:\t\t%lld\n"),
5332654012Reza Sabdar	    si->nsi_mover.nm_window_offset);
5342654012Reza Sabdar	switch (si->nsi_mover.nm_state) {
5352654012Reza Sabdar	case NDMP_MV_STATE_IDLE:
5362654012Reza Sabdar		if (si->nsi_mover.nm_listen_sock != -1)
5372654012Reza Sabdar			(void) fprintf(stdout,
5382654012Reza Sabdar			    gettext("\tmover.listenSock:\t%d\n"),
5392654012Reza Sabdar			    si->nsi_mover.nm_listen_sock);
5402654012Reza Sabdar		if (si->nsi_mover.nm_sock != -1)
5412654012Reza Sabdar			(void) fprintf(stdout, gettext("\tmover.sock:\t%d\n"),
5422654012Reza Sabdar			    si->nsi_mover.nm_sock);
5432654012Reza Sabdar		break;
5442654012Reza Sabdar	case NDMP_MV_STATE_LISTEN:
5452654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.listen socket:\t%d\n"),
5462654012Reza Sabdar		    si->nsi_mover.nm_listen_sock);
5472654012Reza Sabdar		ndmp_tprint_addr(gettext("mover.listen"),
5482654012Reza Sabdar		    si->nsi_mover.nm_addr_type, si->nsi_mover.nm_tcp_addr);
5492654012Reza Sabdar		break;
5502654012Reza Sabdar	case NDMP_MV_STATE_ACTIVE:
5512654012Reza Sabdar	case NDMP_MV_STATE_PAUSED:
5522654012Reza Sabdar	case NDMP_MV_STATE_HALTED:
5532654012Reza Sabdar		(void) fprintf(stdout, gettext("\tmover.data socket:\t%d\n"),
5542654012Reza Sabdar		    si->nsi_mover.nm_sock);
5552654012Reza Sabdar		ndmp_tprint_addr(gettext("mover.data connection"),
5562654012Reza Sabdar		    si->nsi_mover.nm_addr_type, si->nsi_mover.nm_tcp_addr);
5572654012Reza Sabdar		break;
5582654012Reza Sabdar	}
5592654012Reza Sabdar}
5602654012Reza Sabdar
5612654012Reza Sabdar/*
5622654012Reza Sabdar * Print the connection data info.
5632654012Reza Sabdar */
5642654012Reza Sabdarstatic void
5652654012Reza Sabdarndmp_connect_print_data_v3(ndmp_session_info_t *si)
5662654012Reza Sabdar{
5672654012Reza Sabdar	int i;
5682654012Reza Sabdar	ndmp_dt_name_v3_t *np;
5692654012Reza Sabdar
5702654012Reza Sabdar	switch (si->nsi_data.nd_oper) {
5712654012Reza Sabdar	case NDMP_DT_OP_NOACTION:
5722654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.operation:\t\tNone\n"));
5732654012Reza Sabdar		break;
5742654012Reza Sabdar	case NDMP_DT_OP_BACKUP:
5752654012Reza Sabdar		(void) fprintf(stdout,
5762654012Reza Sabdar		    gettext("\tdata.operation:\t\tBackup\n"));
5772654012Reza Sabdar		break;
5782654012Reza Sabdar	case NDMP_DT_OP_RECOVER:
5792654012Reza Sabdar		(void) fprintf(stdout,
5802654012Reza Sabdar		    gettext("\tdata.operation:\t\tRestore\n"));
5812654012Reza Sabdar		break;
5822654012Reza Sabdar	default:
5832654012Reza Sabdar		(void) fprintf(stdout,
5842654012Reza Sabdar		    gettext("\tdata.operation:\t\tUnknown (0x%x)\n"),
5852654012Reza Sabdar		    si->nsi_data.nd_oper);
5862654012Reza Sabdar	}
5872654012Reza Sabdar
5882654012Reza Sabdar	switch (si->nsi_data.nd_state) {
5892654012Reza Sabdar	case NDMP_DT_STATE_IDLE:
5902654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.state:\t\tIdle\n"));
5912654012Reza Sabdar		break;
5922654012Reza Sabdar	case NDMP_DT_STATE_ACTIVE:
5932654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.state:\t\tActive\n"));
5942654012Reza Sabdar		break;
5952654012Reza Sabdar	case NDMP_DT_STATE_HALTED:
5962654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.state:\t\tHalted\n"));
5972654012Reza Sabdar		break;
5982654012Reza Sabdar	case NDMP_DT_STATE_LISTEN:
5992654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.state:\t\tListen\n"));
6002654012Reza Sabdar		break;
6012654012Reza Sabdar	case NDMP_DT_STATE_CONNECTED:
6022654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.state:\t\tConnected\n"));
6032654012Reza Sabdar		break;
6042654012Reza Sabdar	default:
6052654012Reza Sabdar		(void) fprintf(stdout,
6062654012Reza Sabdar		    gettext("\tdata.state:\t\tUnknown (0x%x)\n"),
6072654012Reza Sabdar		    si->nsi_data.nd_state);
6082654012Reza Sabdar	}
6092654012Reza Sabdar
6102654012Reza Sabdar	switch (si->nsi_data.nd_halt_reason) {
6112654012Reza Sabdar	case NDMP_DT_HALT_NA:
6122654012Reza Sabdar		(void) fprintf(stdout,
6132654012Reza Sabdar		    gettext("\tdata.halt reason:\tN/A\n"));
6142654012Reza Sabdar		break;
6152654012Reza Sabdar	case NDMP_DT_HALT_SUCCESSFUL:
6162654012Reza Sabdar		(void) fprintf(stdout,
6172654012Reza Sabdar		    gettext("\tdata.halt reason:\tSuccessful\n"));
6182654012Reza Sabdar		break;
6192654012Reza Sabdar	case NDMP_DT_HALT_ABORTED:
6202654012Reza Sabdar		(void) fprintf(stdout,
6212654012Reza Sabdar		    gettext("\tdata.halt reason:\tAborted\n"));
6222654012Reza Sabdar		break;
6232654012Reza Sabdar	case NDMP_DT_HALT_INTERNAL_ERROR:
6242654012Reza Sabdar		(void) fprintf(stdout,
6252654012Reza Sabdar		    gettext("\tdata.halt reason:\tInternal error\n"));
6262654012Reza Sabdar		break;
6272654012Reza Sabdar	case NDMP_DT_HALT_CONNECT_ERROR:
6282654012Reza Sabdar		(void) fprintf(stdout,
6292654012Reza Sabdar		    gettext("\tdata.halt reason:\tConnection error\n"));
6302654012Reza Sabdar		break;
6312654012Reza Sabdar	default:
6322654012Reza Sabdar		(void) fprintf(stdout,
6332654012Reza Sabdar		    gettext("\tdata.halt reason:\tUnknown (0x%x)\n"),
6342654012Reza Sabdar		    si->nsi_data.nd_halt_reason);
6352654012Reza Sabdar	}
6362654012Reza Sabdar
6372654012Reza Sabdar	switch (si->nsi_data.nd_state) {
6382654012Reza Sabdar	case NDMP_DT_STATE_IDLE:
6392654012Reza Sabdar		if (si->nsi_data.nd_sock != -1)
6402654012Reza Sabdar			(void) fprintf(stdout,
6412654012Reza Sabdar			    gettext("\tdata.data socket:\t%d\n"),
6422654012Reza Sabdar			    si->nsi_data.nd_sock);
6432654012Reza Sabdar		if (si->nsi_data.nd_nlist.nld_dt_v3.dv3_listen_sock != -1)
6442654012Reza Sabdar			(void) fprintf(stdout,
6452654012Reza Sabdar			    gettext("\tdata.data socket:\t%d\n"),
6462654012Reza Sabdar			    si->nsi_data.nd_nlist.nld_dt_v3.dv3_listen_sock);
6472654012Reza Sabdar		break;
6482654012Reza Sabdar	case NDMP_DT_STATE_LISTEN:
6492654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.listen socket:\t%d\n"),
6502654012Reza Sabdar		    si->nsi_data.nd_nlist.nld_dt_v3.dv3_listen_sock);
6512654012Reza Sabdar		ndmp_tprint_addr(gettext("data.listen"),
6522654012Reza Sabdar		    si->nsi_data.nd_addr_type, si->nsi_data.nd_tcp_addr);
6532654012Reza Sabdar		break;
6542654012Reza Sabdar	case NDMP_DT_STATE_ACTIVE:
6552654012Reza Sabdar	case NDMP_DT_STATE_HALTED:
6562654012Reza Sabdar	case NDMP_DT_STATE_CONNECTED:
6572654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.data socket:\t%d\n"),
6582654012Reza Sabdar		    si->nsi_data.nd_sock);
6592654012Reza Sabdar		ndmp_tprint_addr(gettext("data.data"),
6602654012Reza Sabdar		    si->nsi_data.nd_addr_type, si->nsi_data.nd_tcp_addr);
6612654012Reza Sabdar		break;
6622654012Reza Sabdar	}
6632654012Reza Sabdar
6642654012Reza Sabdar	(void) fprintf(stdout, gettext("\tdata.aborted:\t\t%s\n"),
6652654012Reza Sabdar	    B2S(si->nsi_data.nd_abort));
6662654012Reza Sabdar	(void) fprintf(stdout, gettext("\tdata.read offset:\t%llu\n"),
6672654012Reza Sabdar	    si->nsi_data.nd_read_offset);
6682654012Reza Sabdar	(void) fprintf(stdout, gettext("\tdata.read length:\t%llu\n"),
6692654012Reza Sabdar	    si->nsi_data.nd_read_length);
6702654012Reza Sabdar	(void) fprintf(stdout, gettext("\tdata.total size:\t%llu\n"),
6712654012Reza Sabdar	    si->nsi_data.nd_total_size);
6722654012Reza Sabdar	(void) fprintf(stdout,
6732654012Reza Sabdar	    gettext("\tdata.bytes processed:\t%lld\n"),
6742654012Reza Sabdar	    si->nsi_data.nd_nlist.nld_dt_v3.dv3_bytes_processed);
6752654012Reza Sabdar
6762654012Reza Sabdar	ndmp_print_env(si);
6772654012Reza Sabdar
6782654012Reza Sabdar	np = si->nsi_data.nd_nlist.nld_dt_v3.dv3_nlist;
6792654012Reza Sabdar	for (i = 0; np && i < si->nsi_data.nld_nlist_len; i++, np++) {
6802654012Reza Sabdar		(void) fprintf(stdout, gettext("\tdata.nlist[%d]:\tname:\n"),
6812654012Reza Sabdar		    i);
6822654012Reza Sabdar		if (np->nn3_opath)
6832654012Reza Sabdar			(void) fprintf(stdout,
6842654012Reza Sabdar			    gettext("\t\torig: \"%s\"\n"), np->nn3_opath);
6852654012Reza Sabdar		if (np->nn3_dpath)
6862654012Reza Sabdar			(void) fprintf(stdout,
6872654012Reza Sabdar			    gettext("\t\tdest: \"%s\"\n"), np->nn3_dpath);
6882654012Reza Sabdar		else
6892654012Reza Sabdar			(void) fprintf(stdout, gettext("\t\tdest:\n"));
6902654012Reza Sabdar		(void) fprintf(stdout,
6912654012Reza Sabdar		    gettext("\t\tnode: %lld\n"), np->nn3_node);
6922654012Reza Sabdar		(void) fprintf(stdout, gettext("\t\tfh_info: %lld\n"),
6932654012Reza Sabdar		    np->nn3_fh_info);
6942654012Reza Sabdar	}
6952654012Reza Sabdar}
6962654012Reza Sabdar
6972654012Reza Sabdar/*
6982654012Reza Sabdar * Print V3 connection info for given category.
6992654012Reza Sabdar */
7002654012Reza Sabdarstatic void
7012654012Reza Sabdarndmp_connect_print_v3(int cat, ndmp_session_info_t *si)
7022654012Reza Sabdar{
7032654012Reza Sabdar	if (cat & NDMP_CAT_SCSI)
7042654012Reza Sabdar		ndmp_connect_print_scsi_v2(si);
7052654012Reza Sabdar	if (cat & NDMP_CAT_TAPE)
7062654012Reza Sabdar		ndmp_connect_print_tape_v2(si);
7072654012Reza Sabdar	if (cat & NDMP_CAT_MOVER)
7082654012Reza Sabdar		ndmp_connect_print_mover_v3(si);
7092654012Reza Sabdar	if (cat & NDMP_CAT_DATA)
7102654012Reza Sabdar		ndmp_connect_print_data_v3(si);
7112654012Reza Sabdar}
7122654012Reza Sabdar
7132654012Reza Sabdar/*
7142654012Reza Sabdar * Print the list of all active sessions to the clients.  For each version,
7152654012Reza Sabdar * call the appropriate print function.
7162654012Reza Sabdar */
7172654012Reza Sabdarstatic void
7182654012Reza Sabdarndmp_connection_print(int cat, ndmp_session_info_t *si)
7192654012Reza Sabdar{
7202654012Reza Sabdar	switch (si->nsi_pver) {
7212654012Reza Sabdar	case NDMP_V2:
7222654012Reza Sabdar		ndmp_connect_print_conn(si);
7232654012Reza Sabdar		ndmp_connect_print_v2(cat, si);
7242654012Reza Sabdar		break;
7252654012Reza Sabdar	case NDMP_V3:
7262654012Reza Sabdar	case NDMP_V4:
7272654012Reza Sabdar		ndmp_connect_print_conn(si);
7282654012Reza Sabdar		ndmp_connect_print_v3(cat, si);
7292654012Reza Sabdar		break;
7302654012Reza Sabdar	default:
7312654012Reza Sabdar		(void) fprintf(stdout,
7322654012Reza Sabdar		    gettext("Invalid version %d"), si->nsi_pver);
7332654012Reza Sabdar	}
7342654012Reza Sabdar}
7352654012Reza Sabdar
7362654012Reza Sabdar/*
7372654012Reza Sabdar * Print the list of all active sessions to the clients.
7382654012Reza Sabdar */
7392654012Reza Sabdarvoid
7402654012Reza Sabdarndmp_session_all_print(int cat, ndmp_session_info_t *si, size_t num)
7412654012Reza Sabdar{
7422654012Reza Sabdar	int i;
7432654012Reza Sabdar	ndmp_session_info_t *sp;
7442654012Reza Sabdar
7452654012Reza Sabdar	sp = si;
7462654012Reza Sabdar	for (i = 0; i < num; i++, sp++) {
7472654012Reza Sabdar		ndmp_connection_print(cat, sp);
7482654012Reza Sabdar		(void) fprintf(stdout, "\n");
7492654012Reza Sabdar	}
7502654012Reza Sabdar
7512654012Reza Sabdar	if (num == 0) {
7522654012Reza Sabdar		(void) fprintf(stdout, gettext("No active session.\n"));
7532654012Reza Sabdar	} else {
7542654012Reza Sabdar		(void) fprintf(stdout, gettext("%d active sessions.\n"), num);
7552654012Reza Sabdar	}
7562654012Reza Sabdar}
7572654012Reza Sabdar
7582654012Reza Sabdar/*
7592654012Reza Sabdar * Print the connection information for the given category.
7602654012Reza Sabdar */
7612654012Reza Sabdarvoid
7622654012Reza Sabdarndmp_session_print(int cat,  ndmp_session_info_t *si)
7632654012Reza Sabdar{
7642654012Reza Sabdar	ndmp_connection_print(cat, si);
7652654012Reza Sabdar}
7662654012Reza Sabdar
7672654012Reza Sabdarvoid
7682654012Reza Sabdarndmp_devinfo_print(ndmp_devinfo_t *dip, size_t size)
7692654012Reza Sabdar{
7702654012Reza Sabdar	int i;
7712654012Reza Sabdar
7722654012Reza Sabdar	if (dip == NULL) {
7732654012Reza Sabdar		(void) fprintf(stdout, gettext("No device attached.\n"));
7742654012Reza Sabdar		return;
7752654012Reza Sabdar	}
7762654012Reza Sabdar
7772654012Reza Sabdar	for (i = 0; i < size; i++, dip++) {
778e461e79Randall Ralphs		/*
779e461e79Randall Ralphs		 * Don't print dead links.
780e461e79Randall Ralphs		 */
781e461e79Randall Ralphs		if ((access(dip->nd_name, F_OK) == -1) && (errno == ENOENT))
782e461e79Randall Ralphs			continue;
7832654012Reza Sabdar		switch (dip->nd_dev_type) {
7842654012Reza Sabdar		case NDMP_SINQ_TAPE_ROBOT:
7852654012Reza Sabdar			(void) fprintf(stdout, gettext("Robot (Changer):\n"));
7862654012Reza Sabdar			break;
7872654012Reza Sabdar		case NDMP_SINQ_SEQ_ACCESS_DEVICE:
7882654012Reza Sabdar			(void) fprintf(stdout, gettext("Tape drive(s):\n"));
7892654012Reza Sabdar			break;
7902654012Reza Sabdar		}
7912654012Reza Sabdar		if (dip->nd_name)
7922654012Reza Sabdar			(void) fprintf(stdout,
7932654012Reza Sabdar			    gettext("\tName      : %s\n"), dip->nd_name);
7942654012Reza Sabdar		(void) fprintf(stdout,
7952654012Reza Sabdar		    gettext("\tLUN #     : %d\n"), dip->nd_lun);
7962654012Reza Sabdar		(void) fprintf(stdout,
7972654012Reza Sabdar		    gettext("\tSCSI ID # : %d\n"), dip->nd_sid);
7982654012Reza Sabdar		if (dip->nd_vendor)
7992654012Reza Sabdar			(void) fprintf(stdout,
8002654012Reza Sabdar			    gettext("\tVendor    : %s\n"), dip->nd_vendor);
8012654012Reza Sabdar		if (dip->nd_product)
8022654012Reza Sabdar			(void) fprintf(stdout,
8032654012Reza Sabdar			    gettext("\tProduct   : %s\n"), dip->nd_product);
8042654012Reza Sabdar		if (dip->nd_revision)
8052654012Reza Sabdar			(void) fprintf(stdout,
8062654012Reza Sabdar			    gettext("\tRevision  : %s\n"), dip->nd_revision);
8077bc22e4Reza Sabdar		if (dip->nd_serial)
8087bc22e4Reza Sabdar			(void) fprintf(stdout,
8097bc22e4Reza Sabdar			    gettext("\tSerial    : %s\n"), dip->nd_serial);
8107bc22e4Reza Sabdar		if (dip->nd_wwn)
8117bc22e4Reza Sabdar			(void) fprintf(stdout,
8127bc22e4Reza Sabdar			    gettext("\tWWN       : %s\n"), dip->nd_wwn);
8132654012Reza Sabdar		(void) fprintf(stdout, "\n");
8142654012Reza Sabdar	}
8152654012Reza Sabdar}
816