libiscsi
libiscsi.h File Reference
#include <netdb.h>

Go to the source code of this file.

Data Structures

struct  libiscsi_session_timeout
 iSCSI session timeouts More...
 
struct  libiscsi_node
 iSCSI node record More...
 
struct  libiscsi_chap_auth_info
 libiscsi CHAP authentication information struct More...
 
struct  libiscsi_session_info
 iSCSI session More...
 
struct  libiscsi_auth_info
 generic libiscsi authentication information struct More...
 
struct  libiscsi_network_config
 libiscsi network config struct More...
 

Macros

#define PUBLIC
 
#define LIBISCSI_VALUE_MAXLEN   256
 Maximum length for iSCSI values.
 

Enumerations

enum  libiscsi_auth_t { libiscsi_auth_none , libiscsi_auth_chap }
 supported authentication methods More...
 

Functions

PUBLIC struct libiscsi_contextlibiscsi_init (void)
 Initalize libiscsi.
 
PUBLIC void libiscsi_cleanup (struct libiscsi_context *context)
 Cleanup libiscsi used resource.
 
PUBLIC int libiscsi_discover_sendtargets (struct libiscsi_context *context, const char *address, int port, const struct libiscsi_auth_info *auth_info, int *nr_found, struct libiscsi_node **found_nodes)
 Discover iSCSI nodes using sendtargets and add them to the node db.
 
PUBLIC int libiscsi_discover_firmware (struct libiscsi_context *context, int *nr_found, struct libiscsi_node **found_nodes)
 Read iSCSI node info from firmware and add them to the node db.
 
PUBLIC int libiscsi_verify_auth_info (struct libiscsi_context *context, const struct libiscsi_auth_info *auth_info)
 Check validity of the given authentication info.
 
PUBLIC int libiscsi_node_set_auth (struct libiscsi_context *context, const struct libiscsi_node *node, const struct libiscsi_auth_info *auth_info)
 Set the authentication info for the given node.
 
PUBLIC int libiscsi_node_get_auth (struct libiscsi_context *context, const struct libiscsi_node *node, struct libiscsi_auth_info *auth_info)
 Get the authentication info for the given node.
 
PUBLIC int libiscsi_node_login (struct libiscsi_context *context, const struct libiscsi_node *node)
 Login to an iSCSI node.
 
PUBLIC int libiscsi_node_logout (struct libiscsi_context *context, const struct libiscsi_node *node)
 Logout of an iSCSI node.
 
PUBLIC int libiscsi_get_session_infos (struct libiscsi_context *context, struct libiscsi_session_info **infos, int *nr_sessions)
 Get an array of iSCSI sessions.
 
PUBLIC int libiscsi_get_session_info_by_id (struct libiscsi_context *context, struct libiscsi_session_info *info, const char *session)
 Get session information by session ID.
 
PUBLIC int libiscsi_node_set_parameter (struct libiscsi_context *context, const struct libiscsi_node *node, const char *parameter, const char *value)
 Set an iSCSI parameter for the given node.
 
PUBLIC int libiscsi_node_get_parameter (struct libiscsi_context *context, const struct libiscsi_node *node, const char *parameter, char *value)
 Get the value of an iSCSI parameter for the given node.
 
PUBLIC const char * libiscsi_get_error_string (struct libiscsi_context *context)
 Get human readable string describing the last libiscsi error.
 
PUBLIC int libiscsi_get_firmware_network_config (struct libiscsi_network_config *config)
 Get network configuration information from iscsi firmware.
 
PUBLIC int libiscsi_get_firmware_initiator_name (char *initiatorname)
 Get the initiator name (iqn) from the iscsi firmware.
 

Macro Definition Documentation

◆ LIBISCSI_VALUE_MAXLEN

#define LIBISCSI_VALUE_MAXLEN   256

Maximum length for iSCSI values such as hostnames and parameter values.

◆ PUBLIC

#define PUBLIC

Enumeration Type Documentation

◆ libiscsi_auth_t

This enum lists all supported authentication methods.

Enumerator
libiscsi_auth_none 

No authentication

libiscsi_auth_chap 

CHAP authentication

