suricata
log-tlslog.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2014 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Roliers Jean-Paul <popof.fpn@gmail.co>
22  * \author Eric Leblond <eric@regit.org>
23  * \author Victor Julien <victor@inliniac.net>
24  * \author Paulo Pacheco <fooinha@gmail.com>
25  *
26  * Implements TLS logging portion of the engine.
27  */
28 
29 #include "suricata-common.h"
30 #include "detect.h"
31 #include "pkt-var.h"
32 #include "conf.h"
33 
34 #include "threads.h"
35 #include "threadvars.h"
36 #include "tm-threads.h"
37 
38 #include "util-print.h"
39 #include "util-unittest.h"
40 
41 #include "util-debug.h"
42 
43 #include "output.h"
44 #include "log-tlslog.h"
45 #include "app-layer-ssl.h"
46 #include "app-layer.h"
47 #include "app-layer-parser.h"
48 #include "util-privs.h"
49 #include "util-buffer.h"
50 
51 #include "util-logopenfile.h"
52 #include "util-time.h"
53 #include "log-cf-common.h"
54 
55 #define DEFAULT_LOG_FILENAME "tls.log"
56 
57 #define MODULE_NAME "LogTlsLog"
58 
59 #define PRINT_BUF_LEN 46
60 
61 #define OUTPUT_BUFFER_SIZE 65535
62 #define CERT_ENC_BUFFER_SIZE 2048
63 
64 #define LOG_TLS_DEFAULT 0
65 #define LOG_TLS_EXTENDED 1
66 #define LOG_TLS_CUSTOM 2
67 
68 #define LOG_TLS_SESSION_RESUMPTION 4
69 
70 #define LOG_TLS_CF_VERSION 'v'
71 #define LOG_TLS_CF_DATE_NOT_BEFORE 'd'
72 #define LOG_TLS_CF_DATE_NOT_AFTER 'D'
73 #define LOG_TLS_CF_SHA1 'f'
74 #define LOG_TLS_CF_SNI 'n'
75 #define LOG_TLS_CF_SUBJECT 's'
76 #define LOG_TLS_CF_ISSUER 'i'
77 #define LOG_TLS_CF_EXTENDED 'E'
78 
79 typedef struct LogTlsFileCtx_ {
81  uint32_t flags; /** Store mode */
84 
85 typedef struct LogTlsLogThread_ {
87 
88  /* LogTlsFileCtx has the pointer to the file and a mutex to allow
89  multithreading. */
90  uint32_t tls_cnt;
91 
94 
95 int TLSGetIPInformations(const Packet *p, char* srcip, size_t srcip_len,
96  Port* sp, char* dstip, size_t dstip_len, Port* dp,
97  int ipproto)
98 {
99  if ((PKT_IS_TOSERVER(p))) {
100  switch (ipproto) {
101  case AF_INET:
102  PrintInet(AF_INET, (const void *) GET_IPV4_SRC_ADDR_PTR(p),
103  srcip, srcip_len);
104  PrintInet(AF_INET, (const void *) GET_IPV4_DST_ADDR_PTR(p),
105  dstip, dstip_len);
106  break;
107  case AF_INET6:
108  PrintInet(AF_INET6, (const void *) GET_IPV6_SRC_ADDR(p), srcip,
109  srcip_len);
110  PrintInet(AF_INET6, (const void *) GET_IPV6_DST_ADDR(p), dstip,
111  dstip_len);
112  break;
113  default:
114  return 0;
115  }
116  *sp = p->sp;
117  *dp = p->dp;
118  } else {
119  switch (ipproto) {
120  case AF_INET:
121  PrintInet(AF_INET, (const void *) GET_IPV4_DST_ADDR_PTR(p),
122  srcip, srcip_len);
123  PrintInet(AF_INET, (const void *) GET_IPV4_SRC_ADDR_PTR(p),
124  dstip, dstip_len);
125  break;
126  case AF_INET6:
127  PrintInet(AF_INET6, (const void *) GET_IPV6_DST_ADDR(p), srcip,
128  srcip_len);
129  PrintInet(AF_INET6, (const void *) GET_IPV6_SRC_ADDR(p), dstip,
130  dstip_len);
131  break;
132  default:
133  return 0;
134  }
135  *sp = p->dp;
136  *dp = p->sp;
137  }
138  return 1;
139 }
140 
141 static TmEcode LogTlsLogThreadInit(ThreadVars *t, const void *initdata,
142  void **data)
143 {
144  LogTlsLogThread *aft = SCCalloc(1, sizeof(LogTlsLogThread));
145  if (unlikely(aft == NULL))
146  return TM_ECODE_FAILED;
147 
148  if (initdata == NULL) {
149  SCLogDebug("Error getting context for TLSLog. \"initdata\" argument NULL");
150  SCFree(aft);
151  return TM_ECODE_FAILED;
152  }
153 
155  if (aft->buffer == NULL) {
156  SCFree(aft);
157  return TM_ECODE_FAILED;
158  }
159 
160  /* Use the Output Context (file pointer and mutex) */
161  aft->tlslog_ctx = ((OutputCtx *) initdata)->data;
162 
163  *data = (void *)aft;
164  return TM_ECODE_OK;
165 }
166 
167 static TmEcode LogTlsLogThreadDeinit(ThreadVars *t, void *data)
168 {
169  LogTlsLogThread *aft = (LogTlsLogThread *)data;
170  if (aft == NULL) {
171  return TM_ECODE_OK;
172  }
173 
174  MemBufferFree(aft->buffer);
175  memset(aft, 0, sizeof(LogTlsLogThread));
176 
177  SCFree(aft);
178  return TM_ECODE_OK;
179 }
180 
181 static void LogTlsLogDeInitCtx(OutputCtx *output_ctx)
182 {
183  LogTlsFileCtx *tlslog_ctx = (LogTlsFileCtx *) output_ctx->data;
184  LogFileFreeCtx(tlslog_ctx->file_ctx);
185  LogCustomFormatFree(tlslog_ctx->cf);
186  SCFree(tlslog_ctx);
187  SCFree(output_ctx);
188 }
189 
190 static void LogTlsLogExitPrintStats(ThreadVars *tv, void *data)
191 {
192  LogTlsLogThread *aft = (LogTlsLogThread *)data;
193  if (aft == NULL) {
194  return;
195  }
196 
197  SCLogInfo("TLS logger logged %" PRIu32 " requests", aft->tls_cnt);
198 }
199 
200 /** \brief Create a new tls log LogFileCtx.
201  * \param conf Pointer to ConfNode containing this loggers configuration.
202  * \return NULL if failure, LogFileCtx* to the file_ctx if succesful
203  * */
204 static OutputInitResult LogTlsLogInitCtx(ConfNode *conf)
205 {
206  OutputInitResult result = { NULL, false };
207  LogFileCtx* file_ctx = LogFileNewCtx();
208 
209  if (file_ctx == NULL) {
210  SCLogError("LogTlsLogInitCtx: Couldn't "
211  "create new file_ctx");
212  return result;
213  }
214 
215  if (SCConfLogOpenGeneric(conf, file_ctx, DEFAULT_LOG_FILENAME, 1) < 0) {
216  goto filectx_error;
217  }
218 
219  LogTlsFileCtx *tlslog_ctx = SCCalloc(1, sizeof(LogTlsFileCtx));
220  if (unlikely(tlslog_ctx == NULL)) {
221  goto filectx_error;
222  }
223  tlslog_ctx->file_ctx = file_ctx;
224 
225  const char *extended = ConfNodeLookupChildValue(conf, "extended");
226  const char *custom = ConfNodeLookupChildValue(conf, "custom");
227  const char *customformat = ConfNodeLookupChildValue(conf, "customformat");
228 
229  /* If custom logging format is selected, lets parse it */
230  if (custom != NULL && customformat != NULL && ConfValIsTrue(custom)) {
231  tlslog_ctx->cf = LogCustomFormatAlloc();
232  if (!tlslog_ctx->cf) {
233  goto tlslog_error;
234  }
235 
236  tlslog_ctx->flags |= LOG_TLS_CUSTOM;
237 
238  if (!LogCustomFormatParse(tlslog_ctx->cf, customformat)) {
239  goto parser_error;
240  }
241  } else {
242  if (extended == NULL) {
243  tlslog_ctx->flags |= LOG_TLS_DEFAULT;
244  } else {
245  if (ConfValIsTrue(extended)) {
246  tlslog_ctx->flags |= LOG_TLS_EXTENDED;
247  }
248  }
249  }
250 
251  const char *resumption = ConfNodeLookupChildValue(conf,
252  "session-resumption");
253  if (resumption == NULL || ConfValIsTrue(resumption)) {
254  tlslog_ctx->flags |= LOG_TLS_SESSION_RESUMPTION;
255  }
256 
257  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
258  if (unlikely(output_ctx == NULL)) {
259  goto tlslog_error;
260  }
261  output_ctx->data = tlslog_ctx;
262  output_ctx->DeInit = LogTlsLogDeInitCtx;
263 
264  SCLogDebug("TLS log output initialized");
265 
266  /* Enable the logger for the app layer */
268 
269  result.ctx = output_ctx;
270  result.ok = true;
271  return result;
272 
273 parser_error:
274  SCLogError("Syntax error in custom tls log "
275  "format string.");
276 tlslog_error:
277  LogCustomFormatFree(tlslog_ctx->cf);
278  SCFree(tlslog_ctx);
279 filectx_error:
280  LogFileFreeCtx(file_ctx);
281  return result;
282 }
283 
284 static void LogTlsLogVersion(MemBuffer *buffer, uint16_t version)
285 {
286  char ssl_version[SSL_VERSION_MAX_STRLEN];
287  SSLVersionToString(version, ssl_version);
288  MemBufferWriteString(buffer, "VERSION='%s'", ssl_version);
289 }
290 
291 static void LogTlsLogDate(MemBuffer *buffer, const char *title, int64_t *date)
292 {
293  char timebuf[64] = {0};
294  if (sc_x509_format_timestamp(*date, timebuf, sizeof(timebuf))) {
295  MemBufferWriteString(buffer, "%s='%s'", title, timebuf);
296  }
297 }
298 
299 static void LogTlsLogString(MemBuffer *buffer, const char *title,
300  const char *value)
301 {
302  MemBufferWriteString(buffer, "%s='%s'", title, value);
303 }
304 
305 static void LogTlsLogBasic(LogTlsLogThread *aft, SSLState *ssl_state, const SCTime_t ts,
306  char *srcip, Port sp, char *dstip, Port dp)
307 {
308  char timebuf[64];
309  CreateTimeString(ts, timebuf, sizeof(timebuf));
311  "%s %s:%d -> %s:%d TLS:",
312  timebuf, srcip, sp, dstip, dp);
313 
314  if (ssl_state->server_connp.cert0_subject != NULL) {
315  MemBufferWriteString(aft->buffer, " Subject='%s'",
316  ssl_state->server_connp.cert0_subject);
317  }
318 
319  if (ssl_state->server_connp.cert0_issuerdn != NULL) {
320  MemBufferWriteString(aft->buffer, " Issuerdn='%s'",
321  ssl_state->server_connp.cert0_issuerdn);
322  }
323 
324  if (ssl_state->flags & SSL_AL_FLAG_SESSION_RESUMED) {
325  /* Only log a session as 'resumed' if a certificate has not
326  been seen. */
327  if ((ssl_state->server_connp.cert0_issuerdn == NULL) &&
328  (ssl_state->server_connp.cert0_subject == NULL) &&
329  (ssl_state->flags & SSL_AL_FLAG_STATE_SERVER_HELLO) &&
330  ((ssl_state->flags & SSL_AL_FLAG_LOG_WITHOUT_CERT) == 0)) {
331  MemBufferWriteString(aft->buffer, " Session='resumed'");
332  }
333  }
334 }
335 
336 static void LogTlsLogExtended(LogTlsLogThread *aft, SSLState *ssl_state, const SCTime_t ts,
337  char *srcip, Port sp, char *dstip, Port dp)
338 {
339  if (ssl_state->server_connp.cert0_fingerprint != NULL) {
341  LogTlsLogString(aft->buffer, "SHA1",
342  ssl_state->server_connp.cert0_fingerprint);
343  }
344  if (ssl_state->client_connp.sni != NULL) {
346  LogTlsLogString(aft->buffer, "SNI", ssl_state->client_connp.sni);
347  }
348  if (ssl_state->server_connp.cert0_serial != NULL) {
350  LogTlsLogString(aft->buffer, "SERIAL",
351  ssl_state->server_connp.cert0_serial);
352  }
353 
355  LogTlsLogVersion(aft->buffer, ssl_state->server_connp.version);
356 
357  if (ssl_state->server_connp.cert0_not_before != 0) {
359  LogTlsLogDate(aft->buffer, "NOTBEFORE",
360  &ssl_state->server_connp.cert0_not_before);
361  }
362  if (ssl_state->server_connp.cert0_not_after != 0) {
364  LogTlsLogDate(aft->buffer, "NOTAFTER",
365  &ssl_state->server_connp.cert0_not_after);
366  }
367 }
368 
369 /* Custom format logging */
370 static void LogTlsLogCustom(LogTlsLogThread *aft, SSLState *ssl_state, const SCTime_t ts,
371  char *srcip, Port sp, char *dstip, Port dp)
372 {
373  LogTlsFileCtx *tlslog_ctx = aft->tlslog_ctx;
374  uint32_t i;
375  char buf[64];
376 
377  for (i = 0; i < tlslog_ctx->cf->cf_n; i++)
378  {
379  LogCustomFormatNode *node = tlslog_ctx->cf->cf_nodes[i];
380  if (!node) /* Should never happen */
381  continue;
382 
383  switch (node->type) {
384  case LOG_CF_LITERAL:
385  /* LITERAL */
386  MemBufferWriteString(aft->buffer, "%s", node->data);
387  break;
388  case LOG_CF_TIMESTAMP:
389  /* TIMESTAMP */
391  break;
392  case LOG_CF_TIMESTAMP_U:
393  /* TIMESTAMP USECONDS */
394  snprintf(buf, sizeof(buf), "%06u", (unsigned int)SCTIME_USECS(ts));
395  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset, aft->buffer->size,
396  (uint8_t *)buf, MIN(strlen(buf), 6));
397  break;
398  case LOG_CF_CLIENT_IP:
399  /* CLIENT IP ADDRESS */
400  PrintRawUriBuf((char *)aft->buffer->buffer,
401  &aft->buffer->offset, aft->buffer->size,
402  (uint8_t *)srcip,strlen(srcip));
403  break;
404  case LOG_CF_SERVER_IP:
405  /* SERVER IP ADDRESS */
406  PrintRawUriBuf((char *)aft->buffer->buffer,
407  &aft->buffer->offset, aft->buffer->size,
408  (uint8_t *)dstip, strlen(dstip));
409  break;
410  case LOG_CF_CLIENT_PORT:
411  /* CLIENT PORT */
412  MemBufferWriteString(aft->buffer, "%" PRIu16 "", sp);
413  break;
414  case LOG_CF_SERVER_PORT:
415  /* SERVER PORT */
416  MemBufferWriteString(aft->buffer, "%" PRIu16 "", dp);
417  break;
418  case LOG_TLS_CF_VERSION:
419  LogTlsLogVersion(aft->buffer, ssl_state->server_connp.version);
420  break;
422  LogTlsLogDate(aft->buffer, "NOTBEFORE",
423  &ssl_state->server_connp.cert0_not_before);
424  break;
426  LogTlsLogDate(aft->buffer, "NOTAFTER",
427  &ssl_state->server_connp.cert0_not_after);
428  break;
429  case LOG_TLS_CF_SHA1:
430  if (ssl_state->server_connp.cert0_fingerprint != NULL) {
431  MemBufferWriteString(aft->buffer, "%s",
432  ssl_state->server_connp.cert0_fingerprint);
433  } else {
435  }
436  break;
437  case LOG_TLS_CF_SNI:
438  if (ssl_state->client_connp.sni != NULL) {
439  MemBufferWriteString(aft->buffer, "%s",
440  ssl_state->client_connp.sni);
441  } else {
443  }
444  break;
445  case LOG_TLS_CF_SUBJECT:
446  if (ssl_state->server_connp.cert0_subject != NULL) {
447  MemBufferWriteString(aft->buffer, "%s",
448  ssl_state->server_connp.cert0_subject);
449  } else {
451  }
452  break;
453  case LOG_TLS_CF_ISSUER:
454  if (ssl_state->server_connp.cert0_issuerdn != NULL) {
455  MemBufferWriteString(aft->buffer, "%s",
456  ssl_state->server_connp.cert0_issuerdn);
457  } else {
459  }
460  break;
461  case LOG_TLS_CF_EXTENDED:
462  /* Extended format */
463  LogTlsLogExtended(aft, ssl_state, ts, srcip, sp, dstip, dp);
464  break;
465  default:
466  /* NO MATCH */
468  SCLogDebug("No matching parameter %%%c for custom tls log.",
469  node->type);
470  break;
471  }
472  }
473 }
474 
475 
476 static int LogTlsLogger(ThreadVars *tv, void *thread_data, const Packet *p,
477  Flow *f, void *state, void *tx, uint64_t tx_id)
478 {
479  LogTlsLogThread *aft = (LogTlsLogThread *)thread_data;
480  LogTlsFileCtx *hlog = aft->tlslog_ctx;
481  int ipproto = (PKT_IS_IPV4(p)) ? AF_INET : AF_INET6;
482 
483  SSLState *ssl_state = (SSLState *)state;
484  if (unlikely(ssl_state == NULL)) {
485  return 0;
486  }
487 
488  if (((hlog->flags & LOG_TLS_SESSION_RESUMPTION) == 0 ||
489  (ssl_state->flags & SSL_AL_FLAG_SESSION_RESUMED) == 0) &&
490  (ssl_state->server_connp.cert0_issuerdn == NULL ||
491  ssl_state->server_connp.cert0_subject == NULL) &&
492  ((ssl_state->flags & SSL_AL_FLAG_LOG_WITHOUT_CERT) == 0)) {
493  return 0;
494  }
495 
496  char srcip[PRINT_BUF_LEN], dstip[PRINT_BUF_LEN];
497 
498  Port sp, dp;
499  if (!TLSGetIPInformations(p, srcip, PRINT_BUF_LEN, &sp, dstip,
500  PRINT_BUF_LEN, &dp, ipproto)) {
501  return 0;
502  }
503 
504  MemBufferReset(aft->buffer);
505 
506  if (hlog->flags & LOG_TLS_CUSTOM) {
507  LogTlsLogCustom(aft, ssl_state, p->ts, srcip, sp, dstip, dp);
508  } else if (hlog->flags & LOG_TLS_EXTENDED) {
509  LogTlsLogBasic(aft, ssl_state, p->ts, srcip, sp, dstip, dp);
510  LogTlsLogExtended(aft, ssl_state, p->ts, srcip, sp, dstip, dp);
511  } else {
512  LogTlsLogBasic(aft, ssl_state, p->ts, srcip, sp, dstip, dp);
513  }
514 
515  MemBufferWriteString(aft->buffer, "\n");
516 
517  aft->tls_cnt++;
518 
519  hlog->file_ctx->Write((const char *)MEMBUFFER_BUFFER(aft->buffer),
520  MEMBUFFER_OFFSET(aft->buffer), hlog->file_ctx);
521 
522  return 0;
523 }
524 
526 {
528  LogTlsLogInitCtx, ALPROTO_TLS, LogTlsLogger, TLS_HANDSHAKE_DONE,
529  TLS_HANDSHAKE_DONE, LogTlsLogThreadInit, LogTlsLogThreadDeinit,
530  LogTlsLogExitPrintStats);
531 }
LogCustomFormatFree
void LogCustomFormatFree(LogCustomFormat *cf)
Frees memory held by a custom format.
Definition: log-cf-common.c:80
tm-threads.h
SSLStateConnp_::cert0_subject
char * cert0_subject
Definition: app-layer-ssl.h:250
SSLState_
SSLv[2.0|3.[0|1|2|3]] state structure.
Definition: app-layer-ssl.h:288
ts
uint64_t ts
Definition: source-erf-file.c:55
MemBuffer_::buffer
uint8_t buffer[]
Definition: util-buffer.h:30
LOG_TLS_SESSION_RESUMPTION
#define LOG_TLS_SESSION_RESUMPTION
Definition: log-tlslog.c:68
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
SSLState_::client_connp
SSLStateConnp client_connp
Definition: app-layer-ssl.h:306
ALPROTO_TLS
@ ALPROTO_TLS
Definition: app-layer-protos.h:33
LogFileNewCtx
LogFileCtx * LogFileNewCtx(void)
LogFileNewCtx() Get a new LogFileCtx.
Definition: util-logopenfile.c:659
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
LogTlsFileCtx_::flags
uint32_t flags
Definition: log-tlslog.c:81
OUTPUT_BUFFER_SIZE
#define OUTPUT_BUFFER_SIZE
Definition: log-tlslog.c:61
DEFAULT_LOG_FILENAME
#define DEFAULT_LOG_FILENAME
Definition: log-tlslog.c:55
SSLState_::server_connp
SSLStateConnp server_connp
Definition: app-layer-ssl.h:307
SSLStateConnp_::cert0_not_before
int64_t cert0_not_before
Definition: app-layer-ssl.h:253
SSL_AL_FLAG_SESSION_RESUMED
#define SSL_AL_FLAG_SESSION_RESUMED
Definition: app-layer-ssl.h:116
threads.h
Flow_
Flow data structure.
Definition: flow.h:351
LogTlsLogRegister
void LogTlsLogRegister(void)
Definition: log-tlslog.c:525
SSL_AL_FLAG_STATE_SERVER_HELLO
#define SSL_AL_FLAG_STATE_SERVER_HELLO
Definition: app-layer-ssl.h:99
LogTlsLogThread_::buffer
MemBuffer * buffer
Definition: log-tlslog.c:92
LogFileCtx_
Definition: util-logopenfile.h:76
LOG_CF_LITERAL
#define LOG_CF_LITERAL
Definition: log-cf-common.h:39
SSL_VERSION_MAX_STRLEN
#define SSL_VERSION_MAX_STRLEN
Definition: app-layer-ssl.h:154
LogTlsFileCtx_::file_ctx
LogFileCtx * file_ctx
Definition: log-tlslog.c:80
LOG_TLS_CUSTOM
#define LOG_TLS_CUSTOM
Definition: log-tlslog.c:66
MIN
#define MIN(x, y)
Definition: suricata-common.h:391
util-privs.h
LogFileCtx_::Write
int(* Write)(const char *buffer, int buffer_len, struct LogFileCtx_ *fp)
Definition: util-logopenfile.h:91
SSLStateConnp_::sni
char * sni
Definition: app-layer-ssl.h:258
TM_ECODE_FAILED
@ TM_ECODE_FAILED
Definition: tm-threads-common.h:85
LogCustomFormatWriteTimestamp
void LogCustomFormatWriteTimestamp(MemBuffer *buffer, const char *fmt, const SCTime_t ts)
Writes a timestamp with given format into a MemBuffer.
Definition: log-cf-common.c:211
LOG_CF_CLIENT_PORT
#define LOG_CF_CLIENT_PORT
Definition: log-cf-common.h:44
GET_IPV6_DST_ADDR
#define GET_IPV6_DST_ADDR(p)
Definition: decode.h:216
util-unittest.h
MemBuffer_::offset
uint32_t offset
Definition: util-buffer.h:29
SSLStateConnp_::cert0_issuerdn
char * cert0_issuerdn
Definition: app-layer-ssl.h:251
ConfValIsTrue
int ConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:537
OutputCtx_::data
void * data
Definition: tm-modules.h:88
TM_ECODE_OK
@ TM_ECODE_OK
Definition: tm-threads-common.h:84
OutputCtx_
Definition: tm-modules.h:85
SCConfLogOpenGeneric
int SCConfLogOpenGeneric(ConfNode *conf, LogFileCtx *log_ctx, const char *default_filename, int rotate)
open a generic output "log file", which may be a regular file or a socket
Definition: util-logopenfile.c:452
SSLStateConnp_::cert0_not_after
int64_t cert0_not_after
Definition: app-layer-ssl.h:254
LogCustomFormat_::cf_n
uint32_t cf_n
Definition: log-cf-common.h:72
LogCustomFormatNode_
Definition: log-cf-common.h:64
PRINT_BUF_LEN
#define PRINT_BUF_LEN
Definition: log-tlslog.c:59
LOG_TLS_DEFAULT
#define LOG_TLS_DEFAULT
Definition: log-tlslog.c:64
LogCustomFormatNode_::type
uint32_t type
Definition: log-cf-common.h:65
LOG_TLS_CF_DATE_NOT_AFTER
#define LOG_TLS_CF_DATE_NOT_AFTER
Definition: log-tlslog.c:72
MODULE_NAME
#define MODULE_NAME
Definition: log-tlslog.c:57
LOG_TLS_CF_SUBJECT
#define LOG_TLS_CF_SUBJECT
Definition: log-tlslog.c:75
util-debug.h
GET_IPV4_DST_ADDR_PTR
#define GET_IPV4_DST_ADDR_PTR(p)
Definition: decode.h:211
PKT_IS_TOSERVER
#define PKT_IS_TOSERVER(p)
Definition: decode.h:252
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:47
Packet_::ts
SCTime_t ts
Definition: decode.h:485
LOG_CF_CLIENT_IP
#define LOG_CF_CLIENT_IP
Definition: log-cf-common.h:42
LOG_CF_TIMESTAMP
#define LOG_CF_TIMESTAMP
Definition: log-cf-common.h:40
TLS_HANDSHAKE_DONE
@ TLS_HANDSHAKE_DONE
Definition: app-layer-ssl.h:79
AppLayerParserRegisterLogger
void AppLayerParserRegisterLogger(uint8_t ipproto, AppProto alproto)
Definition: app-layer-parser.c:469
LogTlsLogThread
struct LogTlsLogThread_ LogTlsLogThread
util-print.h
detect.h
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:57
PrintInet
const char * PrintInet(int af, const void *src, char *dst, socklen_t size)
Definition: util-print.c:241
pkt-var.h
Packet_::sp
Port sp
Definition: decode.h:444
LOG_CF_SERVER_PORT
#define LOG_CF_SERVER_PORT
Definition: log-cf-common.h:45
SSLVersionToString
void SSLVersionToString(uint16_t version, char *buffer)
Definition: app-layer-ssl.c:345
util-time.h
OutputInitResult_::ok
bool ok
Definition: output.h:48
log-tlslog.h
LOGGER_TLS
@ LOGGER_TLS
Definition: suricata-common.h:466
app-layer-parser.h
Packet_
Definition: decode.h:437
LOG_CF_TIMESTAMP_U
#define LOG_CF_TIMESTAMP_U
Definition: log-cf-common.h:41
conf.h
Port
uint16_t Port
Definition: decode.h:230
SCTime_t
Definition: util-time.h:40
TmEcode
TmEcode
Definition: tm-threads-common.h:83
LOG_CF_WRITE_UNKNOWN_VALUE
#define LOG_CF_WRITE_UNKNOWN_VALUE(buffer)
Definition: log-cf-common.h:57
MemBuffer_
Definition: util-buffer.h:27
SCLogInfo
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:224
LogCustomFormat_
Definition: log-cf-common.h:71
LOG_TLS_CF_VERSION
#define LOG_TLS_CF_VERSION
Definition: log-tlslog.c:70
LogCustomFormatNode_::data
char data[LOG_NODE_STRLEN]
Definition: log-cf-common.h:67
OutputInitResult_
Definition: output.h:46
GET_IPV4_SRC_ADDR_PTR
#define GET_IPV4_SRC_ADDR_PTR(p)
Definition: decode.h:210
LogTlsFileCtx
struct LogTlsFileCtx_ LogTlsFileCtx
suricata-common.h
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:91
MemBufferFree
void MemBufferFree(MemBuffer *buffer)
Definition: util-buffer.c:81
version
uint8_t version
Definition: decode-gre.h:1
LogFileFreeCtx
int LogFileFreeCtx(LogFileCtx *lf_ctx)
LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory)
Definition: util-logopenfile.c:868
LogTlsLogThread_::tls_cnt
uint32_t tls_cnt
Definition: log-tlslog.c:90
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
threadvars.h
log-cf-common.h
LogTlsLogThread_::tlslog_ctx
LogTlsFileCtx * tlslog_ctx
Definition: log-tlslog.c:86
LOG_TLS_CF_SNI
#define LOG_TLS_CF_SNI
Definition: log-tlslog.c:74
TLSGetIPInformations
int TLSGetIPInformations(const Packet *p, char *srcip, size_t srcip_len, Port *sp, char *dstip, size_t dstip_len, Port *dp, int ipproto)
Definition: log-tlslog.c:95
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:261
GET_IPV6_SRC_ADDR
#define GET_IPV6_SRC_ADDR(p)
Definition: decode.h:215
SCFree
#define SCFree(p)
Definition: util-mem.h:61
ConfNode_
Definition: conf.h:32
util-logopenfile.h
LOG_TLS_CF_DATE_NOT_BEFORE
#define LOG_TLS_CF_DATE_NOT_BEFORE
Definition: log-tlslog.c:71
util-buffer.h
LogCustomFormat_::cf_nodes
LogCustomFormatNode * cf_nodes[LOG_MAXN_NODES]
Definition: log-cf-common.h:73
OutputRegisterTxModuleWithProgress
void OutputRegisterTxModuleWithProgress(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, int tc_log_progress, int ts_log_progress, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a tx output module with progress.
Definition: output.c:362
LOG_CF_SERVER_IP
#define LOG_CF_SERVER_IP
Definition: log-cf-common.h:43
LOG_TLS_CF_ISSUER
#define LOG_TLS_CF_ISSUER
Definition: log-tlslog.c:76
LOG_CF_NONE
#define LOG_CF_NONE
Definition: log-cf-common.h:38
LOG_TLS_EXTENDED
#define LOG_TLS_EXTENDED
Definition: log-tlslog.c:65
MemBufferWriteString
void MemBufferWriteString(MemBuffer *dst, const char *fmt,...)
Definition: util-buffer.c:127
PrintRawUriBuf
void PrintRawUriBuf(char *retbuf, uint32_t *offset, uint32_t retbuflen, uint8_t *buf, uint32_t buflen)
Definition: util-print.c:93
MemBuffer_::size
uint32_t size
Definition: util-buffer.h:28
MEMBUFFER_BUFFER
#define MEMBUFFER_BUFFER(mem_buffer)
Get the MemBuffers underlying buffer.
Definition: util-buffer.h:51
SSLStateConnp_::cert0_fingerprint
char * cert0_fingerprint
Definition: app-layer-ssl.h:255
LogCustomFormatAlloc
LogCustomFormat * LogCustomFormatAlloc(void)
Creates a custom format.
Definition: log-cf-common.c:54
MEMBUFFER_OFFSET
#define MEMBUFFER_OFFSET(mem_buffer)
Get the MemBuffers current offset.
Definition: util-buffer.h:56
Packet_::dp
Port dp
Definition: decode.h:452
LOG_CF_WRITE_SPACE_SEPARATOR
#define LOG_CF_WRITE_SPACE_SEPARATOR(buffer)
Definition: log-cf-common.h:54
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
LogTlsFileCtx_::cf
LogCustomFormat * cf
Definition: log-tlslog.c:82
PKT_IS_IPV4
#define PKT_IS_IPV4(p)
Definition: decode.h:246
SSLStateConnp_::cert0_serial
char * cert0_serial
Definition: app-layer-ssl.h:252
app-layer-ssl.h
LOG_TLS_CF_SHA1
#define LOG_TLS_CF_SHA1
Definition: log-tlslog.c:73
SSL_AL_FLAG_LOG_WITHOUT_CERT
#define SSL_AL_FLAG_LOG_WITHOUT_CERT
Definition: app-layer-ssl.h:123
CreateTimeString
void CreateTimeString(const SCTime_t ts, char *str, size_t size)
Definition: util-time.c:272
MemBufferCreateNew
MemBuffer * MemBufferCreateNew(uint32_t size)
Definition: util-buffer.c:32
LOG_TLS_CF_EXTENDED
#define LOG_TLS_CF_EXTENDED
Definition: log-tlslog.c:77
output.h
LogTlsFileCtx_
Definition: log-tlslog.c:79
LogCustomFormatParse
int LogCustomFormatParse(LogCustomFormat *cf, const char *format)
Parses and saves format nodes for custom format.
Definition: log-cf-common.c:96
app-layer.h
SCTIME_USECS
#define SCTIME_USECS(t)
Definition: util-time.h:56
LogTlsLogThread_
Definition: log-tlslog.c:85
SSLState_::flags
uint32_t flags
Definition: app-layer-ssl.h:295
SSLStateConnp_::version
uint16_t version
Definition: app-layer-ssl.h:239
ConfNodeLookupChildValue
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
Definition: conf.c:814