Exemplo n.º 1
0
static void
pdu_send_proxy(struct pdu *pdu)
{
	struct iscsi_daemon_send *ids;
	int error;

	assert(pdu->pdu_connection->conn_conf.isc_iser != 0);

	pdu_set_data_segment_length(pdu, pdu->pdu_data_len);

	ids = calloc(1, sizeof(*ids));
	if (ids == NULL)
		log_err(1, "calloc");

	ids->ids_session_id = pdu->pdu_connection->conn_session_id;
	ids->ids_bhs = pdu->pdu_bhs;
	ids->ids_data_segment_len = pdu->pdu_data_len;
	ids->ids_data_segment = pdu->pdu_data;

	error = ioctl(pdu->pdu_connection->conn_iscsi_fd, ISCSIDSEND, ids);
	if (error != 0)
		log_err(1, "ISCSIDSEND");

	free(ids);
}
Exemplo n.º 2
0
Arquivo: pdu.c Projeto: 2asoft/freebsd
static void
pdu_send_proxy(struct pdu *pdu)
{

	assert(proxy_mode);

	pdu_set_data_segment_length(pdu, pdu->pdu_data_len);
	kernel_send(pdu);
}
Exemplo n.º 3
0
void
pdu_send(struct pdu *pdu)
{
	struct connection *conn;
	ssize_t ret, total_len;
	size_t padding;
	uint32_t zero = 0;
	struct iovec iov[3];
	int iovcnt;

	conn = pdu->pdu_connection;
#ifdef ICL_KERNEL_PROXY
	if (conn->conn_conf.isc_iser != 0)
		return (pdu_send_proxy(pdu));
#endif

	assert(conn->conn_conf.isc_iser == 0);

	pdu_set_data_segment_length(pdu, pdu->pdu_data_len);
	iov[0].iov_base = pdu->pdu_bhs;
	iov[0].iov_len = sizeof(*pdu->pdu_bhs);
	total_len = iov[0].iov_len;
	iovcnt = 1;

	if (pdu->pdu_data_len > 0) {
		iov[1].iov_base = pdu->pdu_data;
		iov[1].iov_len = pdu->pdu_data_len;
		total_len += iov[1].iov_len;
		iovcnt = 2;

		padding = pdu_padding(pdu);
		if (padding > 0) {
			assert(padding < sizeof(zero));
			iov[2].iov_base = &zero;
			iov[2].iov_len = padding;
			total_len += iov[2].iov_len;
			iovcnt = 3;
		}
	}

	ret = writev(conn->conn_socket, iov, iovcnt);
	if (ret < 0) {
		if (timed_out())
			log_errx(1, "exiting due to timeout");
		log_err(1, "writev");
	}
	if (ret != total_len)
		log_errx(1, "short write");
}