ESP32/ESP8266 Firewall 1.0.0
a software firewall for ESP23 or ESP8266
Storage.hpp
1#ifndef STORAGE_HPP
2#define STORAGE_HPP
3
4#ifdef ESP8266
5#include "EEPROM.h"
6#else
7#include "Preferences.h"
8#endif
9#include "Utils.hpp"
10
11namespace fw
12{
17 class Storage
18 {
19 public:
24 Storage();
25
30 ~Storage();
31
32 private:
33#ifdef ESP8266
34 uint8_t max_rules;
35 uint16_t eeprom_size;
36 uint16_t eeprom_amount_of_rules;
37 uint16_t eeprom_rules_head;
38
39 uint16_t eeprom_rule_position(uint8_t key);
40#else
41 Preferences memory;
42#endif
43
44 protected:
51
57 void store_amount_of_rules(const uint8_t new_amount);
58
65 firewall_rule_t *retrieve_firewall_rule(const uint8_t key);
66
73
80 };
81}
82
83#endif
The Storage will handle Firewall rules in EEPROM.
Definition: Storage.hpp:18
~Storage()
Destroy the Storage object.
Definition: Storage.cpp:16
firewall_rule_t * retrieve_firewall_rule(const uint8_t key)
retrieve a Firewall rule from Storage
Definition: Storage.cpp:54
void store_all_firewall_rules(firewall_rule_t *rule_head)
store all Firewall rules in Storage
Definition: Storage.cpp:81
void store_amount_of_rules(const uint8_t new_amount)
store a new amount of Firewall rules in the Storage
Definition: Storage.cpp:42
Storage()
Construct a new Storage object.
Definition: Storage.cpp:5
void store_firewall_rule(firewall_rule_t *rule_ptr)
store Firewall rule in Storage
Definition: Storage.cpp:91
uint8_t retrieve_amount_of_rules()
retrieve the current amount of Firewall rules in the Storage
Definition: Storage.cpp:27
Definition: Utils.hpp:51