suricata
log-cf-common.h File Reference
#include "suricata-common.h"
#include "util-buffer.h"
Include dependency graph for log-cf-common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  LogCustomFormatNode_
 
struct  LogCustomFormat_
 

Macros

#define LOG_MAXN_NODES   64
 
#define LOG_NODE_STRLEN   256
 
#define LOG_NODE_MAXOUTPUTLEN   8192
 
#define TIMESTAMP_DEFAULT_FORMAT   "%D-%H:%M:%S"
 
#define TIMESTAMP_DEFAULT_FORMAT_LEN   62
 
#define LOG_CF_NONE   "-"
 
#define LOG_CF_LITERAL   '%'
 
#define LOG_CF_TIMESTAMP   't'
 
#define LOG_CF_TIMESTAMP_U   'z'
 
#define LOG_CF_CLIENT_IP   'a'
 
#define LOG_CF_SERVER_IP   'A'
 
#define LOG_CF_CLIENT_PORT   'p'
 
#define LOG_CF_SERVER_PORT   'P'
 
#define LOG_CF_STAR_SEPARATOR   "[**]"
 
#define LOG_CF_SPACE_SEPARATOR   " "
 
#define LOG_CF_UNKNOWN_VALUE   "-"
 
#define LOG_CF_WRITE_STAR_SEPATATOR(buffer)   MemBufferWriteString(buffer, LOG_CF_STAR_SEPARATOR);
 
#define LOG_CF_WRITE_SPACE_SEPARATOR(buffer)   MemBufferWriteString(buffer, LOG_CF_SPACE_SEPARATOR);
 
#define LOG_CF_WRITE_UNKNOWN_VALUE(buffer)   MemBufferWriteString(buffer, LOG_CF_UNKNOWN_VALUE);
 

Typedefs

typedef struct LogCustomFormatNode_ LogCustomFormatNode
 
typedef struct LogCustomFormat_ LogCustomFormat
 

Functions

LogCustomFormatNodeLogCustomFormatNodeAlloc (void)
 Creates a custom format node. More...
 
LogCustomFormatLogCustomFormatAlloc (void)
 Creates a custom format. More...
 
void LogCustomFormatNodeFree (LogCustomFormatNode *node)
 Frees memory held by a custom format node. More...
 
void LogCustomFormatFree (LogCustomFormat *cf)
 Frees memory held by a custom format. More...
 
void LogCustomFormatAddNode (LogCustomFormat *cf, LogCustomFormatNode *node)
 Adds a node to custom format. More...
 
int LogCustomFormatParse (LogCustomFormat *cf, const char *format)
 Parses and saves format nodes for custom format. More...
 
void LogCustomFormatWriteTimestamp (MemBuffer *buffer, const char *fmt, const struct timeval *ts)
 Writes a timestamp with given format into a MemBuffer. More...
 
void LogCustomFormatRegister (void)
 

Detailed Description

Macro Definition Documentation

#define LOG_CF_CLIENT_IP   'a'

Definition at line 43 of file log-cf-common.h.

Referenced by TLSGetIPInformations().

#define LOG_CF_CLIENT_PORT   'p'

Definition at line 45 of file log-cf-common.h.

Referenced by TLSGetIPInformations().

#define LOG_CF_LITERAL   '%'

Definition at line 40 of file log-cf-common.h.

Referenced by LogCustomFormatParse(), and TLSGetIPInformations().

#define LOG_CF_NONE   "-"

Definition at line 39 of file log-cf-common.h.

Referenced by TLSGetIPInformations().

#define LOG_CF_SERVER_IP   'A'

Definition at line 44 of file log-cf-common.h.

Referenced by TLSGetIPInformations().

#define LOG_CF_SERVER_PORT   'P'

Definition at line 46 of file log-cf-common.h.

Referenced by TLSGetIPInformations().

#define LOG_CF_SPACE_SEPARATOR   " "

Definition at line 50 of file log-cf-common.h.

#define LOG_CF_STAR_SEPARATOR   "[**]"

Definition at line 49 of file log-cf-common.h.

#define LOG_CF_TIMESTAMP   't'

Definition at line 41 of file log-cf-common.h.

Referenced by TLSGetIPInformations().

#define LOG_CF_TIMESTAMP_U   'z'

Definition at line 42 of file log-cf-common.h.

Referenced by TLSGetIPInformations().

#define LOG_CF_UNKNOWN_VALUE   "-"

Definition at line 51 of file log-cf-common.h.

#define LOG_CF_WRITE_SPACE_SEPARATOR (   buffer)    MemBufferWriteString(buffer, LOG_CF_SPACE_SEPARATOR);

Definition at line 56 of file log-cf-common.h.

Referenced by TLSGetIPInformations().

#define LOG_CF_WRITE_STAR_SEPATATOR (   buffer)    MemBufferWriteString(buffer, LOG_CF_STAR_SEPARATOR);

Definition at line 53 of file log-cf-common.h.

#define LOG_CF_WRITE_UNKNOWN_VALUE (   buffer)    MemBufferWriteString(buffer, LOG_CF_UNKNOWN_VALUE);

Definition at line 59 of file log-cf-common.h.

