/** * Ask use if they would like a dump file, if so, create one. * * @param pcap Reference to the PcapHandle. */ @Override protected boolean beforeStart(Pcap pcap) { super.beforeStart(pcap); int option = JOptionPane.showConfirmDialog(GrassMarlin.window, "Create a dumpfile?"); if (option == JOptionPane.OK_OPTION) { try { String filename = System.currentTimeMillis() + "_dump.pcap"; File f = new File(Environment.DIR_LIVE_CAPTURE.getPath() + File.separator + filename); JFileChooser fc = new JFileChooser(); fc.setSelectedFile(f); int i = fc.showSaveDialog(GrassMarlin.window.getContentPane()); if (i == JFileChooser.APPROVE_OPTION) { dumper = pcap.dumpOpen(fc.getSelectedFile().getCanonicalPath()); } } catch (Exception ex) { Logger.getLogger(LivePCAPImport.class.getName()) .log(Level.SEVERE, "Failed to set dumpfile.", ex); } } else if (option == JOptionPane.CANCEL_OPTION) { return false; } isUsingDumpFile = dumper != null; return true; }
@Override protected void onEnd(Pcap pcap) { super.onEnd(pcap); LogEmitter.factory.get().emit(this, Core.ALERT.INFO, "Live capture has ended."); }