From a7469ab47400bf4add8269a2908965e82ceefc48 Mon Sep 17 00:00:00 2001 From: Arturo Borrero Date: Mon, 3 Nov 2014 21:20:11 +0100 Subject: src: add redirect support This patch adds redirect support for nft. The syntax is: % nft add rule nat prerouting redirect [port] [nat_flags] Signed-off-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- src/statement.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/statement.c') diff --git a/src/statement.c b/src/statement.c index 0ae616a8..2587d275 100644 --- a/src/statement.c +++ b/src/statement.c @@ -348,3 +348,32 @@ struct stmt *masq_stmt_alloc(const struct location *loc) { return stmt_alloc(loc, &masq_stmt_ops); } + +static void redir_stmt_print(const struct stmt *stmt) +{ + printf("redirect"); + + if (stmt->redir.proto) { + printf(" :"); + expr_print(stmt->redir.proto); + } + + print_nf_nat_flags(stmt->redir.flags); +} + +static void redir_stmt_destroy(struct stmt *stmt) +{ + expr_free(stmt->redir.proto); +} + +static const struct stmt_ops redir_stmt_ops = { + .type = STMT_REDIR, + .name = "redir", + .print = redir_stmt_print, + .destroy = redir_stmt_destroy, +}; + +struct stmt *redir_stmt_alloc(const struct location *loc) +{ + return stmt_alloc(loc, &redir_stmt_ops); +} -- cgit v1.2.3