libiscsi.h

Go to the documentation of this file.
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     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 
00167 PUBLIC int libiscsi_discover_firmware(struct libiscsi_context *context,
00168     int *nr_found, struct libiscsi_node **found_nodes);
00169 
00181 PUBLIC int libiscsi_verify_auth_info(struct libiscsi_context *context,
00182         const struct libiscsi_auth_info *auth_info);
00183 
00207 PUBLIC int libiscsi_node_set_auth(struct libiscsi_context *context,
00208     const struct libiscsi_node *node,
00209     const struct libiscsi_auth_info *auth_info);
00210 
00223 PUBLIC int libiscsi_node_get_auth(struct libiscsi_context *context,
00224     const struct libiscsi_node *node,
00225     struct libiscsi_auth_info *auth_info);
00226 
00236 PUBLIC int libiscsi_node_login(struct libiscsi_context *context,
00237     const struct libiscsi_node *node);
00238 
00248 PUBLIC int libiscsi_node_logout(struct libiscsi_context *context,
00249     const struct libiscsi_node *node);
00250 
00262 PUBLIC int libiscsi_node_set_parameter(struct libiscsi_context *context,
00263     const struct libiscsi_node *node,
00264     const char *parameter, const char *value);
00265 
00278 PUBLIC int libiscsi_node_get_parameter(struct libiscsi_context *context,
00279     const struct libiscsi_node *node, const char *parameter, char *value);
00280 
00292 PUBLIC const char *libiscsi_get_error_string(struct libiscsi_context *context);
00293 
00294 
00295 /************************** Utility functions *******************************/
00296 
00301 struct libiscsi_network_config {
00302     int dhcp                                  ;
00303     char iface_name[LIBISCSI_VALUE_MAXLEN]    ;
00304     char mac_address[LIBISCSI_VALUE_MAXLEN]   ;
00305     char ip_address[LIBISCSI_VALUE_MAXLEN]    ;
00306     char netmask[LIBISCSI_VALUE_MAXLEN]       ;
00307     char gateway[LIBISCSI_VALUE_MAXLEN]       ;
00308     char primary_dns[LIBISCSI_VALUE_MAXLEN]   ;
00309     char secondary_dns[LIBISCSI_VALUE_MAXLEN] ;
00310 };
00311 
00325 PUBLIC int libiscsi_get_firmware_network_config(
00326     struct libiscsi_network_config *config);
00327 
00336 PUBLIC int libiscsi_get_firmware_initiator_name(char *initiatorname);
00337 
00338 #undef PUBLIC
00339 
00340 #ifdef __cplusplus
00341 }
00342 #endif /* __cplusplus */
00343 
00344 #endif

Generated on Wed Feb 22 11:59:57 2012 for libiscsi by  doxygen 1.4.7