/*
* iSCSI driver for Linux
* Copyright (C) 2002 Cisco Systems, Inc.
* maintained by linux-iscsi-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* See the file COPYING included with this distribution for more details.
*
* $Id: iscsi-config.c,v 1.13 2005/01/11 03:47:08 mikenc Exp $
*
*/
#include "iscsi-sfnet.h"
#include "iscsi-hooks.h"
char *
get_iscsi_initiatorname(char *pathname)
{
FILE *f = NULL;
int c;
char *line, buffer[1024];
char *name = NULL;
if (!pathname) {
logmsg(AS_ERROR, "No pathname to load InitiatorName from");
return NULL;
}
/* get the InitiatorName */
if ((f = fopen(pathname, "r"))) {
while ((line = fgets(buffer, sizeof (buffer), f))) {
while (line && isspace(c = *line))
line++;
if (strncmp(line, "InitiatorName=", 14) == 0) {
char *end = line + 14;
/* the name is everything up to the first
* bit of whitespace
*/
while (*end && (!isspace(c = *end)))
end++;
if (isspace(c = *end))
*end = '\0';
if (end > line + 14)
name = strdup(line + 14);
}
}
fclose(f);
if (!name) {
logmsg(AS_ERROR,
"an InitiatorName is required, but "
"was not found in %s", pathname);
return NULL;
} else {
debugmsg(5, "InitiatorName=%s\n", name);
}
return name;
} else {
errormsg("cannot open InitiatorName configuration file %s",
pathname);
return NULL;
}
}
int
add_config_entry(struct iscsi_config *config, struct iscsi_config_entry *entry)
{
if (config == NULL || entry == NULL)
return 0;
if (config->head) {
entry->prev = config->tail;
entry->next = NULL;
config->tail->next = entry;
config->tail = entry;
} else {
entry->next = entry->prev = NULL;
config->head = config->tail = entry;
}
return 1;
}
int
remove_config_entry(struct iscsi_config *config,
struct iscsi_config_entry *entry)
{
if (config == NULL || entry == NULL)
return 0;
if (entry == config->head) {
config->head = entry->next;
if (config->head == NULL)
config->tail = NULL;
entry->next = entry->prev = NULL;
return 1;
} else if (entry == config->tail) {
entry->prev->next = NULL;
config->tail = entry->prev;
entry->next = entry->prev = NULL;
return 1;
} else if (entry->prev && entry->next) {
entry->prev->next = entry->next;
entry->next->prev = entry->prev;
entry->next = entry->prev = NULL;
return 1;
} else {
return 0;
}
}
void
free_config_entry(struct iscsi_config_entry *entry)
{
if (entry == NULL)
return;
switch (entry->type) {
case CONFIG_TYPE_SENDTARGETS:{
struct iscsi_sendtargets_config *sendtargets =
entry->config.sendtargets;
if (sendtargets->address) {
free(sendtargets->address);
sendtargets->address = NULL;
}
free(sendtargets);
entry->config.sendtargets = NULL;
break;
}
case CONFIG_TYPE_SLP:{
struct iscsi_slp_config *slp = entry->config.slp;
if (slp->interfaces) {
free(slp->interfaces);
slp->interfaces = NULL;
}
if (slp->address) {
free(slp->address);
slp->address = NULL;
}
if (slp->scopes) {
free(slp->scopes);
slp->scopes = NULL;
}
free(slp);
entry->config.slp = NULL;
break;
}
case CONFIG_TYPE_DISCOVERY_FILE:{
struct iscsi_discovery_file_config *file =
entry->config.file;
if (file->filename) {
free(file->filename);
file->filename = NULL;
}
if (file->address) {
free(file->address);
file->address = NULL;
}
if (file->port) {
free(file->port);
file->port = NULL;
}
free(file);
entry->config.file = NULL;
break;
}
case CONFIG_TYPE_TARGETNAME:{
struct iscsi_targetname_config *targetname =
entry->config.targetname;
if (targetname->TargetName)
free(targetname->TargetName);
free(targetname);
entry->config.targetname = NULL;
break;
}
case CONFIG_TYPE_SUBNET:{
struct iscsi_subnet_config *subnet =
entry->config.subnet;
if (subnet->address)
free(subnet->address);
free(subnet);
entry->config.subnet = NULL;
break;
}
default:
logmsg(AS_ERROR, "can't free unknown config entry %p type %u\n",
entry, entry->type);
break;
}
free(entry);
}
struct iscsi_auth_config *
entry_auth_options(struct iscsi_config_entry *entry)
{
if (entry == NULL)
return NULL;
switch (entry->type) {
case CONFIG_TYPE_SENDTARGETS:{
struct iscsi_sendtargets_config *sendtargets =
entry->config.sendtargets;
return &sendtargets->auth_options;
}
case CONFIG_TYPE_SLP:{
struct iscsi_slp_config *slp = entry->config.slp;
return &slp->auth_options;
}
case CONFIG_TYPE_DISCOVERY_FILE:{
struct iscsi_discovery_file_config *file =
entry->config.file;
return &file->auth_options;
}
case CONFIG_TYPE_TARGETNAME:{
#ifdef PER_TARGETNAME_AUTH
struct iscsi_targetname_config *targetname =
entry->config.targetname;
return &targetname->auth_options;
#else
/* disable configuring auth by TargetName for now,
* and always get the auth options at run-time
* from discovery
*/
return NULL;
#endif
}
case CONFIG_TYPE_SUBNET:{
return NULL;
}
default:
return NULL;
}
}
struct iscsi_connection_timeout_config *
entry_connection_timeout_options(struct iscsi_config_entry *entry)
{
if (entry == NULL)
return NULL;
switch (entry->type) {
case CONFIG_TYPE_SENDTARGETS:{
struct iscsi_sendtargets_config *sendtargets =
entry->config.sendtargets;
return &sendtargets->connection_timeout_options;
}
case CONFIG_TYPE_SLP:{
return NULL;
}
case CONFIG_TYPE_TARGETNAME:{
struct iscsi_targetname_config *targetname =
entry->config.targetname;
return &targetname->connection_timeout_options;
}
case CONFIG_TYPE_SUBNET:{
struct iscsi_subnet_config *subnet =
entry->config.subnet;
return &subnet->connection_timeout_options;
}
default:
return NULL;
}
}
struct iscsi_session_timeout_config *
entry_session_timeout_options(struct iscsi_config_entry *entry)
{
if (entry == NULL)
return NULL;
switch (entry->type) {
case CONFIG_TYPE_SENDTARGETS:{
return NULL;
}
case CONFIG_TYPE_SLP:{
return NULL;
}
case CONFIG_TYPE_TARGETNAME:{
struct iscsi_targetname_config *targetname =
entry->config.targetname;
return &targetname->session_timeout_options;
}
case CONFIG_TYPE_SUBNET:{
return NULL;
}
default:
return NULL;
}
}
struct iscsi_error_timeout_config *
entry_error_timeout_options(struct iscsi_config_entry *entry)
{
if (entry == NULL)
return NULL;
switch (entry->type) {
case CONFIG_TYPE_SENDTARGETS:{
return NULL;
}
case CONFIG_TYPE_SLP:{
return NULL;
}
case CONFIG_TYPE_TARGETNAME:{
struct iscsi_targetname_config *targetname =
entry->config.targetname;
return &targetname->error_timeout_options;
}
case CONFIG_TYPE_SUBNET:{
struct iscsi_subnet_config *subnet =
entry->config.subnet;
return &subnet->error_timeout_options;
}
default:
return NULL;
}
}
struct iscsi_tcp_config *
entry_tcp_options(struct iscsi_config_entry *entry)
{
if (entry == NULL)
return NULL;
switch (entry->type) {
case CONFIG_TYPE_SENDTARGETS:{
return NULL;
}
case CONFIG_TYPE_SLP:{
return NULL;
}
case CONFIG_TYPE_TARGETNAME:{
struct iscsi_targetname_config *targetname =
entry->config.targetname;
return &targetname->tcp_options;
}
case CONFIG_TYPE_SUBNET:{
struct iscsi_subnet_config *subnet =
entry->config.subnet;
return &subnet->tcp_options;
没有合适的资源?快使用搜索试试~ 我知道了~
linux-iscsi-4.0.2.gz_iscsi
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 126 浏览量
2022-09-20
15:25:02
上传
评论
收藏 187KB GZ 举报
温馨提示
共64个文件
c:26个
h:22个
makefile:2个
iSCSI协议在LINUX下的源码.源代码是IBM公布的.主要是结合其OSD设备用的.
资源详情
资源评论
资源推荐
收起资源包目录
linux-iscsi-4.0.2.gz (64个子文件)
linux-iscsi-4.0.2
misc
include
md5.h 1KB
string-buffer.h 2KB
string-buffer.c 6KB
md5.c 7KB
scripts
remove.sh 3KB
iscsi-ls 4KB
iscsi-mountall 3KB
rc.iscsi 9KB
iscsi-rename 1KB
install.sh 11KB
iscsi-umountall 2KB
iscsi.conf 17KB
driver
iscsi-recv-pdu.c 29KB
iscsi-network.c 7KB
scsi_transport_iscsi.c 11KB
include
iscsi-task.h 3KB
iscsi-sfnet.h 5KB
iscsi-session.h 7KB
scsi_transport_iscsi.h 6KB
iscsi-ioctl.c 4KB
iscsi-portal.c 4KB
iscsi-initiator.c 15KB
iscsi-xmit-pdu.c 20KB
Makefile 4KB
iscsi-task.c 17KB
iscsi-attr.c 8KB
iscsi-auth.c 4KB
iscsi-session.c 44KB
man
iscsi.conf.5 14KB
iscsi-ls.1 3KB
iscsid.8 3KB
include
iscsi-version.h 1KB
iscsi-portal.h 2KB
iscsi-ioctl.h 2KB
iscsi-protocol.h 2KB
iscsi.h 11KB
daemon
iscsid.c 70KB
iscsi-io.c 14KB
discovery
iscsi-slp-discovery.h 840B
iscsi-discovery.h 574B
iscsi-discovery.c 48KB
iscsi-slp-discovery.c 22KB
include
iscsi-auth.h 1KB
iscsi-sfnet.h 2KB
iscsi-config.h 10KB
iscsi-session.h 3KB
iscsi-hooks.h 2KB
iscsid.h 4KB
iscsi-config.c 79KB
iscsi-linux.c 23KB
iscsi-auth.c 6KB
README 64KB
common
auth
iscsi-auth-client.h 8KB
iscsi-auth-client.c 45KB
login
iscsi-login.h 3KB
iscsi-login.c 41KB
Makefile 13KB
utils
iscsi-device.c 3KB
iscsi-boot
iscsi-network-boot.c 12KB
iscsi-network-boot.h 2KB
init.c 8KB
mkinitrd.iscsi 11KB
include
iscsi-iname.c 4KB
COPYING 18KB
共 64 条
- 1
御道御小黑
- 粉丝: 58
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0