syslog-ng source
logmsg.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2013 Balabit
3  * Copyright (c) 1998-2013 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 #ifndef LOGMSG_H_INCLUDED
26 #define LOGMSG_H_INCLUDED
27 
28 #include "syslog-ng.h"
29 #include "gsockaddr.h"
30 #include "atomic.h"
31 #include "serialize.h"
32 #include "timeutils/unixtime.h"
33 #include "logmsg/nvtable.h"
34 #include "logmsg/tags.h"
35 #include "messages.h"
36 
37 #include <sys/types.h>
38 #include <sys/socket.h>
39 #include <netinet/in.h>
40 #include <sys/time.h>
41 #include <iv_list.h>
42 
43 typedef enum
44 {
50 
51 #define IS_ACK_ABORTED(x) ((x) == AT_ABORTED ? 1 : 0)
52 
53 #define IS_ABORTFLAG_ON(x) ((x) == 1 ? TRUE : FALSE)
54 
55 #define IS_ACK_SUSPENDED(x) ((x) == AT_SUSPENDED ? 1 : 0)
56 
57 #define IS_SUSPENDFLAG_ON(x) ((x) == 1 ? TRUE : FALSE)
58 
59 #define STRICT_ROUND_TO_NEXT_EIGHT(x) ((x + 8) & ~7)
60 
61 typedef struct _LogPathOptions LogPathOptions;
62 
63 typedef void (*LMAckFunc)(LogMessage *lm, AckType ack_type);
64 
65 #define LOGMSG_MAX_MATCHES 256
66 
67 typedef enum
68 {
72  LM_TS_MAX
74 
75 /* builtin values */
76 enum
77 {
87 
88  /* NOTE: this is used as the number of "statically" allocated elements in
89  * an NVTable. NVTable may impose restrictions on this value (for
90  * instance had to be an even number earlier). So be sure to validate
91  * whether LM_V_MAX would fit NVTable if you add further enums here.
92  */
93 
95 
96  /* these are dynamic values but with a predefined handle */
103 
105 };
106 
107 enum
108 {
109  /* means that the message is not valid utf8 */
111  /* missing <pri> value */
113  /* invalid <pri> value */
115  /* no timestamp present in the original message */
117  /* hostname field does not seem valid, check-hostname(yes) failed */
119  /* we seem to have found an octet count in front of the message */
121  /* no date & host information in the syslog message */
123  /* hostname field missing */
125  /* program field missing */
127  /* pid field missing */
129  /* msgid field missing */
131  /* sdata field missing */
133  /* invalid SDATA */
135  /* sdata field missing */
137  /* message field missing */
139  /* invalid program name */
141 
143 };
144 
145 enum
146 {
147  LM_VF_SDATA = 0x0001,
148  LM_VF_MATCH = 0x0002,
149  LM_VF_MACRO = 0x0004,
150 };
151 
152 enum
153 {
154  /* these flags also matter when the message is serialized */
155  LF_OLD_UNPARSED = 0x0001,
156  /* message payload is guaranteed to be valid utf8 */
157  LF_UTF8 = 0x0001,
158  /* message was generated from within syslog-ng, doesn't matter if it came from the internal() source */
159  LF_INTERNAL = 0x0002,
160  /* message was received on a local transport, e.g. it was generated on the local machine */
161  LF_LOCAL = 0x0004,
162  /* message is a MARK mode */
163  LF_MARK = 0x0008,
164 
165  /* state flags that only matter during syslog-ng runtime and never
166  * when a message is serialized */
167  LF_STATE_MASK = 0xFFF0,
174 
175  /* part of the state that is kept across clones */
178 
179  LF_CHAINED_HOSTNAME = 0x00010000,
180 
181  /* NOTE: this flag is now unused. The original intent was to save whether
182  * LEGACY_MSGHDR was saved by the parser code. Now we simply check
183  * whether the length of ${LEGACY_MSGHDR} is non-zero. This used to be a
184  * slow operation (when name-value pairs were stored in a hashtable), now
185  * it is much faster. Also, this makes it possible to reproduce a message
186  * entirely based on name-value pairs. Without this change, even if
187  * LEGACY_MSGHDR was transferred (e.g. ewmm), the other side couldn't
188  * reproduce the original message, as this flag was not transferred.
189  *
190  * The flag remains here for documentation, and also because it is serialized in disk-buffers
191  */
193 };
194 
197 {
198  /* Everything is represented as a string, formatted in a type specific
199  * automatically parseable format.
200  *
201  * Please note that these values are part of the serialized LogMessage
202  * format, so changing these would cause incompatibilities in type
203  * recognition. Add new types at the end.
204  */
210  LM_VT_INTEGER = 4, /* equals to LM_VT_INT64 */
217 
218  /* extremal value to indicate "unset" state.
219  *
220  * NOTE: THIS IS NOT THE DEFAULT for actual values even if type is
221  * unspecified, those cases default to LM_VT_STRING.
222  */
223  LM_VT_NONE = 255
224 };
225 
227 gboolean log_msg_value_type_from_str(const gchar *in_str, LogMessageValueType *out_type);
228 
229 typedef struct _LogMessageQueueNode
230 {
231  struct iv_list_head list;
232  LogMessage *msg;
233  guint ack_needed: 1, embedded: 1, flow_control_requested: 1;
235 
236 
237 /* NOTE: the members are ordered according to the presumed use frequency.
238  * The structure itself is 2 cachelines, the border is right after the "msg"
239  * member */
241 {
242  /* if you change any of the fields here, be sure to adjust
243  * log_msg_clone_cow() as well to initialize fields properly */
244 
245  /* some of the fields in this struct are shared in copy-on-write
246  * scenarios, tracking of those fields are done using the "flags" member,
247  * see the LF_STATE_OWN_* flags
248  */
249 
250  /* ack_and_ref_and_abort_and_suspended is a 32 bit integer that is accessed in an atomic way.
251  * The upper half contains the ACK count (and the abort flag), the lower half
252  * the REF count. It is not a GAtomicCounter as due to ref/ack caching it has
253  * a lot of magic behind its implementation. See the logmsg.c file, around
254  * log_msg_ref/unref.
255  */
256 
258  guint32 flags;
259 
260  NVTable *payload;
261  LogMessage *original;
262  gulong *tags;
264 
265  /* this member is incremented for any write operation and it can also
266  * overflow, so only track it for changes and assume that 2^16 operations
267  * would suffice between two checks */
268  guint16 generation;
269  guint16 pri;
270  guint8 initial_parse: 1,
272 
273  /* NOTE: proto is just 6 bits wide, but with that it fills a hole
274  * not taking any tolls on the structure size. Realistically, we'd
275  * be storing IPPROTO_UDP and TCP in there, which fits the 6 bits.
276  * This is closely related to saddr/daddr and indicates the IP
277  * protocol that was used to deliver the datagram carrying this
278  * LogMessage. */
279 
280  proto: 6;
281  /* number of capture groups retrieved from a regexp match (e.g. $1, $2, ...) */
282  guint8 num_matches;
283 
284  /* number of bits in the "tags" array, if less than 64, all such bits are
285  * stored in the "tags" pointer, otherwise it points to an allocated bit
286  * array */
287  guint8 num_tags;
288  /* number of items allocated in the "sdata" array */
289  guint8 alloc_sdata;
290  /* number of items stored in the "sdata" array */
291  guint8 num_sdata;
292 
293  /* number of nodes pre-allocated as a part of LogMessage at the tail end of the structure */
294  guint8 num_nodes;
295 
296  /* the next available node */
297  guint8 cur_node;
298  /* is this message currently read only, used to track when we need to copy-on-write */
300  /* identifier of the source host */
301  guint32 host_id;
302  /* unique message identifier (upon receipt) */
303  guint64 rcptid;
304 
305  /* number of bytes in the received message */
307 
308  /* allocated bytes in LogMessage, is limited to 32 bits as it's highly
309  * unlikely that we would ever need more than 4GB for a single message
310  * including overhead */
312 
313  AckRecord *ack_record;
315 
318 
320 
321  /* preallocated LogQueueNodes used to insert this message into a LogQueue */
323 
324  /* a preallocated space for the initial NVTable (payload) may follow */
325 };
326 
327 extern NVRegistry *logmsg_registry;
328 extern const char logmsg_sd_prefix[];
329 extern const gint logmsg_sd_prefix_len;
330 extern gint logmsg_node_max;
331 
332 LogMessage *log_msg_ref(LogMessage *m);
333 void log_msg_unref(LogMessage *m);
334 void log_msg_write_protect(LogMessage *m);
335 
336 static inline gboolean
337 log_msg_is_write_protected(const LogMessage *self)
338 {
339  return self->write_protected;
340 }
341 
342 LogMessage *log_msg_clone_cow(LogMessage *msg, const LogPathOptions *path_options);
343 LogMessage *log_msg_make_writable(LogMessage **pmsg, const LogPathOptions *path_options);
344 
345 gboolean log_msg_write(LogMessage *self, SerializeArchive *sa);
346 gboolean log_msg_read(LogMessage *self, SerializeArchive *sa);
347 
348 /* generic values that encapsulate log message fields, dynamic values and structured data */
349 NVHandle log_msg_get_value_handle(const gchar *value_name);
350 gboolean log_msg_is_value_name_valid(const gchar *value);
351 const gchar *log_msg_get_handle_name(NVHandle handle, gssize *length);
352 
353 static inline gboolean
354 log_msg_is_handle_macro(NVHandle handle)
355 {
356  guint16 flags;
357 
358  flags = nv_registry_get_handle_flags(logmsg_registry, handle);
359  return !!(flags & LM_VF_MACRO);
360 }
361 
362 static inline gboolean
363 log_msg_is_handle_sdata(NVHandle handle)
364 {
365  guint16 flags;
366 
367  flags = nv_registry_get_handle_flags(logmsg_registry, handle);
368  return !!(flags & LM_VF_SDATA);
369 }
370 
371 static inline gboolean
372 log_msg_is_handle_match(NVHandle handle)
373 {
374  guint16 flags;
375 
376  flags = nv_registry_get_handle_flags(logmsg_registry, handle);
377  return !!(flags & LM_VF_MATCH);
378 }
379 
380 static inline gboolean
381 log_msg_is_handle_referencable_from_an_indirect_value(NVHandle handle)
382 {
383  if (handle == LM_V_NONE)
384  return FALSE;
385 
386  /* macro values should not be referenced as they are dynamic, store the actual value instead */
387  if (log_msg_is_handle_macro(handle))
388  return FALSE;
389 
390  /* matches are pretty temporary, so we should not reference them, as the
391  * next matching operation would overwrite them anyway */
392 
393  if (log_msg_is_handle_match(handle))
394  return FALSE;
395 
396  return TRUE;
397 }
398 
399 static inline gboolean
400 log_msg_is_handle_settable_with_an_indirect_value(NVHandle handle)
401 {
402  return (handle >= LM_V_MAX);
403 }
404 
405 const gchar *log_msg_get_macro_value(const LogMessage *self, gint id, gssize *value_len, LogMessageValueType *type);
406 const gchar *log_msg_get_match_with_type(const LogMessage *self, gint index_,
407  gssize *value_len, LogMessageValueType *type);
408 const gchar *log_msg_get_match_if_set_with_type(const LogMessage *self, gint index_,
409  gssize *value_len, LogMessageValueType *type);
410 
411 
412 
413 static inline const gchar *
414 log_msg_get_value_if_set_with_type(const LogMessage *self, NVHandle handle,
415  gssize *value_len,
416  LogMessageValueType *type)
417 {
418  guint16 flags;
419 
420  flags = nv_registry_get_handle_flags(logmsg_registry, handle);
421  if (G_UNLIKELY((flags & LM_VF_MACRO)))
422  return log_msg_get_macro_value(self, flags >> 8, value_len, type);
423  else
424  return nv_table_get_value(self->payload, handle, value_len, type);
425 }
426 
427 static inline gboolean
428 log_msg_is_value_set(const LogMessage *self, NVHandle handle)
429 {
430  return nv_table_is_value_set(self->payload, handle);
431 }
432 
433 static inline const gchar *
434 log_msg_get_value_with_type(const LogMessage *self, NVHandle handle, gssize *value_len, LogMessageValueType *type)
435 {
436  const gchar *result = log_msg_get_value_if_set_with_type(self, handle, value_len, type);
437 
438  if (result)
439  return result;
440  if (type)
441  *type = LM_VT_NULL;
442  if (value_len)
443  *value_len = 0;
444  return "";
445 }
446 
447 static inline const gchar *
448 log_msg_get_value(const LogMessage *self, NVHandle handle, gssize *value_len)
449 {
450  return log_msg_get_value_with_type(self, handle, value_len, NULL);
451 }
452 
453 static inline const gchar *
454 log_msg_get_value_if_set(const LogMessage *self, NVHandle handle, gssize *value_len)
455 {
456  return log_msg_get_value_if_set_with_type(self, handle, value_len, NULL);
457 }
458 
459 static inline const gchar *
460 log_msg_get_value_by_name(const LogMessage *self, const gchar *name, gssize *value_len)
461 {
463  return log_msg_get_value(self, handle, value_len);
464 }
465 
466 static inline const gchar *
467 log_msg_get_value_by_name_with_type(const LogMessage *self,
468  const gchar *name, gssize *value_len,
469  LogMessageValueType *type)
470 {
472  return log_msg_get_value_with_type(self, handle, value_len, type);
473 }
474 
475 static inline const gchar *
476 log_msg_get_value_name(NVHandle handle, gssize *name_len)
477 {
478  return nv_registry_get_handle_name(logmsg_registry, handle, name_len);
479 }
480 
481 typedef gboolean (*LogMessageTagsForeachFunc)(const LogMessage *self, LogTagId tag_id, const gchar *name,
482  gpointer user_data);
483 
484 void log_msg_set_value(LogMessage *self, NVHandle handle, const gchar *new_value, gssize length);
485 void log_msg_set_value_with_type(LogMessage *self, NVHandle handle,
486  const gchar *value, gssize value_len,
487  LogMessageValueType type);
488 
489 void log_msg_set_value_indirect(LogMessage *self, NVHandle handle, NVHandle ref_handle,
490  guint16 ofs, guint16 len);
491 void log_msg_set_value_indirect_with_type(LogMessage *self, NVHandle handle, NVHandle ref_handle,
492  guint16 ofs, guint16 len, LogMessageValueType type);
493 void log_msg_unset_value(LogMessage *self, NVHandle handle);
494 void log_msg_unset_value_by_name(LogMessage *self, const gchar *name);
495 gboolean log_msg_values_foreach(const LogMessage *self, NVTableForeachFunc func, gpointer user_data);
497 gint log_msg_get_match_index(NVHandle handle);
498 void log_msg_set_match(LogMessage *self, gint index, const gchar *value, gssize value_len);
499 void log_msg_set_match_with_type(LogMessage *self, gint index,
500  const gchar *value, gssize value_len,
501  LogMessageValueType type);
502 void log_msg_set_match_indirect(LogMessage *self, gint index, NVHandle ref_handle, guint16 ofs, guint16 len);
503 void log_msg_set_match_indirect_with_type(LogMessage *self, gint index, NVHandle ref_handle,
504  guint16 ofs, guint16 len, LogMessageValueType type);
505 void log_msg_unset_match(LogMessage *self, gint index_);
506 const gchar *log_msg_get_match_with_type(const LogMessage *self, gint index_, gssize *value_len,
507  LogMessageValueType *type);
508 const gchar *log_msg_get_match(const LogMessage *self, gint index_, gssize *value_len);
509 void log_msg_clear_matches(LogMessage *self);
510 void log_msg_truncate_matches(LogMessage *self, gint n);
511 
512 static inline void
513 log_msg_set_value_by_name_with_type(LogMessage *self,
514  const gchar *name, const gchar *value, gssize length,
515  LogMessageValueType type)
516 {
518  log_msg_set_value_with_type(self, handle, value, length, type);
519 }
520 
521 static inline void
522 log_msg_set_value_by_name(LogMessage *self, const gchar *name, const gchar *value, gssize length)
523 {
524  log_msg_set_value_by_name_with_type(self, name, value, length, LM_VT_STRING);
525 }
526 
527 static inline void
528 log_msg_set_value_to_string(LogMessage *self, NVHandle handle, const gchar *literal_string)
529 {
530  log_msg_set_value(self, handle, literal_string, strlen(literal_string));
531 }
532 
533 void log_msg_rename_value(LogMessage *self, NVHandle from, NVHandle to);
534 
535 void log_msg_append_format_sdata(const LogMessage *self, GString *result, guint32 seq_num);
536 void log_msg_format_sdata(const LogMessage *self, GString *result, guint32 seq_num);
537 void log_msg_clear_sdata(LogMessage *self);
538 
539 void log_msg_set_tag_by_id_onoff(LogMessage *self, LogTagId id, gboolean on);
540 void log_msg_set_tag_by_id(LogMessage *self, LogTagId id);
541 void log_msg_set_tag_by_name(LogMessage *self, const gchar *name);
542 void log_msg_clear_tag_by_id(LogMessage *self, LogTagId id);
543 void log_msg_clear_tag_by_name(LogMessage *self, const gchar *name);
544 gboolean log_msg_is_tag_by_id(LogMessage *self, LogTagId id);
545 gboolean log_msg_is_tag_by_name(LogMessage *self, const gchar *name);
546 void log_msg_tags_foreach(const LogMessage *self, LogMessageTagsForeachFunc callback, gpointer user_data);
547 void log_msg_format_tags(const LogMessage *self, GString *result, gboolean include_localtags);
548 void log_msg_format_matches(const LogMessage *self, GString *result);
549 
550 
551 static inline void
552 log_msg_set_recvd_rawmsg_size(LogMessage *self, guint32 size)
553 {
554  self->recvd_rawmsg_size = size;
555 }
556 
557 void log_msg_set_saddr(LogMessage *self, GSockAddr *saddr);
558 void log_msg_set_saddr_ref(LogMessage *self, GSockAddr *saddr);
559 void log_msg_set_daddr(LogMessage *self, GSockAddr *daddr);
560 void log_msg_set_daddr_ref(LogMessage *self, GSockAddr *daddr);
561 
562 
563 LogMessageQueueNode *log_msg_alloc_queue_node(LogMessage *msg, const LogPathOptions *path_options);
564 LogMessageQueueNode *log_msg_alloc_dynamic_queue_node(LogMessage *msg, const LogPathOptions *path_options);
566 
567 void log_msg_clear(LogMessage *self);
568 void log_msg_merge_context(LogMessage *self, LogMessage **context, gsize context_len);
569 
570 LogMessage *log_msg_sized_new(gsize payload_size);
571 LogMessage *log_msg_new_mark(void);
572 LogMessage *log_msg_new_internal(gint prio, const gchar *msg);
573 LogMessage *log_msg_new_empty(void);
574 LogMessage *log_msg_new_local(void);
575 
576 void log_msg_add_ack(LogMessage *msg, const LogPathOptions *path_options);
577 void log_msg_ack(LogMessage *msg, const LogPathOptions *path_options, AckType ack_type);
578 void log_msg_drop(LogMessage *msg, const LogPathOptions *path_options, AckType ack_type);
579 const LogPathOptions *log_msg_break_ack(LogMessage *msg, const LogPathOptions *path_options,
580  LogPathOptions *local_path_options);
581 
582 void log_msg_refcache_start_producer(LogMessage *self);
583 void log_msg_refcache_start_consumer(LogMessage *self, const LogPathOptions *path_options);
584 void log_msg_refcache_stop(void);
585 
586 void log_msg_registry_init(void);
587 void log_msg_registry_deinit(void);
588 void log_msg_global_init(void);
589 void log_msg_global_deinit(void);
591 void log_msg_registry_foreach(GHFunc func, gpointer user_data);
592 
593 gint log_msg_lookup_time_stamp_name(const gchar *name);
594 
595 gssize log_msg_get_size(LogMessage *self);
596 
597 #define evt_tag_msg_reference(msg) \
598  evt_tag_printf("msg", "%p", (msg)), \
599  evt_tag_printf("rcptid", "%" G_GUINT64_FORMAT, (msg)->rcptid)
600 
601 static inline EVTTAG *
602 evt_tag_msg_value(const gchar *name, LogMessage *msg, NVHandle value_handle)
603 {
604  gssize value_len;
605  const gchar *value = log_msg_get_value(msg, value_handle, &value_len);
606 
607  return evt_tag_mem(name, value, value_len);
608 }
609 
610 static inline EVTTAG *
611 evt_tag_msg_value_name(const gchar *name, NVHandle value_handle)
612 {
613  const gchar *value_name = log_msg_get_value_name(value_handle, NULL);
614 
615  return evt_tag_str(name, value_name);
616 }
617 
618 #endif
const gchar * name
Definition: debugger.c:265
EVTTAG * evt_tag_mem(const char *tag, const void *value, size_t len)
Definition: evttags.c:84
EVTTAG * evt_tag_str(const char *tag, const char *value)
Definition: evttags.c:65
void log_msg_clear(LogMessage *self)
Definition: logmsg.c:1357
void log_msg_set_saddr(LogMessage *self, GSockAddr *saddr)
Definition: logmsg.c:1298
void log_msg_unref(LogMessage *m)
Definition: logmsg.c:1721
gssize log_msg_get_size(LogMessage *self)
Definition: logmsg.c:2138
gint logmsg_node_max
void log_msg_format_matches(const LogMessage *self, GString *result)
Definition: logmsg.c:1282
void log_msg_unset_value_by_name(LogMessage *self, const gchar *name)
Definition: logmsg.c:689
void log_msg_registry_deinit(void)
Definition: logmsg.c:2068
gboolean log_msg_values_foreach(const LogMessage *self, NVTableForeachFunc func, gpointer user_data)
Definition: logmsg.c:765
void log_msg_clear_tag_by_name(LogMessage *self, const gchar *name)
Definition: logmsg.c:1027
void log_msg_set_saddr_ref(LogMessage *self, GSockAddr *saddr)
Definition: logmsg.c:1304
@ LM_T_SYSLOG_RFC5424_MISSING_APP_NAME
Definition: logmsg.h:126
@ LM_T_SYSLOG_MISSING_PRI
Definition: logmsg.h:112
@ LM_T_SYSLOG_RFC3164_MISSING_HEADER
Definition: logmsg.h:122
@ LM_T_PREDEFINED_MAX
Definition: logmsg.h:142
@ LM_T_SYSLOG_RFC5424_MISSING_PROCID
Definition: logmsg.h:128
@ LM_T_SYSLOG_MISSING_TIMESTAMP
Definition: logmsg.h:116
@ LM_T_SYSLOG_RFC5424_MISSING_MESSAGE
Definition: logmsg.h:136
@ LM_T_SYSLOG_RFC5424_MISSING_SDATA
Definition: logmsg.h:132
@ LM_T_SYSLOG_RFC5424_MISSING_MSGID
Definition: logmsg.h:130
@ LM_T_SYSLOG_RFC5424_MISSING_HOSTNAME
Definition: logmsg.h:124
@ LM_T_SYSLOG_UNEXPECTED_FRAMING
Definition: logmsg.h:120
@ LM_T_SYSLOG_INVALID_PRI
Definition: logmsg.h:114
@ LM_T_SYSLOG_MISSING_MESSAGE
Definition: logmsg.h:138
@ LM_T_SYSLOG_RFC_3164_INVALID_PROGRAM
Definition: logmsg.h:140
@ LM_T_SYSLOG_INVALID_HOSTNAME
Definition: logmsg.h:118
@ LM_T_MSG_UTF8_SANITIZED
Definition: logmsg.h:110
@ LM_T_SYSLOG_RFC5424_INVALID_SDATA
Definition: logmsg.h:134
LogMessageTimeStamp
Definition: logmsg.h:68
@ LM_TS_MAX
Definition: logmsg.h:72
@ LM_TS_STAMP
Definition: logmsg.h:69
@ LM_TS_PROCESSED
Definition: logmsg.h:71
@ LM_TS_RECVD
Definition: logmsg.h:70
void log_msg_set_value_indirect(LogMessage *self, NVHandle handle, NVHandle ref_handle, guint16 ofs, guint16 len)
Definition: logmsg.c:758
LogMessage * log_msg_ref(LogMessage *m)
Definition: logmsg.c:1695
void log_msg_set_tag_by_name(LogMessage *self, const gchar *name)
Definition: logmsg.c:1015
gboolean log_msg_is_value_name_valid(const gchar *value)
Definition: logmsg.c:434
void log_msg_merge_context(LogMessage *self, LogMessage **context, gsize context_len)
Definition: logmsg.c:1440
@ LM_VF_MATCH
Definition: logmsg.h:148
@ LM_VF_SDATA
Definition: logmsg.h:147
@ LM_VF_MACRO
Definition: logmsg.h:149
void log_msg_drop(LogMessage *msg, const LogPathOptions *path_options, AckType ack_type)
Definition: logmsg.c:1633
void log_msg_set_match_with_type(LogMessage *self, gint index, const gchar *value, gssize value_len, LogMessageValueType type)
Definition: logmsg.c:789
gboolean log_msg_read(LogMessage *self, SerializeArchive *sa)
void log_msg_rename_value(LogMessage *self, NVHandle from, NVHandle to)
Definition: logmsg.c:557
void log_msg_clear_tag_by_id(LogMessage *self, LogTagId id)
Definition: logmsg.c:1021
void log_msg_write_protect(LogMessage *m)
Definition: logmsg.c:283
void log_msg_format_tags(const LogMessage *self, GString *result, gboolean include_localtags)
Definition: logmsg.c:1274
gint log_msg_get_match_index(NVHandle handle)
Definition: logmsg.c:780
LogMessage * log_msg_clone_cow(LogMessage *msg, const LogPathOptions *path_options)
Definition: logmsg.c:1486
void log_msg_refcache_start_consumer(LogMessage *self, const LogPathOptions *path_options)
Definition: logmsg.c:1883
void log_msg_registry_foreach(GHFunc func, gpointer user_data)
Definition: logmsg.c:2075
const LogPathOptions * log_msg_break_ack(LogMessage *msg, const LogPathOptions *path_options, LogPathOptions *local_path_options)
Definition: logmsg.c:1814
_LogMessageValueType
Definition: logmsg.h:197
@ LM_VT_BOOLEAN
Definition: logmsg.h:207
@ LM_VT_BYTES
Definition: logmsg.h:215
@ LM_VT_NULL
Definition: logmsg.h:214
@ LM_VT_STRING
Definition: logmsg.h:205
@ __COMPAT_LM_VT_INT32
Definition: logmsg.h:208
@ __COMPAT_LM_VT_INT64
Definition: logmsg.h:209
@ LM_VT_JSON
Definition: logmsg.h:206
@ LM_VT_LIST
Definition: logmsg.h:213
@ LM_VT_PROTOBUF
Definition: logmsg.h:216
@ LM_VT_NONE
Definition: logmsg.h:223
@ LM_VT_DATETIME
Definition: logmsg.h:212
@ LM_VT_INTEGER
Definition: logmsg.h:210
@ LM_VT_DOUBLE
Definition: logmsg.h:211
void log_msg_set_value(LogMessage *self, NVHandle handle, const gchar *new_value, gssize length)
Definition: logmsg.c:641
void log_msg_set_value_indirect_with_type(LogMessage *self, NVHandle handle, NVHandle ref_handle, guint16 ofs, guint16 len, LogMessageValueType type)
Definition: logmsg.c:695
LogMessage * log_msg_make_writable(LogMessage **pmsg, const LogPathOptions *path_options)
Definition: logmsg.c:289
void log_msg_add_ack(LogMessage *msg, const LogPathOptions *path_options)
Definition: logmsg.c:1750
void log_msg_set_daddr(LogMessage *self, GSockAddr *daddr)
Definition: logmsg.c:1313
void log_msg_clear_matches(LogMessage *self)
Definition: logmsg.c:868
void log_msg_set_tag_by_id_onoff(LogMessage *self, LogTagId id, gboolean on)
Definition: logmsg.c:945
NVHandle log_msg_get_value_handle(const gchar *value_name)
Definition: logmsg.c:418
AckType
Definition: logmsg.h:44
@ AT_PROCESSED
Definition: logmsg.h:46
@ AT_SUSPENDED
Definition: logmsg.h:48
@ AT_ABORTED
Definition: logmsg.h:47
@ AT_UNDEFINED
Definition: logmsg.h:45
@ LM_V_PROGRAM
Definition: logmsg.h:82
@ LM_V_TRANSPORT
Definition: logmsg.h:98
@ LM_V_PREDEFINED_MAX
Definition: logmsg.h:104
@ LM_V_HOST_FROM
Definition: logmsg.h:80
@ LM_V_RAWMSG
Definition: logmsg.h:97
@ LM_V_LEGACY_MSGHDR
Definition: logmsg.h:86
@ LM_V_SOURCE
Definition: logmsg.h:85
@ LM_V_FILE_NAME
Definition: logmsg.h:100
@ LM_V_MSGFORMAT
Definition: logmsg.h:99
@ LM_V_MESSAGE
Definition: logmsg.h:81
@ LM_V_PID
Definition: logmsg.h:83
@ LM_V_MAX
Definition: logmsg.h:94
@ LM_V_PEER_PORT
Definition: logmsg.h:102
@ LM_V_MSGID
Definition: logmsg.h:84
@ LM_V_PEER_IP
Definition: logmsg.h:101
@ LM_V_HOST
Definition: logmsg.h:79
@ LM_V_NONE
Definition: logmsg.h:78
void log_msg_stats_global_init(void)
void log_msg_set_match(LogMessage *self, gint index, const gchar *value, gssize value_len)
Definition: logmsg.c:798
gboolean log_msg_is_tag_by_name(LogMessage *self, const gchar *name)
Definition: logmsg.c:1049
gboolean log_msg_write(LogMessage *self, SerializeArchive *sa)
LogMessage * log_msg_new_mark(void)
Definition: logmsg.c:1585
void log_msg_format_sdata(const LogMessage *self, GString *result, guint32 seq_num)
Definition: logmsg.c:1237
gboolean(* LogMessageTagsForeachFunc)(const LogMessage *self, LogTagId tag_id, const gchar *name, gpointer user_data)
Definition: logmsg.h:481
void log_msg_unset_match(LogMessage *self, gint index_)
Definition: logmsg.c:851
void log_msg_append_format_sdata(const LogMessage *self, GString *result, guint32 seq_num)
Definition: logmsg.c:1096
void log_msg_refcache_stop(void)
Definition: logmsg.c:1902
void log_msg_ack(LogMessage *msg, const LogPathOptions *path_options, AckType ack_type)
Definition: logmsg.c:1778
const char logmsg_sd_prefix[]
Definition: logmsg.c:272
LogMessage * log_msg_new_empty(void)
Definition: logmsg.c:1534
LogMessageQueueNode * log_msg_alloc_dynamic_queue_node(LogMessage *msg, const LogPathOptions *path_options)
Definition: logmsg.c:523
NVType LogMessageValueType
Definition: logmsg.h:195
const gchar * log_msg_get_match_if_set_with_type(const LogMessage *self, gint index_, gssize *value_len, LogMessageValueType *type)
Definition: logmsg.c:820
const gchar * log_msg_get_match(const LogMessage *self, gint index_, gssize *value_len)
Definition: logmsg.c:845
const gint logmsg_sd_prefix_len
Definition: logmsg.c:273
LogMessageQueueNode * log_msg_alloc_queue_node(LogMessage *msg, const LogPathOptions *path_options)
Definition: logmsg.c:492
void log_msg_refcache_start_producer(LogMessage *self)
Definition: logmsg.c:1845
const gchar * log_msg_get_macro_value(const LogMessage *self, gint id, gssize *value_len, LogMessageValueType *type)
Definition: logmsg.c:455
void log_msg_global_deinit(void)
Definition: logmsg.c:2121
void log_msg_registry_init(void)
Definition: logmsg.c:2026
const gchar * log_msg_value_type_to_str(LogMessageValueType self)
Definition: logmsg.c:209
LogMessage * log_msg_sized_new(gsize payload_size)
Definition: logmsg.c:1525
void log_msg_unset_value(LogMessage *self, NVHandle handle)
Definition: logmsg.c:647
void log_msg_truncate_matches(LogMessage *self, gint n)
Definition: logmsg.c:858
void log_msg_set_match_indirect_with_type(LogMessage *self, gint index, NVHandle ref_handle, guint16 ofs, guint16 len, LogMessageValueType type)
Definition: logmsg.c:805
void log_msg_set_value_with_type(LogMessage *self, NVHandle handle, const gchar *value, gssize value_len, LogMessageValueType type)
Definition: logmsg.c:573
gint log_msg_lookup_time_stamp_name(const gchar *name)
Definition: logmsg.c:2128
void log_msg_set_tag_by_id(LogMessage *self, LogTagId id)
Definition: logmsg.c:1009
void log_msg_set_match_indirect(LogMessage *self, gint index, NVHandle ref_handle, guint16 ofs, guint16 len)
Definition: logmsg.c:814
gboolean log_msg_value_type_from_str(const gchar *in_str, LogMessageValueType *out_type)
Definition: logmsg.c:233
LogMessage * log_msg_new_internal(gint prio, const gchar *msg)
Definition: logmsg.c:1560
void log_msg_clear_sdata(LogMessage *self)
Definition: logmsg.c:1244
void log_msg_global_init(void)
Definition: logmsg.c:2101
gboolean log_msg_is_tag_by_id(LogMessage *self, LogTagId id)
Definition: logmsg.c:1033
const gchar * log_msg_get_handle_name(NVHandle handle, gssize *length)
Definition: logmsg.c:2115
NVRegistry * logmsg_registry
Definition: logmsg.c:271
void(* LMAckFunc)(LogMessage *lm, AckType ack_type)
Definition: logmsg.h:63
void log_msg_tags_foreach(const LogMessage *self, LogMessageTagsForeachFunc callback, gpointer user_data)
Definition: logmsg.c:911
@ LF_STATE_OWN_TAGS
Definition: logmsg.h:171
@ LF_INTERNAL
Definition: logmsg.h:159
@ LF_STATE_OWN_PAYLOAD
Definition: logmsg.h:168
@ LF_STATE_OWN_MASK
Definition: logmsg.h:173
@ LF_OLD_UNPARSED
Definition: logmsg.h:155
@ LF_LOCAL
Definition: logmsg.h:161
@ __UNUSED_LF_LEGACY_MSGHDR
Definition: logmsg.h:192
@ LF_STATE_MASK
Definition: logmsg.h:167
@ LF_MARK
Definition: logmsg.h:163
@ LF_STATE_OWN_SDATA
Definition: logmsg.h:172
@ LF_STATE_CLONED_MASK
Definition: logmsg.h:176
@ LF_STATE_OWN_SADDR
Definition: logmsg.h:169
@ LF_CHAINED_HOSTNAME
Definition: logmsg.h:179
@ LF_UTF8
Definition: logmsg.h:157
@ LF_STATE_TRACING
Definition: logmsg.h:177
@ LF_STATE_OWN_DADDR
Definition: logmsg.h:170
LogMessage * log_msg_new_local(void)
Definition: logmsg.c:1541
NVHandle log_msg_get_match_handle(gint index_)
Definition: logmsg.c:771
void log_msg_set_daddr_ref(LogMessage *self, GSockAddr *daddr)
Definition: logmsg.c:1319
const gchar * log_msg_get_match_with_type(const LogMessage *self, gint index_, gssize *value_len, LogMessageValueType *type)
Definition: logmsg.c:829
void log_msg_free_queue_node(LogMessageQueueNode *node)
Definition: logmsg.c:533
guint8 NVType
Definition: nvtable.h:36
gboolean(* NVTableForeachFunc)(NVHandle handle, const gchar *name, const gchar *value, gssize value_len, NVType type, gpointer user_data)
Definition: nvtable.h:37
guint32 NVHandle
Definition: nvtable.h:35
#define self
Definition: rcptid.c:38
Definition: gsockaddr.h:46
Definition: logmsg.h:230
LogMessage * msg
Definition: logmsg.h:232
guint ack_needed
Definition: logmsg.h:233
Definition: logmsg.h:241
guint8 num_nodes
Definition: logmsg.h:294
guint8 proto
Definition: logmsg.h:280
LogMessageQueueNode nodes[0]
Definition: logmsg.h:322
LMAckFunc ack_func
Definition: logmsg.h:314
AckRecord * ack_record
Definition: logmsg.h:313
LogMessage * original
Definition: logmsg.h:261
guint8 initial_parse
Definition: logmsg.h:270
guint8 write_protected
Definition: logmsg.h:299
UnixTime timestamps[LM_TS_MAX]
Definition: logmsg.h:319
guint16 pri
Definition: logmsg.h:269
guint8 num_matches
Definition: logmsg.h:282
guint8 recursed
Definition: logmsg.h:271
guint8 num_sdata
Definition: logmsg.h:291
guint32 flags
Definition: logmsg.h:258
gint ack_and_ref_and_abort_and_suspended
Definition: logmsg.h:257
NVTable * payload
Definition: logmsg.h:260
guint8 cur_node
Definition: logmsg.h:297
guint16 generation
Definition: logmsg.h:268
guint32 host_id
Definition: logmsg.h:301
GSockAddr * saddr
Definition: logmsg.h:316
guint8 alloc_sdata
Definition: logmsg.h:289
GSockAddr * daddr
Definition: logmsg.h:317
guint32 allocated_bytes
Definition: logmsg.h:311
NVHandle * sdata
Definition: logmsg.h:263
guint8 num_tags
Definition: logmsg.h:287
guint32 recvd_rawmsg_size
Definition: logmsg.h:306
gulong * tags
Definition: logmsg.h:262
guint64 rcptid
Definition: logmsg.h:303
Definition: logpipe.h:197
guint16 LogTagId
Definition: tags.h:31
GString * value
Definition: test_decode.c:28
GString * result
Definition: test_lexer_block.c:34
LogMessage * msg
Definition: test_rename.c:35
SerializeArchive * sa
Definition: test_timestamp_serialize.c:31
LogPathOptions path_options
Definition: test_wildcard_file_reader.c:62