ServerResponseHelper.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Copyright (C) 2012-2016 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Utilities;
  11. namespace ISCSI.Server
  12. {
  13. internal class ServerResponseHelper
  14. {
  15. internal static NOPInPDU GetKeepAlivePDU()
  16. {
  17. NOPInPDU response = new NOPInPDU();
  18. // when a target sends a NOP-In that is not a response to a Nop-Out received from the
  19. // initiator, the Initiator Task Tag MUST be set to 0xffffffff.
  20. response.InitiatorTaskTag = 0xFFFFFFFF;
  21. // Target Transfer Tag: If the target is initiating a NOP-In without wanting to receive a
  22. // corresponding NOP-Out, this field MUST hold the reserved value of 0xffffffff.
  23. response.TargetTransferTag = 0xFFFFFFFF;
  24. return response;
  25. }
  26. internal static NOPInPDU GetNOPResponsePDU(NOPOutPDU request)
  27. {
  28. NOPInPDU response = new NOPInPDU();
  29. response.Data = request.Data;
  30. // When a target receives the NOP-Out with a valid Initiator Task Tag (not the reserved value 0xffffffff),
  31. // it MUST respond with a NOP-In with the same Initiator Task Tag that was provided in the NOP-Out request.
  32. // For such a response, the Target Transfer Tag MUST be 0xffffffff.
  33. response.InitiatorTaskTag = request.InitiatorTaskTag;
  34. response.TargetTransferTag = 0xFFFFFFFF;
  35. return response;
  36. }
  37. internal static LogoutResponsePDU GetLogoutResponsePDU(LogoutRequestPDU request, LogoutResponse responseCode)
  38. {
  39. LogoutResponsePDU response = new LogoutResponsePDU();
  40. response.Response = responseCode;
  41. response.Final = true;
  42. response.InitiatorTaskTag = request.InitiatorTaskTag;
  43. return response;
  44. }
  45. }
  46. }