summaryrefslogtreecommitdiffstats
path: root/src/statement.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2015-09-29 18:21:54 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2015-09-30 17:32:10 +0200
commitb870b949470af0b1b578590b38efdd80048b539e (patch)
tree21fbd7c71aa63e3a95b0d4be80d56664b17b2cb7 /src/statement.c
parentde2ebd0e1d43361ecd879170b40bac76a503aa65 (diff)
src: add dup statement support
This allows you to clone packets to destination address, eg. ... dup to 172.20.0.2 ... dup to 172.20.0.2 device eth1 ... dup to ip saddr map { 192.168.0.2 : 172.20.0.2, ... } device eth1 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/statement.c')
-rw-r--r--src/statement.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/statement.c b/src/statement.c
index d620d1ba..2d1a3e6b 100644
--- a/src/statement.c
+++ b/src/statement.c
@@ -455,3 +455,35 @@ struct stmt *set_stmt_alloc(const struct location *loc)
{
return stmt_alloc(loc, &set_stmt_ops);
}
+
+static void dup_stmt_print(const struct stmt *stmt)
+{
+ printf("dup");
+ if (stmt->dup.to != NULL) {
+ printf(" to ");
+ expr_print(stmt->dup.to);
+
+ if (stmt->dup.dev != NULL) {
+ printf(" device ");
+ expr_print(stmt->dup.dev);
+ }
+ }
+}
+
+static void dup_stmt_destroy(struct stmt *stmt)
+{
+ expr_free(stmt->dup.to);
+ expr_free(stmt->dup.dev);
+}
+
+static const struct stmt_ops dup_stmt_ops = {
+ .type = STMT_DUP,
+ .name = "dup",
+ .print = dup_stmt_print,
+ .destroy = dup_stmt_destroy,
+};
+
+struct stmt *dup_stmt_alloc(const struct location *loc)
+{
+ return stmt_alloc(loc, &dup_stmt_ops);
+}