ESP32/ESP8266 Firewall 1.0.0
a software firewall for ESP23 or ESP8266
fw::Firewall Class Reference

The Firewall will handle Firewall rules as linked list. More...

#include <Firewall.hpp>

Inheritance diagram for fw::Firewall:
fw::Storage

Public Member Functions

 Firewall ()
 Construct a new Firewall object, retrieve current amount of firewall rules and restore them from Storage.
 
 ~Firewall ()
 Destroy the Firewall object.
 
firewall_rule_tget_rule_head ()
 Get the current rule head, it indicates the first rule position of the linked list. More...
 
void add_rule_to_firewall (firewall_rule_t *rule_ptr, const bool save_in_eeprom=true)
 add a new rule to the linked list, update amount of rules, store it in Storage if save_in_eeprom is true More...
 
firewall_rule_tadd_rule_to_firewall (String *args)
 add a new rule to the firewall, providing request parameter More...
 
firewall_rule_tupdate_rule_of_firewall (String *args, const uint8_t key)
 update rule of firewall, store it in Storage More...
 
firewall_rule_tget_rule_from_firewall (const uint8_t key)
 retrieve rule from the firewall linked list More...
 
ok_t delete_rule_from_firewall (const uint8_t key)
 delete rule from the firewall linked list, update amount of rules, store new order of rules in Storage More...
 
bool is_packet_allowed (struct pbuf *pbuf)
 checks if network packet is allowed to pass firewall More...
 
- Public Member Functions inherited from fw::Storage
 Storage ()
 Construct a new Storage object.
 
 ~Storage ()
 Destroy the Storage object.
 

Protected Member Functions

bool rule_allows_packet (firewall_rule_t *rule_ptr, my_packet_t *packet)
 checks if network packet is allowed by the rule More...
 
my_packet_tget_packet_information (struct pbuf *pbuf)
 prepares the necessary information to check packet More...
 
- Protected Member Functions inherited from fw::Storage
uint8_t retrieve_amount_of_rules ()
 retrieve the current amount of Firewall rules in the Storage More...
 
void store_amount_of_rules (const uint8_t new_amount)
 store a new amount of Firewall rules in the Storage More...
 
firewall_rule_tretrieve_firewall_rule (const uint8_t key)
 retrieve a Firewall rule from Storage More...
 
void store_all_firewall_rules (firewall_rule_t *rule_head)
 store all Firewall rules in Storage More...
 
void store_firewall_rule (firewall_rule_t *rule_ptr)
 store Firewall rule in Storage More...
 

Protected Attributes

uint8_t amount_of_rules = 0
 
firewall_rule_trule_head = NULL
 

Detailed Description

The Firewall will handle Firewall rules as linked list.

Member Function Documentation

◆ add_rule_to_firewall() [1/2]

void fw::Firewall::add_rule_to_firewall ( firewall_rule_t rule_ptr,
const bool  save_in_eeprom = true 
)

add a new rule to the linked list, update amount of rules, store it in Storage if save_in_eeprom is true

Parameters
rule_ptr
save_in_eeprom

◆ add_rule_to_firewall() [2/2]

firewall_rule_t * fw::Firewall::add_rule_to_firewall ( String *  args)

add a new rule to the firewall, providing request parameter

Parameters
args
Returns
firewall_rule_t*

◆ delete_rule_from_firewall()

ok_t fw::Firewall::delete_rule_from_firewall ( const uint8_t  key)

delete rule from the firewall linked list, update amount of rules, store new order of rules in Storage

Parameters
key
Returns
ok_t

◆ get_packet_information()

my_packet_t * fw::Firewall::get_packet_information ( struct pbuf *  pbuf)
protected

prepares the necessary information to check packet

Parameters
pbuf
Returns
my_packet_t*

◆ get_rule_from_firewall()

firewall_rule_t * fw::Firewall::get_rule_from_firewall ( const uint8_t  key)

retrieve rule from the firewall linked list

Parameters
key
Returns
firewall_rule_t*

◆ get_rule_head()

firewall_rule_t * fw::Firewall::get_rule_head ( )

Get the current rule head, it indicates the first rule position of the linked list.

Returns
firewall_rule_t*

◆ is_packet_allowed()

bool fw::Firewall::is_packet_allowed ( struct pbuf *  pbuf)

checks if network packet is allowed to pass firewall

Parameters
pbuf
Returns
true
false

◆ rule_allows_packet()

bool fw::Firewall::rule_allows_packet ( firewall_rule_t rule_ptr,
my_packet_t packet 
)
protected

checks if network packet is allowed by the rule

Parameters
rule_ptr
packet
Returns
true
false

◆ update_rule_of_firewall()

firewall_rule_t * fw::Firewall::update_rule_of_firewall ( String *  args,
const uint8_t  key 
)

update rule of firewall, store it in Storage

Parameters
args
key
Returns
firewall_rule_t*

The documentation for this class was generated from the following files: