Class Ip4PacketFilter

java.lang.Object
ca.uqac.lif.cep.Processor
ca.uqac.lif.cep.SynchronousProcessor
netp.Ip4PacketFilter
All Implemented Interfaces:
ca.uqac.lif.cep.Contextualizable, ca.uqac.lif.cep.Duplicable, ca.uqac.lif.cep.DuplicableProcessor

public class Ip4PacketFilter extends ca.uqac.lif.cep.SynchronousProcessor
Discards packets from an input trace based on a selection criterion. These criterion are net protocol, source and destination IP, and source and destination port. A packet must satisfy ALL criterion to pass through the filter. At least, it lets only IPv4 packets through, and discards the rest.
  • Nested Class Summary

    Nested classes/interfaces inherited from class ca.uqac.lif.cep.SynchronousProcessor

    ca.uqac.lif.cep.SynchronousProcessor.InputPushable, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable

    Nested classes/interfaces inherited from class ca.uqac.lif.cep.Processor

    ca.uqac.lif.cep.Processor.InternalProcessorState
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     

    Fields inherited from class ca.uqac.lif.cep.SynchronousProcessor

    m_inputPushables, m_outputPullables, m_tempQueue

    Fields inherited from class ca.uqac.lif.cep.Processor

    m_context, m_hasBeenNotifiedOfEndOfTrace, m_inputArity, m_inputPullables, m_inputQueues, m_notifiedEndOfTraceDownstream, m_outputArity, m_outputPushables, m_outputQueues, MAX_PULL_RETRIES, s_versionString
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiates a default filter that allows all packets through
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a destination IP to allow through the filter.
    void
    Adds a source IP to allow through the filter.
     
    protected boolean
    compute(Object[] inputs, Queue<Object[]> outputs)
     
    ca.uqac.lif.cep.Processor
    duplicate(boolean with_state)
     
    void
    Remove a destination IP from the filter.
    void
    Remove a source IP from the filter.
    void
    Set the destination port to allow through the filter
    void
    setDestinationPortRange(int low, int high)
    Set a range of destination ports to allow through the filter
    void
    setProtocol(int protocol)
    Set the protocol to allow through the filter.
    void
    setSourcePort(int src)
    Set the source port to allow through the filter
    void
    setSourcePortRange(int low, int high)
    Set a range of source ports to allow through the filter

    Methods inherited from class ca.uqac.lif.cep.SynchronousProcessor

    getPullableOutput, getPushableInput

    Methods inherited from class ca.uqac.lif.cep.Processor

    allNotifiedEndOfTrace, allNull, copyInputQueue, copyOutputQueue, duplicate, duplicateInto, equals, getAt, getContext, getContext, getEmptyQueue, getId, getInputArity, getInputQueue, getInputType, getInputTypesFor, getOutputArity, getOutputQueue, getOutputType, getPullableInput, getPullableOutput, getPushableInput, getPushableOutput, hashCode, leftShift, newContext, onEndOfTrace, or, or, or, printState, readState, reset, rightShift, setContext, setContext, setPullableInput, setPushableOutput, start, startAll, stop, stopAll

    Methods inherited from class Object

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Ip4PacketFilter

      public Ip4PacketFilter()
      Instantiates a default filter that allows all packets through
  • Method Details

    • addSourceIp

      public void addSourceIp(String src)
      Adds a source IP to allow through the filter. If the IP list is empty, all IPs pass through.
      Parameters:
      src - IP address in string form (e.g. "192.168.0.1")
    • removeSourceIp

      public void removeSourceIp(String src)
      Remove a source IP from the filter. If the IP list is empty, all IPs pass through.
      Parameters:
      src - IP address in string form (e.g. "192.168.0.1")
    • addDestinationIp

      public void addDestinationIp(String dst)
      Adds a destination IP to allow through the filter. If the IP list is empty, all IPs pass through.
      Parameters:
      dst - IP address in string form (e.g. "192.168.0.1")
    • removeDestinationIp

      public void removeDestinationIp(String dst)
      Remove a destination IP from the filter. If the IP list is empty, all IPs pass through.
      Parameters:
      dst - IP address in string form (e.g. "192.168.0.1")
    • setProtocol

      public void setProtocol(int protocol)
      Set the protocol to allow through the filter. The filtered protocol is the one within the IPv4 header.
      Parameters:
      protocol - the protocol ID, or PacketFilter.ANY_PROTOCOL to allow all protocols
    • setSourcePort

      public void setSourcePort(int src)
      Set the source port to allow through the filter
      Parameters:
      src - the port number
    • setSourcePortRange

      public void setSourcePortRange(int low, int high)
      Set a range of source ports to allow through the filter
      Parameters:
      low - the lower bound of the port range to allow
      high - the upper bound of the port range to allow
    • setDestinationPort

      public void setDestinationPort(int dst)
      Set the destination port to allow through the filter
      Parameters:
      dst - the port number
    • setDestinationPortRange

      public void setDestinationPortRange(int low, int high)
      Set a range of destination ports to allow through the filter
      Parameters:
      low - the lower bound of the port range to allow
      high - the upper bound of the port range to allow
    • compute

      protected boolean compute(Object[] inputs, Queue<Object[]> outputs)
      Specified by:
      compute in class ca.uqac.lif.cep.SynchronousProcessor
    • clone

      public Ip4PacketFilter clone()
      Overrides:
      clone in class Object
    • duplicate

      public ca.uqac.lif.cep.Processor duplicate(boolean with_state)
      Specified by:
      duplicate in interface ca.uqac.lif.cep.Duplicable
      Specified by:
      duplicate in class ca.uqac.lif.cep.Processor