Beispiel #1
0
        private void InsertFacts(IContext ctx, IpPacket packet)
        {
            ctx.TryInsert(new IpFlow {
                IpSrc = packet.IpSrc, IpDst = packet.IpDst
            });

            ctx.TryInsert(new IpSourceEndpoint {
                IpAddr = packet.IpSrc
            });
            ctx.TryInsert(new IpEndpoint {
                IpAddr = packet.IpSrc
            });
            ctx.TryInsert(new AddressMapping {
                IpAddr = packet.IpSrc, EthAddr = packet.EthSrc
            });

            ctx.TryInsert(new IpDestinationEndpoint {
                IpAddr = packet.IpDst
            });
            ctx.TryInsert(new IpEndpoint {
                IpAddr = packet.IpDst
            });
            ctx.TryInsert(new AddressMapping {
                IpAddr = packet.IpDst, EthAddr = packet.EthDst
            });

            if (packet.EthDst == "ff:ff:ff:ff:ff:ff" && packet.IpDst != "255.255.255.255")
            {
                var f = new LocalNetworkBroadcast {
                    IpBroadcast = packet.IpDst
                };
                ctx.TryInsert(f);
            }
        }
Beispiel #2
0
        public override bool Equals(object obj)
        {
            LocalNetworkBroadcast that = obj as LocalNetworkBroadcast;

            return((that != null) &&
                   object.Equals(this.IpBroadcast, that.IpBroadcast));
        }
Beispiel #3
0
        private void CheckNetworkMask(IContext ctx, LocalNetworkBroadcast bcast, IpFlow[] flows)
        {
            var bcasts = new BroadcastGroup
            {
                IpBroadcast = bcast.IpBroadcast,
                IpAddrs     = flows.Select(x => x.IpSrc).ToArray()
            };

            ctx.TryInsert(bcasts);
        }
Beispiel #4
0
        public override void Define()
        {
            LocalNetworkBroadcast bcast = null;
            IEnumerable <IpFlow>  flows = null;

            When()
            .Match(() => bcast)
            .Query(() => flows, q =>
                   q.Match <IpFlow>()
                   .Where(f => f.IpDst == bcast.IpBroadcast)
                   .Collect());
            Then()
            .Do(ctx => CheckNetworkMask(ctx, bcast, flows.ToArray()));
        }