This repository has been archived on 2024-10-30. You can view files and clone it, but cannot push or open issues or pull requests.
esp-firewall/SourceCode/arduino/lib/Firewall/Firewall.h

38 lines
888 B
C
Raw Normal View History

2022-04-10 20:46:54 +02:00
#ifndef FIREWALL_H
#define FIREWALL_H
#include "WebServer.h"
#include "cJSON.h"
#include "esp32-hal-log.h"
2022-04-11 11:47:50 +02:00
typedef struct firewall_rule
{
int key;
char source[IP4ADDR_STRLEN_MAX];
char destination[IP4ADDR_STRLEN_MAX];
char protocol[4];
char target[7];
struct firewall_rule *next;
} firewall_rule_t;
2022-04-10 20:46:54 +02:00
class ESPFirewall
{
2022-04-11 11:47:50 +02:00
WebServer *firewall_api;
int amount_of_rules;
struct firewall_rule *head;
2022-04-10 20:46:54 +02:00
void setup_routing();
void custom_message_response(const char *message, int response_code);
2022-04-11 11:47:50 +02:00
void prepare_firewall_json(cJSON *jsonResponse, firewall_rule_t *link);
2022-04-11 13:49:48 +02:00
firewall_rule_t *add_rule_to_firewall(const char *source, const char *destination, const char *protocol, const char *target);
void post_firewall_handler();
void get_firewall_handler();
2022-04-10 20:46:54 +02:00
public:
2022-04-11 11:47:50 +02:00
ESPFirewall(int port = 8080);
2022-04-10 20:46:54 +02:00
void handle_clients();
};
#endif