1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright 2022 Tintri by DDN, Inc. All rights reserved. 25 * Copyright 2022-2023 RackTop Systems, Inc. 26 */ 27 28 #ifndef _SMBD_H 29 #define _SMBD_H 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 #include <sys/types.h> 36 #include <thread.h> 37 #include <synch.h> 38 #include <smbsrv/smb_ioctl.h> 39 #include <smbsrv/smb_token.h> 40 #include <smbsrv/libsmb.h> 41 #include <smbsrv/libmlsvc.h> 42 43 void smbd_nomem(void) __NORETURN; 44 void smbd_report(const char *fmt, ...); 45 int smbd_pipesvc_start(void); 46 void smbd_pipesvc_stop(void); 47 int smbd_share_start(void); 48 void smbd_share_stop(void); 49 int smbd_nicmon_start(const char *); 50 void smbd_nicmon_stop(void); 51 int smbd_nicmon_refresh(void); 52 int smbd_dc_monitor_init(void); 53 void smbd_dc_monitor_refresh(void); 54 smb_token_t *smbd_user_auth_logon(smb_logon_t *); 55 void smbd_user_nonauth_logon(uint32_t); 56 void smbd_user_auth_logoff(uint32_t); 57 void smbd_join(smb_joininfo_t *, smb_joinres_t *); 58 void smbd_set_secmode(int); 59 boolean_t smbd_online(void); 60 void smbd_online_wait(const char *); 61 void smbd_get_authconf(smb_kmod_cfg_t *); 62 uint32_t smbd_logon_final(smb_token_t *, smb_inaddr_t *, char *, char *, 63 uint32_t); 64 65 void smbd_spool_start(void); 66 void smbd_spool_stop(void); 67 int smbd_cups_init(void); 68 void smbd_cups_fini(void); 69 void smbd_load_printers(void); 70 71 int smbd_vss_get_count(const char *, uint32_t *); 72 void smbd_vss_get_snapshots(const char *, uint32_t, uint32_t *, 73 uint32_t *, char **); 74 int smbd_vss_map_gmttoken(const char *, char *, time_t, char *); 75 76 typedef struct smbd { 77 const char *s_version; /* smbd version string */ 78 const char *s_pname; /* basename to use for messages */ 79 pid_t s_pid; /* process-ID of current daemon */ 80 uid_t s_uid; /* UID of current daemon */ 81 gid_t s_gid; /* GID of current daemon */ 82 int s_fg; /* Run in foreground */ 83 int s_debug; /* Enable debug output */ 84 int s_dbg_stop; /* stop for debugger attach */ 85 boolean_t s_initialized; 86 boolean_t s_shutting_down; /* shutdown control */ 87 volatile uint_t s_refreshes; 88 boolean_t s_kbound; /* B_TRUE if bound to kernel */ 89 int s_authsvc_sock; 90 int s_door_lmshr; 91 int s_door_srv; 92 int s_door_opipe; 93 int s_secmode; /* Current security mode */ 94 boolean_t s_dc_changed; 95 pthread_t s_refresh_tid; 96 pthread_t s_authsvc_tid; 97 pthread_t s_localtime_tid; 98 pthread_t s_spool_tid; 99 pthread_t s_dc_monitor_tid; 100 boolean_t s_nbt_listener_running; 101 boolean_t s_tcp_listener_running; 102 pthread_t s_nbt_listener_id; 103 pthread_t s_tcp_listener_id; 104 boolean_t s_fatal_error; 105 } smbd_t; 106 107 extern smbd_t smbd; 108 109 #define SMBD_LOG_MSGSIZE 256 110 111 #define SMBD_DOOR_NAMESZ 16 112 113 typedef struct smbd_door { 114 mutex_t sd_mutex; 115 cond_t sd_cv; 116 uint32_t sd_ncalls; 117 char sd_name[SMBD_DOOR_NAMESZ]; 118 } smbd_door_t; 119 120 #define SMBD_ARG_MAGIC 0x53415247 /* 'SARG' */ 121 122 /* 123 * Parameter for door operations. 124 */ 125 typedef struct smbd_arg { 126 uint32_t magic; 127 list_node_t lnd; 128 smb_doorhdr_t hdr; 129 const char *opname; 130 char *data; 131 size_t datalen; 132 char *rbuf; 133 size_t rsize; 134 boolean_t response_ready; 135 boolean_t response_abort; 136 uint32_t status; 137 } smbd_arg_t; 138 139 int smbd_door_start(void); 140 void smbd_door_stop(void); 141 void smbd_door_init(smbd_door_t *, const char *); 142 void smbd_door_fini(smbd_door_t *); 143 void smbd_door_enter(smbd_door_t *); 144 void smbd_door_return(smbd_door_t *, char *, size_t, door_desc_t *, uint_t); 145 146 void *smbd_door_dispatch_op(void *); 147 148 int smbd_authsvc_start(void); 149 void smbd_authsvc_stop(void); 150 151 /* For fksmbd */ 152 void fksmbd_init(void); 153 int fksmbd_door_dispatch(smb_doorarg_t *); 154 155 #ifdef __cplusplus 156 } 157 #endif 158 159 #endif /* _SMBD_H */ 160