Beispiel #1
0
        /* 监听扫描返回数据包端口 */
        public void listenCheckResult()
        {
            while (true)
            {
                byte[] content = listener.Receive(ref groupEP);
                confirm = Encoding.Default.GetString(content);
                if ((confirm.IndexOf("firedeviceConfirm")) != -1)
                {
#if debug
                    Console.WriteLine("捕获到返回信息!!!");
#endif
                    string[] sArray_IP_MAC = confirm.Split('&');
                    string   fw_IP         = sArray_IP_MAC[0]; //防火墙IP
                    string   dev_mac       = sArray_IP_MAC[1]; //受保护设备MAC
                    string   fw_mac        = sArray_IP_MAC[2]; //防火墙MAC
                    string   dev_IP        = sArray_IP_MAC[4]; //受保护设备IP
                    //if (dev_mac != "")
                    //{
                    if (fw_IP != "0.0.0.0" && (fwMAC_list.Contains(fw_mac)))        //如果已经存在
                    {
                        foreach (FWDeviceForm fwdev in fw_list)
                        {
                            if (fwdev.getDev_MAC() == fw_mac)
                            {
                                if (!fwdev.getProtecDevIP_list().Contains(dev_IP))
                                {
                                    ProtecDeviceForm protecDev = new ProtecDeviceForm(dev_IP, dev_mac);
                                    fwdev.addProtecDev(protecDev);
                                    fwdev.addProtecDevIP(dev_IP);
                                }
                            }
                        }
                    }
                    else
                    {
                        FWDeviceForm fw_dev = new FWDeviceForm(fw_IP, 22222, fw_mac);
                        fw_dev.addProtecDev(new ProtecDeviceForm(dev_IP, dev_mac));
                        fw_dev.addProtecDevIP(dev_IP);
                        fwMAC_list.Add(fw_mac);
                        fw_list.Add(fw_dev);
                    }
                    //}

#if debug
                    Console.WriteLine("保存设备信息!!!");
#endif
                }
                else
                {
                    Console.WriteLine("未扫描到设备");
                }
            }
        }
Beispiel #2
0
        bool IResetIP.ResetIP(ProtecDeviceForm fw_dev, string BindIP)
        {
            string cmd = "ifconfig br0 down && ifconfig br0 " + BindIP + " up";

            fw_dev.setDev_port(22222);
            SendInfo sendResetcmd = new SendInfo(fw_dev);

            if (sendResetcmd.SendConfigInfo(cmd))
            {
                fw_dev.setDev_IP(BindIP);
                return(true);
            }

            else
            {
                return(false);
            }
        }
Beispiel #3
0
 public void addProtecDev(ProtecDeviceForm protecDev)
 {
     ProtecDev_list.Add(protecDev);
 }