/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "isns_server.h"
#include "isns_msgq.h"
#include "isns_htab.h"
#include "isns_cache.h"
#include "isns_pdu.h"
#include "isns_obj.h"
#include "isns_dd.h"
#include "isns_func.h"
#include "isns_dseng.h"
#include "isns_log.h"
#include "isns_scn.h"
#include "isns_utils.h"
#include "isns_esi.h"
/*
* external variables
*/
#ifdef DEBUG
extern int verbose_mc;
extern void print_object(char *, isns_obj_t *);
#endif
extern msg_queue_t *sys_q;
extern msg_queue_t *scn_q;
extern pthread_mutex_t el_mtx;
extern int cache_flag;
/*
* global data
*/
/*
* local variables
*/
/* type of parent object */
0,
0,
0, /* OBJ_DD */
0, /* OBJ_DDS */
0, /* MAX_OBJ_TYPE */
0, /* OBJ_DUMMY1 */
0, /* OBJ_DUMMY2 */
0, /* OBJ_DUMMY3 */
0, /* OBJ_DUMMY4 */
};
/* number of children object type */
0,
0,
0
};
/* type of a child object */
{ 0, 0 },
{ OBJ_ISCSI, OBJ_PORTAL },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 }
};
/* number of attributes of certain type of object */
0,
0, /* MAX_OBJ_TYPE */
0, /* OBJ_DUMMY1 */
0, /* OBJ_DUMMY2 */
0, /* OBJ_DUMMY3 */
0, /* OBJ_DUMMY4 */
};
/* the tag of UID of each type of object */
0,
0, /* MAX_OBJ_TYPE */
0, /* OBJ_DUMMY1 */
0, /* OBJ_DUMMY2 */
0, /* OBJ_DUMMY3 */
0, /* OBJ_DUMMY4 */
};
/* the index of UID of each type of object */
0,
0, /* MAX_OBJ_TYPE */
0, /* OBJ_DUMMY1 */
0, /* OBJ_DUMMY2 */
0, /* OBJ_DUMMY3 */
0, /* OBJ_DUMMY4 */
};
/* the index of the key attributes of each type of object */
{ 0 },
{ ATTR_INDEX_ENTITY(ISNS_EID_ATTR_ID), 0 },
0 },
0 },
{ ATTR_INDEX_DD(ISNS_DD_NAME_ATTR_ID), 0 },
};
/* the operating methods for key attributes of each type of object */
{ 0 },
{ OP_STRING, 0 },
{ OP_STRING, 0 },
{ OP_MEMORY_IP6, OP_INTEGER, 0 },
{ OP_STRING, 0 },
{ OP_STRING, 0 }
};
/* the size of each type of object */
0,
sizeof (isns_entity_t),
sizeof (isns_iscsi_t),
sizeof (isns_portal_t),
sizeof (isns_pg_t),
sizeof (isns_dd_t),
sizeof (isns_dds_t),
0,
0,
0,
0,
0,
sizeof (isns_assoc_iscsi_t),
sizeof (isns_assoc_dd_t)
};
#ifdef DEBUG
#else
static const int NUM_OF_REF[MAX_OBJ_TYPE_FOR_SIZE] = {
#endif
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
};
/* the type of the reference object */
{ 0 },
{ 0 },
{ OBJ_PG, OBJ_PORTAL, 0 },
{ 0, OBJ_ISCSI, OBJ_PORTAL },
{ 0 },
{ 0 }
};
/* the operating method for match operation of the reference object */
{ 0, 0 },
{ 0, 0 },
{ OP_STRING, 0 },
{ OP_MEMORY_IP6, OP_INTEGER },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 }
};
/* the index of the attribute of being matched object */
{ 0, 0 },
{ 0, 0 },
{ ATTR_INDEX_ISCSI(ISNS_ISCSI_NAME_ATTR_ID), 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 }
};
/* the index of the attribute of matching object */
{ 0, 0 },
{ 0, 0 },
{ ATTR_INDEX_PG(ISNS_PG_ISCSI_NAME_ATTR_ID), 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 }
};
/*
* local functions.
*/
static uint32_t get_reg_period();
static char *make_unique_name(int *, uint32_t);
static int setup_ref_lcp(lookup_ctrl_t *,
const isns_obj_t *, const isns_obj_t *);
static int setup_deref_lcp(lookup_ctrl_t *,
const isns_obj_t *, isns_type_t);
static int cb_get_parent(void *, void *);
static int cb_node_child(void *, void *);
static int cb_set_ref(void *, void *);
static int cb_clear_ref(void *, void *);
static int cb_add_child(void *, void *);
static int cb_remove_child(void *, void *);
static int cb_verify_ref(void *, void *);
static int cb_ref_new2old(void *, void *);
static int cb_new_ref(void *, void *);
static int ref_new2old(
static int ref_new2new(
static int set_obj_offline(isns_obj_t *);
(const isns_obj_t *, const isns_obj_t *) = {
NULL,
NULL,
NULL,
NULL,
};
NULL,
&pg_hval,
&dd_hval,
};
/*
* ****************************************************************************
*
* entity_hval:
* caculate the hash value of a network entity object.
*
* p - the pointer pointers to network entity object or
* the lookup control data, both have the key attribute
* of a network entity object.
* chunk- which chunk of the hash table.
* flags- pointer to flags.
* return - the hash value.
*
* ****************************************************************************
*/
static uint32_t
void *p,
/* LINTED E_FUNC_ARG_UNUSED */
)
{
if ((*flags & FLAGS_CTRL_MASK) == 0) {
/* p pointers to a network entity object */
obj = (isns_obj_t *)p;
} else {
/* p is lookup control data */
lcp = (lookup_ctrl_t *)p;
}
return (htab_compute_hval(key));
}
/*
* ****************************************************************************
*
* iscsi_hval:
* caculate the hash value of an iscsi storage node object.
*
* p - the pointer pointers to iscsi storage node object or
* the lookup control data, both have the key attribute
* of an iscsi storage node object.
* chunk- which chunk of the hash table.
* flags- pointer to flags.
* return - the hash value.
*
* ****************************************************************************
*/
static uint32_t
void *p,
/* LINTED E_FUNC_ARG_UNUSED */
)
{
if ((*flags & FLAGS_CTRL_MASK) == 0) {
/* p pointers to an iscsi storage node object */
obj = (isns_obj_t *)p;
} else {
/* p is lookup control data */
lcp = (lookup_ctrl_t *)p;
}
return (htab_compute_hval(key));
}
/*
* ****************************************************************************
*
* portal_hval:
* caculate the hash value of a portal object.
*
* p - the pointer pointers to a portal object or the lookup control
* data, both have the key attributes of a portal object.
* chunk- which chunk of the hash table.
* flags- pointer to flags.
* return - the hash value.
*
* ****************************************************************************
*/
static uint32_t
void *p,
/* LINTED E_FUNC_ARG_UNUSED */
)
{
if ((*flags & FLAGS_CTRL_MASK) == 0) {
/* p pointers to a portal object */
obj = (isns_obj_t *)p;
} else {
/* p is lookup control data */
lcp = (lookup_ctrl_t *)p;
}
return (htab_compute_hval(key));
}
/*
* ****************************************************************************
*
* pg_hval:
* caculate the hash value of a portal group object.
*
* p - the pointer pointers to a portal group object or the lookup
* control data, both have the key attributes of a portal object.
* chunk- which chunk of the hash table.
* flags- pointer to flags.
* return - the hash value.
*
* ****************************************************************************
*/
static uint32_t
void *p,
)
{
if ((*flags & FLAGS_CTRL_MASK) == 0) {
/* p is a portal group object */
obj = (isns_obj_t *)p;
if (chunk == 0) {
/* the first chunk */
} else {
/* another chunk */
}
} else {
/* p is a lookup control data */
lcp = (lookup_ctrl_t *)p;
/* clear the chunk flags */
*flags &= ~FLAGS_CHUNK_MASK;
/* the first chunk */
} else {
/* another chunk */
*flags |= 1;
}
}
}
return (htab_compute_hval(key));
}
/*
* ****************************************************************************
*
* dd_hval:
* caculate the hash value of a DD object.
*
* p - the pointer pointers to a DD object or the lookup control data,
* both have the key attributes of a DD object.
* chunk- which chunk of the hash table.
* flags- pointer to flags.
* return - the hash value.
*
* ****************************************************************************
*/
static uint32_t
void *p,
/* LINTED E_FUNC_ARG_UNUSED */
)
{
if ((*flags & FLAGS_CTRL_MASK) == 0) {
/* p is a DD object */
obj = (isns_obj_t *)p;
} else {
/* p is a lookup control data */
lcp = (lookup_ctrl_t *)p;
}
return (htab_compute_hval(key));
}
/*
* ****************************************************************************
*
* dds_hval:
* caculate the hash value of a DD-set object.
*
* p - the pointer pointers to a DD-set object or the lookup control data,
* both have the key attributes of a DD-set object.
* chunk- which chunk of the hash table.
* flags- pointer to flags.
* return - the hash value.
*
* ****************************************************************************
*/
static uint32_t
void *p,
/* LINTED E_FUNC_ARG_UNUSED */
)
{
if ((*flags & FLAGS_CTRL_MASK) == 0) {
/* p is a DD-set object */
obj = (isns_obj_t *)p;
} else {
/* p is lookup control data */
lcp = (lookup_ctrl_t *)p;
}
return (htab_compute_hval(key));
}
/*
* ****************************************************************************
*
* obj_hval:
* caculate the hash value of an object.
*
* p - the pointer pointers to an object or lookup control data,
* both has the object type and the key attributes of an object.
* chunk- which chunk of the hash table.
* flags- pointer to flags.
* return - the hash value.
*
* ****************************************************************************
*/
void *p,
)
{
}
/*
* ****************************************************************************
*
* get_obj_uid:
* get the UID of an object.
*
* p - the pointer pointers to an object.
* return - the UID.
*
* ****************************************************************************
*/
const void *p
)
{
return (uid);
}
/*
* ****************************************************************************
*
* set_obj_uid:
* set the UID of an object.
*
* p - the pointer pointers to an object.
* uid - the UID.
* return - the UID.
*
* ****************************************************************************
*/
void *p,
)
{
/* set the tag, len and value */
return (uid);
}
/*
* ****************************************************************************
*
* obj_cmp:
* compare between two objects or an object with a lookup control data.
*
* p1 - the pointer points to an object.
* p2 - the pointer points to an object or a lookup control data.
* flags- 0: p2 is an object; otherwise p2 is a lookup control data.
* return - the comparsion result.
*
* ****************************************************************************
*/
int
void *p1,
void *p2,
int flags
)
{
if (flags == 0) {
} else {
/* the object are linked with decending order by */
/* the object UID, if the object UID is greater than */
/* or equal to the current UID, it needs to compare */
/* for the next one. */
return (-1);
}
}
}
/*
* ****************************************************************************
*
* replace_object:
* replace an existing object with the new one.
*
* p1 - the pointer points to an object being replaced.
* p2 - the pointer points to a new object.
* uid_p- points to uid for returning.
* flag - 0: do not free the source object, otherwise free it.
* return - error code.
*
* ****************************************************************************
*/
int
void *p1,
void *p2,
int flag
)
{
int ec = 0;
#ifndef SKIP_SRC_AUTH
#endif
int online;
/* replace not allowed */
return (ERR_NAME_IN_USE);
}
/* set cache update flag */
/* update parent uid */
#ifndef SKIP_SRC_AUTH
if (swap != 0) {
}
}
#endif
/* update all of attributes */
return (ISNS_RSP_INTERNAL_ERROR);
}
/* free up the src object */
if (flag != 0) {
(void) free_object(src);
} else if (online == 0) {
(void) set_obj_offline(src);
}
/* update data store */
} else {
/* we should never have duplicated entry in data store */
}
/* trigger a scn */
if (ec == 0) {
dst);
}
}
}
return (ec);
}
/*
* ****************************************************************************
*
* add_object:
* post function after adding a new object.
*
* p - object which has been added.
* return - error code.
*
* ****************************************************************************
*/
int
void *p
)
{
int ec = 0;
/* add the new object to data store */
}
/* trigger a scn */
}
return (ec);
}
/*
* ****************************************************************************
*
* obj_tab_init:
* initialize the object hash tables.
*
* c - points to the cache.
* return - error code.
*
* ****************************************************************************
*/
int
struct cache *c
)
{
htab_t *t;
htab_init();
/*
* allocate an array of pointer for the object hash tables.
*/
if (c->t == NULL) {
return (1);
}
/*
* hash table for network entity objects.
*/
if (t != NULL) {
t->c = c;
c->t[OBJ_ENTITY] = t;
} else {
return (1);
}
/*
* hash table for iscsi storage node objects.
*/
if (t != NULL) {
t->c = c;
c->t[OBJ_ISCSI] = t;
} else {
return (1);
}
/*
* hash table for portal objects.
*/
if (t != NULL) {
t->c = c;
c->t[OBJ_PORTAL] = t;
} else {
return (1);
}
/*
* hash table for portal group objects.
*/
if (t != NULL) {
t->c = c;
c->t[OBJ_PG] = t;
} else {
return (1);
}
/*
* hash table for discovery domain objects.
*/
if (t != NULL) {
t->c = c;
c->t[OBJ_DD] = t;
} else {
return (1);
}
/*
* hash table for discovery domain set objects.
*/
if (t != NULL) {
t->c = c;
c->t[OBJ_DDS] = t;
} else {
return (1);
}
return (0);
}
/*
* ****************************************************************************
*
* get_ref_np:
* get the ref pointer of the portal group object.
*
* obj - portal group object.
* return - ref pointer.
*
* ****************************************************************************
*/
static uint32_t *
int n
)
{
return (refp);
}
#ifdef DEBUG
#else
static uint32_t
#endif
int n
)
{
return (*get_ref_np(obj, n));
}
static uint32_t *
)
{
int i = 0;
while (i < NUM_OF_REF[t]) {
return (get_ref_np(obj, i));
}
i ++;
}
return (NULL);
}
)
{
return (*refp);
/* LINTED E_NOP_ELSE_STMT */
} else {
ASSERT(0);
}
return (0);
}
/*
* ****************************************************************************
*
* get_parent_p:
* get the pointer of the parent object.
*
* obj - an object.
* return - parent object pointer.
*
* ****************************************************************************
*/
uint32_t *const
const isns_obj_t *obj
)
{
case OBJ_ISCSI:
break;
case OBJ_PORTAL:
break;
case OBJ_PG:
break;
case OBJ_ASSOC_ISCSI:
break;
case OBJ_ASSOC_DD:
break;
default:
break;
}
return (pp);
}
const isns_obj_t *obj
)
{
return (*pp);
}
return (0);
}
/*
* ****************************************************************************
*
* get_child_np:
* get the pointer of the UID array of the n'th child of an object.
*
* obj - an object.
* n - the child index.
* return - the pointer of the UID array.
*
* ****************************************************************************
*/
static uint32_t **
int n
)
{
return (pp);
}
/*
* ****************************************************************************
*
* get_child_n:
* get the UID array of the n'th child of an object.
*
* obj - an object.
* n - the child index.
* return - the UID array.
*
* ****************************************************************************
*/
#ifdef DEBUG
uint32_t *
#else
static uint32_t *
#endif
int n
)
{
return (*pp);
}
ASSERT(0);
return (NULL);
}
/*
* ****************************************************************************
*
* get_child_p:
* get the pointer of the UID array of the child matching the type.
*
* base - an object.
* child_type - the child object type.
* return - the pointer of the UID array.
*
* ****************************************************************************
*/
static uint32_t **
int child_type
)
{
int i = 0;
break;
}
i ++;
}
return (pp);
}
/*
* ****************************************************************************
*
* get_child_t:
* get the UID array of the child object matching the type.
*
* base - an object.
* child_type - the child object type.
* return - the UID array.
*
* ****************************************************************************
*/
uint32_t *
int child_type
)
{
return (*pp);
} else {
return (NULL);
}
}
/*
* ****************************************************************************
*
* key_cmp:
* compare the object against the lookup control data.
*
* lcp - the lookup control data.
* obj - an object.
* return - comparison result.
*
* ****************************************************************************
*/
int
)
{
int i = 0;
case OP_STRING:
break;
case OP_INTEGER:
break;
case OP_MEMORY_IP6:
sizeof (in6_addr_t));
break;
default:
ASSERT(0);
match = 0;
break;
}
i ++;
}
if (i && match) {
return (0);
} else {
return (1);
}
}
/*
* ****************************************************************************
*
* set_lookup_ctrl:
* fill in the lookup control data for an object.
*
* lcp - the lookup control data.
* obj - an object.
* return - the lookup control data.
*
* ****************************************************************************
*/
static lookup_ctrl_t *
)
{
int i = 0;
while (i < MAX_KEY_ATTRS) {
if (op != 0) {
} else {
break;
}
i ++;
}
return (lcp);
}
/*
* ****************************************************************************
*
* assign_attr:
* assign an attribute.
*
* attr - the attribute being assigned.
* tmp - the attribute.
* return - error code.
*
* ****************************************************************************
*/
int
const isns_attr_t *tmp
)
{
uint32_t t;
case ISNS_EID_ATTR_ID:
case ISNS_DD_SET_NAME_ATTR_ID:
case ISNS_DD_NAME_ATTR_ID:
int len;
} else {
/* memory exhausted */
return (1);
}
}
case ISNS_PORTAL_NAME_ATTR_ID:
case ISNS_ISCSI_NAME_ATTR_ID:
case ISNS_ISCSI_ALIAS_ATTR_ID:
return (0);
}
} else {
/* memory exhausted */
return (1);
}
break;
}
} else {
/* memory exhausted */
return (1);
}
break;
case ISNS_PG_INDEX_ATTR_ID:
case ISNS_DD_SET_ID_ATTR_ID:
case ISNS_DD_ID_ATTR_ID:
break;
}
case ISNS_PORTAL_PORT_ATTR_ID:
case ISNS_ESI_PORT_ATTR_ID:
case ISNS_SCN_PORT_ATTR_ID:
case ISNS_PG_TAG_ATTR_ID:
break;
t = get_reg_period();
}
break;
}
break;
default:
ASSERT(0);
/* don't assign the attribute */
break;
}
return (0);
}
/*
* ****************************************************************************
*
* copy_attrs:
* copy all of attributes from one object to another.
*
* dst - the destination object.
* tmp - the source object.
* return - error code.
*
* ****************************************************************************
*/
static int
const isns_obj_t *src
)
{
int i = 0;
while (i < n) {
return (1);
}
}
i ++;
}
return (0);
}
/*
* ****************************************************************************
*
* extract_attr:
* extract an attribute from a TLV format data.
*
* attr - the attribute.
* tlv - the TLV format data.
* return - error code.
*
* ****************************************************************************
*/
int
const isns_tlv_t *tlv,
int flag
)
{
int ec = 0;
case ISNS_EID_ATTR_ID:
min_len = 0;
case ISNS_PORTAL_NAME_ATTR_ID:
case ISNS_ISCSI_ALIAS_ATTR_ID:
case ISNS_DD_SET_NAME_ATTR_ID:
case ISNS_DD_NAME_ATTR_ID:
max_len = 256;
case ISNS_ISCSI_NAME_ATTR_ID:
} else {
}
break;
break;
} else {
}
break;
/* fall throught */
case ISNS_PORTAL_PORT_ATTR_ID:
case ISNS_ESI_PORT_ATTR_ID:
case ISNS_SCN_PORT_ATTR_ID:
/* fall throught */
/* fall throught */
/* fall throught */
case ISNS_DD_SET_ID_ATTR_ID:
/* fall throught */
case ISNS_DD_ID_ATTR_ID:
break;
}
case ISNS_PG_TAG_ATTR_ID:
&(tlv->attr_value[0]));
} else {
}
break;
/* ignore scn bitmap attribute during object registration, */
/* it is registered by scn_reg message. */
case ISNS_ENTITY_CERT_ATTR_ID:
case ISNS_PORTAL_CERT_ATTR_ID:
break;
case ISNS_PG_INDEX_ATTR_ID:
if (flag == 0) {
} else {
&(tlv->attr_value[0]));
}
break;
}
case ISNS_TIMESTAMP_ATTR_ID:
default:
if (flag == 0) {
} else {
}
break;
}
return (ec);
}
/*
* ****************************************************************************
*
* copy_attr:
* copy an attribute from a TLV format data.
*
* attr - the attribute.
* tlv - the TLV format data.
* return - error code.
*
* ****************************************************************************
*/
static int
const isns_tlv_t *tlv
)
{
int ec = 0;
/* extract the attribute first */
/* assign the attribute */
}
}
return (ec);
}
/*
* ****************************************************************************
*
* get_timestamp:
* get current timestamp.
*
* return - current timestamp.
*
* ****************************************************************************
*/
)
{
uint32_t t;
int flag;
/* block the scheduler */
(void) pthread_mutex_lock(&el_mtx);
/* get most current time */
/* need to wakeup idle */
flag = 1;
} else {
flag = 0;
}
t = get_stopwatch(flag);
/* unblock it */
(void) pthread_mutex_unlock(&el_mtx);
return (t);
}
/*
* ****************************************************************************
*
* get_reg_period:
* get the longest registration period.
*
* return - the longest registration period.
*
* ****************************************************************************
*/
static uint32_t
)
{
uint32_t t;
/* get most current time */
t = get_timestamp();
/* just one second before the end of the world */
return (period);
}
/*
* ****************************************************************************
*
* obj_calloc:
* allocate memory space for an object.
*
* type - the object type.
* return - pointer of the object being allocated.
*
* ****************************************************************************
*/
int type
)
{
#ifdef DEBUG
if (verbose_mc) {
}
#endif
}
return (obj);
}
/*
* ****************************************************************************
*
* make_default_entity:
* generate a default network entity object.
*
* return - pointer of the default network entity object.
*
* ****************************************************************************
*/
)
{
uint32_t t;
int len;
if (!eid) {
return (NULL);
}
/* set default entity name */
/* set default registration period */
t = get_reg_period();
}
}
return (obj);
}
/*
* ****************************************************************************
*
* make_default_pg:
* generate a default portal group object.
*
* iscsi - the iscsi storage node object.
* portal - the portal object.
* return - pointer of the default portal group object.
*
* ****************************************************************************
*/
static isns_obj_t *
const isns_obj_t *p1,
const isns_obj_t *p2
)
{
} else {
}
} else {
}
return (pg);
}
/*
* ****************************************************************************
*
* reg_get_entity:
* parse the Operating Attributes of the DevAttrReg message and
* create the Network Entity object if it has one.
*
* p - the pointer of the object for returning.
* op - the operating attributes.
* op_len - the length of the operating attributes.
* return - error code.
*
* ****************************************************************************
*/
int
isns_obj_t **p,
isns_tlv_t **op,
)
{
int ec = 0;
/* parse the entity object */
do {
} while (ec == 0 &&
tmp_len >= 8 &&
} else {
}
if (ec == 0) {
/* set default registration period */
}
}
}
*p = entity;
return (ec);
}
/*
* ****************************************************************************
*
* reg_get_iscsi:
* parse the Operating Attributes of the DevAttrReg message and
* create an iSCSI Storage Node object.
*
* p - the pointer of the object for returning.
* pg_key1 - the pointer of iscsi storage node name for returning.
* op - the operating attributes.
* op_len - the length of the operating attributes.
* return - error code.
*
* ****************************************************************************
*/
static int
isns_obj_t **p,
isns_tlv_t **op,
)
{
int ec = 0;
/* keep the iscsi storage node name for */
/* parsing a pg object which is immediately */
/* followed with a PGT by the iscsi storage node */
/* parse one iscsi storage node object */
/* parse key & non-key attributes */
do {
} while (ec == 0 &&
tmp_len >= 8 &&
} else {
/* no memory */
}
*p = obj;
return (ec);
}
/*
* ****************************************************************************
*
* reg_get_portal:
* parse the Operating Attributes of the DevAttrReg message and
* create a Portal object.
*
* p - the pointer of the object for returning.
* pg_key1 - the pointer of portal ip addr for returning.
* pg_key2 - the pointer of portal port for returning.
* op - the operating attributes.
* op_len - the length of the operating attributes.
* return - error code.
*
* ****************************************************************************
*/
static int
isns_obj_t **p,
isns_tlv_t **op,
)
{
int ec = 0;
/* keep the portal ip addr */
if (tmp_len > 8 &&
/* keep the portal port */
/* parse one portal object */
/* copy ip addr attribute */
/* copy port attribute */
if (ec == 0) {
}
/* parse non-key attributes */
while (ec == 0 &&
tmp_len >= 8 &&
}
} else {
/* no memory */
}
} else {
/* ip address is not followed by port */
}
*p = obj;
return (ec);
}
/*
* ****************************************************************************
*
* reg_get_pg:
* parse the Operating Attributes of the DevAttrReg message and
* create a Portal Group object.
*
* p - the pointer of the object for returning.
* op - the operating attributes.
* op_len - the length of the operating attributes.
* return - error code.
*
* ****************************************************************************
*/
static int
isns_obj_t **p,
isns_tlv_t **op,
)
{
int ec = 0;
/* parse a complete pg object */
/* parse attributes */
do {
} while (ec == 0 &&
tmp_len >= 8 &&
} else {
}
*p = obj;
return (ec);
}
/*
* ****************************************************************************
*
* reg_get_pg1:
* parse the Operating Attributes of the DevAttrReg message and
* create a Portal Group object which is followed to a Portal object.
*
* p - the pointer of the object for returning.
* pgt - the size-3 array of pointers which have the pg portal ip addr, port
* and the pg tag attributes.
* op - the operating attributes.
* op_len - the length of the operating attributes.
* return - error code.
*
* ****************************************************************************
*/
static int
isns_obj_t **p,
isns_attr_t const *pgt,
isns_tlv_t **op,
)
{
int ec = 0;
int i = 0;
/* the pg iscsi storage node name is */
/* followed to a portal group tag */
/* copy pg iscsi storage node name */
/* copy pg ip addr, pg port & pgt */
while (ec == 0 && i < 3) {
i ++;
}
} else {
/* no memory */
}
} else {
}
*p = obj;
return (ec);
}
/*
* ****************************************************************************
*
* reg_get_pg2:
* parse the Operating Attributes of the DevAttrReg message and
* create a Portal Group object which is followed to a iSCSI
* Storage Node object.
*
* p - the pointer of the object for returning.
* pgt - the size-3 array of pointers which have the pg iscsi storage
* node name and the pg tag attributes.
* op - the operating attributes.
* op_len - the length of the operating attributes.
* return - error code.
*
* ****************************************************************************
*/
static int
isns_obj_t **p,
isns_attr_t const *pgt,
isns_tlv_t **op,
)
{
int ec = 0;
int i = 0;
/* keep ip address */
if (tmp_len > 8 &&
/* expect pg portal port */
/* expect pg tag */
/* expect pg iscsi storage node name only */
/* the pg portal ip addr & port is followed */
/* to a pg tag and we have the iscsi storage */
/* node parsed previously */
/* copy the pg ip addr */
/* copy the pg port */
if (ec == 0) {
}
/* copy pg iscsi storage node name & pgt */
while (ec == 0 && i < 3) {
i += 2;
}
} else {
}
} else {
}
*p = obj;
return (ec);
}
/*
* ****************************************************************************
*
* reg_get_obj:
* parse and create one object from the rest of Operating Attributes
* of the DevAttrReg message, the object can be iSCSI Storage Node,
* Portal or Portal Group.
*
* p - the pointer of the object for returning.
* pgt - an attribute array with size 3, the elements are:
* 0: the first pg key attribute, it is either the name of an
* iscsi storage node object or the ip addr of a portal object.
* 1: the second pg key attribute, i.e. the portal port.
* 2: the portal group tag attribute.
* op - the operating attributes.
* op_len - the length of the operating attributes.
* return - error code.
*
* ****************************************************************************
*/
int
isns_obj_t **p,
isns_tlv_t **op,
)
{
int ec = 0;
int derefd = 0;
if (*op_len == 0) {
*p = NULL;
return (0);
}
case ISCSI_KEY:
break;
case PORTAL_KEY1:
break;
case PG_KEY1:
/* pg iscsi storage node name is */
/* followed to a pgt */
} else {
/* a complete pg object */
}
break;
case PG_KEY2:
/* pg portal ip addr is followed to a pgt */
break;
case PG_PGT:
case 0:
/* portal group tag does not follow */
/* iscsi storage node or portal object */
*p = NULL;
break;
case PG_KEY1:
case PG_KEY2:
pg_tag = 0;
case 4:
&(*op)->attr_value[0]);
case 0:
break;
default:
*p = NULL;
break;
}
if (ec == 0) {
derefd = 1;
}
break;
default:
/* should never happen */
ASSERT(0);
*p = NULL;
break;
}
break;
default:
*p = NULL;
break;
}
ec = update_deref_obj(*p);
}
free_one_object(*p);
*p = NULL;
}
return (ec);
}
/*
* ****************************************************************************
*
* reg_auth_src:
* Authorize the source attribute the DevAttrReg message.
* The update can only performed by the node who has the owenership.
*
* p - the pointer of the object for returning.
* pgt - an attribute array with size 3, the elements are:
* 0: the first pg key attribute, it is either the name of an
* iscsi storage node object or the ip addr of a portal object.
* 1: the second pg key attribute, i.e. the portal port.
* 2: the portal group tag attribute.
* op - the operating attributes.
* op_len - the length of the operating attributes.
* return - error code.
*
* ****************************************************************************
*/
int
)
{
if (TYPE_OF_PARENT[type] != 0) {
}
}
return (0);
}
return (1);
}
/*
* ****************************************************************************
*
* is_obj_online:
* determine if the object is currently registered with the server.
*
* obj - the object being checked.
* return - 0: not registered, otherwise registered.
*
* ****************************************************************************
*/
int
const isns_obj_t *obj
)
{
case OBJ_ISCSI:
break;
default:
break;
}
return (online);
}
static int
)
{
case OBJ_ISCSI:
break;
default:
break;
}
return (0);
}
/*
* ****************************************************************************
*
* assoc_clone:
* clone the association object.
*
* p - the object being cloned.
* clone_flag - 0: the object is being removed;
* 1: only the association is being removed.
* return - the clone object.
*
* ****************************************************************************
*/
void *
void *p,
int clone_flag
)
{
int i = 0;
int online;
int state;
obj = (isns_obj_t *)p;
return (NULL);
}
0 : 1;
/* clone_flag dd_flag online action */
/* 0 0 0 ASSERT(0) */
/* 0 0 1 NULL */
/* 0 1 0 itself */
/* 0 1 1 clone it */
/* 1 0 0 NULL */
/* 1 0 1 itself */
/* 1 1 0 itself */
/* 1 1 1 itself */
switch (state) {
case 0:
ASSERT(0);
case 1:
case 4:
return (NULL);
case 2:
case 5:
case 6:
case 7:
return (p);
case 3:
default:
break;
}
return (NULL);
}
while (i < MAX_KEY_ATTRS) {
if (op != 0) {
return (NULL);
}
} else {
break;
}
i ++;
}
}
return ((void *)clone);
}
/*
* ****************************************************************************
*
* free_one_object:
* free up one object.
*
* obj - the object being freed.
*
* ****************************************************************************
*/
void
)
{
int i;
return;
}
case ISNS_EID_ATTR_ID:
case ISNS_ISCSI_NAME_ATTR_ID:
case ISNS_ISCSI_ALIAS_ATTR_ID:
case ISNS_PORTAL_NAME_ATTR_ID:
case ISNS_DD_SET_NAME_ATTR_ID:
case ISNS_DD_NAME_ATTR_ID:
#ifdef DEBUG
if (verbose_mc) {
printf("memory(%d) deallocated\n",
}
#endif
break;
default:
break;
}
}
/* free child uids */
i = 0;
i ++;
}
/* at last, free the object itself */
#ifdef DEBUG
if (verbose_mc) {
}
#endif
}
/*
* ****************************************************************************
*
* free_object:
* free up one object.
*
* obj - the object being freed.
*
* ****************************************************************************
*/
void
)
{
}
/*
* ****************************************************************************
*
* set_parent_obj:
* set the parent object UID.
*
* obj - the child object.
* puid- the parent object UID.
* return - error code.
*
* ****************************************************************************
*/
int
)
{
if (p != NULL) {
*p = puid;
}
return (0);
}
/*
* ****************************************************************************
*
* buff_child_obj:
* add a child object UID to the child object array.
*
* obj - the parent object.
* child_type - the type of the child object.
* number - the number of the child object.
* return - the length of the child object UID array.
*
* ****************************************************************************
*/
int
const isns_type_t ptype,
const isns_type_t ctype,
const void *c,
void const ***child
)
{
int ec = 0;
int i = 0;
void const ***pp, **p;
/* get the pointer of the array which the child belongs to */
while (i < NUM_OF_CHILD[ptype]) {
break;
}
i ++;
}
/* the child type is not applicable */
return (ec);
}
p = *pp;
/* get an empty slot from the uid array for this child */
if (p != NULL) {
i = 0;
while (i < num) {
if (p[++i] == NULL) {
/* found it */
p[i] = c;
return (ec);
}
}
p = *pp;
} else {
num = 0;
new_num = 1;
}
/* the array is full, enlarge the child uid array */
if (p != NULL) {
*pp = p;
*p = (void *)new_num;
p[new_num] = c;
} else {
}
return (ec);
}
/*
* ****************************************************************************
*
* update_child_object:
* update the child object of a network entity object.
*
* puid - the UID of the parent object, i.e. the network entity object.
* child_type - the type of the child object.
* child_uid - the uid of the child object.
* return - error code.
*
* ****************************************************************************
*/
int
const isns_type_t ptype,
void const ***child,
int child_flag
)
{
int ec = 0;
return (ec);
}
int
const isns_obj_t *obj
)
{
isns_type_t t;
if (TYPE_OF_REF[t][0] != 0) {
uid = 0;
do {
} while (uid != 0);
}
return (0);
}
/*
* ****************************************************************************
*
* verify_ref_obj:
* update the reference bit of a portal group object.
*
* obj - the object being ref'ed.
* return - error code.
*
* ****************************************************************************
*/
int
const isns_type_t ptype,
void const ***child
)
{
int ec = 0;
return (ec);
}
int
)
{
int ec = 0;
int i, ref_count;
i = ref_count = 0;
while (i < NUM_OF_REF[t]) {
if (uid != 0) {
ref_count ++;
}
i ++;
}
if (i > 0 && ref_count == 0) {
}
return (ec);
}
/*
* ****************************************************************************
*
* register_object:
* add one object to the object container.
*
* obj - the object being added.
* uid_p- the pointer for returning object UID.
* update_p- the pointer for returning flag which indicates if the object
* is newly registered or updated with an existing one.
* return - error code.
*
* ****************************************************************************
*/
int
int *update_p
)
{
}
/*
* ****************************************************************************
*
* register_assoc:
* add one association object to the object container, the association
* object has only the information for discovery domain membership, i.e.
* a name and UID only.
*
* obj - the association object being added.
* uid_p- the pointer for returning object UID.
* return - error code.
*
* ****************************************************************************
*/
int
)
{
}
/*
* ****************************************************************************
*
* is_obj_there:
* check if the object is registered or not.
*
* lcp - the lookup control data.
* return - the object UID.
*
* ****************************************************************************
*/
)
{
return (uid);
}
)
{
}
/*
* ****************************************************************************
*
* setup_ref_lcp:
* prepare the lookup control data for looking up a portal group
* object.
*
* lcp - the lookup control data.
* iscsi- the ref'ed iscsi storage node object.
* portal- the ref'ed portal object.
* return - error code.
*
* ****************************************************************************
*/
static int
const isns_obj_t *iscsi,
const isns_obj_t *portal
)
{
int i = 0, j = 0;
/* extrace the matching attributes from iscsi storage node object */
i < MAX_REF_MATCH &&
i ++;
}
/* extrace the matching attributes from portal object */
i < MAX_LOOKUP_CTRL &&
j < MAX_REF_MATCH &&
j ++;
i ++;
}
if (i < MAX_LOOKUP_CTRL) {
}
return (0);
}
static int
const isns_obj_t *pg,
)
{
int i = 0;
/* extrace the matching attributes from iscsi storage node object */
while (i < MAX_REF_MATCH &&
REF_MATCH_OPS[t][i] > 0) {
i ++;
}
if (i < MAX_LOOKUP_CTRL) {
}
return (0);
}
/*
* ****************************************************************************
*
* setup_parent_lcp:
* prepare the lookup control data for looking up parent object
* with a child object.
*
* lcp - the lookup control data.
* obj - the child object.
* return - parent object UID.
*
* ****************************************************************************
*/
static uint32_t
)
{
if (puid != 0) {
}
return (puid);
}
static int
void *p1,
/* LINTED E_FUNC_ARG_UNUSED */
void *p2
)
{
return (get_parent_uid(p1));
}
static int
void *p1,
/* LINTED E_FUNC_ARG_UNUSED */
void *p2
)
{
} else {
num = 0;
}
while (num > 0) {
if (uid != 0) {
return (uid);
}
num --;
}
return (0);
}
/*
* ****************************************************************************
*
* cb_set_ref:
* callback function which sets the reference bit to 1 according to
* the type of object.
*
* p1 - the object.
* p2 - the lcp.
* return - error code.
*
* ****************************************************************************
*/
static int
void *p1,
void *p2
)
{
isns_type_t t;
uint32_t u;
*refp = u;
/* successful */
return (0);
}
/*
* ****************************************************************************
*
* cb_clear_ref:
* callback function which clears the reference bit according to
* the type of object.
*
* p1 - the object.
* p2 - the lcp.
* return - 1: the object is no longer ref'ed, 0: otherwise.
*
* ****************************************************************************
*/
static int
void *p1,
void *p2
)
{
isns_type_t t;
int i = 0;
*refp = 0;
if (ref != 0) {
return (0);
}
i ++;
}
return (1);
}
static int
void *p1,
void *p2
)
{
const void ***child;
const void **vpp;
int child_flag;
isns_obj_t *o;
int i = 0;
if (child_flag == 0 &&
}
} else {
}
/* copy required */
return (ISNS_RSP_INTERNAL_ERROR);
}
while (vnum > 0) {
*up = 0;
} else if (child_flag == 0) {
} else {
o = (isns_obj_t *)*vpp;
*up = get_obj_uid(o);
if (is_obj_online(o) == 0) {
free_object(o);
}
}
up --;
vpp --;
vnum --;
}
}
}
i ++;
}
return (0);
}
/*
* ****************************************************************************
*
* cb_remove_child:
* callback function which removes a child object UID from the
* children objet UID array of the parent object.
*
* p1 - the object.
* p2 - the lcp.
* return - 1: no more such type of child object, 0: otherwise.
*
* ****************************************************************************
*/
static int
void *p1,
void *p2
)
{
int i;
/* get the children object UID array */
num_of_child = *cuidp;
}
/* remove it */
while (num_of_child > 0) {
*cuidp = 0;
break;
}
num_of_child --;
}
/* check if all of child object UIDs are removed */
i = 0;
num_of_child = *cuidp;
while (num_of_child > 0) {
if (cuid != 0) {
return (0);
}
num_of_child --;
}
}
i ++;
}
return (1);
}
static int
void *p1,
void *p2
)
{
int ec = 0;
const void ***child;
const void **vpp;
const void *vp;
const void **evpp;
const void *evp;
uint32_t u;
int i, j, k;
for (i = 0; i < NUM_OF_CHILD[pt]; i++) {
if (rt == 0) {
continue;
}
} else {
unum = 0;
}
} else {
vnum = 0;
}
j = vnum;
while (j > 0) {
k = unum;
while (k > 0) {
u = up[k];
if (u != 0) {
ec = ref_new2old(
if (ec != 0) {
return (ec);
}
}
k --;
} /* End of while each unum */
}
j --;
} /* End of while each vnum */
continue;
}
evnum = 0;
j = 0;
while (j < NUM_OF_CHILD[pt]) {
}
break;
}
j ++;
}
j = vnum;
while (j > 0) {
k = evnum;
while (k > 0) {
if (ec != 0) {
return (ec);
}
}
k --;
}
j --;
} /* End of while each vnum */
} /* End of for each type of child */
return (ec);
}
static int
void *p1,
void *p2
)
{
int match;
match = 1;
} else {
match = 0;
}
return (match);
}
static int
void *p1,
void *p2
)
{
int ec = 0;
return (ec);
}
static int
const isns_obj_t *vp
)
{
int ec = 0;
int match;
uid = 0;
do {
if (match == 0) {
/* no such ref, create a default one */
}
return (ec);
}
static int
const isns_obj_t *p1,
const isns_obj_t *p2
)
{
int ec = 0;
if (is_obj_there(lcp) != 0) {
return (0);
}
return (ec);
}
static int
const isns_obj_t *p1,
const isns_obj_t *p2
)
{
int ec = 0;
} else {
}
return (ec);
}
/*
* ****************************************************************************
*
* do_dereg:
* Physically remove an object along with the children objects,
* the reference object and the parent object recursively.
* Apporiate SCN is triggered.
*
* lcp - the lookup control for the object being removed.
* parent_flag - 1: the object being removed is the parent object;
* 0: otherwise.
* child_flag - 1: the object being removed is a child object;
* 0: otherwise.
* pending - 1: do not remove the ESI entry immediately;
* 0: remove the ESI entry without any delay.
* return - error code.
*
* ****************************************************************************
*/
static int
int parent_flag,
int child_flag,
int pending
)
{
int ec = 0;
int i;
/* remove the object from object container */
return (0);
}
/* trigger a scn */
}
/* dereg children */
i = 0;
while (ec == 0 && !parent_flag &&
} else {
num = 0;
}
if (uid != 0) {
1,
pending);
}
num --;
}
i ++;
}
/* clear the ref bit on the ref'd object */
uid = 0;
do {
pending);
}
} while (uid != 0);
}
/* remove it from the parent */
if (ec == 0 && !child_flag &&
1,
0);
}
}
if (ec == 0 && !child_flag) {
/* remove it from persistent data store */
if (sys_q) {
}
/* remove esi event entry */
if (ec == 0) {
}
/* save the parent uid for caller */
} else {
/* it's the parent itself */
}
}
/* remove this portal from scn registry */
if (ec == 0 &&
}
/* free the object */
(void) free_object(obj);
return (ec);
}
/*
* ****************************************************************************
*
* dereg_assoc:
* Remove one association object from object container.
*
* lcp - the lookup control for the object being removed.
* return - error code.
*
* ****************************************************************************
*/
int
)
{
/* free the object */
}
return (0);
}
/*
* ****************************************************************************
*
* dereg_object:
* Remove one object from object container.
*
* lcp - the lookup control for the object being removed.
* return - error code.
*
* ****************************************************************************
*/
int
int pending
)
{
}
/*
* ****************************************************************************
*
* data_sync:
* Synchronize the cache with persistent data store.
* Flush the cache data to data store if the input ec is zero,
* retreat the changes in cache and ignore data store update
* if there is an error.
*
* ec - error code.
* return - error code.
*
* ****************************************************************************
*/
int
int ec
)
{
/* cache is updated successfully, commit the data to data store */
if (IS_CACHE_UPDATED()) {
if (ec == 0) {
}
if (ec == 0) {
/* successful, trigger the SCN */
} else {
}
} else {
/* ignore all SCNs which have been generated */
}
return (ec);
}
};
"ENTITY_ID_%d",
"DD_%d",
"DD-Set_%d"
};
0,
0,
0
};
/*
* ****************************************************************************
*
* make_unique_name:
* make a default unique name for a newly registered network entity,
* discovery domain or discovery domain set object.
*
* len - pointer of the length of the new name for returning.
* tag - which attribute of the new name is for.
* return - the name being made.
*
* ****************************************************************************
*/
static char *
int *len,
)
{
int i;
int count;
char *p;
switch (tag) {
case ISNS_EID_ATTR_ID:
i = 0;
break;
case ISNS_DD_NAME_ATTR_ID:
i = 1;
break;
case ISNS_DD_SET_NAME_ATTR_ID:
i = 2;
break;
default:
ASSERT(0);
break;
}
do {
(void) pthread_mutex_lock(&name_mtx[i]);
count = ++ name_count[i];
(void) pthread_mutex_unlock(&name_mtx[i]);
/* no more space, failure */
if (count == 0) {
return (NULL);
}
} while (is_obj_there(&lc) != 0);
/* 4-bytes aligned length */
if (p != NULL) {
}
return (p);
}
#ifdef DEBUG
void
void *p
)
{
}
#endif