示例#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);
            }
        }
示例#2
0
 /// <summary>
 ///		Create a new TdpSourcePortFilterIndexer class.
 /// </summary>
 /// <param name="owner">
 ///		The owner.
 ///	</param>
 public TdpSourcePortFilterIndexer(TcpFilter owner)
 {
     this.owner = owner;
 }
示例#3
0
 /// <summary>
 ///		Create a new DestinationPortFilterIndexer class.
 /// </summary>
 /// <param name="owner">
 ///		The owner.
 ///	</param>
 public DestinationPortFilterIndexer(TcpFilter owner)
 {
     this.owner = owner;
 }
示例#4
0
 /// <summary>
 ///		Create a new TdpSourcePortFilterIndexer class.
 /// </summary>
 /// <param name="owner">
 ///		The owner.
 ///	</param>
 public TdpSourcePortFilterIndexer(TcpFilter owner)
 {
     this.owner = owner;
 }
示例#5
0
 /// <summary>
 ///		Create a new DestinationPortFilterIndexer class.
 /// </summary>
 /// <param name="owner">
 ///		The owner.
 ///	</param>
 public DestinationPortFilterIndexer(TcpFilter owner)
 {
     this.owner = owner;
 }