15331Samw /* 25331Samw * CDDL HEADER START 35331Samw * 45331Samw * The contents of this file are subject to the terms of the 55331Samw * Common Development and Distribution License (the "License"). 65331Samw * You may not use this file except in compliance with the License. 75331Samw * 85331Samw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 95331Samw * or http://www.opensolaris.org/os/licensing. 105331Samw * See the License for the specific language governing permissions 115331Samw * and limitations under the License. 125331Samw * 135331Samw * When distributing Covered Code, include this CDDL HEADER in each 145331Samw * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 155331Samw * If applicable, add the following below this CDDL HEADER, with the 165331Samw * fields enclosed by brackets "[]" replaced with your own identifying 175331Samw * information: Portions Copyright [yyyy] [name of copyright owner] 185331Samw * 195331Samw * CDDL HEADER END 205331Samw */ 215331Samw /* 226030Sjb150015 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 235331Samw * Use is subject to license terms. 245331Samw */ 255331Samw 265331Samw #pragma ident "%Z%%M% %I% %E% SMI" 275331Samw 285331Samw #include <smbsrv/smb_incl.h> 295331Samw 305331Samw /* 315331Samw * The echo request is used to test the connection to the server, 325331Samw * and to see if the server is still responding. The tid is ignored, 335331Samw * so this request may be sent to the server even if there are no 345331Samw * tree connections to the server. 355331Samw * 365331Samw * Each response echoes the data sent, though ByteCount may indicate 375331Samw * no data. If echo-count is zero, no response is sent. 385331Samw */ 396030Sjb150015 smb_sdrc_t 406139Sjb150015 smb_pre_echo(smb_request_t *sr) 416139Sjb150015 { 426139Sjb150015 DTRACE_SMB_1(op__Echo__start, smb_request_t *, sr); 436139Sjb150015 return (SDRC_SUCCESS); 446139Sjb150015 } 456139Sjb150015 466139Sjb150015 void 476139Sjb150015 smb_post_echo(smb_request_t *sr) 486139Sjb150015 { 496139Sjb150015 DTRACE_SMB_1(op__Echo__done, smb_request_t *, sr); 506139Sjb150015 } 516139Sjb150015 526139Sjb150015 smb_sdrc_t 535331Samw smb_com_echo(struct smb_request *sr) 545331Samw { 555331Samw unsigned short necho; 565331Samw unsigned short nbytes; 575331Samw unsigned short i; 585331Samw struct mbuf_chain reply; 595331Samw char *data; 605331Samw 616030Sjb150015 if (smbsr_decode_vwv(sr, "w", &necho) != 0) 626139Sjb150015 return (SDRC_ERROR); 635331Samw 645331Samw nbytes = sr->smb_bcc; 655331Samw data = smbsr_malloc(&sr->request_storage, nbytes); 665331Samw 67*7052Samw if (smb_mbc_decodef(&sr->smb_data, "#c", nbytes, data)) 686139Sjb150015 return (SDRC_ERROR); 695331Samw 705331Samw for (i = 1; i <= necho; ++i) { 715331Samw MBC_INIT(&reply, SMB_HEADER_ED_LEN + 10 + nbytes); 725331Samw 73*7052Samw (void) smb_mbc_encodef(&reply, SMB_HEADER_ED_FMT, 745331Samw sr->first_smb_com, 755331Samw sr->smb_rcls, 765331Samw sr->smb_reh, 775331Samw sr->smb_err, 785331Samw sr->smb_flg | SMB_FLAGS_REPLY, 795331Samw sr->smb_flg2, 805331Samw sr->smb_pid_high, 815331Samw sr->smb_sig, 825331Samw sr->smb_tid, 835331Samw sr->smb_pid, 845331Samw sr->smb_uid, 855331Samw sr->smb_mid); 865331Samw 87*7052Samw (void) smb_mbc_encodef(&reply, "bww#c", 1, i, 885331Samw nbytes, nbytes, data); 895331Samw 905331Samw if (sr->session->signing.flags & SMB_SIGNING_ENABLED) 915331Samw smb_sign_reply(sr, &reply); 925331Samw 935331Samw (void) smb_session_send(sr->session, 0, &reply); 945331Samw } 955331Samw 965331Samw return (SDRC_NO_REPLY); 975331Samw } 98