communicating with eeprom
This commit is contained in:
parent
ae73e2081d
commit
d269eff8ee
2 changed files with 25 additions and 0 deletions
|
@ -53,6 +53,25 @@ firewall_target_t ESPFirewall::string_to_target(String &target)
|
||||||
return FW_ACCEPT;
|
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)
|
void ESPFirewall::add_rule_to_firewall(firewall_rule_t *rule)
|
||||||
{
|
{
|
||||||
firewall_rule_t *temp;
|
firewall_rule_t *temp;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "AsyncJson.h"
|
#include "AsyncJson.h"
|
||||||
#include "ArduinoJson.h"
|
#include "ArduinoJson.h"
|
||||||
|
#include "EEPROM.h"
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#include "WiFi.h"
|
#include "WiFi.h"
|
||||||
#include "AsyncTCP.h"
|
#include "AsyncTCP.h"
|
||||||
|
@ -40,6 +41,7 @@ typedef struct firewall_rule
|
||||||
class ESPFirewall
|
class ESPFirewall
|
||||||
{
|
{
|
||||||
uint8_t amount_of_rules = 0;
|
uint8_t amount_of_rules = 0;
|
||||||
|
int eeprom_address = 0;
|
||||||
struct firewall_rule *head = NULL;
|
struct firewall_rule *head = NULL;
|
||||||
|
|
||||||
AsyncWebServer *firewall_api;
|
AsyncWebServer *firewall_api;
|
||||||
|
@ -50,6 +52,10 @@ class ESPFirewall
|
||||||
String target_to_string(firewall_target_t &);
|
String target_to_string(firewall_target_t &);
|
||||||
firewall_target_t string_to_target(String &);
|
firewall_target_t string_to_target(String &);
|
||||||
|
|
||||||
|
// EEPROM
|
||||||
|
void write_rule_to_eeprom(firewall_rule_t *rule);
|
||||||
|
void get_rules_from_eeprom();
|
||||||
|
|
||||||
// Firewall Actions
|
// Firewall Actions
|
||||||
void add_rule_to_firewall(firewall_rule_t *);
|
void add_rule_to_firewall(firewall_rule_t *);
|
||||||
firewall_rule_t *get_rule_from_firewall(int);
|
firewall_rule_t *get_rule_from_firewall(int);
|
||||||
|
|
Reference in a new issue