Ignore:
Timestamp:
Jul 26, 2016, 11:47:31 AM (9 years ago)
Author:
Paul Smedley
Message:

Introduce smb_echo, used to confirm server connection is still active before trying a connection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/client-3.0/src/smbwrp.c

    r931 r933  
    12211221}
    12221222
     1223/*****************************************************
     1224Send an echo to the server to confirm it is still alive
     1225*******************************************************/
     1226int _System smbwrp_echo(cli_state * cli)
     1227{
     1228        debuglocal(4," smbwrp_echo\n");
     1229        unsigned char garbage[16];
     1230        NTSTATUS status;
     1231        if (!cli)
     1232        {
     1233                return maperror(EINVAL);
     1234        }
     1235        /* Ping the server to keep the connection alive using SMBecho. */
     1236        memset(garbage, 0xf0, sizeof(garbage));
     1237        unsigned int old_timeout = cli->timeout;
     1238        cli->timeout = 2000;// we don't want to wait 20 seconds
     1239        status = cli_echo(cli, 1, data_blob_const(garbage, sizeof(garbage)));
     1240        cli->timeout = old_timeout; // reset back to previous value
     1241        if (NT_STATUS_IS_OK(status)) {
     1242                return 0;
     1243        } else {
     1244                return -1;
     1245        }
     1246}
Note: See TracChangeset for help on using the changeset viewer.