Beispiel #1
0
  /**
   * Process a request made on the IPC$ remote admin named pipe.
   *
   * @param sess SMBSrvSession
   * @param smbPkt SMBSrvPacket
   * @exception IOException
   * @exception SMBSrvException
   */
  public static void processIPCRequest(SMBSrvSession sess, SMBSrvPacket smbPkt)
      throws IOException, SMBSrvException {

    // Get the tree id from the received packet and validate that it is a valid
    // connection id.

    TreeConnection conn = sess.findTreeConnection(smbPkt);

    if (conn == null) {
      sess.sendErrorResponseSMB(smbPkt, SMBStatus.DOSInvalidDrive, SMBStatus.ErrDos);
      return;
    }

    // Debug

    if (Debug.EnableInfo && sess.hasDebug(SMBSrvSession.DBG_IPC))
      sess.debugPrintln(
          "IPC$ Request [" + smbPkt.getTreeId() + "] - cmd = " + smbPkt.getPacketTypeString());

    // Determine the SMB command

    switch (smbPkt.getCommand()) {

        // Open file request

      case PacketType.OpenAndX:
      case PacketType.OpenFile:
        procIPCFileOpen(sess, smbPkt);
        break;

        // Read file request

      case PacketType.ReadFile:
        procIPCFileRead(sess, smbPkt);
        break;

        // Read AndX file request

      case PacketType.ReadAndX:
        procIPCFileReadAndX(sess, smbPkt);
        break;

        // Write file request

      case PacketType.WriteFile:
        procIPCFileWrite(sess, smbPkt);
        break;

        // Write AndX file request

      case PacketType.WriteAndX:
        procIPCFileWriteAndX(sess, smbPkt);
        break;

        // Close file request

      case PacketType.CloseFile:
        procIPCFileClose(sess, smbPkt);
        break;

        // NT create andX request

      case PacketType.NTCreateAndX:
        procNTCreateAndX(sess, smbPkt);
        break;

        // Default, respond with an unsupported function error.

      default:
        sess.sendErrorResponseSMB(smbPkt, SMBStatus.SRVUnrecognizedCommand, SMBStatus.ErrSrv);
        break;
    }
  }