summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorEric Leblond <eric@regit.org>2013-05-30 04:22:46 +0000
committerPablo Neira Ayuso <pablo@netfilter.org>2013-05-31 13:10:55 +0200
commit1d00bb3964184531f4533870c66de33de2d689e1 (patch)
tree8a817860dddfe198be379c27b47712cc470f17da /src/main.c
parent99fc209e6a465ccb6ea96ef81116e8d931e2261c (diff)
rule: add flag to display rule handle as comment
Knowing the rule handle is necessary to be able to delete a single rule. It was not displayed till now in the output and it was thus impossible to remove a single rule. This patch modify the listing output to add a comment containing the handle when the -a/--handle flag is provided. Signed-off-by: Eric Leblond <eric@regit.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 283ec289..48d4e038 100644
--- a/src/main.c
+++ b/src/main.c
@@ -26,6 +26,7 @@
#include <erec.h>
unsigned int numeric_output;
+unsigned int handle_output;
#ifdef DEBUG
unsigned int debug_level;
#endif
@@ -41,10 +42,11 @@ enum opt_vals {
OPT_INCLUDEPATH = 'I',
OPT_NUMERIC = 'n',
OPT_DEBUG = 'd',
+ OPT_HANDLE_OUTPUT = 'a',
OPT_INVALID = '?',
};
-#define OPTSTRING "hvf:iI:vn"
+#define OPTSTRING "hvf:iI:vna"
static const struct option options[] = {
{
@@ -81,6 +83,10 @@ static const struct option options[] = {
},
#endif
{
+ .name = "handle",
+ .val = OPT_HANDLE_OUTPUT,
+ },
+ {
.name = NULL
}
};
@@ -100,6 +106,7 @@ static void show_help(const char *name)
" -n/--numeric When specified once, show network addresses numerically.\n"
" When specified twice, also show Internet protocols,\n"
" Internet services, user IDs and group IDs numerically.\n"
+" -a/--handle Output rule handle.\n"
" -I/--includepath <directory> Add <directory> to the paths searched for include files.\n"
#ifdef DEBUG
" --debug <level [,level...]> Specify debugging level (scanner, parser, eval, netlink, all)\n"
@@ -244,6 +251,9 @@ int main(int argc, char * const *argv)
}
break;
#endif
+ case OPT_HANDLE_OUTPUT:
+ handle_output++;
+ break;
case OPT_INVALID:
exit(NFT_EXIT_FAILURE);
}