Example #1
0
  /**
   * Process a set named pipe handle state request
   *
   * @param sess SMBSrvSession
   * @param vc VirtualCircuit
   * @param tbuf SrvTransactBuffer
   * @param smbPkt SMBSrvPacket
   */
  protected static void procSetNamedPipeHandleState(
      SMBSrvSession sess, VirtualCircuit vc, SrvTransactBuffer tbuf, SMBSrvPacket smbPkt)
      throws IOException, SMBSrvException {

    // Get the request parameters

    DataBuffer setupBuf = tbuf.getSetupBuffer();
    setupBuf.skipBytes(2);
    int fid = setupBuf.getShort();

    DataBuffer paramBuf = tbuf.getParameterBuffer();
    int state = paramBuf.getShort();

    // Get the connection for the request

    TreeConnection conn = vc.findConnection(tbuf.getTreeId());

    // Get the IPC pipe file for the specified file id

    DCEPipeFile netFile = (DCEPipeFile) conn.findFile(fid);
    if (netFile == null) {
      sess.sendErrorResponseSMB(smbPkt, SMBStatus.DOSInvalidHandle, SMBStatus.ErrDos);
      return;
    }

    // Debug

    if (Debug.EnableInfo && sess.hasDebug(SMBSrvSession.DBG_IPC))
      sess.debugPrintln(
          "  SetNmPHandState pipe="
              + netFile.getName()
              + ", fid="
              + fid
              + ", state=0x"
              + Integer.toHexString(state));

    // Store the named pipe state

    netFile.setPipeState(state);

    // Setup the response packet

    SMBSrvTransPacket.initTransactReply(smbPkt, 0, 0, 0, 0);

    // Send the response packet

    sess.sendResponseSMB(smbPkt);
  }