Trait Plugin

Source
pub trait Plugin: Sync + Send {
    // Required method
    fn name(&self) -> &'static str;

    // Provided methods
    fn plugin_type(&self) -> u16 { ... }
    fn pre_process(&mut self) { ... }
    fn post_process(&mut self) { ... }
    fn handle_layer_physical<'s, 'i>(
        &'s mut self,
        _packet: &'s Packet<'_>,
        _data: &'i [u8],
    ) -> PluginResult<'i> { ... }
    fn handle_layer_link<'s, 'i>(
        &'s mut self,
        _packet: &'s Packet<'_>,
        _linklayertype: u16,
        _data: &'i [u8],
    ) -> PluginResult<'i> { ... }
    fn handle_layer_network<'s, 'i>(
        &'s mut self,
        _packet: &'s Packet<'_>,
        _payload: &'i [u8],
        _t3: &'s ThreeTuple,
    ) -> PluginResult<'i> { ... }
    fn handle_layer_transport<'s, 'i>(
        &'s mut self,
        _packet: &'s Packet<'_>,
        _pinfo: &PacketInfo<'_, '_, '_, '_>,
    ) -> PluginResult<'i> { ... }
    fn flow_created(&mut self, _flow: &Flow) { ... }
    fn flow_destroyed(&mut self, _flow: &Flow) { ... }
    fn get_results(&mut self) -> Option<Box<dyn Any>> { ... }
    fn save_results(&mut self, _path: &str) -> Result<(), &'static str> { ... }
}
Expand description

Pcap/Pcap-ng analysis plugin instance

Plugins must be thread-safe because functions can (and will) be called concurrently from multiple threads.

Required Methods§

Source

fn name(&self) -> &'static str

Returns the name of the plugin instance

Provided Methods§

Source

fn plugin_type(&self) -> u16

Returns the layers registered by this plugin

Source

fn pre_process(&mut self)

Plugin initialization function Called before processing a pcap file

Source

fn post_process(&mut self)

Plugin end of processing function Called after processing a pcap file

Source

fn handle_layer_physical<'s, 'i>( &'s mut self, _packet: &'s Packet<'_>, _data: &'i [u8], ) -> PluginResult<'i>

Callback function when layer 2 data is available data is the raw ethernet data PLUGIN_L1 must be added to plugin_type() return See crate::layers for possible linklayertype values

Source

fn handle_layer_network<'s, 'i>( &'s mut self, _packet: &'s Packet<'_>, _payload: &'i [u8], _t3: &'s ThreeTuple, ) -> PluginResult<'i>

Callback function when layer 3 data is available packet is the initial layer 3 packet information payload is the layer 3 payload. It can be different from packet.data if defragmentation occured t3 is the three-tuple of the connection PLUGIN_L3 must be added to plugin_type() return

Source

fn handle_layer_transport<'s, 'i>( &'s mut self, _packet: &'s Packet<'_>, _pinfo: &PacketInfo<'_, '_, '_, '_>, ) -> PluginResult<'i>

Callback function when layer 4 data is available packet is the initial layer 3 packet information pinfo is the flow and layers information, including payload PLUGIN_L4 must be added to plugin_type() return

Source

fn flow_created(&mut self, _flow: &Flow)

Callback function when a new flow is created PLUGIN_FLOW_NEW must be added to plugin_type() return

Source

fn flow_destroyed(&mut self, _flow: &Flow)

Callback function when a flow is destroyed PLUGIN_FLOW_DEL must be added to plugin_type() return

Source

fn get_results(&mut self) -> Option<Box<dyn Any>>

Get results, if present

Source

fn save_results(&mut self, _path: &str) -> Result<(), &'static str>

Save results to specified directory

Implementors§