libiscsi
|
00001 /* 00002 * iSCSI Administration library 00003 * 00004 * Copyright (C) 2008-2009 Red Hat, Inc. All rights reserved. 00005 * Copyright (C) 2008-2009 Hans de Goede <hdegoede@redhat.com> 00006 * maintained by open-iscsi@googlegroups.com 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published 00010 * by the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * General Public License for more details. 00017 * 00018 * See the file COPYING included with this distribution for more details. 00019 */ 00020 00021 #ifndef __LIBISCSI_H 00022 #define __LIBISCSI_H 00023 00024 #include <netdb.h> 00025 00026 #ifdef __cplusplus 00027 extern "C" { 00028 #endif /* __cplusplus */ 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 /* Note open-iscsi has some code in place for multiple connections in one 00067 node record and thus multiple address / port combi's, but this does not 00068 get used anywhere, so we keep things simple and assume one connection */ 00069 char address[NI_MAXHOST] ; 00070 int port ; 00071 }; 00072 00079 struct libiscsi_chap_auth_info { 00080 char username[LIBISCSI_VALUE_MAXLEN] ; 00081 char password[LIBISCSI_VALUE_MAXLEN] ; 00082 char reverse_username[LIBISCSI_VALUE_MAXLEN] ; 00083 char reverse_password[LIBISCSI_VALUE_MAXLEN] ; 00084 }; 00085 00090 struct libiscsi_auth_info { 00091 enum libiscsi_auth_t method ; 00092 union { 00093 struct libiscsi_chap_auth_info chap ; 00094 } ; 00095 }; 00096 00104 PUBLIC struct libiscsi_context *libiscsi_init(void); 00105 00113 PUBLIC void libiscsi_cleanup(struct libiscsi_context *context); 00114 00140 PUBLIC int libiscsi_discover_sendtargets(struct libiscsi_context *context, 00141 const char *address, int port, const struct libiscsi_auth_info *auth_info, 00142 int *nr_found, struct libiscsi_node **found_nodes); 00143 00166 PUBLIC int libiscsi_discover_firmware(struct libiscsi_context *context, 00167 int *nr_found, struct libiscsi_node **found_nodes); 00168 00180 PUBLIC int libiscsi_verify_auth_info(struct libiscsi_context *context, 00181 const struct libiscsi_auth_info *auth_info); 00182 00206 PUBLIC int libiscsi_node_set_auth(struct libiscsi_context *context, 00207 const struct libiscsi_node *node, 00208 const struct libiscsi_auth_info *auth_info); 00209 00222 PUBLIC int libiscsi_node_get_auth(struct libiscsi_context *context, 00223 const struct libiscsi_node *node, 00224 struct libiscsi_auth_info *auth_info); 00225 00235 PUBLIC int libiscsi_node_login(struct libiscsi_context *context, 00236 const struct libiscsi_node *node); 00237 00247 PUBLIC int libiscsi_node_logout(struct libiscsi_context *context, 00248 const struct libiscsi_node *node); 00249 00261 PUBLIC int libiscsi_node_set_parameter(struct libiscsi_context *context, 00262 const struct libiscsi_node *node, 00263 const char *parameter, const char *value); 00264 00277 PUBLIC int libiscsi_node_get_parameter(struct libiscsi_context *context, 00278 const struct libiscsi_node *node, const char *parameter, char *value); 00279 00291 PUBLIC const char *libiscsi_get_error_string(struct libiscsi_context *context); 00292 00293 00294 /************************** Utility functions *******************************/ 00295 00300 struct libiscsi_network_config { 00301 int dhcp ; 00302 char iface_name[LIBISCSI_VALUE_MAXLEN] ; 00303 char mac_address[LIBISCSI_VALUE_MAXLEN] ; 00304 char ip_address[LIBISCSI_VALUE_MAXLEN] ; 00305 char netmask[LIBISCSI_VALUE_MAXLEN] ; 00306 char gateway[LIBISCSI_VALUE_MAXLEN] ; 00307 char primary_dns[LIBISCSI_VALUE_MAXLEN] ; 00308 char secondary_dns[LIBISCSI_VALUE_MAXLEN] ; 00309 }; 00310 00324 PUBLIC int libiscsi_get_firmware_network_config( 00325 struct libiscsi_network_config *config); 00326 00335 PUBLIC int libiscsi_get_firmware_initiator_name(char *initiatorname); 00336 00337 #undef PUBLIC 00338 00339 #ifdef __cplusplus 00340 } 00341 #endif /* __cplusplus */ 00342 00343 #endif