summaryrefslogtreecommitdiff
path: root/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h
diff options
context:
space:
mode:
Diffstat (limited to 'libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h')
-rw-r--r--libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h155
1 files changed, 155 insertions, 0 deletions
diff --git a/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h b/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h
index bf8a845..7b5a280 100644
--- a/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h
+++ b/libopeniscsiusr/libopeniscsiusr/libopeniscsiusr.h
@@ -25,6 +25,7 @@ extern "C" {
#include <stdint.h>
#include <stdarg.h>
+#include <stdbool.h>
#include "libopeniscsiusr_common.h"
#include "libopeniscsiusr_session.h"
@@ -324,6 +325,160 @@ __DLL_EXPORT int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid,
*/
__DLL_EXPORT void iscsi_session_free(struct iscsi_session *se);
+/**
+ * iscsi_default_iface_setup() - Setup default iSCSI interfaces.
+ *
+ * Setup default iSCSI interfaces for iSCSI TCP, iSER and iSCSI hardware offload
+ * cards. It is required after new iSCSI hardware offload card installed.
+ *
+ * Below kernel modules will be loaded when required by this function:
+ *
+ * * cxgb3i
+ * * cxgb4i
+ * * bnx2i
+ *
+ * It will also create configuration files for iSCSI hardware offload cards in
+ * /etc/iscsi/ifaces/<iface_name>.
+ *
+ * @ctx:
+ * Pointer of 'struct iscsi_context'.
+ *
+ * Return:
+ * int. Valid error codes are:
+ *
+ * * LIBISCSI_OK
+ *
+ * * LIBISCSI_ERR_BUG
+ *
+ * * LIBISCSI_ERR_NOMEM
+ *
+ * * LIBISCSI_ERR_ACCESS
+ *
+ * * LIBISCSI_ERR_SYSFS_LOOKUP
+ *
+ * * LIBISCSI_ERR_IDBM
+ *
+ * Error number could be converted to string by iscsi_strerror().
+ */
+__DLL_EXPORT int iscsi_default_iface_setup(struct iscsi_context *ctx);
+
+/**
+ * iscsi_ifaces_get() - Retrieve all iSCSI interfaces.
+ *
+ * Retrieves all iSCSI interfaces. For the properties of 'struct iscsi_iface',
+ * please refer to the functions defined in 'libopeniscsiusr_iface.h' file.
+ * The returned results contains default iSCSI interfaces(iser and iscsi_tcp)
+ * and iSCSI interfaces configured in "/etc/iscsi/ifaces/".
+ * Illegal configuration file will be skipped and warned.
+ * To generate iSCSI interface configuration when new card installed, please
+ * use iscsi_default_iface_setup().
+ *
+ * @ctx:
+ * Pointer of 'struct iscsi_context'.
+ * If this pointer is NULL, your program will be terminated by assert.
+ * @ifaces:
+ * Output pointer of 'struct iscsi_iface' pointer array. Its memory
+ * should be freed by iscsi_ifaces_free().
+ * If this pointer is NULL, your program will be terminated by assert.
+ * @iface_count:
+ * Output pointer of uint32_t. Will store the size of
+ * 'struct iscsi_iface' pointer array.
+ *
+ * Return:
+ * int. Valid error codes are:
+ *
+ * * LIBISCSI_OK
+ *
+ * * LIBISCSI_ERR_BUG
+ *
+ * * LIBISCSI_ERR_NOMEM
+ *
+ * * LIBISCSI_ERR_ACCESS
+ *
+ * * LIBISCSI_ERR_SYSFS_LOOKUP
+ *
+ * Error number could be converted to string by iscsi_strerror().
+ */
+__DLL_EXPORT int iscsi_ifaces_get(struct iscsi_context *ctx,
+ struct iscsi_iface ***ifaces,
+ uint32_t *iface_count);
+
+/**
+ * iscsi_ifaces_free() - Free the memory of 'struct iscsi_iface' pointer
+ * array
+ *
+ * Free the memory of 'iscsi_iface' pointer array generated by
+ * 'iscsi_ifaces_get()'.
+ * If provided 'ifaces' pointer is NULL or 'iface_count' is 0, do nothing.
+ *
+ * @ifaces:
+ * Pointer of 'struct iscsi_iface' pointer array.
+ * @iface_count:
+ * uint32_t, the size of 'struct iscsi_iface' pointer array.
+ *
+ * Return:
+ * void
+ */
+__DLL_EXPORT void iscsi_ifaces_free(struct iscsi_iface **ifaces,
+ uint32_t iface_count);
+
+/**
+ * iscsi_iface_get() - Retrieve specified iSCSI interface.
+ *
+ * Retrieves specified iSCSI interfaces by reading configuration from
+ * "/etc/iscsi/iface/<iface_name>".
+ * To generate iSCSI interface configuration when new card installed, please
+ * use iscsi_default_iface_setup().
+ * Illegal configuration file will be treated as error LIBISCSI_ERR_IDBM.
+ * Configuration file not found will be treated as error LIBISCSI_ERR_INVAL.
+ *
+ * @ctx:
+ * Pointer of 'struct iscsi_context'.
+ * If this pointer is NULL, your program will be terminated by assert.
+ * @iface_name:
+ * String. Name of iSCSI interface. Also the file name of configuration
+ * file "/etc/iscsi/iface/<iface_name>".
+ * If this pointer is NULL or empty string, your program will be terminated
+ * by assert.
+ * @iface:
+ * Output pointer of 'struct iscsi_iface'. Its memory should be freed by
+ * iscsi_iface_free().
+ * If this pointer is NULL, your program will be terminated by assert.
+ *
+ * Return:
+ * int. Valid error codes are:
+ *
+ * * LIBISCSI_OK
+ *
+ * * LIBISCSI_ERR_BUG
+ *
+ * * LIBISCSI_ERR_NOMEM
+ *
+ * * LIBISCSI_ERR_ACCESS
+ *
+ * * LIBISCSI_ERR_SYSFS_LOOKUP
+ *
+ * * LIBISCSI_ERR_IDBM
+ *
+ * Error number could be converted to string by iscsi_strerror().
+ */
+__DLL_EXPORT int iscsi_iface_get(struct iscsi_context *ctx,
+ const char *iface_name,
+ struct iscsi_iface **iface);
+
+/**
+ * iscsi_iface_free() - Free the memory of 'struct iscsi_iface' pointer.
+ *
+ * Free the memory of 'iscsi_iface' pointer generated by 'iscsi_iface_get()'.
+ * If provided 'iface' pointer is NULL, do nothing.
+ *
+ * @iface:
+ * Pointer of 'struct iscsi_iface' pointer.
+ *
+ * Return:
+ * void
+ */
+__DLL_EXPORT void iscsi_iface_free(struct iscsi_iface *iface);
#ifdef __cplusplus
} /* End of extern "C" */