smbd.h revision 68b2bbf26c7040fea4281dcb58b81e7627e46f34
a23fd118e437af0a7877dd313db8fdaa3537c675yl/*
a23fd118e437af0a7877dd313db8fdaa3537c675yl * CDDL HEADER START
a23fd118e437af0a7877dd313db8fdaa3537c675yl *
a23fd118e437af0a7877dd313db8fdaa3537c675yl * The contents of this file are subject to the terms of the
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Common Development and Distribution License (the "License").
a23fd118e437af0a7877dd313db8fdaa3537c675yl * You may not use this file except in compliance with the License.
a23fd118e437af0a7877dd313db8fdaa3537c675yl *
a23fd118e437af0a7877dd313db8fdaa3537c675yl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a23fd118e437af0a7877dd313db8fdaa3537c675yl * or http://www.opensolaris.org/os/licensing.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See the License for the specific language governing permissions
a23fd118e437af0a7877dd313db8fdaa3537c675yl * and limitations under the License.
a23fd118e437af0a7877dd313db8fdaa3537c675yl *
a23fd118e437af0a7877dd313db8fdaa3537c675yl * When distributing Covered Code, include this CDDL HEADER in each
a23fd118e437af0a7877dd313db8fdaa3537c675yl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * If applicable, add the following below this CDDL HEADER, with the
a23fd118e437af0a7877dd313db8fdaa3537c675yl * fields enclosed by brackets "[]" replaced with your own identifying
a23fd118e437af0a7877dd313db8fdaa3537c675yl * information: Portions Copyright [yyyy] [name of copyright owner]
a23fd118e437af0a7877dd313db8fdaa3537c675yl *
a23fd118e437af0a7877dd313db8fdaa3537c675yl * CDDL HEADER END
a23fd118e437af0a7877dd313db8fdaa3537c675yl */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl
a23fd118e437af0a7877dd313db8fdaa3537c675yl/*
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
a23fd118e437af0a7877dd313db8fdaa3537c675yl */
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675yl#ifndef _SMBD_H
a23fd118e437af0a7877dd313db8fdaa3537c675yl#define _SMBD_H
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675yl#ifdef __cplusplus
a23fd118e437af0a7877dd313db8fdaa3537c675ylextern "C" {
a23fd118e437af0a7877dd313db8fdaa3537c675yl#endif
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675yl#include <sys/types.h>
a23fd118e437af0a7877dd313db8fdaa3537c675yl#include <thread.h>
a23fd118e437af0a7877dd313db8fdaa3537c675yl#include <synch.h>
a23fd118e437af0a7877dd313db8fdaa3537c675yl#include <smbsrv/smb_ioctl.h>
a23fd118e437af0a7877dd313db8fdaa3537c675yl#include <smbsrv/smb_token.h>
a23fd118e437af0a7877dd313db8fdaa3537c675yl#include <smbsrv/libsmb.h>
a23fd118e437af0a7877dd313db8fdaa3537c675yl#include <smbsrv/libmlsvc.h>
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_report(const char *fmt, ...);
a23fd118e437af0a7877dd313db8fdaa3537c675ylint smbd_pipesvc_start(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_pipesvc_stop(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylint smbd_share_start(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_share_stop(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylint smbd_nicmon_start(const char *);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_nicmon_stop(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylint smbd_nicmon_refresh(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylint smbd_dc_monitor_init(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_dc_monitor_refresh(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylsmb_token_t *smbd_user_auth_logon(smb_logon_t *);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_user_nonauth_logon(uint32_t);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_user_auth_logoff(uint32_t);
a23fd118e437af0a7877dd313db8fdaa3537c675yluint32_t smbd_join(smb_joininfo_t *);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_set_secmode(int);
a23fd118e437af0a7877dd313db8fdaa3537c675ylboolean_t smbd_online(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_online_wait(const char *);
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_spool_start(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_spool_stop(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylint smbd_cups_init(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_cups_fini(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_load_printers(void);
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675ylint smbd_vss_get_count(const char *, uint32_t *);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_vss_get_snapshots(const char *, uint32_t, uint32_t *,
a23fd118e437af0a7877dd313db8fdaa3537c675yl uint32_t *, char **);
a23fd118e437af0a7877dd313db8fdaa3537c675ylint smbd_vss_map_gmttoken(const char *, char *, char *);
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675yltypedef struct smbd {
a23fd118e437af0a7877dd313db8fdaa3537c675yl const char *s_version; /* smbd version string */
a23fd118e437af0a7877dd313db8fdaa3537c675yl const char *s_pname; /* basename to use for messages */
a23fd118e437af0a7877dd313db8fdaa3537c675yl pid_t s_pid; /* process-ID of current daemon */
a23fd118e437af0a7877dd313db8fdaa3537c675yl uid_t s_uid; /* UID of current daemon */
a23fd118e437af0a7877dd313db8fdaa3537c675yl gid_t s_gid; /* GID of current daemon */
a23fd118e437af0a7877dd313db8fdaa3537c675yl int s_fg; /* Run in foreground */
a23fd118e437af0a7877dd313db8fdaa3537c675yl int s_debug; /* Enable debug output */
a23fd118e437af0a7877dd313db8fdaa3537c675yl int s_dbg_stop; /* stop for debugger attach */
a23fd118e437af0a7877dd313db8fdaa3537c675yl boolean_t s_initialized;
a23fd118e437af0a7877dd313db8fdaa3537c675yl boolean_t s_shutting_down; /* shutdown control */
a23fd118e437af0a7877dd313db8fdaa3537c675yl volatile uint_t s_refreshes;
a23fd118e437af0a7877dd313db8fdaa3537c675yl boolean_t s_kbound; /* B_TRUE if bound to kernel */
a23fd118e437af0a7877dd313db8fdaa3537c675yl int s_door_lmshr;
a23fd118e437af0a7877dd313db8fdaa3537c675yl int s_door_srv;
a23fd118e437af0a7877dd313db8fdaa3537c675yl int s_door_opipe;
a23fd118e437af0a7877dd313db8fdaa3537c675yl int s_secmode; /* Current security mode */
a23fd118e437af0a7877dd313db8fdaa3537c675yl char s_site[MAXHOSTNAMELEN];
a23fd118e437af0a7877dd313db8fdaa3537c675yl smb_inaddr_t s_pdc;
a23fd118e437af0a7877dd313db8fdaa3537c675yl boolean_t s_pdc_changed;
a23fd118e437af0a7877dd313db8fdaa3537c675yl pthread_t s_refresh_tid;
a23fd118e437af0a7877dd313db8fdaa3537c675yl pthread_t s_localtime_tid;
a23fd118e437af0a7877dd313db8fdaa3537c675yl pthread_t s_spool_tid;
a23fd118e437af0a7877dd313db8fdaa3537c675yl pthread_t s_dc_monitor_tid;
a23fd118e437af0a7877dd313db8fdaa3537c675yl boolean_t s_nbt_listener_running;
a23fd118e437af0a7877dd313db8fdaa3537c675yl boolean_t s_tcp_listener_running;
a23fd118e437af0a7877dd313db8fdaa3537c675yl pthread_t s_nbt_listener_id;
a23fd118e437af0a7877dd313db8fdaa3537c675yl pthread_t s_tcp_listener_id;
a23fd118e437af0a7877dd313db8fdaa3537c675yl boolean_t s_fatal_error;
a23fd118e437af0a7877dd313db8fdaa3537c675yl} smbd_t;
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675ylextern smbd_t smbd;
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675yl#define SMBD_LOG_MSGSIZE 256
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675yl#define SMBD_DOOR_NAMESZ 16
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675yltypedef struct smbd_door {
a23fd118e437af0a7877dd313db8fdaa3537c675yl mutex_t sd_mutex;
a23fd118e437af0a7877dd313db8fdaa3537c675yl cond_t sd_cv;
a23fd118e437af0a7877dd313db8fdaa3537c675yl uint32_t sd_ncalls;
a23fd118e437af0a7877dd313db8fdaa3537c675yl char sd_name[SMBD_DOOR_NAMESZ];
a23fd118e437af0a7877dd313db8fdaa3537c675yl} smbd_door_t;
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675yl#define SMBD_ARG_MAGIC 0x53415247 /* 'SARG' */
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675yl/*
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Parameter for door operations.
a23fd118e437af0a7877dd313db8fdaa3537c675yl */
a23fd118e437af0a7877dd313db8fdaa3537c675yltypedef struct smbd_arg {
a23fd118e437af0a7877dd313db8fdaa3537c675yl uint32_t magic;
a23fd118e437af0a7877dd313db8fdaa3537c675yl list_node_t lnd;
a23fd118e437af0a7877dd313db8fdaa3537c675yl smb_doorhdr_t hdr;
a23fd118e437af0a7877dd313db8fdaa3537c675yl const char *opname;
a23fd118e437af0a7877dd313db8fdaa3537c675yl char *data;
a23fd118e437af0a7877dd313db8fdaa3537c675yl size_t datalen;
a23fd118e437af0a7877dd313db8fdaa3537c675yl char *rbuf;
a23fd118e437af0a7877dd313db8fdaa3537c675yl size_t rsize;
a23fd118e437af0a7877dd313db8fdaa3537c675yl boolean_t response_ready;
a23fd118e437af0a7877dd313db8fdaa3537c675yl boolean_t response_abort;
a23fd118e437af0a7877dd313db8fdaa3537c675yl uint32_t status;
a23fd118e437af0a7877dd313db8fdaa3537c675yl} smbd_arg_t;
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675ylint smbd_door_start(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_door_stop(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_door_init(smbd_door_t *, const char *);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_door_fini(smbd_door_t *);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_door_enter(smbd_door_t *);
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid smbd_door_return(smbd_door_t *, char *, size_t, door_desc_t *, uint_t);
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid *smbd_door_dispatch_op(void *);
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675yl/* For fksmbd */
a23fd118e437af0a7877dd313db8fdaa3537c675ylvoid fksmbd_init(void);
a23fd118e437af0a7877dd313db8fdaa3537c675ylint fksmbd_door_dispatch(smb_doorarg_t *);
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675yl#ifdef __cplusplus
a23fd118e437af0a7877dd313db8fdaa3537c675yl}
a23fd118e437af0a7877dd313db8fdaa3537c675yl#endif
a23fd118e437af0a7877dd313db8fdaa3537c675yl
a23fd118e437af0a7877dd313db8fdaa3537c675yl#endif /* _SMBD_H */
a23fd118e437af0a7877dd313db8fdaa3537c675yl