1/* 2 * Copyright (c) 2017 Balabit 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 as published 6 * by the Free Software Foundation, or (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 * 17 * As an additional exemption you are allowed to compile & link against the 18 * OpenSSL libraries as published by the OpenSSL project. See the file 19 * COPYING for details. 20 * 21 */ 22 23%code top { 24#include "geoip-parser-parser.h" 25} 26 27%code { 28 29#include "geoip-parser.h" 30#include "cfg-parser.h" 31#include "cfg-grammar-internal.h" 32#include "syslog-names.h" 33#include "messages.h" 34 35} 36 37%define api.prefix {geoip2_parser_} 38 39/* this parameter is needed in order to instruct bison to use a complete 40 * argument list for yylex/yyerror */ 41 42%lex-param {CfgLexer *lexer} 43%parse-param {CfgLexer *lexer} 44%parse-param {LogParser **instance} 45%parse-param {gpointer arg} 46 47/* INCLUDE_DECLS */ 48 49%token KW_GEOIP2 50%token KW_DATABASE 51%token KW_PREFIX 52 53%type <ptr> parser_expr_maxminddb 54 55%% 56 57start 58 : LL_CONTEXT_PARSER parser_expr_maxminddb { YYACCEPT; } 59 ; 60 61parser_expr_maxminddb 62 : KW_GEOIP2 '(' 63 { 64 last_parser = *instance = (LogParser *) maxminddb_parser_new(configuration); 65 } 66 optional_direct_template 67 parser_geoip_opts 68 ')' { $$ = last_parser; } 69 ; 70 71optional_direct_template 72 : string 73 { 74 LogTemplate *template; 75 GError *error = NULL; 76 77 template = cfg_tree_check_inline_template(&configuration->tree, $1, &error); 78 CHECK_ERROR_GERROR(template != NULL, @1, error, "Error compiling template"); 79 log_parser_set_template(last_parser, template); 80 free($1); 81 } 82 | 83 ; 84 85parser_geoip_opts 86 : parser_geoip_opt parser_geoip_opts 87 | 88 ; 89 90parser_geoip_opt 91 : KW_PREFIX '(' string ')' { geoip_parser_set_prefix(last_parser, $3); free($3); } 92 | KW_DATABASE '(' path_check ')' { geoip_parser_set_database_path(last_parser, $3); free($3); } 93 | parser_opt 94 ; 95 96/* INCLUDE_RULES */ 97 98%% 99