/* RFC 4171 lists a "iSCSI node certificate"
	 * as an option attribute of an iSCSI
	 * storage node, but doesn't define it anywhere
	 * in the spec.
	 */
};

static uint32_t iscsi_node_key_attrs[] = {
	ISNS_TAG_ISCSI_NAME,
};

isns_object_template_t		isns_iscsi_node_template = {
	.iot_name	= "iSCSI Storage Node",
	.iot_handle	= ISNS_OBJECT_TYPE_NODE,
	.iot_attrs	= iscsi_node_attrs,
	.iot_num_attrs	= array_num_elements(iscsi_node_attrs),
	.iot_keys	= iscsi_node_key_attrs,
	.iot_num_keys	= array_num_elements(iscsi_node_key_attrs),
	.iot_index	= ISNS_TAG_ISCSI_NODE_INDEX,
	.iot_next_index	= ISNS_TAG_ISCSI_NODE_NEXT_INDEX,
	.iot_container	= &isns_entity_template,
};

static uint32_t fc_port_attrs[] = {
	ISNS_TAG_FC_PORT_NAME_WWPN,
	ISNS_TAG_PORT_ID,
	ISNS_TAG_FC_PORT_TYPE,
	ISNS_TAG_SYMBOLIC_PORT_NAME,
	ISNS_TAG_FABRIC_PORT_NAME,
	ISNS_TAG_HARD_ADDRESS,
	ISNS_TAG_PORT_IP_ADDRESS,
Exemple #2
0
#include "vendor.h"
#include <libisns/util.h>

static uint32_t policy_attrs[] = {
	OPENISNS_TAG_POLICY_SPI,
	OPENISNS_TAG_POLICY_KEY,
	OPENISNS_TAG_POLICY_ENTITY,
	OPENISNS_TAG_POLICY_OBJECT_TYPE,
	OPENISNS_TAG_POLICY_NODE_NAME,
	OPENISNS_TAG_POLICY_NODE_TYPE,
	OPENISNS_TAG_POLICY_FUNCTIONS,
	OPENISNS_TAG_POLICY_VISIBLE_DD,
	OPENISNS_TAG_POLICY_DEFAULT_DD,
};

static uint32_t policy_key_attrs[] = {
	OPENISNS_TAG_POLICY_SPI,
};

isns_object_template_t		isns_policy_template = {
	.iot_name	= "Policy",
	.iot_handle	= ISNS_OBJECT_TYPE_POLICY,
	.iot_attrs	= policy_attrs,
	.iot_num_attrs	= array_num_elements(policy_attrs),
	.iot_keys	= policy_key_attrs,
	.iot_num_keys	= array_num_elements(policy_key_attrs),
	.iot_container	= &isns_entity_template,
	.iot_vendor_specific = 1,
};

static uint32_t	iscsi_pg_attrs[] = {
    ISNS_TAG_PG_ISCSI_NAME,
    ISNS_TAG_PG_PORTAL_IP_ADDR,
    ISNS_TAG_PG_PORTAL_TCP_UDP_PORT,
    ISNS_TAG_PG_TAG,
    ISNS_TAG_PG_INDEX,
};

static uint32_t	iscsi_pg_key_attrs[] = {
    ISNS_TAG_PG_ISCSI_NAME,
    ISNS_TAG_PG_PORTAL_IP_ADDR,
    ISNS_TAG_PG_PORTAL_TCP_UDP_PORT,
};

isns_object_template_t		isns_iscsi_pg_template = {
    .iot_name	= "iSCSI Portal Group",
    .iot_handle	= ISNS_OBJECT_TYPE_PG,
    .iot_attrs	= iscsi_pg_attrs,
    .iot_num_attrs	= array_num_elements(iscsi_pg_attrs),
    .iot_keys	= iscsi_pg_key_attrs,
    .iot_num_keys	= array_num_elements(iscsi_pg_key_attrs),
    .iot_attrs	= iscsi_pg_attrs,
    .iot_keys	= iscsi_pg_key_attrs,
    .iot_index	= ISNS_TAG_PG_INDEX,
    .iot_next_index	= ISNS_TAG_PG_NEXT_INDEX,
    .iot_container	= &isns_entity_template,
    .iot_relation_type = ISNS_RELATION_PORTAL_GROUP,
    .iot_build_relation = isns_db_build_pg_relation,
};

} Test;

static Test tests[] =
{
	{ 1L,		1L,		1L,		0	},
	{ 46340L,	46341L,		2147441940L,	0	},
	{ 46341L,	46341L,		0L,		-1	},
	{ 0L,		LONG_MAX,	0L,		0	},
	{ 1L,		LONG_MAX,	LONG_MAX,	0	},
	{ 2L,		LONG_MAX,	0L,		-1	},
	{ -1L,		LONG_MAX,	-2147483647L,	0	},
	{ 0L,		0L,		0L,		0	},
	{ 46340L,	-46341L,	-2147441940L,	0	},
	{ LONG_MAX,	-1L,		-2147483647L,	0,	},
};
static const int num_tests = array_num_elements (tests);

int
product (long multiplier,
	 long multiplicand,
	 long *product)
{
	char is_negative = 0; /* 0: positive, 1: negative */
	*product = 0;

	/* Deal with the sign -- make multiplier & multiplicand positive */
	if (is_positive (multiplier) != is_positive (multiplicand))
	{
		is_negative = 1;
	}
	if (!is_positive (multiplier))