Debian Codegraph @

runtime/rsyslog.h

raw
1 /**
2 * @file rsyslog.h
3 * @brief Public interface for the rsyslog runtime library.
4 *
5 * This header provides the public API and data structures required by
6 * modules interacting with the rsyslog runtime. It is part of the
7 * rsyslog runtime library, which is licensed under the GNU Lesser General
8 * Public License version 3 or later.
9 */
10 #ifndef INCLUDED_RSYSLOG_H
11 #define INCLUDED_RSYSLOG_H
12 #ifdef __GNUC__
13
14 /**
15 * @brief Suppress -Wstrict-prototypes for plugin interface compatibility.
16 *
17 * This suppression is required because rsyslog's plugin interface API,
18 * designed over 20 years ago, uses traditional C-style function declarations
19 * like `int func()` instead of `int func(void)`.
20 *
21 * While this style triggers `-Wstrict-prototypes` in modern GCC, it remains
22 * intentional and necessary: the plugin interface must stay ABI-compatible
23 * with numerous out-of-tree and third-party plugins, many of which are
24 * unknown and beyond our control.
25 *
26 * Internally, function declarations are correctly overridden and type-checked
27 * where possible, and care is taken not to introduce mismatches. However,
28 * the original form must be preserved to maintain binary compatibility.
29 *
30 * AI note: Do not "modernize" these declarations automatically. This is
31 * legacy interface preservation, not an oversight.
32 */
33 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
34 #pragma GCC diagnostic ignored "-Wdeclaration-after-statement"
35 #if __GNUC__ >= 8 || defined(__clang__)
36 #if defined(__clang__)
37 #pragma GCC diagnostic ignored "-Wunknown-warning-option"
38 #endif
39 /* GCC, starting at least with version 8, is now really overdoing with it's
40 * warning messages. We turn those off that either cause an enormous amount
41 * of false positives or flag perfectly legal code as problematic.
42 */
43 /* That one causes warnings when we use variable buffers for error
44 * messages which may be truncated in the very unlikely case of all
45 * vars using max value. If going over the max size, the engine will
46 * most likely truncate due to max message size anyhow. Also, sizing
47 * the buffers for max-max message size is a wast of (stack) memory.
48 */
49 #pragma GCC diagnostic ignored "-Wformat-truncation"
50 /* The next one flags variable initializations within out exception handling
51 * (iRet system) as problematic, even though variables are not used in those
52 * cases. This would be a good diagnostic if gcc would actually check that
53 * a variable is used uninitialized. Unfortunately it does not do that. But
54 * the static analyzers we use as part of CI do, so we are covered in any
55 * case.
56 * Unfortunately ignoring this diagnostic leads to two more info lines
57 * being emitted where nobody knows what the mean and why they appear :-(
58 */
59 #pragma GCC diagnostic ignored "-Wjump-misses-init"
60 #pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
61 #pragma GCC diagnostic ignored "-Wcast-function-type"
62 #endif
63
64 #if defined(__clang__)
65 #define ATTR_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined")))
66 #define ATTR_NO_SANITIZE_THREAD __attribute__((no_sanitize("thread")))
67 #else
68 #define ATTR_NO_SANITIZE_UNDEFINED
69 #define ATTR_NO_SANITIZE_THREAD
70 #endif
71 /* define a couple of attributes to improve cross-platform builds */
72 #if __GNUC__ > 6
73 #define CASE_FALLTHROUGH __attribute__((fallthrough));
74 #else
75 #define CASE_FALLTHROUGH
76 #endif
77
78 #define ATTR_NORETURN __attribute__((noreturn))
79 #define ATTR_UNUSED __attribute__((unused))
80 #define ATTR_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
81
82 #else /* ifdef __GNUC__ */
83
84 #define CASE_FALLTHROUGH
85 #define ATTR_NORETURN
86 #define ATTR_UNUSED
87 #define ATTR_NONNULL(...)
88 #define ATTR_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined")))
89 #define ATTR_NO_SANITIZE_THREAD __attribute__((no_sanitize("thread")))
90
91 #endif /* ifdef __GNUC__ */
92
93 #if defined(_AIX)
94 #include <sys/select.h>
95 /* AIXPORT : start*/
96 #define SRC_FD 13
97 #define SRCMSG (sizeof(srcpacket))
98 #endif
99 /* src end */
100
101 #include <pthread.h>
102 #include <string.h>
103 #include "typedefs.h"
104
105 #if defined(__GNUC__)
106 #define PRAGMA_IGNORE_Wswitch_enum _Pragma("GCC diagnostic ignored \"-Wswitch-enum\"")
107 #define PRAGMA_IGNORE_Wempty_body _Pragma("GCC diagnostic ignored \"-Wempty-body\"")
108 #define PRAGMA_IGNORE_Wstrict_prototypes _Pragma("GCC diagnostic ignored \"-Wstrict-prototypes\"")
109 #define PRAGMA_IGNORE_Wold_style_definition _Pragma("GCC diagnostic ignored \"-Wold-style-definition\"")
110 #if defined(__clang_major__) && __clang_major__ >= 14
111 #define PRAGMA_IGNORE_Wvoid_pointer_to_enum_cast \
112 _Pragma("GCC diagnostic ignored \"-Wvoid-pointer-to-enum-cast\"")
113 #else
114 #define PRAGMA_IGNORE_Wvoid_pointer_to_enum_cast
115 #endif
116 #define PRAGMA_IGNORE_Wsign_compare _Pragma("GCC diagnostic ignored \"-Wsign-compare\"")
117 #define PRAGMA_IGNORE_Wpragmas _Pragma("GCC diagnostic ignored \"-Wpragmas\"")
118 #define PRAGMA_IGNORE_Wmissing_noreturn _Pragma("GCC diagnostic ignored \"-Wmissing-noreturn\"")
119 #define PRAGMA_IGNORE_Wexpansion_to_defined _Pragma("GCC diagnostic ignored \"-Wexpansion-to-defined\"")
120 #define PRAGMA_IGNORE_Wunknown_warning_option _Pragma("GCC diagnostic ignored \"-Wunknown-warning-option\"")
121 #define PRAGMA_IGNORE_Wjump_misses_init _Pragma("GCC diagnostic ignored \"-Wjump-misses-init\"")
122 #if !defined(__clang__)
123 #define PRAGMA_IGNORE_Wunknown_attribute _Pragma("GCC diagnostic ignored \"-Wunknown-attribute\"")
124 #else
125 #define PRAGMA_IGNORE_Wunknown_attribute
126 #endif
127 #define PRAGMA_IGNORE_Wformat_nonliteral _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
128 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) || defined(__clang__)
129 #define PRAGMA_IGNORE_Wdeprecated_declarations _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
130 #define PRAGMA_IGNORE_Wunused_parameter _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"")
131 #define PRAGMA_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
132 #define PRAGMA_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
133 #else
134 #define PRAGMA_IGNORE_Wdeprecated_declarations
135 #define PRAGMA_IGNORE_Wunused_parameter
136 #define PRAGMA_DIAGNOSTIC_PUSH
137 #define PRAGMA_DIAGNOSTIC_POP
138 #endif
139 #else
140 #define PRAGMA_IGNORE_Wswitch_enum
141 #define PRAGMA_IGNORE_Wsign_compare
142 #define PRAGMA_IGNORE_Wformat_nonliteral
143 #define PRAGMA_IGNORE_Wpragmas
144 #define PRAGMA_IGNORE_Wmissing_noreturn
145 #define PRAGMA_IGNORE_Wempty_body
146 #define PRAGMA_IGNORE_Wstrict_prototypes
147 #define PRAGMA_IGNORE_Wold_style_definition
148 #define PRAGMA_IGNORE_Wvoid_pointer_to_enum_cast
149 #define PRAGMA_IGNORE_Wdeprecated_declarations
150 #define PRAGMA_IGNORE_Wexpansion_to_defined
151 #define PRAGMA_IGNORE_Wunknown_attribute
152 #define PRAGMA_IGNORE_Wunknown_warning_option
153 #define PRAGMA_IGNORE_Wjump_misses_init
154 #define PRAGMA_DIAGNOSTIC_PUSH
155 #define PRAGMA_DIAGNOSTIC_POP
156 #endif
157
158 #define NULL_CHECK(ptr) \
159 do { \
160 if (unlikely(ptr == NULL)) { \
161 LogError(0, RS_RET_PROGRAM_ERROR, "%s:%d: prevented NULL pointer access", __FILE__, __LINE__); \
162 ABORT_FINALIZE(RS_RET_PROGRAM_ERROR); \
163 } \
164 } while (0);
165
166 /* ############################################################# *
167 * # Some constant values # *
168 * ############################################################# */
169
170 /**
171 * @brief Number of characters in an RFC 3164 timestamp (excluding the NUL terminator).
172 */
173 #define CONST_LEN_TIMESTAMP_3164 15
174
175 /**
176 * @brief Number of characters in an RFC 3339 timestamp (excluding the NUL terminator).
177 */
178 #define CONST_LEN_TIMESTAMP_3339 32
179
180 #define CONST_LEN_CEE_COOKIE 5
181 #define CONST_CEE_COOKIE "@cee:"
182
183 /* ############################################################# *
184 * # Config Settings # *
185 * ############################################################# */
186 #define RS_STRINGBUF_ALLOC_INCREMENT 128
187
188 /* MAXSIZE are absolute maxima, while BUFSIZE are just values after which
189 * processing is more time-intense. The BUFSIZE params currently add their
190 * value to the fixed size of the message object.
191 */
192
193 /**
194 * @brief Maximum permitted size for a syslog TAG field.
195 *
196 * This value is intentionally set far above any realistic tag length
197 * to guard against malformed or excessive configurations.
198 */
199 #define CONF_TAG_MAXSIZE 512
200
201 /**
202 * @brief Maximum permitted size for a syslog HOSTNAME field.
203 *
204 * This value is intentionally set far above any realistic hostname length
205 * to guard against malformed or excessive configurations.
206 */
207 #define CONF_HOSTNAME_MAXSIZE 512
208 #define CONF_RAWMSG_BUFSIZE 101
209 #define CONF_TAG_BUFSIZE 32
210 #define CONF_PROGNAME_BUFSIZE 16
211 #define CONF_HOSTNAME_BUFSIZE 32
212 /**
213 * @brief Suggested buffer size for config string properties.
214 *
215 * Should be close to the size of a pointer or slightly above it.
216 * This may be used in unions with pointers.
217 */
218 #define CONF_PROP_BUFSIZE 16
219
220 /**
221 * @brief Initial size of iparams array in worker thread instances.
222 *
223 * This array is automatically extended as needed.
224 */
225 #define CONF_IPARAMS_BUFSIZE 16
226
227 /**
228 * @brief Minimum message size (in bytes) to attempt compression.
229 *
230 * Compression is skipped for smaller messages to avoid overhead.
231 * Even though rsyslog checks for compression gain before submitting,
232 * it still requires a (costly) compress() call. This threshold skips
233 * the call entirely for very small messages.
234 *
235 * @note Some small messages may be sent uncompressed, trading a few
236 * extra bytes for better performance.
237 *
238 * @remarks
239 * Originally introduced to avoid pointless compression attempts that
240 * save no bandwidth due to protocol padding (e.g. UDP).
241 * - rgerhards, 2006-11-30
242 */
243 #define CONF_MIN_SIZE_FOR_COMPRESS 60
244
245 /**
246 * @brief Maximum number of cached string buffer pointers in output modules.
247 *
248 * All rsyslog-provided plugins stay below this value. Recompile with a
249 * higher value only if future or third-party plugins require it.
250 *
251 * Hardcoding this value reduces runtime and code complexity overhead.
252 * Most modules require ≤ 3 buffers; 5 is considered safe.
253 *
254 * @remarks
255 * - rgerhards, 2010-06-24
256 */
257 #define CONF_OMOD_NUMSTRINGS_MAXSIZE 5
258
259 /**
260 * @brief Default number of messages per multisub structure.
261 */
262 #define CONF_NUM_MULTISUB 1024
263
264
265 /* ############################################################# *
266 * # End Config Settings # *
267 * ############################################################# */
268
269 /* make sure we uses consistent macros, no matter what the
270 * platform gives us.
271 */
272 #undef LOG_EMERG
273 #undef LOG_ALERT
274 #undef LOG_CRIT
275 #undef LOG_ERR
276 #undef LOG_WARNING
277 #undef LOG_NOTICE
278 #undef LOG_INFO
279 #undef LOG_DEBUG
280
281 #undef LOG_KERN
282 #undef LOG_USER
283 #undef LOG_MAIL
284 #undef LOG_DAEMON
285 #undef LOG_AUTH
286 #undef LOG_SYSLOG
287 #undef LOG_LPR
288 #undef LOG_NEWS
289 #undef LOG_UUCP
290 #undef LOG_CRON
291 #undef LOG_AUTHPRIV
292 #undef LOG_FTP
293 #undef LOG_LOCAL0
294 #undef LOG_LOCAL1
295 #undef LOG_LOCAL2
296 #undef LOG_LOCAL3
297 #undef LOG_LOCAL4
298 #undef LOG_LOCAL5
299 #undef LOG_LOCAL6
300 #undef LOG_LOCAL7
301 #undef LOG_FAC_INVLD
302 #undef LOG_INVLD
303 #undef LOG_NFACILITIES
304 /**
305 * @brief Number of facility codes, including special invalid facility.
306 *
307 * This value covers the 24 standard syslog facilities plus
308 * one extra slot for the special “invld” facility.
309 */
310 #define LOG_NFACILITIES (24 + 1)
311
312 /**
313 * @brief Maximum supported PRI (priority) value.
314 *
315 * The highest valid PRI according to RFC 3164 and RFC 5424.
316 */
317 #define LOG_MAXPRI 191
318 #undef LOG_MAKEPRI
319 #define LOG_PRI_INVLD (LOG_INVLD | LOG_DEBUG)
320 /* PRI is invalid --> special "invld.=debug" PRI code (rsyslog-specific) */
321
322 #define LOG_EMERG 0 /* system is unusable */
323 #define LOG_ALERT 1 /* action must be taken immediately */
324 #define LOG_CRIT 2 /* critical conditions */
325 #define LOG_ERR 3 /* error conditions */
326 #define LOG_WARNING 4 /* warning conditions */
327 #define LOG_NOTICE 5 /* normal but significant condition */
328 #define LOG_INFO 6 /* informational */
329 #define LOG_DEBUG 7 /* debug-level messages */
330
331 #define LOG_KERN (0 << 3) /* kernel messages */
332 #define LOG_USER (1 << 3) /* random user-level messages */
333 #define LOG_MAIL (2 << 3) /* mail system */
334 #define LOG_DAEMON (3 << 3) /* system daemons */
335 #define LOG_AUTH (4 << 3) /* security/authorization messages */
336 #define LOG_SYSLOG (5 << 3) /* messages generated internally by syslogd */
337 #define LOG_LPR (6 << 3) /* line printer subsystem */
338 #define LOG_NEWS (7 << 3) /* network news subsystem */
339 #define LOG_UUCP (8 << 3) /* UUCP subsystem */
340 #if !defined(LOG_CRON)
341 #define LOG_CRON (9 << 3) /* clock daemon */
342 #endif
343 #define LOG_AUTHPRIV (10 << 3) /* security/authorization messages (private) */
344 #define LOG_FTP (11 << 3) /* ftp daemon */
345 #if defined(_AIX) /* AIXPORT : These are necessary for AIX */
346 #define LOG_ASO (12 << 3) /* Active System Optimizer. Reserved for internal use */
347 #define LOG_CAA (15 << 3) /* Cluster aware AIX subsystem */
348 #endif
349 #define LOG_LOCAL0 (16 << 3) /* reserved for local use */
350 #define LOG_LOCAL1 (17 << 3) /* reserved for local use */
351 #define LOG_LOCAL2 (18 << 3) /* reserved for local use */
352 #define LOG_LOCAL3 (19 << 3) /* reserved for local use */
353 #define LOG_LOCAL4 (20 << 3) /* reserved for local use */
354 #define LOG_LOCAL5 (21 << 3) /* reserved for local use */
355 #define LOG_LOCAL6 (22 << 3) /* reserved for local use */
356 #define LOG_LOCAL7 (23 << 3) /* reserved for local use */
357 #define LOG_FAC_INVLD 24
358 #define LOG_INVLD (LOG_FAC_INVLD << 3) /* invalid facility/PRI code */
359
360 /* we need to evaluate our argument only once, as otherwise we may
361 * have side-effects (this was seen in some version).
362 * Note: I know that "static inline" is not the right thing from a C99
363 * PoV, but some environments treat, even in C99 mode, compile
364 * non-static inline into the source even if not defined as "extern". This
365 * obviously results in linker errors. Using "static inline" as below together
366 * with "__attribute__((unused))" works in all cases. Note also that we
367 * cannot work around this in pri2fac, as we would otherwise need to evaluate
368 * pri more than once.
369 */
370 static inline syslog_pri_t __attribute__((unused)) pri2fac(const syslog_pri_t pri) {
371 unsigned fac = pri >> 3;
372 return (fac > 23) ? LOG_FAC_INVLD : fac;
373 }
374 #define pri2sev(pri) ((pri) & 0x07)
375
376 /* the rsyslog core provides information about present feature to plugins
377 * asking it. Below are feature-test macros which must be used to query
378 * features. Note that this must be powers of two, so that multiple queries
379 * can be combined. -- rgerhards, 2009-04-27
380 */
381 #define CORE_FEATURE_BATCHING 1
382 /* for additional features, define as powers of two (e.g. 'CORE_FEATURE_whatever 2', then 4, ...) */
383
384 #ifndef _PATH_CONSOLE
385 #define _PATH_CONSOLE "/dev/console"
386 #endif
387
388
389 /**
390 * @enum rsRetVal_
391 * @brief Return values used throughout the runtime API.
392 *
393 * The error codes below are originally borrowed from liblogging. Values up to
394 * -2999 are reserved for future expansion.
395 */
396 enum rsRetVal_ {
397 /* the first two define are for errmsg.logError(), so that we can use the rsRetVal
398 * as an rsyslog error code. -- rgerhards, 20080-06-27
399 */
400 RS_RET_NO_ERRCODE = -1, /**< RESERVED for NO_ERRCODE errmsg.logError status name */
401 RS_RET_INCLUDE_ERRNO = 1073741824, /* 2**30 - do NOT use error codes above this! */
402 /* begin regular error codes */
403 RS_RET_NOT_IMPLEMENTED = -7, /**< implementation is missing (probably internal error or lazyness ;)) */
404 RS_RET_OUT_OF_MEMORY = -6, /**< memory allocation failed */
405 RS_RET_PROVIDED_BUFFER_TOO_SMALL = -50, /*< the caller provided a buffer, but the called function sees
406 the size of this buffer is too small - operation not carried out */
407 RS_RET_FILE_TRUNCATED = -51, /**< (input) file was truncated, not an error but a status */
408 RS_RET_TRUE = -3, /**< to indicate a true state (can be used as TRUE, legacy) */
409 RS_RET_FALSE = -2, /**< to indicate a false state (can be used as FALSE, legacy) */
410 RS_RET_NO_IRET = -8, /**< This is a trick for the debuging system - it means no iRet is provided */
411 RS_RET_VALIDATION_RUN = -9, /**< indicates a (config) validation run, processing not carried out */
412 RS_RET_ERR = -3000, /**< generic failure */
413 RS_TRUNCAT_TOO_LARGE = -3001, /**< truncation operation where too many chars should be truncated */
414 RS_RET_FOUND_AT_STRING_END = -3002, /**< some value found, but at the last pos of string */
415 RS_RET_NOT_FOUND = -3003, /**< some requested value not found */
416 RS_RET_MISSING_TRAIL_QUOTE = -3004, /**< an expected trailing quote is missing */
417 RS_RET_NO_DIGIT = -3005, /**< an digit was expected, but none found (mostly parsing) */
418 RS_RET_NO_MORE_DATA = -3006, /**< end of data, e.g. end of string during parsing or EAGAIN API state */
419 RS_RET_INVALID_IP = -3007, /**< invalid ip found where valid was expected */
420 RS_RET_OBJ_CREATION_FAILED = -3008, /**< the creation of an object failed (no details available) */
421 RS_RET_INOTIFY_INIT_FAILED = -3009,
422 /**< the initialization of an inotify instance failed (no details available) */
423 RS_RET_FEN_INIT_FAILED = -3010, /**< the initialization of a fen instance failed (no details available) */
424 RS_RET_PARAM_ERROR = -1000, /**< invalid parameter in call to function */
425 RS_RET_MISSING_INTERFACE = -1001, /**< interface version mismatch, required missing */
426 RS_RET_INVALID_CORE_INTERFACE = -1002, /**< interface provided by host invalid, can not be used */
427 RS_RET_ENTRY_POINT_NOT_FOUND = -1003, /**< a requested entry point was not found */
428 RS_RET_MODULE_ENTRY_POINT_NOT_FOUND = -1004, /**< a entry point requested from a module was not present in it */
429 RS_RET_OBJ_NOT_AVAILABLE = -1005,
430 /**< something could not be completed because the required object is not available*/
431 RS_RET_LOAD_ERROR = -1006, /**< we had an error loading the object/interface and can not continue */
432 RS_RET_MODULE_STILL_REFERENCED = -1007,
433 /**< module could not be unloaded because it still is referenced by someone */
434 RS_RET_OBJ_UNKNOWN = -1008, /**< object is unknown where required */
435 RS_RET_OBJ_NOT_REGISTERED = -1009, /**< tried to unregister an object that is not registered */
436 /* return states for config file processing */
437 RS_RET_NONE = -2000, /**< some value is not available - not necessarily an error */
438 RS_RET_CONFLINE_UNPROCESSED = -2001, /**< config line was not processed, pass to other module */
439 RS_RET_DISCARDMSG = -2002, /**< discard message (no error state, processing request!) */
440 RS_RET_INCOMPATIBLE = -2003, /**< function not compatible with requested feature */
441 RS_RET_NOENTRY = -2004, /**< do not create an entry for (whatever) - not necessary an error */
442 RS_RET_NO_SQL_STRING = -2005, /**< string is not suitable for use as SQL */
443 RS_RET_DISABLE_ACTION = -2006, /**< action requests that it be disabled */
444 RS_RET_SUSPENDED = -2007, /**< something was suspended, not neccesarily an error */
445 RS_RET_RQD_TPLOPT_MISSING = -2008, /**< a required template option is missing */
446 RS_RET_INVALID_VALUE = -2009, /**< some value is invalid (e.g. user-supplied data) */
447 RS_RET_INVALID_INT = -2010, /**< invalid integer */
448 RS_RET_INVALID_CMD = -2011, /**< invalid command */
449 RS_RET_VAL_OUT_OF_RANGE = -2012, /**< value out of range */
450 RS_RET_FOPEN_FAILURE = -2013, /**< failure during fopen, for example file not found - see errno */
451 RS_RET_END_OF_LINKEDLIST = -2014, /**< end of linked list, not an error, but a status */
452 RS_RET_CHAIN_NOT_PERMITTED = -2015, /**< chaining (e.g. of config command handlers) not permitted */
453 RS_RET_INVALID_PARAMS = -2016, /**< supplied parameters are invalid */
454 RS_RET_EMPTY_LIST = -2017, /**< linked list is empty */
455 RS_RET_FINISHED = -2018, /**< some opertion is finished, not an error state */
456 RS_RET_INVALID_SOURCE = -2019, /**< source (address) invalid for some reason */
457 RS_RET_ADDRESS_UNKNOWN = -2020, /**< an address is unknown - not necessarily an error */
458 RS_RET_MALICIOUS_ENTITY = -2021, /**< there is an malicious entity involved */
459 RS_RET_NO_KERNEL_LOGSRC = -2022, /**< no source for kernel logs can be obtained */
460 RS_RET_TCP_SEND_ERROR = -2023, /**< error during TCP send process */
461 RS_RET_GSS_SEND_ERROR = -2024, /**< error during GSS (via TCP) send process */
462 RS_RET_TCP_SOCKCREATE_ERR = -2025, /**< error during creation of TCP socket */
463 RS_RET_GSS_SENDINIT_ERROR = -2024, /**< error during GSS (via TCP) send initialization process */
464 RS_RET_EOF = -2026, /**< end of file reached, not necessarily an error */
465 RS_RET_IO_ERROR = -2027, /**< some kind of IO error happened */
466 RS_RET_INVALID_OID = -2028, /**< invalid object ID */
467 RS_RET_INVALID_HEADER = -2029, /**< invalid header */
468 RS_RET_INVALID_HEADER_VERS = -2030, /**< invalid header version */
469 RS_RET_INVALID_DELIMITER = -2031, /**< invalid delimiter, e.g. between params */
470 RS_RET_INVALID_PROPFRAME = -2032, /**< invalid framing in serialized property */
471 RS_RET_NO_PROPLINE = -2033, /**< line is not a property line */
472 RS_RET_INVALID_TRAILER = -2034, /**< invalid trailer */
473 RS_RET_VALUE_TOO_LOW = -2035, /**< a provided value is too low */
474 RS_RET_FILE_PREFIX_MISSING = -2036, /**< a required file prefix (parameter?) is missing */
475 RS_RET_INVALID_HEADER_RECTYPE = -2037, /**< invalid record type in header or invalid header */
476 RS_RET_QTYPE_MISMATCH = -2038, /**< different qType when reading back a property type */
477 RS_RET_NO_FILE_ACCESS = -2039, /**< covers EACCES error on file open() */
478 RS_RET_FILE_NOT_FOUND = -2040, /**< file not found */
479 RS_RET_TIMED_OUT = -2041, /**< timeout occurred (not necessarily an error) */
480 RS_RET_QSIZE_ZERO = -2042, /**< queue size is zero where this is not supported */
481 RS_RET_ALREADY_STARTING = -2043, /**< something (a thread?) is already starting - not necessarily an error */
482 RS_RET_NO_MORE_THREADS = -2044, /**< no more threads available, not necessarily an error */
483 RS_RET_NO_FILEPREFIX = -2045, /**< file prefix is not specified where one is needed */
484 RS_RET_CONFIG_ERROR = -2046, /**< there is a problem with the user-provided config settigs */
485 RS_RET_OUT_OF_DESRIPTORS = -2047, /**< a descriptor table's space has been exhausted */
486 RS_RET_NO_DRIVERS = -2048, /**< a required drivers missing */
487 RS_RET_NO_DRIVERNAME = -2049, /**< driver name missing where one was required */
488 RS_RET_EOS = -2050, /**< end of stream (of whatever) */
489 RS_RET_SYNTAX_ERROR = -2051, /**< syntax error, eg. during parsing */
490 RS_RET_INVALID_OCTAL_DIGIT = -2052, /**< invalid octal digit during parsing */
491 RS_RET_INVALID_HEX_DIGIT = -2053, /**< invalid hex digit during parsing */
492 RS_RET_INTERFACE_NOT_SUPPORTED = -2054, /**< interface not supported */
493 RS_RET_OUT_OF_STACKSPACE = -2055, /**< a stack data structure is exhausted and can not be grown */
494 RS_RET_STACK_EMPTY = -2056, /**< a pop was requested on a stack, but the stack was already empty */
495 RS_RET_INVALID_VMOP = -2057, /**< invalid virtual machine instruction */
496 RS_RET_INVALID_VAR = -2058, /**< a var or its content is unsuitable, eg. VARTYPE_NONE */
497 RS_RET_INVALID_NUMBER = -2059, /**< number invalid during parsing */
498 RS_RET_NOT_A_NUMBER = -2060, /**< e.g. conversion impossible because the string is not a number */
499 RS_RET_OBJ_ALREADY_REGISTERED = -2061, /**< object (name) is already registered */
500 RS_RET_OBJ_REGISTRY_OUT_OF_SPACE = -2062, /**< the object registry has run out of space */
501 RS_RET_HOST_NOT_PERMITTED = -2063, /**< a host is not permitted to perform an action it requested */
502 RS_RET_MODULE_LOAD_ERR = -2064, /**< module could not be loaded */
503 RS_RET_MODULE_LOAD_ERR_PATHLEN = -2065, /**< module could not be loaded - path to long */
504 RS_RET_MODULE_LOAD_ERR_DLOPEN = -2066, /**< module could not be loaded - problem in dlopen() */
505 RS_RET_MODULE_LOAD_ERR_NO_INIT = -2067, /**< module could not be loaded - init() missing */
506 RS_RET_MODULE_LOAD_ERR_INIT_FAILED = -2068, /**< module could not be loaded - init() failed */
507 RS_RET_NO_SOCKET = -2069, /**< socket could not be obtained or was not provided */
508 RS_RET_SMTP_ERROR = -2070, /**< error during SMTP transation */
509 RS_RET_MAIL_NO_TO = -2071, /**< recipient for mail destination is missing */
510 RS_RET_MAIL_NO_FROM = -2072, /**< sender for mail destination is missing */
511 RS_RET_INVALID_PRI = -2073, /**< PRI value is invalid */
512 RS_RET_MALICIOUS_HNAME = -2074, /**< remote peer is trying malicious things with its hostname */
513 RS_RET_INVALID_HNAME = -2075, /**< remote peer's hostname invalid or unobtainable */
514 RS_RET_INVALID_PORT = -2076, /**< invalid port value */
515 RS_RET_COULD_NOT_BIND = -2077, /**< could not bind socket, defunct */
516 RS_RET_GNUTLS_ERR = -2078, /**< (unexpected) error in GnuTLS call */
517 RS_RET_MAX_SESS_REACHED = -2079, /**< max nbr of sessions reached, can not create more */
518 RS_RET_MAX_LSTN_REACHED = -2080, /**< max nbr of listeners reached, can not create more */
519 RS_RET_INVALID_DRVR_MODE = -2081, /**< tried to set mode not supported by driver */
520 RS_RET_DRVRNAME_TOO_LONG = -2082, /**< driver name too long - should never happen */
521 RS_RET_TLS_HANDSHAKE_ERR = -2083, /**< TLS handshake failed */
522 RS_RET_TLS_CERT_ERR = -2084, /**< generic TLS certificate error */
523 RS_RET_TLS_NO_CERT = -2085, /**< no TLS certificate available where one was expected */
524 RS_RET_VALUE_NOT_SUPPORTED = -2086, /**< a provided value is not supported */
525 RS_RET_VALUE_NOT_IN_THIS_MODE = -2087, /**< a provided value is invalid for the curret mode */
526 RS_RET_INVALID_FINGERPRINT = -2088, /**< a fingerprint is not valid for this use case */
527 RS_RET_CONNECTION_ABORTREQ = -2089, /**< connection was abort requested due to previous error */
528 RS_RET_CERT_INVALID = -2090, /**< a x509 certificate failed validation */
529 RS_RET_CERT_INVALID_DN = -2091, /**< distinguised name in x509 certificate is invalid (e.g. wrong escaping) */
530 RS_RET_CERT_EXPIRED = -2092, /**< we are past a x.509 cert's expiration time */
531 RS_RET_CERT_NOT_YET_ACTIVE = -2094, /**< x.509 cert's activation time not yet reached */
532 RS_RET_SYS_ERR = -2095, /**< system error occurred (e.g. time() returned -1, quite unexpected) */
533 RS_RET_FILE_NO_STAT = -2096, /**< can not stat() a file */
534 RS_RET_FILE_TOO_LARGE = -2097, /**< a file is larger than permitted */
535 RS_RET_INVALID_WILDCARD = -2098, /**< a wildcard entry is invalid */
536 RS_RET_CLOSED = -2099, /**< connection was closed */
537 RS_RET_RETRY = -2100, /**< call should be retried (e.g. EGAIN on recv) */
538 RS_RET_GSS_ERR = -2101, /**< generic error occurred in GSSAPI subsystem */
539 RS_RET_CERTLESS = -2102, /**< state: we run without machine cert (this may be OK) */
540 RS_RET_NO_ACTIONS = -2103, /**< no active actions are configured (no output will be created) */
541 RS_RET_CONF_FILE_NOT_FOUND = -2104, /**< config file or directory not found */
542 RS_RET_QUEUE_FULL = -2105, /**< queue is full, operation could not be completed */
543 RS_RET_ACCEPT_ERR = -2106, /**< error during accept() system call */
544 RS_RET_INVLD_TIME = -2107, /**< invalid timestamp (e.g. could not be parsed) */
545 RS_RET_NO_ZIP = -2108, /**< ZIP functionality is not present */
546 RS_RET_CODE_ERR = -2109, /**< program code (internal) error */
547 RS_RET_FUNC_NO_LPAREN = -2110, /**< left parenthesis missing after function call (rainerscript) */
548 RS_RET_FUNC_MISSING_EXPR = -2111, /**< no expression after comma in function call (rainerscript) */
549 RS_RET_INVLD_NBR_ARGUMENTS = -2112, /**< invalid number of arguments for function call (rainerscript) */
550 RS_RET_INVLD_FUNC = -2113, /**< invalid function name for function call (rainerscript) */
551 RS_RET_DUP_FUNC_NAME = -2114, /**< duplicate function name (rainerscript) */
552 RS_RET_UNKNW_FUNC = -2115, /**< unkown function name (rainerscript) */
553 RS_RET_ERR_RLIM_NOFILE = -2116, /**< error setting max. nbr open files process limit */
554 RS_RET_ERR_CREAT_PIPE = -2117, /**< error during pipe creation */
555 RS_RET_ERR_FORK = -2118, /**< error during fork() */
556 RS_RET_ERR_WRITE_PIPE = -2119, /**< error writing to pipe */
557 RS_RET_RSCORE_TOO_OLD = -2120, /**< rsyslog core is too old for ... (eg this plugin) */
558 RS_RET_DEFER_COMMIT = -2121, /**< output plugin status: not yet committed (an OK state!) */
559 RS_RET_PREVIOUS_COMMITTED = -2122, /**< output plugin status: previous record was committed (an OK state!) */
560 RS_RET_ACTION_FAILED = -2123, /**< action failed and is now suspended */
561 RS_RET_NON_SIZELIMITCMD = -2125, /**< size limit for file defined, but no size limit command given */
562 RS_RET_SIZELIMITCMD_DIDNT_RESOLVE = -2126, /**< size limit command did not resolve situation */
563 RS_RET_STREAM_DISABLED = -2127, /**< a file has been disabled (e.g. by size limit restriction) */
564 RS_RET_FILENAME_INVALID = -2140, /**< filename invalid, not found, no access, ... */
565 RS_RET_ZLIB_ERR = -2141, /**< error during zlib call */
566 RS_RET_VAR_NOT_FOUND = -2142, /**< variable not found */
567 RS_RET_EMPTY_MSG = -2143, /**< provided (raw) MSG is empty */
568 RS_RET_PEER_CLOSED_CONN = -2144, /**< remote peer closed connection (information, no error) */
569 RS_RET_ERR_OPEN_KLOG = -2145, /**< error opening or reading the kernel log socket */
570 RS_RET_ERR_AQ_CONLOG = -2146, /**< error aquiring console log (on solaris) */
571 RS_RET_ERR_DOOR = -2147, /**< some problems with handling the Solaris door functionality */
572 RS_RET_NO_SRCNAME_TPL = -2150, /**< sourcename template was not specified where one was needed
573 (omudpspoof spoof addr) */
574 RS_RET_HOST_NOT_SPECIFIED = -2151, /**< (target) host was not specified where it was needed */
575 RS_RET_ERR_LIBNET_INIT = -2152, /**< error initializing libnet, e.g. because not running as root */
576 RS_RET_FORCE_TERM = -2153, /**< thread was forced to terminate by bShallShutdown, a state, not an error */
577 RS_RET_RULES_QUEUE_EXISTS = -2154, /**< we were instructed to create a new
578 ruleset queue, but one already exists */
579 RS_RET_NO_CURR_RULESET = -2155, /**< no current ruleset exists (but one is required) */
580 RS_RET_NO_MSG_PASSING = -2156,
581 /*< output module interface parameter passing mode "MSG" is not available but required */
582 RS_RET_RULESET_NOT_FOUND = -2157, /**< a required ruleset could not be found */
583 RS_RET_NO_RULESET = -2158, /**< no ruleset name as specified where one was needed */
584 RS_RET_PARSER_NOT_FOUND = -2159, /**< parser with the specified name was not found */
585 RS_RET_COULD_NOT_PARSE = -2160, /**< (this) parser could not parse the message (no error, means try next one) */
586 RS_RET_EINTR = -2161, /**< EINTR occurred during a system call (not necessarily an error) */
587 RS_RET_ERR_EPOLL = -2162, /**< epoll() returned with an unexpected error code */
588 RS_RET_ERR_EPOLL_CTL = -2163, /**< epol_ctll() returned with an unexpected error code */
589 RS_RET_TIMEOUT = -2164, /**< timeout occurred during operation */
590 RS_RET_RCV_ERR = -2165, /**< error occurred during socket rcv operation */
591 RS_RET_NO_SOCK_CONFIGURED = -2166, /**< no socket (name) was configured where one is required */
592 RS_RET_CONF_NOT_GLBL = -2167, /**< $Begin not in global scope */
593 RS_RET_CONF_IN_GLBL = -2168, /**< $End when in global scope */
594 RS_RET_CONF_INVLD_END = -2169, /**< $End for wrong conf object (probably nesting error) */
595 RS_RET_CONF_INVLD_SCOPE = -2170,
596 /*< config statement not valid in current scope (e.g. global stmt in action block) */
597 RS_RET_CONF_END_NO_ACT = -2171, /**< end of action block, but no actual action specified */
598 RS_RET_NO_LSTN_DEFINED = -2172, /**< no listener defined (e.g. inside an input module) */
599 RS_RET_EPOLL_CR_FAILED = -2173, /**< epoll_create() failed */
600 RS_RET_EPOLL_CTL_FAILED = -2174, /**< epoll_ctl() failed */
601 RS_RET_INTERNAL_ERROR = -2175, /**< rsyslogd internal error, unexpected code path reached */
602 RS_RET_ERR_CRE_AFUX = -2176, /**< error creating AF_UNIX socket (and binding it) */
603 RS_RET_RATE_LIMITED = -2177, /**< some messages discarded due to exceeding a rate limit */
604 RS_RET_ERR_HDFS_WRITE = -2178, /**< error writing to HDFS */
605 RS_RET_ERR_HDFS_OPEN = -2179, /**< error during hdfsOpen (e.g. file does not exist) */
606 RS_RET_FILE_NOT_SPECIFIED = -2180, /**< file name not configured where this was required */
607 RS_RET_ERR_WRKDIR = -2181, /**< problems with the rsyslog working directory */
608 RS_RET_WRN_WRKDIR = -2182, /**< correctable problems with the rsyslog working directory */
609 RS_RET_ERR_QUEUE_EMERGENCY = -2183, /**< some fatal error caused queue to switch to emergency mode */
610 RS_RET_OUTDATED_STMT = -2184, /**< some outdated statement/functionality is being used in conf file */
611 RS_RET_MISSING_WHITESPACE = -2185, /**< whitespace is missing in some config construct */
612 RS_RET_OK_WARN = -2186, /**< config part: everything was OK, but a warning message was emitted */
613
614 RS_RET_INVLD_CONF_OBJ = -2200, /**< invalid config object (e.g. $Begin conf statement) */
615 /* UNUSED, WAS; RS_RET_ERR_LIBEE_INIT = -2201, < cannot obtain libee ctx */
616 RS_RET_ERR_LIBLOGNORM_INIT = -2202, /**< cannot obtain liblognorm ctx */
617 RS_RET_ERR_LIBLOGNORM_SAMPDB_LOAD = -2203, /**< liblognorm sampledb load failed */
618 RS_RET_CMD_GONE_AWAY = -2204, /**< config directive existed, but no longer supported */
619 RS_RET_ERR_SCHED_PARAMS = -2205, /**< there is a problem with configured thread scheduling params */
620 RS_RET_SOCKNAME_MISSING = -2206, /**< no socket name configured where one is required */
621 RS_RET_CONF_PARSE_ERROR = -2207, /**< (fatal) error parsing config file */
622 RS_RET_CONF_RQRD_PARAM_MISSING = -2208, /**< required parameter in config object is missing */
623 RS_RET_MOD_UNKNOWN = -2209, /**< module (config name) is unknown */
624 RS_RET_CONFOBJ_UNSUPPORTED = -2210, /**< config objects (v6 conf) are not supported here */
625 RS_RET_MISSING_CNFPARAMS = -2211, /**< missing configuration parameters */
626 RS_RET_NO_LISTNERS = -2212, /**< module loaded, but no listeners are defined */
627 RS_RET_INVLD_PROTOCOL = -2213, /**< invalid protocol specified in config file */
628 RS_RET_CNF_INVLD_FRAMING = -2214, /**< invalid framing specified in config file */
629 RS_RET_LEGA_ACT_NOT_SUPPORTED = -2215, /**< the module (no longer) supports legacy action syntax */
630 RS_RET_MAX_OMSR_REACHED = -2216, /**< max nbr of string requests reached, not supported by core */
631 RS_RET_UID_MISSING = -2217, /**< a user id is missing (but e.g. a password provided) */
632 RS_RET_DATAFAIL = -2218, /**< data passed to action caused failure */
633 /* reserved for pre-v6.5 */
634 RS_RET_DUP_PARAM = -2220, /**< config parameter is given more than once */
635 RS_RET_MODULE_ALREADY_IN_CONF = -2221, /**< module already in current configuration */
636 RS_RET_PARAM_NOT_PERMITTED = -2222, /**< legacy parameter no longer permitted (usally already set by v2) */
637 RS_RET_NO_JSON_PASSING = -2223, /**< rsyslog core does not support JSON-passing plugin API */
638 RS_RET_MOD_NO_INPUT_STMT = -2224, /**< (input) module does not support input() statement */
639 RS_RET_NO_CEE_MSG = -2225, /**< the message being processed is NOT CEE-enhanced */
640
641 /**** up to 2290 is reserved for v6 use ****/
642 RS_RET_RELP_ERR = -2291, /**<< error in RELP processing */
643 /**** up to 3000 is reserved for c7 use ****/
644 RS_RET_JNAME_NO_ROOT = -2301, /**< root element is missing in JSON path */
645 RS_RET_JNAME_INVALID = -2302, /**< JSON path is invalid */
646 RS_RET_JSON_PARSE_ERR = -2303, /**< we had a problem parsing JSON (or extra data) */
647 RS_RET_BSD_BLOCKS_UNSUPPORTED = -2304, /**< BSD-style config blocks are no longer supported */
648 RS_RET_JNAME_NOTFOUND = -2305, /**< JSON name not found (does not exist) */
649 RS_RET_INVLD_SETOP = -2305, /**< invalid variable set operation, incompatible type */
650 RS_RET_RULESET_EXISTS = -2306, /**< ruleset already exists */
651 RS_RET_DEPRECATED = -2307, /**< deprecated functionality is used */
652 RS_RET_DS_PROP_SEQ_ERR = -2308, /**< property sequence error deserializing object */
653 RS_RET_INVLD_PROP = -2309, /**< property name error (unknown name) */
654 RS_RET_NO_RULEBASE = -2310, /**< mmnormalize: rulebase can not be found or otherwise invalid */
655 RS_RET_INVLD_MODE = -2311, /**< invalid mode specified in configuration */
656 RS_RET_INVLD_ANON_BITS = -2312, /**< mmanon: invalid number of bits to anonymize specified */
657 RS_RET_REPLCHAR_IGNORED = -2313, /**< mmanon: replacementChar parameter is ignored */
658 RS_RET_SIGPROV_ERR = -2320, /**< error in signature provider */
659 RS_RET_CRYPROV_ERR = -2321, /**< error in cryptography encryption provider */
660 RS_RET_EI_OPN_ERR = -2322, /**< error opening an .encinfo file */
661 RS_RET_EI_NO_EXISTS = -2323, /**< .encinfo file does not exist (status, not necessarily error!)*/
662 RS_RET_EI_WR_ERR = -2324, /**< error writing an .encinfo file */
663 RS_RET_EI_INVLD_FILE = -2325, /**< header indicates the file is no .encinfo file */
664 RS_RET_CRY_INVLD_ALGO = -2326, /**< user specified invalid (unkonwn) crypto algorithm */
665 RS_RET_CRY_INVLD_MODE = -2327, /**< user specified invalid (unkonwn) crypto mode */
666 RS_RET_QUEUE_DISK_NO_FN = -2328, /**< disk queue configured, but filename not set */
667 RS_RET_CA_CERT_MISSING = -2329, /**< a CA cert is missing where one is required (e.g. TLS) */
668 RS_RET_CERT_MISSING = -2330, /**< a cert is missing where one is required (e.g. TLS) */
669 RS_RET_CERTKEY_MISSING = -2331, /**< a cert (private) key is missing where one is required (e.g. TLS) */
670 RS_RET_CRL_MISSING = -2332, /**< a CRL file is missing but not required (e.g. TLS) */
671 RS_RET_CRL_INVALID = -2333, /**< a CRL file PEM file failed validation */
672 RS_RET_CERT_REVOKED = -2334, /**< a certificate has been revoked */
673 RS_RET_STRUC_DATA_INVLD = -2349, /**< structured data is malformed */
674
675 /* up to 2350 reserved for 7.4 */
676 RS_RET_QUEUE_CRY_DISK_ONLY = -2351, /**< crypto provider only supported for disk-associated queues */
677 RS_RET_NO_DATA = -2352, /**< file has no data; more a state than a real error */
678 RS_RET_RELP_AUTH_FAIL = -2353, /**< RELP peer authentication failed */
679 RS_RET_ERR_UDPSEND = -2354, /**< sending msg via UDP failed */
680 RS_RET_LAST_ERRREPORT = -2355, /**< module does not emit more error messages as limit is reached */
681 RS_RET_READ_ERR = -2356, /**< read error occurred (file i/o) */
682 RS_RET_CONF_PARSE_WARNING = -2357, /**< warning parsing config file */
683 RS_RET_CONF_WRN_FULLDLY_BELOW_HIGHWTR = -2358, /**< warning queue full delay mark below high wtr mark */
684 RS_RET_RESUMED = -2359, /**< status: action was resumed (used for reporting) */
685 RS_RET_RELP_NO_TLS = -2360, /**< librel does not support TLS (but TLS requested) */
686 RS_RET_STATEFILE_WRONG_FNAME = -2361, /**< state file is for wrong file */
687 RS_RET_NAME_INVALID = -2362, /**< invalid name (in RainerScript) */
688
689 /* up to 2400 reserved for 7.5 & 7.6 */
690 RS_RET_INVLD_OMOD = -2400, /**< invalid output module, does not provide proper interfaces */
691 RS_RET_INVLD_INTERFACE_INPUT = -2401, /**< invalid value for "interface.input" parameter (ext progs) */
692 RS_RET_PARSER_NAME_EXISTS = -2402, /**< parser name already exists */
693 RS_RET_MOD_NO_PARSER_STMT = -2403, /**< (parser) module does not support parser() statement */
694
695 /* up to 2419 reserved for 8.4.x */
696 RS_RET_IMFILE_WILDCARD = -2420, /**< imfile file name contains wildcard, which may be problematic */
697 RS_RET_RELP_NO_TLS_AUTH = -2421, /**< librel does not support TLS authentication (but was requested) */
698 RS_RET_KAFKA_ERROR = -2422, /**< error reported by Apache Kafka subsystem. See message for details. */
699 RS_RET_KAFKA_NO_VALID_BROKERS = -2423, /**< no valid Kafka brokers configured/available */
700 RS_RET_KAFKA_PRODUCE_ERR = -2424, /**< error during Kafka produce function */
701 RS_RET_CONF_PARAM_INVLD = -2425, /**< config parameter is invalid */
702 RS_RET_KSI_ERR = -2426, /**< error in KSI subsystem */
703 RS_RET_ERR_LIBLOGNORM = -2427, /**< cannot obtain liblognorm ctx */
704 RS_RET_CONC_CTRL_ERR = -2428, /**< error in lock/unlock/condition/concurrent-modification operation */
705 RS_RET_SENDER_GONE_AWAY = -2429, /**< warning: sender not seen for configured amount of time */
706 RS_RET_SENDER_APPEARED = -2430, /**< info: new sender appeared */
707 RS_RET_FILE_ALREADY_IN_TABLE = -2431, /**< in imfile: table already contains to be added file */
708 RS_RET_ERR_DROP_PRIV = -2432, /**< error droping privileges */
709 RS_RET_FILE_OPEN_ERROR = -2433, /**< error other than "not found" occurred during open() */
710 RS_RET_RENAME_TMP_QI_ERROR = -2435, /**< renaming temporary .qi file failed */
711 RS_RET_ERR_SETENV = -2436, /**< error setting an environment variable */
712 RS_RET_DIR_CHOWN_ERROR = -2437, /**< error during chown() */
713 RS_RET_JSON_UNUSABLE = -2438, /**< JSON object is NULL or otherwise unusable */
714 RS_RET_OPERATION_STATUS = -2439, /**< operational status (info) message, no error */
715 RS_RET_UDP_MSGSIZE_TOO_LARGE = -2440, /**< a message is too large to be sent via UDP */
716 RS_RET_NON_JSON_PROP = -2441, /**< a non-json property id is provided where a json one is requried */
717 RS_RET_NO_TZ_SET = -2442, /**< system env var TZ is not set (status msg) */
718 RS_RET_FS_ERR = -2443, /**< file-system error */
719 RS_RET_POLL_ERR = -2444, /**< error in poll() system call */
720 RS_RET_OVERSIZE_MSG = -2445, /**< message is too long (above configured max) */
721 RS_RET_TLS_KEY_ERR = -2446, /**< TLS KEY has problems */
722 RS_RET_RABBITMQ_CONN_ERR = -2447, /**< RabbitMQ Connection error */
723 RS_RET_RABBITMQ_LOGIN_ERR = -2448, /**< RabbitMQ Login error */
724 RS_RET_RABBITMQ_CHANNEL_ERR = -2449, /**< RabbitMQ Connection error */
725 RS_RET_NO_WRKDIR_SET = -2450, /**< working directory not set, but desired by functionality */
726 RS_RET_ERR_QUEUE_FN_DUP = -2451, /**< duplicate queue file name */
727 RS_RET_REDIS_ERROR = -2452, /**< redis-specific error. See message foe details. */
728 RS_RET_REDIS_AUTH_FAILED = -2453, /**< redis authentication failure */
729 RS_RET_FAUP_INIT_OPTIONS_FAILED = -2454, /**< could not initialize faup options */
730 RS_RET_LIBCAPNG_ERR = -2455, /**< error during dropping the capabilities */
731 RS_RET_NET_CONN_ABORTED = -2456, /**< error during dropping the capabilities */
732 RS_RET_PROGRAM_ERROR = -2457, /**< rsyslogd internal error, like tried NULL-ptr access */
733 RS_RET_DEBUG = -2458, /**< status messages primarily meant for debugging, no error */
734 RS_RET_TLS_BASEINIT_FAIL = -2459, /**< Basic TLS initialization step failed */
735 RS_RET_TLS_ERR_SYSCALL = -2460, /**< TLS lib had problem with syscall */
736 RS_RET_WARN_NO_SENDER_STATS = -2461, /**< TLS lib had problem with syscall */
737 RS_RET_UNSUPP_SOCK_AF = -2462, /**< unsupported socket address family, use if code cannot process
738 address family or does not expect it (may be handled locally) */
739 RS_RET_SYSTEMD_VERSION_ERR = -2463, /**< systemd version doesn't support journal namespacing */
740 RS_RET_NO_TEMPLATE_SUPPORT_ERR = -2464, /**< journald namespace doesn't support template yet */
741 RS_RET_SERVER_NO_TLS = -2465, /**< server received TLS handshake but is not configured for TLS */
742
743 /* RainerScript error messages (range 1000.. 1999) */
744 RS_RET_SYSVAR_NOT_FOUND = 1001, /**< system variable could not be found (maybe misspelled) */
745 RS_RET_FIELD_NOT_FOUND = 1002, /**< field() function did not find requested field */
746
747 /* some generic error/status codes */
748 RS_RET_OK = 0, /**< operation successful */
749 RS_RET_OK_DELETE_LISTENTRY = 1,
750 /*< operation successful, but callee requested the deletion of an entry (special state) */
751 RS_RET_TERMINATE_NOW = 2, /**< operation successful, function is requested to terminate
752 (mostly used with threads) */
753 RS_RET_NO_RUN = 3, /**< operation successful, but function does not like to be executed */
754 RS_RET_IDLE = 4, /**< operation successful, but callee is idle (e.g. because queue is empty) */
755 RS_RET_TERMINATE_WHEN_IDLE = 5 /**< operation successful, function is requested to terminate when idle */
756 };
757
758 /* some helpful macros to work with srRetVals.
759 * Be sure to call the to-be-returned variable always "iRet" and
760 * the function finalizer always "finalize_it".
761 */
762 #ifdef HAVE_BUILTIN_EXCEPT
763 #define CHKiRet(code) \
764 if (__builtin_expect(((iRet = code) != RS_RET_OK), 0)) goto finalize_it
765 #define likely(x) __builtin_expect(!!(x), 1)
766 #define unlikely(x) __builtin_expect(!!(x), 0)
767 #else
768 #define CHKiRet(code) \
769 if ((iRet = code) != RS_RET_OK) goto finalize_it
770 #define likely(x) (x)
771 #define unlikely(x) (x)
772 #endif
773
774 #define CHKiConcCtrl(code) \
775 { \
776 int tmp_CC; \
777 if ((tmp_CC = code) != 0) { \
778 iRet = RS_RET_CONC_CTRL_ERR; \
779 errno = tmp_CC; \
780 goto finalize_it; \
781 } \
782 }
783
784 /* macro below is to be used if we need our own handling, eg for cleanup */
785 #define CHKiRet_Hdlr(code) if ((iRet = code) != RS_RET_OK)
786 /* macro below is to handle failing malloc/calloc/strdup... which we almost always handle in the same way... */
787 #define CHKmalloc(operation) \
788 if ((operation) == NULL) ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY)
789 /* macro below is used in conjunction with CHKiRet_Hdlr, else use ABORT_FINALIZE */
790 #define FINALIZE goto finalize_it;
791 #define DEFiRet rsRetVal iRet = RS_RET_OK
792 #define RETiRet return iRet
793
794 #define RS_CONCAT_(a, b) a##b
795 #define RS_CONCAT(a, b) RS_CONCAT_(a, b)
796
797 /**
798 * @brief Compile-time assertion with a pre-C11 fallback.
799 *
800 * Uses C11 `_Static_assert` when available and otherwise falls back
801 * to a typedef-size check.
802 */
803 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
804 #define RS_STATIC_ASSERT(condition, message) _Static_assert((condition), message)
805 #else
806 #define RS_STATIC_ASSERT(condition, message) \
807 typedef char RS_CONCAT(rs_static_assertion_line_, __LINE__)[(condition) ? 1 : -1] ATTR_UNUSED
808 #endif
809
810 /**
811 * @brief Copy a string literal into a fixed-size destination buffer.
812 *
813 * The macro enforces at compile time that `dst` is large enough for
814 * `lit` (including the trailing NUL) and then performs a `memcpy`.
815 *
816 * @note Intended for true fixed-size arrays, not pointer destinations.
817 */
818 #define RS_COPY_LITERAL(dst, lit) \
819 do { \
820 RS_STATIC_ASSERT(sizeof(dst) >= sizeof(lit), "destination buffer too small"); \
821 memcpy((dst), (lit), sizeof(lit)); \
822 } while (0)
823
824 #define ABORT_FINALIZE(errCode) \
825 do { \
826 iRet = errCode; \
827 goto finalize_it; \
828 } while (0)
829
830 /**
831 * @enum rsObjectID
832 * @brief Internal object identifiers used for sanity checks.
833 *
834 * Each object carries one of these IDs to verify that pointers refer
835 * to the expected type.
836 */
837 enum rsObjectID {
838 OIDrsFreed = -1, /**< assigned, when an object is freed. If this
839 * is seen during a method call, this is an
840 * invalid object pointer!
841 */
842 OIDrsInvalid = 0, /**< value created by calloc(), so do not use ;) */
843 /* The 0x3412 is a debug aid. It helps us find object IDs in memory
844 * dumps (on X86, this is 1234 in the dump ;)
845 * If you are on an embedded device and you would like to save space
846 * make them 1 byte only.
847 */
848 OIDrsCStr = 0x34120001,
849 OIDrsPars = 0x34120002
850 };
851 typedef enum rsObjectID rsObjID;
852
853 /* support to set object types */
854 #ifdef NDEBUG
855 #define rsSETOBJTYPE(pObj, type)
856 #define rsCHECKVALIDOBJECT(x, type)
857 #else
858 #define rsSETOBJTYPE(pObj, type) pObj->OID = type;
859 #define rsCHECKVALIDOBJECT(x, type) \
860 { \
861 assert(x != NULL); \
862 assert(x->OID == type); \
863 }
864 #endif
865
866 /**
867 * This macro should be used to free objects.
868 * It aids in interpreting dumps during debugging.
869 */
870 #ifdef NDEBUG
871 #define RSFREEOBJ(x) free(x)
872 #else
873 #define RSFREEOBJ(x) \
874 { \
875 (x)->OID = OIDrsFreed; \
876 free(x); \
877 }
878 #endif
879
880 /** Default thread attributes used for internal worker threads. */
881 extern pthread_attr_t default_thread_attr;
882 #ifdef HAVE_PTHREAD_SETSCHEDPARAM
883 /** Scheduling parameters for worker threads. */
884 extern struct sched_param default_sched_param;
885 extern int default_thr_sched_policy;
886 #endif
887 /**
888 * @struct actWrkrIParams
889 * @brief Immutable parameters passed to output workers.
890 *
891 * Each output plugin may request multiple templates. The overall table
892 * therefore holds one entry per template per message. Modifying this
893 * structure requires adjusting all output modules.
894 */
895 struct actWrkrIParams {
896 uchar *param;
897 uint32_t lenBuf; /* length of string buffer (if string ptr) */
898 uint32_t lenStr; /* length of current string (if string ptr) */
899 };
900
901 /* macro to access actWrkrIParams base object:
902 * param is ptr to base address
903 * nActTpls is the number of templates the action has requested
904 * iMsg is the message index
905 * iTpl is the template index
906 * This macro can be used for read and write access.
907 */
908 #define actParam(param, nActTpls, iMsg, iTpl) (param[(iMsg * nActTpls) + iTpl])
909
910 /* for the time being, we do our own portability handling here. It
911 * looks like autotools either does not yet support checks for it, or
912 * I wasn't smart enough to find them ;) rgerhards, 2007-07-18
913 */
914 #ifndef __GNUC__
915 #define __attribute__(x) /*NOTHING*/
916 #endif
917
918 /* some constants */
919 #define MUTEX_ALREADY_LOCKED 0
920 #define LOCK_MUTEX 1
921
922
923 #include "debug.h"
924 #include "obj.h"
925
926 /* the variable below is a trick: before we can init the runtime, the caller
927 * may want to set a module load path. We can not do this via the glbl class
928 * because it needs an initialized runtime system (and may at some point in time
929 * even be loaded itself). So this is a no-go. What we do is use a single global
930 * variable which may be provided with a pointer by the caller. This variable
931 * resides in rsyslog.c, the main runtime file. We have not seen any realy valule
932 * in providing object access functions. If you don't like that, feel free to
933 * add them. -- rgerhards, 2008-04-17
934 */
935 /** Path where modules are searched when loading dynamically. */
936 extern uchar *glblModPath;
937 /** Optional callback used for runtime error logging. */
938 extern void (*glblErrLogger)(const int, const int, const uchar *);
939
940 /* some runtime prototypes */
941 /** Process messages from iminternal. */
942 void processImInternal(void);
943 /** Initialize the runtime environment. */
944 rsRetVal rsrtInit(const char **ppErrObj, obj_if_t *pObjIF);
945 /** Shut down the runtime environment. */
946 rsRetVal rsrtExit(void);
947 /** Check if the runtime system has been initialized. */
948 int rsrtIsInit(void);
949 /** Specify an alternative error logger. */
950 void rsrtSetErrLogger(void (*errLogger)(const int, const int, const uchar *));
951 /** Default error logger used by the runtime. */
952 void dfltErrLogger(const int, const int, const uchar *errMsg);
953 /** Determine the local host name and store it in the configuration. */
954 rsRetVal queryLocalHostname(rsconf_t *const);
955
956
957 /* this define below is intended to be used to implement empty
958 * structs on platforms where at least on struct member is.
959 * absolutely necessary. We need to do this, as our runtime
960 * expects several definitions to be present, even if in
961 * rare cases the code in question does not really need it.
962 */
963 #ifdef OS_SOLARIS
964 #define EMPTY_STRUCT int remove_me_when_first_real_member_is_added;
965 #else
966 #define EMPTY_STRUCT
967 #endif
968
969 /** Global pointer to the active configuration object. */
970 extern rsconf_t *ourConf; /* defined by syslogd.c */
971
972
973 /** add compatibility layer for old platforms that miss essential functions */
974 #ifndef HAVE_STRNDUP
975 char *strndup(const char *s, size_t n);
976 #endif
977 #if !defined(O_CLOEXEC) && !defined(_AIX)
978 /* of course, this limits the functionality... */
979 #define O_CLOEXEC 0
980 #endif
981
982
983 #endif /* multi-include protection */