12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Collections.Generic;
- using SMBLibrary.SMB2;
- using Utilities;
- namespace SMBLibrary.Server.SMB2
- {
- internal class CancelHelper
- {
- internal static SMB2Command GetCancelResponse(CancelRequest request, SMB2ConnectionState state)
- {
- SMB2Session session = state.GetSession(request.Header.SessionID);
- if (request.Header.IsAsync)
- {
- SMB2AsyncContext context = state.GetAsyncContext(request.Header.AsyncID);
- if (context != null)
- {
- ISMBShare share = session.GetConnectedTree(context.TreeID);
- OpenFileObject openFile = session.GetOpenFileObject(context.FileID);
- NTStatus status = share.FileStore.Cancel(context.IORequest);
- if (openFile != null)
- {
- state.LogToServer(Severity.Information, "Cancel: Requested cancel on '{0}{1}'. NTStatus: {2}, AsyncID: {3}.", share.Name, openFile.Path, status, context.AsyncID);
- }
- if (status == NTStatus.STATUS_SUCCESS || status == NTStatus.STATUS_CANCELLED)
- {
- state.RemoveAsyncContext(context);
-
-
- ErrorResponse response = new ErrorResponse(request.CommandName, NTStatus.STATUS_CANCELLED);
- response.Header.IsAsync = true;
- response.Header.AsyncID = context.AsyncID;
- return response;
- }
-
- return null;
- }
- else
- {
-
- return null;
- }
- }
- else
- {
-
-
- return null;
- }
- }
- }
- }
|