TransTransactNamedPipe.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. namespace SharpCifs.Smb
  19. {
  20. internal class TransTransactNamedPipe : SmbComTransaction
  21. {
  22. private byte[] _pipeData;
  23. private int _pipeFid;
  24. private int _pipeDataOff;
  25. private int _pipeDataLen;
  26. internal TransTransactNamedPipe(int fid, byte[] data, int off, int len)
  27. {
  28. _pipeFid = fid;
  29. _pipeData = data;
  30. _pipeDataOff = off;
  31. _pipeDataLen = len;
  32. Command = SmbComTransaction;
  33. SubCommand = TransTransactNamedPipe;
  34. MaxParameterCount = 0;
  35. MaxDataCount = unchecked(0xFFFF);
  36. MaxSetupCount = unchecked(unchecked(0x00));
  37. SetupCount = 2;
  38. Name = "\\PIPE\\";
  39. }
  40. internal override int WriteSetupWireFormat(byte[] dst, int dstIndex)
  41. {
  42. dst[dstIndex++] = SubCommand;
  43. dst[dstIndex++] = unchecked(unchecked(0x00));
  44. WriteInt2(_pipeFid, dst, dstIndex);
  45. dstIndex += 2;
  46. return 4;
  47. }
  48. internal override int ReadSetupWireFormat(byte[] buffer, int bufferIndex, int len
  49. )
  50. {
  51. return 0;
  52. }
  53. internal override int WriteParametersWireFormat(byte[] dst, int dstIndex)
  54. {
  55. return 0;
  56. }
  57. internal override int WriteDataWireFormat(byte[] dst, int dstIndex)
  58. {
  59. if ((dst.Length - dstIndex) < _pipeDataLen)
  60. {
  61. if (Log.Level >= 3)
  62. {
  63. Log.WriteLine("TransTransactNamedPipe data too long for buffer");
  64. }
  65. return 0;
  66. }
  67. Array.Copy(_pipeData, _pipeDataOff, dst, dstIndex, _pipeDataLen);
  68. return _pipeDataLen;
  69. }
  70. internal override int ReadParametersWireFormat(byte[] buffer, int bufferIndex, int
  71. len)
  72. {
  73. return 0;
  74. }
  75. internal override int ReadDataWireFormat(byte[] buffer, int bufferIndex, int len)
  76. {
  77. return 0;
  78. }
  79. public override string ToString()
  80. {
  81. return "TransTransactNamedPipe[" + base.ToString() + ",pipeFid=" + _pipeFid
  82. + "]";
  83. }
  84. }
  85. }