Beispiel #1
0
        public bool ConfigOPCRules(OPCRulesForm orf, bool log_flag, bool add_delete)
        {
            string flag = null; string sql_rule = null;

            String opc_rules_from_client_to_server0    = "iptables -A FORWARD -p tcp -s " + orf.getSrc_IP() + " -d " + orf.getDst_IP() + " --dport 135 -m state --state ESTABLISHED -j NFQUEUE --queue-num 1";
            String opc_rules_from_client_to_server1    = "iptables -A FORWARD -p tcp -s " + orf.getDst_IP() + " -d " + orf.getSrc_IP();
            String opc_rules_from_client_to_server_log = "iptables -A FORWARD -p tcp -s " + orf.getSrc_IP() + " -d " + orf.getDst_IP() + " --dport 135 -m state --state ESTABLISHED -j LOG --log-prefix " + "\"" + "ACCEPT&OPC&ESTABLISHED " + "\"";

            //String opc_rules_from_server_to_client = "iptables -A FORWARD -p tcp -s " + orf.getDst_IP() + " -d " + orf.getSrc_IP() + " --sport 135 -m state --state ESTABLISHED -j NFQUEUE --queue-num 1";
            if (add_delete == true)
            {
                flag     = "DPI1";
                sql_rule = "INSERT INTO OPC values " + "(" + devform.getDev_IP() + "','" + orf.getDst_IP() + "','" + orf.getSrc_IP() + "','ACCEPT','" + log_flag + "')";
            }

            else if (add_delete == false)
            {
                flag     = "DPI0";
                sql_rule = "DELETE FROM OPC where (dev_IP='" + devform.getDev_IP() + "' and dst_IP='" + orf.getDst_IP() + "' and src_IP='" + orf.getSrc_IP() + "' and method='ACCEPT')";
            }

            string rule = flag + opc_rules_from_client_to_server_log + " && " + opc_rules_from_client_to_server0 + " && " + opc_rules_from_client_to_server1;

            DPIdb_operate.dboperate(sql_rule);
            SendInfo sendcmd = new SendInfo(devform);

            return(sendcmd.SendConfigInfo(rule));
        }
Beispiel #2
0
        public bool ChangeOPCRules(string dst_IP, string src_IP, string dev_IP, bool log_record, bool add_delete)
        {
            OPCRulesForm orf = new OPCRulesForm();

            orf.setDst_IPAndSrc_IP(dst_IP, src_IP);

            DeviceForm devform = new DeviceForm(dev_IP, 22222);

            ConfigDPIRules configDevice = new ConfigDPIRules(devform);

            return(configDevice.ConfigOPCRules(orf, log_record, add_delete));
        }