~ubuntu-branches/ubuntu/lucid/rsyslog/lucid

« back to all changes in this revision

Viewing changes to msg.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2007-10-19 17:21:49 UTC
  • Revision ID: james.westby@ubuntu.com-20071019172149-ie6ej2xve33mxiu7
Tags: upstream-1.19.10
ImportĀ upstreamĀ versionĀ 1.19.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* msg.h
 
2
 * Header file for all msg-related functions.
 
3
 *
 
4
 * File begun on 2007-07-13 by RGerhards (extracted from syslogd.c)
 
5
 *
 
6
 * Copyright 2007 Rainer Gerhards and Adiscon GmbH.
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU General Public License
 
10
 * as published by the Free Software Foundation; either version 2
 
11
 * of the License, or (at your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
21
 *
 
22
 * A copy of the GPL can be found in the file "COPYING" in this distribution.
 
23
 */
 
24
#ifndef MSG_H_INCLUDED
 
25
#define MSG_H_INCLUDED 1
 
26
 
 
27
#include "syslogd-types.h"
 
28
#include "template.h"
 
29
 
 
30
/* rgerhards 2004-11-08: The following structure represents a
 
31
 * syslog message. 
 
32
 *
 
33
 * Important Note:
 
34
 * The message object is used for multiple purposes (once it
 
35
 * has been created). Once created, it actully is a read-only
 
36
 * object (though we do not specifically express this). In order
 
37
 * to avoid multiple copies of the same object, we use a
 
38
 * reference counter. This counter is set to 1 by the constructer
 
39
 * and increased by 1 with a call to MsgAddRef(). The destructor
 
40
 * checks the reference count. If it is more than 1, only the counter
 
41
 * will be decremented. If it is 1, however, the object is actually
 
42
 * destroyed. To make this work, it is vital that MsgAddRef() is
 
43
 * called each time a "copy" is stored somewhere.
 
44
 */
 
45
struct msg {
 
46
        int     iRefCount;      /* reference counter (0 = unused) */
 
47
        short   iSyslogVers;    /* version of syslog protocol
 
48
                                 * 0 - RFC 3164
 
49
                                 * 1 - RFC draft-protocol-08 */
 
50
        short   bParseHOSTNAME; /* should the hostname be parsed from the message? */
 
51
           /* background: the hostname is not present on "regular" messages
 
52
            * received via UNIX domain sockets from the same machine. However,
 
53
            * it is available when we have a forwarder (e.g. rfc3195d) using local
 
54
            * sockets. All in all, the parser would need parse templates, that would
 
55
            * resolve all these issues... rgerhards, 2005-10-06
 
56
            */
 
57
        short   iSeverity;      /* the severity 0..7 */
 
58
        uchar *pszSeverity;     /* severity as string... */
 
59
        int iLenSeverity;       /* ... and its length. */
 
60
        uchar *pszSeverityStr;   /* severity name... */
 
61
        int iLenSeverityStr;    /* ... and its length. */
 
62
        int     iFacility;      /* Facility code (up to 2^32-1) */
 
63
        uchar *pszFacility;     /* Facility as string... */
 
64
        int iLenFacility;       /* ... and its length. */
 
65
        uchar *pszFacilityStr;   /* facility name... */
 
66
        int iLenFacilityStr;    /* ... and its length. */
 
67
        uchar *pszPRI;          /* the PRI as a string */
 
68
        int iLenPRI;            /* and its length */
 
69
        uchar   *pszRawMsg;     /* message as it was received on the
 
70
                                 * wire. This is important in case we
 
71
                                 * need to preserve cryptographic verifiers.
 
72
                                 */
 
73
        int     iLenRawMsg;     /* length of raw message */
 
74
        uchar   *pszMSG;        /* the MSG part itself */
 
75
        int     iLenMSG;        /* Length of the MSG part */
 
76
        uchar   *pszUxTradMsg;  /* the traditional UNIX message */
 
77
        int     iLenUxTradMsg;/* Length of the traditional UNIX message */
 
78
        uchar   *pszTAG;        /* pointer to tag value */
 
79
        int     iLenTAG;        /* Length of the TAG part */
 
80
        uchar   *pszHOSTNAME;   /* HOSTNAME from syslog message */
 
81
        int     iLenHOSTNAME;   /* Length of HOSTNAME */
 
82
        uchar   *pszRcvFrom;    /* System message was received from */
 
83
        int     iLenRcvFrom;    /* Length of pszRcvFrom */
 
84
        int     iProtocolVersion;/* protocol version of message received 0 - legacy, 1 syslog-protocol) */
 
85
        rsCStrObj *pCSProgName; /* the (BSD) program name */
 
86
        rsCStrObj *pCSStrucData;/* STRUCTURED-DATA */
 
87
        rsCStrObj *pCSAPPNAME;  /* APP-NAME */
 
88
        rsCStrObj *pCSPROCID;   /* PROCID */
 
89
        rsCStrObj *pCSMSGID;    /* MSGID */
 
90
        struct syslogTime tRcvdAt;/* time the message entered this program */
 
91
        char *pszRcvdAt3164;    /* time as RFC3164 formatted string (always 15 charcters) */
 
92
        char *pszRcvdAt3339;    /* time as RFC3164 formatted string (32 charcters at most) */
 
93
        char *pszRcvdAt_MySQL;  /* rcvdAt as MySQL formatted string (always 14 charcters) */
 
94
        struct syslogTime tTIMESTAMP;/* (parsed) value of the timestamp */
 
95
        char *pszTIMESTAMP3164; /* TIMESTAMP as RFC3164 formatted string (always 15 charcters) */
 
96
        char *pszTIMESTAMP3339; /* TIMESTAMP as RFC3339 formatted string (32 charcters at most) */
 
97
        char *pszTIMESTAMP_MySQL;/* TIMESTAMP as MySQL formatted string (always 14 charcters) */
 
98
        int msgFlags;           /* flags associated with this message */
 
99
};
 
100
typedef struct msg msg_t;       /* new name */
 
101
 
 
102
/* function prototypes
 
103
 */
 
104
char* getProgramName(msg_t*);
 
105
msg_t* MsgConstruct(void);
 
106
void MsgDestruct(msg_t * pM);
 
107
msg_t* MsgDup(msg_t* pOld);
 
108
msg_t *MsgAddRef(msg_t *pM);
 
109
void setProtocolVersion(msg_t *pM, int iNewVersion);
 
110
int getProtocolVersion(msg_t *pM);
 
111
char *getProtocolVersionString(msg_t *pM);
 
112
int getMSGLen(msg_t *pM);
 
113
char *getRawMsg(msg_t *pM);
 
114
char *getUxTradMsg(msg_t *pM);
 
115
char *getMSG(msg_t *pM);
 
116
char *getPRI(msg_t *pM);
 
117
int getPRIi(msg_t *pM);
 
118
char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt);
 
