Blame libopeniscsiusr/default.c

Packit Service 646995
/*
Packit Service 646995
 * Copyright (C) 2017-2018 Red Hat, Inc.
Packit Service 646995
 *
Packit Service 646995
 * This program is free software: you can redistribute it and/or modify
Packit Service 646995
 * it under the terms of the GNU General Public License as published by
Packit Service 646995
 * the Free Software Foundation, either version 3 of the License, or
Packit Service 646995
 * (at your option) any later version.
Packit Service 646995
 *
Packit Service 646995
 * This program is distributed in the hope that it will be useful,
Packit Service 646995
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 646995
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 646995
 * GNU General Public License for more details.
Packit Service 646995
 *
Packit Service 646995
 * You should have received a copy of the GNU General Public License
Packit Service 646995
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit Service 646995
 *
Packit Service 646995
 * Author: Gris Ge <fge@redhat.com>
Packit Service 646995
 */
Packit Service 646995
Packit Service 646995
#include <string.h>
Packit Service 646995
Packit Service 646995
#include "libopeniscsiusr/libopeniscsiusr.h"
Packit Service 646995
#include "default.h"
Packit Service 646995
#include "iface.h"
Packit Service 646995
#include "node.h"
Packit Service 646995
Packit Service 646995
#define CONFIG_DIGEST_NEVER	0
Packit Service 646995
Packit Service 646995
static void default_session_op_cfg(struct iscsi_session_op_cfg *op_cfg)
Packit Service 646995
{
Packit Service 646995
	op_cfg->InitialR2T = 0;
Packit Service 646995
	op_cfg->ImmediateData = 1;
Packit Service 646995
	op_cfg->FirstBurstLength = DEF_INI_FIRST_BURST_LEN;
Packit Service 646995
	op_cfg->MaxBurstLength = DEF_INI_MAX_BURST_LEN;
Packit Service 646995
	op_cfg->DefaultTime2Wait = ISCSI_DEF_TIME2WAIT;
Packit Service 646995
	op_cfg->DefaultTime2Retain = 0;
Packit Service 646995
	op_cfg->MaxConnections = 1;
Packit Service 646995
	op_cfg->MaxOutstandingR2T = 1;
Packit Service 646995
	op_cfg->ERL = 0;
Packit Service 646995
	op_cfg->FastAbort = 1;
Packit Service 646995
}
Packit Service 646995
Packit Service 646995
static void default_conn_op_cfg(struct iscsi_conn_op_cfg *op_cfg)
Packit Service 646995
{
Packit Service 646995
	op_cfg->MaxXmitDataSegmentLength = 0;
Packit Service 646995
	op_cfg->MaxRecvDataSegmentLength = DEF_INI_MAX_RECV_SEG_LEN;
Packit Service 646995
	op_cfg->HeaderDigest = DIGEST_NEVER;
Packit Service 646995
	op_cfg->DataDigest = DIGEST_NEVER;
Packit Service 646995
	op_cfg->IFMarker = 0;
Packit Service 646995
	op_cfg->OFMarker = 0;
Packit Service 646995
}
Packit Service 646995
Packit Service 646995
/*
Packit Service 646995
 * default is to use tcp through whatever the network layer
Packit Service 646995
 * selects for us with the /etc/iscsi/initiatorname.iscsi iname.
Packit Service 646995
 */
Packit Service 646995
static void default_iface(struct iscsi_iface *iface)
Packit Service 646995
{
Packit Service 646995
	snprintf(iface->transport_name,
Packit Service 646995
		 sizeof(iface->transport_name)/sizeof(char),
Packit Service 646995
		 DEFAULT_TRANSPORT);
Packit Service 646995
Packit Service 646995
	if (!strlen(iface->name))
Packit Service 646995
		snprintf(iface->name, sizeof(iface->name)/sizeof(char),
Packit Service 646995
			 DEFAULT_IFACENAME);
Packit Service 646995
}
Packit Service 646995
Packit Service 646995
void _default_node(struct iscsi_node *node)
Packit Service 646995
{
Packit Service 646995
	node->tpgt = PORTAL_GROUP_TAG_UNKNOWN;
Packit Service 646995
	node->disc_type = DISCOVERY_TYPE_STATIC;
Packit Service 646995
	node->leading_login = 0;
Packit Service 646995
	node->session.cmds_max = CMDS_MAX;
Packit Service 646995
	node->session.xmit_thread_priority = XMIT_THREAD_PRIORITY;
Packit Service 646995
	node->session.initial_cmdsn = 0;
Packit Service 646995
	node->session.queue_depth = QUEUE_DEPTH;
Packit Service 646995
	node->session.nr_sessions = 1;
Packit Service 646995
	node->session.initial_login_retry_max = DEF_INITIAL_LOGIN_RETRIES_MAX;
Packit Service 646995
	node->session.reopen_max = DEF_SESSION_REOPEN_MAX;
Packit Service 646995
	node->session.auth.authmethod = 0;
Packit Service 646995
	/* TYPE_INT_LIST fields should be initialized to ~0 to indicate unset values */
Packit Service 646995
	memset(node->session.auth.chap_algs, ~0, sizeof(node->session.auth.chap_algs));
Packit Service 646995
	node->session.auth.chap_algs[0] = ISCSI_AUTH_CHAP_ALG_MD5;
Packit Service 646995
	node->session.auth.password_length = 0;
Packit Service 646995
	node->session.auth.password_in_length = 0;
Packit Service 646995
	node->session.err_tmo.abort_timeout = DEF_ABORT_TIMEO;
Packit Service 646995
	node->session.err_tmo.lu_reset_timeout = DEF_LU_RESET_TIMEO;
Packit Service 646995
	node->session.err_tmo.tgt_reset_timeout = DEF_TGT_RESET_TIMEO;
Packit Service 646995
	node->session.err_tmo.host_reset_timeout = DEF_HOST_RESET_TIMEO;
Packit Service 646995
	node->session.tmo.replacement_timeout = DEF_REPLACEMENT_TIMEO;
Packit Service 646995
	node->session.se = NULL;
Packit Service 646995
	node->session.sid = 0;
Packit Service 646995
	node->session.multiple = 0;
Packit Service 646995
	node->session.scan = DEF_INITIAL_SCAN;
Packit Service 646995
Packit Service 646995
	default_session_op_cfg(&node->session.op_cfg);
Packit Service 646995
Packit Service 646995
	node->conn.startup = ISCSI_STARTUP_MANUAL;
Packit Service 646995
	node->conn.port = ISCSI_DEFAULT_PORT;
Packit Service 646995
	node->conn.tcp.window_size = TCP_WINDOW_SIZE;
Packit Service 646995
	node->conn.tcp.type_of_service = 0;
Packit Service 646995
	node->conn.tmo.login_timeout= DEF_LOGIN_TIMEO;
Packit Service 646995
	node->conn.tmo.logout_timeout= DEF_LOGOUT_TIMEO;
Packit Service 646995
	node->conn.tmo.auth_timeout = 45;
Packit Service 646995
	node->conn.tmo.noop_out_interval = DEF_NOOP_OUT_INTERVAL;
Packit Service 646995
	node->conn.tmo.noop_out_timeout = DEF_NOOP_OUT_TIMEO;
Packit Service 646995
Packit Service 646995
	default_conn_op_cfg(&node->conn.op_cfg);
Packit Service 646995
Packit Service 646995
	default_iface(&node->iface);
Packit Service 646995
}