smb_kproto.h revision 856399cf160942495309c59ac7a9541834573cd3
/*
* 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 2013 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Function prototypes for the SMB module.
*/
#ifndef _SMB_KPROTO_H_
#define _SMB_KPROTO_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/socketvar.h>
#include <smbsrv/smb_vops.h>
#include <smbsrv/smb_token.h>
#include <smbsrv/smb_ktypes.h>
#include <smbsrv/smb_ioctl.h>
extern int smb_maxbufsize;
extern int smb_flush_required;
extern int smb_dirsymlink_enable;
extern int smb_oplock_levelII;
extern int smb_oplock_timeout;
extern int smb_oplock_min_timeout;
extern int smb_shortnames;
extern int smb_sign_debug;
extern int smb_raw_mode;
extern uint_t smb_audit_flags;
extern int smb_ssetup_threshold;
extern int smb_tcon_threshold;
extern int smb_opipe_threshold;
extern int smb_ssetup_timeout;
extern int smb_tcon_timeout;
extern int smb_opipe_timeout;
extern const uint32_t smb_vop_dosattr_settable;
/* Thread priorities - see smb_init.c */
extern int smbsrv_base_pri;
extern int smbsrv_listen_pri;
extern int smbsrv_receive_pri;
extern int smbsrv_worker_pri;
extern int smbsrv_notify_pri;
extern int smbsrv_timer_pri;
extern kmem_cache_t *smb_cache_request;
extern kmem_cache_t *smb_cache_session;
extern kmem_cache_t *smb_cache_user;
extern kmem_cache_t *smb_cache_tree;
extern kmem_cache_t *smb_cache_ofile;
extern kmem_cache_t *smb_cache_odir;
extern kmem_cache_t *smb_cache_opipe;
extern kmem_cache_t *smb_cache_event;
extern kmem_cache_t *smb_kshare_cache_vfs;
int fd_dealloc(int);
int clock_get_uptime(void);
int smb_server_lookup(smb_server_t **);
void smb_server_release(smb_server_t *);
/*
* SMB request handers called from the dispatcher. Each SMB request
* is handled in three phases: pre, com (command) and post.
*
* The pre-handler is primarily to set things up for the DTrace start
* probe. Typically, the SMB request is unmarshalled so that request
* specific context can be traced. This is also a useful place to
* allocate memory that will be used throughout the processing of the
* command.
*
* The com-handler performs the requested operation: request validation,
* bulk (write) incoming data decode, implementation of the appropriate
* algorithm and transmission of a response (as appropriate).
*
* The post-handler is always called, regardless of success or failure
* of the pre or com functions, to trigger the DTrace done probe and
* deallocate memory allocated in the pre-handler.
*/
#define SMB_SDT_OPS(NAME) \
#define SMB_COM_DECL(NAME) \
#define SMB_NT_TRANSACT_DECL(NAME) \
/*
* Logging functions
*/
void smb_log_flush(void);
void smb_close_all_connections(void);
int smb_net_id(uint32_t);
/*
* oplock functions - node operations
*/
int smb_oplock_init(void);
void smb_oplock_fini(void);
void smb_oplock_break_levelII(smb_node_t *);
void smb_oplock_broadcast(smb_node_t *);
/*
* range lock functions - node operations
*/
boolean_t smb_needs_mangled(const char *);
boolean_t smb_maybe_mangled(char *);
boolean_t smb_is_reserved_dos_name(const char *);
boolean_t smb_is_invalid_filename(const char *);
int smbsr_connect_tree(smb_request_t *);
void smb_convert_wildcards(char *);
boolean_t smb_contains_wildcards(const char *);
int smb_ascii_or_unicode_strlen(smb_request_t *, char *);
int smb_ascii_or_unicode_strlen_null(smb_request_t *, char *);
int smb_search(smb_request_t *);
boolean_t smb_is_stream_name(char *);
void smb_stream_parse_name(char *, char *, char *);
void sshow_distribution_info(char *);
void smb_dispatch_stats_init(smb_server_t *);
void smb_dispatch_stats_fini(smb_server_t *);
smb_kstat_req_t *, int, int);
void smbsr_lookup_file(smb_request_t *);
void smbsr_release_file(smb_request_t *);
int smbsr_encode_result(smb_request_t *, int, int, char *, ...);
void smbsr_send_reply(smb_request_t *);
void smbsr_map_errno(int, smb_error_t *);
void smbsr_errno(smb_request_t *, int);
int clock_get_milli_uptime(void);
int smb_mbc_decodef(mbuf_chain_t *, char *, ...);
int smb_mbc_encodef(mbuf_chain_t *, char *, ...);
int smb_mbc_peek(mbuf_chain_t *, int, char *, ...);
int smb_mbc_poke(mbuf_chain_t *, int, char *, ...);
int smb_mbc_put_mem(mbuf_chain_t *, void *, int);
/*
* Socket functions
*/
void smb_net_init(void);
void smb_net_fini(void);
void smb_net_txl_constructor(smb_txlst_t *);
void smb_net_txl_destructor(smb_txlst_t *);
smb_txreq_t *smb_net_txr_alloc(void);
void smb_net_txr_free(smb_txreq_t *);
/*
* SMB RPC interface
*/
void smb_opipe_dealloc(smb_opipe_t *);
int smb_opipe_open(smb_request_t *);
void smb_opipe_close(smb_ofile_t *);
void smb_opipe_door_init(smb_server_t *);
void smb_opipe_door_fini(smb_server_t *);
int smb_opipe_door_open(smb_server_t *, int);
void smb_opipe_door_close(smb_server_t *);
void smb_kdoor_init(smb_server_t *);
void smb_kdoor_fini(smb_server_t *);
int smb_kdoor_open(smb_server_t *, int);
void smb_kdoor_close(smb_server_t *);
/*
* SMB server functions (file smb_server.c)
*/
int smb_server_g_init(void);
int smb_server_g_fini(void);
int smb_server_create(void);
int smb_server_delete(void);
int smb_server_configure(smb_ioc_cfg_t *);
int smb_server_start(smb_ioc_start_t *);
int smb_server_stop(void);
int smb_server_set_gmtoff(smb_ioc_gmt_t *);
int smb_server_numopen(smb_ioc_opennum_t *);
int smb_server_enum(smb_ioc_svcenum_t *);
int smb_server_unshare(const char *);
void smb_server_inc_nbt_sess(smb_server_t *);
void smb_server_dec_nbt_sess(smb_server_t *);
void smb_server_inc_tcp_sess(smb_server_t *);
void smb_server_dec_tcp_sess(smb_server_t *);
void smb_server_inc_users(smb_server_t *);
void smb_server_dec_users(smb_server_t *);
void smb_server_inc_trees(smb_server_t *);
void smb_server_dec_trees(smb_server_t *);
void smb_server_inc_files(smb_server_t *);
void smb_server_dec_files(smb_server_t *);
void smb_server_inc_pipes(smb_server_t *);
void smb_server_dec_pipes(smb_server_t *);
void smb_server_inc_req(smb_server_t *);
void smb_event_destroy(smb_event_t *);
int smb_event_wait(smb_event_t *);
/*
* SMB node functions (file smb_node.c)
*/
void smb_node_init(void);
void smb_node_fini(void);
void smb_node_ref(smb_node_t *);
void smb_node_release(smb_node_t *);
void smb_node_end_crit(smb_node_t *);
int smb_node_in_crit(smb_node_t *);
void smb_node_rdlock(smb_node_t *);
void smb_node_wrlock(smb_node_t *);
void smb_node_unlock(smb_node_t *);
void smb_node_inc_open_ofiles(smb_node_t *);
void smb_node_inc_opening_count(smb_node_t *);
void smb_node_dec_opening_count(smb_node_t *);
void smb_node_notify_parents(smb_node_t *);
smb_ofile_t *, smb_attr_t *);
smb_ofile_t *, smb_attr_t *);
void smb_node_reset_delete_on_close(smb_node_t *);
/*
* Pathname functions
*/
/*
* smb_vfs functions
*/
void smb_vfs_rele_all(smb_export_t *);
/* NOTIFY CHANGE */
int smb_fem_fcn_install(smb_node_t *);
void smb_fem_fcn_uninstall(smb_node_t *);
int smb_fem_oplock_install(smb_node_t *);
void smb_fem_oplock_uninstall(smb_node_t *);
/* FEM */
int smb_fem_init(void);
void smb_fem_fini(void);
unsigned short smb_worker_getnum();
/* SMB signing routines smb_signing.c */
void smb_sign_g_init(void);
int smb_sign_check_request(smb_request_t *);
int smb_sign_check_secondary(smb_request_t *, unsigned int);
void smb_request_cancel(smb_request_t *);
void smb_request_wait(smb_request_t *);
/*
* session functions (file smb_session.c)
*/
void smb_session_receiver(smb_session_t *);
void smb_session_disconnect(smb_session_t *);
void smb_session_timers(smb_llist_t *);
smb_request_t *);
void smb_session_disconnect_from_share(smb_llist_t *, char *);
smb_tree_t *);
smb_tree_t *);
void smb_session_disconnect_share(smb_session_t *, const char *);
#define SMB_SESSION_GET_ID(s) ((s)->s_kid)
void smb_request_free(smb_request_t *);
/*
* ofile functions (file smb_ofile.c)
*/
void smb_ofile_delete(void *);
void smb_ofile_release(smb_ofile_t *);
void smb_ofile_request_complete(smb_ofile_t *);
void smb_ofile_close_all(smb_tree_t *);
void smb_ofile_set_delete_on_close(smb_ofile_t *);
void smb_delayed_write_timer(smb_llist_t *);
void smb_ofile_set_quota_resume(smb_ofile_t *, char *);
void smb_ofile_get_quota_resume(smb_ofile_t *, char *, int);
/*
* odir functions (file smb_odir.c)
*/
void smb_odir_close(smb_odir_t *);
void smb_odir_release(smb_odir_t *);
void smb_odir_delete(void *);
smb_odirent_t *, boolean_t *);
smb_fileinfo_t *, uint16_t *);
smb_streaminfo_t *, boolean_t *);
/*
* SMB user functions (file smb_user.c)
*/
void smb_user_logoff(smb_user_t *);
void smb_user_delete(void *);
void smb_user_hold_internal(smb_user_t *);
void smb_user_release(smb_user_t *);
void smb_user_netinfo_fini(smb_netuserinfo_t *);
/*
* SMB tree functions (file smb_tree.c)
*/
void smb_tree_dealloc(void *);
void smb_tree_release(smb_tree_t *);
void smb_check_status(void);
/*
* Pool ID function prototypes
*/
/*
* SMB thread function prototypes
*/
void smb_session_worker(void *arg);
/*
* SMB locked list function prototypes
*/
void smb_llist_init(void);
void smb_llist_fini(void);
void smb_llist_destructor(smb_llist_t *);
void smb_llist_exit(smb_llist_t *);
void smb_llist_flush(smb_llist_t *);
/*
* SMB Synchronized list function prototypes
*/
void smb_slist_destructor(smb_slist_t *);
void *, pri_t);
void smb_thread_destroy(smb_thread_t *);
int smb_thread_start(smb_thread_t *);
void smb_thread_stop(smb_thread_t *);
void smb_thread_signal(smb_thread_t *);
/* 100's of ns between 1/1/1970 and 1/1/1601 */
boolean_t smb_ace_is_generic(int);
boolean_t smb_ace_is_access(int);
boolean_t smb_ace_is_audit(int);
char *, smb_node_t **, smb_node_t **);
void smb_panic(char *, const char *, int);
#pragma does_not_return(smb_panic)
void smb_latency_init(smb_latency_t *);
void smb_latency_destroy(smb_latency_t *);
void smb_srqueue_init(smb_srqueue_t *);
void smb_srqueue_destroy(smb_srqueue_t *);
void smb_srqueue_waitq_enter(smb_srqueue_t *);
void smb_srqueue_runq_exit(smb_srqueue_t *);
void smb_srqueue_waitq_to_runq(smb_srqueue_t *);
void *smb_mem_alloc(size_t);
void *smb_mem_zalloc(size_t);
void *smb_mem_realloc(void *, size_t);
void *smb_mem_rezalloc(void *, size_t);
void smb_mem_free(void *);
void smb_mem_zfree(void *);
char *smb_mem_strdup(const char *);
void smb_srm_init(smb_request_t *);
void smb_srm_fini(smb_request_t *);
char *smb_srm_strdup(smb_request_t *, const char *);
void smb_export_start(smb_server_t *);
void smb_export_stop(smb_server_t *);
void smb_kshare_g_init(void);
void smb_kshare_g_fini(void);
void smb_kshare_init(smb_server_t *);
void smb_kshare_fini(smb_server_t *);
int smb_kshare_start(smb_server_t *);
void smb_kshare_stop(smb_server_t *);
int smb_kshare_info(smb_ioc_shareinfo_t *);
void smb_avl_destroy(smb_avl_t *);
int smb_avl_add(smb_avl_t *, void *);
void smb_avl_remove(smb_avl_t *, void *);
void *smb_avl_lookup(smb_avl_t *, void *);
void smb_avl_release(smb_avl_t *, void *);
void smb_threshold_fini(smb_cmd_threshold_t *);
void smb_threshold_exit(smb_cmd_threshold_t *);
#ifdef __cplusplus
}
#endif
#endif /* _SMB_KPROTO_H_ */