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 struct nspoll_s nspoll_t;
57 typedef enum nsdsel_waitOp_e nsdsel_waitOp_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_gsspi_s nsd_gsspi_t;
62 typedef struct nsd_nss_s nsd_nss_t;
63 typedef struct nsdsel_ptcp_s nsdsel_ptcp_t;
64 typedef struct nsdsel_gtls_s nsdsel_gtls_t;
65 typedef struct nsdsel_ossl_s nsdsel_ossl_t;
66 typedef struct nsdpoll_ptcp_s nsdpoll_ptcp_t;
67 typedef struct wti_s wti_t;
68 typedef struct msgPropDescr_s msgPropDescr_t;
69 typedef struct msg smsg_t;
70 typedef struct queue_s qqueue_t;
71 typedef struct prop_s prop_t;
72 typedef struct interface_s interface_t;
73 typedef struct objInfo_s objInfo_t;
74 typedef enum rsRetVal_ rsRetVal; /**< friendly type for global return value */
75 typedef rsRetVal (*errLogFunc_t)(uchar*);
76 /* this is a trick to store a function ptr to a function returning a function ptr... */
77 typedef struct permittedPeers_s permittedPeers_t;
78 /* this should go away in the long term -- rgerhards, 2008-05-19 */
79 typedef struct permittedPeerWildcard_s permittedPeerWildcard_t;
80 /* this should go away in the long term -- rgerhards, 2008-05-19 */
81 typedef struct tcpsrv_s tcpsrv_t;
82 typedef struct tcps_sess_s tcps_sess_t;
83 typedef struct strmsrv_s strmsrv_t;
84 typedef struct strms_sess_s strms_sess_t;
85 typedef struct vmstk_s vmstk_t;
86 typedef struct batch_obj_s batch_obj_t;
87 typedef struct batch_s batch_t;
88 typedef struct wtp_s wtp_t;
89 typedef struct modInfo_s modInfo_t;
90 typedef struct parser_s parser_t;
91 typedef struct parserList_s parserList_t;
92 typedef struct strgen_s strgen_t;
93 typedef struct strgenList_s strgenList_t;
94 typedef struct statsobj_s statsobj_t;
95 typedef void (*statsobj_read_notifier_t)(statsobj_t *, void *);
96 typedef struct nsd_epworkset_s nsd_epworkset_t;
97 typedef struct templates_s templates_t;
98 typedef struct queuecnf_s queuecnf_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 rsconf_s rsconf_t;
104 typedef struct cfgmodules_s cfgmodules_t;
105 typedef struct cfgmodules_etry_s cfgmodules_etry_t;
106 typedef struct outchannels_s outchannels_t;
107 typedef struct modConfData_s modConfData_t;
108 typedef struct instanceConf_s instanceConf_t;
109 typedef struct ratelimit_s ratelimit_t;
110 typedef struct lookup_string_tab_entry_s lookup_string_tab_entry_t;
111 typedef struct lookup_string_tab_s lookup_string_tab_t;
112 typedef struct lookup_array_tab_s lookup_array_tab_t;
113 typedef struct lookup_sparseArray_tab_s lookup_sparseArray_tab_t;
114 typedef struct lookup_sparseArray_tab_entry_s lookup_sparseArray_tab_entry_t;
115 typedef struct lookup_tables_s lookup_tables_t;
116 typedef union lookup_key_u lookup_key_t;
117 
118 typedef struct lookup_s lookup_t;
119 typedef struct lookup_ref_s lookup_ref_t;
120 typedef struct action_s action_t;
121 typedef int rs_size_t; /* we do never need more than 2Gig strings, signed permits to
122 			* use -1 as a special flag. */
123 typedef rsRetVal (*prsf_t)(struct vmstk_s*, int);	/* pointer to a RainerScript function */
124 typedef uint64 qDeqID;	/* queue Dequeue order ID. 32 bits is considered dangerously few */
125 
126 typedef struct tcpLstnParams_s tcpLstnParams_t;
127 typedef struct tcpLstnPortList_s tcpLstnPortList_t; // TODO: rename?
128 typedef struct strmLstnPortList_s strmLstnPortList_t; // TODO: rename?
129 typedef struct actWrkrIParams actWrkrIParams_t;
130 typedef struct dynstats_bucket_s dynstats_bucket_t;
131 typedef struct dynstats_buckets_s dynstats_buckets_t;
132 typedef struct perctile_buckets_s perctile_buckets_t;
133 typedef struct dynstats_ctr_s dynstats_ctr_t;
134 
135 /* under Solaris (actually only SPARC), we need to redefine some types
136  * to be void, so that we get void* pointers. Otherwise, we will see
137  * alignment errors.
138  */
139 #ifdef OS_SOLARIS
140 	typedef void * obj_t_ptr;
141 	typedef void nsd_t;
142 	typedef void nsdsel_t;
143 	typedef void nsdpoll_t;
144 #else
145 	typedef obj_t *obj_t_ptr;
146 	typedef obj_t nsd_t;
147 	typedef obj_t nsdsel_t;
148 	typedef obj_t nsdpoll_t;
149 #endif
150 
151 
152 #ifdef __hpux
153 typedef unsigned int u_int32_t; /* TODO: is this correct? */
154 typedef int socklen_t;
155 #endif
156 
157 typedef struct epoll_event epoll_event_t;
158 
159 typedef signed char sbool;	/* (small bool) I intentionally use char, to keep it slim so that
160 				many fit into the CPU cache! */
161 
162 /* settings for flow control
163  * TODO: is there a better place for them? -- rgerhards, 2008-03-14
164  */
165 typedef enum {
166 	eFLOWCTL_NO_DELAY = 0,		/**< UDP and other non-delayable sources */
167 	eFLOWCTL_LIGHT_DELAY = 1,	/**< some light delay possible, but no extended period of time */
168 	eFLOWCTL_FULL_DELAY = 2	/**< delay possible for extended period of time */
169 } flowControl_t;
170 
171 /* filter operations */
172 typedef enum {
173 	FIOP_NOP = 0,		/* do not use - No Operation */
174 	FIOP_CONTAINS  = 1,	/* contains string? */
175 	FIOP_ISEQUAL  = 2,	/* is (exactly) equal? */
176 	FIOP_STARTSWITH = 3,	/* starts with a string? */
177 	FIOP_REGEX = 4,		/* matches a (BRE) regular expression? */
178 	FIOP_EREREGEX = 5,	/* matches a ERE regular expression? */
179 	FIOP_ISEMPTY = 6	/* 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_SYS_NOW			150
221 #define PROP_SYS_YEAR			151
222 #define PROP_SYS_MONTH			152
223 #define PROP_SYS_DAY			153
224 #define PROP_SYS_HOUR			154
225 #define PROP_SYS_HHOUR			155
226 #define PROP_SYS_QHOUR			156
227 #define PROP_SYS_MINUTE			157
228 #define PROP_SYS_MYHOSTNAME		158
229 #define PROP_SYS_BOM			159
230 #define PROP_SYS_UPTIME			160
231 #define PROP_UUID			161
232 #define PROP_SYS_NOW_UTC		162
233 #define PROP_SYS_YEAR_UTC		163
234 #define PROP_SYS_MONTH_UTC		164
235 #define PROP_SYS_DAY_UTC		165
236 #define PROP_SYS_HOUR_UTC		166
237 #define PROP_SYS_HHOUR_UTC		167
238 #define PROP_SYS_QHOUR_UTC		168
239 #define PROP_SYS_MINUTE_UTC		169
240 #define PROP_SYS_WDAY			170
241 #define PROP_SYS_WDAY_UTC		171
242 #define PROP_SYS_NOW_UXTIMESTAMP	173
243 #define PROP_CEE			200
244 #define PROP_CEE_ALL_JSON		201
245 #define PROP_LOCAL_VAR			202
246 #define PROP_GLOBAL_VAR			203
247 #define PROP_CEE_ALL_JSON_PLAIN		204
248 
249 /* types of configuration handlers
250  */
251 typedef enum cslCmdHdlrType {
252 	eCmdHdlrInvalid = 0,		/* invalid handler type - indicates a coding error */
253 	eCmdHdlrCustomHandler,		/* custom handler, just call handler function */
254 	eCmdHdlrUID,
255 	eCmdHdlrGID,
256 	eCmdHdlrBinary,
257 	eCmdHdlrFileCreateMode,
258 	eCmdHdlrInt,
259 	eCmdHdlrNonNegInt,
260 	eCmdHdlrPositiveInt,
261 	eCmdHdlrSize,
262 	eCmdHdlrGetChar,
263 	eCmdHdlrFacility,
264 	eCmdHdlrSeverity,
265 	eCmdHdlrGetWord,
266 	eCmdHdlrString,
267 	eCmdHdlrArray,
268 	eCmdHdlrQueueType,
269 	eCmdHdlrGoneAway		/* statment existed, but is no longer supported */
270 } ecslCmdHdrlType;
271 
272 
273 /* the next type describes $Begin .. $End block object types
274  */
275 typedef enum cslConfObjType {
276 	eConfObjGlobal = 0,	/* global directives */
277 	eConfObjAction,		/* action-specific directives */
278 	/* now come states that indicate that we wait for a block-end. These are
279 	 * states that permit us to do some safety checks and they hopefully ease
280 	 * migration to a "real" parser/grammar.
281 	 */
282 	eConfObjActionWaitEnd,
283 	eConfObjAlways		/* always valid, very special case (guess $End only!) */
284 } ecslConfObjType;
285 
286 
287 /* multi-submit support.
288  * This is done via a simple data structure, which holds the number of elements
289  * as well as an array of to-be-submitted messages.
290  * rgerhards, 2009-06-16
291  */
292 typedef struct multi_submit_s multi_submit_t;
293 struct multi_submit_s {
294 	short	maxElem;	/* maximum number of Elements */
295 	short	nElem;		/* current number of Elements, points to the next one FREE */
296 	smsg_t	**ppMsgs;
297 };
298 
299 /* the following structure is a helper to describe a message property */
300 struct msgPropDescr_s {
301 	propid_t id;
302 	uchar *name;		/* name and lenName are only set for dynamic */
303 	int nameLen;		/* properties (JSON) */
304 };
305 
306 /* some forward-definitions from the grammar */
307 struct nvlst;
308 struct cnfobj;
309 
310 #endif /* multi-include protection */
311