ESP32/ESP8266 Firewall 1.0.0
a software firewall for ESP23 or ESP8266
Firewall.hpp
1#ifndef FIREWALL_HPP
2#define FIREWALL_HPP
3
4#include "Utils.hpp"
5#include "Storage.hpp"
6#include "WiFiClient.h"
7#include "lwip/netif.h"
8#include "lwip/pbuf.h"
9#include "lwip/ip4.h"
10#include "lwip/prot/udp.h"
11#include "lwip/prot/tcp.h"
12
13namespace fw
14{
19 class Firewall : public Storage
20 {
21 public:
27 Firewall();
28
33 ~Firewall();
34
42
51 void add_rule_to_firewall(firewall_rule_t *rule_ptr, const bool save_in_eeprom = true);
52
61
70 firewall_rule_t *update_rule_of_firewall(String *args, const uint8_t key);
71
78 firewall_rule_t *get_rule_from_firewall(const uint8_t key);
79
88 ok_t delete_rule_from_firewall(const uint8_t key);
89
97 bool is_packet_allowed(struct pbuf *pbuf);
98
99 protected:
108 bool rule_allows_packet(firewall_rule_t *rule_ptr, my_packet_t *packet);
109
116 my_packet_t *get_packet_information(struct pbuf *pbuf);
117
118 uint8_t amount_of_rules = 0;
119 firewall_rule_t *rule_head = NULL;
120 };
121}
122
123#endif
The Firewall will handle Firewall rules as linked list.
Definition: Firewall.hpp:20
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 Storag...
Definition: Firewall.cpp:88
bool rule_allows_packet(firewall_rule_t *rule_ptr, my_packet_t *packet)
checks if network packet is allowed by the rule
Definition: Firewall.cpp:151
~Firewall()
Destroy the Firewall object.
Definition: Firewall.cpp:15
Firewall()
Construct a new Firewall object, retrieve current amount of firewall rules and restore them from Stor...
Definition: Firewall.cpp:5
my_packet_t * get_packet_information(struct pbuf *pbuf)
prepares the necessary information to check packet
Definition: Firewall.cpp:128
firewall_rule_t * get_rule_from_firewall(const uint8_t key)
retrieve rule from the firewall linked list
Definition: Firewall.cpp:73
bool is_packet_allowed(struct pbuf *pbuf)
checks if network packet is allowed to pass firewall
Definition: Firewall.cpp:166
firewall_rule_t * get_rule_head()
Get the current rule head, it indicates the first rule position of the linked list.
Definition: Firewall.cpp:19
firewall_rule_t * update_rule_of_firewall(String *args, const uint8_t key)
update rule of firewall, store it in Storage
Definition: Firewall.cpp:58
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 t...
Definition: Firewall.cpp:24
The Storage will handle Firewall rules in EEPROM.
Definition: Storage.hpp:18
Definition: Utils.hpp:51
Definition: Utils.hpp:64