Exemplo n.º 1
0
/*
 * inf_connect_client_auth() Test the ndmp NDMP_CONNECT_CLIENT_AUTH interface
 * for different error condition. This request authenticates the DMA to a
 * NDMP Server. Successful DMA authentication MUST occur prior to processing
 * most NDMP requests. Requests that do not require DMA authentication are
 * limited to NDMP_CONNECT_OPEN, NDMP_CONNECT_CLOSE,
 * NDMP_CONFIG_GET_SERVER_INFO, NDMP_CONFIG_GET_AUTH_ATTR and
 * NDMP_CONNECT_CLIENT_AUTH. Any other request received prior to successful
 * DMA authentication will result in a NDMP_NOT_AUTHORIZED reply error.
 *
 * Arguments : error - Error condition to test. host_details - Information about
 * the host. outfile - log file.
 *
 * Return : 0 - Success 1 - Error
 */
int
inf_connect_client_auth(ndmp_error error, host_info * host_details,
			FILE * outfile)
{
	conn_handle conn;
	ndmp_connect_open_reply *reply = NULL;
	ndmp_connect_client_auth_reply *reply_ca = NULL;

	(void) ndmp_fprintf(outfile,
		"Test case name : ndmp_connect_client_auth\n");
	(void) ndmp_fprintf(outfile,
		"Error condition : %s\n", ndmpErrorCodeToStr(error));
	client_connect_open(host_details, &conn, &reply, outfile);
	if (reply->error != NDMP_NO_ERR) {
		(void) ndmp_dprintf(outfile, "inf_connect_client_auth: "
			"Not able to open connection \n");
		print_test_result(1, outfile);
		return (1);
	}
	client_connect_authorize(host_details, &conn, &reply_ca, outfile);
	if (reply_ca != NULL && reply_ca->error == error) {
		print_test_result(0, outfile);
	} else {
		print_test_result(1, outfile);
	}
	close_connection(&conn, outfile);
	return (0);
}
Exemplo n.º 2
0
/*
 * ndmp_config_set_ext_list_reply_print() :
 * Prints the reply object structure. This object gets
 * printed twice in the program, once when it comes
 * from the ndmp server and second time, the expected
 * reply
 *
 * Arguments :
 * 		FILE * - Log file handle.
 * 		void *ndmpMsg - Ndmp message object got from
 * 		the ndmp server response.
 *
 */
void
ndmp_config_set_ext_list_reply_print(FILE *out, void *ndmpMsg)
{
	ndmp_config_set_ext_list_reply	*reply;

	reply = (ndmp_config_set_ext_list_reply*)ndmpMsg;

	if (reply != 0) {
	(void) fprintf(out, "error %s \n", ndmpErrorCodeToStr(reply->error));
	}
}
Exemplo n.º 3
0
/*
 * ndmp_config_get_auth_attr_reply_print() :
 * Prints the reply object structure. This object gets
 * printed twice in the program, once when it comes
 * from the ndmp server and second time, the expected
 * reply
 *
 * Arguments :
 * 		FILE * - Log file handle.
 * 		void *ndmpMsg - Ndmp message object got from
 * 		the ndmp server response.
 *
 */
void
ndmp_config_get_auth_attr_reply_print(FILE *out, void *ndmpMsg)
{
	ndmp_config_get_auth_attr_reply	*reply;

	reply = (ndmp_config_get_auth_attr_reply*)ndmpMsg;

	if (reply != 0) {
	(void) fprintf(out, "error %s \n", ndmpErrorCodeToStr(reply->error));
	print_ndmp_auth_attr(out, &(reply->server_attr));
	}
}
Exemplo n.º 4
0
/*
 * ndmp_config_get_butype_info_reply_print() :
 * Prints the reply object structure. This object gets
 * printed twice in the program, once when it comes
 * from the ndmp server and second time, the expected
 * reply
 *
 * Arguments :
 * 		FILE * - Log file handle.
 * 		void *ndmpMsg - Ndmp message object got from
 * 		the ndmp server response.
 *
 */
void
ndmp_config_get_butype_info_reply_print(FILE *out, void *ndmpMsg)
{
	ndmp_config_get_butype_attr_reply	*reply;
	reply = (ndmp_config_get_butype_attr_reply*)ndmpMsg;

	if (reply != 0) {
	(void) fprintf(out, "error %s\n", ndmpErrorCodeToStr(reply->error));
	print_butype_info(out, (butype_info *)&(reply->butype_info));
	} else
	(void) fprintf(out,
	    "ndmp_config_get_butype_info_reply_print: obj is null\n");
}
Exemplo n.º 5
0
/*
 * ndmp_config_get_host_info_reply_print() :
 * Prints the reply object structure. This object gets
 * printed twice in the program, once when it comes
 * from the ndmp server and second time, the expected
 * reply
 *
 * Arguments :
 * 		FILE * - Log file handle.
 * 		void *ndmpMsg - Ndmp message object got from
 * 		the ndmp server response.
 *
 */
