1 /*
2  * Copyright (c) 2002-2012 Balabit
3  * Copyright (c) 1998-2012 Balázs Scheidler
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  *
19  * As an additional exemption you are allowed to compile & link against the
20  * OpenSSL libraries as published by the OpenSSL project. See the file
21  * COPYING for details.
22  *
23  */
24 
25 #include "filter/filter-expr-parser.h"
26 #include "filter/filter-expr-grammar.h"
27 #include "filter/filter-expr.h"
28 
29 extern int filter_expr_debug;
30 int filter_expr_parse(CfgLexer *lexer, FilterExprNode **node, gpointer arg);
31 
32 static CfgLexerKeyword filter_expr_keywords[] =
33 {
34   { "or",                 KW_OR },
35   { "and",                KW_AND },
36   { "not",                KW_NOT },
37   { "lt",                 KW_LT },
38   { "le",                 KW_LE },
39   { "eq",                 KW_EQ },
40   { "ne",                 KW_NE },
41   { "ge",                 KW_GE },
42   { "gt",                 KW_GT },
43 
44   { "<",                  KW_NUM_LT },
45   { "<=",                 KW_NUM_LE },
46   { "==",                 KW_NUM_EQ },
47   { "!=",                 KW_NUM_NE },
48   { ">=",                 KW_NUM_GE },
49   { ">",                  KW_NUM_GT },
50   { "severity",           KW_SEVERITY },
51   { "level",              KW_SEVERITY },
52   { "priority",           KW_SEVERITY },
53   { "facility",           KW_FACILITY },
54   { "program",            KW_PROGRAM },
55   { "host",               KW_HOST },
56   { "message",            KW_MESSAGE },
57   { "match",              KW_MATCH },
58   { "netmask",            KW_NETMASK },
59   { "throttle",           KW_THROTTLE },
60   { "rate",               KW_RATE },
61   { "tags",               KW_TAGS },
62   { "in_list",            KW_IN_LIST },
63 #if SYSLOG_NG_ENABLE_IPV6
64   { "netmask6",           KW_NETMASK6 },
65 #endif
66 
67   { "value",              KW_VALUE },
68   { "flags",              KW_FLAGS },
69 
70   { NULL }
71 };
72 
73 CfgParser filter_expr_parser =
74 {
75 #if SYSLOG_NG_ENABLE_DEBUG
76   .debug_flag = &filter_expr_debug,
77 #endif
78   .name = "filter expression",
79   .context = LL_CONTEXT_FILTER,
80   .keywords = filter_expr_keywords,
81   .parse = (gint (*)(CfgLexer *, gpointer *, gpointer)) filter_expr_parse,
82 };
83 
84 CFG_PARSER_IMPLEMENT_LEXER_BINDING(filter_expr_, FILTER_EXPR_, FilterExprNode **)
85