/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#if defined(_KERNEL)
#else
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
#include <errno.h>
#endif
#include <sys/iscsi_protocol.h>
void *
{
#if defined(_KERNEL)
#else
#endif
}
void
{
#if defined(_KERNEL)
#else
#endif
}
/*
* default_port should be the port to be used, if not specified
* as part of the supplied string 'arg'.
*/
struct sockaddr_storage *
{
/* Why does addrbuf need to be this big!??! XXX */
char *addr_str;
char *port_str;
#ifndef _KERNEL
char *errchr;
#endif
long tmp_port = 0;
return (NULL);
}
/* don't modify the passed-in string */
if (*addr_str == '[') {
/*
* An IPv6 address must be inside square brackets
*/
if (!port_str) {
/* No closing bracket */
return (NULL);
}
/* strip off the square brackets so we can convert */
addr_str++;
*port_str = '\0';
port_str++;
if (*port_str == ':') {
/* TCP port to follow */
port_str++;
} else if (*port_str == '\0') {
/* No port specified */
} else {
/* malformed */
return (NULL);
}
} else {
if (port_str) {
*port_str = '\0';
port_str++;
}
}
if (port_str) {
#if defined(_KERNEL)
return (NULL);
}
#else
#endif
return (NULL);
}
} else {
}
return (NULL);
}
} else {
return (NULL);
}
}
/* successful */
return (sa);
}
#ifndef _KERNEL
int
{
int ret;
if (!nvl) {
return (EINVAL);
}
if (ret != 0) {
return (ret);
}
/* if there's no config, store an empty list */
if (!cfg) {
return (0);
}
if (ret == 0) {
}
}
if (ret == 0) {
}
}
if (ret == 0) {
}
}
if (ret == 0) {
}
if (ret == 0) {
} else {
}
return (ret);
}
#endif /* !_KERNEL */
/*
* nvlist version of config is 3 list-of-list, + 1 proplist. arrays
* are interesting, but lists-of-lists are more useful when doing
* individual lookups when we later add support for it. Also, no
* need to store name in individual struct representation.
*/
int
{
int ret;
if (!cfg) {
return (EINVAL);
}
/* initialize output */
return (ENOMEM);
}
if (!nvl) {
/* nothing to decode, but return the empty cfg struct */
NV_UNIQUE_NAME, 0);
if (ret != 0) {
return (ret);
}
return (0);
}
if (ret != 0) {
return (ret);
}
if (ret == 0) {
/* decode list of it_tgt_t */
&(tmpcfg->config_tgt_list));
}
if (ret == 0) {
/* decode list of it_tpg_t */
&(tmpcfg->config_tpg_list));
}
if (ret == 0) {
/* decode list of initiators */
&(tmpcfg->config_ini_list));
}
if (ret == 0) {
/*
* don't depend on the original nvlist staying in-scope,
* duplicate the nvlist
*/
0);
/*
* No global properties defined, make an empty list
*/
NV_UNIQUE_NAME, 0);
}
if (ret == 0) {
/*
* decode the list of iSNS server information to make
* references from the kernel simpler.
*/
if (tmpcfg->config_global_properties) {
if (ret == 0) {
/* It's OK if we don't have any iSNS servers */
ret = 0;
}
}
}
if (ret == 0) {
} else {
}
return (ret);
}
it_tgt_t *
{
MAX_ISCSI_NODENAMELEN) == 0) {
return (cfg_tgt);
}
}
return (NULL);
}
int
{
int ret = 0;
char *name;
return (EINVAL);
}
*count = 0;
if (!nvl) {
/* nothing to do */
return (0);
}
if (ret != 0) {
/* invalid entry? */
continue;
}
if (ret != 0) {
break;
}
(*count)++;
} else {
}
}
if (ret != 0) {
}
return (ret);
}
int
{
int ret;
if (!nvl) {
return (EINVAL);
}
if (!tgtlist) {
/* nothing to do */
return (0);
}
/* create the target list if required */
if (ret != 0) {
return (ret);
}
}
while (tgtp) {
if (ret != 0) {
break;
}
if (ret != 0) {
break;
}
}
if (ret != 0) {
if (pnv) {
}
}
return (ret);
}
int
{
int ret;
if (!nvl) {
return (EINVAL);
}
if (!tgt) {
/* nothing to do */
return (0);
}
if (ret != 0) {
return (ret);
}
if (tgt->tgt_properties) {
}
if (ret == 0) {
}
if (ret == 0) {
}
}
if (ret != 0) {
nvlist_free(*nvl);
}
return (ret);
}
int
{
int ret;
return (EINVAL);
}
if (!ttgt) {
return (ENOMEM);
}
if (ret == 0) {
/* duplicate list so it does not go out of context */
ret = 0;
}
if (ret == 0) {
&(ttgt->tgt_generation));
ret = 0;
}
if (ret == 0) {
}
if (ret == 0) {
&(ttgt->tgt_tpgt_list));
ret = 0;
}
if (ret == 0) {
} else {
}
return (ret);
}
int
{
int ret;
if (!nvl) {
return (EINVAL);
}
if (!tpgt) {
/* nothing to do */
return (0);
}
if (ret != 0) {
return (ret);
}
if (ret == 0) {
}
if (ret != 0) {
nvlist_free(*nvl);
}
return (ret);
}
int
{
int ret;
return (EINVAL);
}
if (!nvl) {
return (0);
}
if (!ptr) {
return (ENOMEM);
}
if (ret == 0) {
&(ptr->tpgt_generation));
}
if (ret == 0) {
} else {
}
return (ret);
}
int
{
int ret;
if (!nvl) {
return (EINVAL);
}
if (!tpgtlist) {
/* nothing to do */
return (0);
}
/* create the target list if required */
if (ret != 0) {
return (ret);
}
}
while (ptr) {
if (ret != 0) {
break;
}
if (ret != 0) {
break;
}
}
if (ret != 0) {
if (pnv) {
}
}
return (ret);
}
int
{
int ret = 0;
char *name;
return (EINVAL);
}
*count = 0;
if (!nvl) {
/* nothing to do */
return (0);
}
if (ret != 0) {
/* invalid entry? */
continue;
}
if (ret != 0) {
break;
}
(*count)++;
} else {
}
}
if (ret != 0) {
}
return (ret);
}
#ifndef _KERNEL
int
{
int ret;
int i;
if (!nvl) {
return (EINVAL);
}
if (!tpg) {
/* nothing to do */
return (0);
}
if (ret != 0) {
return (ret);
}
/* add the portals */
sizeof (it_portal_t));
if (portalArray == NULL) {
nvlist_free(*nvl);
return (ENOMEM);
}
i = 0;
&(portalArray[i]));
if (ret != 0) {
break;
}
i++;
}
}
if ((ret == 0) && portalArray) {
portalArray, i);
}
if (portalArray) {
while (--i >= 0) {
if (portalArray[i]) {
}
}
}
if (ret != 0) {
nvlist_free(*nvl);
}
return (ret);
}
#endif /* !_KERNEL */
int
{
int ret;
return (EINVAL);
}
return (ENOMEM);
}
&(ptpg->tpg_generation));
if (ret == 0) {
&portalArray, &count);
}
if (ret == 0) {
/* set the portals */
&ptpg->tpg_portal_count);
ret = 0;
}
if (ret == 0) {
} else {
}
return (ret);
}
#ifndef _KERNEL
int
{
int ret;
if (!nvl) {
return (EINVAL);
}
if (!tpglist) {
/* nothing to do */
return (0);
}
/* create the target portal group list if required */
if (ret != 0) {
return (ret);
}
}
while (ptr) {
if (ret != 0) {
break;
}
if (ret != 0) {
break;
}
}
if (ret != 0) {
if (pnv) {
}
}
return (ret);
}
#endif /* !_KERNEL */
it_tpg_t *
{
MAX_TPG_NAMELEN) == 0) {
return (cfg_tpg);
}
}
return (NULL);
}
int
{
/*
* XXX - should we check here for IPv4 addrs mapped to v6?
* see also iscsit_is_v4_mapped in iscsit_login.c
*/
return (1);
}
/*
* sockaddr_in has padding which may not be initialized.
* be more specific in the comparison, and don't trust the
* caller has fully initialized the structure.
*/
sizeof (struct in_addr)) == 0) &&
return (0);
}
return (0);
}
}
return (1);
}
{
cfg_portal != NULL;
return (cfg_portal);
}
return (NULL);
}
{
cfg_portal != NULL;
return (cfg_portal);
}
return (NULL);
}
int
{
int ret = 0;
char *name;
return (EINVAL);
}
*count = 0;
if (!nvl) {
/* nothing to do */
return (0);
}
if (ret != 0) {
/* invalid entry? */
continue;
}
if (ret != 0) {
break;
}
(*count)++;
} else {
}
}
if (ret != 0) {
}
return (ret);
}
int
{
int ret;
if (!nvl) {
return (EINVAL);
}
if (!ini) {
return (0);
}
if (ret != 0) {
return (ret);
}
if (ini->ini_properties) {
}
if (ret == 0) {
ret = 0;
}
if (ret != 0) {
nvlist_free(*nvl);
}
return (ret);
}
int
{
int ret;
return (EINVAL);
}
if (!nvl) {
return (0);
}
if (!inip) {
return (ENOMEM);
}
if (ret == 0) {
ret = 0;
}
if (ret == 0) {
&(inip->ini_generation));
}
if (ret == 0) {
} else {
}
return (ret);
}
int
{
int ret;
if (!nvl) {
return (EINVAL);
}
if (!inilist) {
return (0);
}
/* create the target list if required */
if (ret != 0) {
return (ret);
}
}
while (ptr) {
if (ret != 0) {
break;
}
if (ret != 0) {
break;
}
}
if (ret != 0) {
if (pnv) {
}
}
return (ret);
}
int
{
int ret = 0;
char *name;
return (EINVAL);
}
*count = 0;
if (!nvl) {
/* nothing to do */
return (0);
}
if (ret != 0) {
/* invalid entry? */
continue;
}
if (ret != 0) {
break;
}
(*count)++;
} else {
}
}
if (ret != 0) {
}
return (ret);
}
/*
* Convert a sockaddr to the string representation, suitable for
* storing in an nvlist or printing out in a list.
*/
#ifndef _KERNEL
int
{
int ret;
const char *bufp;
return (EINVAL);
}
buf[0] = '\0';
return (ret);
}
return (ret);
}
} else {
return (EINVAL);
}
return (ENOMEM);
}
return (0);
}
#endif /* !_KERNEL */
int
{
int ret = 0;
int i;
return (EINVAL);
}
*list_count = 0;
*portallist = NULL;
for (i = 0; i < count; i++) {
if (!arr[i]) {
/* should never happen */
continue;
}
if (!portal) {
break;
}
if (it_common_convert_sa(arr[i],
break;
}
/* make sure no duplicates */
tmp = *portallist;
while (tmp) {
&(portal->portal_addr)) == 0) {
break;
}
}
if (!portal) {
continue;
}
/*
* The first time through the loop, *portallist == NULL
* because we assigned it to NULL above. Subsequently
* prev will have been set. Therefor it's OK to put
* lint override before prev->portal_next assignment.
*/
if (*portallist == NULL) {
*portallist = portal;
} else {
}
(*list_count)++;
}
return (ret);
}
/*
* Function: it_config_free_cmn()
*
* Free any resources associated with the it_config_t structure.
*
* Parameters:
* cfg A C representation of the current iSCSI configuration
*/
void
{
if (!cfg) {
return;
}
if (cfg->config_tgt_list) {
}
if (cfg->config_tpg_list) {
}
if (cfg->config_ini_list) {
}
if (cfg->config_global_properties) {
}
if (cfg->config_isns_svr_list) {
while (pp) {
}
}
}
/*
* Function: it_tgt_free_cmn()
*
* Frees an it_tgt_t structure. If tgt_next is not NULL, frees
* all structures in the list.
*/
void
{
if (!tgt) {
return;
}
while (tgtp) {
if (tgtp->tgt_tpgt_list) {
}
if (tgtp->tgt_properties) {
}
}
}
/*
* Function: it_tpgt_free_cmn()
*
* Deallocates resources of an it_tpgt_t structure. If tpgt->next
* is not NULL, frees all members of the list.
*/
void
{
if (!tpgt) {
return;
}
while (tpgtp) {
}
}
/*
* Function: it_tpg_free_cmn()
*
* Deallocates resources associated with an it_tpg_t structure.
* If tpg->next is not NULL, frees all members of the list.
*/
void
{
while (tpgp) {
while (portalp) {
}
}
}
/*
* Function: it_ini_free_cmn()
*
* Deallocates resources of an it_ini_t structure. If ini->next is
* not NULL, frees all members of the list.
*/
void
{
if (!ini) {
return;
}
while (inip) {
if (inip->ini_properties) {
}
}
}