summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2017-08-22 18:45:52 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2017-08-23 23:42:33 +0200
commitbe441e1ffdc2495162399b61053a8f8c18ebc5b6 (patch)
tree6c49381c37635690f69c8d21f52c24648b53210f /src/main.c
parente1946ec7f11e2c6daa11b141eb344ef44642056f (diff)
src: add debugging mask to context structure
So this toggle is not global anymore. Update name that fits better with the semantics of this variable. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index 4c74bdce..3519377b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -29,7 +29,6 @@
#include <cli.h>
static struct nft_ctx nft;
-unsigned int debug_level;
enum opt_vals {
OPT_HELP = 'h',
@@ -200,6 +199,7 @@ static int nft_netlink(struct nft_ctx *nft,
ctx.octx = &nft->output;
ctx.nf_sock = nf_sock;
ctx.cache = &nft->cache;
+ ctx.debug_mask = nft->debug_mask;
init_list_head(&ctx.list);
ret = do_command(&ctx, cmd);
if (ret < 0)
@@ -363,7 +363,7 @@ int main(int argc, char * const *argv)
for (i = 0; i < array_size(debug_param); i++) {
if (strcmp(debug_param[i].name, optarg))
continue;
- debug_level |= debug_param[i].level;
+ nft.debug_mask |= debug_param[i].level;
break;
}
@@ -400,15 +400,16 @@ int main(int argc, char * const *argv)
strcat(buf, " ");
}
strcat(buf, "\n");
- parser_init(nf_sock, &nft.cache, &state, &msgs);
+ parser_init(nf_sock, &nft.cache, &state, &msgs, nft.debug_mask);
scanner = scanner_init(&state);
scanner_push_buffer(scanner, &indesc_cmdline, buf);
} else if (filename != NULL) {
- rc = cache_update(nf_sock, &nft.cache, CMD_INVALID, &msgs);
+ rc = cache_update(nf_sock, &nft.cache, CMD_INVALID, &msgs,
+ nft.debug_mask);
if (rc < 0)
return rc;
- parser_init(nf_sock, &nft.cache, &state, &msgs);
+ parser_init(nf_sock, &nft.cache, &state, &msgs, nft.debug_mask);
scanner = scanner_init(&state);
if (scanner_read_file(scanner, filename, &internal_location) < 0)
goto out;
@@ -428,7 +429,7 @@ int main(int argc, char * const *argv)
rc = NFT_EXIT_FAILURE;
out:
scanner_destroy(scanner);
- erec_print_list(stderr, &msgs);
+ erec_print_list(stderr, &msgs, nft.debug_mask);
xfree(buf);
cache_release(&nft.cache);
iface_cache_release();