00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef LSM_DATATYPES_H
00020 #define LSM_DATATYPES_H
00021
00022 #include "libstoragemgmt/libstoragemgmt_plug_interface.h"
00023 #include "libstoragemgmt/libstoragemgmt_common.h"
00024 #include "libxml/uri.h"
00025 #include <glib.h>
00026 #include "lsm_ipc.hpp"
00027
00028
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032
00033 #define MEMBER_FUNC_GET(return_type, name, param_sig, x, validation, member, error) \
00034 return_type name( param_sig ) {\
00035 if( validation(x) ) { \
00036 return x->member; \
00037 } else { \
00038 return error; \
00039 } \
00040 } \
00041
00042 #define MAGIC_CHECK(obj, m) ((obj) && \
00043 ((obj)->magic==(m) ))
00044 #define LSM_DEL_MAGIC(obj) ((obj & 0x0FFFFFFF) | 0xD0000000)
00045 #define LSM_VOL_MAGIC 0xAA7A0000
00046 #define LSM_IS_VOL(obj) MAGIC_CHECK(obj, LSM_VOL_MAGIC)
00047 #define LSM_FLAG_UNUSED_CHECK(x) ( x != 0 )
00048 #define LSM_FLAG_GET_VALUE(x) x["flags"].asUint64_t()
00049 #define LSM_FLAG_EXPECTED_TYPE(x) (Value::numeric_t == x["flags"].valueType())
00050 struct LSM_DLL_LOCAL _lsm_volume {
00053 uint32_t magic;
00054 char *id;
00055 char *name;
00056 char *vpd83;
00057 uint64_t block_size;
00058 uint64_t number_of_blocks;
00059 uint32_t admin_state;
00060 char *system_id;
00061 char *pool_id;
00062 char *plugin_data;
00063 };
00064
00065 #define LSM_POOL_MAGIC 0xAA7A0001
00066 #define LSM_IS_POOL(obj) MAGIC_CHECK(obj, LSM_POOL_MAGIC)
00067
00071 struct LSM_DLL_LOCAL _lsm_pool {
00072 uint32_t magic;
00073 char *id;
00074 char *name;
00075 uint64_t element_type;
00076 uint64_t unsupported_actions;
00077 uint64_t total_space;
00078 uint64_t free_space;
00079 uint64_t status;
00080 char *status_info;
00081 char *system_id;
00082 char *plugin_data;
00083 };
00084
00085
00086 #define LSM_ACCESS_GROUP_MAGIC 0xAA7A0003
00087 #define LSM_IS_ACCESS_GROUP(obj) MAGIC_CHECK(obj, LSM_ACCESS_GROUP_MAGIC)
00088
00092 struct _lsm_access_group {
00093 uint32_t magic;
00094 char *id;
00095 char *name;
00096 char *system_id;
00097 lsm_access_group_init_type init_type;
00099 lsm_string_list *initiators;
00101 char *plugin_data;
00102 };
00103
00104 #define LSM_NFS_EXPORT_MAGIC 0xAA7A0006
00105 #define LSM_IS_NFS_EXPORT(obj) MAGIC_CHECK(obj, LSM_NFS_EXPORT_MAGIC)
00106
00110 struct _lsm_nfs_export {
00111 uint32_t magic;
00112 char *id;
00113 char *fs_id;
00114 char *export_path;
00115 char *auth_type;
00116 lsm_string_list *root;
00117 lsm_string_list *rw;
00118 lsm_string_list *ro;
00119 uint64_t anonuid;
00120 uint64_t anongid;
00121 char *options;
00122 char *plugin_data;
00123 };
00124
00125 #define LSM_BLOCK_RANGE_MAGIC 0xAA7A0007
00126 #define LSM_IS_BLOCK_RANGE(obj) MAGIC_CHECK(obj, LSM_BLOCK_RANGE_MAGIC)
00127
00131 struct _lsm_block_range {
00132 uint32_t magic;
00133 uint64_t source_start;
00134 uint64_t dest_start;
00135 uint64_t block_count;
00136 };
00137
00138 #define LSM_CAPABILITIES_MAGIC 0xAA7A0008
00139 #define LSM_IS_CAPABILITIY(obj) MAGIC_CHECK(obj, LSM_CAPABILITIES_MAGIC)
00140
00141 #define LSM_CAP_MAX 512
00142
00146 struct _lsm_storage_capabilities {
00147 uint32_t magic;
00148 uint32_t len;
00149 uint8_t *cap;
00150 };
00151
00152 #define LSM_SYSTEM_MAGIC 0xAA7A0009
00153 #define LSM_IS_SYSTEM(obj) MAGIC_CHECK(obj, LSM_SYSTEM_MAGIC)
00154
00158 struct _lsm_system {
00159 uint32_t magic;
00160 char *id;
00161 char *name;
00162 uint32_t status;
00163 char *status_info;
00164 char *plugin_data;
00165 };
00166
00167 #define LSM_CONNECT_MAGIC 0xAA7A000A
00168 #define LSM_IS_CONNECT(obj) MAGIC_CHECK(obj, LSM_CONNECT_MAGIC)
00169
00170
00171 #define LSM_PLUGIN_MAGIC 0xAA7A000B
00172 #define LSM_IS_PLUGIN(obj) MAGIC_CHECK(obj, LSM_PLUGIN_MAGIC)
00173
00177 struct LSM_DLL_LOCAL _lsm_plugin {
00178 uint32_t magic;
00179 Ipc *tp;
00180 char *desc;
00181 char *version;
00182 void *private_data;
00183 lsm_error *error;
00184 lsm_plugin_register reg;
00185 lsm_plugin_unregister unreg;
00186 struct lsm_mgmt_ops_v1 *mgmt_ops;
00187 struct lsm_san_ops_v1 *san_ops;
00188 struct lsm_nas_ops_v1 *nas_ops;
00189 struct lsm_fs_ops_v1 *fs_ops;
00190 struct lsm_ops_v1_2 *ops_v1_2;
00191 };
00192
00193
00198 struct LSM_DLL_LOCAL _lsm_connect {
00199 uint32_t magic;
00200 uint32_t flags;
00201 xmlURIPtr uri;
00202 char *raw_uri;
00203 lsm_error *error;
00204 Ipc *tp;
00205 };
00206
00207
00208 #define LSM_ERROR_MAGIC 0xAA7A000C
00209 #define LSM_IS_ERROR(obj) MAGIC_CHECK(obj, LSM_ERROR_MAGIC)
00210
00214 struct LSM_DLL_LOCAL _lsm_error {
00215 uint32_t magic;
00216 lsm_error_number code;
00217 uint32_t reserved;
00218 char *message;
00219 char *exception;
00220 char *debug;
00221 void *debug_data;
00222 uint32_t debug_data_size;
00224 };
00225
00229 #define LSM_STRING_LIST_MAGIC 0xAA7A000D
00230 #define LSM_IS_STRING_LIST(obj) MAGIC_CHECK(obj, LSM_STRING_LIST_MAGIC)
00231 struct LSM_DLL_LOCAL _lsm_string_list {
00232 uint32_t magic;
00233 GPtrArray *values;
00234 };
00235
00239 #define LSM_FS_MAGIC 0xAA7A000E
00240 #define LSM_IS_FS(obj) MAGIC_CHECK(obj, LSM_FS_MAGIC)
00241 struct LSM_DLL_LOCAL _lsm_fs {
00242 uint32_t magic;
00243 char *id;
00244 char *name;
00245 char *pool_id;
00246 uint64_t total_space;
00247 uint64_t free_space;
00248 char *system_id;
00249 char *plugin_data;
00250 };
00251
00252 #define LSM_SS_MAGIC 0xAA7A000F
00253 #define LSM_IS_SS(obj) MAGIC_CHECK(obj, LSM_SS_MAGIC)
00254 struct LSM_DLL_LOCAL _lsm_fs_ss {
00255 uint32_t magic;
00256 char *id;
00257 char *name;
00258 uint64_t ts;
00259 char *plugin_data;
00260 };
00261
00262 #define LSM_DISK_MAGIC 0xAA7A0010
00263 #define LSM_IS_DISK(obj) MAGIC_CHECK(obj, LSM_DISK_MAGIC)
00264 struct LSM_DLL_LOCAL _lsm_disk {
00265 uint32_t magic;
00266 char *id;
00267 char *name;
00268 lsm_disk_type disk_type;
00269 uint64_t block_size;
00270 uint64_t block_count;
00271 uint64_t disk_status;
00272 char *system_id;
00273 };
00274
00275 #define LSM_HASH_MAGIC 0xAA7A0011
00276 #define LSM_IS_HASH(obj) MAGIC_CHECK(obj, LSM_HASH_MAGIC)
00277 struct LSM_DLL_LOCAL _lsm_hash {
00278 uint32_t magic;
00279 GHashTable *data;
00280 };
00281
00282
00283 #define LSM_TARGET_PORT_MAGIC 0xAA7A0012
00284 #define LSM_IS_TARGET_PORT(obj) MAGIC_CHECK(obj, LSM_TARGET_PORT_MAGIC)
00285 struct LSM_DLL_LOCAL _lsm_target_port {
00286 uint32_t magic;
00287 char *id;
00288 lsm_target_port_type port_type;
00289 char *service_address;
00290 char *network_address;
00291 char *physical_address;
00292 char *physical_name;
00293 char *system_id;
00294 char *plugin_data;
00295 };
00296
00297
00302 lsm_connect LSM_DLL_LOCAL *connection_get();
00303
00308 void LSM_DLL_LOCAL connection_free(lsm_connect * c);
00309
00321 int LSM_DLL_LOCAL driver_load(lsm_connect * c, const char *plugin,
00322 const char *password, uint32_t timeout,
00323 lsm_error_ptr * e, int startup, lsm_flag flags);
00324
00325 char LSM_DLL_LOCAL *capability_string(lsm_storage_capabilities * c);
00326
00327 const char LSM_DLL_LOCAL *uds_path(void);
00328
00343 int LSM_DLL_LOCAL number_convert(const char *str_num, int64_t * si,
00344 uint64_t * ui, long double *d);
00345
00346
00352 int LSM_DLL_LOCAL iqn_validate(const char *iqn);
00353
00359 int LSM_DLL_LOCAL wwpn_validate(const char *wwpn);
00360
00366 char LSM_DLL_LOCAL *wwpn_convert(const char *wwpn);
00367
00368 #ifdef __cplusplus
00369 }
00370 #endif
00371 #endif