ndmpd_common.h revision faac71c002f7c7a98741f991b25937b24f309df0
/*
*/
/*
* BSD 3 Clause License
*
* Copyright (c) 2007, The Storage Networking Industry Association.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* - Neither the name of The Storage Networking Industry Association (SNIA)
* nor the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* Copyright (c) 2007, The Storage Networking Industry Association. */
/* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */
/*
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _NDMP_COMMON_H
#define _NDMP_COMMON_H
#include <thread.h>
#include <synch.h>
#include "ndmpd_log.h"
#include "ndmp.h"
#include <unistd.h>
#include <stdio.h>
#include <bsm/adt_event.h>
#define AUTH_REQUIRED TRUE
#define AUTH_NOT_REQUIRED FALSE
#define NDMP_EOM_MAGIC "PRCMEOM"
#define KILOBYTE 1024
#define INT_MAXCMD 12
extern mutex_t ndmpd_zfs_fd_lock;
/* Connection data structure. */
typedef struct msg_info {
struct ndmp_msg_handler *mi_handler;
void *mi_body;
} msg_info_t;
typedef struct ndmp_connection {
int conn_sock;
void *conn_client_data;
typedef void (*ndmp_con_handler_func_t) (struct ndmp_connection *);
typedef void ndmp_msg_handler_func_t(struct ndmp_connection *, void *);
typedef struct ndmp_msg_handler {
int mh_sizeof_request;
int mh_sizeof_reply;
typedef struct ndmp_handler {
int hd_cnt;
struct hd_messages {
} hd_msgs[INT_MAXCMD];
/*
* Function prototypes.
*/
extern ndmp_connection_t *ndmp_create_connection(void);
extern void ndmp_destroy_connection(ndmp_connection_t *);
extern void ndmp_close(ndmp_connection_t *);
extern int ndmp_connect(ndmp_connection_t *,
char *,
ulong_t);
extern int ndmp_process_requests(ndmp_connection_t *);
extern int ndmp_send_response(ndmp_connection_t *,
void *);
extern int ndmp_send_request(ndmp_connection_t *,
void *,
void **);
extern int ndmp_send_request_lock(ndmp_connection_t *,
void *,
void **);
extern void ndmp_free_message(ndmp_connection_t *);
extern int ndmp_get_fd(ndmp_connection_t *);
extern void ndmp_set_client_data(ndmp_connection_t *,
void *);
extern void *ndmp_get_client_data(ndmp_connection_t *);
extern void ndmp_set_version(ndmp_connection_t *,
ushort_t);
extern void ndmp_set_authorized(ndmp_connection_t *,
/*
* NDMP daemon callback functions.
*/
typedef char *ndmpd_get_env_func_t(void *, char *);
typedef int ndmpd_add_env_func_t(void *, char *, char *);
typedef void *ndmpd_get_name_func_t(void *, ulong_t);
typedef int ndmpd_dispatch_func_t(void *, boolean_t);
typedef void ndmpd_done_func_t(void *, int);
typedef int ndmpd_log_func_t(void *, char *, ...);
char *, ...);
#define NDMPD_SELECT_MODE_READ 1
#define NDMPD_SELECT_MODE_WRITE 2
#define NDMPD_SELECT_MODE_EXCEPTION 4
typedef void ndmpd_file_handler_func_t(void *, int, ulong_t);
typedef int ndmpd_add_file_handler_func_t(void *, void *, int, ulong_t,
typedef int ndmpd_remove_file_handler_func_t(void *, int);
typedef int ndmpd_write_func_t(void *, char *, ulong_t);
typedef int ndmpd_file_history_path_func_t(void *, char *, struct stat64 *,
typedef int ndmpd_file_history_dir_func_t(void *, char *, ulong_t,
ulong_t);
typedef int ndmpd_read_func_t(void *, char *, ulong_t);
typedef int ndmpd_file_recovered_func_t(void *, char *, int);
typedef struct ndmpd_module_stats {
/*
* Parameter structure passed to module start function.
*/
typedef struct ndmpd_module_params {
void *mp_daemon_cookie;
void **mp_module_cookie;
/*
* NDMP V3 params.
*/
#define MOD_ADDENV(m, n, v) \
(*(m)->mp_add_env_func)((m)->mp_daemon_cookie, n, v)
#define MOD_SETENV(m, n, v) \
(*(m)->mp_set_env_func)((m)->mp_daemon_cookie, n, v)
#define MOD_GETENV(m, e) \
(*(m)->mp_get_env_func)((m)->mp_daemon_cookie, e)
#define MOD_GETNAME(m, i) \
(*(m)->mp_get_name_func)((m)->mp_daemon_cookie, i)
#define MOD_LOG(m, ...) \
#define MOD_READ(m, b, s) \
(*(m)->mp_read_func)((m)->mp_daemon_cookie, b, s)
#define MOD_WRITE(m, b, s) \
(*(m)->mp_write_func)((m)->mp_daemon_cookie, b, s)
#define MOD_DONE(m, e) \
(*(m)->mp_done_func)((m)->mp_daemon_cookie, e)
#define MOD_FILERECOVERD(m, n, e) \
(*(m)->mp_file_recovered_func)((m)->mp_daemon_cookie, n, e)
extern int ndmp_log_msg_id;
#define MOD_LOGV3(m, t, ...) \
(*(m)->mp_log_func_v3)((m)->mp_daemon_cookie, (t), \
#define MOD_LOGCONTV3(m, t, ...) \
(*(m)->mp_log_func_v3)((m)->mp_daemon_cookie, \
(t), ndmp_log_msg_id, __VA_ARGS__)
/*
* Module function prototypes.
*/
typedef int module_start_func_t(void *);
typedef int module_abort_func_t(void *);
#endif /* _NDMP_COMMON_H */