Inheritance: ServerMessageBlock
Beispiel #1
0
 private SmbComBlankResponse Blank_resp()
 {
     if (_blankResp == null)
     {
         _blankResp = new SmbComBlankResponse();
     }
     return _blankResp;
 }
Beispiel #2
0
 /// <exception cref="SharpCifs.Smb.SmbException"></exception>
 internal virtual void Send(ServerMessageBlock request, ServerMessageBlock response)
 {
     Connect();
     request.Flags2    |= Flags2;
     request.UseUnicode = UseUnicode;
     request.Response   = response;
     if (request.Digest == null)
     {
         request.Digest = Digest;
     }
     try
     {
         if (response == null)
         {
             DoSend0(request);
             return;
         }
         if (request is SmbComTransaction)
         {
             response.Command = request.Command;
             SmbComTransaction         req  = (SmbComTransaction)request;
             SmbComTransactionResponse resp = (SmbComTransactionResponse)response;
             req.MaxBufferSize = SndBufSize;
             resp.Reset();
             try
             {
                 BufferCache.GetBuffers(req, resp);
                 req.Current();
                 if (req.MoveNext())
                 {
                     SmbComBlankResponse interim = new SmbComBlankResponse();
                     Sendrecv(req, interim, SmbConstants.ResponseTimeout);
                     if (interim.ErrorCode != 0)
                     {
                         CheckStatus(req, interim);
                     }
                     req.Current();
                 }
                 else
                 {
                     MakeKey(req);
                 }
                 lock (this)
                 {
                     response.Received = false;
                     resp.IsReceived   = false;
                     try
                     {
                         ResponseMap.Put(req, resp);
                         do
                         {
                             DoSend0(req);
                         }while (req.MoveNext() && req.Current() != null);
                         long timeout = SmbConstants.ResponseTimeout;
                         resp.Expiration = Runtime.CurrentTimeMillis() + timeout;
                         while (resp.MoveNext())
                         {
                             Runtime.Wait(this, timeout);
                             timeout = resp.Expiration - Runtime.CurrentTimeMillis();
                             if (timeout <= 0)
                             {
                                 throw new TransportException(
                                           this + " timedout waiting for response to " + req);
                             }
                         }
                         if (response.ErrorCode != 0)
                         {
                             CheckStatus(req, resp);
                         }
                     }
                     catch (Exception ie)
                     {
                         if (ie is SmbException)
                         {
                             throw;
                         }
                         else
                         {
                             throw new TransportException(ie);
                         }
                     }
                     finally
                     {
                         //Sharpen.Collections.Remove<Hashtable, SmbComTransaction>(response_map, req);
                         ResponseMap.Remove(req);
                     }
                 }
             }
             finally
             {
                 BufferCache.ReleaseBuffer(req.TxnBuf);
                 BufferCache.ReleaseBuffer(resp.TxnBuf);
             }
         }
         else
         {
             response.Command = request.Command;
             Sendrecv(request, response, SmbConstants.ResponseTimeout);
         }
     }
     catch (SmbException se)
     {
         throw;
     }
     catch (IOException ioe)
     {
         throw new SmbException(ioe.Message, ioe);
     }
     CheckStatus(request, response);
 }
Beispiel #3
0
 /// <exception cref="SharpCifs.Smb.SmbException"></exception>
 internal virtual void Send(ServerMessageBlock request, ServerMessageBlock response
     )
 {
     Connect();
     request.Flags2 |= Flags2;
     request.UseUnicode = UseUnicode;
     request.Response = response;
     if (request.Digest == null)
     {
         request.Digest = Digest;
     }
     try
     {
         if (response == null)
         {
             DoSend0(request);
             return;
         }
         if (request is SmbComTransaction)
         {
             response.Command = request.Command;
             SmbComTransaction req = (SmbComTransaction)request;
             SmbComTransactionResponse resp = (SmbComTransactionResponse)response;
             req.MaxBufferSize = SndBufSize;
             resp.Reset();
             try
             {
                 BufferCache.GetBuffers(req, resp);
                 req.Current();
                 if (req.MoveNext())
                 {
                     SmbComBlankResponse interim = new SmbComBlankResponse();
                     Sendrecv(req, interim, SmbConstants.ResponseTimeout);
                     if (interim.ErrorCode != 0)
                     {
                         CheckStatus(req, interim);
                     }
                     req.Current();
                 }
                 else
                 {
                     MakeKey(req);
                 }
                 lock (this)
                 {
                     response.Received = false;
                     resp.IsReceived = false;
                     try
                     {
                         ResponseMap.Put(req, resp);
                         do
                         {
                             DoSend0(req);
                         }
                         while (req.MoveNext() && req.Current() != null);
                         long timeout = SmbConstants.ResponseTimeout;
                         resp.Expiration = Runtime.CurrentTimeMillis() + timeout;
                         while (resp.MoveNext())
                         {
                             Runtime.Wait(this, timeout);
                             timeout = resp.Expiration - Runtime.CurrentTimeMillis();
                             if (timeout <= 0)
                             {
                                 throw new TransportException(this + " timedout waiting for response to " + req);
                             }
                         }
                         if (response.ErrorCode != 0)
                         {
                             CheckStatus(req, resp);
                         }
                     }
                     catch (Exception ie)
                     {
                         if (ie is SmbException)
                         {
                             throw;
                         }
                         else
                         {
                             throw new TransportException(ie);
                         }
                     }
                     finally
                     {
                         //Sharpen.Collections.Remove<Hashtable, SmbComTransaction>(response_map, req);
                         ResponseMap.Remove(req);
                     }
                 }
             }
             finally
             {
                 BufferCache.ReleaseBuffer(req.TxnBuf);
                 BufferCache.ReleaseBuffer(resp.TxnBuf);
             }
         }
         else
         {
             response.Command = request.Command;
             Sendrecv(request, response, SmbConstants.ResponseTimeout);
         }
     }
     catch (SmbException se)
     {
         throw;
     }
     catch (IOException ioe)
     {
         throw new SmbException(ioe.Message, ioe);
     }
     CheckStatus(request, response);
 }