public ChildThread(DICOMSniffer mainObj, SnifferSession snifferSession, string dataDir, string signature) { snifferObj = mainObj; dvtkSnifferSession = snifferSession; orgDataDir = dataDir; associationName = signature; }
/// <summary> /// Load a session from file. /// </summary> /// <param name="fileName">file with extension <c>.SES</c></param> /// <returns> /// Returns a session of type; /// <list type="bullet"> /// <item>Dvtk.Sessions.ScriptSession</item> /// <item>Dvtk.Sessions.EmulatorSession</item> /// <item>Dvtk.Sessions.MediaSession</item> /// </list> /// </returns> /// <remarks> /// The type of session is dynamically determined. /// </remarks> public Session Load(FileName fileName) { if (fileName == null) { throw new ArgumentNullException(); } System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName); if (!fileInfo.Exists) { throw new ArgumentException(); } // // Transform fileName to fully qualified file name. // fileName = fileInfo.FullName; Session session = null; Wrappers.MBaseSession adaptee = Wrappers.MSessionFactory.Load(fileName); switch (adaptee.SessionType) { case Wrappers.SessionType.SessionTypeEmulator: session = new EmulatorSession(adaptee); break; case Wrappers.SessionType.SessionTypeMedia: session = new MediaSession(adaptee); break; case Wrappers.SessionType.SessionTypeScript: session = new ScriptSession(adaptee); break; case Wrappers.SessionType.SessionTypeSniffer: session = new SnifferSession(adaptee); break; case Wrappers.SessionType.SessionTypeUnknown: // Unknown Wrappers.SessionType throw new System.NotImplementedException(); } return(session); }
/// <summary> /// Event Handler for loading of main DICOM Sniffer form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DICOMSniffer_Load(object sender, System.EventArgs e) { // Create DICOM analyzer object instance for analyzing all DICOM PDUs // and subscribe for the logging event. dicom = new DICOMAnalyser(this); dicom.Output += new DICOMAnalyser.OutputEvent(OutputHandler); // Create TCP layer object instance for parsing TCP/IP packets and filtering // DICOM packets and subscribe for the events passing the DICOM packets to // upper DICOM layer tcp = new TCPParser(); tcp.FragmentAdded += new TCPParser.FragmentAddedEvent(dicom.ReceiveTCPData); tcp.EndOfStream += new TCPParser.EndOfStreamEvent(dicom.EndOfStream); tcp.Error += new TCPParser.ErrorEvent(ErrorHandler); // Create low level sniffer object instance for sniffing TCP/IP packets // from the network and subscribe for the error event. sniffer = new SnifferObject(); sniffer.Error += new Sniffer.ErrorEvent(ErrorHandler); sniffer.DataReceived += new Sniffer.DataReceivedEvent(tcp.AddPacket); try { // Get the list of network adapters(drivers) from the current machine string[] descriptions = sniffer.AdapterDescriptions; string[] names = sniffer.AdapterNames; for (int i = 0; i < descriptions.Length; i++) { String desc = descriptions[i].Replace("\0", ""); String name = names[i].Replace("\0", ""); adapterList.Items.Add(name + " (" + desc + ")"); } } catch (Exception except) { string msg = string.Format("Error:{0}\n", except.Message); MessageBox.Show(this, "Please install the WinPcap4.x.\n" +msg, "Error",MessageBoxButtons.OK, MessageBoxIcon.Error ); this.Close(); return; } // Select the first adapter from the list by default if(adapterList.Items.Count != 0) { selectedAdapter.Text = adapterList.Items[0].ToString(); adapterList.SelectedIndex = 0; } else { string msg = "No network adapter(driver) detected on the machine.\nPlease install the WinPcap4.x.\r\n"; MessageBox.Show(this, msg, "Warning",MessageBoxButtons.OK, MessageBoxIcon.Warning ); this.Close(); return; } // Load the Dvtk Sniffer session and try { dvtkSnifferSession = SnifferSession.LoadFromFile(Application.StartupPath + @"\NetworkAnalyzer.ses"); // Get the results directory if(dvtkSnifferSession != null) { resultDirectoryname = dvtkSnifferSession.ResultsRootDirectory; } } catch (Exception except) { string msg = string.Format("Error in loading Network Analyzer session file\r\n due to {0}",except.Message); MessageBox.Show(this, msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } //Get the IP Address of the current machine try { string strHostName = Dns.GetHostName(); IPHostEntry ipEntry = Dns.GetHostEntry(strHostName); IPAddress [] addr = ipEntry.AddressList; if(addr != null) { foreach (IPAddress address in addr) { if (address.AddressFamily.ToString() == ProtocolFamily.InterNetwork.ToString()) { ipAddress1.Text = address.ToString(); } } } } catch (SocketException) { //Do nothing in case of no specific DNS configuration present } //Default setting for all toolbar buttons & menuitems menuItemAnalysisMode.Checked = false; menuItem_capopen.Visible = false; ReadCapture.Visible = false; Explore.Visible = false; Error.Visible = false; Warning.Visible = false; Backward.Visible = false; Forward.Visible = false; menuItemView.Visible = false; menuItemShowResult.Enabled = false; tabControlSniffer.Controls.Remove(tabAssoOverview); tabControlSniffer.Controls.Remove(tabPDUsOverview); tabControlSniffer.Controls.Remove(tabSummaryValidationResults); tabControlSniffer.Controls.Remove(tabDetailValidationResults); menuItemConfig.Visible = true; menuItemSaveResultsAs.Visible = true; menuItem_capaspdus.Visible = true; menuItem_capaspdus.Enabled = false; menuItemCap.Visible = true; SaveConfig.Visible = true; SaveResultAs.Visible = true; CaptureButton.Visible = true; }
public HLIThread(DICOMSniffer mainObj, SnifferSession snifferSession, ArrayList list) { snifferObj = mainObj; dvtkSnifferSession = snifferSession; connectionList = list; }