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
90 #ifndef PCAP_NETMASK_UNKNOWN
91 #define PCAP_NETMASK_UNKNOWN 0xffffffff
118 #define MAX_FILENAMELEN 513
130 LZ4F_compressionContext_t lz4f_context;
131 LZ4F_preferences_t lz4f_prefs;
151 struct pcap_pkthdr *
h;
177 uint32_t thread_number;
179 int timestamp_format;
186 int filename_part_cnt;
187 struct timeval last_pcap_dump;
203 static const char timestamp_pattern[] =
".*?(\\d+)(\\.(\\d+))?";
204 static pcre2_code *pcre_timestamp_code = NULL;
205 static pcre2_match_data *pcre_timestamp_match = NULL;
215 static void PcapLogFileDeInitCtx(
OutputCtx *);
224 .ConditionFunc = PcapLogCondition,
225 .ThreadInitFunc = PcapLogDataInit,
226 .ThreadDeinitFunc = PcapLogDataDeinit,
227 .ThreadExitPrintStatsFunc = NULL,
236 #define PCAPLOG_PROFILE_START \
237 uint64_t pcaplog_profile_ticks = UtilCpuGetTicks()
239 #define PCAPLOG_PROFILE_END(prof) \
240 (prof).total += (UtilCpuGetTicks() - pcaplog_profile_ticks); \
261 return !PacketIsTunnelChild(p);
286 SCLogError(
"SCFmemopen failed: %s", strerror(errno));
305 uint64_t bytes_written = LZ4F_compressEnd(comp->lz4f_context,
307 if (LZ4F_isError(bytes_written)) {
308 SCLogError(
"LZ4F_compressEnd: %s", LZ4F_getErrorName(bytes_written));
311 if (fwrite(comp->
buffer, 1, bytes_written, comp->
file) < bytes_written) {
312 SCLogError(
"fwrite failed: %s", strerror(errno));
354 if (PcapLogCloseFile(t,pl) < 0) {
370 PcapFileNameFree(pf);
374 if (PcapLogOpenFileCtx(pl) < 0) {
375 SCLogError(
"opening new pcap log file failed");
390 if (PacketIsTunnelChild(p)) {
395 SCLogDebug(
"Setting pcap-log link type to %u", datalink);
402 struct bpf_program bpfp;
409 if (pl->
bpfp == NULL) {
410 FatalError(
"Failed to allocate memory for BPF filter, aborting");
421 if (!pl->pcap_open_err) {
423 pl->pcap_open_err =
true;
427 pl->pcap_open_err =
false;
435 if (comp->
file == NULL) {
436 if (errno != pl->fopen_err) {
437 SCLogError(
"Error opening file for compressed output: %s", strerror(errno));
438 pl->fopen_err = errno;
447 if (!pl->pcap_open_err) {
449 pl->pcap_open_err =
true;
455 pl->pcap_open_err =
false;
458 uint64_t bytes_written = LZ4F_compressBegin(comp->lz4f_context,
460 if (LZ4F_isError(bytes_written)) {
461 SCLogError(
"LZ4F_compressBegin: %s", LZ4F_getErrorName(bytes_written));
464 if (fwrite(comp->
buffer, 1, bytes_written, comp->
file) < bytes_written) {
465 SCLogError(
"fwrite failed: %s", strerror(errno));
502 static inline int PcapWrite(
505 struct timeval current_dump;
506 gettimeofday(¤t_dump, NULL);
510 if (pcap_offline_filter(pl->
bpfp, pl->
h, data) == 0) {
511 SCLogDebug(
"Packet doesn't match filter, will not be logged.");
529 SCLogError(
"ftell failed with: %s", strerror(errno));
532 uint64_t out_size = LZ4F_compressUpdate(comp->lz4f_context, comp->
buffer, comp->
buffer_size,
533 comp->
pcap_buf, (uint64_t)in_size, NULL);
534 if (LZ4F_isError(
len)) {
535 SCLogError(
"LZ4F_compressUpdate: %s", LZ4F_getErrorName(
len));
539 SCLogError(
"fseek failed: %s", strerror(errno));
542 if (fwrite(comp->
buffer, 1, out_size, comp->
file) < out_size) {
543 SCLogError(
"fwrite failed: %s", strerror(errno));
557 pl->last_pcap_dump = current_dump;
566 static int PcapLogSegmentCallback(
567 const Packet *p,
TcpSegment *seg,
void *data,
const uint8_t *buf, uint32_t buflen)
578 MemBufferReset(pctx->
td->
buf);
626 if (PacketIsTunnelChild(p)) {
638 ret = PcapLogOpenFileCtx(pl);
649 if (PcapLogRotateFile(
tv, pl) < 0) {
665 if (PcapLogRotateFile(
tv, pl) < 0) {
688 if (PacketIsTCP(p)) {
690 PcapLogDumpSegments(
tv,
td, p);
700 if (PacketIsTunnelChild(p)) {
713 if (PacketIsTunnelChild(p)) {
728 SCLogDebug(
"pl->size_current %"PRIu64
", pl->size_limit %"PRIu64,
749 copy->prefix =
SCStrdup(pl->prefix);
750 if (
unlikely(copy->prefix == NULL)) {
756 copy->suffix = pl->suffix;
762 copy->use_ringbuffer = pl->use_ringbuffer;
763 copy->timestamp_format = pl->timestamp_format;
779 copy_comp->lz4f_prefs = comp->lz4f_prefs;
784 if (copy_comp->
buffer == NULL) {
785 SCLogError(
"SCMalloc failed: %s", strerror(errno));
793 SCLogError(
"SCMalloc failed: %s", strerror(errno));
803 SCLogError(
"SCFmemopen failed: %s", strerror(errno));
814 LZ4F_errorCode_t errcode =
815 LZ4F_createCompressionContext(©_comp->lz4f_context, 1);
816 if (LZ4F_isError(errcode)) {
817 SCLogError(
"LZ4F_createCompressionContext failed: %s", LZ4F_getErrorName(errcode));
829 copy_comp->
file = NULL;
837 strlcpy(copy->dir, pl->dir,
sizeof(copy->dir));
839 for (
int i = 0; i < pl->filename_part_cnt && i <
MAX_TOKS; i++)
840 copy->filename_parts[i] = pl->filename_parts[i];
841 copy->filename_part_cnt = pl->filename_part_cnt;
850 #ifdef INIT_RING_BUFFER
851 static int PcapLogGetTimeOfFile(
const char *filename, uint64_t *secs,
857 int n = pcre2_match(pcre_timestamp_code, (PCRE2_SPTR8)filename, strlen(filename), 0, 0,
858 pcre_timestamp_match, NULL);
859 if (n != 2 && n != 4) {
866 copylen =
sizeof(buf);
867 if (pcre2_substring_copy_bynumber(pcre_timestamp_match, 1, (PCRE2_UCHAR8 *)buf, ©len) <
877 copylen =
sizeof(buf);
878 if (pcre2_substring_copy_bynumber(pcre_timestamp_match, 3, (PCRE2_UCHAR8 *)buf, ©len) <
892 char pattern[PATH_MAX];
894 SCLogInfo(
"Initializing PCAP ring buffer for %s/%s.",
895 pl->dir, pl->prefix);
897 strlcpy(pattern, pl->dir, PATH_MAX);
898 if (pattern[strlen(pattern) - 1] !=
'/') {
899 strlcat(pattern,
"/", PATH_MAX);
902 for (
int i = 0; i < pl->filename_part_cnt; i++) {
903 char *part = pl->filename_parts[i];
904 if (part == NULL || strlen(part) == 0) {
907 if (part[0] !=
'%' || strlen(part) < 2) {
908 strlcat(pattern, part, PATH_MAX);
913 SCLogError(
"Thread ID not allowed in ring buffer mode.");
917 snprintf(tmp, PATH_MAX,
"%"PRIu32, pl->thread_number);
918 strlcat(pattern, tmp, PATH_MAX);
922 strlcat(pattern,
"*", PATH_MAX);
925 SCLogError(
"Unsupported format character: %%%s", part);
930 strlcat(pattern, pl->prefix, PATH_MAX);
931 strlcat(pattern,
".*", PATH_MAX);
933 strlcat(pattern, pl->suffix, PATH_MAX);
935 char *basename = strrchr(pattern,
'/');
939 DIR *dir = opendir(pattern);
941 SCLogWarning(
"Failed to open directory %s: %s", pattern, strerror(errno));
946 struct dirent *entry = readdir(dir);
950 if (fnmatch(basename, entry->d_name, 0) != 0) {
957 if (!PcapLogGetTimeOfFile(entry->d_name, &secs, &usecs)) {
968 if (
PathMerge(path,
sizeof(path), pattern, entry->d_name) < 0)
1023 PcapFileNameFree(pf);
1039 static TmEcode PcapLogDataInit(
ThreadVars *t,
const void *initdata,
void **data)
1041 if (initdata == NULL) {
1042 SCLogDebug(
"Error getting context for LogPcap. \"initdata\" argument NULL");
1056 td->
pcap_log = PcapLogDataCopy(pl);
1063 FatalError(
"Pcap logging with multiple link type is not supported.");
1074 FatalError(
"Can't have multiple link types in pcap conditional mode.");
1077 SCLogWarning(
"Using multiple link types can result in invalid pcap output");
1113 #ifdef INIT_RING_BUFFER
1118 SCLogInfo(
"Unable to initialize ring buffer on this platform.");
1129 PcapLogOpenFileCtx(pl);
1139 dst->profile_open.total +=
src->profile_open.total;
1140 dst->profile_open.cnt +=
src->profile_open.cnt;
1142 dst->profile_close.total +=
src->profile_close.total;
1143 dst->profile_close.cnt +=
src->profile_close.cnt;
1145 dst->profile_write.total +=
src->profile_write.total;
1146 dst->profile_write.cnt +=
src->profile_write.cnt;
1148 dst->profile_rotate.total +=
src->profile_rotate.total;
1149 dst->profile_rotate.cnt +=
src->profile_rotate.cnt;
1151 dst->profile_handles.total +=
src->profile_handles.total;
1152 dst->profile_handles.cnt +=
src->profile_handles.cnt;
1154 dst->profile_lock.total +=
src->profile_lock.total;
1155 dst->profile_lock.cnt +=
src->profile_lock.cnt;
1157 dst->profile_unlock.total +=
src->profile_unlock.total;
1158 dst->profile_unlock.cnt +=
src->profile_unlock.cnt;
1160 dst->profile_data_size +=
src->profile_data_size;
1167 while ((pf =
TAILQ_FIRST(&pl->pcap_file_list)) != NULL) {
1169 PcapFileNameFree(pf);
1171 if (pl == g_pcap_data) {
1172 for (
int i = 0; i <
MAX_TOKS; i++) {
1173 if (pl->filename_parts[i] != NULL) {
1174 SCFree(pl->filename_parts[i]);
1187 pcap_freecode(pl->
bpfp);
1193 SCFree(pl->compression.buffer);
1194 fclose(pl->compression.pcap_buf_wrapper);
1195 SCFree(pl->compression.pcap_buf);
1196 LZ4F_errorCode_t errcode =
1197 LZ4F_freeCompressionContext(pl->compression.lz4f_context);
1198 if (LZ4F_isError(errcode)) {
1220 if (PcapLogCloseFile(t,pl) < 0) {
1227 StatsMerge(g_pcap_data, pl);
1228 g_pcap_data->reported++;
1229 if (g_pcap_data->threads == g_pcap_data->reported)
1230 PcapLogProfilingDump(g_pcap_data);
1233 if (pl->reported == 0) {
1234 PcapLogProfilingDump(pl);
1239 if (pl != g_pcap_data) {
1240 PcapLogDataFree(pl);
1251 static int ParseFilename(
PcapLogData *pl,
const char *filename)
1258 size_t filename_len = 0;
1261 filename_len = strlen(filename);
1267 for (
int i = 0; i < (int)strlen(filename); i++) {
1269 SCLogError(
"invalid filename option. Max 2 %%-sign options");
1273 str[s++] = filename[i];
1275 if (filename[i] ==
'%') {
1286 if (i+1 < (
int)strlen(filename)) {
1288 SCLogError(
"invalid filename option. Max 2 %%-sign options");
1292 if (filename[i+1] !=
'n' && filename[i+1] !=
't' && filename[i+1] !=
'i') {
1294 "invalid filename option. Valid %%-sign options: %%n, %%i and %%t");
1298 str[1] = filename[i+1];
1310 SCLogError(
"Invalid filename for multimode. Need at least one %%-sign option");
1316 SCLogError(
"invalid filename option. Max 3 %%-sign options");
1328 for (
int i = 0; i < tok; i++) {
1329 if (toks[i] == NULL)
1333 pl->filename_parts[i] = toks[i];
1335 pl->filename_part_cnt = tok;
1339 for (
int x = 0; x <
MAX_TOKS; x++) {
1340 if (toks[x] != NULL)
1357 FatalError(
"A pcap-log instance is already active, only one can be enabled.");
1362 FatalError(
"Failed to allocate Memory for PcapLogData");
1366 if (pl->
h == NULL) {
1367 FatalError(
"Failed to allocate Memory for pcap header struct");
1384 pcre_timestamp_code =
1385 pcre2_compile((PCRE2_SPTR8)timestamp_pattern, PCRE2_ZERO_TERMINATED, 0, &en, &eo, NULL);
1386 if (pcre_timestamp_code == NULL) {
1387 PCRE2_UCHAR errbuffer[256];
1388 pcre2_get_error_message(en, errbuffer,
sizeof(errbuffer));
1390 "Failed to compile \"%s\" at offset %d: %s", timestamp_pattern, (
int)eo, errbuffer);
1392 pcre_timestamp_match = pcre2_match_data_create_from_pattern(pcre_timestamp_code, NULL);
1396 const char *filename = NULL;
1402 if (filename == NULL)
1405 if ((pl->prefix =
SCStrdup(filename)) == NULL) {
1413 const char *s_limit = NULL;
1415 if (s_limit != NULL) {
1417 SCLogError(
"Failed to initialize pcap output, invalid limit: %s", s_limit);
1421 SCLogInfo(
"pcap-log \"limit\" value of %"PRIu64
" assumed to be pre-1.2 "
1423 uint64_t size = pl->
size_limit * 1024 * 1024;
1426 FatalError(
"Fail to initialize pcap-log output, limit less than "
1427 "allowed minimum of %d bytes.",
1434 const char *s_mode = NULL;
1436 if (s_mode != NULL) {
1437 if (strcasecmp(s_mode,
"multi") == 0) {
1439 }
else if (strcasecmp(s_mode,
"normal") != 0) {
1440 FatalError(
"log-pcap: invalid mode \"%s\". Valid options: \"normal\""
1441 "or \"multi\" mode ",
1446 const char *s_dir = NULL;
1448 if (s_dir == NULL) {
1449 const char *log_dir = NULL;
1452 strlcpy(pl->dir, log_dir,
sizeof(pl->dir));
1457 s_dir,
sizeof(pl->dir));
1459 const char *log_dir = NULL;
1462 snprintf(pl->dir,
sizeof(pl->dir),
"%s/%s",
1466 struct stat stat_buf;
1467 if (stat(pl->dir, &stat_buf) != 0) {
1469 "supplied doesn't exist. Shutting down the engine",
1478 if (compression_str == NULL || strcmp(compression_str,
"none") == 0) {
1486 }
else if (strcmp(compression_str,
"lz4") == 0) {
1496 SCLogError(
"SCMalloc failed: %s", strerror(errno));
1502 SCLogError(
"SCFmemopen failed: %s", strerror(errno));
1508 memset(&comp->lz4f_prefs,
'\0',
sizeof(comp->lz4f_prefs));
1509 comp->lz4f_prefs.frameInfo.blockSizeID = LZ4F_max4MB;
1510 comp->lz4f_prefs.frameInfo.blockMode = LZ4F_blockLinked;
1512 comp->lz4f_prefs.frameInfo.contentChecksumFlag = 1;
1514 comp->lz4f_prefs.frameInfo.contentChecksumFlag = 0;
1520 }
else if (lvl < 0) {
1526 comp->lz4f_prefs.compressionLevel = (int)lvl;
1530 LZ4F_errorCode_t errcode =
1531 LZ4F_createCompressionContext(&pl->compression.lz4f_context, 1);
1533 if (LZ4F_isError(errcode)) {
1534 SCLogError(
"LZ4F_createCompressionContext failed: %s", LZ4F_getErrorName(errcode));
1546 "lz4 output buffer.");
1553 pl->suffix =
".lz4";
1556 "in pcap-log, but suricata was not compiled with lz4 "
1558 PcapLogDataFree(pl);
1564 "compression format: %s",
1566 PcapLogDataFree(pl);
1570 SCLogInfo(
"Selected pcap-log compression method: %s",
1571 compression_str ? compression_str :
"none");
1574 if (s_conditional != NULL) {
1575 if (strcasecmp(s_conditional,
"alerts") == 0) {
1578 }
else if (strcasecmp(s_conditional,
"tag") == 0) {
1581 }
else if (strcasecmp(s_conditional,
"all") != 0) {
1582 FatalError(
"log-pcap: invalid conditional \"%s\". Valid options: \"all\", "
1583 "\"alerts\", or \"tag\" mode ",
1589 "Selected pcap-log conditional logging: %s", s_conditional ? s_conditional :
"all");
1592 if (ParseFilename(pl, filename) != 0)
1599 const char *max_number_of_files_s = NULL;
1601 if (max_number_of_files_s != NULL) {
1603 max_number_of_files_s) == -1) {
1605 "pcap-log output, invalid number of files limit: %s",
1606 max_number_of_files_s);
1608 }
else if (max_file_limit < 1) {
1609 FatalError(
"Failed to initialize pcap-log output, limit less than "
1610 "allowed minimum.");
1618 const char *ts_format = NULL;
1622 if (ts_format != NULL) {
1623 if (strcasecmp(ts_format,
"usec") == 0) {
1625 }
else if (strcasecmp(ts_format,
"sec") != 0) {
1626 SCLogError(
"log-pcap ts_format specified %s is invalid must be"
1627 " \"sec\" or \"usec\"",
1633 const char *use_stream_depth = NULL;
1637 if (use_stream_depth != NULL) {
1643 FatalError(
"log-pcap use_stream_depth specified is invalid must be");
1647 const char *honor_pass_rules = NULL;
1651 if (honor_pass_rules != NULL) {
1657 FatalError(
"log-pcap honor-pass-rules specified is invalid");
1666 if (
unlikely(output_ctx == NULL)) {
1667 FatalError(
"Failed to allocate memory for OutputCtx.");
1669 output_ctx->
data = pl;
1670 output_ctx->
DeInit = PcapLogFileDeInitCtx;
1673 result.
ctx = output_ctx;
1678 static void PcapLogFileDeInitCtx(
OutputCtx *output_ctx)
1680 if (output_ctx == NULL)
1689 PcapLogDataFree(pl);
1692 pcre2_code_free(pcre_timestamp_code);
1693 pcre2_match_data_free(pcre_timestamp_match);
1729 char file[PATH_MAX] =
"";
1734 ret = snprintf(file,
sizeof(file),
"%s.%" PRIu32
"%s", pl->prefix,
1737 ret = snprintf(file,
sizeof(file),
"%s.%" PRIu32
".%" PRIu32
"%s", pl->prefix,
1740 if (ret < 0 || (
size_t)ret >= PATH_MAX) {
1745 if (pl->filename_part_cnt > 0) {
1748 for (
int i = 0; i < pl->filename_part_cnt; i++) {
1749 if (pl->filename_parts[i] == NULL ||strlen(pl->filename_parts[i]) == 0)
1753 if (pl->filename_parts[i][0] ==
'%') {
1755 if (strlen(pl->filename_parts[i]) < 2)
1758 switch(pl->filename_parts[i][1]) {
1760 snprintf(
str,
sizeof(
str),
"%u", pl->thread_number);
1765 snprintf(
str,
sizeof(
str),
"%"PRIu64, (uint64_t)thread_id);
1773 snprintf(
str,
sizeof(
str),
"%" PRIu32
".%" PRIu32,
1781 strlcat(file, pl->filename_parts[i],
sizeof(file));
1784 strlcat(file, pl->suffix,
sizeof(file));
1789 ret = snprintf(file,
sizeof(file),
"%s.%u.%" PRIu32
"%s", pl->prefix,
1792 ret = snprintf(file,
sizeof(file),
"%s.%u.%" PRIu32
".%" PRIu32
"%s", pl->prefix,
1796 if (ret < 0 || (
size_t)ret >= PATH_MAX) {
1803 if (
PathMerge(path, PATH_MAX, pl->dir, file) < 0) {
1809 SCLogError(
"Error allocating memory. For filename");
1822 PcapFileNameFree(pf);
1835 static int profiling_pcaplog_enabled = 0;
1836 static int profiling_pcaplog_output_to_file = 0;
1837 static char *profiling_pcaplog_file_name = NULL;
1838 static const char *profiling_pcaplog_file_mode =
"a";
1840 static void FormatNumber(uint64_t num,
char *
str,
size_t size)
1843 snprintf(
str, size,
"%"PRIu64, num);
1844 else if (num < 1000000UL)
1845 snprintf(
str, size,
"%3.1fk", (
float)num/1000UL);
1846 else if (num < 1000000000UL)
1847 snprintf(
str, size,
"%3.1fm", (
float)num/1000000UL);
1849 snprintf(
str, size,
"%3.1fb", (
float)num/1000000000UL);
1854 char ticks_str[32] =
"n/a";
1855 char cnt_str[32] =
"n/a";
1856 char avg_str[32] =
"n/a";
1858 FormatNumber((uint64_t)p->
cnt, cnt_str,
sizeof(cnt_str));
1859 FormatNumber((uint64_t)p->
total, ticks_str,
sizeof(ticks_str));
1861 FormatNumber((uint64_t)(p->
total/p->
cnt), avg_str,
sizeof(avg_str));
1863 fprintf(fp,
"%-28s %-10s %-10s %-10s\n",
name, cnt_str, avg_str, ticks_str);
1866 static void ProfileReport(FILE *fp,
PcapLogData *pl)
1871 ProfileReportPair(fp,
"rotate (incl open/close)", &pl->
profile_rotate);
1877 static void FormatBytes(uint64_t num,
char *
str,
size_t size)
1880 snprintf(
str, size,
"%"PRIu64, num);
1881 else if (num < 1048576UL)
1882 snprintf(
str, size,
"%3.1fKiB", (
float)num/1000UL);
1883 else if (num < 1073741824UL)
1884 snprintf(
str, size,
"%3.1fMiB", (
float)num/1000000UL);
1886 snprintf(
str, size,
"%3.1fGiB", (
float)num/1000000000UL);
1893 if (profiling_pcaplog_enabled == 0)
1896 if (profiling_pcaplog_output_to_file == 1) {
1897 fp = fopen(profiling_pcaplog_file_name, profiling_pcaplog_file_mode);
1899 SCLogError(
"failed to open %s: %s", profiling_pcaplog_file_name, strerror(errno));
1907 fprintf(fp,
"\n\nOperation Cnt Avg ticks Total ticks\n");
1908 fprintf(fp,
"---------------------------- ---------- ---------- -----------\n");
1910 ProfileReport(fp, pl);
1917 fprintf(fp,
"\nOverall: %"PRIu64
" bytes written, average %d bytes per write.\n",
1920 fprintf(fp,
" PCAP data structure overhead: %"PRIuMAX
" per write.\n",
1921 (uintmax_t)
sizeof(
struct pcap_pkthdr));
1926 fprintf(fp,
" Size written: %s\n", bytes_str);
1929 uint64_t ticks_per_mib = 0, ticks_per_gib = 0;
1932 ticks_per_mib = total/mib;
1933 char ticks_per_mib_str[32] =
"n/a";
1934 if (ticks_per_mib > 0)
1935 FormatNumber(ticks_per_mib, ticks_per_mib_str,
sizeof(ticks_per_mib_str));
1936 fprintf(fp,
" Ticks per MiB: %s\n", ticks_per_mib_str);
1940 ticks_per_gib = total/gib;
1941 char ticks_per_gib_str[32] =
"n/a";
1942 if (ticks_per_gib > 0)
1943 FormatNumber(ticks_per_gib, ticks_per_gib_str,
sizeof(ticks_per_gib_str));
1944 fprintf(fp,
" Ticks per GiB: %s\n", ticks_per_gib_str);
1954 profiling_pcaplog_enabled = 1;
1955 SCLogInfo(
"pcap-log profiling enabled");
1958 if (filename != NULL) {
1959 const char *log_dir;
1962 profiling_pcaplog_file_name =
SCMalloc(PATH_MAX);
1963 if (
unlikely(profiling_pcaplog_file_name == NULL)) {
1967 snprintf(profiling_pcaplog_file_name, PATH_MAX,
"%s/%s", log_dir, filename);
1971 profiling_pcaplog_file_mode =
"a";
1973 profiling_pcaplog_file_mode =
"w";
1976 profiling_pcaplog_output_to_file = 1;
1977 SCLogInfo(
"pcap-log profiling output goes to %s (mode %s)",
1978 profiling_pcaplog_file_name, profiling_pcaplog_file_mode);