fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _ISNS_CLIENT_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _ISNS_CLIENT_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/adapters/iscsi_if.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISNS_DEFAULT_ESI_SCN_PORT 32046
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISNS_DEFAULT_PORTAL_GROUP_TAG 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum isns_status {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_ok,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_no_svr_found,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_internal_err,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_create_msg_err,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_open_conn_err,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_send_msg_err,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_rcv_msg_err,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_no_rsp_rcvd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_op_failed,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_op_partially_failed,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_no_transport_found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} isns_status_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISNSP_MULT_PAYLOAD_HEADER_SIZE 8
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * when we concatenate payloads from multiple pdus, we need
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a larger payload_len then what is defined in isns_protocol.h
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for each payload that comes in, we need to save off the payload_len
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and the payload
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct isns_pdu_mult_payload {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t payload_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t payload[1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} isns_pdu_mult_payload_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct isns_scn_callback_arg {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t scn_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t source_key_attr[ISCSI_MAX_NAME_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} isns_scn_callback_arg_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To initialize the iSNS Client module.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_client_init(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To clean up the resources associated with the iSNS Client module.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_client_cleanup(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To register a network entity against the iSNS server(s) visible to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified LHBA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_status_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_reg(uint8_t *lhba_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t node_name_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_alias,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t node_alias_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t node_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*scn_callback)(void *));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To register a network entity against the specified iSNS server.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_status_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_reg_one_server(entry_t *isns_server,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *lhba_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t node_name_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_alias,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t node_alias_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t node_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*scn_callback)(void *));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To deregister a network entity from the all iSNS server(s) visible to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified LHBA.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_status_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_dereg(uint8_t *lhba_handle, uint8_t *node_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To deregister a network entity from the specified iSNS server.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_status_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_dereg_one_server(entry_t *isns_server, uint8_t *node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t is_last_isns_server);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To query all portal group objects that are visible to the specified LHBA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * registered through all iSNS servers this LHBA discovered.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pg_list is NULL if no portal group object is found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_status_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_query(uint8_t *lhba_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_alias,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t node_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_portal_group_list_t **pg_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To query all portal group objects registered through the specified iSNS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * server registered through the specified iSNS server. pg_list is NULL if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * no portal group object is found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_status_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_query_one_server(iscsi_addr_t *isns_server_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *lhba_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *node_alias,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t node_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_portal_group_list_t **pg_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To query the portal group objects associated with the specified storage
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * node through all iSNS servers this LHBA discovered. pg_list is NULL if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * no portal group object is found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_status_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_query_one_node(uint8_t *target_node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *lhba_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *source_node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *source_node_alias,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t source_node_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_portal_group_list_t **pg_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To query the portal group objects associated with the specified storage
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * node registered through the specified iSNS server. pg_list is NULL if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * no portal group object is found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_status_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteisns_query_one_server_one_node(iscsi_addr_t *isns_server_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *target_node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *lhba_handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *source_node_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *source_node_alias,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t source_node_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_portal_group_list_t **pg_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _ISNS_CLIENT_H */