SmbConstants.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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 System;
  18. using System.Collections.Generic;
  19. using System.Net;
  20. using SharpCifs.Util.Sharpen;
  21. namespace SharpCifs.Smb
  22. {
  23. internal static class SmbConstants
  24. {
  25. public static readonly int DefaultPort = 445;
  26. public static readonly int DefaultMaxMpxCount = 10;
  27. public static readonly int DefaultResponseTimeout = 30000;
  28. public static readonly int DefaultSoTimeout = 35000;
  29. public static readonly int DefaultRcvBufSize = 60416;
  30. public static readonly int DefaultSndBufSize = 16644;
  31. public static readonly int DefaultSsnLimit = 250;
  32. public static readonly int DefaultConnTimeout = 35000;
  33. public static readonly IPAddress Laddr = Config.GetLocalHost();
  34. public static readonly int Lport = Config.GetInt("jcifs.smb.client.lport", 0);
  35. public static readonly int MaxMpxCount = Config.GetInt("jcifs.smb.client.maxMpxCount", DefaultMaxMpxCount
  36. );
  37. public static readonly int SndBufSize = Config.GetInt("jcifs.smb.client.snd_buf_size", DefaultSndBufSize
  38. );
  39. public static readonly int RcvBufSize = Config.GetInt("jcifs.smb.client.rcv_buf_size", DefaultRcvBufSize
  40. );
  41. public static readonly bool UseUnicode = Config.GetBoolean("jcifs.smb.client.useUnicode",
  42. true);
  43. public static readonly bool ForceUnicode = Config.GetBoolean("jcifs.smb.client.useUnicode"
  44. , false);
  45. public static readonly bool UseNtstatus = Config.GetBoolean("jcifs.smb.client.useNtStatus"
  46. , true);
  47. public static readonly bool Signpref = Config.GetBoolean("jcifs.smb.client.signingPreferred"
  48. , false);
  49. public static readonly bool UseNtsmbs = Config.GetBoolean("jcifs.smb.client.useNTSmbs", true
  50. );
  51. public static readonly bool UseExtsec = Config.GetBoolean("jcifs.smb.client.useExtendedSecurity"
  52. , true);
  53. public static readonly string NetbiosHostname = Config.GetProperty("jcifs.netbios.hostname"
  54. , null);
  55. public static readonly int LmCompatibility = Config.GetInt("jcifs.smb.lmCompatibility", 3);
  56. public static readonly int FlagsNone = unchecked(0x00);
  57. public static readonly int FlagsLockAndReadWriteAndUnlock = unchecked(0x01);
  58. public static readonly int FlagsReceiveBufferPosted = unchecked(0x02);
  59. public static readonly int FlagsPathNamesCaseless = unchecked(0x08);
  60. public static readonly int FlagsPathNamesCanonicalized = unchecked(0x10);
  61. public static readonly int FlagsOplockRequestedOrGranted = unchecked(0x20);
  62. public static readonly int FlagsNotifyOfModifyAction = unchecked(0x40);
  63. public static readonly int FlagsResponse = unchecked(0x80);
  64. public static readonly int Flags2None = unchecked(0x0000);
  65. public static readonly int Flags2LongFilenames = unchecked(0x0001);
  66. public static readonly int Flags2ExtendedAttributes = unchecked(0x0002);
  67. public static readonly int Flags2SecuritySignatures = unchecked(0x0004);
  68. public static readonly int Flags2ExtendedSecurityNegotiation = unchecked(0x0800);
  69. public static readonly int Flags2ResolvePathsInDfs = unchecked(0x1000);
  70. public static readonly int Flags2PermitReadIfExecutePerm = unchecked(0x2000);
  71. public static readonly int Flags2Status32 = unchecked(0x4000);
  72. public static readonly int Flags2Unicode = unchecked(0x8000);
  73. public static readonly int CapNone = unchecked(0x0000);
  74. public static readonly int CapRawMode = unchecked(0x0001);
  75. public static readonly int CapMpxMode = unchecked(0x0002);
  76. public static readonly int CapUnicode = unchecked(0x0004);
  77. public static readonly int CapLargeFiles = unchecked(0x0008);
  78. public static readonly int CapNtSmbs = unchecked(0x0010);
  79. public static readonly int CapRpcRemoteApis = unchecked(0x0020);
  80. public static readonly int CapStatus32 = unchecked(0x0040);
  81. public static readonly int CapLevelIiOplocks = unchecked(0x0080);
  82. public static readonly int CapLockAndRead = unchecked(0x0100);
  83. public static readonly int CapNtFind = unchecked(0x0200);
  84. public static readonly int CapDfs = unchecked(0x1000);
  85. public static readonly int CapExtendedSecurity = unchecked((int)(0x80000000));
  86. public static readonly int AttrReadonly = unchecked(0x01);
  87. public static readonly int AttrHidden = unchecked(0x02);
  88. public static readonly int AttrSystem = unchecked(0x04);
  89. public static readonly int AttrVolume = unchecked(0x08);
  90. public static readonly int AttrDirectory = unchecked(0x10);
  91. public static readonly int AttrArchive = unchecked(0x20);
  92. public static readonly int AttrCompressed = unchecked(0x800);
  93. public static readonly int AttrNormal = unchecked(0x080);
  94. public static readonly int AttrTemporary = unchecked(0x100);
  95. public static readonly int FileReadData = unchecked(0x00000001);
  96. public static readonly int FileWriteData = unchecked(0x00000002);
  97. public static readonly int FileAppendData = unchecked(0x00000004);
  98. public static readonly int FileReadEa = unchecked(0x00000008);
  99. public static readonly int FileWriteEa = unchecked(0x00000010);
  100. public static readonly int FileExecute = unchecked(0x00000020);
  101. public static readonly int FileDelete = unchecked(0x00000040);
  102. public static readonly int FileReadAttributes = unchecked(0x00000080);
  103. public static readonly int FileWriteAttributes = unchecked(0x00000100);
  104. public static readonly int Delete = unchecked(0x00010000);
  105. public static readonly int ReadControl = unchecked(0x00020000);
  106. public static readonly int WriteDac = unchecked(0x00040000);
  107. public static readonly int WriteOwner = unchecked(0x00080000);
  108. public static readonly int Synchronize = unchecked(0x00100000);
  109. public static readonly int GenericAll = unchecked(0x10000000);
  110. public static readonly int GenericExecute = unchecked(0x20000000);
  111. public static readonly int GenericWrite = unchecked(0x40000000);
  112. public static readonly int GenericRead = unchecked((int)(0x80000000));
  113. public static readonly int FlagsTargetMustBeFile = unchecked(0x0001);
  114. public static readonly int FlagsTargetMustBeDirectory = unchecked(0x0002);
  115. public static readonly int FlagsCopyTargetModeAscii = unchecked(0x0004);
  116. public static readonly int FlagsCopySourceModeAscii = unchecked(0x0008);
  117. public static readonly int FlagsVerifyAllWrites = unchecked(0x0010);
  118. public static readonly int FlagsTreeCopy = unchecked(0x0020);
  119. public static readonly int OpenFunctionFailIfExists = unchecked(0x0000);
  120. public static readonly int OpenFunctionOverwriteIfExists = unchecked(0x0020);
  121. public static readonly int Pid = (int)(new Random().NextDouble() * 65536d);
  122. public static readonly int SecurityShare = unchecked(0x00);
  123. public static readonly int SecurityUser = unchecked(0x01);
  124. public static readonly int CmdOffset = 4;
  125. public static readonly int ErrorCodeOffset = 5;
  126. public static readonly int FlagsOffset = 9;
  127. public static readonly int SignatureOffset = 14;
  128. public static readonly int TidOffset = 24;
  129. public static readonly int HeaderLength = 32;
  130. public static readonly long MillisecondsBetween1970And1601 = 11644473600000L;
  131. public static readonly TimeZoneInfo Tz = TimeZoneInfo.Local;
  132. public static readonly bool UseBatching = Config.GetBoolean("jcifs.smb.client.useBatching"
  133. , true);
  134. public static readonly string OemEncoding = Config.GetProperty("jcifs.encoding", Config.DefaultOemEncoding
  135. );
  136. public static readonly string UniEncoding = "UTF-16LE";
  137. public static readonly int DefaultFlags2 = Flags2LongFilenames | Flags2ExtendedAttributes
  138. | (UseExtsec ? Flags2ExtendedSecurityNegotiation : 0) | (Signpref ? Flags2SecuritySignatures
  139. : 0) | (UseNtstatus ? Flags2Status32 : 0) | (UseUnicode ? Flags2Unicode : 0
  140. );
  141. public static readonly int DefaultCapabilities = (UseNtsmbs ? CapNtSmbs : 0) | (UseNtstatus
  142. ? CapStatus32 : 0) | (UseUnicode ? CapUnicode : 0) | CapDfs;
  143. public static readonly int Flags2 = Config.GetInt("jcifs.smb.client.flags2", DefaultFlags2
  144. );
  145. public static readonly int Capabilities = Config.GetInt("jcifs.smb.client.capabilities", DefaultCapabilities
  146. );
  147. public static readonly bool TcpNodelay = Config.GetBoolean("jcifs.smb.client.tcpNoDelay",
  148. false);
  149. public static readonly int ResponseTimeout = Config.GetInt("jcifs.smb.client.responseTimeout"
  150. , DefaultResponseTimeout);
  151. public static readonly List<SmbTransport> Connections = new List<SmbTransport>();
  152. public static readonly int SsnLimit = Config.GetInt("jcifs.smb.client.ssnLimit", DefaultSsnLimit
  153. );
  154. public static readonly int SoTimeout = Config.GetInt("jcifs.smb.client.soTimeout", DefaultSoTimeout
  155. );
  156. public static readonly int ConnTimeout = Config.GetInt("jcifs.smb.client.connTimeout", DefaultConnTimeout
  157. );
  158. public static readonly string NativeOs = Config.GetProperty("jcifs.smb.client.nativeOs", Runtime
  159. .GetProperty("os.name"));
  160. public static readonly string NativeLanman = Config.GetProperty("jcifs.smb.client.nativeLanMan"
  161. , "jCIFS");
  162. public static readonly int VcNumber = 1;
  163. public static SmbTransport NullTransport = new SmbTransport(null, 0, null, 0);
  164. // file attribute encoding
  165. // extended file attribute encoding(others same as above)
  166. // access mask encoding
  167. // 1
  168. // 2
  169. // 3
  170. // 4
  171. // 5
  172. // 6
  173. // 7
  174. // 8
  175. // 9
  176. // 16
  177. // 17
  178. // 18
  179. // 19
  180. // 20
  181. // 28
  182. // 29
  183. // 30
  184. // 31
  185. // flags for move and copy
  186. // open function
  187. }
  188. }