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