1
/* common header for syslogd
2
* Copyright 2007 Rainer Gerhards and Adiscon GmbH.
4
* This file is part of rsyslog.
6
* Rsyslog is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* Rsyslog is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
19
* A copy of the GPL can be found in the file "COPYING" in this distribution.
21
#ifndef SYSLOGD_H_INCLUDED
22
#define SYSLOGD_H_INCLUDED 1
24
#include "syslogd-types.h"
29
#include "linkedlist.h"
32
/* portability: not all platforms have these defines, so we
33
* define them here if they are missing. -- rgerhards, 2008-03-04
36
# define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
39
# define LOG_PRI(p) ((p) & LOG_PRIMASK)
42
# define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
47
/* config param: minimum message size to try compression. The smaller
48
* the message, the less likely is any compression gain. We check for
49
* gain before we submit the message. But to do so we still need to
50
* do the (costly) compress() call. The following setting sets a size
51
* for which no call to compress() is done at all. This may result in
52
* a few more bytes being transmited but better overall performance.
53
* Note: I have not yet checked the minimum UDP packet size. It might be
54
* that we do not save anything by compressing very small messages, because
55
* UDP might need to pad ;)
56
* rgerhards, 2006-11-30
58
#define MIN_SIZE_FOR_COMPRESS 60
61
#define MAXLINE 2048 /* maximum line length */
65
#define NOFLAG 0x000 /* no flag is set (to be used when a flag must be specified and none is required) */
66
#define INTERNAL_MSG 0x001 /* msg generated by logmsgInternal() --> special handling */
67
#define SYNC_FILE 0x002 /* do fsync on file after printing */
68
#define ADDDATE 0x004 /* add a date to the message */
69
#define MARK 0x008 /* this message is a mark */
71
/* This structure represents the files that will have log
73
* RGerhards 2004-11-08: Each instance of the filed structure
74
* describes what I call an "output channel". This is important
75
* to mention as we now allow database connections to be
76
* present in the filed structure. If helps immensely, if we
77
* think of it as the abstraction of an output channel.
78
* rgerhards, 2005-10-26: The structure below provides ample
79
* opportunity for non-thread-safety. Each of the variable
80
* accesses must be carefully evaluated, many of them probably
81
* be guarded by mutexes. But beware of deadlocks...
82
* rgerhards, 2007-08-01: as you can see, the structure has shrunk pretty much. I will
83
* remove some of the comments some time. It's still the structure that controls much
84
* of the processing that goes on in syslogd, but it now has lots of helpers.
87
struct filed *f_next; /* next in linked list */
88
/* filter properties */
90
FILTER_PRI = 0, /* traditional PRI based filer */
91
FILTER_PROP = 1, /* extended filter, property based */
92
FILTER_EXPR = 2 /* extended filter, expression based */
94
EHostnameCmpMode eHostnameCmpMode;
95
cstr_t *pCSHostnameComp; /* hostname to check */
96
cstr_t *pCSProgNameComp; /* tag to check or NULL, if not to be checked */
98
u_char f_pmask[LOG_NFACILITIES+1]; /* priority mask */
102
FIOP_NOP = 0, /* do not use - No Operation */
103
FIOP_CONTAINS = 1, /* contains string? */
104
FIOP_ISEQUAL = 2, /* is (exactly) equal? */
105
FIOP_STARTSWITH = 3, /* starts with a string? */
106
FIOP_REGEX = 4 /* matches a regular expression? */
108
cstr_t *pCSCompValue; /* value to "compare" against */
109
char isNegated; /* actually a boolean ;) */
111
expr_t *f_expr; /* expression object */
114
linkedList_t llActList; /* list of configured actions */
116
typedef struct filed selector_t; /* new type name */
119
#define MSG_PARSE_HOSTNAME 1
120
#define MSG_DONT_PARSE_HOSTNAME 0
121
rsRetVal parseAndSubmitMessage(char *hname, char *msg, int len, int bParseHost, int flags, flowControl_t flowCtlType);
122
#include "net.h" /* TODO: remove when you remoe isAllowedSender from here! */
124
rsRetVal selectorConstruct(selector_t **ppThis);
125
rsRetVal cflineParseTemplateName(uchar** pp, omodStringRequest_t *pOMSR, int iEntry, int iTplOpts, uchar *dfltTplName);
126
rsRetVal cflineParseFileName(uchar* p, uchar *pFileName, omodStringRequest_t *pOMSR, int iEntry, int iTplOpts, uchar *pszTpl);
127
int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep);
128
rsRetVal selectorDestruct(void *pVal);
129
rsRetVal selectorAddList(selector_t *f);
130
/* the following prototypes should go away once we have an input
131
* module interface -- rgerhards, 2007-12-12
133
rsRetVal logmsgInternal(int pri, char *msg, int flags);
134
void logmsg(msg_t *pMsg, int flags);
135
rsRetVal submitMsg(msg_t *pMsg);
136
extern int glblHadMemShortage; /* indicates if we had memory shortage some time during the run */
137
extern uchar *LocalHostName;
140
extern int send_to_all;
141
extern int option_DisallowWarning;
143
extern char**LocalHosts;
144
extern int DisableDNS;
145
extern char **StripDomains;
146
extern char *LocalDomain;
147
extern int bDropMalPTRMsgs;
149
extern int MarkInterval;
150
extern int bReduceRepeatMsgs;
151
extern int bActExecWhenPrevSusp;
152
extern int iActExecOnceInterval;
154
/* Intervals at which we flush out "message repeated" messages,
155
* in seconds after previous message is logged. After each flush,
156
* we move to the next interval until we reach the largest.
157
* TODO: move this to action object!
159
extern int repeatinterval[2];
160
#define MAXREPEAT ((int)((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1))
161
#define REPEATTIME(f) ((f)->f_time + repeatinterval[(f)->f_repeatcount])
162
#define BACKOFF(f) { if (++(f)->f_repeatcount > MAXREPEAT) \
163
(f)->f_repeatcount = MAXREPEAT; \
166
#endif /* #ifndef SYSLOGD_H_INCLUDED */