Go to the documentation of this file.
55 #define MODULE_NAME "AlertSyslog"
70 static void AlertSyslogDeInitCtx(
OutputCtx *output_ctx)
72 if (output_ctx != NULL) {
74 if (logfile_ctx != NULL) {
92 if (facility_s == NULL) {
97 if (logfile_ctx == NULL) {
98 SCLogDebug(
"AlertSyslogInitCtx: Could not create new LogFileCtx");
103 if (facility == -1) {
105 " now using \"%s\" as syslog facility",
111 if (level_s != NULL) {
114 alert_syslog_level = level;
122 openlog(ident, LOG_PID|LOG_NDELAY, facility);
130 memset(output_ctx, 0x00,
sizeof(
OutputCtx));
132 output_ctx->
data = logfile_ctx;
133 output_ctx->
DeInit = AlertSyslogDeInitCtx;
137 result.
ctx = output_ctx;
150 static TmEcode AlertSyslogThreadInit(
ThreadVars *t,
const void *initdata,
void **data)
152 if(initdata == NULL) {
153 SCLogDebug(
"Error getting context for AlertSyslog. \"initdata\" "
204 const char *action =
"";
210 const char *protoptr;
227 char srcip[16], dstip[16];
238 syslog(alert_syslog_level,
"%s[%" PRIu32
":%" PRIu32
":%"
239 PRIu32
"] %s [Classification: %s] [Priority: %"PRIu32
"]"
240 " {%s} %s:%" PRIu32
" -> %s:%" PRIu32
"", action, pa->
s->
gid,
242 protoptr, srcip, p->
sp, dstip, p->
dp);
262 const char *action =
"";
268 const char *protoptr;
284 char srcip[46], dstip[46];
295 syslog(alert_syslog_level,
"%s[%" PRIu32
":%" PRIu32
":%"
296 "" PRIu32
"] %s [Classification: %s] [Priority: %"
297 "" PRIu32
"] {%s} %s:%" PRIu32
" -> %s:%" PRIu32
"",
299 pa->
s->
prio, protoptr, srcip, p->
sp,
321 const char *action =
"";
328 char temp_buf_hdr[512];
329 char temp_buf_pkt[65] =
"";
330 char temp_buf_tail[64];
331 char alert[2048] =
"";
345 snprintf(temp_buf_hdr,
sizeof(temp_buf_hdr),
"%s[%" PRIu32
":%" PRIu32
346 ":%" PRIu32
"] %s [Classification: %s] [Priority: %" PRIu32
347 "] [**] [Raw pkt: ", action, pa->
s->
gid, pa->
s->
id, pa->
s->
rev, pa->
s->
msg,
349 strlcpy(alert, temp_buf_hdr,
sizeof(alert));
352 strlcat(alert, temp_buf_pkt,
sizeof(alert));
355 snprintf(temp_buf_tail,
sizeof(temp_buf_tail),
"] [pcap file packet: %"PRIu64
"]",
358 temp_buf_tail[0] =
']';
359 temp_buf_tail[1] =
'\0';
361 strlcat(alert, temp_buf_tail,
sizeof(alert));
363 syslog(alert_syslog_level,
"%s", alert);
378 return AlertSyslogIPv4(
tv, p, thread_data);
380 return AlertSyslogIPv6(
tv, p, thread_data);
382 return AlertSyslogDecoderEvent(
tv, p, thread_data);
395 AlertSyslogInitCtx, AlertSyslogLogger, AlertSyslogCondition,
396 AlertSyslogThreadInit, AlertSyslogThreadDeinit, NULL);
const struct Signature_ * s
#define syslog(__pri, __fmt, __param)
LogFileCtx * LogFileNewCtx(void)
LogFileNewCtx() Get a new LogFileCtx.
bool SCProtoNameValid(uint16_t proto)
Function to check if the received protocol number is valid and do we have corresponding name entry fo...
void AlertSyslogRegister(void)
Function to register the AlertSyslog module.
#define IPV6_GET_L4PROTO(p)
const char * known_proto[256]
#define GET_IPV6_DST_ADDR(p)
PacketEngineEvents events
#define DEFAULT_ALERT_SYSLOG_FACILITY
size_t strlcpy(char *dst, const char *src, size_t siz)
#define DEFAULT_ALERT_SYSLOG_LEVEL
#define IPV4_GET_IPPROTO(p)
#define GET_IPV4_DST_ADDR_PTR(p)
size_t strlcat(char *, const char *src, size_t siz)
SCEnumCharMap * SCSyslogGetFacilityMap(void)
returns the syslog facility enum map
#define SCMutexUnlock(mut)
#define DEFAULT_ALERT_SYSLOG_FACILITY_STR
Per thread variable structure.
const char * PrintInet(int af, const void *src, char *dst, socklen_t size)
#define SCLogWarning(...)
Macro used to log WARNING messages.
SCEnumCharMap * SCSyslogGetLogLevelMap(void)
returns the syslog facility enum map
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
#define GET_IPV4_SRC_ADDR_PTR(p)
int SCMapEnumNameToValue(const char *enum_name, SCEnumCharMap *table)
Maps a string name to an enum value from the supplied table. Please specify the last element of any m...
void(* DeInit)(struct OutputCtx_ *)
int LogFileFreeCtx(LogFileCtx *lf_ctx)
LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory)
void OutputRegisterPacketModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a packet output module.
#define GET_IPV6_SRC_ADDR(p)
int EngineModeIsIPS(void)
struct AlertSyslogThread_ AlertSyslogThread
#define openlog(__ident, __option, __facility)
void PrintRawLineHexBuf(char *retbuf, uint32_t retbuflen, const uint8_t *buf, uint32_t buflen)
print a buffer as hex on a single line into retbuf buffer
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.