diff options
Diffstat (limited to 'fwd.h')
| -rw-r--r-- | fwd.h | 38 |
1 files changed, 22 insertions, 16 deletions
@@ -68,8 +68,6 @@ struct fwd_listen_ref { unsigned rule :FWD_RULE_BITS; }; -#define PORT_BITMAP_SIZE DIV_ROUND_UP(NUM_PORTS, 8) - /* Maximum number of listening sockets (per pif & protocol) * * Rationale: This lets us listen on every port for two addresses (which we need @@ -78,41 +76,49 @@ struct fwd_listen_ref { #define MAX_LISTEN_SOCKS (NUM_PORTS * 3) /** - * fwd_ports() - Describes port forwarding for one protocol and direction - * @scan4: /proc/net fd to scan for IPv4 ports when in AUTO mode - * @scan6: /proc/net fd to scan for IPv6 ports when in AUTO mode + * struct fwd_table - Table of forwarding rules (per protocol and ini pif) * @count: Number of forwarding rules * @rules: Array of forwarding rules - * @map: Bitmap describing which ports are forwarded * @sock_count: Number of entries used in @socks * @socks: Listening sockets for forwarding */ -struct fwd_ports { - int scan4; - int scan6; +struct fwd_table { unsigned count; struct fwd_rule rules[MAX_FWD_RULES]; - uint8_t map[PORT_BITMAP_SIZE]; unsigned sock_count; int socks[MAX_LISTEN_SOCKS]; }; +#define PORT_BITMAP_SIZE DIV_ROUND_UP(NUM_PORTS, 8) + +/** + * struct fwd_scan - Port scanning state for a protocol+direction + * @scan4: /proc/net fd to scan for IPv4 ports when in AUTO mode + * @scan6: /proc/net fd to scan for IPv6 ports when in AUTO mode + * @map: Bitmap describing which ports are forwarded + */ +struct fwd_scan { + int scan4; + int scan6; + uint8_t map[PORT_BITMAP_SIZE]; +}; + #define FWD_PORT_SCAN_INTERVAL 1000 /* ms */ -void fwd_rule_add(struct fwd_ports *fwd, uint8_t flags, +void fwd_rule_add(struct fwd_table *fwd, uint8_t flags, const union inany_addr *addr, const char *ifname, in_port_t first, in_port_t last, in_port_t to); -const struct fwd_rule *fwd_rule_search(const struct fwd_ports *fwd, +const struct fwd_rule *fwd_rule_search(const struct fwd_table *fwd, const struct flowside *ini, int hint); -void fwd_rules_print(const struct fwd_ports *fwd); +void fwd_rules_print(const struct fwd_table *fwd); void fwd_scan_ports_init(struct ctx *c); void fwd_scan_ports_timer(struct ctx * c, const struct timespec *now); -int fwd_listen_sync(const struct ctx *c, const struct fwd_ports *fwd, - uint8_t pif, uint8_t proto); -void fwd_listen_close(const struct fwd_ports *fwd); +int fwd_listen_sync(const struct ctx *c, const struct fwd_table *fwd, + const struct fwd_scan *scan, uint8_t pif, uint8_t proto); +void fwd_listen_close(const struct fwd_table *fwd); bool nat_inbound(const struct ctx *c, const union inany_addr *addr, union inany_addr *translated); |