Function Documentation

◆ libiscsi_cleanup()

PUBLIC void libiscsi_cleanup ( struct libiscsi_context * context)

This function cleanups any used resources and then destroys the passed context. After this the passed in context may no longer be used!

Parameters
contextlibiscsi context to operate on.

◆ libiscsi_discover_firmware()

PUBLIC int libiscsi_discover_firmware ( struct libiscsi_context * context,
int * nr_found,
struct libiscsi_node ** found_nodes )

This function discovers iSCSI nodes using firmware (ppc or ibft). Any found nodes are added to the local iSCSI node database and are returned in a dynamically allocated array.

Note that unlike sendtargets discovery, this function will also read authentication info and store that in the database too.

Note this function currently is a stub which will always return -EINVAL (IOW it is not yet implemented)

Parameters
contextlibiscsi context to operate on.
nr_foundThe number of found nodes will be returned through this pointer if not NULL.
found_nodesThe address of the dynamically allocated array of found nodes will be returned through this pointer if not NULL. The caller must free this array using free().
Returns
0 on success, otherwise a standard error code (from errno.h).

◆ libiscsi_discover_sendtargets()

PUBLIC int libiscsi_discover_sendtargets ( struct libiscsi_context * context,
const char * address,
int port,
const struct libiscsi_auth_info * auth_info,
int * nr_found,
struct libiscsi_node ** found_nodes )

This function connects to the given address and port and then tries to discover iSCSI nodes using the sendtargets protocol. Any found nodes are added to the local iSCSI node database and are returned in a dynamically allocated array.

Note that the (optional) authentication info is for authenticating the discovery, and is not for the found nodes! If the connection(s) to the node(s) need authentication too, you can set the username / password for those (which can be different!) using the libiscsi_node_set_auth() function.

Parameters
contextlibiscsi context to operate on.
addressHostname or IP-address to connect to.
portPort to connect to, or 0 for the default port.
auth_infoAuthentication information, or NULL.
nr_foundThe number of found nodes will be returned through this pointer if not NULL.
found_nodesThe address of the dynamically allocated array of found nodes will be returned through this pointer if not NULL. The caller must free this array using free().
Returns
0 on success, otherwise a standard error code (from errno.h).

◆ libiscsi_get_error_string()

PUBLIC const char * libiscsi_get_error_string ( struct libiscsi_context * context)

This function can be called to get a human readable error string when a libiscsi function has returned an error. This function uses a single buffer per context, thus the result is only valid as long as no other libiscsi calls are made on the same context after the failing function call.

Parameters
contextlibiscsi context to operate on.
Returns
human readable string describing the last libiscsi error.

◆ libiscsi_get_firmware_initiator_name()

PUBLIC int libiscsi_get_firmware_initiator_name ( char * initiatorname)

Get the initiator name (iqn) from the iscsi firmware.

Parameters
initiatornameThe initiator name is stored here, this buffer must be atleast LIBISCSI_VALUE_MAXLEN bytes large.
Returns
0 on success, ENODEV when no iscsi firmware was found.

◆ libiscsi_get_firmware_network_config()

PUBLIC int libiscsi_get_firmware_network_config ( struct libiscsi_network_config * config)

Function can be called to get the network configuration information (like dhcp, ip, netmask, default gateway, etc.) from the firmware of a network adapter with iscsi boot firmware.

Note that not all fields of the returned struct are necessarilly filled, unset fields contain a 0 length string.

Parameters
configpointer to a libiscsi_network_config struct to fill.
Returns
0 on success, ENODEV when no iscsi firmware was found.

◆ libiscsi_get_session_info_by_id()

PUBLIC int libiscsi_get_session_info_by_id ( struct libiscsi_context * context,
struct libiscsi_session_info * info,
const char * session )
Parameters
contextlibiscsi context to operate on.
infoiSCSI session information.
sessionSession name.
Returns
0 on success, otherwise a standard error code (from errno.h)

◆ libiscsi_get_session_infos()

PUBLIC int libiscsi_get_session_infos ( struct libiscsi_context * context,
struct libiscsi_session_info ** infos,
int * nr_sessions )

