summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am3
-rw-r--r--include/nftables.h27
-rw-r--r--include/nftables/Makefile.am1
-rw-r--r--include/nftables/nftables.h58
4 files changed, 62 insertions, 27 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 5dd73d81..a74ffbfa 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,4 +1,5 @@
-SUBDIRS = linux
+SUBDIRS = linux \
+ nftables
noinst_HEADERS = cli.h \
datatype.h \
diff --git a/include/nftables.h b/include/nftables.h
index 01d72a87..eb39dbd1 100644
--- a/include/nftables.h
+++ b/include/nftables.h
@@ -4,23 +4,7 @@
#include <stdbool.h>
#include <stdarg.h>
#include <utils.h>
-
-enum numeric_level {
- NUMERIC_NONE,
- NUMERIC_ADDR,
- NUMERIC_PORT,
- NUMERIC_ALL,
-};
-
-enum debug_level {
- DEBUG_SCANNER = 0x1,
- DEBUG_PARSER = 0x2,
- DEBUG_EVALUATION = 0x4,
- DEBUG_NETLINK = 0x8,
- DEBUG_MNL = 0x10,
- DEBUG_PROTO_CTX = 0x20,
- DEBUG_SEGTREE = 0x40,
-};
+#include <nftables/nftables.h>
#define INCLUDE_PATHS_MAX 16
@@ -53,15 +37,6 @@ struct nft_ctx {
uint32_t flags;
};
-#define NFT_CTX_DEFAULT 0
-
-enum nftables_exit_codes {
- NFT_EXIT_SUCCESS = 0,
- NFT_EXIT_FAILURE = 1,
- NFT_EXIT_NOMEM = 2,
- NFT_EXIT_NONL = 3,
-};
-
struct input_descriptor;
struct location {
const struct input_descriptor *indesc;
diff --git a/include/nftables/Makefile.am b/include/nftables/Makefile.am
new file mode 100644
index 00000000..9e31d519
--- /dev/null
+++ b/include/nftables/Makefile.am
@@ -0,0 +1 @@
+noinst_HEADERS = nftables.h
diff --git a/include/nftables/nftables.h b/include/nftables/nftables.h
new file mode 100644
index 00000000..44d3e95d
--- /dev/null
+++ b/include/nftables/nftables.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017 Eric Leblond <eric@regit.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+#ifndef LIB_NFTABLES_H
+#define LIB_NFTABLES_H
+
+#define _GNU_SOURCE
+#include <stdint.h>
+#include <stdio.h>
+#include <stdbool.h>
+
+struct nft_ctx;
+
+enum debug_level {
+ DEBUG_SCANNER = 0x1,
+ DEBUG_PARSER = 0x2,
+ DEBUG_EVALUATION = 0x4,
+ DEBUG_NETLINK = 0x8,
+ DEBUG_MNL = 0x10,
+ DEBUG_PROTO_CTX = 0x20,
+ DEBUG_SEGTREE = 0x40,
+};
+
+enum numeric_level {
+ NUMERIC_NONE,
+ NUMERIC_ADDR,
+ NUMERIC_PORT,
+ NUMERIC_ALL,
+};
+
+/**
+ * Possible flags to pass to nft_ctx_new()
+ */
+#define NFT_CTX_DEFAULT 0
+
+/**
+ * Exit codes returned by nft_run_cmd_from_*()
+ */
+enum nftables_exit_codes {
+ NFT_EXIT_SUCCESS = 0,
+ NFT_EXIT_FAILURE = 1,
+ NFT_EXIT_NOMEM = 2,
+ NFT_EXIT_NONL = 3,
+};
+
+struct nft_ctx *nft_ctx_new(uint32_t flags);
+void nft_ctx_free(struct nft_ctx *ctx);
+FILE *nft_ctx_set_output(struct nft_ctx *ctx, FILE *fp);
+
+int nft_run_cmd_from_buffer(struct nft_ctx *nft, char *buf, size_t buflen);
+int nft_run_cmd_from_filename(struct nft_ctx *nft, const char *filename);
+
+#endif /* LIB_NFTABLES_H */