diff --git a/SourceCode/arduino/lib/Firewall/Firewall.cpp b/SourceCode/arduino/lib/Firewall/Firewall.cpp index fa07e7d..a6fc841 100644 --- a/SourceCode/arduino/lib/Firewall/Firewall.cpp +++ b/SourceCode/arduino/lib/Firewall/Firewall.cpp @@ -53,6 +53,25 @@ firewall_target_t ESPFirewall::string_to_target(String &target) return FW_ACCEPT; } +void ESPFirewall::write_rule_to_eeprom(firewall_rule_t *rule) +{ + EEPROM.put(this->eeprom_address, rule->source); + this->eeprom_address + IP4ADDR_STRLEN_MAX; + EEPROM.put(this->eeprom_address, rule->destination); + this->eeprom_address + IP4ADDR_STRLEN_MAX; + EEPROM.put(this->eeprom_address, rule->protocol); + this->eeprom_address + sizeof(rule->protocol); + EEPROM.put(this->eeprom_address, rule->target); + this->eeprom_address + sizeof(rule->target); +} + +void ESPFirewall::get_rules_from_eeprom() +{ + int temp_eeprom_address = 0; + char source[IP4ADDR_STRLEN_MAX]; + EEPROM.get(temp_eeprom_address, source); +} + void ESPFirewall::add_rule_to_firewall(firewall_rule_t *rule) { firewall_rule_t *temp; diff --git a/SourceCode/arduino/lib/Firewall/Firewall.h b/SourceCode/arduino/lib/Firewall/Firewall.h index 96ec643..41ee6e6 100644 --- a/SourceCode/arduino/lib/Firewall/Firewall.h +++ b/SourceCode/arduino/lib/Firewall/Firewall.h @@ -4,6 +4,7 @@ #include "Arduino.h" #include "AsyncJson.h" #include "ArduinoJson.h" +#include "EEPROM.h" #ifdef ESP32 #include "WiFi.h" #include "AsyncTCP.h" @@ -40,6 +41,7 @@ typedef struct firewall_rule class ESPFirewall { uint8_t amount_of_rules = 0; + int eeprom_address = 0; struct firewall_rule *head = NULL; AsyncWebServer *firewall_api; @@ -50,6 +52,10 @@ class ESPFirewall String target_to_string(firewall_target_t &); firewall_target_t string_to_target(String &); + // EEPROM + void write_rule_to_eeprom(firewall_rule_t *rule); + void get_rules_from_eeprom(); + // Firewall Actions void add_rule_to_firewall(firewall_rule_t *); firewall_rule_t *get_rule_from_firewall(int);