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 #pragma ident "@(#)smb_share_door_decode.c 1.4 08/08/05 SMI" 27 28 /* 29 * Encode/decode functions used by both lmshare door server and client. 30 */ 31 32 #ifndef _KERNEL 33 #include <errno.h> 34 #include <string.h> 35 #include <strings.h> 36 #else 37 #include <sys/types.h> 38 #include <sys/sunddi.h> 39 #include <sys/errno.h> 40 #endif 41 42 #include <smbsrv/smb_share.h> 43 #include <smbsrv/smb_common_door.h> 44 #include <smbsrv/alloc.h> 45 #include <smbsrv/smbinfo.h> 46 47 void 48 smb_dr_get_share(smb_dr_ctx_t *ctx, smb_share_t *si) 49 { 50 if (ctx->status == 0) { 51 if (smb_dr_get_int32(ctx)) { 52 (void) memcpy(si, ctx->ptr, sizeof (smb_share_t)); 53 ctx->ptr += sizeof (smb_share_t); 54 } 55 else 56 bzero(si, sizeof (smb_share_t)); 57 } 58 else 59 bzero(si, sizeof (smb_share_t)); 60 } 61 62 void 63 smb_dr_put_share(smb_dr_ctx_t *ctx, smb_share_t *si) 64 { 65 if (si) { 66 smb_dr_put_int32(ctx, 1); 67 if (ctx->ptr + sizeof (smb_share_t) <= ctx->end_ptr) { 68 (void) memcpy(ctx->ptr, si, sizeof (smb_share_t)); 69 ctx->ptr += sizeof (smb_share_t); 70 } 71 else 72 ctx->status = ENOSPC; 73 } 74 else 75 smb_dr_put_int32(ctx, 0); 76 } 77