/** * Process a special IPC$ file close request. * * @param sess SMBSrvSession * @param smbPkt SMBSrvPacket * @exception IOException * @exception SMBSrvException */ protected static void procIPCFileClose(SMBSrvSession sess, SMBSrvPacket smbPkt) throws IOException, SMBSrvException { // Check that the received packet looks like a valid file close request if (smbPkt.checkPacketIsValid(3, 0) == false) { sess.sendErrorResponseSMB(smbPkt, SMBStatus.SRVUnrecognizedCommand, SMBStatus.ErrSrv); return; } // 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; } // Get the file id from the request int fid = smbPkt.getParameter(0); 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("IPC$ File close [" + smbPkt.getTreeId() + "] fid=" + fid); // Remove the file from the connections list of open files conn.removeFile(fid, sess); // Build the close file response smbPkt.setParameterCount(0); smbPkt.setByteCount(0); // Send the response packet sess.sendResponseSMB(smbPkt); }
/** * Process an IPC pipe file write andX request * * @param sess SMBSrvSession * @param smbPkt SMBSrvPacket * @exception IOException * @exception SMBSrvException */ protected static void procIPCFileWriteAndX(SMBSrvSession sess, SMBSrvPacket smbPkt) throws IOException, SMBSrvException { // Check if the received packet is a valid write andX request if (smbPkt.checkPacketIsValid(12, 0) == false) { // Invalid request sess.sendErrorResponseSMB(smbPkt, SMBStatus.SRVUnrecognizedCommand, SMBStatus.ErrSrv); return; } // Debug if (Debug.EnableInfo && sess.hasDebug(SMBSrvSession.DBG_IPC)) sess.debugPrintln("IPC$ File Write AndX"); // Pass the write request the DCE/RPC handler DCERPCHandler.processDCERPCRequest(sess, smbPkt); }