SmbComNTCreateAndXResponse.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. {
  51. int start = bufferIndex;
  52. OplockLevel = buffer[bufferIndex++];
  53. Fid = ReadInt2(buffer, bufferIndex);
  54. bufferIndex += 2;
  55. CreateAction = ReadInt4(buffer, bufferIndex);
  56. bufferIndex += 4;
  57. CreationTime = ReadTime(buffer, bufferIndex);
  58. bufferIndex += 8;
  59. LastAccessTime = ReadTime(buffer, bufferIndex);
  60. bufferIndex += 8;
  61. LastWriteTime = ReadTime(buffer, bufferIndex);
  62. bufferIndex += 8;
  63. ChangeTime = ReadTime(buffer, bufferIndex);
  64. bufferIndex += 8;
  65. ExtFileAttributes = ReadInt4(buffer, bufferIndex);
  66. bufferIndex += 4;
  67. AllocationSize = ReadInt8(buffer, bufferIndex);
  68. bufferIndex += 8;
  69. EndOfFile = ReadInt8(buffer, bufferIndex);
  70. bufferIndex += 8;
  71. FileType = ReadInt2(buffer, bufferIndex);
  72. bufferIndex += 2;
  73. DeviceState = ReadInt2(buffer, bufferIndex);
  74. bufferIndex += 2;
  75. Directory = (buffer[bufferIndex++] & unchecked(0xFF)) > 0;
  76. return bufferIndex - start;
  77. }
  78. internal override int ReadBytesWireFormat(byte[] buffer, int bufferIndex)
  79. {
  80. return 0;
  81. }
  82. public override string ToString()
  83. {
  84. return "SmbComNTCreateAndXResponse[" + base.ToString() + ",oplockLevel="
  85. + OplockLevel + ",fid=" + Fid + ",createAction=0x" + Hexdump.ToHexString(CreateAction
  86. , 4) + ",creationTime=" + Extensions.CreateDate(CreationTime) + ",lastAccessTime="
  87. + Extensions.CreateDate(LastAccessTime) + ",lastWriteTime=" + Extensions.CreateDate
  88. (LastWriteTime) + ",changeTime=" + Extensions.CreateDate(ChangeTime) + ",extFileAttributes=0x"
  89. + Hexdump.ToHexString(ExtFileAttributes, 4) + ",allocationSize=" + AllocationSize
  90. + ",endOfFile=" + EndOfFile + ",fileType=" + FileType + ",deviceState=" + DeviceState
  91. + ",directory=" + Directory + "]";
  92. }
  93. }
  94. }