Supporting a new traffic filter type¶
The steps to add support for a new queuing discipline are:
Creation of a new Python class that inherits from
TrafficFilter; the convention is to name such a classxxxFilterwherexxxis the name of the filterxxxFilter.__init__()should expect as optional arguments:the filter priority (an integer)
the
Handleof the destination queuing classthe filter-specific parameters
The
xxxFilterclass must implement thefilter_creation_args()method; this method should return the filter-specific tc(8) arguments for creating the filterThe
xxxFilterclass must implement the class methodparse()to create axxxFilterinstance from theFilterOutputinstance that is passed as an argument.The
xxxFilterclass must be registered by invoking theTrafficFilterParser.register_filter()methodThe
xxxFilterclass should implement theget_description()methodThe
xxxFilterclass should implement theget_match_name()methodThe
xxxFilterclass should implement getter methods for the filter-specific parametersThe
xxxFilterclass may implement setter methods for the filter-specific parameters
TrafficFilter¶
- class TrafficFilter(protocol: str, prio: Optional[int], filter_type: str, *, dest_class_handle: Optional[Handle] = None, filter_name: Optional[str] = None)[source]¶
Generic filter class. It cannot be instantiated. It is subclassed based on filter type.
- Parameters:
protocol – protocol
prio – optional filter priority (a number); defaults to -1
filter_type – a string indicating one of the currently supported filter types:
u32,fwdest_class_handle –
Handleof class where this filter will direct trafficfilter_name – user-friendly filter name
- get_match_name() Optional[str][source]¶
Returns a string with the name that describes the traffic matched by the filter, or
None.This method should be defined in derived classes.
- get_dest_handle() Optional[Handle][source]¶
Returns the
Handleof theQClasswhere this filter will send traffic