~arges/ubuntu/quantal/rsyslog/fix-lp1059592

« back to all changes in this revision

Viewing changes to syslogd.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2009-02-15 21:56:23 UTC
  • mto: (3.2.4 squeeze) (1.1.9 upstream)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20090215215623-xsycf628eo3kguc0
Tags: upstream-3.20.4
ImportĀ upstreamĀ versionĀ 3.20.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* common header for syslogd
2
 
 * Copyright 2007 Rainer Gerhards and Adiscon GmbH.
3
 
 *
4
 
 * This file is part of rsyslog.
5
 
 *
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.
10
 
 *
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.
15
 
 *
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/>.
18
 
 *
19
 
 * A copy of the GPL can be found in the file "COPYING" in this distribution.
20
 
 */
21
 
#ifndef SYSLOGD_H_INCLUDED
22
 
#define SYSLOGD_H_INCLUDED 1
23
 
 
24
 
#include "syslogd-types.h"
25
 
#include "objomsr.h"
26
 
#include "modules.h"
27
 
#include "template.h"
28
 
#include "action.h"
29
 
#include "linkedlist.h"
30
 
#include "expr.h"
31
 
 
32
 
/* portability: not all platforms have these defines, so we
33
 
 * define them here if they are missing. -- rgerhards, 2008-03-04
34
 
 */
35
 
#ifndef LOG_MAKEPRI
36
 
#       define  LOG_MAKEPRI(fac, pri)   (((fac) << 3) | (pri))
37
 
#endif
38
 
#ifndef LOG_PRI
39
 
#       define  LOG_PRI(p)      ((p) & LOG_PRIMASK)
40
 
#endif
41
 
#ifndef LOG_FAC
42
 
#       define  LOG_FAC(p)      (((p) & LOG_FACMASK) >> 3)
43
 
#endif
44
 
 
45
 
 
46
 
#ifdef USE_NETZIP
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
57
 
 */
58
 
#define MIN_SIZE_FOR_COMPRESS   60
59
 
#endif
60
 
 
61
 
#define MAXLINE         2048            /* maximum line length */
62
 
 
63
 
/* Flags to logmsg().
64
 
 */
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 */
70
 
 
71
 
/* This structure represents the files that will have log
72
 
 * copies printed.
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.
85
 
 */
86
 
struct filed {
87
 
        struct  filed *f_next;          /* next in linked list */
88
 
        /* filter properties */
89
 
        enum {
90
 
                FILTER_PRI = 0,         /* traditional PRI based filer */
91
 
                FILTER_PROP = 1,        /* extended filter, property based */
92
 
                FILTER_EXPR = 2         /* extended filter, expression based */
93
 
        } f_filter_type;
94
 
        EHostnameCmpMode eHostnameCmpMode;
95
 
        cstr_t *pCSHostnameComp;        /* hostname to check */
96
 
        cstr_t *pCSProgNameComp;        /* tag to check or NULL, if not to be checked */
97
 
        union {
98
 
                u_char  f_pmask[LOG_NFACILITIES+1];     /* priority mask */
99
 
                struct {
100
 
                        cstr_t *pCSPropName;
101
 
                        enum {
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? */
107
 
                        } operation;
108
 
                        cstr_t *pCSCompValue;   /* value to "compare" against */
109
 
                        char isNegated;                 /* actually a boolean ;) */
110
 
                } prop;
111
 
                expr_t *f_expr;                         /* expression object */
112
 
        } f_filterData;
113
 
 
114
 
        linkedList_t llActList; /* list of configured actions */
115
 
};
116
 
typedef struct filed selector_t;        /* new type name */
117
 
 
118
 
 
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! */
123
 
void untty(void);
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
132
 
 */
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;
138
 
extern int family;
139
 
extern int NoHops;
140
 
extern int send_to_all;
141
 
extern int option_DisallowWarning;
142
 
extern int Debug;
143
 
extern char**LocalHosts;
144
 
extern int DisableDNS;
145
 
extern char **StripDomains;
146
 
extern char *LocalDomain;
147
 
extern int bDropMalPTRMsgs;
148
 
extern char ctty[];
149
 
extern int MarkInterval;
150
 
extern int  bReduceRepeatMsgs;
151
 
extern int bActExecWhenPrevSusp;
152
 
extern int iActExecOnceInterval;
153
 
 
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!
158
 
 */
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; \
164
 
                        }
165
 
 
166
 
#endif /* #ifndef SYSLOGD_H_INCLUDED */