func.c revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include "isns_server.h"
#include "isns_msgq.h"
#include "isns_func.h"
#include "isns_cache.h"
#include "isns_obj.h"
#include "isns_dd.h"
#include "isns_pdu.h"
#include "isns_qry.h"
#include "isns_scn.h"
#include "isns_utils.h"
#include "isns_cfg.h"
#include "isns_esi.h"
#include "isns_provider.h"
#include "isns_log.h"
/*
* extern global variables
*/
#ifdef DEBUG
extern int verbose_mc;
extern int verbose_tc;
#endif
extern const int NUM_OF_ATTRS[MAX_OBJ_TYPE_FOR_SIZE];
extern const int NUM_OF_CHILD[MAX_OBJ_TYPE];
extern const int TYPE_OF_PARENT[MAX_OBJ_TYPE_FOR_SIZE];
extern const int UID_ATTR_INDEX[MAX_OBJ_TYPE_FOR_SIZE];
/* scn message queue */
extern msg_queue_t *scn_q;
/*
* extern functions.
*/
/*
* local variables
*/
/*
* local functions.
*/
static int dev_attr_reg(conn_arg_t *);
static int dev_attr_qry(conn_arg_t *);
static int dev_get_next(conn_arg_t *);
static int dev_dereg(conn_arg_t *);
static int scn_reg(conn_arg_t *);
static int scn_dereg(conn_arg_t *);
static int dd_reg(conn_arg_t *);
static int dd_dereg(conn_arg_t *);
static int dds_reg(conn_arg_t *);
static int dds_dereg(conn_arg_t *);
static int msg_error(conn_arg_t *);
/*
* ****************************************************************************
*
* packet_get_source:
* get the source attributes of the packet.
*
* conn - the argument of the connection.
* return - error code.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
}
if (ec == 0) {
}
return (ec);
}
/*
* ****************************************************************************
*
* packet_get_key:
* get the key attributes of the packet.
*
* conn - the argument of the connection.
* return - error code.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
return (ec);
}
/*
* ****************************************************************************
*
* packet_get_operand:
* get the operating attributes of the packet.
*
* conn - the argument of the connection.
* return - error code.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
isns_tlv_t *op;
return (ec);
}
/*
* ****************************************************************************
*
* packet_split_verify:
* split and verify the packet, get the apporiate locking type and
* function handler for the packet.
*
* conn - the argument of the connection.
* return - error code.
*
* ****************************************************************************
*/
int
)
{
int ec = 0;
int lock = CACHE_NO_ACTION;
} else {
case ISNS_DEV_ATTR_REG:
lock = CACHE_WRITE;
break;
case ISNS_DEV_ATTR_QRY:
lock = CACHE_READ;
break;
case ISNS_DEV_GET_NEXT:
lock = CACHE_READ;
break;
case ISNS_DEV_DEREG:
lock = CACHE_WRITE;
break;
case ISNS_SCN_REG:
lock = CACHE_WRITE;
} else {
}
break;
case ISNS_SCN_DEREG:
lock = CACHE_WRITE;
} else {
}
break;
case ISNS_SCN_EVENT:
break;
case ISNS_DD_REG:
lock = CACHE_WRITE;
break;
case ISNS_DD_DEREG:
lock = CACHE_WRITE;
break;
case ISNS_DDS_REG:
lock = CACHE_WRITE;
break;
case ISNS_DDS_DEREG:
lock = CACHE_WRITE;
break;
default:
break;
}
}
if (ISNS_OPERATION_TYPE_ENABLED()) {
char buf[INET6_ADDRSTRLEN];
} else {
}
}
/* packet split & verify */
if (ec == 0) {
if (ec == 0) {
if (ec == 0) {
}
}
}
return (ec);
}
/*
* ****************************************************************************
*
* setup_key_lcp:
* setup the lookup control data for looking up the object
* which the key attributes identify.
*
* lcp - the pointer of the lookup control data.
* key - the key attributes.
* key_len - the length of the key attributes.
* return - the pointer of the lookup control data or
* NULL if there is an error.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
case ISNS_EID_ATTR_ID:
}
break;
case ISNS_ISCSI_NAME_ATTR_ID:
} else {
}
break;
if (key_len <= 8 ||
return (ISNS_RSP_MSG_FORMAT_ERROR);
}
} else {
}
break;
return (ISNS_RSP_MSG_FORMAT_ERROR);
}
if (key_len <= 8 ||
return (ISNS_RSP_MSG_FORMAT_ERROR);
}
if (key_len <= 8 ||
return (ISNS_RSP_MSG_FORMAT_ERROR);
}
break;
default:
}
return (ec);
}
/*
* ****************************************************************************
*
* rsp_add_op:
* add the operating attributes to the response packet.
*
* conn - the argument of the connection.
* obj - the object which is being added as operating attributes.
* return - error code.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
int i;
i = 0;
ec == 0) {
/* there is an attribute, send it back */
}
i ++;
}
return (ec);
}
/*
* ****************************************************************************
*
* rsp_add_key:
* add the key attributes to the response packet.
*
* conn - the argument of the connection.
* entity - the object which is being added as key attributes.
* return - error code.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
if (key_len == 0) {
} else {
while (key_len >= 8 &&
ec == 0) {
} else {
}
}
}
if (ec == 0) {
ISNS_DELIMITER_ATTR_ID, 0, NULL, 0);
}
if (ec == 0) {
}
return (ec);
}
/*
* ****************************************************************************
*
* rsp_add_tlv:
* add one attribute with TLV format to the response packet.
*
* conn - the argument of the connection.
* tag - the tag of the attribute.
* len - the length of the attribute.
* value- the value of the attribute.
* pflag- the flag of the value, 0: value; 1: pointer to value
* return - error code.
*
* ****************************************************************************
*/
static int
void *value,
int pflag
)
{
int ec = 0;
return (ec);
}
/*
* ****************************************************************************
*
* rsp_add_tlvs:
* add attributes with TLV format to the response packet.
*
* conn - the argument of the connection.
* tlv - the attributes with TLV format being added.
* tlv_len - the length of the attributes.
* return - error code.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
void *value;
while (tlv_len >= 8 &&
ec == 0) {
}
return (ec);
}
/*
* ****************************************************************************
*
* dev_attr_reg:
* function which handles the isnsp DEV_ATTR_REG message.
*
* conn - the argument of the connection.
* return - 0: the message requires response.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
int ctrl;
int ety_update, obj_update;
int i = 0;
if (ec != 0) {
goto reg_done;
}
/* validate key attributes and make lcp for */
/* the object identified by key attributes. */
/* object is not found */
/* error if it is a network entity */
}
/* validate for the source attribute before */
/* update or replace the network entity object */
} else if (ctrl == 0 &&
#ifndef SKIP_SRC_AUTH
#else
0) {
#endif
/* de-register the network entity if replace is true */
} else if (replace != 0) {
/* generate a SCN */
if (ec == 0) {
(void) queue_msg_set(scn_q,
SCN_TRIGGER, NULL);
}
}
}
}
if (ec != 0) {
goto reg_done;
}
/* register the network entity object */
if (ec != 0) {
goto reg_done;
}
ety = make_default_entity();
/* the eid in key attribute and */
/* op attribute must be the same */
goto reg_done;
}
} else {
ptype = OBJ_ENTITY;
}
if (ec == 0 && ety_update == 0) {
/* newly registered, reset the pointer */
}
/* register the reset of objects which are specified in */
/* operating attributes */
while (ec == 0 &&
/* set the parent object UID */
/* register it */
if (ec == 0) {
if (obj_update == 0 ||
is_obj_online(obj) == 0) {
/* update the ref'd object */
(void) update_ref_obj(obj);
/* add the newly registered object info */
/* to child info array of the parent object */
} else {
if (ctrl == 0 &&
#ifndef SKIP_SRC_AUTH
#else
0) {
#endif
}
/* it was for updating an existing object */
}
} else {
/* failed registering it */
}
}
/* update the portal group object for the associations between */
/* the newly registered objects and previously registered objects */
if (ec == 0) {
}
if (ec != 0) {
goto reg_done;
}
/* update the children list of the parent object */
while (i < MAX_CHILD_TYPE) {
break;
}
i ++;
}
} else {
#ifndef SKIP_SRC_AUTH
#else
/* for interop-ability, we cannot treat this as */
/* an error, instead, remove the network entity */
goto reg_done;
#endif
}
if (ec != 0) {
goto reg_done;
}
/* add esi entry */
if (ety_update != 0) {
(void) esi_remove(puid);
}
uid = 0;
while (uid < MAX_CHILD_TYPE) {
}
uid ++;
}
if (ec != 0) {
}
return (0);
}
/*
* ****************************************************************************
*
* dev_attr_qry:
* function which handles the isnsp DEV_ATTR_QRY message.
*
* conn - the argument of the connection.
* return - 0: the message requires response.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
/* isns_pdu_t *pdu = conn->in_packet.pdu; */
if (ec != 0) {
goto qry_done;
}
/*
* RFC 4171 section 5.7.5.2:
* If no Operating Attributes are included in the original query, then
* all Operating Attributes SHALL be returned in the response. ???
*/
if (op_len == 0) {
goto qry_done;
}
if (is_control_node(iscsi_name) == 0) {
goto qry_done;
}
}
size_of_ops = 0;
/*
* Return the original message key.
*/
if (ec != 0) {
goto qry_done;
}
/*
* Delimiter
*/
if (ec != 0) {
goto qry_done;
}
/*
* Query objects which match the Key Attributes.
*/
goto qry_done;
}
/*
* Iterate thru each object identified by the message key.
*/
/*
* Iterate thru each Operating Attributes.
*/
if (op_type == 0) {
goto qry_done;
}
&num_of_ops, &size_of_ops);
if (ec != 0) {
goto qry_done;
}
/*
* Iterate thru each object for the Operating
* Attributes again.
*/
if (ec != 0) {
goto qry_done;
}
});
});
});
} else {
/*
* Iterate thru each Operating Attributes.
*/
&num_of_ops, &size_of_ops);
if (ec != 0) {
goto qry_done;
}
/*
* Iterate thru each object for the Operating
* Attributes again.
*/
if (ec != 0) {
goto qry_done;
}
});
});
}
if (ec != 0) {
}
return (0);
}
/*
* ****************************************************************************
*
* dev_get_next:
* function which handles the isnsp DEV_GET_NEXT message.
*
* conn - the argument of the connection.
* return - 0: the message requires response.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
/* isns_pdu_t *pdu = conn->in_packet.pdu; */
if (ec != 0) {
goto get_next_done;
}
if (is_control_node(iscsi_name) == 0) {
}
if (ec != 0) {
goto get_next_done;
}
}
/*
* Get Message Key type and validate the Message Key.
*/
if (key_type == 0) {
goto get_next_done;
}
if (ec != 0) {
goto get_next_done;
}
size_of_obj = 0;
/*
* Query the objects which match the Operating Attributes.
*/
}
} else {
/*
* Query the objects which match the Message Key type.
*/
}
if (ec != 0) {
goto get_next_done;
}
/*
* Get the object which is next to the one indicated by the
* Message Key.
*/
if (uid == 0) {
goto get_next_done;
}
/*
* Message Key
*/
goto get_next_done;
}
/*
* Delimiter
*/
goto get_next_done;
}
/*
* Operating Attributes
*/
}
}
return (0);
}
/*
* ****************************************************************************
*
* dev_dereg:
* function which handles the isnsp DEV_DEREG message.
*
* conn - the argument of the connection.
* return - 0: the message requires response.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
/* isns_pdu_t *pdu = conn->in_packet.pdu; */
/* isns_tlv_t *key = conn->in_packet.key; */
/* uint16_t key_len = conn->in_packet.key_len; */
int ctrl;
if (ctrl == 0) {
}
case ISNS_EID_ATTR_ID:
break;
case ISNS_ISCSI_NAME_ATTR_ID:
break;
break;
if (op_len > 8 &&
} else {
}
break;
break;
default:
break;
}
if (ec == 0 &&
if (ctrl == 0 &&
#ifndef SKIP_SRC_AUTH
#else
0) {
#endif
} else {
}
}
}
if (ec != 0) {
}
return (0);
}
/*
* ****************************************************************************
*
* scn_reg:
* function which handles the isnsp SCN_REG message.
*
* conn - the argument of the connection.
* return - 0: the message requires response.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
/* isns_pdu_t *pdu = conn->in_packet.pdu; */
/* isns_tlv_t *source = conn->in_packet.source; */
/* uchar_t *src; */
/* src = (uchar_t *)&source->attr_value[0]; */
op_len != 12 ||
goto scn_reg_done;
}
if (ec != 0) {
}
return (0);
}
/*
* ****************************************************************************
*
* scn_dereg:
* function which handles the isnsp SCN_DEREG message.
*
* conn - the argument of the connection.
* return - 0: the message requires response.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
} else {
}
if (ec != 0) {
}
return (0);
}
/*
* ****************************************************************************
*
* setup_ddid_lcp:
* setup the lookup control data for looking up the DD object
* by using the dd_id attribute.
*
* lcp - pointer to the lookup control data.
* dd_id- the unique ID of the DD object.
* return - the pointer to the lcp.
*
* ****************************************************************************
*/
#ifndef DEBUG
static
#endif
)
{
return (lcp);
}
/*
* ****************************************************************************
*
* setup_ddsid_lcp:
* setup the lookup control data for looking up the DD-set object
* by using the dds_id attribute.
*
* lcp - pointer to the lookup control data.
* dds_id - the unique ID of the DD-set object.
* return - the pointer to the lcp.
*
* ****************************************************************************
*/
#ifndef DEBUG
static
#endif
)
{
return (lcp);
}
/*
* ****************************************************************************
*
* dd_reg:
* function which handles the isnsp DD_REG message.
*
* conn - the argument of the connection.
* return - 0: the message requires response.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
/* isns_pdu_t *pdu = conn->in_packet.pdu; */
if (is_control_node(iscsi_name) == 0) {
goto dd_reg_done;
}
if (ec != 0) {
goto dd_reg_done;
}
(key_len != 12 ||
goto dd_reg_done;
}
/* message key */
(void *)dd_id, 0)) != 0) {
goto dd_reg_done;
}
/* delimiter */
NULL, 0)) != 0) {
goto dd_reg_done;
}
/* A DDReg message with no Message Key SHALL result in the */
/* attempted creation of a new Discovery Domain (DD). */
if (dd_id == 0) {
if (ec == 0) {
if (ec == ERR_NAME_IN_USE) {
}
if (ec != 0) {
goto dd_reg_done;
}
} else {
goto dd_reg_done;
}
}
/* add the newly created dd to the response */
}
case ISNS_DD_ID_ATTR_ID:
/* if the DD_ID is included in both the Message Key */
/* and Operating Attributes, then the DD_ID value */
/* in the Message Key MUST be the same as the DD_ID */
/* value in the Operating Attributes. */
} else {
(void *)dd_id, 0);
}
}
break;
case ISNS_DD_NAME_ATTR_ID:
/* It is going to modify the DD Symbolic Name. */
ec = update_dd_name(
if (ec == ERR_NAME_IN_USE) {
}
} else {
}
if (ec == 0) {
}
}
break;
/* zero the association object */
ec = 0;
}
}
} else {
}
if (ec == 0) {
}
break;
ec = 0;
}
} else {
}
if (ec == 0) {
}
break;
break;
case ISNS_DD_FEATURES_ATTR_ID:
/* It is going to modify the DD Symbolic Name. */
} else {
}
if (ec == 0) {
4, (void *)features, 0);
}
}
break;
default:
break;
}
}
if (ec != 0) {
}
return (0);
}
/*
* ****************************************************************************
*
* dds_reg:
* function which handles the isnsp DDS_REG message.
*
* conn - the argument of the connection.
* return - 0: the message requires response.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
/* isns_pdu_t *pdu = conn->in_packet.pdu; */
if (is_control_node(iscsi_name) == 0) {
goto dds_reg_done;
}
if (ec != 0) {
goto dds_reg_done;
}
(key_len != 12 ||
goto dds_reg_done;
}
/* message key */
(void *)dds_id, 0)) != 0) {
goto dds_reg_done;
}
/* delimiter */
NULL, 0)) != 0) {
goto dds_reg_done;
}
/* A DDSReg message with no Message Key SHALL result in the */
/* attempted creation of a new Discovery Domain (DD). */
if (dds_id == 0) {
if (ec == 0) {
if (ec == ERR_NAME_IN_USE) {
}
if (ec != 0) {
goto dds_reg_done;
}
} else {
goto dds_reg_done;
}
}
/* add the newly created dd to the response */
}
case ISNS_DD_SET_ID_ATTR_ID:
/* if the DDS_ID is included in both the Message Key */
/* and Operating Attributes, then the DDS_ID value */
/* in the Message Key MUST be the same as the DDS_ID */
/* value in the Operating Attributes. */
} else {
4, (void *)dds_id, 0);
}
}
break;
case ISNS_DD_SET_NAME_ATTR_ID:
/* It is going to modify the DD Symbolic Name. */
if (ec == ERR_NAME_IN_USE) {
}
} else {
}
if (ec == 0) {
}
}
break;
/* It is going to modify the DD Symbolic Name. */
} else {
}
if (ec == 0) {
4, (void *)code, 0);
}
}
break;
case ISNS_DD_ID_ATTR_ID:
/* zero the association object */
ec = 0;
}
} else {
}
if (ec == 0) {
}
break;
default:
break;
}
}
if (ec != 0) {
}
return (0);
}
/*
* ****************************************************************************
*
* dd_dereg:
* function which handles the isnsp DD_DEREG message.
*
* conn - the argument of the connection.
* return - 0: the message requires response.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
/* isns_pdu_t *pdu = conn->in_packet.pdu; */
if (is_control_node(iscsi_name) == 0) {
goto dd_dereg_done;
}
key_len != 12 ||
goto dd_dereg_done;
}
} else {
/* zero the association object */
ec = 0;
}
}
break;
ec = 0;
}
break;
break;
default:
break;
}
}
}
if (ec != 0) {
}
return (0);
}
/*
* ****************************************************************************
*
* dds_dereg:
* function which handles the isnsp DDS_DEREG message.
*
* conn - the argument of the connection.
* return - 0: the message requires response.
*
* ****************************************************************************
*/
static int
)
{
int ec = 0;
/* isns_pdu_t *pdu = conn->in_packet.pdu; */
if (is_control_node(iscsi_name) == 0) {
goto dds_dereg_done;
}
key_len != 12 ||
goto dds_dereg_done;
}
} else {
ec = 0;
}
} else {
}
}
}
if (ec != 0) {
}
return (0);
}
/*
* ****************************************************************************
*
* msg_error:
* function which handles any unknown isnsp messages or the
* messages which are not supported.
*
* conn - the argument of the connection.
* return - 0: the message requires response.
*
* ****************************************************************************
*/
static int
/* LINTED E_FUNC_ARG_UNUSED */
)
{
return (0);
}
/*
* ****************************************************************************
*
* isns_response_ec:
* send the response message to the client with error code.
*
* so - the socket descriptor.
* pdu - the received pdu.
* ec - the error code which is being responsed.
* return - status of the sending operation.
*
* ****************************************************************************
*/
static int
int so,
int ec
)
{
int status;
return (status);
}
/*
* ****************************************************************************
*
* isns_response:
* send the response message to the client.
*
* conn - the argument of the connection.
* return - status of the sending operation.
*
* ****************************************************************************
*/
int
)
{
int status;
} else {
}
return (status);
}