Пример #1
0
        //删除静态路由
        public static bool DeleteStaticRouting(DB_Talk.Model.m_StaticRoute model)
        {
            List<DB_Talk.Model.m_StaticRoute> lst=new List<DB_Talk.Model.m_StaticRoute>();
            GetStaticRouting(out lst);
            if (lst.Count==0)
            {
                return true;
            }
            //是否存在要删除的静态路由
            bool isExits = false;
            foreach (DB_Talk.Model.m_StaticRoute item in lst)
            {
                if (item.vc_GateWayIP==model.vc_GateWayIP && item.vc_Mask==model.vc_Mask && item.vc_NetIP==model.vc_NetIP)
                {
                    isExits = true;
                    break;
                }
            }
            if (isExits==false)
            {
                return true;
            }
            MBoxSDK.ConfigSDK.tagStaticRoutingInfo StaticRoutingInfo = new MBoxSDK.ConfigSDK.tagStaticRoutingInfo();

            StaticRoutingInfo.szNet = new byte[MBoxSDK.ConfigSDK.MAX_IP4];
            StaticRoutingInfo.szMask = new byte[MBoxSDK.ConfigSDK.MAX_IP4];
            StaticRoutingInfo.szGateWay = new byte[MBoxSDK.ConfigSDK.MAX_IP4];

            byte[] bnet = System.Text.ASCIIEncoding.ASCII.GetBytes(model.vc_NetIP);
            bnet.CopyTo(StaticRoutingInfo.szNet, 0);

            byte[] bmask = System.Text.ASCIIEncoding.ASCII.GetBytes(model.vc_Mask);
            bmask.CopyTo(StaticRoutingInfo.szMask, 0);

            byte[] bgateway = System.Text.ASCIIEncoding.ASCII.GetBytes(model.vc_GateWayIP);  //安全网关地址
            bgateway.CopyTo(StaticRoutingInfo.szGateWay, 0);

            return MBoxSDK.ConfigSDK.MBOX_DeleteStaticRouting(Global.Params.BoxHandle, StaticRoutingInfo);
        }
Пример #2
0
        //添加静态路由
        public static bool CreateStaticRouting(DB_Talk.Model.m_StaticRoute model)
        {
            MBoxSDK.ConfigSDK.tagStaticRoutingInfo StaticRoutingInfo = new MBoxSDK.ConfigSDK.tagStaticRoutingInfo();

            StaticRoutingInfo.szNet = new byte[MBoxSDK.ConfigSDK.MAX_IP4];
            StaticRoutingInfo.szMask = new byte[MBoxSDK.ConfigSDK.MAX_IP4];
            StaticRoutingInfo.szGateWay = new byte[MBoxSDK.ConfigSDK.MAX_IP4];

            byte[] bnet = System.Text.ASCIIEncoding.ASCII.GetBytes(model.vc_NetIP);//"192.168.100.0");
            bnet.CopyTo(StaticRoutingInfo.szNet, 0);

            byte[] bmask = System.Text.ASCIIEncoding.ASCII.GetBytes(model.vc_Mask);//"255.255.255.0");
            bmask.CopyTo(StaticRoutingInfo.szMask, 0);

            byte[] bgateway = System.Text.ASCIIEncoding.ASCII.GetBytes(model.vc_GateWayIP);//"192.168.1.11");  //安全网关地址
            bgateway.CopyTo(StaticRoutingInfo.szGateWay, 0);

            return  MBoxSDK.ConfigSDK.MBOX_SetStaticRouting(Global.Params.BoxHandle, StaticRoutingInfo);

        }