119
char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt);
 
120
char *getSeverity(msg_t *pM);
 
121
char *getSeverityStr(msg_t *pM);
 
122
char *getFacility(msg_t *pM);
 
123
char *getFacilityStr(msg_t *pM);
 
124
rsRetVal MsgSetAPPNAME(msg_t *pMsg, char* pszAPPNAME);
 
125
int getAPPNAMELen(msg_t *pM);
 
126
char *getAPPNAME(msg_t *pM);
 
127
rsRetVal MsgSetPROCID(msg_t *pMsg, char* pszPROCID);
 
128
int getPROCIDLen(msg_t *pM);
 
129
char *getPROCID(msg_t *pM);
 
130
rsRetVal MsgSetMSGID(msg_t *pMsg, char* pszMSGID);
 
131
void MsgAssignTAG(msg_t *pMsg, uchar *pBuf);
 
132
void MsgSetTAG(msg_t *pMsg, char* pszTAG);
 
133
char *getTAG(msg_t *pM);
 
134
int getHOSTNAMELen(msg_t *pM);
 
135
char *getHOSTNAME(msg_t *pM);
 
136
char *getRcvFrom(msg_t *pM);
 
137
rsRetVal MsgSetStructuredData(msg_t *pMsg, char* pszStrucData);
 
138
char *getStructuredData(msg_t *pM);
 
139
int getProgramNameLen(msg_t *pM);
 
140
char *getProgramName(msg_t *pM);
 
141
void MsgSetRcvFrom(msg_t *pMsg, char* pszRcvFrom);
 
142
void MsgAssignHOSTNAME(msg_t *pMsg, char *pBuf);
 
143
void MsgSetHOSTNAME(msg_t *pMsg, char* pszHOSTNAME);
 
144
int MsgSetUxTradMsg(msg_t *pMsg, char* pszUxTradMsg);
 
145
void MsgSetMSG(msg_t *pMsg, char* pszMSG);
 
146
void MsgSetRawMsg(msg_t *pMsg, char* pszRawMsg);
 
147
void moveHOSTNAMEtoTAG(msg_t *pM);
 
148
char *getMSGID(msg_t *pM);
 
149
char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
 
150
                 rsCStrObj *pCSPropName, unsigned short *pbMustBeFreed);
 
151
char *textpri(char *pRes, size_t pResLen, int pri);
 
152
 
 
153
#endif /* #ifndef MSG_H_INCLUDED */
 
154
/*
 
155
 * vi:set ai:
 
156
 */