IPCSession.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (C) 2006-2010 Alfresco Software Limited.
  3. *
  4. * This file is part of Alfresco
  5. *
  6. * Alfresco is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Alfresco is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package org.alfresco.jlan.client;
  20. import java.io.*;
  21. import org.alfresco.jlan.smb.PCShare;
  22. import org.alfresco.jlan.smb.PacketType;
  23. import org.alfresco.jlan.smb.SMBDeviceType;
  24. import org.alfresco.jlan.smb.SMBException;
  25. /**
  26. * SMB IPC session class
  27. *
  28. * <p>
  29. * Contains the details of a connection to a remote named pipe service.
  30. *
  31. * @author gkspencer
  32. */
  33. public abstract class IPCSession extends Session {
  34. /**
  35. * Construct an IPC session
  36. *
  37. * @param shr Remote server details.
  38. * @param dialect SMB dialect that this session is using
  39. */
  40. protected IPCSession(PCShare shr, int dialect) {
  41. super(shr, dialect, null);
  42. // Set the device type for this session
  43. setDeviceType(SMBDeviceType.Pipe);
  44. }
  45. /**
  46. * Send/receive an SMB transaction packet on this pipe session
  47. *
  48. * @param tpkt SMBTransPacket to send
  49. * @param rxpkt Packet to receive the reply into
  50. * @exception java.io.IOException If an I/O error occurs
  51. * @exception SMBException If an SMB error occurs
  52. */
  53. public abstract void SendTransaction(TransPacket tpkt, TransPacket rxpkt)
  54. throws java.io.IOException, SMBException;
  55. /**
  56. * Close the connection to the IPC$ named pipe
  57. *
  58. * @throws IOException
  59. * @throws SMBException
  60. */
  61. public void CloseSession()
  62. throws IOException, SMBException {
  63. // Build a tree disconnect packet
  64. m_pkt.setCommand(PacketType.TreeDisconnect);
  65. m_pkt.setUserId(getUserId());
  66. m_pkt.setTreeId(m_treeid);
  67. m_pkt.setParameterCount(0);
  68. m_pkt.setByteCount(0);
  69. // Send the tree disconnect packet
  70. m_pkt.ExchangeSMB(this, m_pkt);
  71. // Call the base class
  72. super.CloseSession();
  73. }
  74. }