SmbComNegotiate.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 SharpCifs.Util.Sharpen;
  19. namespace SharpCifs.Smb
  20. {
  21. internal class SmbComNegotiate : ServerMessageBlock
  22. {
  23. private const string Dialects = "\u0002NT LM 0.12\u0000";
  24. public SmbComNegotiate()
  25. {
  26. Command = SmbComNegotiate;
  27. Flags2 = SmbConstants.DefaultFlags2;
  28. }
  29. internal override int WriteParameterWordsWireFormat(byte[] dst, int dstIndex)
  30. {
  31. return 0;
  32. }
  33. internal override int WriteBytesWireFormat(byte[] dst, int dstIndex)
  34. {
  35. byte[] dialects;
  36. try
  37. {
  38. //dialects = Runtime.GetBytesForString(Dialects, "ASCII");
  39. dialects = Runtime.GetBytesForString(Dialects, "UTF-8");
  40. }
  41. catch (UnsupportedEncodingException)
  42. {
  43. return 0;
  44. }
  45. Array.Copy(dialects, 0, dst, dstIndex, dialects.Length);
  46. return dialects.Length;
  47. }
  48. internal override int ReadParameterWordsWireFormat(byte[] buffer, int bufferIndex)
  49. {
  50. return 0;
  51. }
  52. internal override int ReadBytesWireFormat(byte[] buffer, int bufferIndex)
  53. {
  54. return 0;
  55. }
  56. public override string ToString()
  57. {
  58. return "SmbComNegotiate["
  59. + base.ToString()
  60. + ",wordCount=" + WordCount
  61. + ",dialects=NT LM 0.12]";
  62. }
  63. }
  64. }