42
42
LogRewrite *last_rewrite;
45
is_sdata_valid(const gchar *buffer)
47
gboolean result = FALSE;
50
if (strlen(buffer)>6 && strncmp(buffer,".SDATA.",7)==0)
52
dot = memchr(buffer,'.',strlen(buffer));
53
while (dot && strlen(dot)>1)
57
dot = memchr(dot, '.',strlen(dot));
46
67
%name-prefix "rewrite_expr_"
47
68
%lex-param {CfgLexer *lexer}
48
69
%parse-param {CfgLexer *lexer}
49
70
%parse-param {GList **result}
71
%parse-param {gpointer arg}
51
73
%type <ptr> rewrite_expr
52
74
%type <ptr> rewrite_expr_list
89
111
gchar __buf[256]; \
90
112
g_snprintf(__buf, sizeof(__buf), errorfmt ? errorfmt : "x", ## __VA_ARGS__); \
91
yyerror(& (token), lexer, NULL, __buf); \
113
yyerror(& (token), lexer, NULL, NULL, __buf); \
334
368
p = plugin_find(configuration, context, $1);
335
369
CHECK_ERROR(p, @1, "%s plugin %s not found", cfg_lexer_lookup_context_name_by_type(context), $1);
337
last_rewrite = (LogRewrite *) plugin_parse_config(p, configuration, &@1);
371
last_rewrite = (LogRewrite *) plugin_parse_config(p, configuration, &@1, NULL);
339
373
if (!last_rewrite)
385
419
last_rewrite->value_handle = LM_V_MESSAGE;
422
/* SDATA validation */
423
if (strlen($3)>6 && strncmp($3,".SDATA.",7)==0)
425
if (!is_sdata_valid($3))
427
msg_error("Invalid structured data format",evt_tag_str("SDATA",$3), NULL);
389
433
| KW_CONDITION '('
391
435
FilterExprNode *filter_expr;
393
CHECK_ERROR(cfg_parser_parse(&filter_expr_parser, lexer, (gpointer *) &filter_expr), @1, NULL);
437
CHECK_ERROR(cfg_parser_parse(&filter_expr_parser, lexer, (gpointer *) &filter_expr, NULL), @1, NULL);
394
438
log_rewrite_set_condition(last_rewrite, filter_expr);
503
/* LogSource related options */
505
/* NOTE: plugins need to set "last_source_options" in order to incorporate this rule in their grammar */
506
: KW_LOG_IW_SIZE '(' LL_NUMBER ')' { last_source_options->init_window_size = $3; }
507
| KW_CHAIN_HOSTNAMES '(' yesno ')' { last_source_options->chain_hostnames = $3; }
508
| KW_NORMALIZE_HOSTNAMES '(' yesno ')' { last_source_options->normalize_hostnames = $3; }
509
| KW_KEEP_HOSTNAME '(' yesno ')' { last_source_options->keep_hostname = $3; }
510
| KW_USE_FQDN '(' yesno ')' { last_source_options->use_fqdn = $3; }
511
| KW_USE_DNS '(' dnsmode ')' { last_source_options->use_dns = $3; }
512
| KW_DNS_CACHE '(' yesno ')' { last_source_options->use_dns_cache = $3; }
513
| KW_PROGRAM_OVERRIDE '(' string ')' { last_source_options->program_override = g_strdup($3); free($3); }
514
| KW_HOST_OVERRIDE '(' string ')' { last_source_options->host_override = g_strdup($3); free($3); }
515
| KW_LOG_PREFIX '(' string ')' { gchar *p = strrchr($3, ':'); if (p) *p = 0; last_source_options->program_override = g_strdup($3); free($3); }
516
| KW_KEEP_TIMESTAMP '(' yesno ')' { last_source_options->keep_timestamp = $3; }
517
| KW_TAGS '(' string_list ')' { log_source_options_set_tags(last_source_options, $3); }
459
521
source_reader_options
460
522
: source_reader_option source_reader_options
526
/* LogReader related options, inherits from LogSource */
464
527
source_reader_option
465
: KW_LOG_IW_SIZE '(' LL_NUMBER ')' { last_reader_options->super.init_window_size = $3; }
466
| KW_CHAIN_HOSTNAMES '(' yesno ')' { last_reader_options->super.chain_hostnames = $3; }
467
| KW_NORMALIZE_HOSTNAMES '(' yesno ')' { last_reader_options->super.normalize_hostnames = $3; }
468
| KW_KEEP_HOSTNAME '(' yesno ')' { last_reader_options->super.keep_hostname = $3; }
469
| KW_USE_FQDN '(' yesno ')' { last_reader_options->super.use_fqdn = $3; }
470
| KW_USE_DNS '(' dnsmode ')' { last_reader_options->super.use_dns = $3; }
471
| KW_DNS_CACHE '(' yesno ')' { last_reader_options->super.use_dns_cache = $3; }
472
| KW_PROGRAM_OVERRIDE '(' string ')' { last_reader_options->super.program_override = g_strdup($3); free($3); }
473
| KW_HOST_OVERRIDE '(' string ')' { last_reader_options->super.host_override = g_strdup($3); free($3); }
474
| KW_LOG_PREFIX '(' string ')' { gchar *p = strrchr($3, ':'); if (p) *p = 0; last_reader_options->super.program_override = g_strdup($3); free($3); }
475
| KW_TIME_ZONE '(' string ')' { last_reader_options->parse_options.recv_time_zone = g_strdup($3); free($3); }
528
/* NOTE: plugins need to set "last_reader_options" in order to incorporate this rule in their grammar */
530
: KW_TIME_ZONE '(' string ')' { last_reader_options->parse_options.recv_time_zone = g_strdup($3); free($3); }
476
531
| KW_CHECK_HOSTNAME '(' yesno ')' { last_reader_options->check_hostname = $3; }
477
532
| KW_FLAGS '(' source_reader_option_flags ')'
478
533
| KW_LOG_MSG_SIZE '(' LL_NUMBER ')' { last_reader_options->msg_size = $3; }
479
534
| KW_LOG_FETCH_LIMIT '(' LL_NUMBER ')' { last_reader_options->fetch_limit = $3; }
480
535
| KW_PAD_SIZE '(' LL_NUMBER ')' { last_reader_options->padding = $3; }
481
| KW_KEEP_TIMESTAMP '(' yesno ')' { last_reader_options->super.keep_timestamp = $3; }
482
536
| KW_ENCODING '(' string ')' { last_reader_options->text_encoding = g_strdup($3); free($3); }
483
| KW_TAGS '(' string_list ')' { log_reader_options_set_tags(last_reader_options, $3); }
484
537
| KW_FORMAT '(' string ')' { last_reader_options->parse_options.format = g_strdup($3); free($3); }
485
538
| KW_DEFAULT_LEVEL '(' level_string ')'
494
547
last_reader_options->parse_options.default_pri = LOG_NOTICE;
495
548
last_reader_options->parse_options.default_pri = (last_reader_options->parse_options.default_pri & 7) | $3;
550
| { last_source_options = &last_reader_options->super; } source_option
499
553
source_reader_option_flags
500
554
: string source_reader_option_flags { CHECK_ERROR(log_reader_options_process_flag(last_reader_options, $1), @1, "Unknown flag %s", $1); free($1); }
555
| KW_CHECK_HOSTNAME source_reader_option_flags { log_reader_options_process_flag(last_reader_options, "check-hostname"); }
560
/* NOTE: plugins need to set "last_driver" in order to incorporate this rule in their grammar */
562
: KW_LOG_FIFO_SIZE '(' LL_NUMBER ')' { ((LogDestDriver *) last_driver)->log_fifo_size = $3; }
563
| KW_THROTTLE '(' LL_NUMBER ')' { ((LogDestDriver *) last_driver)->throttle = $3; }
567
gint context = LL_CONTEXT_INNER_DEST;
570
p = plugin_find(configuration, context, $1);
571
CHECK_ERROR(p, @1, "%s plugin %s not found", cfg_lexer_lookup_context_name_by_type(context), $1);
573
value = plugin_parse_config(p, configuration, &@1, last_driver);
580
log_driver_add_plugin(last_driver, (LogDriverPlugin *) value);
504
584
dest_writer_options
505
585
: dest_writer_option dest_writer_options
509
589
dest_writer_option
590
/* NOTE: plugins need to set "last_writer_options" in order to incorporate this rule in their grammar */
510
592
: KW_FLAGS '(' dest_writer_options_flags ')' { last_writer_options->options = $3; }
511
| KW_LOG_FIFO_SIZE '(' LL_NUMBER ')' { last_writer_options->mem_fifo_size = $3; }
512
593
| KW_FLUSH_LINES '(' LL_NUMBER ')' { last_writer_options->flush_lines = $3; }
513
594
| KW_FLUSH_TIMEOUT '(' LL_NUMBER ')' { last_writer_options->flush_timeout = $3; }
514
595
| KW_SUPPRESS '(' LL_NUMBER ')' { last_writer_options->suppress = $3; }
515
596
| KW_TEMPLATE '(' string ')' {
516
597
GError *error = NULL;
518
last_writer_options->template = cfg_check_inline_template(configuration, $3);
519
CHECK_ERROR(log_template_compile(last_writer_options->template, &error), @3, "Error compiling template (%s)", error->message);
599
last_writer_options->template = cfg_check_inline_template(configuration, $3, &error);
600
CHECK_ERROR(last_writer_options->template != NULL, @3, "Error compiling template (%s)", error->message);
522
603
| KW_TEMPLATE_ESCAPE '(' yesno ')' { log_writer_options_set_template_escape(last_writer_options, $3); }
523
604
| KW_TIME_ZONE '(' string ')' { last_writer_options->template_options.time_zone[LTZ_SEND] = g_strdup($3); free($3); }
524
605
| KW_TS_FORMAT '(' string ')' { last_writer_options->template_options.ts_format = cfg_ts_format_value($3); free($3); }
525
606
| KW_FRAC_DIGITS '(' LL_NUMBER ')' { last_writer_options->template_options.frac_digits = $3; }
526
| KW_THROTTLE '(' LL_NUMBER ')' { last_writer_options->throttle = $3; }
607
| KW_PAD_SIZE '(' LL_NUMBER ')' { last_writer_options->padding = $3; }
529
610
dest_writer_options_flags
617
{ last_value_pairs = value_pairs_new(); }
619
{ $$ = last_value_pairs; }
623
: vp_option vp_options
628
: KW_PAIR '(' string ':' string ')' { value_pairs_add_pair(last_value_pairs, configuration, $3, $5); free($3); free($5); }
629
| KW_PAIR '(' string string ')' { value_pairs_add_pair(last_value_pairs, configuration, $3, $4); free($3); free($4); }
630
| KW_KEY '(' string ')' {
631
gchar *k = g_strconcat("$", $3, NULL);
632
value_pairs_add_pair(last_value_pairs, configuration, $3, k);
636
| KW_EXCLUDE '(' string ')' { value_pairs_add_exclude_glob(last_value_pairs, $3); free($3); }
637
| KW_SCOPE '(' vp_scope_list ')'
641
: string vp_scope_list { value_pairs_add_scope(last_value_pairs, $1); free($1); }