void
ndmp_config_get_host_info_reply_print(FILE *out, void *ndmpMsg)
{
	ndmp_config_get_host_info_reply *msg;

	msg = (ndmp_config_get_host_info_reply*)ndmpMsg;
	(void) fprintf(out, "error = %s\n", ndmpErrorCodeToStr(msg->error));
	(void) fprintf(out, "hostname = %s\n", msg->hostname);
	(void) fprintf(out, "os_type = %s\n", msg->os_type);
	(void) fprintf(out, "os_vers = %s\n",
	    msg->os_vers ? msg->os_vers : "msg->os_vers is null");
	(void) fprintf(out, "hostid = %s\n",
	    msg->hostid ? msg->hostid : "msg->hostid is null");
}
Exemplo n.º 6
0
/*
 * ndmp_config_get_connection_type_reply_print() :
 * Prints the reply object structure. This object gets
 * printed twice in the program, once when it comes
 * from the ndmp server and second time, the expected
 * reply
 *
 * Arguments :
 * 		FILE * - Log file handle.
 * 		void *ndmpMsg - Ndmp message object got from
 * 		the ndmp server response.
 *
 */
void
ndmp_config_get_connection_type_reply_print(FILE *out, void *ndmpMsg)
{
	ndmp_config_get_connection_type_reply	*reply;

	reply = (ndmp_config_get_connection_type_reply*)ndmpMsg;

	if (reply != 0) {

	(void) fprintf(out, "error %s \n", ndmpErrorCodeToStr(reply->error));
	print_addr_types(out, (addr_types *)&(reply->addr_types));

	}
}
Exemplo n.º 7
0
/*
 * ndmp_config_get_server_info_reply_print() :
 * Prints the reply object structure. This object gets
 * printed twice in the program, once when it comes
 * from the ndmp server and second time, the expected
 * reply
 *
 * Arguments :
 * 		FILE * - Log file handle.
 * 		void *ndmpMsg - Ndmp message object got from
 * 		the ndmp server response.
 *
 */
void
ndmp_config_get_server_info_reply_print(FILE *out, void *ndmpMsg)
{
	ndmp_config_get_server_info_reply *msg;

	msg = (ndmp_config_get_server_info_reply*)ndmpMsg;
	(void) fprintf(out, "error = %s\n", ndmpErrorCodeToStr(msg->error));
	(void) fprintf(out, "vendor_name = %s\n", msg->vendor_name);
	(void) fprintf(out, "product_name = %s\n", msg->product_name);
	(void) fprintf(out, "revision_number = %s\n",
	    msg->revision_number ? msg->revision_number :
	    "msg->revision_number is null");
	(void) fprintf(out, "auth_type.auth_type_len = %d\n",
	    msg->auth_type.auth_type_len);
}
Exemplo n.º 8
0
/*
 * ndmp_config_get_fs_info_reply_print() :
 * Prints the reply object structure. This object gets
 * printed twice in the program, once when it comes
 * from the ndmp server and second time, the expected
 * reply
 *
 * Arguments :
 * 		FILE * - Log file handle.
 * 		void *ndmpMsg - Ndmp message object got from
 * 		the ndmp server response.
 *
 */
void
ndmp_config_get_fs_info_reply_print(FILE *out, void *ndmpMsg)
{
	ndmp_config_get_fs_info_reply	*reply;

	reply = (ndmp_config_get_fs_info_reply*)ndmpMsg;

	if (reply != 0) {

	(void) fprintf(out, "error %s \n", ndmpErrorCodeToStr(reply->error));

	print_fs_info(out, (fs_info *)&(reply->fs_info));

	}
}
Exemplo n.º 9
0
/*
 * ndmp_config_get_scsi_info_reply_print() :
 * Prints the reply object structure. This object gets
 * printed twice in the program, once when it comes
 * from the ndmp server and second time, the expected
 * reply
 *
 * Arguments :
 * 		FILE * - Log file handle.
 * 		void *ndmpMsg - Ndmp message object got from
 * 		the ndmp server response.
 *
 */
