Helium
Functions
plugin_chain.h File Reference

Creation, destruction, registration, and execution for a plugin chain. More...

#include "he_internal.h"
Include dependency graph for plugin_chain.h:

Go to the source code of this file.

Functions

he_plugin_chain_the_plugin_create_chain (void)
 Creates a Helium plugin chain. More...
 
void he_plugin_destroy_chain (he_plugin_chain_t *chain)
 Releases all memory allocated by Helium for this plugin chain. More...
 
he_return_code_t he_plugin_register_plugin (he_plugin_chain_t *chain, plugin_struct_t *plugin)
 Register the plugin to the plugin chain. More...
 
he_return_code_t he_plugin_ingress (he_plugin_chain_t *chain, uint8_t *packet, size_t *length, size_t capacity)
 Execute the ingress function of each registered plugin. More...
 
he_return_code_t he_plugin_egress (he_plugin_chain_t *chain, uint8_t *packet, size_t *length, size_t capacity)
 Execute the egress function of each registered plugin. More...
 

Detailed Description

Creation, destruction, registration, and execution for a plugin chain.

Function Documentation

◆ he_plugin_create_chain()

he_plugin_chain_t* he_plugin_create_chain ( void  )

Creates a Helium plugin chain.

Returns
he_plugin_chain_t* Returns a pointer to a valid plugin chain
Note
This function allocates memory

This function must be called to create the initial plugin chain for use with other functions

◆ he_plugin_destroy_chain()

void he_plugin_destroy_chain ( he_plugin_chain_t chain)

Releases all memory allocated by Helium for this plugin chain.

Parameters
chainA pointer to a valid plugin chain
Note
he_plugin_destroy_chain does NOT free the plugin objects registered to the plugin chain.

◆ he_plugin_egress()

he_return_code_t he_plugin_egress ( he_plugin_chain_t chain,
uint8_t *  packet,
size_t *  length,
size_t  capacity 
)

Execute the egress function of each registered plugin.

Parameters
chainA pointer to a valid plugin chain
packetA pointer to the packet data
lengthA pointer to the length of the packet data. If the packet size changed after processed by this function, the length will be set to the new length of the packet data.
capacityThe length of the underlying buffer for packet
Returns
HE_SUCCESS All plugins executed successfully
HE_ERR_PLUGIN_DROP A plugin marked this packet for a drop
HE_ERR_FAILED An error occurred processing this packet
Note
The content of packet may be modified, grow or shrunk, depending on the registered plugins

◆ he_plugin_ingress()

he_return_code_t he_plugin_ingress ( he_plugin_chain_t chain,
uint8_t *  packet,
size_t *  length,
size_t  capacity 
)

Execute the ingress function of each registered plugin.

Parameters
chainA pointer to a valid plugin chain
packetA pointer to the packet data
lengthA pointer to the length of the packet data. If the packet size changed after processed by this function, the length will be set to the new length of the packet data.
capacityThe length of the underlying buffer for packet
Returns
HE_SUCCESS All plugins executed successfully
HE_ERR_PLUGIN_DROP A plugin marked this packet for a drop
HE_ERR_FAILED An error occurred processing this packet
Note
The content of packet may be modified, grow or shrunk, depending on the registered plugins

◆ he_plugin_register_plugin()

he_return_code_t he_plugin_register_plugin ( he_plugin_chain_t chain,
plugin_struct_t plugin 
)

Register the plugin to the plugin chain.

Parameters
chainA pointer to a valid plugin chain
pluginA pointer to the initialised plugin struct
Returns
HE_SUCCESS Plugin was successfully registered
HE_ERR_NULL_POINTER Either parameter was NULL
HE_ERR_INIT_FAILED Registering the plugin failed
Note
The plugin chain only keeps a reference to the plugin object. The caller is still responsible for freeing the memory used by the plugin object after use.