1*5331Samw /* 2*5331Samw * CDDL HEADER START 3*5331Samw * 4*5331Samw * The contents of this file are subject to the terms of the 5*5331Samw * Common Development and Distribution License (the "License"). 6*5331Samw * You may not use this file except in compliance with the License. 7*5331Samw * 8*5331Samw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*5331Samw * or http://www.opensolaris.org/os/licensing. 10*5331Samw * See the License for the specific language governing permissions 11*5331Samw * and limitations under the License. 12*5331Samw * 13*5331Samw * When distributing Covered Code, include this CDDL HEADER in each 14*5331Samw * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*5331Samw * If applicable, add the following below this CDDL HEADER, with the 16*5331Samw * fields enclosed by brackets "[]" replaced with your own identifying 17*5331Samw * information: Portions Copyright [yyyy] [name of copyright owner] 18*5331Samw * 19*5331Samw * CDDL HEADER END 20*5331Samw */ 21*5331Samw /* 22*5331Samw * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*5331Samw * Use is subject to license terms. 24*5331Samw */ 25*5331Samw 26*5331Samw #pragma ident "%Z%%M% %I% %E% SMI" 27*5331Samw 28*5331Samw #include <smbsrv/smb_incl.h> 29*5331Samw 30*5331Samw /* 31*5331Samw * The echo request is used to test the connection to the server, 32*5331Samw * and to see if the server is still responding. The tid is ignored, 33*5331Samw * so this request may be sent to the server even if there are no 34*5331Samw * tree connections to the server. 35*5331Samw * 36*5331Samw * Each response echoes the data sent, though ByteCount may indicate 37*5331Samw * no data. If echo-count is zero, no response is sent. 38*5331Samw */ 39*5331Samw int 40*5331Samw smb_com_echo(struct smb_request *sr) 41*5331Samw { 42*5331Samw unsigned short necho; 43*5331Samw unsigned short nbytes; 44*5331Samw unsigned short i; 45*5331Samw struct mbuf_chain reply; 46*5331Samw char *data; 47*5331Samw 48*5331Samw if (smbsr_decode_vwv(sr, "w", &necho) != 0) { 49*5331Samw smbsr_decode_error(sr); 50*5331Samw /* NOTREACHED */ 51*5331Samw } 52*5331Samw 53*5331Samw nbytes = sr->smb_bcc; 54*5331Samw 55*5331Samw data = smbsr_malloc(&sr->request_storage, nbytes); 56*5331Samw 57*5331Samw (void) smb_decode_mbc(&sr->smb_data, "#c", nbytes, data); 58*5331Samw 59*5331Samw for (i = 1; i <= necho; ++i) { 60*5331Samw 61*5331Samw MBC_INIT(&reply, SMB_HEADER_ED_LEN + 10 + nbytes); 62*5331Samw 63*5331Samw (void) smb_encode_mbc(&reply, SMB_HEADER_ED_FMT, 64*5331Samw sr->first_smb_com, 65*5331Samw sr->smb_rcls, 66*5331Samw sr->smb_reh, 67*5331Samw sr->smb_err, 68*5331Samw sr->smb_flg | SMB_FLAGS_REPLY, 69*5331Samw sr->smb_flg2, 70*5331Samw sr->smb_pid_high, 71*5331Samw sr->smb_sig, 72*5331Samw sr->smb_tid, 73*5331Samw sr->smb_pid, 74*5331Samw sr->smb_uid, 75*5331Samw sr->smb_mid); 76*5331Samw 77*5331Samw (void) smb_encode_mbc(&reply, "bww#c", 1, i, 78*5331Samw nbytes, nbytes, data); 79*5331Samw 80*5331Samw if (sr->session->signing.flags & SMB_SIGNING_ENABLED) 81*5331Samw smb_sign_reply(sr, &reply); 82*5331Samw 83*5331Samw (void) smb_session_send(sr->session, 0, &reply); 84*5331Samw } 85*5331Samw 86*5331Samw return (SDRC_NO_REPLY); 87*5331Samw } 88*5331Samw 89*5331Samw /* 90*5331Samw * Broadcast messages are not supported. 91*5331Samw */ 92*5331Samw int /*ARGSUSED*/ 93*5331Samw smb_com_send_broadcast_message(struct smb_request *sr) 94*5331Samw { 95*5331Samw return (SDRC_UNIMPLEMENTED); 96*5331Samw } 97*5331Samw 98*5331Samw /* 99*5331Samw * Multi-block messages are not supported. 100*5331Samw */ 101*5331Samw int /*ARGSUSED*/ 102*5331Samw smb_com_send_end_mb_message(struct smb_request *sr) 103*5331Samw { 104*5331Samw return (SDRC_UNIMPLEMENTED); 105*5331Samw } 106*5331Samw 107*5331Samw /* 108*5331Samw * Single-block messages are not supported. 109*5331Samw */ 110*5331Samw int /*ARGSUSED*/ 111*5331Samw smb_com_send_single_message(struct smb_request *sr) 112*5331Samw { 113*5331Samw return (SDRC_UNIMPLEMENTED); 114*5331Samw } 115*5331Samw 116*5331Samw /* 117*5331Samw * Multi-block messages are not supported. 118*5331Samw */ 119*5331Samw int /*ARGSUSED*/ 120*5331Samw smb_com_send_start_mb_message(struct smb_request *sr) 121*5331Samw { 122*5331Samw return (SDRC_UNIMPLEMENTED); 123*5331Samw } 124*5331Samw 125*5331Samw /* 126*5331Samw * Multi-block messages are not supported. 127*5331Samw */ 128*5331Samw int /*ARGSUSED*/ 129*5331Samw smb_com_send_text_mb_message(struct smb_request *sr) 130*5331Samw { 131*5331Samw return (SDRC_UNIMPLEMENTED); 132*5331Samw } 133