Esempio n. 1
0
        public override bool Equals(object obj)
        {
            LocalNetworkPrefix that = obj as LocalNetworkPrefix;

            return(((that != null) &&
                    object.Equals(this.IpNetwork, that.IpNetwork)) &&
                   object.Equals(this.IpPrefix, that.IpPrefix));
        }
Esempio n. 2
0
        public override void Define()
        {
            LocalNetworkPrefix localPrefix = null;
            ArpUnanswered      hostArp     = null;

            When()
            .Match(() => localPrefix)
            .Match(() => hostArp)
            .All <IpFlow>(f => f.IpSrc != hostArp.Request.ArpSrcProtoIpv4 || IsLocalOrMulticast(f.IpDst, localPrefix));
            Then()
            .Do(ctx => EmitInvalidGateway(ctx, hostArp));
        }
Esempio n. 3
0
        public override void Define()
        {
            LocalNetworkPrefix localNetworkPrefix = null;
            IGrouping <AddressScope, AddressMapping> addressClass = null;

            When()
            .Match(() => localNetworkPrefix)
            .Query(() => addressClass, q => q
                   .Match <AddressMapping>()
                   .GroupBy(m => LanRulesHelper.GetAddressScope(m.IpAddr, localNetworkPrefix)));
            Then()
            .Do(ctx => ctx.Info($"{addressClass.Key} hosts: {StringUtils.ToString(addressClass.ToArray())}"));
        }
Esempio n. 4
0
        public static AddressScope GetAddressScope(string ipAddr, LocalNetworkPrefix localNetworkPrefix)
        {
            var ip = IPAddress.Parse(ipAddr);

            if (ip.BelongsTo(linkLocalIp, 16))
            {
                return(AddressScope.LinkLocalAddress);
            }
            if (ip.BelongsTo(multicastIp, 3))
            {
                return(AddressScope.MulticastAddress);
            }
            if (ip.BelongsTo(IPAddress.Parse(localNetworkPrefix.IpNetwork), localNetworkPrefix.IpPrefix))
            {
                return(AddressScope.LocalAddress);
            }
            else
            {
                return(AddressScope.RemoteAddress);
            }
        }
Esempio n. 5
0
        bool IsLocalOrMulticast(string ipAddr, LocalNetworkPrefix localNetworkPrefix)
        {
            var scope = LanRulesHelper.GetAddressScope(ipAddr, localNetworkPrefix);

            return(scope != AddressScope.RemoteAddress);
        }