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 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SMBSRV_SMB_DOOR_SVC_H 27 #define _SMBSRV_SMB_DOOR_SVC_H 28 29 #pragma ident "@(#)smb_door_svc.h 1.2 08/01/04 SMI" 30 31 #include <smbsrv/smb_token.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /* 38 * SMB door service (user-space and kernel-space) 39 */ 40 #define SMB_DR_SVC_NAME "/var/run/smbd_door" 41 #define SMB_DR_SVC_VERSION 1 42 #define SMB_DR_SVC_COOKIE ((void*)(0xdeadbeef^SMB_DR_SVC_VERSION)) 43 44 /* 45 * Door argument buffer starts off by the four-byte opcode. 46 * Door result buffer starts off by the four-byte status. 47 * The real data starts at offset 4 of the door buffer. 48 */ 49 #define SMB_DR_DATA_OFFSET 4 50 51 /* 52 * A smb_dr_op_t exists for each user-space door operation. 53 * A smb_kdr_op_t exists for each kernel-space door operation. 54 * 55 * The first argument to smb_dr_op_t/smb_kdr_op_t is a pointer to the 56 * door argument buffer. The second argument indicates the size of 57 * the door argument buffer. 58 * 59 * The user-space door server accepts file descriptors from clients. 60 * Thus, door_desc_t and n_desc can be passed to any smb_dr_op_t operation. 61 * 62 * Returns door result buffer and its size 'rbufsize' upon success. 63 * Otherwise, NULL pointer will be returned and appropriate error code 64 * will be set. 65 */ 66 typedef char *(*smb_dr_op_t)(char *argp, size_t arg_size, door_desc_t *dp, 67 uint_t n_desc, size_t *rbufsize, int *err); 68 typedef char *(*smb_kdr_op_t)(char *argp, size_t arg_size, size_t *rbufsize, 69 int *errno); 70 71 extern smb_dr_op_t smb_doorsrv_optab[]; 72 73 /* 74 * Door Opcode 75 * ------------- 76 * smb_dr_opcode_t - opcodes for user-space door operations. 77 * smb_kdr_opcode_t - opcodes for kernel-space door operations. 78 */ 79 enum smb_dr_opcode_t { 80 SMB_DR_USER_AUTH_LOGON, 81 SMB_DR_SET_DWNCALL_DESC, 82 SMB_DR_USER_NONAUTH_LOGON, 83 SMB_DR_USER_AUTH_LOGOFF, 84 SMB_DR_USER_LIST, 85 SMB_DR_LOOKUP_SID, 86 SMB_DR_LOOKUP_NAME 87 }; 88 89 enum smb_kdr_opcode_t { 90 SMB_KDR_USER_NUM, 91 SMB_KDR_USER_LIST, 92 SMB_KDR_SHARE 93 }; 94 95 /* 96 * Door result status 97 * SMB door servers will pass the following result status along with the 98 * requested data back to the clients. 99 */ 100 #define SMB_DR_OP_SUCCESS 0 101 #define SMB_DR_OP_ERR 1 102 #define SMB_DR_OP_ERR_DECODE 2 103 #define SMB_DR_OP_ERR_ENCODE 3 104 #define SMB_DR_OP_ERR_EMPTYBUF 4 105 #define SMB_DR_OP_ERR_INVALID_OPCODE 5 106 107 #ifdef _KERNEL 108 /* 109 * The 2nd argument of the smb_kdoor_srv_callback will be of the 110 * following data structure type. 111 * 112 * rbuf - The pointer to a dynamically allocated door result buffer that 113 * is required to be freed after the kernel completes the copyout 114 * operation. 115 */ 116 typedef struct smb_kdoor_cb_arg { 117 char *rbuf; 118 size_t rbuf_size; 119 } smb_kdoor_cb_arg_t; 120 121 /* 122 * SMB kernel door server 123 * ------------------------ 124 * NOTE: smb_kdoor_srv_init()/smb_kdoor_srv_fini() are noops. 125 */ 126 extern int smb_kdoor_srv_start(); 127 extern void smb_kdoor_srv_stop(); 128 extern int smb_kdr_is_valid_opcode(int opcode); 129 130 extern char *smb_kdr_op_user_num(char *argp, size_t arg_size, 131 size_t *rbufsize, int *errno); 132 extern char *smb_kdr_op_users(char *argp, size_t arg_size, 133 size_t *rbufsize, int *errno); 134 extern char *smb_kdr_op_share(char *argp, size_t arg_size, 135 size_t *rbufsize, int *errno); 136 137 /* 138 * SMB kernel door client 139 * ------------------------ 140 * NOTE: smb_kdoor_clnt_init()/smb_kdoor_clnt_fini() are noops. 141 */ 142 extern int smb_kdoor_clnt_start(); 143 extern void smb_kdoor_clnt_stop(); 144 extern void smb_kdoor_clnt_free(); 145 extern char *smb_kdoor_clnt_upcall(char *argp, size_t arg_size, door_desc_t *dp, 146 uint_t desc_num, size_t *rbufsize); 147 148 /* 149 * SMB upcalls 150 */ 151 extern smb_token_t *smb_upcall_get_token(netr_client_t *clnt_info); 152 extern int smb_upcall_set_dwncall_desc(uint32_t opcode, door_desc_t *dp, 153 uint_t n_desc); 154 extern void smb_user_nonauth_logon(uint32_t); 155 extern void smb_user_auth_logoff(uint32_t); 156 #else /* _KERNEL */ 157 158 /* 159 * SMB user-space door server 160 */ 161 extern int smb_door_srv_start(); 162 extern void smb_door_srv_stop(void); 163 164 /* downcall descriptor */ 165 typedef int (*smb_dwncall_get_desc_t)(); 166 extern int smb_dwncall_install_callback(smb_dwncall_get_desc_t get_desc_cb); 167 168 extern int smb_dr_is_valid_opcode(int opcode); 169 170 /* 171 * SMB user-space door client 172 */ 173 extern int smb_dr_clnt_open(int *fd, char *path, char *op_desc); 174 extern char *smb_dr_clnt_call(int fd, char *argp, size_t arg_size, 175 size_t *rbufsize, char *op_desc); 176 extern void smb_dr_clnt_free(char *argp, size_t arg_size, char *rbufp, 177 size_t rbuf_size); 178 /* 179 * SMB downcalls 180 */ 181 extern int smb_dwncall_get_users(int offset, smb_dr_ulist_t *users); 182 extern int smb_dwncall_share(int op, char *path, char *sharename); 183 184 #endif /* _KERNEL */ 185 186 #ifdef __cplusplus 187 } 188 #endif 189 190 #endif /* _SMBSRV_SMB_DOOR_SVC_H */ 191