@@ -75,7 +75,10 @@ enum nftables_exit_codes {
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);
+void nft_ctx_set_dry_run(struct nft_ctx *ctx, bool dry);
+
void nft_ctx_flush_cache(struct nft_ctx *ctx);
int nft_run_cmd_from_buffer(struct nft_ctx *nft, char *buf, size_t buflen);
@@ -171,6 +171,11 @@ FILE *nft_ctx_set_output(struct nft_ctx *ctx, FILE *fp)
return old;
}
+void nft_ctx_set_dry_run(struct nft_ctx *ctx, bool dry)
+{
+ ctx->check = dry;
+}
+
static const struct input_descriptor indesc_cmdline = {
.type = INDESC_BUFFER,
.name = "<cmdline>",
@@ -187,7 +187,7 @@ int main(int argc, char * const *argv)
PACKAGE_NAME, PACKAGE_VERSION, RELEASE_NAME);
exit(NFT_EXIT_SUCCESS);
case OPT_CHECK:
- nft->check = true;
+ nft_ctx_set_dry_run(nft, true);
break;
case OPT_FILE:
filename = optarg;
Provide a convenient interface to configure dry run mode. Signed-off-by: Phil Sutter <phil@nwl.cc> --- include/nftables/nftables.h | 3 +++ src/libnftables.c | 5 +++++ src/main.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-)