base/frameworks/packet-filter/main.bro
-
PacketFilter
This script supports how Bro sets its BPF capture filter. By default
Bro sets a capture filter that allows all traffic. If a filter
is set on the command line, that filter takes precedence over the default
open filter and all filters defined in Bro scripts with the
capture_filters
and restrict_filters
variables.
Detailed Interface
Redefinable Options
-
PacketFilter::default_capture_filter
-
The BPF filter that is used by default to define what traffic should
be captured. Filters defined in restrict_filters
will
still be applied to reduce the captured traffic.
-
PacketFilter::enable_auto_protocol_capture_filters
-
Enables the old filtering approach of “only watch common ports for
analyzed protocols”.
Unless you know what you are doing, leave this set to F.
-
PacketFilter::max_filter_compile_time
-
The maximum amount of time that you’d like to allow for BPF filters to compile.
If this time is exceeded, compensation measures may be taken by the framework
to reduce the filter size. This threshold being crossed also results
in the PacketFilter::Too_Long_To_Compile_Filter
notice.
-
PacketFilter::restricted_filter
-
Filter string which is unconditionally and’ed to the beginning of
every dynamically built filter. This is mostly used when a custom
filter is being used but MPLS or VLAN tags are on the traffic.
-
PacketFilter::unrestricted_filter
-
Filter string which is unconditionally or’ed to the beginning of
every dynamically built filter.
State Variables
-
PacketFilter::current_filter
Type: | string |
Default: | "<not set yet>" |
This is where the default packet filter is stored and it should not
normally be modified by users.
Types
-
PacketFilter::FilterPlugin
Type: | record
- func:
function () : void
A function that is directly called when generating the complete filter.
|
A data structure to represent filter generating plugins.
-
PacketFilter::Info
Type: | record
- ts:
time &log
The time at which the packet filter installation attempt was made.
- node:
string &log &optional
This is a string representation of the node that applied this
packet filter. It’s mostly useful in the context of
dynamically changing filters on clusters.
- filter:
string &log
The packet filter that is being set.
- init:
bool &log &default = F &optional
Indicate if this is the filter set during initialization.
- success:
bool &log &default = T &optional
Indicate if the filter was applied successfully.
|
The record type defining columns to be logged in the packet filter
logging stream.
Functions
-
PacketFilter::exclude
-
Install a BPF filter to exclude some traffic. The filter should
positively match what is to be excluded, it will be wrapped in
a “not”.
Filter_id: | An arbitrary string that can be used to identify
the filter. |
Filter: | A BPF expression of traffic that should be excluded. |
Returns: | A boolean value to indicate if the filter was successfully
installed or not. |
-
PacketFilter::exclude_for
-
Install a temporary filter to traffic which should not be passed
through the BPF filter. The filter should match the traffic you
don’t want to see (it will be wrapped in a “not” condition).
Filter_id: | An arbitrary string that can be used to identify
the filter. |
Filter: | A BPF expression of traffic that should be excluded. |
Length: | The duration for which this filter should be put in place. |
Returns: | A boolean value to indicate if the filter was successfully
installed or not. |
-
PacketFilter::install
-
Call this function to build and install a new dynamically built
packet filter.
-
PacketFilter::register_filter_plugin
-
API function to register a new plugin for dynamic restriction filters.