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 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SMBSRV_SMB_XDR_H 27 #define _SMBSRV_SMB_XDR_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #include <rpc/xdr.h> 34 #include <sys/param.h> 35 #include <smbsrv/smbinfo.h> 36 37 typedef struct smb_dr_kshare { 38 int32_t k_op; 39 char *k_path; 40 char *k_sharename; 41 } smb_dr_kshare_t; 42 43 #ifdef _KERNEL 44 #define xdr_int8_t xdr_char 45 #define xdr_uint8_t xdr_u_char 46 #define xdr_int16_t xdr_short 47 #define xdr_uint16_t xdr_u_short 48 49 extern bool_t xdr_u_char(XDR *xdrs, uchar_t *cp); 50 extern bool_t xdr_vector(XDR *xdrs, char *basep, uint_t nelem, 51 uint_t elemsize, xdrproc_t xdr_elem); 52 53 smb_dr_kshare_t *smb_share_mkabsolute(uint8_t *buf, uint32_t len); 54 #else 55 uint8_t *smb_kshare_mkselfrel(smb_dr_kshare_t *kshare, uint32_t *len); 56 #endif /* _KERNEL */ 57 58 /* null-terminated string buffer */ 59 typedef struct smb_dr_string { 60 char *buf; 61 } smb_dr_string_t; 62 63 /* byte buffer (non-null terminated) */ 64 typedef struct smb_dr_bytes { 65 uint32_t bytes_len; 66 uint8_t *bytes_val; 67 } smb_dr_bytes_t; 68 69 #define SMB_OPIPE_HDR_MAGIC 0x4F484452 /* OHDR */ 70 #define SMB_OPIPE_DOOR_BUFSIZE (30 * 1024) 71 72 /* 73 * Door operations for opipes. 74 */ 75 typedef enum { 76 SMB_OPIPE_NULL = 0, 77 SMB_OPIPE_LOOKUP, 78 SMB_OPIPE_OPEN, 79 SMB_OPIPE_CLOSE, 80 SMB_OPIPE_READ, 81 SMB_OPIPE_WRITE, 82 SMB_OPIPE_STAT 83 } smb_opipe_op_t; 84 85 typedef struct smb_opipe_hdr { 86 uint32_t oh_magic; 87 uint32_t oh_fid; 88 uint32_t oh_op; 89 uint32_t oh_datalen; 90 uint32_t oh_resid; 91 uint32_t oh_status; 92 } smb_opipe_hdr_t; 93 94 typedef struct smb_opipe_context { 95 uint64_t oc_session_id; 96 uint16_t oc_uid; 97 uint16_t oc_domain_len; 98 char *oc_domain; 99 uint16_t oc_account_len; 100 char *oc_account; 101 uint16_t oc_workstation_len; 102 char *oc_workstation; 103 smb_inaddr_t oc_ipaddr; 104 int32_t oc_native_os; 105 int64_t oc_logon_time; 106 uint32_t oc_flags; 107 } smb_opipe_context_t; 108 109 typedef struct smb_ulist { 110 uint32_t ul_cnt; 111 smb_opipe_context_t *ul_users; 112 } smb_ulist_t; 113 114 /* xdr routines for common door arguments/results */ 115 extern bool_t xdr_smb_dr_string_t(XDR *, smb_dr_string_t *); 116 extern bool_t xdr_smb_dr_bytes_t(XDR *, smb_dr_bytes_t *); 117 extern bool_t xdr_smb_dr_kshare_t(XDR *, smb_dr_kshare_t *); 118 extern bool_t xdr_smb_inaddr_t(XDR *, smb_inaddr_t *); 119 120 int smb_opipe_hdr_encode(smb_opipe_hdr_t *, uint8_t *, uint32_t); 121 int smb_opipe_hdr_decode(smb_opipe_hdr_t *, uint8_t *, uint32_t); 122 bool_t smb_opipe_hdr_xdr(XDR *xdrs, smb_opipe_hdr_t *objp); 123 int smb_opipe_context_encode(smb_opipe_context_t *, uint8_t *, uint32_t, 124 uint_t *); 125 int smb_opipe_context_decode(smb_opipe_context_t *, uint8_t *, uint32_t, 126 uint_t *); 127 bool_t smb_opipe_context_xdr(XDR *, smb_opipe_context_t *); 128 /* 129 * VSS Door Structures 130 */ 131 #define SMB_VSS_GMT_SIZE sizeof ("@GMT-yyyy.mm.dd-hh.mm.ss") 132 133 typedef struct smb_dr_get_gmttokens { 134 uint32_t gg_count; 135 char *gg_path; 136 } smb_dr_get_gmttokens_t; 137 138 typedef char *gmttoken; 139 140 typedef struct smb_dr_return_gmttokens { 141 uint32_t rg_count; 142 struct { 143 uint_t rg_gmttokens_len; 144 gmttoken *rg_gmttokens_val; 145 } rg_gmttokens; 146 } smb_dr_return_gmttokens_t; 147 148 typedef struct smb_dr_map_gmttoken { 149 char *mg_path; 150 char *mg_gmttoken; 151 } smb_dr_map_gmttoken_t; 152 153 extern bool_t xdr_smb_dr_get_gmttokens_t(XDR *, smb_dr_get_gmttokens_t *); 154 extern bool_t xdr_gmttoken(XDR *, gmttoken *); 155 extern bool_t xdr_smb_dr_return_gmttokens_t(XDR *xdrs, 156 smb_dr_return_gmttokens_t *); 157 extern bool_t xdr_smb_dr_map_gmttoken_t(XDR *, smb_dr_map_gmttoken_t *); 158 159 #ifdef __cplusplus 160 } 161 #endif 162 163 #endif /* _SMBSRV_SMB_XDR_H */ 164