/// <summary> /// Start a capture task. /// </summary> /// <param name="des"></param> /// <param name="option"></param> public void StartNewCaptureTask(DeviceDes des, DumpOptions options = null) { Microsoft.Win32.SaveFileDialog dlg = null; if (options == null) { dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "new_capture"; dlg.DefaultExt = ".pcap"; dlg.Filter = "Libpcap capture file (.pcap)|*.pcap"; Nullable <bool> res = dlg.ShowDialog(); if (res != true) { return; } } var op = options ?? new DumpOptions() { Path = dlg.FileName, Count = int.MaxValue, Durance = TimeSpan.MaxValue, Filter = null }; CaptureControlBlock cm = new CaptureControlBlock() { Device = des, Options = op }; RaiseCaptureCreated(cm); cm.StartCapture(); RaiseCaptureStarted(cm); ActivateDocument.Execute(pages.OfType <TaskListPage>().FirstOrDefault(), this); cm.CaptureTask.ContinueWith( (res) => { if (res.Exception != null) { MessageBox.Show(res.Exception.Message); } else if (res.IsCanceled) { string str = string.Format("{0} 上的捕获任务已停止!", cm.Device.FriendlyName); MessageBox.Show(str); } else { string str = string.Format("{0} 上的捕获任务完成!", cm.Device.FriendlyName); MessageBox.Show(str); } }); }
/// <summary> /// Open a new Flux file to analyze /// </summary> public void OpenNewFluxAnalyze() { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".pcap"; dlg.Filter = "Libpcap capture file (.pcap)|*.pcap"; Nullable <bool> res = dlg.ShowDialog(); if (res == true) { FileAnalyzePage page = new FileAnalyzePage(dlg.FileName); pages.Add(page); ActivateDocument.Execute(page, this); } }