summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/evaluate.c22
-rw-r--r--src/parser_bison.y10
-rw-r--r--src/rule.c4
-rw-r--r--src/scanner.l2
4 files changed, 11 insertions, 27 deletions
diff --git a/src/evaluate.c b/src/evaluate.c
index 4be52992..b42b5a6f 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -6452,13 +6452,6 @@ static int cmd_evaluate_rename(struct eval_ctx *ctx, struct cmd *cmd)
return 0;
}
-enum {
- CMD_MONITOR_EVENT_ANY,
- CMD_MONITOR_EVENT_NEW,
- CMD_MONITOR_EVENT_DEL,
- CMD_MONITOR_EVENT_MAX
-};
-
static uint32_t monitor_flags[CMD_MONITOR_EVENT_MAX][CMD_MONITOR_OBJ_MAX] = {
[CMD_MONITOR_EVENT_ANY] = {
[CMD_MONITOR_OBJ_ANY] = 0xffffffff,
@@ -6528,20 +6521,9 @@ static uint32_t monitor_flags[CMD_MONITOR_EVENT_MAX][CMD_MONITOR_OBJ_MAX] = {
static int cmd_evaluate_monitor(struct eval_ctx *ctx, struct cmd *cmd)
{
- uint32_t event;
-
- if (cmd->monitor->event == NULL)
- event = CMD_MONITOR_EVENT_ANY;
- else if (strcmp(cmd->monitor->event, "new") == 0)
- event = CMD_MONITOR_EVENT_NEW;
- else if (strcmp(cmd->monitor->event, "destroy") == 0)
- event = CMD_MONITOR_EVENT_DEL;
- else {
- return monitor_error(ctx, cmd->monitor, "invalid event %s",
- cmd->monitor->event);
- }
+ uint32_t *monitor_event_flags = monitor_flags[cmd->monitor->event];
- cmd->monitor->flags = monitor_flags[event][cmd->monitor->type];
+ cmd->monitor->flags = monitor_event_flags[cmd->monitor->type];
return 0;
}
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 3ceef794..96d0e151 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -353,6 +353,7 @@ int nft_lex(void *, void *, void *);
%token DESCRIBE "describe"
%token IMPORT "import"
%token EXPORT "export"
+%token NEW "new"
%token DESTROY "destroy"
%token MONITOR "monitor"
@@ -985,9 +986,7 @@ int nft_lex(void *, void *, void *);
%destructor { expr_free($$); } osf_expr
%type <val> markup_format
-%type <string> monitor_event
-%destructor { free_const($$); } monitor_event
-%type <val> monitor_object monitor_format
+%type <val> monitor_event monitor_object monitor_format
%type <val> synproxy_ts synproxy_sack
@@ -1892,8 +1891,9 @@ monitor_cmd : monitor_event monitor_object monitor_format
}
;
-monitor_event : /* empty */ { $$ = NULL; }
- | STRING { $$ = $1; }
+monitor_event : /* empty */ { $$ = CMD_MONITOR_EVENT_ANY; }
+ | NEW { $$ = CMD_MONITOR_EVENT_NEW; }
+ | DESTROY { $$ = CMD_MONITOR_EVENT_DEL; }
;
monitor_object : /* empty */ { $$ = CMD_MONITOR_OBJ_ANY; }
diff --git a/src/rule.c b/src/rule.c
index 8f8b77f1..dabc1620 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -1389,7 +1389,8 @@ void markup_free(struct markup *m)
free(m);
}
-struct monitor *monitor_alloc(uint32_t format, uint32_t type, const char *event)
+struct monitor *monitor_alloc(uint32_t format, uint32_t type,
+ enum cmd_monitor_event event)
{
struct monitor *mon;
@@ -1404,7 +1405,6 @@ struct monitor *monitor_alloc(uint32_t format, uint32_t type, const char *event)
void monitor_free(struct monitor *m)
{
- free_const(m->event);
free(m);
}
diff --git a/src/scanner.l b/src/scanner.l
index df8e536b..99ace057 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -322,6 +322,8 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
<SCANSTATE_CMD_MONITOR>{
"rules" { return RULES; }
"trace" { return TRACE; }
+ "new" { return NEW; }
+ "destroy" { return DESTROY; }
}
"hook" { return HOOK; }
"device" { return DEVICE; }