SmbComNTCreateAndXResponse.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // This code is derived from jcifs smb client library <jcifs at samba dot org>
  2. // Ported by J. Arturo <webmaster at komodosoft dot net>
  3. //
  4. // This library is free software; you can redistribute it and/or
  5. // modify it under the terms of the GNU Lesser General Public
  6. // License as published by the Free Software Foundation; either
  7. // version 2.1 of the License, or (at your option) any later version.
  8. //
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. // Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public
  15. // License along with this library; if not, write to the Free Software
  16. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. using SharpCifs.Util;
  18. using SharpCifs.Util.Sharpen;
  19. namespace SharpCifs.Smb
  20. {
  21. internal class SmbComNtCreateAndXResponse : AndXServerMessageBlock
  22. {
  23. internal const int ExclusiveOplockGranted = 1;
  24. internal const int BatchOplockGranted = 2;
  25. internal const int LevelIiOplockGranted = 3;
  26. internal byte OplockLevel;
  27. internal int Fid;
  28. internal int CreateAction;
  29. internal int ExtFileAttributes;
  30. internal int FileType;
  31. internal int DeviceState;
  32. internal long CreationTime;
  33. internal long LastAccessTime;
  34. internal long LastWriteTime;
  35. internal long ChangeTime;
  36. internal long AllocationSize;
  37. internal long EndOfFile;
  38. internal bool Directory;
  39. internal bool IsExtended;
  40. internal override int WriteParameterWordsWireFormat(byte[] dst, int dstIndex)
  41. {
  42. return 0;
  43. }
  44. internal override int WriteBytesWireFormat(byte[] dst, int dstIndex)
  45. {
  46. return 0;
  47. }
  48. internal override int ReadParameterWordsWireFormat(byte[] buffer, int bufferIndex)
  49. {
  50. int start = bufferIndex;
  51. OplockLevel = buffer[bufferIndex++];
  52. Fid = ReadInt2(buffer, bufferIndex);
  53. bufferIndex += 2;
  54. CreateAction = ReadInt4(buffer, bufferIndex);
  55. bufferIndex += 4;
  56. CreationTime = ReadTime(buffer, bufferIndex);
  57. bufferIndex += 8;
  58. LastAccessTime = ReadTime(buffer, bufferIndex);
  59. bufferIndex += 8;
  60. LastWriteTime = ReadTime(buffer, bufferIndex);
  61. bufferIndex += 8;
  62. ChangeTime = ReadTime(buffer, bufferIndex);
  63. bufferIndex += 8;
  64. ExtFileAttributes = ReadInt4(buffer, bufferIndex);
  65. bufferIndex += 4;
  66. AllocationSize = ReadInt8(buffer, bufferIndex);
  67. bufferIndex += 8;
  68. EndOfFile = ReadInt8(buffer, bufferIndex);
  69. bufferIndex += 8;
  70. FileType = ReadInt2(buffer, bufferIndex);
  71. bufferIndex += 2;
  72. DeviceState = ReadInt2(buffer, bufferIndex);
  73. bufferIndex += 2;
  74. Directory = (buffer[bufferIndex++] & unchecked(0xFF)) > 0;
  75. return bufferIndex - start;
  76. }
  77. internal override int ReadBytesWireFormat(byte[] buffer, int bufferIndex)
  78. {
  79. return 0;
  80. }
  81. public override string ToString()
  82. {
  83. return "SmbComNTCreateAndXResponse["
  84. + base.ToString()
  85. + ",oplockLevel=" + OplockLevel
  86. + ",fid=" + Fid
  87. + ",createAction=0x" + Hexdump.ToHexString(CreateAction, 4)
  88. + ",creationTime=" + Extensions.CreateDate(CreationTime)
  89. + ",lastAccessTime=" + Extensions.CreateDate(LastAccessTime)
  90. + ",lastWriteTime=" + Extensions.CreateDate(LastWriteTime)
  91. + ",changeTime=" + Extensions.CreateDate(ChangeTime)
  92. + ",extFileAttributes=0x" + Hexdump.ToHexString(ExtFileAttributes, 4)
  93. + ",allocationSize=" + AllocationSize
  94. + ",endOfFile=" + EndOfFile
  95. + ",fileType=" + FileType
  96. + ",deviceState=" + DeviceState
  97. + ",directory=" + Directory + "]";
  98. }
  99. }
  100. }