From c847b2afe7f4c979499c20869563439e25f0cb7e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 4 Aug 2007 20:08:35 +0000 Subject: r24223: Convert reply_echo to the new API (This used to be commit 4863ff2899419e791ed0e340821072d004fb1d17) --- source3/client/client.c | 10 ++++++---- source3/libsmb/clientgen.c | 20 +++++++++++++------- source3/smbd/process.c | 2 +- source3/smbd/reply.c | 39 +++++++++++++++++++++++++-------------- 4 files changed, 45 insertions(+), 26 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index ce66e08930..91cf128bc4 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -777,14 +777,16 @@ static int cmd_du(void) static int cmd_echo(void) { + fstring num; pstring data; - if (!next_token_nr(NULL, data, NULL, sizeof(data))) { - d_printf("echo \n"); + if (!next_token_nr(NULL, num, NULL, sizeof(num)) + || !next_token_nr(NULL, data, NULL, sizeof(data))) { + d_printf("echo \n"); return 1; } - if (!cli_echo(cli, (uint8 *)data, strlen(data))) { + if (!cli_echo(cli, atoi(num), (uint8 *)data, strlen(data))) { d_printf("echo failed: %s\n", nt_errstr(cli_get_nt_error(cli))); return 1; @@ -3730,7 +3732,7 @@ static void readline_callback(void) { unsigned char garbage[16]; memset(garbage, 0xf0, sizeof(garbage)); - cli_echo(cli, garbage, sizeof(garbage)); + cli_echo(cli, 1, garbage, sizeof(garbage)); } } diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 29d4d9c334..a23e0184d7 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -680,9 +680,11 @@ BOOL cli_send_keepalive(struct cli_state *cli) Send/receive a SMBecho command: ping the server ****************************************************************************/ -BOOL cli_echo(struct cli_state *cli, unsigned char *data, size_t length) +BOOL cli_echo(struct cli_state *cli, uint16 num_echos, + unsigned char *data, size_t length) { char *p; + int i; SMB_ASSERT(length < 1024); @@ -690,7 +692,7 @@ BOOL cli_echo(struct cli_state *cli, unsigned char *data, size_t length) set_message(NULL,cli->outbuf,1,length,True); SCVAL(cli->outbuf,smb_com,SMBecho); SSVAL(cli->outbuf,smb_tid,65535); - SSVAL(cli->outbuf,smb_vwv0,1); + SSVAL(cli->outbuf,smb_vwv0,num_echos); cli_setup_packet(cli); p = smb_buf(cli->outbuf); memcpy(p, data, length); @@ -699,12 +701,16 @@ BOOL cli_echo(struct cli_state *cli, unsigned char *data, size_t length) cli_setup_bcc(cli, p); cli_send_smb(cli); - if (!cli_receive_smb(cli)) { - return False; - } - if (cli_is_error(cli)) { - return False; + for (i=0; iinbuf); + START_PROFILE(SMBecho); + if (req->wct < 1) { + reply_nterror(req, NT_STATUS_INVALID_PARAMETER); + END_PROFILE(SMBecho); + return; + } + if (data_len > BUFFER_SIZE) { DEBUG(0,("reply_echo: data_len too large.\n")); + reply_nterror(req, NT_STATUS_INSUFFICIENT_RESOURCES); END_PROFILE(SMBecho); - return -1; + return; } + smb_reverb = SVAL(req->inbuf,smb_vwv0); + + reply_outbuf(req, 1, data_len); + /* copy any incoming data back out */ - if (data_len > 0) - memcpy(smb_buf(outbuf),smb_buf(inbuf),data_len); + if (data_len > 0) { + memcpy(smb_buf(req->outbuf),smb_buf(req->inbuf),data_len); + } if (smb_reverb > 100) { DEBUG(0,("large reverb (%d)?? Setting to 100\n",smb_reverb)); @@ -3800,21 +3811,21 @@ int reply_echo(connection_struct *conn, } for (seq_num =1 ; seq_num <= smb_reverb ; seq_num++) { - SSVAL(outbuf,smb_vwv0,seq_num); - - smb_setlen(inbuf,outbuf,outsize - 4); + SSVAL(req->outbuf,smb_vwv0,seq_num); - show_msg(outbuf); - if (!send_smb(smbd_server_fd(),outbuf)) + show_msg((char *)req->outbuf); + if (!send_smb(smbd_server_fd(),(char *)req->outbuf)) exit_server_cleanly("reply_echo: send_smb failed."); } DEBUG(3,("echo %d times\n", smb_reverb)); + TALLOC_FREE(req->outbuf); + smb_echo_count++; END_PROFILE(SMBecho); - return -1; + return; } /**************************************************************************** -- cgit