Exemplo n.º 1
0
        /// <summary>
        ///		Whenever a new TCP packet arrives it should be passed to this method.
        ///		If the packet is to be filtered out it will be ignored otherwise the
        ///		TcpPacketArrived will be raised with the packet
        /// </summary>
        /// <param name="packet">
        ///		The packet which has arrived.
        ///	</param>
        public void HandleNewPacket(TcpPacket packet)
        {
            bool match = true;

            // check the source port filter
            foreach (string filter in m_sourcePortFilter)
            {
                if (!TcpFilter.IsMatch(packet.SourcePort, filter))
                {
                    match = false;
                    break;
                }
            }

            // if no match then exit
            if (!match)
            {
                return;
            }

            // check the destination port filter
            foreach (string filter in m_destPortFilter)
            {
                if (!TcpFilter.IsMatch(packet.DestinationPort, filter))
                {
                    match = false;
                    break;
                }
            }

            // if no match then exit
            if (!match)
            {
                return;
            }

            // if we get here then the packet has passed through the filter and we
            // raise the event
            if (TcpPacketArrived != null)
            {
                TcpPacketArrived(packet);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 ///		Create a new TdpSourcePortFilterIndexer class.
 /// </summary>
 /// <param name="owner">
 ///		The owner.
 ///	</param>
 public TdpSourcePortFilterIndexer(TcpFilter owner)
 {
     this.owner = owner;
 }
Exemplo n.º 3
0
 /// <summary>
 ///		Create a new DestinationPortFilterIndexer class.
 /// </summary>
 /// <param name="owner">
 ///		The owner.
 ///	</param>
 public DestinationPortFilterIndexer(TcpFilter owner)
 {
     this.owner = owner;
 }
Exemplo n.º 4
0
 /// <summary>
 ///		Create a new TdpSourcePortFilterIndexer class.
 /// </summary>
 /// <param name="owner">
 ///		The owner.
 ///	</param>
 public TdpSourcePortFilterIndexer(TcpFilter owner)
 {
     this.owner = owner;
 }
Exemplo n.º 5
0
 /// <summary>
 ///		Create a new DestinationPortFilterIndexer class.
 /// </summary>
 /// <param name="owner">
 ///		The owner.
 ///	</param>
 public DestinationPortFilterIndexer(TcpFilter owner)
 {
     this.owner = owner;
 }