| 1 |
/* The ruleset object. |
| 2 |
* |
| 3 |
* This implements rulesets within rsyslog. |
| 4 |
* |
| 5 |
* Copyright 2009-2026 Rainer Gerhards and Adiscon GmbH. |
| 6 |
* |
| 7 |
* This file is part of the rsyslog runtime library. |
| 8 |
* |
| 9 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 |
* you may not use this file except in compliance with the License. |
| 11 |
* You may obtain a copy of the License at |
| 12 |
* |
| 13 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 14 |
* -or- |
| 15 |
* see COPYING.ASL20 in the source distribution |
| 16 |
* |
| 17 |
* Unless required by applicable law or agreed to in writing, software |
| 18 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 19 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 20 |
* See the License for the specific language governing permissions and |
| 21 |
* limitations under the License. |
| 22 |
*/ |
| 23 |
#ifndef INCLUDED_RULESET_H |
| 24 |
#define INCLUDED_RULESET_H |
| 25 |
|
| 26 |
#include "queue.h" |
| 27 |
#include "linkedlist.h" |
| 28 |
#include "rsconf.h" |
| 29 |
|
| 30 |
/* the ruleset object */ |
| 31 |
struct ruleset_s { |
| 32 |
BEGINobjInstance |
| 33 |
; /* Data to implement generic object - MUST be the first data element! */ |
| 34 |
uchar *pszName; /* name of our ruleset */ |
| 35 |
qqueue_t *pQueue; /* "main" message queue, if the ruleset has its own (else NULL) */ |
| 36 |
struct cnfstmt *root; |
| 37 |
struct cnfstmt *last; |
| 38 |
parserList_t *pParserLst; /* list of parsers to use for this ruleset */ |
| 39 |
}; |
| 40 |
|
| 41 |
/* interfaces */ |
| 42 |
BEGINinterface(ruleset) /* name must also be changed in ENDinterface macro! */ |
| 43 |
INTERFACEObjDebugPrint(ruleset); |
| 44 |
rsRetVal (*DebugPrintAll)(rsconf_t *conf); |
| 45 |
rsRetVal (*Construct)(ruleset_t **ppThis); |
| 46 |
rsRetVal (*ConstructFinalize)(rsconf_t *conf, ruleset_t __attribute__((unused)) * pThis); |
| 47 |
rsRetVal (*Destruct)(ruleset_t **ppThis); |
| 48 |
rsRetVal (*DestructAllActions)(rsconf_t *conf); |
| 49 |
rsRetVal (*SetName)(ruleset_t *pThis, uchar *pszName); |
| 50 |
rsRetVal (*ProcessBatch)(batch_t *, wti_t *); |
| 51 |
rsRetVal (*GetRuleset)(rsconf_t *conf, ruleset_t **ppThis, uchar *); |
| 52 |
rsRetVal (*SetDefaultRuleset)(rsconf_t *conf, uchar *); |
| 53 |
rsRetVal (*SetCurrRuleset)(rsconf_t *conf, uchar *); |
| 54 |
ruleset_t *(*GetCurrent)(rsconf_t *conf); |
| 55 |
qqueue_t *(*GetRulesetQueue)(ruleset_t *); |
| 56 |
/* v3, 2009-11-04 */ |
| 57 |
parserList_t *(*GetParserList)(rsconf_t *conf, smsg_t *); |
| 58 |
/* v5, 2011-04-19 |
| 59 |
* added support for the rsconf object -- fundamental change |
| 60 |
* v6, 2011-07-15 |
| 61 |
* removed conf ptr from SetName, AddRule as the flex/bison based |
| 62 |
* system uses globals in any case. |
| 63 |
*/ |
| 64 |
/* v7, 2012-09-04 */ |
| 65 |
/* AddRule() removed */ |
| 66 |
/*TODO:REMOVE*/ rsRetVal (*IterateAllActions)(rsconf_t *conf, rsRetVal (*pFunc)(void *, void *), void *pParam); |
| 67 |
void (*AddScript)(ruleset_t *pThis, struct cnfstmt *script); |
| 68 |
/* v8: changed processBatch interface */ |
| 69 |
ENDinterface(ruleset) |
| 70 |
#define rulesetCURR_IF_VERSION 8 /* increment whenever you change the interface structure! */ |
| 71 |
|
| 72 |
|
| 73 |
/* prototypes */ |
| 74 |
PROTOTYPEObjFull(ruleset); |
| 75 |
PROTOTYPEObjDebugPrint(ruleset); |
| 76 |
|
| 77 |
/* TODO: remove these -- currently done dirty for config file |
| 78 |
* redo -- rgerhards, 2011-04-19 |
| 79 |
* rgerhards, 2012-04-19: actually, it may be way cooler not to remove |
| 80 |
* them and use plain c-style conventions at least inside core objects. |
| 81 |
*/ |
| 82 |
rsRetVal rulesetDestructForLinkedList(void *pData); |
| 83 |
rsRetVal rulesetKeyDestruct(void __attribute__((unused)) * pData); |
| 84 |
|
| 85 |
/* Get name associated to ruleset. This function cannot fail (except, |
| 86 |
* of course, if previously something went really wrong). Returned |
| 87 |
* pointer is read-only. |
| 88 |
* rgerhards, 2012-04-18 |
| 89 |
*/ |
| 90 |
#define rulesetGetName(pRuleset) ((pRuleset)->pszName) |
| 91 |
|
| 92 |
/* returns 1 if the ruleset has a queue associated, 0 if not */ |
| 93 |
#define rulesetHasQueue(pRuleset) \ |
| 94 |
(((pRuleset)->pQueue != NULL) && ((pRuleset)->pQueue->qType != QUEUETYPE_DIRECT) ? 1 : 0) |
| 95 |
|
| 96 |
|
| 97 |
/* we will most probably convert this module back to traditional C |
| 98 |
* calling sequence, so here we go... |
| 99 |
*/ |
| 100 |
rsRetVal rulesetGetRuleset(rsconf_t *conf, ruleset_t **ppRuleset, uchar *pszName); |
| 101 |
rsRetVal rulesetOptimizeAll(rsconf_t *conf); |
| 102 |
rsRetVal rulesetProcessCnf(struct cnfobj *o); |
| 103 |
rsRetVal activateRulesetQueues(void); |
| 104 |
|
| 105 |
/* Set a current rule set to already-known pointer */ |
| 106 |
#define rulesetSetCurrRulesetPtr(pRuleset) (loadConf->rulesets.pCurr = (pRuleset)) |
| 107 |
|
| 108 |
#endif /* #ifndef INCLUDED_RULESET_H */ |