int ndmca_test_call (struct ndmconn *conn, struct ndmp_xa_buf *xa, ndmp9_error expect_err) { struct ndm_session *sess = conn->context; int protocol_version = conn->protocol_version; unsigned msg = xa->request.header.message; char * msgname = ndmp_message_to_str (protocol_version, msg); unsigned reply_error; int rc; /* close previous test if there is one */ ndmca_test_close (sess); /* open new 'test' */ ndmca_test_open (sess, msgname, ndmp9_error_to_str (expect_err)); rc = ndma_call_no_tattle (conn, xa); reply_error = ndmnmb_get_reply_error (&xa->reply); if (rc >= 0) { /* Call succeeded. Body valid */ if (reply_error == expect_err) { /* Worked exactly as expected */ rc = 0; } else if (reply_error != NDMP9_NO_ERR && expect_err != NDMP9_NO_ERR) { /* both are errors, don't be picky about the codes */ rc = 2; } else { /* intolerable mismatch */ rc = 1; } } if (rc != 0) { char tmpbuf[128]; sprintf(tmpbuf, "got %s (call)", ndmp9_error_to_str (reply_error)); if (rc == 2) ndmca_test_warn (sess, tmpbuf); else ndmca_test_fail (sess, tmpbuf); ndma_tattle (conn, xa, rc); if (rc == 2) rc = 0; } return rc; }
int ndmca_tape_get_state_no_tattle (struct ndm_session *sess) { struct ndmconn * conn = sess->plumb.tape; struct ndm_control_agent *ca = &sess->control_acb; struct ndmp9_tape_get_state_reply *state = &ca->tape_state; int rc; NDMC_WITH_VOID_REQUEST(ndmp9_tape_get_state, NDMP9VER) rc = ndma_call_no_tattle (conn, xa); if (rc) { NDMOS_MACRO_ZEROFILL (state); /* tape_state.state = -1; */ } else { *state = *reply; } if (rc < 0 || (reply->error != NDMP9_DEV_NOT_OPEN_ERR && reply->error != NDMP9_NO_ERR)) ndma_tattle (sess->plumb.tape, xa, rc); NDMC_ENDWITH return rc; }