Referenced by TLSGetIPInformations().

#define LOG_MAXN_NODES   64

Definition at line 31 of file log-cf-common.h.

Referenced by LogCustomFormatAddNode(), and LogCustomFormatParse().

#define LOG_NODE_MAXOUTPUTLEN   8192

Definition at line 33 of file log-cf-common.h.

Referenced by LogCustomFormatParse().

#define LOG_NODE_STRLEN   256

Definition at line 32 of file log-cf-common.h.

Referenced by LogCustomFormatParse().

#define TIMESTAMP_DEFAULT_FORMAT   "%D-%H:%M:%S"

Definition at line 35 of file log-cf-common.h.

Referenced by LogCustomFormatWriteTimestamp().

#define TIMESTAMP_DEFAULT_FORMAT_LEN   62

Definition at line 36 of file log-cf-common.h.

Typedef Documentation

Function Documentation

void LogCustomFormatAddNode ( LogCustomFormat cf,
LogCustomFormatNode node 
)

Adds a node to custom format.

Parameters
LogCustomFormat* cf - custom format
LogCustomFormatNode* node - node to add

Definition at line 183 of file log-cf-common.c.

References LogCustomFormat_::cf_n, LogCustomFormat_::cf_nodes, LogCustomFormatNode_::data, LOG_MAXN_NODES, LogCustomFormatNode_::maxlen, SC_WARN_LOG_CF_TOO_MANY_NODES, SCLogDebug, SCLogWarning, and LogCustomFormatNode_::type.

Referenced by LogCustomFormatParse().

Here is the caller graph for this function:

LogCustomFormat* LogCustomFormatAlloc ( void  )

Creates a custom format.

Return values
LogCustomFormat* ptr if created
NULLif failed to allocate

Definition at line 52 of file log-cf-common.c.

References SC_ERR_MEM_ALLOC, SCCalloc, SCLogError, and unlikely.

Referenced by LogHttpLogInitCtx(), and TLSGetIPInformations().

Here is the caller graph for this function:

void LogCustomFormatFree ( LogCustomFormat cf)

Frees memory held by a custom format.

Parameters
LogCustomFormat* cf - format to relaease

Definition at line 78 of file log-cf-common.c.

References LogCustomFormat_::cf_n, LogCustomFormat_::cf_nodes, LogCustomFormatNodeFree(), and SCFree.

Referenced by LogHttpLogInitCtx(), and TLSGetIPInformations().

Here is the call graph for this function:

Here is the caller graph for this function:

LogCustomFormatNode* LogCustomFormatNodeAlloc ( void  )

Creates a custom format node.

Return values
LogCustomFormatNode* ptr if created
NULLif failed to allocate

Definition at line 37 of file log-cf-common.c.

References SC_ERR_MEM_ALLOC, SCCalloc, SCLogError, and unlikely.

Referenced by LogCustomFormatParse().

Here is the caller graph for this function:

void LogCustomFormatNodeFree ( LogCustomFormatNode node)

Frees memory held by a custom format node.

Parameters
LogCustomFormatNode* node - node to relaease

Definition at line 66 of file log-cf-common.c.

References SCFree.

Referenced by LogCustomFormatFree(), and LogCustomFormatParse().

Here is the caller graph for this function:

int LogCustomFormatParse ( LogCustomFormat cf,
const char *  format 
)

Parses and saves format nodes for custom format.

Parameters
LogCustomFormat* cf - custom format to build
constchar * format - string with format specification

Definition at line 94 of file log-cf-common.c.

References LogCustomFormat_::cf_n, LogCustomFormatNode_::data, LOG_CF_LITERAL, LOG_MAXN_NODES, LOG_NODE_MAXOUTPUTLEN, LOG_NODE_STRLEN, LogCustomFormatAddNode(), LogCustomFormatNodeAlloc(), LogCustomFormatNodeFree(), LogCustomFormatNode_::maxlen, strlcpy(), and LogCustomFormatNode_::type.

Referenced by LogHttpLogInitCtx(), and TLSGetIPInformations().

Here is the call graph for this function:

Here is the caller graph for this function:

void LogCustomFormatRegister ( void  )

Definition at line 269 of file log-cf-common.c.

Referenced by OutputRegisterLoggers().

Here is the caller graph for this function:

void LogCustomFormatWriteTimestamp ( MemBuffer buffer,
const char *  fmt,
const struct timeval *  ts 
)

Writes a timestamp with given format into a MemBuffer.

Parameters
MemBuffer* buffer - where to write
constchar * fmt - format to be used write timestamp
conststruct timeveal *ts - the timetstamp

Definition at line 209 of file log-cf-common.c.

References MemBuffer_::buffer, CreateFormattedTimeString(), FAIL_IF, FAIL_IF_NOT, LogCustomFormatWriteTimestamp(), MemBufferCreateNew(), MemBufferFree(), MemBuffer_::offset, PrintRawUriBuf(), SCLocalTime(), MemBuffer_::size, TIMESTAMP_DEFAULT_FORMAT, and UtRegisterTest().

Referenced by LogCustomFormatWriteTimestamp(), and TLSGetIPInformations().

Here is the call graph for this function:

Here is the caller graph for this function: