summaryrefslogtreecommitdiffstats
path: root/src/osf.c
diff options
context:
space:
mode:
authorFernando Fernandez Mancera <ffmancera@riseup.net>2018-08-03 23:47:11 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2018-08-04 00:21:19 +0200
commit9f28b685b473b2424524d0443ef1e0ed8ba276de (patch)
tree14834b9e589da013b8b058b49beaf8a2b8ceae72 /src/osf.c
parentcdb5655ee44da4113d1ee72fbd6afa6ca4ffaa14 (diff)
src: introduce passive OS fingerprint matching
Add support for "osf" expression. Example: table ip foo { chain bar { type filter hook input priority 0; policy accept; osf name "Linux" counter packets 3 bytes 132 } } Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/osf.c')
-rw-r--r--src/osf.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/osf.c b/src/osf.c
new file mode 100644
index 00000000..f07a725c
--- /dev/null
+++ b/src/osf.c
@@ -0,0 +1,35 @@
+#include <nftables.h>
+#include <expression.h>
+#include <utils.h>
+#include <string.h>
+#include <osf.h>
+
+#include <net/if.h>
+
+static void osf_expr_print(const struct expr *expr, struct output_ctx *octx)
+{
+ nft_print(octx, "osf name");
+}
+
+static void osf_expr_clone(struct expr *new, const struct expr *expr)
+{
+}
+
+static const struct expr_ops osf_expr_ops = {
+ .type = EXPR_OSF,
+ .name = "osf",
+ .print = osf_expr_print,
+ .clone = osf_expr_clone,
+};
+
+struct expr *osf_expr_alloc(const struct location *loc)
+{
+ unsigned int len = IFNAMSIZ * BITS_PER_BYTE;
+ const struct datatype *type = &string_type;
+ struct expr *expr;
+
+ expr = expr_alloc(loc, &osf_expr_ops, type,
+ BYTEORDER_HOST_ENDIAN, len);
+
+ return expr;
+}