diff options
author | Volker Lendecke <vlendec@samba.org> | 2007-08-04 20:08:35 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:29:17 -0500 |
commit | c847b2afe7f4c979499c20869563439e25f0cb7e (patch) | |
tree | 7cc705a9c65eee219b83073a2d21da5d18eecc2c /source3 | |
parent | 87165a81d9a9be0b3476c130cb772a8a578f4f94 (diff) | |
download | samba-c847b2afe7f4c979499c20869563439e25f0cb7e.tar.gz samba-c847b2afe7f4c979499c20869563439e25f0cb7e.tar.bz2 samba-c847b2afe7f4c979499c20869563439e25f0cb7e.zip |
r24223: Convert reply_echo to the new API
(This used to be commit 4863ff2899419e791ed0e340821072d004fb1d17)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/client/client.c | 10 | ||||
-rw-r--r-- | source3/libsmb/clientgen.c | 20 | ||||
-rw-r--r-- | source3/smbd/process.c | 2 | ||||
-rw-r--r-- | source3/smbd/reply.c | 39 |
4 files changed, 45 insertions, 26 deletions
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 <data>\n"); + if (!next_token_nr(NULL, num, NULL, sizeof(num)) + || !next_token_nr(NULL, data, NULL, sizeof(data))) { + d_printf("echo <num> <data>\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; i<num_echos; i++) { + if (!cli_receive_smb(cli)) { + return False; + } + + if (cli_is_error(cli)) { + return False; + } } + return True; } diff --git a/source3/smbd/process.c b/source3/smbd/process.c index df86970ca8..02ad205bd5 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -731,7 +731,7 @@ static const struct smb_message_struct { /* 0x28 */ { "SMBioctls",NULL, NULL,AS_USER}, /* 0x29 */ { "SMBcopy",reply_copy,NULL,AS_USER | NEED_WRITE }, /* 0x2a */ { "SMBmove",NULL, NULL,AS_USER | NEED_WRITE }, -/* 0x2b */ { "SMBecho",reply_echo,NULL,0}, +/* 0x2b */ { "SMBecho",NULL,reply_echo,0}, /* 0x2c */ { "SMBwriteclose",reply_writeclose,NULL,AS_USER}, /* 0x2d */ { "SMBopenX",NULL,reply_open_and_X,AS_USER | CAN_IPC }, /* 0x2e */ { "SMBreadX",reply_read_and_X,NULL,AS_USER | CAN_IPC }, diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 91e4274814..94f18641bf 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -3775,24 +3775,35 @@ void reply_tdis(connection_struct *conn, struct smb_request *req) conn POINTER CAN BE NULL HERE ! ****************************************************************************/ -int reply_echo(connection_struct *conn, - char *inbuf,char *outbuf, int dum_size, int dum_buffsize) +void reply_echo(connection_struct *conn, struct smb_request *req) { - int smb_reverb = SVAL(inbuf,smb_vwv0); + int smb_reverb; int seq_num; - unsigned int data_len = smb_buflen(inbuf); - int outsize = set_message(inbuf,outbuf,1,data_len,True); + unsigned int data_len = smb_buflen(req->inbuf); + 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; } /**************************************************************************** |