void
ndmp_config_get_scsi_info_reply_print(FILE *out, void *ndmpMsg)
{
	ndmp_config_get_scsi_info_reply	*reply;

	reply = (ndmp_config_get_scsi_info_reply*)ndmpMsg;

	if (reply != NULL) {

	(void) fprintf(out, "error %s \n", ndmpErrorCodeToStr(reply->error));
	print_scsi_info(out, (scsi_info *)&(reply->scsi_info));

	} else
	(void) fprintf(out, "ndmp_config_get_scsi_info_reply_print: ");
	(void) fprintf(out, "obj is null\n");

}
Exemplo n.º 10
0
/*
 * inf_connect_open() Test the ndmp connect open interface for different
 * error condition. This message negotiates the protocol version to be used
 * between the DMA and NDMP Server. This message is OPTIONAL if the DMA
 * agrees to the protocol version specified in the
 * NDMP_NOTIFY_CONNECTION_STATUS message. If sent, it MUST be the first
 * message type sent by the DMA. If the suggested protocol version is not
 * supported on the NDMP Server, an NDMP_ILLEGAL_ARGS_ERR MUST be returned.
 *
 * Arguments : error - Error condition to test ndmp_ver - NDMP version to test.
 * Default is 4 outfile - log file
 *
 * Return : 0 - Success 1 - Error
 */
int
inf_connect_open(ndmp_error error, host_info * host_details, FILE * outfile)
{
	conn_handle conn;
	ndmp_connect_open_reply *reply = NULL;

	(void) ndmp_fprintf(outfile,
		"Test case name : ndmp_connect_open\n");
	(void) ndmp_fprintf(outfile,
		"Error condition : %s\n", ndmpErrorCodeToStr(error));
	if (error == NDMP_ILLEGAL_ARGS_ERR) {
		host_details->protocol_version = -1;
	}
	client_connect_open(host_details, &conn, &reply, outfile);
	if (error == NDMP_ILLEGAL_STATE_ERR) {
		ndmp_connect_client_auth_reply *reply_ca = NULL;
		client_connect_authorize(host_details,
						&conn, &reply_ca, outfile);
		if (reply_ca->error != NDMP_NO_ERR) {
			(void) ndmp_fprintf(outfile, "inf_connect_close: "
				"Not able to authorize connection \n");
			print_test_result(1, outfile);
			return (1);
		}
		if (data_listen_core(NDMP_NO_ERR, NDMP_ADDR_LOCAL,
			NULL, outfile, &conn)) {
			(void) ndmp_fprintf(outfile, "inf_connect_close: "
				"Not able to do data listen\n");
		}
		if (data_connect_core(NDMP_NO_ERR, NDMP_ADDR_LOCAL,
			NULL, outfile, &conn)) {
			(void) ndmp_fprintf(outfile, "inf_connect_close: "
				"Not able to do data connect\n");
		}
		client_connect_open(host_details, &conn, &reply, outfile);
	}
	if (reply->error == error)
		print_test_result(0, outfile);
	else
		print_test_result(1, outfile);
	close_connection(&conn, outfile);
	return (0);
}
Exemplo n.º 11
0
/*
 * inf_connect_server_auth() Test the ndmp NDMP_CONNECT_SERVER_AUTH interface
 * for different error condition. This optional request is used by the DMA to
 * force the NDMP Server to authenticate itself. The DMA may use this request
 * when there is a security requirement to validate the sever identity. A DMA
 * MUST authenticate itself to the server using the NDMP_CONNECT_CLIENT_AUTH
 * prior to issuing this request.
 *
 * Arguments : error - Error condition to test. host_details - Information about
 * the host. ndmp_ver - NDMP version to test. Default is 4. challenge -
 * Challenge string. outfile - log file.
 *
 * Return : 0 - Success 1 - Error
 */
int
inf_connect_server_auth(ndmp_error error, host_info * host_details,
			FILE * outfile)
{
	conn_handle conn;
	char *challenge = "bad";
	ndmp_connect_open_reply *reply = NULL;
	ndmp_connect_client_auth_reply *reply_ca = NULL;
	ndmp_connect_server_auth_reply *reply_sa = NULL;

	(void) ndmp_fprintf(outfile,
		"Test case name : ndmp_connect_server_auth\n");
	(void) ndmp_fprintf(outfile,
		"Error condition : %s\n", ndmpErrorCodeToStr(error));
	client_connect_open(host_details, &conn, &reply, outfile);
	if (reply->error != NDMP_NO_ERR) {
		(void) ndmp_dprintf(outfile, "inf_connect_server_auth: "
			"Not able to open connection \n");
		print_test_result(1, outfile);
		return (1);
	}
	client_connect_authorize(host_details, &conn, &reply_ca, outfile);
	if (reply_ca->error != NDMP_NO_ERR) {
		(void) ndmp_dprintf(outfile, "inf_connect_server_auth: "
			"Not able to authorize connection \n");
		print_test_result(1, outfile);
		return (1);
	}
	if (error == NDMP_ILLEGAL_ARGS_ERR &&
		host_details->server_challenge == NULL) {
		strcpy(host_details->server_challenge, challenge);
	}
	server_connect_auth(host_details, &conn, &reply_sa, outfile);
	if (reply_sa != NULL && reply_sa->error == error) {
		print_test_result(0, outfile);
	} else {
		print_test_result(1, outfile);
	}
	close_connection(&conn, outfile);
	return (0);
}