Example #1
0
        public IPList()
        {
            string       path = "IPlist.csv";
            StreamReader sr   = new StreamReader(path, Encoding.Default);
            String       line;

            while ((line = sr.ReadLine()) != null)
            {
                ConfigurationProperties Configuration = new ConfigurationProperties();
                string[] strs = line.Split(new char[] { ',' });
                Configuration.Name = strs[0];
                Configuration.IP   = strs[1];
                Configuration.Port = strs[2];
                Configuration.Type = strs[3];
                ConfigProperties.Add(Configuration);
            }
        }
Example #2
0
 private void CalculateInterval(PacketProperties Properties, ConfigurationProperties SourceDevice, ConfigurationProperties DestDevice)
 {
     if (DicInterval.Keys.Contains(SourceDevice.IP + "-" + SourceDevice.Port + "+" + DestDevice.IP + "-" + DestDevice.Port))
     {
         Properties.Interval = (Properties.CaptureTime - DicInterval[SourceDevice.IP + "-" + SourceDevice.Port + "+" + DestDevice.IP + "-" + DestDevice.Port]).TotalSeconds;
         DicInterval[SourceDevice.IP + "-" + SourceDevice.Port + "+" + DestDevice.IP + "-" + DestDevice.Port] = Properties.CaptureTime;
     }
     else
     {
         Properties.Interval = 0;
         DicInterval.Add(SourceDevice.IP + "-" + SourceDevice.Port + "+" + DestDevice.IP + "-" + DestDevice.Port, Properties.CaptureTime);
     }
     showSignal = true;
     if (!Pause)
     {
         UpdateForm(Properties, showSignal, showSignaling);
     }
     SaveToPcap(Properties);
 }
        private void DataFilterByIPAndPort(PacketProperties Properties)
        {
            bool IsSourceMeet = false;
            bool isDestMeet   = false;
            ConfigurationProperties SourceDevice = null;
            ConfigurationProperties DestDevice   = null;

            foreach (var Source in IPList.ConfigProperties)
            {
                if (Source.IsSourceChoose == true && Properties.OriginationAddress == Source.IP && Properties.OriginationPort == Source.Port)
                {
                    IsSourceMeet = true;
                    SourceDevice = Source;
                    break;
                }
            }
            if (IsSourceMeet)
            {
                foreach (var Dest in IPList.ConfigProperties)
                {
                    if (Dest.IsDestChoose == true && Properties.DestinationAddress == Dest.IP && Properties.DestinationPort == Dest.Port)
                    {
                        isDestMeet = true;
                        DestDevice = Dest;
                        break;
                    }
                }
                if (isDestMeet)
                {
                    if (SetSendDir(SourceDevice, DestDevice, Properties))
                    {
                        if (!Pause)
                        {
                            SaveToShowStorage(Properties);
                        }
                        SaveToPcap(Properties);
                    }
                }
            }
        }
Example #4
0
 private bool SetSendDir(ConfigurationProperties SourceDevice, ConfigurationProperties DestDevice, PacketProperties Properties)
 {
     if (SourceDevice.Type == "VOBC" && DestDevice.Type == "ZC")
     {
         Properties.SendDir = SendDir.VOBCToZC;
         return(true);
     }
     else if (SourceDevice.Type == "ZC" && DestDevice.Type == "VOBC")
     {
         Properties.SendDir = SendDir.ZCToVOBC;
         return(true);
     }
     else if (SourceDevice.Type == "CI" && DestDevice.Type == "VOBC")
     {
         Properties.SendDir = SendDir.CIToVOBC;
         return(true);
     }
     else if (SourceDevice.Type == "VOBC" && DestDevice.Type == "CI")
     {
         Properties.SendDir = SendDir.VOBCToCI;
         return(true);
     }
     else if (SourceDevice.Type == "ATS" && DestDevice.Type == "VOBC")
     {
         Properties.SendDir = SendDir.ATSToVOBC;
         return(true);
     }
     else if (SourceDevice.Type == "VOBC" && DestDevice.Type == "ATS")
     {
         Properties.SendDir = SendDir.VOBCToATS;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #5
0
        public IPList()
        {
            string       path = "IPlist.csv";
            StreamReader sr   = new StreamReader(path, Encoding.Default);
            String       line;

            while ((line = sr.ReadLine()) != null)
            {
                ConfigurationProperties Configuration = new ConfigurationProperties();
                string[] strs = line.Split(new char[] { ',' });
                Configuration.Name = strs[0];
                Configuration.IP   = strs[1];
                Configuration.Port = strs[2];
                Configuration.Type = strs[3];
                ConfigProperties.Add(Configuration);
            }
            bool IsBug = false;

            for (int i = 1; i < ConfigProperties.Count; i++)
            {
                if (ConfigProperties[i].Type != "VOBC" && ConfigProperties[i].Type != "ZC" && ConfigProperties[i].Type != "ATS" && ConfigProperties[i].Type != "CI")
                {
                    IsBug = true;
                }
            }
            if (IsBug)
            {
                MessageBox.Show("IPlist.csv文件配置有误,请检查备注栏是否按\n规定填写(“VOBC”,“ZC”,“CI”,“ATS”)",
                                "警告",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning,
                                MessageBoxDefaultButton.Button2,
                                MessageBoxOptions.RightAlign
                                );
            }
        }
Example #6
0
        private void DataFilterByIPAndPort(PacketProperties Properties)
        {
            bool IsSourceMeet = false;
            bool isDestMeet   = false;
            ConfigurationProperties SourceDevice = null;
            ConfigurationProperties DestDevice   = null;

            foreach (var Source in IPList.ConfigProperties)
            {
                if (Source.IsSourceChoose == true && Properties.OriginationAddress.Contains(Source.IP) && Properties.OriginationPort == Source.Port)
                {
                    IsSourceMeet = true;
                    SourceDevice = Source;
                    break;
                }
            }
            if (IsSourceMeet)
            {
                foreach (var Dest in IPList.ConfigProperties)
                {
                    if (Dest.IsDestChoose == true && Properties.DestinationAddress.Contains(Dest.IP) && Properties.DestinationPort == Dest.Port)
                    {
                        isDestMeet = true;
                        DestDevice = Dest;
                        break;
                    }
                }
                if (isDestMeet)
                {
                    if (SetSendDir(SourceDevice, DestDevice, Properties))
                    {
                        CalculateInterval(Properties, SourceDevice, DestDevice);
                    }
                }
            }
        }