From 6f511cecfae3592f271627ebcb41e6a8c4f831e9 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 3 Nov 2009 12:39:48 +0100 Subject: more cleanup and working towards a parser module calling interface I cleaned up a lot of config variable access along the way. This version compiles and runs, but does not yet offer any enhanced functionality. pmrfc5424 is just a dummy that is not yet being used. --- runtime/parser.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'runtime/parser.h') diff --git a/runtime/parser.h b/runtime/parser.h index cec9c083..d5d9243d 100644 --- a/runtime/parser.h +++ b/runtime/parser.h @@ -24,7 +24,21 @@ #ifndef INCLUDED_PARSE_H #define INCLUDED_PARSE_H -extern rsRetVal parserClassInit(void); -extern rsRetVal parseMsg(msg_t*); +/* the parser object, a dummy because we have only static methods */ +typedef struct parser_s { + BEGINobjInstance; /* Data to implement generic object - MUST be the first data element! */ +} parser_t; + +/* interfaces */ +BEGINinterface(parser) /* name must also be changed in ENDinterface macro! */ + INTERFACEObjDebugPrint(var); + rsRetVal (*ParseMsg)(msg_t *pMsg); +ENDinterface(parser) +#define parserCURR_IF_VERSION 1 /* increment whenever you change the interface above! */ + + +/* prototypes */ +PROTOTYPEObj(parser); + #endif /* #ifndef INCLUDED_PARSE_H */ -- cgit v1.2.3 From b1db196953713dd09c499a3edf81347bd903c19e Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 3 Nov 2009 18:44:02 +0100 Subject: one step closer to dynamically loadable parsers This is a milestone commit, which adds new code that breaks nothing, but also does not add any visible change. Just prep work... --- runtime/parser.h | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'runtime/parser.h') diff --git a/runtime/parser.h b/runtime/parser.h index d5d9243d..47521f63 100644 --- a/runtime/parser.h +++ b/runtime/parser.h @@ -1,8 +1,6 @@ /* header for parser.c - * This is not yet an object, but contains all those code necessary to - * parse syslog messages. * - * Copyright 2008 Rainer Gerhards and Adiscon GmbH. + * Copyright 2008,2009 Rainer Gerhards and Adiscon GmbH. * * This file is part of the rsyslog runtime library. * @@ -21,18 +19,43 @@ * * A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution. */ -#ifndef INCLUDED_PARSE_H -#define INCLUDED_PARSE_H +#ifndef INCLUDED_PARSER_H +#define INCLUDED_PARSER_H + + +/* we create a small helper object, a list of parsers, that we can use to + * build a chain of them whereever this is needed (initially thought to be + * used in ruleset.c as well as ourselvs). + */ +struct parserList_s { + parser_t *pParser; + parserList_t *pNext; +}; + /* the parser object, a dummy because we have only static methods */ -typedef struct parser_s { +struct parser_s { BEGINobjInstance; /* Data to implement generic object - MUST be the first data element! */ -} parser_t; + uchar *pName; /* name of this parser */ + modInfo_t *pModule; /* pointer to parser's module */ + bool bDoSanitazion; /* do standard message sanitazion before calling parser? */ +}; /* interfaces */ BEGINinterface(parser) /* name must also be changed in ENDinterface macro! */ INTERFACEObjDebugPrint(var); + rsRetVal (*Construct)(parser_t **ppThis); + rsRetVal (*ConstructFinalize)(parser_t *pThis); + rsRetVal (*Destruct)(parser_t **ppThis); + rsRetVal (*SetName)(parser_t *pThis, uchar *name); + rsRetVal (*SetModPtr)(parser_t *pThis, modInfo_t *pMod); + rsRetVal (*SetDoSanitazion)(parser_t *pThis, int); + rsRetVal (*FindParser)(parser_t **ppThis, uchar*name); + rsRetVal (*InitParserList)(parserList_t **pListRoot); + rsRetVal (*AddParserToList)(parserList_t **pListRoot, parser_t *pParser); + /* static functions */ rsRetVal (*ParseMsg)(msg_t *pMsg); + rsRetVal (*SanitizeMsg)(msg_t *pMsg); ENDinterface(parser) #define parserCURR_IF_VERSION 1 /* increment whenever you change the interface above! */ @@ -41,4 +64,4 @@ ENDinterface(parser) PROTOTYPEObj(parser); -#endif /* #ifndef INCLUDED_PARSE_H */ +#endif /* #ifndef INCLUDED_PARSER_H */ -- cgit v1.2.3 From 1b7f5c54684db29c096e09238648a45dce78ebee Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 4 Nov 2009 10:40:27 +0100 Subject: moved rfc3164/5424 code to new parser modules another milestone commit: the program works, the new interface is used, some more cleanup is needed and the per-ruleset config options are still missing. But we are getting closer... --- runtime/parser.h | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/parser.h') diff --git a/runtime/parser.h b/runtime/parser.h index 47521f63..d600fb19 100644 --- a/runtime/parser.h +++ b/runtime/parser.h @@ -56,6 +56,7 @@ BEGINinterface(parser) /* name must also be changed in ENDinterface macro! */ /* static functions */ rsRetVal (*ParseMsg)(msg_t *pMsg); rsRetVal (*SanitizeMsg)(msg_t *pMsg); + rsRetVal (*AddDfltParser)(uchar *); ENDinterface(parser) #define parserCURR_IF_VERSION 1 /* increment whenever you change the interface above! */ -- cgit v1.2.3 From ef661fe13c0ab5018afedb1cb5b8cffab05ad7c4 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 4 Nov 2009 11:33:09 +0100 Subject: finalized parser module calling interface looks like we are almost done and need only to add the ruleset parser-specific config options. --- runtime/parser.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime/parser.h') diff --git a/runtime/parser.h b/runtime/parser.h index d600fb19..a92b9920 100644 --- a/runtime/parser.h +++ b/runtime/parser.h @@ -39,6 +39,7 @@ struct parser_s { uchar *pName; /* name of this parser */ modInfo_t *pModule; /* pointer to parser's module */ bool bDoSanitazion; /* do standard message sanitazion before calling parser? */ + bool bDoPRIParsing; /* do standard PRI parsing before calling parser? */ }; /* interfaces */ @@ -50,6 +51,7 @@ BEGINinterface(parser) /* name must also be changed in ENDinterface macro! */ rsRetVal (*SetName)(parser_t *pThis, uchar *name); rsRetVal (*SetModPtr)(parser_t *pThis, modInfo_t *pMod); rsRetVal (*SetDoSanitazion)(parser_t *pThis, int); + rsRetVal (*SetDoPRIParsing)(parser_t *pThis, int); rsRetVal (*FindParser)(parser_t **ppThis, uchar*name); rsRetVal (*InitParserList)(parserList_t **pListRoot); rsRetVal (*AddParserToList)(parserList_t **pListRoot, parser_t *pParser); -- cgit v1.2.3 From aa2e8ea15b2001f131ebd196c180cc82aceb57b4 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 4 Nov 2009 15:34:31 +0100 Subject: first complete implementation of loadable parser system I have now done the necessary cleanup. Looks like everything is in place. Unfortunately, I do not yet have any actual parser that is not built-in, but I think we can postpone working on that when the first one appears. I don't expect troubles in that case, but you never know ;) --- runtime/parser.h | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/parser.h') diff --git a/runtime/parser.h b/runtime/parser.h index a92b9920..c4f63021 100644 --- a/runtime/parser.h +++ b/runtime/parser.h @@ -54,6 +54,7 @@ BEGINinterface(parser) /* name must also be changed in ENDinterface macro! */ rsRetVal (*SetDoPRIParsing)(parser_t *pThis, int); rsRetVal (*FindParser)(parser_t **ppThis, uchar*name); rsRetVal (*InitParserList)(parserList_t **pListRoot); + rsRetVal (*DestructParserList)(parserList_t **pListRoot); rsRetVal (*AddParserToList)(parserList_t **pListRoot, parser_t *pParser); /* static functions */ rsRetVal (*ParseMsg)(msg_t *pMsg); -- cgit v1.2.3