Files
utun2/src/firewall.h
T
evgeny a97e8bcc1f docs: update file inventory and module header contracts
Refresh both AGENTS guides and clarify module purpose, usage, ownership, threading, return values and wire formats in headers. Remove the unused timeout_heap freed_count field and unimplemented getter.
2026-10-04 13:10:01 +02:00

31 lines
1.0 KiB
C

/* firewall — список разрешённых пар IPv4/порт из global_config, без изменения системного firewall.
* init/обнуление → load_rules (копия и сортировка правил) → check → free; контекст использует один поток.
* check: 1 разрешено, 0 запрещено; port=0 в правиле разрешает все порты IP, bypass_all разрешает всё.
* IP и порт передавать в host order, как в CFG_FIREWALL_RULE. */
#ifndef FIREWALL_H
#define FIREWALL_H
#include <stdint.h>
#include "config_parser.h"
#ifdef __cplusplus
extern "C" {
#endif
struct firewall_ctx {
struct CFG_FIREWALL_RULE *rules;
int count;
int bypass_all;
};
int fw_init(struct firewall_ctx *ctx);
int fw_load_rules(struct firewall_ctx *ctx, const struct global_config *cfg);
int fw_check(const struct firewall_ctx *ctx, uint32_t ip, uint16_t port);
void fw_free(struct firewall_ctx *ctx);
#ifdef __cplusplus
}
#endif
#endif