Get the array containing iSCSI sessions' information.

Parameters
contextlibiscsi context to operate on.
infosArray of iSCSI sessions' information. Release with free().
nr_sessionsThe number of elements in infos.
Returns
0 on success, otherwise a standard error code (from errno.h).

◆ libiscsi_init()

PUBLIC struct libiscsi_context * libiscsi_init ( void )

This function creates a libiscsi context and initalizes it. This context is need to use other libiscsi funtions.

Returns
A pointer to the created context, or NULL in case of an error.

◆ libiscsi_node_get_auth()

PUBLIC int libiscsi_node_get_auth ( struct libiscsi_context * context,
const struct libiscsi_node * node,
struct libiscsi_auth_info * auth_info )

This function gets the authentication information for the node described by the given node record.

Parameters
contextlibiscsi context to operate on.
nodeiSCSI node to set auth information of
auth_infoPointer to a libiscsi_auth_info struct where the retreived information will be stored.
Returns
0 on success, otherwise a standard error code (from errno.h).

◆ libiscsi_node_get_parameter()

PUBLIC int libiscsi_node_get_parameter ( struct libiscsi_context * context,
const struct libiscsi_node * node,
const char * parameter,
char * value )

Get the value of the given nodes iSCSI parameter named by parameter.

Parameters
contextlibiscsi context to operate on.
nodeiSCSI node to change a parameter from.
parameterName of the parameter to get.
valueThe retreived value is stored here, this buffer must be atleast LIBISCSI_VALUE_MAXLEN bytes large.
Returns
0 on success, otherwise a standard error code (from errno.h).

◆ libiscsi_node_login()

PUBLIC int libiscsi_node_login ( struct libiscsi_context * context,
const struct libiscsi_node * node )

Login to the iSCSI node described by the given node record.

Parameters
contextlibiscsi context to operate on.
nodeiSCSI node to login to.
Returns
0 on success, otherwise a standard error code (from errno.h).

◆ libiscsi_node_logout()

PUBLIC int libiscsi_node_logout ( struct libiscsi_context * context,
const struct libiscsi_node * node )

Logout of the iSCSI node described by the given node record.

Parameters
contextlibiscsi context to operate on.
nodeiSCSI node to logout from.
Returns
0 on success, otherwise a standard error code (from errno.h).

◆ libiscsi_node_set_auth()

PUBLIC int libiscsi_node_set_auth ( struct libiscsi_context * context,
const struct libiscsi_node * node,
const struct libiscsi_auth_info * auth_info )

This function sets the authentication information for the node described by the given node record. This will overwrite any existing authentication information.

This is the way to specify authentication information for nodes found through sendtargets discovery.

Note: 1) This is a convience wrapper around libiscsi_node_set_parameter(), setting the node.session.auth.* parameters. 2) For nodes found through firmware discovery the authentication information has already been set from the firmware. 3) auth_info may be NULL in which case any existing authinfo will be cleared.

Parameters
contextlibiscsi context to operate on.
nodeiSCSI node to set auth information of
auth_infoAuthentication information, or NULL.
Returns
0 on success, otherwise a standard error code (from errno.h).

◆ libiscsi_node_set_parameter()

PUBLIC int libiscsi_node_set_parameter ( struct libiscsi_context * context,
const struct libiscsi_node * node,
const char * parameter,
const char * value )

Set the given nodes iSCSI parameter named by parameter to value value.

Parameters
contextlibiscsi context to operate on.
nodeiSCSI node to change a parameter from.
parameterName of the parameter to set.
valueValue to set the parameter too.
Returns
0 on success, otherwise a standard error code (from errno.h).

◆ libiscsi_verify_auth_info()

PUBLIC int libiscsi_verify_auth_info ( struct libiscsi_context * context,
const struct libiscsi_auth_info * auth_info )

This function checks the validity of the given authentication info. For example in case of CHAP, if the username and password are not empty.

This function is mainly intended for use by language bindings.

Parameters
contextlibiscsi context to operate on.
auth_infoAuthentication information to check.
Returns
0 on success, otherwise EINVAL.

Generated for libiscsi by doxygen 1.13.2