| 1 |
/* This defines some types commonly used. Do NOT include any other |
| 2 |
* rsyslog runtime file. |
| 3 |
* |
| 4 |
* Begun 2010-11-25 RGerhards |
| 5 |
* |
| 6 |
* Copyright (C) 2005-2020 by Rainer Gerhards and Adiscon GmbH |
| 7 |
* |
| 8 |
* This file is part of the rsyslog runtime library. |
| 9 |
* |
| 10 |
* The rsyslog runtime library is free software: you can redistribute it and/or modify |
| 11 |
* it under the terms of the GNU Lesser General Public License as published by |
| 12 |
* the Free Software Foundation, either version 3 of the License, or |
| 13 |
* (at your option) any later version. |
| 14 |
* |
| 15 |
* The rsyslog runtime library is distributed in the hope that it will be useful, |
| 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
* GNU Lesser General Public License for more details. |
| 19 |
* |
| 20 |
* You should have received a copy of the GNU Lesser General Public License |
| 21 |
* along with the rsyslog runtime library. If not, see <http://www.gnu.org/licenses/>. |
| 22 |
* |
| 23 |
* A copy of the GPL can be found in the file "COPYING" in this distribution. |
| 24 |
* A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution. |
| 25 |
*/ |
| 26 |
#ifndef INCLUDED_TYPEDEFS_H |
| 27 |
#define INCLUDED_TYPEDEFS_H |
| 28 |
|
| 29 |
#include <stdint.h> |
| 30 |
#if defined(__FreeBSD__) || !defined(HAVE_LSEEK64) |
| 31 |
#include <sys/types.h> |
| 32 |
#endif |
| 33 |
|
| 34 |
/* some universal fixed size integer defines ... */ |
| 35 |
#ifndef _AIX |
| 36 |
typedef long long int64; |
| 37 |
#endif |
| 38 |
typedef long long unsigned uint64; |
| 39 |
typedef int64 number_t; /* type to use for numbers - TODO: maybe an autoconf option? */ |
| 40 |
typedef char intTiny; /* 0..127! */ |
| 41 |
typedef unsigned char uintTiny; /* 0..255! */ |
| 42 |
|
| 43 |
/* define some base data types */ |
| 44 |
|
| 45 |
typedef uint16_t syslog_pri_t; /* to be used for syslog PRI values */ |
| 46 |
typedef unsigned char uchar; /* get rid of the unhandy "unsigned char" */ |
| 47 |
typedef struct aUsrp_s aUsrp_t; |
| 48 |
typedef struct thrdInfo thrdInfo_t; |
| 49 |
typedef struct obj_s obj_t; |
| 50 |
typedef struct ruleset_s ruleset_t; |
| 51 |
typedef struct rule_s rule_t; |
| 52 |
typedef struct NetAddr netAddr_t; |
| 53 |
typedef struct netstrms_s netstrms_t; |
| 54 |
typedef struct netstrm_s netstrm_t; |
| 55 |
typedef struct nssel_s nssel_t; |
| 56 |
typedef enum nsdsel_waitOp_e nsdsel_waitOp_t; |
| 57 |
typedef struct net_ossl_s net_ossl_t; |
| 58 |
typedef struct nsd_ptcp_s nsd_ptcp_t; |
| 59 |
typedef struct nsd_gtls_s nsd_gtls_t; |
| 60 |
typedef struct nsd_ossl_s nsd_ossl_t; |
| 61 |
typedef struct nsd_mbedtls_s nsd_mbedtls_t; |
| 62 |
typedef struct nsd_gsspi_s nsd_gsspi_t; |
| 63 |
typedef struct nsd_nss_s nsd_nss_t; |
| 64 |
typedef struct wti_s wti_t; |
| 65 |
typedef struct msgPropDescr_s msgPropDescr_t; |
| 66 |
typedef struct msg smsg_t; |
| 67 |
typedef struct queue_s qqueue_t; |
| 68 |
typedef struct prop_s prop_t; |
| 69 |
typedef struct interface_s interface_t; |
| 70 |
typedef struct objInfo_s objInfo_t; |
| 71 |
typedef enum rsRetVal_ rsRetVal; /**< friendly type for global return value */ |
| 72 |
typedef rsRetVal (*errLogFunc_t)(uchar *); |
| 73 |
/* this is a trick to store a function ptr to a function returning a function ptr... */ |
| 74 |
typedef struct permittedPeers_s permittedPeers_t; |
| 75 |
/* this should go away in the long term -- rgerhards, 2008-05-19 */ |
| 76 |
typedef struct permittedPeerWildcard_s permittedPeerWildcard_t; |
| 77 |
/* this should go away in the long term -- rgerhards, 2008-05-19 */ |
| 78 |
typedef struct tcpsrv_s tcpsrv_t; |
| 79 |
typedef struct tcps_sess_s tcps_sess_t; |
| 80 |
typedef struct strmsrv_s strmsrv_t; |
| 81 |
typedef struct strms_sess_s strms_sess_t; |
| 82 |
typedef struct vmstk_s vmstk_t; |
| 83 |
typedef struct batch_obj_s batch_obj_t; |
| 84 |
typedef struct batch_s batch_t; |
| 85 |
typedef struct wtp_s wtp_t; |
| 86 |
typedef struct modInfo_s modInfo_t; |
| 87 |
typedef struct parser_s parser_t; |
| 88 |
typedef struct parserList_s parserList_t; |
| 89 |
typedef struct strgen_s strgen_t; |
| 90 |
typedef struct strgenList_s strgenList_t; |
| 91 |
typedef struct statsobj_s statsobj_t; |
| 92 |
typedef void (*statsobj_read_notifier_t)(statsobj_t *, void *); |
| 93 |
// typedef struct nsd_epworkset_s nsd_epworkset_t; // TODO: REMOVE |
| 94 |
typedef struct tcpsrv_io_descr_s tcpsrv_io_descr_t; // i/o descriptor used for tcpsrv network i/o |
| 95 |
typedef struct templates_s templates_t; |
| 96 |
typedef struct parsers_s parsers_t; |
| 97 |
typedef struct queuecnf_s queuecnf_t; |
| 98 |
typedef struct parsercnf_s parsercnf_t; |
| 99 |
typedef struct rulesets_s rulesets_t; |
| 100 |
typedef struct globals_s globals_t; |
| 101 |
typedef struct defaults_s defaults_t; |
| 102 |
typedef struct actions_s actions_t; |
| 103 |
typedef struct timezones_s timezones_t; |
| 104 |
typedef struct rsconf_s rsconf_t; |
| 105 |
typedef struct cfgmodules_s cfgmodules_t; |
| 106 |
typedef struct cfgmodules_etry_s cfgmodules_etry_t; |
| 107 |
typedef struct outchannels_s outchannels_t; |
| 108 |
typedef struct modConfData_s modConfData_t; |
| 109 |
typedef struct instanceConf_s instanceConf_t; |
| 110 |
typedef struct ratelimit_s ratelimit_t; |
| 111 |
typedef struct lookup_string_tab_entry_s lookup_string_tab_entry_t; |
| 112 |
typedef struct lookup_string_tab_s lookup_string_tab_t; |
| 113 |
typedef struct lookup_array_tab_s lookup_array_tab_t; |
| 114 |
typedef struct lookup_sparseArray_tab_s lookup_sparseArray_tab_t; |
| 115 |
typedef struct lookup_sparseArray_tab_entry_s lookup_sparseArray_tab_entry_t; |
| 116 |
typedef struct lookup_regex_tab_entry_s lookup_regex_tab_entry_t; |
| 117 |
typedef struct lookup_tables_s lookup_tables_t; |
| 118 |
typedef struct lookup_regex_tab_s lookup_regex_tab_t; |
| 119 |
typedef union lookup_key_u lookup_key_t; |
| 120 |
|
| 121 |
typedef struct lookup_s lookup_t; |
| 122 |
typedef struct lookup_ref_s lookup_ref_t; |
| 123 |
typedef struct action_s action_t; |
| 124 |
typedef int rs_size_t; /* we do never need more than 2Gig strings, signed permits to |
| 125 |
* use -1 as a special flag. */ |
| 126 |
typedef rsRetVal (*prsf_t)(struct vmstk_s *, int); /* pointer to a RainerScript function */ |
| 127 |
typedef uint64 qDeqID; /* queue Dequeue order ID. 32 bits is considered dangerously few */ |
| 128 |
|
| 129 |
typedef struct tcpLstnParams_s tcpLstnParams_t; |
| 130 |
typedef struct tcpLstnPortList_s tcpLstnPortList_t; // TODO: rename? |
| 131 |
typedef struct strmLstnPortList_s strmLstnPortList_t; // TODO: rename? |
| 132 |
typedef struct actWrkrIParams actWrkrIParams_t; |
| 133 |
typedef struct dynstats_bucket_s dynstats_bucket_t; |
| 134 |
typedef struct dynstats_buckets_s dynstats_buckets_t; |
| 135 |
typedef struct perctile_buckets_s perctile_buckets_t; |
| 136 |
typedef struct dynstats_ctr_s dynstats_ctr_t; |
| 137 |
|
| 138 |
/* under Solaris (actually only SPARC), we need to redefine some types |
| 139 |
* to be void, so that we get void* pointers. Otherwise, we will see |
| 140 |
* alignment errors. |
| 141 |
*/ |
| 142 |
#ifdef OS_SOLARIS |
| 143 |
typedef void *obj_t_ptr; |
| 144 |
typedef void nsd_t; |
| 145 |
#else |
| 146 |
typedef obj_t *obj_t_ptr; |
| 147 |
typedef obj_t nsd_t; |
| 148 |
#endif |
| 149 |
|
| 150 |
|
| 151 |
#ifdef __hpux |
| 152 |
typedef unsigned int u_int32_t; /* TODO: is this correct? */ |
| 153 |
typedef int socklen_t; |
| 154 |
#endif |
| 155 |
|
| 156 |
typedef struct epoll_event epoll_event_t; |
| 157 |
|
| 158 |
typedef signed char sbool; /* (small bool) I intentionally use char, to keep it slim so that |
| 159 |
many fit into the CPU cache! */ |
| 160 |
|
| 161 |
/* settings for flow control |
| 162 |
* TODO: is there a better place for them? -- rgerhards, 2008-03-14 |
| 163 |
*/ |
| 164 |
typedef enum { |
| 165 |
eFLOWCTL_NO_DELAY = 0, /**< UDP and other non-delayable sources */ |
| 166 |
eFLOWCTL_LIGHT_DELAY = 1, /**< some light delay possible, but no extended period of time */ |
| 167 |
eFLOWCTL_FULL_DELAY = 2 /**< delay possible for extended period of time */ |
| 168 |
} flowControl_t; |
| 169 |
|
| 170 |
/* filter operations */ |
| 171 |
typedef enum { |
| 172 |
FIOP_NOP = 0, /* do not use - No Operation */ |
| 173 |
FIOP_CONTAINS = 1, /* contains string? */ |
| 174 |
FIOP_ISEQUAL = 2, /* is (exactly) equal? */ |
| 175 |
FIOP_STARTSWITH = 3, /* starts with a string? */ |
| 176 |
FIOP_ENDSWITH = 4, /* ends with a string? */ |
| 177 |
FIOP_REGEX = 5, /* matches a (BRE) regular expression? */ |
| 178 |
FIOP_EREREGEX = 6, /* matches a ERE regular expression? */ |
| 179 |
FIOP_ISEMPTY = 7 /* string empty <=> strlen(s) == 0 ?*/ |
| 180 |
} fiop_t; |
| 181 |
|
| 182 |
#ifndef HAVE_LSEEK64 |
| 183 |
#ifndef HAVE_OFF64_T |
| 184 |
typedef off_t off64_t; |
| 185 |
#endif |
| 186 |
#endif |
| 187 |
|
| 188 |
|
| 189 |
/* properties are now encoded as (tiny) integers. I do not use an enum as I would like |
| 190 |
* to keep the memory footprint small (and thus cache hits high). |
| 191 |
* rgerhards, 2009-06-26 |
| 192 |
*/ |
| 193 |
typedef uintTiny propid_t; |
| 194 |
#define PROP_INVALID 0 |
| 195 |
#define PROP_MSG 1 |
| 196 |
#define PROP_TIMESTAMP 2 |
| 197 |
#define PROP_HOSTNAME 3 |
| 198 |
#define PROP_SYSLOGTAG 4 |
| 199 |
#define PROP_RAWMSG 5 |
| 200 |
#define PROP_INPUTNAME 6 |
| 201 |
#define PROP_FROMHOST 7 |
| 202 |
#define PROP_FROMHOST_IP 8 |
| 203 |
#define PROP_PRI 9 |
| 204 |
#define PROP_PRI_TEXT 10 |
| 205 |
#define PROP_IUT 11 |
| 206 |
#define PROP_SYSLOGFACILITY 12 |
| 207 |
#define PROP_SYSLOGFACILITY_TEXT 13 |
| 208 |
#define PROP_SYSLOGSEVERITY 14 |
| 209 |
#define PROP_SYSLOGSEVERITY_TEXT 15 |
| 210 |
#define PROP_TIMEGENERATED 16 |
| 211 |
#define PROP_PROGRAMNAME 17 |
| 212 |
#define PROP_PROTOCOL_VERSION 18 |
| 213 |
#define PROP_STRUCTURED_DATA 19 |
| 214 |
#define PROP_APP_NAME 20 |
| 215 |
#define PROP_PROCID 21 |
| 216 |
#define PROP_MSGID 22 |
| 217 |
#define PROP_PARSESUCCESS 23 |
| 218 |
#define PROP_JSONMESG 24 |
| 219 |
#define PROP_RAWMSG_AFTER_PRI 25 |
| 220 |
#define PROP_FROMHOST_PORT 26 |
| 221 |
#define PROP_SYS_NOW 150 |
| 222 |
#define PROP_SYS_YEAR 151 |
| 223 |
#define PROP_SYS_MONTH 152 |
| 224 |
#define PROP_SYS_DAY 153 |
| 225 |
#define PROP_SYS_HOUR 154 |
| 226 |
#define PROP_SYS_HHOUR 155 |
| 227 |
#define PROP_SYS_QHOUR 156 |
| 228 |
#define PROP_SYS_MINUTE 157 |
| 229 |
#define PROP_SYS_MYHOSTNAME 158 |
| 230 |
#define PROP_SYS_BOM 159 |
| 231 |
#define PROP_SYS_UPTIME 160 |
| 232 |
#define PROP_UUID 161 |
| 233 |
#define PROP_SYS_NOW_UTC 162 |
| 234 |
#define PROP_SYS_YEAR_UTC 163 |
| 235 |
#define PROP_SYS_MONTH_UTC 164 |
| 236 |
#define PROP_SYS_DAY_UTC 165 |
| 237 |
#define PROP_SYS_HOUR_UTC 166 |
| 238 |
#define PROP_SYS_HHOUR_UTC 167 |
| 239 |
#define PROP_SYS_QHOUR_UTC 168 |
| 240 |
#define PROP_SYS_MINUTE_UTC 169 |
| 241 |
#define PROP_SYS_WDAY 170 |
| 242 |
#define PROP_SYS_WDAY_UTC 171 |
| 243 |
#define PROP_SYS_NOW_UXTIMESTAMP 173 |
| 244 |
#define PROP_CEE 200 |
| 245 |
#define PROP_CEE_ALL_JSON 201 |
| 246 |
#define PROP_LOCAL_VAR 202 |
| 247 |
#define PROP_GLOBAL_VAR 203 |
| 248 |
#define PROP_CEE_ALL_JSON_PLAIN 204 |
| 249 |
|
| 250 |
/* types of configuration handlers. These are used in rainerscript.h |
| 251 |
*/ |
| 252 |
typedef enum cslCmdHdlrType { |
| 253 |
eCmdHdlrInvalid = 0, /* invalid handler type - indicates a coding error */ |
| 254 |
eCmdHdlrCustomHandler, /* custom handler, just call handler function */ |
| 255 |
eCmdHdlrUID, |
| 256 |
eCmdHdlrGID, |
| 257 |
eCmdHdlrBinary, |
| 258 |
eCmdHdlrFileCreateMode, |
| 259 |
eCmdHdlrInt, |
| 260 |
eCmdHdlrNonNegInt, |
| 261 |
eCmdHdlrPositiveInt, |
| 262 |
eCmdHdlrSize, |
| 263 |
eCmdHdlrGetChar, |
| 264 |
eCmdHdlrFacility, |
| 265 |
eCmdHdlrSeverity, |
| 266 |
eCmdHdlrGetWord, |
| 267 |
eCmdHdlrString, |
| 268 |
eCmdHdlrArray, |
| 269 |
eCmdHdlrQueueType, |
| 270 |
eCmdHdlrGoneAway /* statement existed, but is no longer supported */ |
| 271 |
} ecslCmdHdrlType; |
| 272 |
|
| 273 |
|
| 274 |
/* the next type describes $Begin .. $End block object types |
| 275 |
*/ |
| 276 |
typedef enum cslConfObjType { |
| 277 |
eConfObjGlobal = 0, /* global directives */ |
| 278 |
eConfObjAction, /* action-specific directives */ |
| 279 |
/* now come states that indicate that we wait for a block-end. These are |
| 280 |
* states that permit us to do some safety checks and they hopefully ease |
| 281 |
* migration to a "real" parser/grammar. |
| 282 |
*/ |
| 283 |
eConfObjActionWaitEnd, |
| 284 |
eConfObjAlways /* always valid, very special case (guess $End only!) */ |
| 285 |
} ecslConfObjType; |
| 286 |
|
| 287 |
|
| 288 |
/* multi-submit support. |
| 289 |
* This is done via a simple data structure, which holds the number of elements |
| 290 |
* as well as an array of to-be-submitted messages. |
| 291 |
* rgerhards, 2009-06-16 |
| 292 |
*/ |
| 293 |
typedef struct multi_submit_s multi_submit_t; |
| 294 |
struct multi_submit_s { |
| 295 |
short maxElem; /* maximum number of Elements */ |
| 296 |
short nElem; /* current number of Elements, points to the next one FREE */ |
| 297 |
smsg_t **ppMsgs; |
| 298 |
}; |
| 299 |
|
| 300 |
/* the following structure is a helper to describe a message property */ |
| 301 |
struct msgPropDescr_s { |
| 302 |
propid_t id; |
| 303 |
uchar *name; /* name and lenName are only set for dynamic */ |
| 304 |
int nameLen; /* properties (JSON) */ |
| 305 |
}; |
| 306 |
|
| 307 |
/* some forward-definitions from the grammar */ |
| 308 |
struct nvlst; |
| 309 |
struct cnfobj; |
| 310 |
|
| 311 |
#endif /* multi-include protection */ |