Beispiel #1
0
 public RouteEntry(
     uint destination,
     uint mask,
     int policy,
     uint nextHop,
     NetworkInterface intf,
     ForwardType type,
     ForwardProtocol proto,
     int age,
     int nextHopAS,
     int metric1,
     int metric2,
     int metric3,
     int metric4,
     int metric5,
     int idx)
 {
     this._age         = age;
     this._policy      = policy;
     this._protocol    = proto;
     this._type        = type;
     this._destination = new IPAddress((long)destination);
     this._mask        = new IPAddress((long)mask);
     this._nextHop     = new IPAddress((long)nextHop);
     this._nextHopAS   = nextHopAS;
     this._interface   = intf;
     this._metric1     = metric1;
     this._metric2     = metric2;
     this._metric3     = metric3;
     this._metric4     = metric4;
     this._metric5     = metric5;
     this._index       = idx;
 }
Beispiel #2
0
        /// <summary>
        /// Modifie une route existante.
        /// </summary>
        /// <param name="entryToSet">Route à modifier.</param>
        /// <param name="IPInterface">Nouvelle interface.</param>
        /// <param name="IPDestination">Nouvelle IP de destination.</param>
        /// <param name="Mask">Nouveau masque.</param>
        /// <param name="Protocol">Protocol de routage.</param>
        /// <param name="NextHopAddr">Nouvelle adresse du prochain saut.</param>
        /// <returns>0 si réussi.</returns>
        public int ChangeRouteEntry(ref RouteEntry entryToSet, int IPInterface, IPAddress IPDestination,
                                    IPAddress Mask, ForwardProtocol Protocol, IPAddress NextHopAddr, int metric)
        {
            int ret = -1;

            try
            {
                MIB_IPFORWARDROW ipFwdSet = entryToSet._ipFwdNative;
                ipFwdSet.dwForwardIfIndex = IPInterface;
                ipFwdSet.dwForwardDest    = (uint)BitConverter.ToInt32(IPDestination.GetAddressBytes(), 0);
                ipFwdSet.dwForwardMask    = (uint)BitConverter.ToInt32(Mask.GetAddressBytes(), 0);
                ipFwdSet.dwForwardProto   = Protocol;
                ipFwdSet.dwForwardNextHop = (uint)BitConverter.ToInt32(NextHopAddr.GetAddressBytes(), 0);
                //ipFwdSet.dwForwardMetric1 = metric;
                //Appel api pour modifier la route.
                ret = NativeMethods.SetIpForwardEntry(ref ipFwdSet);
                if (ret == 0)
                {
                    entryToSet.Index       = IPInterface;
                    entryToSet.Destination = IPDestination;
                    entryToSet.Mask        = Mask;
                    entryToSet.Protocol    = Protocol;
                    entryToSet.NextHop     = NextHopAddr;
                    entryToSet.Metric1     = metric;
                }
            }
            catch (Exception)
            {
            }

            return(ret);
        }
Beispiel #3
0
        public void Parse_ParsesSpecification(string input, ForwardProtocol protocol, int port, string socketName, int processId)
        {
            var value = ForwardSpec.Parse(input);

            Assert.NotNull(value);
            Assert.Equal(protocol, value.Protocol);
            Assert.Equal(port, value.Port);
            Assert.Equal(processId, value.ProcessId);
            Assert.Equal(socketName, value.SocketName);

            Assert.Equal(input, value.ToString());
        }