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/ESPFirewall/lib/Firewall/src/Utils.hpp

63 lines
1.4 KiB
C++
Raw Normal View History

2022-04-21 15:16:54 +02:00
#ifndef UTILS_HPP
#define UTILS_HPP
2022-04-23 23:36:44 +02:00
#include "Arduino.h"
2022-04-21 15:16:54 +02:00
#include "WString.h"
namespace firewall
{
2022-04-22 22:40:01 +02:00
static const uint8_t IPV4ADDRESS_LENGTH = 16;
static const uint8_t CREDENTIALS_LENGTH = 32;
typedef enum firewall_targets : uint8_t
{
TARGET_REJECT = 0,
TARGET_DROP = 1,
TARGET_ACCEPT = 2,
} firewall_target_t;
typedef enum firewall_protocols : uint8_t
{
PROTOCOL_TCP = 0,
PROTOCOL_UDP = 1,
PROTOCOL_ALL = 255,
} firewall_protocol_t;
typedef enum ok : uint8_t
{
SUCCESS = 0,
ERROR = 1,
NO_ACTION = 2,
} ok_t;
typedef enum auth : uint8_t
{
AUTHENTICATED = 0,
DENIED = 1,
} auth_t;
typedef struct firewall_rules
{
uint8_t key;
char source[IPV4ADDRESS_LENGTH];
char destination[IPV4ADDRESS_LENGTH];
firewall_protocol_t protocol;
firewall_target_t target;
struct firewall_rules *next;
} firewall_rule_t;
typedef struct credentials
{
char password[CREDENTIALS_LENGTH];
char username[CREDENTIALS_LENGTH];
} credential_t;
2022-04-21 15:16:54 +02:00
String protocol_to_string(firewall_protocol_t &protocol);
2022-04-23 23:50:46 +02:00
firewall_protocol_t string_to_protocol(String &protocol);
2022-04-21 15:16:54 +02:00
String target_to_string(firewall_target_t &target);
2022-04-23 23:50:46 +02:00
firewall_target_t string_to_target(String &target);
2022-04-21 15:16:54 +02:00
void endless_loop();
}
#endif