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 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #pragma ident "%Z%%M% %I% %E% SMI" 27 28 /* 29 * SMB: tree_connect 30 * 31 * When a client connects to a server resource, an SMB_COM_TREE_CONNECT 32 * message is generated to the server. This command is almost exactly like 33 * SMB_COM_TREE_CONNECT_ANDX, except that no AndX command may follow; see 34 * section 4.1.4. 35 * 36 * Client Request Description 37 * ================================== ================================= 38 * 39 * UCHAR WordCount; Count of parameter words = 0 40 * USHORT ByteCount; Count of data bytes; min = 4 41 * UCHAR BufferFormat1; 0x04 42 * STRING Path[]; Server name and share name 43 * UCHAR BufferFormat2; 0x04 44 * STRING Password[]; Password 45 * UCHAR BufferFormat3; 0x04 46 * STRING Service[]; Service name 47 * 48 * The CIFS server responds with: 49 * 50 * Server Response Description 51 * ================================ ================================= 52 * 53 * UCHAR WordCount; Count of parameter words = 2 54 * USHORT MaxBufferSize; Max size message the server handles 55 * USHORT Tid; Tree ID 56 * USHORT ByteCount; Count of data bytes = 0 57 * 58 * If the negotiated dialect is MICROSOFT NETWORKS 1.03 or earlier, 59 * MaxBufferSize in the response message indicates the maximum size message 60 * that the server can handle. The client should not generate messages, 61 * nor expect to receive responses, larger than this. This must be 62 * constant for a given server. For newer dialects, this field is ignored. 63 * 64 * Tid should be included in any future SMBs referencing this tree 65 * connection. 66 */ 67 68 #include <smbsrv/smb_incl.h> 69 70 int 71 smb_com_tree_connect(struct smb_request *sr) 72 { 73 /* 74 * I'm not sure it this should be "%A.sA" 75 * now that unicode is enabled. 76 */ 77 if (smbsr_decode_data(sr, "%AAA", sr, &sr->arg.tcon.path, 78 &sr->arg.tcon.password, &sr->arg.tcon.service) != 0) { 79 smbsr_decode_error(sr); 80 /* NOTREACHED */ 81 } 82 83 sr->arg.tcon.flags = 0; 84 85 /* 86 * If the negotiated dialect is MICROSOFT NETWORKS 1.03 87 * or earlier, MaxBufferSize in the response message 88 * indicates the maximum size message that the server can 89 * handle. The client should not generate messages, nor 90 * expect to receive responses, larger than this. This 91 * must be constant for a given server. For newer dialects, 92 * this field is ignored. 93 * 94 * The reason for this is that the maximum buffer size is 95 * established during the NEGOTIATE. 96 */ 97 98 (void) smbsr_connect_tree(sr); 99 100 smbsr_encode_result(sr, 2, 0, "bwww", 101 2, /* wct */ 102 (WORD)smb_maxbufsize, /* MaxBufferSize */ 103 sr->smb_tid, /* TID */ 104 0); /* bcc */ 105 106 return (SDRC_NORMAL_REPLY); 107 } 108