00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __LIBISCSI_H
00022 #define __LIBISCSI_H
00023
00024 #include <netdb.h>
00025
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029
00030 #if __GNUC__ >= 4
00031 #define PUBLIC __attribute__ ((visibility("default")))
00032 #else
00033 #define PUBLIC
00034 #endif
00035
00040 #define LIBISCSI_VALUE_MAXLEN 256
00041
00046 enum libiscsi_auth_t {
00047 libiscsi_auth_none ,
00048 libiscsi_auth_chap ,
00049 };
00050
00057 struct libiscsi_context;
00058
00063 struct libiscsi_node {
00064 char name[LIBISCSI_VALUE_MAXLEN] ;
00065 int tpgt ;
00066
00067
00068
00069 char address[NI_MAXHOST] ;
00070 int port ;
00071 char iface[LIBISCSI_VALUE_MAXLEN] ;
00072 };
00073
00080 struct libiscsi_chap_auth_info {
00081 char username[LIBISCSI_VALUE_MAXLEN] ;
00082 char password[LIBISCSI_VALUE_MAXLEN] ;
00083 char reverse_username[LIBISCSI_VALUE_MAXLEN] ;
00084 char reverse_password[LIBISCSI_VALUE_MAXLEN] ;
00085 };
00086
00091 struct libiscsi_auth_info {
00092 enum libiscsi_auth_t method ;
00093 union {
00094 struct libiscsi_chap_auth_info chap ;
00095 } ;
00096 };
00097
00105 PUBLIC struct libiscsi_context *libiscsi_init(void);
00106
00114 PUBLIC void libiscsi_cleanup(struct libiscsi_context *context);
00115
00141 PUBLIC int libiscsi_discover_sendtargets(struct libiscsi_context *context,
00142 const char *address, int port, const struct libiscsi_auth_info *auth_info,
00143 int *nr_found, struct libiscsi_node **found_nodes);
00144
00171 PUBLIC int libiscsi_discover_sendtargets_by_hwaddr(
00172 struct libiscsi_context *context,
00173 const char *address, int port,
00174 const struct libiscsi_auth_info *auth_info,
00175 char *hw_addr, int *nr_found,
00176 struct libiscsi_node **found_nodes);
00177
00200 PUBLIC int libiscsi_discover_firmware(struct libiscsi_context *context,
00201 int *nr_found, struct libiscsi_node **found_nodes);
00202
00214 PUBLIC int libiscsi_verify_auth_info(struct libiscsi_context *context,
00215 const struct libiscsi_auth_info *auth_info);
00216
00240 PUBLIC int libiscsi_node_set_auth(struct libiscsi_context *context,
00241 const struct libiscsi_node *node,
00242 const struct libiscsi_auth_info *auth_info);
00243
00256 PUBLIC int libiscsi_node_get_auth(struct libiscsi_context *context,
00257 const struct libiscsi_node *node,
00258 struct libiscsi_auth_info *auth_info);
00259
00269 PUBLIC int libiscsi_node_login(struct libiscsi_context *context,
00270 const struct libiscsi_node *node);
00271
00281 PUBLIC int libiscsi_node_logout(struct libiscsi_context *context,
00282 const struct libiscsi_node *node);
00283
00295 PUBLIC int libiscsi_node_set_parameter(struct libiscsi_context *context,
00296 const struct libiscsi_node *node,
00297 const char *parameter, const char *value);
00298
00311 PUBLIC int libiscsi_node_get_parameter(struct libiscsi_context *context,
00312 const struct libiscsi_node *node, const char *parameter, char *value);
00313
00325 PUBLIC const char *libiscsi_get_error_string(struct libiscsi_context *context);
00326
00327
00328
00329
00334 struct libiscsi_network_config {
00335 int dhcp ;
00336 char iface_name[LIBISCSI_VALUE_MAXLEN] ;
00337 char mac_address[LIBISCSI_VALUE_MAXLEN] ;
00338 char ip_address[LIBISCSI_VALUE_MAXLEN] ;
00339 char netmask[LIBISCSI_VALUE_MAXLEN] ;
00340 char gateway[LIBISCSI_VALUE_MAXLEN] ;
00341 char primary_dns[LIBISCSI_VALUE_MAXLEN] ;
00342 char secondary_dns[LIBISCSI_VALUE_MAXLEN] ;
00343 };
00344
00358 PUBLIC int libiscsi_get_firmware_network_config(
00359 struct libiscsi_network_config *config);
00360
00369 PUBLIC int libiscsi_get_firmware_initiator_name(char *initiatorname);
00370
00383 PUBLIC int libiscsi_set_netconfig(struct libiscsi_context *context,
00384 uint32_t host_no, char *transport_name,
00385 struct iovec *iovs, int param_count);
00386
00387 #undef PUBLIC
00388
00389 #ifdef __cplusplus
00390 }
00391 #endif
00392
00393 #endif