33 #if defined(HAVE_DIRENT_H) && defined(HAVE_FNMATCH_H)
34 #define INIT_RING_BUFFER
58 #define DEFAULT_LOG_FILENAME "pcaplog"
59 #define MODULE_NAME "PcapLog"
60 #define MIN_LIMIT 4 * 1024 * 1024
61 #define DEFAULT_LIMIT 100 * 1024 * 1024
62 #define DEFAULT_FILE_LIMIT 0
64 #define LOGMODE_NORMAL 0
65 #define LOGMODE_MULTI 1
73 #define RING_BUFFER_MODE_DISABLED 0
74 #define RING_BUFFER_MODE_ENABLED 1
76 #define TS_FORMAT_SEC 0
77 #define TS_FORMAT_USEC 1
79 #define USE_STREAM_DEPTH_DISABLED 0
80 #define USE_STREAM_DEPTH_ENABLED 1
82 #define HONOR_PASS_RULES_DISABLED 0
83 #define HONOR_PASS_RULES_ENABLED 1
85 #define PCAP_SNAPLEN 262144
86 #define PCAP_BUFFER_TIMEOUT 1000000 // microseconds
87 #define PCAP_PKTHDR_SIZE 16
113 #define MAX_FILENAMELEN 513
125 LZ4F_compressionContext_t lz4f_context;
126 LZ4F_preferences_t lz4f_prefs;
145 struct pcap_pkthdr *
h;
170 uint32_t thread_number;
172 int timestamp_format;
179 int filename_part_cnt;
180 struct timeval last_pcap_dump;
193 static const char timestamp_pattern[] =
".*?(\\d+)(\\.(\\d+))?";
194 static pcre2_code *pcre_timestamp_code = NULL;
195 static pcre2_match_data *pcre_timestamp_match = NULL;
205 static void PcapLogFileDeInitCtx(
OutputCtx *);
215 .ConditionFunc = PcapLogCondition,
216 .ThreadInitFunc = PcapLogDataInit,
217 .ThreadDeinitFunc = PcapLogDataDeinit,
218 .ThreadExitPrintStatsFunc = NULL,
227 #define PCAPLOG_PROFILE_START \
228 uint64_t pcaplog_profile_ticks = UtilCpuGetTicks()
230 #define PCAPLOG_PROFILE_END(prof) \
231 (prof).total += (UtilCpuGetTicks() - pcaplog_profile_ticks); \
280 SCLogError(
"SCFmemopen failed: %s", strerror(errno));
299 uint64_t bytes_written = LZ4F_compressEnd(comp->lz4f_context,
301 if (LZ4F_isError(bytes_written)) {
302 SCLogError(
"LZ4F_compressEnd: %s", LZ4F_getErrorName(bytes_written));
305 if (fwrite(comp->
buffer, 1, bytes_written, comp->
file) < bytes_written) {
306 SCLogError(
"fwrite failed: %s", strerror(errno));
348 if (PcapLogCloseFile(t,pl) < 0) {
364 PcapFileNameFree(pf);
368 if (PcapLogOpenFileCtx(pl) < 0) {
369 SCLogError(
"opening new pcap log file failed");
389 SCLogDebug(
"Setting pcap-log link type to %u", datalink);
400 if (!pl->pcap_open_err) {
402 pl->pcap_open_err =
true;
406 pl->pcap_open_err =
false;
414 if (comp->
file == NULL) {
415 if (errno != pl->fopen_err) {
416 SCLogError(
"Error opening file for compressed output: %s", strerror(errno));
417 pl->fopen_err = errno;
426 if (!pl->pcap_open_err) {
428 pl->pcap_open_err =
true;
434 pl->pcap_open_err =
false;
437 uint64_t bytes_written = LZ4F_compressBegin(comp->lz4f_context,
439 if (LZ4F_isError(bytes_written)) {
440 SCLogError(
"LZ4F_compressBegin: %s", LZ4F_getErrorName(bytes_written));
443 if (fwrite(comp->
buffer, 1, bytes_written, comp->
file) < bytes_written) {
444 SCLogError(
"fwrite failed: %s", strerror(errno));
481 static inline int PcapWrite(
484 struct timeval current_dump;
485 gettimeofday(¤t_dump, NULL);
495 SCLogError(
"ftell failed with: %s", strerror(errno));
498 uint64_t out_size = LZ4F_compressUpdate(comp->lz4f_context, comp->
buffer, comp->
buffer_size,
499 comp->
pcap_buf, (uint64_t)in_size, NULL);
500 if (LZ4F_isError(
len)) {
501 SCLogError(
"LZ4F_compressUpdate: %s", LZ4F_getErrorName(
len));
505 SCLogError(
"fseek failed: %s", strerror(errno));
508 if (fwrite(comp->
buffer, 1, out_size, comp->
file) < out_size) {
509 SCLogError(
"fwrite failed: %s", strerror(errno));
523 pl->last_pcap_dump = current_dump;
533 static int PcapLogSegmentCallback(
534 const Packet *p,
TcpSegment *seg,
void *data,
const uint8_t *buf, uint32_t buflen)
541 pctx->
pl->
h->ts.tv_sec =
tv.tv_sec;
542 pctx->
pl->
h->ts.tv_usec =
tv.tv_usec;
545 MemBufferReset(pctx->
buf);
554 static void PcapLogDumpSegments(
605 ret = PcapLogOpenFileCtx(
pl);
616 if (PcapLogRotateFile(t,
pl) < 0) {
632 if (PcapLogRotateFile(t,
pl) < 0) {
655 if (PacketIsTCP(p)) {
657 PcapLogDumpSegments(td,
comp, p);
695 SCLogDebug(
"pl->size_current %"PRIu64
", pl->size_limit %"PRIu64,
717 if (
unlikely(copy->prefix == NULL)) {
723 copy->suffix =
pl->suffix;
729 copy->use_ringbuffer =
pl->use_ringbuffer;
730 copy->timestamp_format =
pl->timestamp_format;
745 copy_comp->lz4f_prefs =
comp->lz4f_prefs;
750 if (copy_comp->
buffer == NULL) {
751 SCLogError(
"SCMalloc failed: %s", strerror(errno));
758 SCLogError(
"SCMalloc failed: %s", strerror(errno));
767 SCLogError(
"SCFmemopen failed: %s", strerror(errno));
777 LZ4F_errorCode_t errcode =
778 LZ4F_createCompressionContext(©_comp->lz4f_context, 1);
779 if (LZ4F_isError(errcode)) {
780 SCLogError(
"LZ4F_createCompressionContext failed: %s", LZ4F_getErrorName(errcode));
791 copy_comp->
file = NULL;
799 strlcpy(copy->dir,
pl->dir,
sizeof(copy->dir));
801 for (
int i = 0; i <
pl->filename_part_cnt && i <
MAX_TOKS; i++)
802 copy->filename_parts[i] =
pl->filename_parts[i];
803 copy->filename_part_cnt =
pl->filename_part_cnt;
812 #ifdef INIT_RING_BUFFER
813 static int PcapLogGetTimeOfFile(
const char *filename, uint64_t *secs,
819 int n = pcre2_match(pcre_timestamp_code, (PCRE2_SPTR8)filename, strlen(filename), 0, 0,
820 pcre_timestamp_match, NULL);
821 if (n != 2 && n != 4) {
828 copylen =
sizeof(
buf);
829 if (pcre2_substring_copy_bynumber(pcre_timestamp_match, 1, (PCRE2_UCHAR8 *)
buf, ©len) <
839 copylen =
sizeof(
buf);
840 if (pcre2_substring_copy_bynumber(pcre_timestamp_match, 3, (PCRE2_UCHAR8 *)
buf, ©len) <
854 char pattern[PATH_MAX];
856 SCLogInfo(
"Initializing PCAP ring buffer for %s/%s.",
857 pl->dir,
pl->prefix);
860 if (pattern[strlen(pattern) - 1] !=
'/') {
861 strlcat(pattern,
"/", PATH_MAX);
864 for (
int i = 0; i <
pl->filename_part_cnt; i++) {
865 char *part =
pl->filename_parts[i];
866 if (part == NULL || strlen(part) == 0) {
869 if (part[0] !=
'%' || strlen(part) < 2) {
870 strlcat(pattern, part, PATH_MAX);
875 SCLogError(
"Thread ID not allowed in ring buffer mode.");
879 snprintf(tmp, PATH_MAX,
"%"PRIu32,
pl->thread_number);
880 strlcat(pattern, tmp, PATH_MAX);
884 strlcat(pattern,
"*", PATH_MAX);
887 SCLogError(
"Unsupported format character: %%%s", part);
893 strlcat(pattern,
".*", PATH_MAX);
897 char *basename = strrchr(pattern,
'/');
901 DIR *dir = opendir(pattern);
903 SCLogWarning(
"Failed to open directory %s: %s", pattern, strerror(errno));
908 struct dirent *entry = readdir(dir);
912 if (fnmatch(basename, entry->d_name, 0) != 0) {
919 if (!PcapLogGetTimeOfFile(entry->d_name, &secs, &usecs)) {
930 if (snprintf(path, PATH_MAX,
"%s/%s", pattern, entry->d_name) == PATH_MAX)
985 PcapFileNameFree(pf);
1001 static TmEcode PcapLogDataInit(
ThreadVars *t,
const void *initdata,
void **data)
1003 if (initdata == NULL) {
1004 SCLogDebug(
"Error getting context for LogPcap. \"initdata\" argument NULL");
1015 td->
pcap_log = PcapLogDataCopy(pl);
1022 FatalError(
"Pcap logging with multiple link type is not supported.");
1033 FatalError(
"Can't have multiple link types in pcap conditional mode.");
1036 SCLogWarning(
"Using multiple link types can result in invalid pcap output");
1072 #ifdef INIT_RING_BUFFER
1077 SCLogInfo(
"Unable to initialize ring buffer on this platform.");
1088 PcapLogOpenFileCtx(pl);
1098 dst->profile_open.total +=
src->profile_open.total;
1099 dst->profile_open.cnt +=
src->profile_open.cnt;
1101 dst->profile_close.total +=
src->profile_close.total;
1102 dst->profile_close.cnt +=
src->profile_close.cnt;
1104 dst->profile_write.total +=
src->profile_write.total;
1105 dst->profile_write.cnt +=
src->profile_write.cnt;
1107 dst->profile_rotate.total +=
src->profile_rotate.total;
1108 dst->profile_rotate.cnt +=
src->profile_rotate.cnt;
1110 dst->profile_handles.total +=
src->profile_handles.total;
1111 dst->profile_handles.cnt +=
src->profile_handles.cnt;
1113 dst->profile_lock.total +=
src->profile_lock.total;
1114 dst->profile_lock.cnt +=
src->profile_lock.cnt;
1116 dst->profile_unlock.total +=
src->profile_unlock.total;
1117 dst->profile_unlock.cnt +=
src->profile_unlock.cnt;
1119 dst->profile_data_size +=
src->profile_data_size;
1126 while ((pf =
TAILQ_FIRST(&pl->pcap_file_list)) != NULL) {
1128 PcapFileNameFree(pf);
1130 if (pl == g_pcap_data) {
1131 for (
int i = 0; i <
MAX_TOKS; i++) {
1132 if (pl->filename_parts[i] != NULL) {
1133 SCFree(pl->filename_parts[i]);
1147 SCFree(pl->compression.buffer);
1148 fclose(pl->compression.pcap_buf_wrapper);
1149 SCFree(pl->compression.pcap_buf);
1150 LZ4F_errorCode_t errcode =
1151 LZ4F_freeCompressionContext(pl->compression.lz4f_context);
1152 if (LZ4F_isError(errcode)) {
1174 if (PcapLogCloseFile(t,pl) < 0) {
1181 StatsMerge(g_pcap_data, pl);
1182 g_pcap_data->reported++;
1183 if (g_pcap_data->threads == g_pcap_data->reported)
1184 PcapLogProfilingDump(g_pcap_data);
1187 if (pl->reported == 0) {
1188 PcapLogProfilingDump(pl);
1193 if (pl != g_pcap_data) {
1194 PcapLogDataFree(pl);
1205 static int ParseFilename(
PcapLogData *pl,
const char *filename)
1212 size_t filename_len = 0;
1215 filename_len = strlen(filename);
1221 for (
int i = 0; i < (int)strlen(filename); i++) {
1223 SCLogError(
"invalid filename option. Max 2 %%-sign options");
1227 str[s++] = filename[i];
1229 if (filename[i] ==
'%') {
1240 if (i+1 < (
int)strlen(filename)) {
1242 SCLogError(
"invalid filename option. Max 2 %%-sign options");
1246 if (filename[i+1] !=
'n' && filename[i+1] !=
't' && filename[i+1] !=
'i') {
1248 "invalid filename option. Valid %%-sign options: %%n, %%i and %%t");
1252 str[1] = filename[i+1];
1264 SCLogError(
"Invalid filename for multimode. Need at least one %%-sign option");
1270 SCLogError(
"invalid filename option. Max 3 %%-sign options");
1282 for (
int i = 0; i < tok; i++) {
1283 if (toks[i] == NULL)
1287 pl->filename_parts[i] = toks[i];
1289 pl->filename_part_cnt = tok;
1293 for (
int x = 0; x <
MAX_TOKS; x++) {
1294 if (toks[x] != NULL)
1312 FatalError(
"Failed to allocate Memory for PcapLogData");
1316 if (pl->
h == NULL) {
1317 FatalError(
"Failed to allocate Memory for pcap header struct");
1334 pcre_timestamp_code =
1335 pcre2_compile((PCRE2_SPTR8)timestamp_pattern, PCRE2_ZERO_TERMINATED, 0, &en, &eo, NULL);
1336 if (pcre_timestamp_code == NULL) {
1337 PCRE2_UCHAR errbuffer[256];
1338 pcre2_get_error_message(en, errbuffer,
sizeof(errbuffer));
1340 "Failed to compile \"%s\" at offset %d: %s", timestamp_pattern, (
int)eo, errbuffer);
1342 pcre_timestamp_match = pcre2_match_data_create_from_pattern(pcre_timestamp_code, NULL);
1346 const char *filename = NULL;
1352 if (filename == NULL)
1355 if ((pl->prefix =
SCStrdup(filename)) == NULL) {
1363 const char *s_limit = NULL;
1365 if (s_limit != NULL) {
1367 SCLogError(
"Failed to initialize pcap output, invalid limit: %s", s_limit);
1371 SCLogInfo(
"pcap-log \"limit\" value of %"PRIu64
" assumed to be pre-1.2 "
1373 uint64_t size = pl->
size_limit * 1024 * 1024;
1376 FatalError(
"Fail to initialize pcap-log output, limit less than "
1377 "allowed minimum of %d bytes.",
1384 const char *s_mode = NULL;
1386 if (s_mode != NULL) {
1387 if (strcasecmp(s_mode,
"multi") == 0) {
1389 }
else if (strcasecmp(s_mode,
"normal") != 0) {
1390 FatalError(
"log-pcap: invalid mode \"%s\". Valid options: \"normal\""
1391 "or \"multi\" mode ",
1396 const char *s_dir = NULL;
1398 if (s_dir == NULL) {
1399 const char *log_dir = NULL;
1402 strlcpy(pl->dir, log_dir,
sizeof(pl->dir));
1407 s_dir,
sizeof(pl->dir));
1409 const char *log_dir = NULL;
1412 snprintf(pl->dir,
sizeof(pl->dir),
"%s/%s",
1416 struct stat stat_buf;
1417 if (stat(pl->dir, &stat_buf) != 0) {
1419 "supplied doesn't exist. Shutting down the engine",
1429 if (compression_str == NULL || strcmp(compression_str,
"none") == 0) {
1437 }
else if (strcmp(compression_str,
"lz4") == 0) {
1447 SCLogError(
"SCMalloc failed: %s", strerror(errno));
1453 SCLogError(
"SCFmemopen failed: %s", strerror(errno));
1459 memset(&comp->lz4f_prefs,
'\0',
sizeof(comp->lz4f_prefs));
1460 comp->lz4f_prefs.frameInfo.blockSizeID = LZ4F_max4MB;
1461 comp->lz4f_prefs.frameInfo.blockMode = LZ4F_blockLinked;
1463 comp->lz4f_prefs.frameInfo.contentChecksumFlag = 1;
1466 comp->lz4f_prefs.frameInfo.contentChecksumFlag = 0;
1472 }
else if (lvl < 0) {
1478 comp->lz4f_prefs.compressionLevel = (int)lvl;
1482 LZ4F_errorCode_t errcode =
1483 LZ4F_createCompressionContext(&pl->compression.lz4f_context, 1);
1485 if (LZ4F_isError(errcode)) {
1486 SCLogError(
"LZ4F_createCompressionContext failed: %s", LZ4F_getErrorName(errcode));
1498 "lz4 output buffer.");
1505 pl->suffix =
".lz4";
1508 "in pcap-log, but suricata was not compiled with lz4 "
1510 PcapLogDataFree(pl);
1516 "compression format: %s",
1518 PcapLogDataFree(pl);
1522 SCLogInfo(
"Selected pcap-log compression method: %s",
1523 compression_str ? compression_str :
"none");
1526 if (s_conditional != NULL) {
1527 if (strcasecmp(s_conditional,
"alerts") == 0) {
1530 }
else if (strcasecmp(s_conditional,
"tag") == 0) {
1533 }
else if (strcasecmp(s_conditional,
"all") != 0) {
1534 FatalError(
"log-pcap: invalid conditional \"%s\". Valid options: \"all\", "
1535 "\"alerts\", or \"tag\" mode ",
1541 "Selected pcap-log conditional logging: %s", s_conditional ? s_conditional :
"all");
1544 if (ParseFilename(pl, filename) != 0)
1551 const char *max_number_of_files_s = NULL;
1553 if (max_number_of_files_s != NULL) {
1555 max_number_of_files_s) == -1) {
1557 "pcap-log output, invalid number of files limit: %s",
1558 max_number_of_files_s);
1560 }
else if (max_file_limit < 1) {
1561 FatalError(
"Failed to initialize pcap-log output, limit less than "
1562 "allowed minimum.");
1570 const char *ts_format = NULL;
1574 if (ts_format != NULL) {
1575 if (strcasecmp(ts_format,
"usec") == 0) {
1577 }
else if (strcasecmp(ts_format,
"sec") != 0) {
1578 SCLogError(
"log-pcap ts_format specified %s is invalid must be"
1579 " \"sec\" or \"usec\"",
1585 const char *use_stream_depth = NULL;
1589 if (use_stream_depth != NULL) {
1595 FatalError(
"log-pcap use_stream_depth specified is invalid must be");
1599 const char *honor_pass_rules = NULL;
1603 if (honor_pass_rules != NULL) {
1609 FatalError(
"log-pcap honor-pass-rules specified is invalid");
1616 if (
unlikely(output_ctx == NULL)) {
1617 FatalError(
"Failed to allocate memory for OutputCtx.");
1619 output_ctx->
data = pl;
1620 output_ctx->
DeInit = PcapLogFileDeInitCtx;
1623 result.
ctx = output_ctx;
1628 static void PcapLogFileDeInitCtx(
OutputCtx *output_ctx)
1630 if (output_ctx == NULL)
1639 PcapLogDataFree(pl);
1642 pcre2_code_free(pcre_timestamp_code);
1643 pcre2_match_data_free(pcre_timestamp_match);
1656 char *filename = NULL;
1683 ret = snprintf(filename, PATH_MAX,
"%s/%s.%" PRIu32
"%s", pl->dir, pl->prefix,
1686 ret = snprintf(filename, PATH_MAX,
"%s/%s.%" PRIu32
".%" PRIu32
"%s", pl->dir,
1689 if (ret < 0 || (
size_t)ret >= PATH_MAX) {
1694 if (pl->filename_part_cnt > 0) {
1697 strlcpy(filename, pl->dir, PATH_MAX);
1698 strlcat(filename,
"/", PATH_MAX);
1700 for (
int i = 0; i < pl->filename_part_cnt; i++) {
1701 if (pl->filename_parts[i] == NULL ||strlen(pl->filename_parts[i]) == 0)
1705 if (pl->filename_parts[i][0] ==
'%') {
1707 if (strlen(pl->filename_parts[i]) < 2)
1710 switch(pl->filename_parts[i][1]) {
1712 snprintf(
str,
sizeof(
str),
"%u", pl->thread_number);
1717 snprintf(
str,
sizeof(
str),
"%"PRIu64, (uint64_t)thread_id);
1725 snprintf(
str,
sizeof(
str),
"%" PRIu32
".%" PRIu32,
1733 strlcat(filename, pl->filename_parts[i], PATH_MAX);
1736 strlcat(filename, pl->suffix, PATH_MAX);
1741 ret = snprintf(filename, PATH_MAX,
"%s/%s.%u.%" PRIu32
"%s", pl->dir, pl->prefix,
1744 ret = snprintf(filename, PATH_MAX,
"%s/%s.%u.%" PRIu32
".%" PRIu32
"%s", pl->dir,
1748 if (ret < 0 || (
size_t)ret >= PATH_MAX) {
1753 SCLogDebug(
"multi-mode: filename %s", filename);
1757 SCLogError(
"Error allocating memory. For filename");
1770 PcapFileNameFree(pf);
1783 static int profiling_pcaplog_enabled = 0;
1784 static int profiling_pcaplog_output_to_file = 0;
1785 static char *profiling_pcaplog_file_name = NULL;
1786 static const char *profiling_pcaplog_file_mode =
"a";
1788 static void FormatNumber(uint64_t num,
char *
str,
size_t size)
1791 snprintf(
str, size,
"%"PRIu64, num);
1792 else if (num < 1000000UL)
1793 snprintf(
str, size,
"%3.1fk", (
float)num/1000UL);
1794 else if (num < 1000000000UL)
1795 snprintf(
str, size,
"%3.1fm", (
float)num/1000000UL);
1797 snprintf(
str, size,
"%3.1fb", (
float)num/1000000000UL);
1802 char ticks_str[32] =
"n/a";
1803 char cnt_str[32] =
"n/a";
1804 char avg_str[32] =
"n/a";
1806 FormatNumber((uint64_t)p->
cnt, cnt_str,
sizeof(cnt_str));
1807 FormatNumber((uint64_t)p->
total, ticks_str,
sizeof(ticks_str));
1809 FormatNumber((uint64_t)(p->
total/p->
cnt), avg_str,
sizeof(avg_str));
1811 fprintf(fp,
"%-28s %-10s %-10s %-10s\n",
name, cnt_str, avg_str, ticks_str);
1814 static void ProfileReport(FILE *fp,
PcapLogData *pl)
1819 ProfileReportPair(fp,
"rotate (incl open/close)", &pl->
profile_rotate);
1825 static void FormatBytes(uint64_t num,
char *
str,
size_t size)
1828 snprintf(
str, size,
"%"PRIu64, num);
1829 else if (num < 1048576UL)
1830 snprintf(
str, size,
"%3.1fKiB", (
float)num/1000UL);
1831 else if (num < 1073741824UL)
1832 snprintf(
str, size,
"%3.1fMiB", (
float)num/1000000UL);
1834 snprintf(
str, size,
"%3.1fGiB", (
float)num/1000000000UL);
1841 if (profiling_pcaplog_enabled == 0)
1844 if (profiling_pcaplog_output_to_file == 1) {
1845 fp = fopen(profiling_pcaplog_file_name, profiling_pcaplog_file_mode);
1847 SCLogError(
"failed to open %s: %s", profiling_pcaplog_file_name, strerror(errno));
1855 fprintf(fp,
"\n\nOperation Cnt Avg ticks Total ticks\n");
1856 fprintf(fp,
"---------------------------- ---------- ---------- -----------\n");
1858 ProfileReport(fp, pl);
1865 fprintf(fp,
"\nOverall: %"PRIu64
" bytes written, average %d bytes per write.\n",
1868 fprintf(fp,
" PCAP data structure overhead: %"PRIuMAX
" per write.\n",
1869 (uintmax_t)
sizeof(
struct pcap_pkthdr));
1874 fprintf(fp,
" Size written: %s\n", bytes_str);
1877 uint64_t ticks_per_mib = 0, ticks_per_gib = 0;
1880 ticks_per_mib = total/mib;
1881 char ticks_per_mib_str[32] =
"n/a";
1882 if (ticks_per_mib > 0)
1883 FormatNumber(ticks_per_mib, ticks_per_mib_str,
sizeof(ticks_per_mib_str));
1884 fprintf(fp,
" Ticks per MiB: %s\n", ticks_per_mib_str);
1888 ticks_per_gib = total/gib;
1889 char ticks_per_gib_str[32] =
"n/a";
1890 if (ticks_per_gib > 0)
1891 FormatNumber(ticks_per_gib, ticks_per_gib_str,
sizeof(ticks_per_gib_str));
1892 fprintf(fp,
" Ticks per GiB: %s\n", ticks_per_gib_str);
1902 profiling_pcaplog_enabled = 1;
1903 SCLogInfo(
"pcap-log profiling enabled");
1906 if (filename != NULL) {
1907 const char *log_dir;
1910 profiling_pcaplog_file_name =
SCMalloc(PATH_MAX);
1911 if (
unlikely(profiling_pcaplog_file_name == NULL)) {
1915 snprintf(profiling_pcaplog_file_name, PATH_MAX,
"%s/%s", log_dir, filename);
1919 profiling_pcaplog_file_mode =
"a";
1921 profiling_pcaplog_file_mode =
"w";
1924 profiling_pcaplog_output_to_file = 1;
1925 SCLogInfo(
"pcap-log profiling output goes to %s (mode %s)",
1926 profiling_pcaplog_file_name, profiling_pcaplog_file_mode);