private void MovePacketCaptureFile(string currentCaptureFileName) { // Move the packet capture file to the parser service folder // Wait for any process to finish writing to the file Thread.Sleep(500); try { // Call the CaptureAgent CaptureAgent.CaptureAgent ca = new CaptureAgent.CaptureAgent(); ca.MoveCaptureFileToParseFolder(_CaptureFolderPath, _ParseFolderPath, currentCaptureFileName); } catch (Exception ex) { MessageBox.Show("Error moving packet capture: " + ex.Message, "Move Packet Capture File", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//private bool StartPacketCapture(string sourceHostIp, string destinationHostIp, int captureInterval) private bool StartPacketCapture(string sourceHostIp, string localHostIp, int captureInterval) { bool result = false; int pid = 0; string fileName = string.Format("CaptureFile{0}{1}.pcap", DateTime.Now.Ticks.ToString(), IsMarked ? "d" : "u"); _CurrentCaptureFileName = fileName; try { // Call the CaptureAgent CaptureAgent.CaptureAgent ca = new CaptureAgent.CaptureAgent(); // Note: the pcap interface number is one-based (not zero-based), so adding a one here int nicNumber = Convert.ToInt32(_CurrentClientNetworkInterface); nicNumber++; //ca.StartCaptureSession(sourceHostIp, destinationHostIp, captureInterval, _CaptureFolderPath, fileName, nicNumber.ToString(), out pid); ca.StartCaptureSession(sourceHostIp, localHostIp, captureInterval, _CaptureFolderPath, fileName, nicNumber.ToString(), out pid); if (pid > 0) { _CaptureProcessId = pid; } result = true; return result; } catch (Exception ex) { MessageBox.Show("Error starting packet capture: " + ex.Message, "Start Packet Capture", MessageBoxButtons.OK, MessageBoxIcon.Error); return result; } }
//private void StartPacketCapture(bool marked, string sourceHostIp, string destinationHostIp, int captureInterval) private bool StartPacketCapture(string sourceHostIp, string destinationHostIp, int captureInterval) { bool result = false; // Start capturing packet data //bool marked = true; //string _CurrentCaptureFileName = string.Empty; //string _CaptureFolderPath = @"C:\temp"; //string _ParseFolderPath = @"C:\temp\ParseCaptureFiles"; string fileName = string.Format("CaptureFile{0}{1}.pcap", DateTime.Now.Ticks.ToString(), IsMarked ? "d" : "u"); _CurrentCaptureFileName = fileName; try { // Call the CaptureAgent CaptureAgent.CaptureAgent ca = new CaptureAgent.CaptureAgent(); ca.StartCaptureSession(sourceHostIp, destinationHostIp, captureInterval, _CaptureFolderPath, fileName); result = true; return result; } catch (Exception ex) { MessageBox.Show("Error starting packet capture: " + ex.Message, "Start Packet Capture", MessageBoxButtons.OK, MessageBoxIcon.Error); return result; } }
private void MovePacketCaptureFile(string currentCaptureFileName) { // Move the packet capture file to the ParseCaptureFiles folder specified in app.config // The ParseCaptureFilesService will read the file(s) in this folder and parse them, // then move the parsed file to the ProcessedCaptureFiles folder. // Wait for any process to finish writing to the file Thread.Sleep(500); try { // Call the CaptureAgent CaptureAgent.CaptureAgent ca = new CaptureAgent.CaptureAgent(); ca.MoveCaptureFileToParseFolder(_CaptureFolderPath, _ParseFolderPath, currentCaptureFileName); } catch (Exception ex) { MessageBox.Show("Error moving packet capture: " + ex.Message, "Move Packet Capture File", MessageBoxButtons.OK, MessageBoxIcon.Error); } }