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_XDR_H 27 #define _SMBSRV_SMB_XDR_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 #include <rpc/xdr.h> 36 #include <sys/param.h> 37 38 typedef struct smb_dr_kshare { 39 int32_t k_op; 40 char *k_path; 41 char *k_sharename; 42 } smb_dr_kshare_t; 43 44 #ifdef _KERNEL 45 #define xdr_int8_t xdr_char 46 #define xdr_uint8_t xdr_u_char 47 #define xdr_int16_t xdr_short 48 #define xdr_uint16_t xdr_u_short 49 50 extern bool_t xdr_u_char(XDR *xdrs, uchar_t *cp); 51 extern bool_t xdr_vector(XDR *xdrs, char *basep, uint_t nelem, 52 uint_t elemsize, xdrproc_t xdr_elem); 53 54 smb_dr_kshare_t *smb_share_mkabsolute(uint8_t *buf, uint32_t len); 55 #else 56 uint8_t *smb_kshare_mkselfrel(smb_dr_kshare_t *kshare, uint32_t *len); 57 #endif /* _KERNEL */ 58 59 /* null-terminated string buffer */ 60 typedef struct smb_dr_string { 61 char *buf; 62 } smb_dr_string_t; 63 64 /* byte buffer (non-null terminated) */ 65 typedef struct smb_dr_bytes { 66 uint32_t bytes_len; 67 uint8_t *bytes_val; 68 } smb_dr_bytes_t; 69 70 #define SMB_DR_MAX_USERS 50 71 72 #define SMB_OPIPE_HDR_MAGIC 0x4F484452 /* OHDR */ 73 #define SMB_OPIPE_DOOR_BUFSIZE (30 * 1024) 74 75 /* 76 * Door operations for opipes. 77 */ 78 typedef enum { 79 SMB_OPIPE_NULL = 0, 80 SMB_OPIPE_LOOKUP, 81 SMB_OPIPE_OPEN, 82 SMB_OPIPE_CLOSE, 83 SMB_OPIPE_READ, 84 SMB_OPIPE_WRITE, 85 SMB_OPIPE_STAT 86 } smb_opipe_op_t; 87 88 typedef struct smb_opipe_hdr { 89 uint32_t oh_magic; 90 uint32_t oh_fid; 91 uint32_t oh_op; 92 uint32_t oh_datalen; 93 uint32_t oh_resid; 94 uint32_t oh_status; 95 } smb_opipe_hdr_t; 96 97 typedef struct smb_opipe_context { 98 uint64_t oc_session_id; 99 uint16_t oc_uid; 100 uint16_t oc_domain_len; 101 char *oc_domain; 102 uint16_t oc_account_len; 103 char *oc_account; 104 uint16_t oc_workstation_len; 105 char *oc_workstation; 106 uint32_t oc_ipaddr; 107 int32_t oc_native_os; 108 int64_t oc_logon_time; 109 uint32_t oc_flags; 110 } smb_opipe_context_t; 111 112 typedef struct smb_dr_ulist { 113 uint32_t dul_cnt; 114 smb_opipe_context_t dul_users[SMB_DR_MAX_USERS]; 115 } smb_dr_ulist_t; 116 117 /* xdr routines for common door arguments/results */ 118 extern bool_t xdr_smb_dr_string_t(XDR *, smb_dr_string_t *); 119 extern bool_t xdr_smb_dr_bytes_t(XDR *, smb_dr_bytes_t *); 120 extern bool_t xdr_smb_dr_ulist_t(XDR *, smb_dr_ulist_t *); 121 extern bool_t xdr_smb_dr_kshare_t(XDR *, smb_dr_kshare_t *); 122 123 int smb_opipe_hdr_encode(smb_opipe_hdr_t *, uint8_t *, uint32_t); 124 int smb_opipe_hdr_decode(smb_opipe_hdr_t *, uint8_t *, uint32_t); 125 bool_t smb_opipe_hdr_xdr(XDR *xdrs, smb_opipe_hdr_t *objp); 126 int smb_opipe_context_encode(smb_opipe_context_t *, uint8_t *, uint32_t); 127 int smb_opipe_context_decode(smb_opipe_context_t *, uint8_t *, uint32_t); 128 bool_t smb_opipe_context_xdr(XDR *, smb_opipe_context_t *); 129 130 #ifdef __cplusplus 131 } 132 #endif 133 134 #endif /* _SMBSRV_SMB_XDR_H */ 135