mm.h revision d1d2228c6cf3ec632d28262810ab7902932a5d33
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _MM_H
#define _MM_H
#include <limits.h>
#include <mms_network.h>
#include <mms_mm_msg.h>
#include <host_ident.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Mount return codes */
#define MM_MOUNT_ERROR 0
#define MM_MOUNT_READY 1
#define MM_MOUNT_NOT_READY 2
#define MM_MOUNT_NEED_UNLOAD 3
/* UNmount return codes */
#define MM_UNMOUNT_ERROR 4
#define MM_UNMOUNT_READY 5
#define MM_UNMOUNT_NOT_READY 6
#define MM_DELETE_NOTIFY "delete from \"NOTIFY\" where "\
"\"ConnectionID\" = '%s';"
#define MM_DELETE_NOTIFYRULES "delete from \"NOTIFYRULES\" where "\
"\"ConnectionID\" = '%s';"
#define MM_DELETE_CONNECTION "delete from \"CONNECTION\" where "\
"\"ConnectionID\" = '%s';"
#define MM_DELETE_SESSION "delete from \"SESSION\" where "\
"\"SessionID\" = '%s';"
/* This is the string for a PCL outside of MMS */
/* postgres trigger in mm_db_plpgsql.c must use this string */
#define MM_NON_MMS_CART "non-MMS"
/*
* Core on fatal
*/
{ \
abort(); \
}
{ \
}
{ \
}
#define MM_PROGNAME "mm"
#define MM_PATHS_FN "/etc/mms/config/mm_paths.xml"
#define MM_TYPES_FN "/etc/mms/types/mm_types.xml"
#define UUID_PRINTF_SIZE 37
#define CMI_NUM_FIRSTMOUNT 100
#define CMI_NUM_ACCESSMODE 100
#define MM_NO_TASK NULL
/* Defines the max size of MM response, default 32000? */
/* 500 to test */
#define MM_CMD_SIZE_LIMIT 32000
/* DM Debug Options */
typedef enum mm_lmp_scope mm_lmp_scope_t;
enum mm_lmp_scope {
};
typedef struct mm_command mm_command_t;
typedef char uuid_text_t[UUID_PRINTF_SIZE];
goto no_mem; \
} \
}
/*
* MM config structure
*/
struct mm_cfg {
char *mm_ssl_dh_file; /* DH parameter file */
int mm_ssl_verify_peer; /* client cert required */
};
/*
* MMP begin end mode
*/
enum access_mode {
ACCESS_MODE_IMMEDIATE, /* run now */
ACCESS_MODE_BLOCKING /* willing to wait for resources */
};
/*
* MMP begin end data
*/
struct begin_end {
};
#define MM_NUM_STATUS_OBJS 14
#define MM_NUM_STATUS_ATTS 50
#define MM_NUM_CONTROL_ATTS 16
typedef struct mm_attribute_info mm_attribute_info_t;
struct mm_attribute_info {
char *status_objs[MM_NUM_STATUS_OBJS];
char *status_atts[MM_NUM_STATUS_ATTS];
char *control_atts[MM_NUM_CONTROL_ATTS];
};
/*
* MM data structure
*/
struct mm_data {
int mm_service_fd; /* mm service */
void *mm_ssl_data; /* mm secure socket layer context */
/* Db pointer */
int mm_work_todo;
int mm_tm_work_todo;
int mm_notify_work_todo;
int mm_cmd_dispatchable;
};
enum mm_lang {
MM_LANG_MMP, /* media manager */
MM_LANG_DMP, /* drive manager */
MM_LANG_LMP /* library manager */
};
typedef enum mm_privilege mm_privilege_t;
enum mm_privilege {
MM_PRIV_STANDARD, /* unprivileged app */
MM_PRIV_ADMIN, /* privileged app */
MM_PRIV_SYSTEM /* super user */
};
#define MM_SIDE_STRING "SIDE"
#define MM_PARTITION_STRING "PARTITION"
#define MM_VOLUME_STRING "VOLUME"
typedef enum mm_mount_type mm_mount_type_t;
enum mm_mount_type {
};
typedef enum mm_mount_when mm_mount_when_t;
enum mm_mount_when {
};
/*
* Client MMP, DMP, LMP parser function pointer
*/
struct cci {
char *cci_client;
char *cci_instance;
char *cci_language;
char *cci_version;
char *cci_password;
char *cci_certificate;
char *cci_authentication;
};
typedef struct cmi_mode_list cmi_mode_list_t;
struct cmi_mode_list {
char *cmi_accessmode[CMI_NUM_ACCESSMODE];
int cmi_num_accessmode;
};
typedef struct cmi_cart_list cmi_cart_list_t;
struct cmi_cart_list {
char *cmi_side_name;
char *cmi_library;
char *cmi_cart_pcl;
char *cmi_cart_type;
char *cmi_bit_format;
int cmi_cart_priority;
int cmi_cart_num_mounts;
int cmi_remove_cart;
int cmi_cart_not_ready;
int cmi_cart_loaded;
};
typedef struct cmi_drive_list cmi_drive_list_t;
struct cmi_drive_list {
char *cmi_drive_name;
char *cmi_dm_name;
int cmi_drv_priority;
int cmi_drv_num_mounts;
int cmi_mode_valid;
int cmi_drive_loaded;
char *cmi_loaded_pcl;
int cmi_remove_drive;
int cmi_drive_not_ready;
};
#define MM_MOUNT 0
#define MM_UNMOUNT 1
typedef struct cmd_mount_info cmd_mount_info_t;
struct cmd_mount_info {
int cmi_operation;
char *cmi_dm;
char *cmi_drive;
char *cmi_library;
char *cmi_cartridge;
char *cmi_pcl;
char *cmi_side_name;
char *cmi_capability;
char *cmi_handle;
int cmi_total_carts;
/* Recovery */
int cmi_retries;
int cmi_fail_type;
int cmi_fail_state;
int cmi_reset_states;
/* mount */
char *cmi_where;
char *cmi_firstmount[CMI_NUM_FIRSTMOUNT];
int cmi_num_firstmount;
int cmi_total_modes;
char *cmi_filename;
char *cmi_user;
char *cmi_blocksize;
char *cmi_filesequence;
char *cmi_volumeid;
char *cmi_retention;
int cmi_need_clear;
/* Dispatch info */
int cmi_mount_type;
char *cmi_first_drive;
char *cmi_first_lib;
char *cmi_second_drive;
char *cmi_second_lib;
/* unmount */
int cui_physical;
int cui_signature_clean;
char *cui_signature_type;
char *cui_signature;
int cui_skip_unload;
int cui_force;
};
#define MM_CANDIDATE_LOADED 5
#define MM_OPEN_DRIVE 6
#define MM_UNMOUNT_DRIVE 7
#define MM_UNMOUNT_CART 8
#define MM_UNMOUNT_2 9
typedef struct eject_cart eject_cart_t;
struct eject_cart {
char *cart_cartid;
char *cart_cartpcl;
char *cart_slottype;
char *cart_slotname;
char *cart_library;
};
typedef struct cmd_eject cmd_eject_t;
struct cmd_eject {
char *eject_library;
char *eject_lm;
char *eject_slotgroup;
};
typedef enum mm_msg_sev mm_msg_sev_t;
enum mm_msg_sev {
MESS_EMERG = 9,
MESS_ALERT = 8,
MESS_CRIT = 7,
MESS_ERROR = 6,
MESS_WARN = 5,
MESS_NOTICE = 4,
MESS_INFO = 3,
MESS_DEBUG = 2,
MESS_DEVP = 1
};
typedef enum mm_msg_who mm_msg_who_t;
enum mm_msg_who {
};
#define MESS_MANUFACTURER "SUNW"
#define MESS_MODEL "MMS"
#define MESS_LANG "EN"
#define MESS_MM_STR "MM"
#define MESS_DM_STR "DM"
#define MESS_LM_STR "LM"
#define MESS_AI_STR "AI"
#define MM_TIMESTAMP 24
typedef char mm_timestamp_t[MM_TIMESTAMP];
/* message flags */
#define MESS_FLAG_FIFO 0x1
#define MESS_FLAG_SLOG 0x2
#define MESS_FLAG_HANDLED 0x4
struct mm_msg {
char *msg_client_uuid;
char *msg_type;
char *msg_client;
char *msg_instance;
char *msg_cid;
char *msg_host;
char *msg_manufacturer;
char *msg_model;
int msg_messageid;
char *msg_lang;
char *msg_text;
char *msg_localized;
int msg_flags;
};
typedef struct mm_wka {
int mm_cmd_dispatchable;
int wka_remove;
int wka_need_accept;
int wka_goodbye;
int wka_unwelcome;
} mm_wka_t;
struct mm_command {
int cmd_flags;
/* Short name of command */
char *cmd_name;
/* Continue from state */
int cmd_state;
/* command root node */
/* Parse tree for response */
/* List of responses for each cmd */
/* Generated report */
char *cmd_report;
/* task string */
char *cmd_task;
/* dispatch this cmd */
char *cmd_textcmd;
/* command work buffer */
char *cmd_buf;
int cmd_bufsize;
/* command removal flag */
int cmd_remove;
/* mount information */
/* eject information */
/* Path Information */
int cmd_source_num;
int cmd_dest_num;
int cmd_const_num;
int cmd_has_list;
int cmd_begin_has_end;
/* Used for notify to clause */
int cmd_notify_to;
/* command message */
/* command request id */
/* error class */
char *cmd_eclass;
char *cmd_ecode;
};
/* Set and Unset Struct */
struct cmd_set {
int cmd_set_type;
char *cmd_set_obj;
char *cmd_set_attr;
char *cmd_set_value;
};
typedef struct notify_cmd notify_cmd_t;
struct notify_cmd {
int evt_can_dispatch;
/* Text of the command */
char *evt_cmd;
/* Connection info about the event originator */
char *evt_cli_name;
char *evt_cli_instance;
/* object is LM, DM, etc */
char *evt_obj_name;
/* object instance 'dm1' 'lm1' */
char *evt_obj_instance;
/* a host associated with the obj */
char *evt_obj_host;
/* If there is a lib associated with this obj */
char *evt_obj_library;
/* If there is a cartid associated with this obj */
char *evt_obj_cartid;
/* If there is a drive associated with this obj */
char *evt_obj_drive;
/* If there is a application associated with this obj */
char *evt_obj_app;
/* If there is a application instance */
/* associated with this obj */
char *evt_obj_appinst;
};
typedef struct mm_lib_stat mm_lib_stat_t;
struct mm_lib_stat {
char *lib_stat_name;
char *lib_stat_online;
char *lib_stat_disabled;
char *lib_stat_broken;
char *lib_stat_lm;
};
typedef struct mm_lm_stat mm_lm_stat_t;
struct mm_lm_stat {
char *lm_stat_name;
char *lm_stat_hard;
char *lm_stat_soft;
char *lm_stat_disabled;
char *lm_stat_library;
};
typedef struct mm_drive_stat mm_drive_stat_t;
struct mm_drive_stat {
char *drive_stat_name;
char *drive_stat_disabled;
char *drive_stat_broken;
char *drive_stat_soft;
char *drive_stat_hard;
char *drive_stat_lib_acc;
char *drive_stat_excl_app;
char *drive_stat_online;
char *drive_stat_group;
char *drive_stat_library;
char *drive_stat_priority;
char *drive_stat_dm;
char *drive_stat_geometry;
char *drive_stat_serial;
char *drive_stat_pcl;
char *drive_stat_drvlib_occ;
};
typedef struct mm_dm_stat mm_dm_stat_t;
struct mm_dm_stat {
char *dm_stat_name;
char *dm_stat_soft;
char *dm_stat_hard;
char *dm_stat_drive;
char *dm_stat_disabled;
char *dm_stat_host;
};
/* For cmd_set_type */
#define MM_SET 1
#define MM_UNSET 2
/* Dispatcher return codes */
/* no additional dispatch is necessary */
/* that has triggered another command for */
/* dispatch */
/* waiting for it has completed successfully */
/* reqires additional commands to be */
/* dispatched */
/* where more work is requried */
/* waiting on has terminated with an error */
/* when internal states */
/* have gotten out of sync */
/* Command Flags */
#define MM_CMD_DISPATCHABLE 0x01
#define MM_CMD_NEED_ACCEPT 0x02
#define MM_CMD_DEPEND_ERROR 0x04
#define MM_CMD_ACCEPTED 0x08
/* DMP DM Command Types */
#define MM_DMP_RESERVE 1
#define MM_DMP_PRIV 2
#define MM_DMP_LOAD 3
#define MM_DMP_ATTACH 4
#define MM_DMP_IDENTIFY 5
#define MM_DMP_DETACH 6
#define MM_DMP_UNLOAD 7
#define MM_DMP_RELEASE 8
/* Recovery */
#define MM_MAX_RETRY 1
#define MM_USE_RECOVER 0
#define NONE 0
#define LM 1
#define DM 2
#define MM 3
/* Parse Error Return Codes */
#define MM_PAR_NO_MEM 1
#define MM_PAR_ERROR 2
#define MM_PAR_OK 3
#define MM_PAR_SEND_UNACC 4
#define MM_PAR_SEND_UNWEL 5
#define MM_PAR_IS_RESP 6
/* Number-clause range */
enum mm_range_type {
};
typedef enum mm_range_type mm_range_type_t;
typedef struct mm_range mm_range_t;
struct mm_range {
int mm_range_first;
int mm_range_last;
};
/* MM routines */
extern void mm_set_mount_info_pcl(char *pcl,
extern void mm_set_mount_info_cart(char *cart_id,
extern void mm_set_mount_info_drive(char *drive,
extern void mm_set_mount_info_dm(char *dm,
extern void mm_set_mount_info_library(char *library,
char *cur_id, int need_unload);
char **drive_to_unload, char **lib_to_unload);
/* Cmd Depend list functions */
extern void
extern int
extern mm_command_t *
extern mm_command_t *
extern int
extern void
extern void
extern void
extern
int
/* MM Object Status */
/* Call these functions to get status of MM objects */
extern mm_lib_stat_t *
extern void
extern void
extern mm_lm_stat_t *
extern void
extern void
extern mm_drive_stat_t *
extern void
extern void
extern mm_dm_stat_t *
extern void
extern void
/* Event Notification Functions */
extern void mm_notify_close(void);
extern void mm_notify_rollback(char *cmd_uuid);
extern void mm_notify_commit(char *cmd_uuid);
char *cartridgepcl, char *libraryname);
char *libraryname);
char *type,
char *drivename);
char *drivename);
char *libraryname);
/* MMP Commands */
/* DMP Commands */
/* LMP Commands */
int
char *cartridge_pcl, char *library_name);
/* Message */
extern void mm_message_close(void);
extern int mm_msg_exists(int message_id);
int messageid, ...);
int messageid, ...);
/* System log file */
/* Operator Commands */
#ifdef __cplusplus
}
#endif
#endif /* _MM_H */