suricata
log-httplog.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2013 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 Victor Julien <victor@inliniac.net>
22  * \author Ignacio Sanchez <sanchezmartin.ji@gmail.com>
23  *
24  * Implements http logging portion of the engine.
25  */
26 
27 #include "suricata-common.h"
28 #include "detect.h"
29 #include "pkt-var.h"
30 #include "conf.h"
31 
32 #include "threads.h"
33 #include "threadvars.h"
34 #include "tm-threads.h"
35 
36 #include "util-print.h"
37 #include "util-unittest.h"
38 
39 #include "util-debug.h"
40 
41 #include "output.h"
42 #include "log-httplog.h"
43 #include "app-layer-htp.h"
44 #include "app-layer.h"
45 #include "app-layer-parser.h"
46 #include "util-privs.h"
47 #include "util-buffer.h"
48 
49 #include "util-logopenfile.h"
50 #include "util-time.h"
51 #include "log-cf-common.h"
52 
53 #define DEFAULT_LOG_FILENAME "http.log"
54 
55 #define MODULE_NAME "LogHttpLog"
56 
57 #define OUTPUT_BUFFER_SIZE 65535
58 
59 TmEcode LogHttpLogThreadInit(ThreadVars *, const void *, void **);
61 static void LogHttpLogDeInitCtx(OutputCtx *);
62 
63 int LogHttpLogger(ThreadVars *tv, void *thread_data, const Packet *, Flow *f, void *state, void *tx, uint64_t tx_id);
64 
65 void LogHttpLogRegister (void)
66 {
69 }
70 
71 #define LOG_HTTP_CF_REQUEST_HOST 'h'
72 #define LOG_HTTP_CF_REQUEST_PROTOCOL 'H'
73 #define LOG_HTTP_CF_REQUEST_METHOD 'm'
74 #define LOG_HTTP_CF_REQUEST_URI 'u'
75 #define LOG_HTTP_CF_REQUEST_TIME 't'
76 #define LOG_HTTP_CF_REQUEST_HEADER 'i'
77 #define LOG_HTTP_CF_REQUEST_COOKIE 'C'
78 #define LOG_HTTP_CF_REQUEST_LEN 'b'
79 #define LOG_HTTP_CF_RESPONSE_STATUS 's'
80 #define LOG_HTTP_CF_RESPONSE_HEADER 'o'
81 #define LOG_HTTP_CF_RESPONSE_LEN 'B'
82 
83 
84 typedef struct LogHttpFileCtx_ {
86  uint32_t flags; /** Store mode */
89 
90 #define LOG_HTTP_DEFAULT 0
91 #define LOG_HTTP_EXTENDED 1
92 #define LOG_HTTP_CUSTOM 2
93 
94 typedef struct LogHttpLogThread_ {
96  /** LogFileCtx has the pointer to the file and a mutex to allow multithreading */
97  uint32_t uri_cnt;
98 
101 
102 /* Retrieves the selected cookie value */
103 static uint32_t GetCookieValue(uint8_t *rawcookies, uint32_t rawcookies_len, char *cookiename,
104  uint8_t **cookievalue)
105 {
106  uint8_t *p = rawcookies;
107  uint8_t *cn = p; /* ptr to cookie name start */
108  uint8_t *cv = NULL; /* ptr to cookie value start */
109  while (p < rawcookies + rawcookies_len) {
110  if (cv == NULL && *p == '=') {
111  cv = p + 1;
112  } else if (cv != NULL && (*p == ';' || p == rawcookies + rawcookies_len - 1) ) {
113  /* Found end of cookie */
114  p++;
115  if (strlen(cookiename) == (unsigned int) (cv-cn-1) &&
116  strncmp(cookiename, (char *) cn, cv-cn-1) == 0) {
117  *cookievalue = cv;
118  return (uint32_t) (p-cv);
119  }
120  cv = NULL;
121  cn = p + 1;
122  }
123  p++;
124  }
125  return 0;
126 }
127 
128 /* Custom format logging */
129 static void LogHttpLogCustom(LogHttpLogThread *aft, htp_tx_t *tx, const SCTime_t ts, char *srcip,
130  Port sp, char *dstip, Port dp)
131 {
132  LogHttpFileCtx *httplog_ctx = aft->httplog_ctx;
133  uint32_t i;
134  uint32_t datalen;
135  char buf[128];
136 
137  uint8_t *cvalue = NULL;
138  uint32_t cvalue_len = 0;
139 
140  htp_header_t *h_request_hdr;
141  htp_header_t *h_response_hdr;
142 
143  for (i = 0; i < httplog_ctx->cf->cf_n; i++) {
144  h_request_hdr = NULL;
145  h_response_hdr = NULL;
146 
147  LogCustomFormatNode * node = httplog_ctx->cf->cf_nodes[i];
148  if (! node) /* Should never happen */
149  continue;
150 
151  switch (node->type){
152  case LOG_CF_LITERAL:
153  /* LITERAL */
154  MemBufferWriteString(aft->buffer, "%s", node->data);
155  break;
156  case LOG_CF_TIMESTAMP:
157  /* TIMESTAMP */
159  break;
160  case LOG_CF_TIMESTAMP_U:
161  /* TIMESTAMP USECONDS */
162  snprintf(buf, sizeof(buf), "%06u", (unsigned int)SCTIME_USECS(ts));
163  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset, aft->buffer->size,
164  (uint8_t *)buf, MIN(strlen(buf), 6));
165  break;
166  case LOG_CF_CLIENT_IP:
167  /* CLIENT IP ADDRESS */
168  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset,
169  aft->buffer->size, (uint8_t *)srcip,strlen(srcip));
170  break;
171  case LOG_CF_SERVER_IP:
172  /* SERVER IP ADDRESS */
173  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset,
174  aft->buffer->size, (uint8_t *)dstip,strlen(dstip));
175  break;
176  case LOG_CF_CLIENT_PORT:
177  /* CLIENT PORT */
178  MemBufferWriteString(aft->buffer, "%" PRIu16 "", sp);
179  break;
180  case LOG_CF_SERVER_PORT:
181  /* SERVER PORT */
182  MemBufferWriteString(aft->buffer, "%" PRIu16 "", dp);
183  break;
185  /* METHOD */
186  if (tx->request_method != NULL) {
187  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset,
188  aft->buffer->size, (uint8_t *)bstr_ptr(tx->request_method),
189  bstr_len(tx->request_method));
190  } else {
192  }
193  break;
195  /* URI */
196  if (tx->request_uri != NULL) {
197  datalen = node->maxlen;
198  if (datalen == 0 || datalen > bstr_len(tx->request_uri)) {
199  datalen = bstr_len(tx->request_uri);
200  }
201  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset,
202  aft->buffer->size, (uint8_t *)bstr_ptr(tx->request_uri),
203  datalen);
204  } else {
206  }
207  break;
209  /* HOSTNAME */
210  if (tx->request_hostname != NULL)
211  {
212  datalen = node->maxlen;
213  if (datalen == 0 || datalen > bstr_len(tx->request_hostname)) {
214  datalen = bstr_len(tx->request_hostname);
215  }
216  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset,
217  aft->buffer->size, (uint8_t *)bstr_ptr(tx->request_hostname),
218  datalen);
219  } else {
221  }
222  break;
224  /* PROTOCOL */
225  if (tx->request_protocol != NULL) {
226  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset,
227  aft->buffer->size, (uint8_t *)bstr_ptr(tx->request_protocol),
228  bstr_len(tx->request_protocol));
229  } else {
231  }
232  break;
234  /* REQUEST HEADER */
235  if (tx->request_headers != NULL) {
236  h_request_hdr = htp_table_get_c(tx->request_headers, node->data);
237  }
238  if (h_request_hdr != NULL) {
239  datalen = node->maxlen;
240  if (datalen == 0 || datalen > bstr_len(h_request_hdr->value)) {
241  datalen = bstr_len(h_request_hdr->value);
242  }
243  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset,
244  aft->buffer->size, (uint8_t *)bstr_ptr(h_request_hdr->value),
245  datalen);
246  } else {
248  }
249  break;
251  /* REQUEST COOKIE */
252  if (tx->request_headers != NULL) {
253  h_request_hdr = htp_table_get_c(tx->request_headers, "Cookie");
254  if (h_request_hdr != NULL) {
255  cvalue_len = GetCookieValue((uint8_t *) bstr_ptr(h_request_hdr->value),
256  bstr_len(h_request_hdr->value), (char *) node->data,
257  &cvalue);
258  }
259  }
260  if (cvalue_len > 0 && cvalue != NULL) {
261  datalen = node->maxlen;
262  if (datalen == 0 || datalen > cvalue_len) {
263  datalen = cvalue_len;
264  }
265  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset,
266  aft->buffer->size, cvalue, datalen);
267  } else {
269  }
270  break;
272  /* REQUEST LEN */
273  MemBufferWriteString(aft->buffer, "%"PRIuMAX"", (uintmax_t)tx->request_message_len);
274  break;
276  /* RESPONSE STATUS */
277  if (tx->response_status != NULL) {
278  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset,
279  aft->buffer->size, (uint8_t *)bstr_ptr(tx->response_status),
280  bstr_len(tx->response_status));
281  } else {
283  }
284  break;
286  /* RESPONSE HEADER */
287  if (tx->response_headers != NULL) {
288  h_response_hdr = htp_table_get_c(tx->response_headers,
289  node->data);
290  }
291  if (h_response_hdr != NULL) {
292  datalen = node->maxlen;
293  if (datalen == 0 || datalen > bstr_len(h_response_hdr->value)) {
294  datalen = bstr_len(h_response_hdr->value);
295  }
296  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset,
297  aft->buffer->size, (uint8_t *)bstr_ptr(h_response_hdr->value),
298  datalen);
299  } else {
301  }
302  break;
304  /* RESPONSE LEN */
305  MemBufferWriteString(aft->buffer, "%"PRIuMAX"", (uintmax_t)tx->response_message_len);
306  break;
307  default:
308  /* NO MATCH */
310  SCLogDebug("No matching parameter %%%c for custom http log.", node->type);
311  break;
312  }
313  }
314  MemBufferWriteString(aft->buffer, "\n");
315 }
316 
317 static void LogHttpLogExtended(LogHttpLogThread *aft, htp_tx_t *tx)
318 {
320 
321  /* referer */
322  htp_header_t *h_referer = NULL;
323  if (tx->request_headers != NULL) {
324  h_referer = htp_table_get_c(tx->request_headers, "referer");
325  }
326  if (h_referer != NULL) {
327  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset, aft->buffer->size,
328  (uint8_t *)bstr_ptr(h_referer->value),
329  bstr_len(h_referer->value));
330  } else {
331  MemBufferWriteString(aft->buffer, "<no referer>");
332  }
333 
335 
336  /* method */
337  if (tx->request_method != NULL) {
338  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset, aft->buffer->size,
339  (uint8_t *)bstr_ptr(tx->request_method),
340  bstr_len(tx->request_method));
341  }
343 
344  /* protocol */
345  if (tx->request_protocol != NULL) {
346  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset, aft->buffer->size,
347  (uint8_t *)bstr_ptr(tx->request_protocol),
348  bstr_len(tx->request_protocol));
349  } else {
350  MemBufferWriteString(aft->buffer, "<no protocol>");
351  }
353 
354  /* response status */
355  if (tx->response_status != NULL) {
356  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset, aft->buffer->size,
357  (uint8_t *)bstr_ptr(tx->response_status),
358  bstr_len(tx->response_status));
359  /* Redirect? */
360  if ((tx->response_status_number > 300) && ((tx->response_status_number) < 303)) {
361  htp_header_t *h_location = htp_table_get_c(tx->response_headers, "location");
362  if (h_location != NULL) {
363  MemBufferWriteString(aft->buffer, " => ");
364 
365  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset, aft->buffer->size,
366  (uint8_t *)bstr_ptr(h_location->value),
367  bstr_len(h_location->value));
368  }
369  }
370  } else {
371  MemBufferWriteString(aft->buffer, "<no status>");
372  }
373 
374  /* length */
376  MemBufferWriteString(aft->buffer, "%"PRIuMAX" bytes", (uintmax_t)tx->response_message_len);
377 }
378 
379 static TmEcode LogHttpLogIPWrapper(ThreadVars *tv, void *data, const Packet *p, Flow *f, HtpState *htp_state, htp_tx_t *tx, uint64_t tx_id, int ipproto)
380 {
381  SCEnter();
382 
383  LogHttpLogThread *aft = (LogHttpLogThread *)data;
384  LogHttpFileCtx *hlog = aft->httplog_ctx;
385  char timebuf[64];
386 
387  /* check if we have HTTP state or not */
388  CreateTimeString(p->ts, timebuf, sizeof(timebuf));
389 
390  char srcip[46], dstip[46];
391  Port sp, dp;
392  if ((PKT_IS_TOSERVER(p))) {
393  switch (ipproto) {
394  case AF_INET:
395  PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip));
396  PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip));
397  break;
398  case AF_INET6:
399  PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), srcip, sizeof(srcip));
400  PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), dstip, sizeof(dstip));
401  break;
402  default:
403  goto end;
404  }
405  sp = p->sp;
406  dp = p->dp;
407  } else {
408  switch (ipproto) {
409  case AF_INET:
410  PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), srcip, sizeof(srcip));
411  PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), dstip, sizeof(dstip));
412  break;
413  case AF_INET6:
414  PrintInet(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), srcip, sizeof(srcip));
415  PrintInet(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), dstip, sizeof(dstip));
416  break;
417  default:
418  goto end;
419  }
420  sp = p->dp;
421  dp = p->sp;
422  }
423 
424  SCLogDebug("got a HTTP request and now logging !!");
425 
426  /* reset */
427  MemBufferReset(aft->buffer);
428 
429  if (hlog->flags & LOG_HTTP_CUSTOM) {
430  LogHttpLogCustom(aft, tx, p->ts, srcip, sp, dstip, dp);
431  } else {
432  /* time */
433  MemBufferWriteString(aft->buffer, "%s ", timebuf);
434 
435  /* hostname */
436  if (tx->request_hostname != NULL) {
437  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset, aft->buffer->size,
438  (uint8_t *)bstr_ptr(tx->request_hostname),
439  bstr_len(tx->request_hostname));
440  } else {
441  MemBufferWriteString(aft->buffer, "<hostname unknown>");
442  }
444 
445  /* uri */
446  if (tx->request_uri != NULL) {
447  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset, aft->buffer->size,
448  (uint8_t *)bstr_ptr(tx->request_uri),
449  bstr_len(tx->request_uri));
450  }
452 
453  /* user agent */
454  htp_header_t *h_user_agent = NULL;
455  if (tx->request_headers != NULL) {
456  h_user_agent = htp_table_get_c(tx->request_headers, "user-agent");
457  }
458  if (h_user_agent != NULL) {
459  PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset, aft->buffer->size,
460  (uint8_t *)bstr_ptr(h_user_agent->value),
461  bstr_len(h_user_agent->value));
462  } else {
463  MemBufferWriteString(aft->buffer, "<useragent unknown>");
464  }
465  if (hlog->flags & LOG_HTTP_EXTENDED) {
466  LogHttpLogExtended(aft, tx);
467  }
468 
469  /* ip/tcp header info */
472  "%s:%" PRIu16 " -> %s:%" PRIu16 "\n",
473  srcip, sp, dstip, dp);
474  }
475 
476  aft->uri_cnt ++;
477 
478  hlog->file_ctx->Write((const char *)MEMBUFFER_BUFFER(aft->buffer),
479  MEMBUFFER_OFFSET(aft->buffer), hlog->file_ctx);
480 
481 end:
482  SCReturnInt(0);
483 
484 }
485 
486 int LogHttpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Flow *f, void *state, void *tx, uint64_t tx_id)
487 {
488  SCEnter();
489 
490  if (!(PKT_IS_TCP(p))) {
492  }
493 
494  int r = 0;
495  if (PKT_IS_IPV4(p)) {
496  r = LogHttpLogIPWrapper(tv, thread_data, p, f, (HtpState *)state, (htp_tx_t *)tx, tx_id, AF_INET);
497  } else if (PKT_IS_IPV6(p)) {
498  r = LogHttpLogIPWrapper(tv, thread_data, p, f, (HtpState *)state, (htp_tx_t *)tx, tx_id, AF_INET6);
499  }
500 
501  SCReturnInt(r);
502 }
503 
504 TmEcode LogHttpLogThreadInit(ThreadVars *t, const void *initdata, void **data)
505 {
506  LogHttpLogThread *aft = SCCalloc(1, sizeof(LogHttpLogThread));
507  if (unlikely(aft == NULL))
508  return TM_ECODE_FAILED;
509 
510  if(initdata == NULL)
511  {
512  SCLogDebug("Error getting context for LogHTTPLog. \"initdata\" argument NULL");
513  SCFree(aft);
514  return TM_ECODE_FAILED;
515  }
516 
518  if (aft->buffer == NULL) {
519  SCFree(aft);
520  return TM_ECODE_FAILED;
521  }
522 
523  /* Use the Output Context (file pointer and mutex) */
524  aft->httplog_ctx= ((OutputCtx *)initdata)->data;
525 
526  *data = (void *)aft;
527  return TM_ECODE_OK;
528 }
529 
531 {
532  LogHttpLogThread *aft = (LogHttpLogThread *)data;
533  if (aft == NULL) {
534  return TM_ECODE_OK;
535  }
536 
537  MemBufferFree(aft->buffer);
538  /* clear memory */
539  memset(aft, 0, sizeof(LogHttpLogThread));
540 
541  SCFree(aft);
542  return TM_ECODE_OK;
543 }
544 
545 /** \brief Create a new http log LogFileCtx.
546  * \param conf Pointer to ConfNode containing this loggers configuration.
547  * \return NULL if failure, LogFileCtx* to the file_ctx if succesful
548  * */
550 {
551  OutputInitResult result = { NULL, false };
552  LogFileCtx* file_ctx = LogFileNewCtx();
553  if(file_ctx == NULL) {
554  SCLogError("couldn't create new file_ctx");
555  return result;
556  }
557 
558  if (SCConfLogOpenGeneric(conf, file_ctx, DEFAULT_LOG_FILENAME, 1) < 0) {
559  LogFileFreeCtx(file_ctx);
560  return result;
561  }
562 
563  LogHttpFileCtx *httplog_ctx = SCCalloc(1, sizeof(LogHttpFileCtx));
564  if (unlikely(httplog_ctx == NULL)) {
565  LogFileFreeCtx(file_ctx);
566  return result;
567  }
568 
569  httplog_ctx->file_ctx = file_ctx;
570 
571  const char *extended = ConfNodeLookupChildValue(conf, "extended");
572  const char *custom = ConfNodeLookupChildValue(conf, "custom");
573  const char *customformat = ConfNodeLookupChildValue(conf, "customformat");
574 
575  /* If custom logging format is selected, lets parse it */
576  if (custom != NULL && customformat != NULL && ConfValIsTrue(custom)) {
577 
578  httplog_ctx->cf = LogCustomFormatAlloc();
579  if (!httplog_ctx->cf) {
580  goto errorfree;
581  }
582 
583  httplog_ctx->flags |= LOG_HTTP_CUSTOM;
584 
585  /* Parsing */
586  if ( ! LogCustomFormatParse(httplog_ctx->cf, customformat)) {
587  goto parsererror;
588  }
589  } else {
590  if (extended == NULL) {
591  httplog_ctx->flags |= LOG_HTTP_DEFAULT;
592  } else {
593  if (ConfValIsTrue(extended)) {
594  httplog_ctx->flags |= LOG_HTTP_EXTENDED;
595  }
596  }
597  }
598 
599  OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
600  if (unlikely(output_ctx == NULL)) {
601  goto parsererror;
602  }
603 
604  output_ctx->data = httplog_ctx;
605  output_ctx->DeInit = LogHttpLogDeInitCtx;
606 
607  SCLogDebug("HTTP log output initialized");
608 
609  /* enable the logger for the app layer */
611 
612  result.ctx = output_ctx;
613  result.ok = true;
614  return result;
615 
616 parsererror:
617  SCLogError("Syntax error in custom http log format string.");
618 errorfree:
619  LogCustomFormatFree(httplog_ctx->cf);
620  LogFileFreeCtx(file_ctx);
621  SCFree(httplog_ctx);
622  return result;
623 
624 }
625 
626 static void LogHttpLogDeInitCtx(OutputCtx *output_ctx)
627 {
628  LogHttpFileCtx *httplog_ctx = (LogHttpFileCtx *)output_ctx->data;
629  LogCustomFormatFree(httplog_ctx->cf);
630  LogFileFreeCtx(httplog_ctx->file_ctx);
631  SCFree(httplog_ctx);
632  SCFree(output_ctx);
633 }
LogHttpLogThread
struct LogHttpLogThread_ LogHttpLogThread
LogCustomFormatFree
void LogCustomFormatFree(LogCustomFormat *cf)
Frees memory held by a custom format.
Definition: log-cf-common.c:80
tm-threads.h
LOG_HTTP_CF_RESPONSE_STATUS
#define LOG_HTTP_CF_RESPONSE_STATUS
Definition: log-httplog.c:79
ts
uint64_t ts
Definition: source-erf-file.c:55
MemBuffer_::buffer
uint8_t buffer[]
Definition: util-buffer.h:30
LOG_HTTP_CF_RESPONSE_HEADER
#define LOG_HTTP_CF_RESPONSE_HEADER
Definition: log-httplog.c:80
PKT_IS_IPV6
#define PKT_IS_IPV6(p)
Definition: decode.h:246
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
OUTPUT_BUFFER_SIZE
#define OUTPUT_BUFFER_SIZE
Definition: log-httplog.c:57
LogFileNewCtx
LogFileCtx * LogFileNewCtx(void)
LogFileNewCtx() Get a new LogFileCtx.
Definition: util-logopenfile.c:659
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
LOG_HTTP_EXTENDED
#define LOG_HTTP_EXTENDED
Definition: log-httplog.c:91
threads.h
Flow_
Flow data structure.
Definition: flow.h:350
LogFileCtx_
Definition: util-logopenfile.h:76
LOG_CF_LITERAL
#define LOG_CF_LITERAL
Definition: log-cf-common.h:39
LogHttpLogInitCtx
OutputInitResult LogHttpLogInitCtx(ConfNode *conf)
Create a new http log LogFileCtx.
Definition: log-httplog.c:549
LogHttpLogThread_::uri_cnt
uint32_t uri_cnt
Definition: log-httplog.c:97
OutputRegisterTxModule
void OutputRegisterTxModule(LoggerId id, const char *name, const char *conf_name, OutputInitFunc InitFunc, AppProto alproto, TxLogger TxLogFunc, ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, ThreadExitPrintStatsFunc ThreadExitPrintStats)
Register a tx output module.
Definition: output.c:402
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
LOG_HTTP_CF_REQUEST_URI
#define LOG_HTTP_CF_REQUEST_URI
Definition: log-httplog.c:74
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:215
util-unittest.h
MemBuffer_::offset
uint32_t offset
Definition: util-buffer.h:29
LOG_HTTP_CF_REQUEST_LEN
#define LOG_HTTP_CF_REQUEST_LEN
Definition: log-httplog.c:78
HtpState_
Definition: app-layer-htp.h:244
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
LogCustomFormat_::cf_n
uint32_t cf_n
Definition: log-cf-common.h:72
LogCustomFormatNode_
Definition: log-cf-common.h:64
LOGGER_HTTP
@ LOGGER_HTTP
Definition: suricata-common.h:464
PKT_IS_TCP
#define PKT_IS_TCP(p)
Definition: decode.h:247
LogHttpLogRegister
void LogHttpLogRegister(void)
Definition: log-httplog.c:65
LogCustomFormatNode_::type
uint32_t type
Definition: log-cf-common.h:65
app-layer-htp.h
LOG_CF_WRITE_STAR_SEPARATOR
#define LOG_CF_WRITE_STAR_SEPARATOR(buffer)
Definition: log-cf-common.h:52
util-debug.h
GET_IPV4_DST_ADDR_PTR
#define GET_IPV4_DST_ADDR_PTR(p)
Definition: decode.h:210
PKT_IS_TOSERVER
#define PKT_IS_TOSERVER(p)
Definition: decode.h:251
OutputInitResult_::ctx
OutputCtx * ctx
Definition: output.h:47
Packet_::ts
SCTime_t ts
Definition: decode.h:484
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
LOG_HTTP_CF_REQUEST_HEADER
#define LOG_HTTP_CF_REQUEST_HEADER
Definition: log-httplog.c:76
AppLayerParserRegisterLogger
void AppLayerParserRegisterLogger(uint8_t ipproto, AppProto alproto)
Definition: app-layer-parser.c:475
util-print.h
SCEnter
#define SCEnter(...)
Definition: util-debug.h:271
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:262
pkt-var.h
LogHttpLogThreadInit
TmEcode LogHttpLogThreadInit(ThreadVars *, const void *, void **)
Definition: log-httplog.c:504
Packet_::sp
Port sp
Definition: decode.h:443
DEFAULT_LOG_FILENAME
#define DEFAULT_LOG_FILENAME
Definition: log-httplog.c:53
LOG_CF_SERVER_PORT
#define LOG_CF_SERVER_PORT
Definition: log-cf-common.h:45
util-time.h
OutputInitResult_::ok
bool ok
Definition: output.h:48
app-layer-parser.h
Packet_
Definition: decode.h:436
LOG_HTTP_CUSTOM
#define LOG_HTTP_CUSTOM
Definition: log-httplog.c:92
LOG_CF_TIMESTAMP_U
#define LOG_CF_TIMESTAMP_U
Definition: log-cf-common.h:41
LogHttpFileCtx_::file_ctx
LogFileCtx * file_ctx
Definition: log-httplog.c:85
conf.h
Port
uint16_t Port
Definition: decode.h:229
SCTime_t
Definition: util-time.h:40
TmEcode
TmEcode
Definition: tm-threads-common.h:83
LogCustomFormatNode_::maxlen
uint32_t maxlen
Definition: log-cf-common.h:66
LogHttpFileCtx_::cf
LogCustomFormat * cf
Definition: log-httplog.c:87
MemBuffer_
Definition: util-buffer.h:27
LogCustomFormat_
Definition: log-cf-common.h:71
LogHttpLogThread_::buffer
MemBuffer * buffer
Definition: log-httplog.c:99
LogHttpLogThreadDeinit
TmEcode LogHttpLogThreadDeinit(ThreadVars *, void *)
Definition: log-httplog.c:530
LOG_HTTP_CF_REQUEST_METHOD
#define LOG_HTTP_CF_REQUEST_METHOD
Definition: log-httplog.c:73
LogCustomFormatNode_::data
char data[LOG_NODE_STRLEN]
Definition: log-cf-common.h:67
OutputInitResult_
Definition: output.h:46
LogHttpLogThread_
Definition: log-httplog.c:94
GET_IPV4_SRC_ADDR_PTR
#define GET_IPV4_SRC_ADDR_PTR(p)
Definition: decode.h:209
suricata-common.h
LOG_HTTP_CF_REQUEST_PROTOCOL
#define LOG_HTTP_CF_REQUEST_PROTOCOL
Definition: log-httplog.c:72
OutputCtx_::DeInit
void(* DeInit)(struct OutputCtx_ *)
Definition: tm-modules.h:91
ALPROTO_HTTP1
@ ALPROTO_HTTP1
Definition: app-layer-protos.h:30
MemBufferFree
void MemBufferFree(MemBuffer *buffer)
Definition: util-buffer.c:81
LOG_HTTP_CF_REQUEST_HOST
#define LOG_HTTP_CF_REQUEST_HOST
Definition: log-httplog.c:71
LogFileFreeCtx
int LogFileFreeCtx(LogFileCtx *lf_ctx)
LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory)
Definition: util-logopenfile.c:868
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:32
log-httplog.h
threadvars.h
log-cf-common.h
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:214
SCFree
#define SCFree(p)
Definition: util-mem.h:61
ConfNode_
Definition: conf.h:32
util-logopenfile.h
util-buffer.h
LogCustomFormat_::cf_nodes
LogCustomFormatNode * cf_nodes[LOG_MAXN_NODES]
Definition: log-cf-common.h:73
LOG_HTTP_DEFAULT
#define LOG_HTTP_DEFAULT
Definition: log-httplog.c:90
LOG_CF_SERVER_IP
#define LOG_CF_SERVER_IP
Definition: log-cf-common.h:43
LogHttpFileCtx
struct LogHttpFileCtx_ LogHttpFileCtx
LOG_HTTP_CF_RESPONSE_LEN
#define LOG_HTTP_CF_RESPONSE_LEN
Definition: log-httplog.c:81
LOG_CF_NONE
#define LOG_CF_NONE
Definition: log-cf-common.h:38
MemBufferWriteString
void MemBufferWriteString(MemBuffer *dst, const char *fmt,...)
Definition: util-buffer.c:127
LogHttpLogThread_::httplog_ctx
LogHttpFileCtx * httplog_ctx
Definition: log-httplog.c:95
PrintRawUriBuf
void PrintRawUriBuf(char *retbuf, uint32_t *offset, uint32_t retbuflen, uint8_t *buf, uint32_t buflen)
Definition: util-print.c:114
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
LogCustomFormatAlloc
LogCustomFormat * LogCustomFormatAlloc(void)
Creates a custom format.
Definition: log-cf-common.c:54
LogHttpFileCtx_::flags
uint32_t flags
Definition: log-httplog.c:86
LogHttpLogger
int LogHttpLogger(ThreadVars *tv, void *thread_data, const Packet *, Flow *f, void *state, void *tx, uint64_t tx_id)
Definition: log-httplog.c:486
MEMBUFFER_OFFSET
#define MEMBUFFER_OFFSET(mem_buffer)
Get the MemBuffers current offset.
Definition: util-buffer.h:56
LogHttpFileCtx_
Definition: log-httplog.c:84
Packet_::dp
Port dp
Definition: decode.h:451
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:275
MODULE_NAME
#define MODULE_NAME
Definition: log-httplog.c:55
LOG_HTTP_CF_REQUEST_COOKIE
#define LOG_HTTP_CF_REQUEST_COOKIE
Definition: log-httplog.c:77
PKT_IS_IPV4
#define PKT_IS_IPV4(p)
Definition: decode.h:245
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
output.h
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
ConfNodeLookupChildValue
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
Definition: conf.c:814