TransTransactNamedPipe.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. return 0;
  51. }
  52. internal override int WriteParametersWireFormat(byte[] dst, int dstIndex)
  53. {
  54. return 0;
  55. }
  56. internal override int WriteDataWireFormat(byte[] dst, int dstIndex)
  57. {
  58. if ((dst.Length - dstIndex) < _pipeDataLen)
  59. {
  60. if (Log.Level >= 3)
  61. {
  62. Log.WriteLine("TransTransactNamedPipe data too long for buffer");
  63. }
  64. return 0;
  65. }
  66. Array.Copy(_pipeData, _pipeDataOff, dst, dstIndex, _pipeDataLen);
  67. return _pipeDataLen;
  68. }
  69. internal override int ReadParametersWireFormat(byte[] buffer,
  70. int bufferIndex,
  71. int 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["
  82. + base.ToString()
  83. + ",pipeFid=" + _pipeFid + "]";
  84. }
  85. }
  86. }