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