#ifndef _LIBSMP_H
#define _LIBSMP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
#include <sys/sysmacros.h>
#include <sys/scsi/impl/usmp.h>
#include <sys/scsi/generic/smp_frames.h>
#include <libnvpair.h>
#include <stdarg.h>
#define LIBSMP_VERSION 1
#define SMP_TARGET_C_LONG_RESP 0x01
#define SMP_TARGET_C_ZONING 0x02
#define SMP_TARGET_C_ZG_256 0x04
typedef enum smp_errno {
ESMP_NONE,
ESMP_NOMEM,
ESMP_ZERO_LENGTH,
ESMP_VERSION,
ESMP_BADTARGET,
ESMP_BADFUNC,
ESMP_BADENGINE,
ESMP_NOENGINE,
ESMP_ENGINE_INIT,
ESMP_ENGINE_VER,
ESMP_ENGINE_BADPATH,
ESMP_BADLENGTH,
ESMP_NEEDBUF,
ESMP_PLUGIN,
ESMP_IO,
ESMP_SYS,
ESMP_PERM,
ESMP_RANGE,
ESMP_NOTSUP,
ESMP_UNKNOWN,
ESMP_REPGEN_FAILED,
ESMP_MAX
} smp_errno_t;
typedef struct smp_target_def {
const char *std_engine;
const void *std_def;
} smp_target_def_t;
struct smp_target;
typedef struct smp_target smp_target_t;
struct smp_action;
typedef struct smp_action smp_action_t;
extern int smp_init(int);
extern void smp_fini(void);
extern smp_target_t *smp_open(const smp_target_def_t *);
extern uint_t smp_target_getcap(const smp_target_t *);
extern uint16_t smp_target_get_change_count(const smp_target_t *);
extern void smp_target_set_change_count(smp_target_t *, uint16_t);
extern uint8_t smp_target_get_number_of_phys(const smp_target_t *);
extern uint16_t smp_target_get_exp_route_indexes(const smp_target_t *);
extern const char *smp_target_vendor(const smp_target_t *);
extern const char *smp_target_product(const smp_target_t *);
extern const char *smp_target_revision(const smp_target_t *);
extern const char *smp_target_component_vendor(const smp_target_t *);
extern uint16_t smp_target_component_id(const smp_target_t *);
extern uint8_t smp_target_component_revision(const smp_target_t *);
extern void smp_target_name(const smp_target_t *, char *, size_t);
extern uint64_t smp_target_addr(const smp_target_t *);
extern void smp_close(smp_target_t *);
extern smp_errno_t smp_errno(void);
extern smp_errno_t smp_errcode(const char *);
extern const char *smp_errmsg(void);
extern const char *smp_strerror(smp_errno_t);
extern const char *smp_errname(smp_errno_t);
extern char *smp_trim_strdup(const char *, size_t);
extern smp_action_t *smp_action_alloc(smp_function_t, smp_target_t *, size_t);
extern smp_action_t *smp_action_xalloc(smp_function_t, smp_target_t *,
void *, size_t, void *, size_t);
extern uint32_t smp_action_get_timeout(const smp_action_t *);
extern void smp_action_set_timeout(smp_action_t *, uint32_t);
extern void smp_action_get_request(const smp_action_t *, void **, size_t *);
extern void smp_action_get_response(const smp_action_t *,
smp_result_t *, void **, size_t *);
extern int smp_exec(smp_action_t *, smp_target_t *);
extern void smp_action_free(smp_action_t *);
extern nvlist_t *smp_discover(const smp_target_def_t **, size_t);
extern nvlist_t *smp_discover_targets(smp_target_t **, size_t);
#ifdef __cplusplus
}
#endif
#endif