33 #if defined(HAVE_DIRENT_H) && defined(HAVE_FNMATCH_H)
34 #define INIT_RING_BUFFER
59 #define DEFAULT_LOG_FILENAME "pcaplog"
60 #define MODULE_NAME "PcapLog"
61 #define MIN_LIMIT 4 * 1024 * 1024
62 #define DEFAULT_LIMIT 100 * 1024 * 1024
63 #define DEFAULT_FILE_LIMIT 0
65 #define LOGMODE_NORMAL 0
66 #define LOGMODE_SGUIL 1
67 #define LOGMODE_MULTI 2
75 #define RING_BUFFER_MODE_DISABLED 0
76 #define RING_BUFFER_MODE_ENABLED 1
78 #define TS_FORMAT_SEC 0
79 #define TS_FORMAT_USEC 1
81 #define USE_STREAM_DEPTH_DISABLED 0
82 #define USE_STREAM_DEPTH_ENABLED 1
84 #define HONOR_PASS_RULES_DISABLED 0
85 #define HONOR_PASS_RULES_ENABLED 1
87 #define PCAP_SNAPLEN 262144
88 #define PCAP_BUFFER_TIMEOUT 1000000 // microseconds
114 #define MAX_FILENAMELEN 513
126 LZ4F_compressionContext_t lz4f_context;
127 LZ4F_preferences_t lz4f_prefs;
147 struct pcap_pkthdr *
h;
171 uint32_t thread_number;
173 int timestamp_format;
180 int filename_part_cnt;
181 struct timeval last_pcap_dump;
192 static const char timestamp_pattern[] =
".*?(\\d+)(\\.(\\d+))?";
193 static pcre2_code *pcre_timestamp_code = NULL;
194 static pcre2_match_data *pcre_timestamp_match = NULL;
204 static void PcapLogFileDeInitCtx(
OutputCtx *);
212 PcapLogInitCtx, PcapLog, PcapLogCondition, PcapLogDataInit,
213 PcapLogDataDeinit, NULL);
220 #define PCAPLOG_PROFILE_START \
221 uint64_t pcaplog_profile_ticks = UtilCpuGetTicks()
223 #define PCAPLOG_PROFILE_END(prof) \
224 (prof).total += (UtilCpuGetTicks() - pcaplog_profile_ticks); \
283 SCLogError(
"SCFmemopen failed: %s", strerror(errno));
302 uint64_t bytes_written = LZ4F_compressEnd(comp->lz4f_context,
304 if (LZ4F_isError(bytes_written)) {
305 SCLogError(
"LZ4F_compressEnd: %s", LZ4F_getErrorName(bytes_written));
308 if (fwrite(comp->
buffer, 1, bytes_written, comp->
file) < bytes_written) {
309 SCLogError(
"fwrite failed: %s", strerror(errno));
354 if (PcapLogCloseFile(t,pl) < 0) {
374 SCLogDebug(
"Current entry dir %s and next entry %s "
375 "are equal: not removing dir",
379 "not equal: removing dir",
382 if (remove(pf->
dirname) != 0) {
389 PcapFileNameFree(pf);
393 if (PcapLogOpenFileCtx(pl) < 0) {
394 SCLogError(
"opening new pcap log file failed");
414 SCLogDebug(
"Setting pcap-log link type to %u", datalink);
438 if (comp->
file == NULL) {
439 SCLogError(
"Error opening file for compressed output: %s", strerror(errno));
443 uint64_t bytes_written = LZ4F_compressBegin(comp->lz4f_context,
445 if (LZ4F_isError(bytes_written)) {
446 SCLogError(
"LZ4F_compressBegin: %s", LZ4F_getErrorName(bytes_written));
449 if (fwrite(comp->
buffer, 1, bytes_written, comp->
file) < bytes_written) {
450 SCLogError(
"fwrite failed: %s", strerror(errno));
487 static inline int PcapWrite(
490 struct timeval current_dump;
491 gettimeofday(¤t_dump, NULL);
501 SCLogError(
"ftell failed with: %s", strerror(errno));
504 uint64_t out_size = LZ4F_compressUpdate(comp->lz4f_context, comp->
buffer, comp->
buffer_size,
505 comp->
pcap_buf, (uint64_t)in_size, NULL);
506 if (LZ4F_isError(
len)) {
507 SCLogError(
"LZ4F_compressUpdate: %s", LZ4F_getErrorName(
len));
510 if (fseek(pl->compression.pcap_buf_wrapper, 0, SEEK_SET) != 0) {
511 SCLogError(
"fseek failed: %s", strerror(errno));
514 if (fwrite(comp->
buffer, 1, out_size, comp->
file) < out_size) {
515 SCLogError(
"fwrite failed: %s", strerror(errno));
529 pl->last_pcap_dump = current_dump;
539 static int PcapLogSegmentCallback(
540 const Packet *p,
TcpSegment *seg,
void *data,
const uint8_t *buf, uint32_t buflen)
558 static void PcapLogDumpSegments(
611 ret = PcapLogOpenFileCtx(
pl);
631 if (PcapLogRotateFile(t,pl) < 0) {
648 if (PcapLogRotateFile(t,pl) < 0) {
674 PcapLogDumpSegments(td, comp, p);
676 PcapLogDumpSegments(td, NULL, p);
722 SCLogDebug(
"pl->size_current %"PRIu64
", pl->size_limit %"PRIu64,
743 copy->prefix =
SCStrdup(pl->prefix);
744 if (
unlikely(copy->prefix == NULL)) {
750 copy->suffix = pl->suffix;
756 copy->use_ringbuffer = pl->use_ringbuffer;
757 copy->timestamp_format = pl->timestamp_format;
772 copy_comp->lz4f_prefs = comp->lz4f_prefs;
777 if (copy_comp->
buffer == NULL) {
778 SCLogError(
"SCMalloc failed: %s", strerror(errno));
785 SCLogError(
"SCMalloc failed: %s", strerror(errno));
794 SCLogError(
"SCFmemopen failed: %s", strerror(errno));
804 LZ4F_errorCode_t errcode =
805 LZ4F_createCompressionContext(©_comp->lz4f_context, 1);
806 if (LZ4F_isError(errcode)) {
807 SCLogError(
"LZ4F_createCompressionContext failed: %s", LZ4F_getErrorName(errcode));
818 copy_comp->
file = NULL;
826 strlcpy(copy->dir, pl->dir,
sizeof(copy->dir));
829 for (i = 0; i < pl->filename_part_cnt && i <
MAX_TOKS; i++)
830 copy->filename_parts[i] = pl->filename_parts[i];
831 copy->filename_part_cnt = pl->filename_part_cnt;
840 #ifdef INIT_RING_BUFFER
841 static int PcapLogGetTimeOfFile(
const char *filename, uint64_t *secs,
847 int n = pcre2_match(pcre_timestamp_code, (PCRE2_SPTR8)filename, strlen(filename), 0, 0,
848 pcre_timestamp_match, NULL);
849 if (n != 2 && n != 4) {
856 copylen =
sizeof(buf);
857 if (pcre2_substring_copy_bynumber(pcre_timestamp_match, 1, (PCRE2_UCHAR8 *)buf, ©len) <
867 copylen =
sizeof(buf);
868 if (pcre2_substring_copy_bynumber(pcre_timestamp_match, 3, (PCRE2_UCHAR8 *)buf, ©len) <
882 char pattern[PATH_MAX];
884 SCLogInfo(
"Initializing PCAP ring buffer for %s/%s.",
885 pl->dir, pl->prefix);
887 strlcpy(pattern, pl->dir, PATH_MAX);
888 if (pattern[strlen(pattern) - 1] !=
'/') {
889 strlcat(pattern,
"/", PATH_MAX);
892 for (
int i = 0; i < pl->filename_part_cnt; i++) {
893 char *part = pl->filename_parts[i];
894 if (part == NULL || strlen(part) == 0) {
897 if (part[0] !=
'%' || strlen(part) < 2) {
898 strlcat(pattern, part, PATH_MAX);
903 SCLogError(
"Thread ID not allowed in ring buffer mode.");
907 snprintf(tmp, PATH_MAX,
"%"PRIu32, pl->thread_number);
908 strlcat(pattern, tmp, PATH_MAX);
912 strlcat(pattern,
"*", PATH_MAX);
915 SCLogError(
"Unsupported format character: %%%s", part);
920 strlcat(pattern, pl->prefix, PATH_MAX);
921 strlcat(pattern,
".*", PATH_MAX);
923 strlcat(pattern, pl->suffix, PATH_MAX);
925 char *basename = strrchr(pattern,
'/');
929 DIR *dir = opendir(pattern);
931 SCLogWarning(
"Failed to open directory %s: %s", pattern, strerror(errno));
936 struct dirent *entry = readdir(dir);
940 if (fnmatch(basename, entry->d_name, 0) != 0) {
947 if (!PcapLogGetTimeOfFile(entry->d_name, &secs, &usecs)) {
958 if (snprintf(path, PATH_MAX,
"%s/%s", pattern, entry->d_name) == PATH_MAX)
1012 PcapFileNameFree(pf);
1027 static TmEcode PcapLogDataInit(
ThreadVars *t,
const void *initdata,
void **data)
1029 if (initdata == NULL) {
1030 SCLogDebug(
"Error getting context for LogPcap. \"initdata\" argument NULL");
1041 td->
pcap_log = PcapLogDataCopy(pl);
1048 FatalError(
"Pcap logging with multiple link type is not supported.");
1059 FatalError(
"Can't have multiple link types in pcap conditional mode.");
1062 SCLogWarning(
"Using multiple link types can result in invalid pcap output");
1098 #ifdef INIT_RING_BUFFER
1103 SCLogInfo(
"Unable to initialize ring buffer on this platform.");
1114 PcapLogOpenFileCtx(pl);
1124 dst->profile_open.total +=
src->profile_open.total;
1125 dst->profile_open.cnt +=
src->profile_open.cnt;
1127 dst->profile_close.total +=
src->profile_close.total;
1128 dst->profile_close.cnt +=
src->profile_close.cnt;
1130 dst->profile_write.total +=
src->profile_write.total;
1131 dst->profile_write.cnt +=
src->profile_write.cnt;
1133 dst->profile_rotate.total +=
src->profile_rotate.total;
1134 dst->profile_rotate.cnt +=
src->profile_rotate.cnt;
1136 dst->profile_handles.total +=
src->profile_handles.total;
1137 dst->profile_handles.cnt +=
src->profile_handles.cnt;
1139 dst->profile_lock.total +=
src->profile_lock.total;
1140 dst->profile_lock.cnt +=
src->profile_lock.cnt;
1142 dst->profile_unlock.total +=
src->profile_unlock.total;
1143 dst->profile_unlock.cnt +=
src->profile_unlock.cnt;
1145 dst->profile_data_size +=
src->profile_data_size;
1152 while ((pf =
TAILQ_FIRST(&pl->pcap_file_list)) != NULL) {
1154 PcapFileNameFree(pf);
1156 if (pl == g_pcap_data) {
1157 for (
int i = 0; i <
MAX_TOKS; i++) {
1158 if (pl->filename_parts[i] != NULL) {
1159 SCFree(pl->filename_parts[i]);
1169 SCFree(pl->compression.buffer);
1170 fclose(pl->compression.pcap_buf_wrapper);
1171 SCFree(pl->compression.pcap_buf);
1172 LZ4F_errorCode_t errcode =
1173 LZ4F_freeCompressionContext(pl->compression.lz4f_context);
1174 if (LZ4F_isError(errcode)) {
1196 if (PcapLogCloseFile(t,pl) < 0) {
1203 StatsMerge(g_pcap_data, pl);
1204 g_pcap_data->reported++;
1205 if (g_pcap_data->threads == g_pcap_data->reported)
1206 PcapLogProfilingDump(g_pcap_data);
1209 if (pl->reported == 0) {
1210 PcapLogProfilingDump(pl);
1215 if (pl != g_pcap_data) {
1216 PcapLogDataFree(pl);
1227 static int ParseFilename(
PcapLogData *pl,
const char *filename)
1235 size_t filename_len = 0;
1238 filename_len = strlen(filename);
1244 for (i = 0; i < (int)strlen(filename); i++) {
1246 SCLogError(
"invalid filename option. Max 2 %%-sign options");
1250 str[s++] = filename[i];
1252 if (filename[i] ==
'%') {
1263 if (i+1 < (
int)strlen(filename)) {
1265 SCLogError(
"invalid filename option. Max 2 %%-sign options");
1269 if (filename[i+1] !=
'n' && filename[i+1] !=
't' && filename[i+1] !=
'i') {
1271 "invalid filename option. Valid %%-sign options: %%n, %%i and %%t");
1275 str[1] = filename[i+1];
1287 SCLogError(
"Invalid filename for multimode. Need at least one %%-sign option");
1293 SCLogError(
"invalid filename option. Max 3 %%-sign options");
1305 for (i = 0; i < tok; i++) {
1306 if (toks[i] == NULL)
1310 pl->filename_parts[i] = toks[i];
1312 pl->filename_part_cnt = tok;
1317 if (toks[x] != NULL)
1335 FatalError(
"Failed to allocate Memory for PcapLogData");
1340 if (pl->
h == NULL) {
1341 FatalError(
"Failed to allocate Memory for pcap header struct");
1358 pcre_timestamp_code =
1359 pcre2_compile((PCRE2_SPTR8)timestamp_pattern, PCRE2_ZERO_TERMINATED, 0, &en, &eo, NULL);
1360 if (pcre_timestamp_code == NULL) {
1361 PCRE2_UCHAR errbuffer[256];
1362 pcre2_get_error_message(en, errbuffer,
sizeof(errbuffer));
1364 "Failed to compile \"%s\" at offset %d: %s", timestamp_pattern, (
int)eo, errbuffer);
1366 pcre_timestamp_match = pcre2_match_data_create_from_pattern(pcre_timestamp_code, NULL);
1370 const char *filename = NULL;
1376 if (filename == NULL)
1379 if ((pl->prefix =
SCStrdup(filename)) == NULL) {
1387 const char *s_limit = NULL;
1389 if (s_limit != NULL) {
1391 SCLogError(
"Failed to initialize pcap output, invalid limit: %s", s_limit);
1395 SCLogInfo(
"pcap-log \"limit\" value of %"PRIu64
" assumed to be pre-1.2 "
1397 uint64_t size = pl->
size_limit * 1024 * 1024;
1400 FatalError(
"Fail to initialize pcap-log output, limit less than "
1401 "allowed minimum of %d bytes.",
1408 const char *s_mode = NULL;
1410 if (s_mode != NULL) {
1411 if (strcasecmp(s_mode,
"sguil") == 0) {
1413 }
else if (strcasecmp(s_mode,
"multi") == 0) {
1415 }
else if (strcasecmp(s_mode,
"normal") != 0) {
1416 SCLogError(
"log-pcap: invalid mode \"%s\". Valid options: \"normal\", "
1417 "\"sguil\", or \"multi\" mode ",
1423 const char *s_dir = NULL;
1425 if (s_dir == NULL) {
1428 if (s_dir == NULL) {
1430 FatalError(
"log-pcap \"sguil\" mode requires \"sguil-base-dir\" "
1431 "option to be set.");
1433 const char *log_dir = NULL;
1437 log_dir,
sizeof(pl->dir));
1443 s_dir,
sizeof(pl->dir));
1445 const char *log_dir = NULL;
1448 snprintf(pl->dir,
sizeof(pl->dir),
"%s/%s",
1452 struct stat stat_buf;
1453 if (stat(pl->dir, &stat_buf) != 0) {
1454 SCLogError(
"The sguil-base-dir directory \"%s\" "
1455 "supplied doesn't exist. Shutting down the engine",
1466 if (compression_str == NULL || strcmp(compression_str,
"none") == 0) {
1474 }
else if (strcmp(compression_str,
"lz4") == 0) {
1478 "logs are not possible in sguil mode");
1491 SCLogError(
"SCMalloc failed: %s", strerror(errno));
1497 SCLogError(
"SCFmemopen failed: %s", strerror(errno));
1503 memset(&comp->lz4f_prefs,
'\0',
sizeof(comp->lz4f_prefs));
1504 comp->lz4f_prefs.frameInfo.blockSizeID = LZ4F_max4MB;
1505 comp->lz4f_prefs.frameInfo.blockMode = LZ4F_blockLinked;
1507 comp->lz4f_prefs.frameInfo.contentChecksumFlag = 1;
1510 comp->lz4f_prefs.frameInfo.contentChecksumFlag = 0;
1516 }
else if (lvl < 0) {
1522 comp->lz4f_prefs.compressionLevel = lvl;
1526 LZ4F_errorCode_t errcode =
1527 LZ4F_createCompressionContext(&pl->compression.lz4f_context, 1);
1529 if (LZ4F_isError(errcode)) {
1530 SCLogError(
"LZ4F_createCompressionContext failed: %s", LZ4F_getErrorName(errcode));
1542 "lz4 output buffer.");
1549 pl->suffix =
".lz4";
1552 "in pcap-log, but suricata was not compiled with lz4 "
1554 PcapLogDataFree(pl);
1560 "compression format: %s",
1562 PcapLogDataFree(pl);
1566 SCLogInfo(
"Selected pcap-log compression method: %s",
1567 compression_str ? compression_str :
"none");
1570 if (s_conditional != NULL) {
1571 if (strcasecmp(s_conditional,
"alerts") == 0) {
1574 }
else if (strcasecmp(s_conditional,
"tag") == 0) {
1577 }
else if (strcasecmp(s_conditional,
"all") != 0) {
1578 FatalError(
"log-pcap: invalid conditional \"%s\". Valid options: \"all\", "
1579 "\"alerts\", or \"tag\" mode ",
1585 "Selected pcap-log conditional logging: %s", s_conditional ? s_conditional :
"all");
1588 if (ParseFilename(pl, filename) != 0)
1596 const char *max_number_of_files_s = NULL;
1598 if (max_number_of_files_s != NULL) {
1600 max_number_of_files_s) == -1) {
1602 "pcap-log output, invalid number of files limit: %s",
1603 max_number_of_files_s);
1605 }
else if (max_file_limit < 1) {
1606 FatalError(
"Failed to initialize pcap-log output, limit less than "
1607 "allowed minimum.");
1615 const char *ts_format = NULL;
1619 if (ts_format != NULL) {
1620 if (strcasecmp(ts_format,
"usec") == 0) {
1622 }
else if (strcasecmp(ts_format,
"sec") != 0) {
1623 SCLogError(
"log-pcap ts_format specified %s is invalid must be"
1624 " \"sec\" or \"usec\"",
1630 const char *use_stream_depth = NULL;
1634 if (use_stream_depth != NULL) {
1640 FatalError(
"log-pcap use_stream_depth specified is invalid must be");
1644 const char *honor_pass_rules = NULL;
1648 if (honor_pass_rules != NULL) {
1654 FatalError(
"log-pcap honor-pass-rules specified is invalid");
1661 if (
unlikely(output_ctx == NULL)) {
1662 FatalError(
"Failed to allocate memory for OutputCtx.");
1664 output_ctx->
data = pl;
1665 output_ctx->
DeInit = PcapLogFileDeInitCtx;
1668 result.
ctx = output_ctx;
1673 static void PcapLogFileDeInitCtx(
OutputCtx *output_ctx)
1675 if (output_ctx == NULL)
1684 PcapLogDataFree(pl);
1687 pcre2_code_free(pcre_timestamp_code);
1688 pcre2_match_data_free(pcre_timestamp_match);
1703 char *filename = NULL;
1731 char dirname[32], dirfull[PATH_MAX] =
"";
1733 snprintf(dirname,
sizeof(dirname),
"%04d-%02d-%02d",
1734 tms->tm_year + 1900, tms->tm_mon + 1, tms->tm_mday);
1737 int ret = snprintf(dirfull,
sizeof(dirfull),
"%s/%s", pl->dir, dirname);
1738 if (ret < 0 || (
size_t)ret >=
sizeof(dirfull)) {
1754 written = snprintf(filename, PATH_MAX,
"%s/%s.%" PRIu32
"%s", dirfull, pl->prefix,
1757 written = snprintf(filename, PATH_MAX,
"%s/%s.%" PRIu32
".%" PRIu32
"%s", dirfull,
1760 if (written == PATH_MAX) {
1768 ret = snprintf(filename, PATH_MAX,
"%s/%s.%" PRIu32
"%s", pl->dir, pl->prefix,
1771 ret = snprintf(filename, PATH_MAX,
"%s/%s.%" PRIu32
".%" PRIu32
"%s", pl->dir,
1774 if (ret < 0 || (
size_t)ret >= PATH_MAX) {
1779 if (pl->filename_part_cnt > 0) {
1782 strlcpy(filename, pl->dir, PATH_MAX);
1783 strlcat(filename,
"/", PATH_MAX);
1786 for (i = 0; i < pl->filename_part_cnt; i++) {
1787 if (pl->filename_parts[i] == NULL ||strlen(pl->filename_parts[i]) == 0)
1791 if (pl->filename_parts[i][0] ==
'%') {
1793 if (strlen(pl->filename_parts[i]) < 2)
1796 switch(pl->filename_parts[i][1]) {
1798 snprintf(
str,
sizeof(
str),
"%u", pl->thread_number);
1803 snprintf(
str,
sizeof(
str),
"%"PRIu64, (uint64_t)thread_id);
1811 snprintf(
str,
sizeof(
str),
"%" PRIu32
".%" PRIu32,
1819 strlcat(filename, pl->filename_parts[i], PATH_MAX);
1822 strlcat(filename, pl->suffix, PATH_MAX);
1827 ret = snprintf(filename, PATH_MAX,
"%s/%s.%u.%" PRIu32
"%s", pl->dir, pl->prefix,
1830 ret = snprintf(filename, PATH_MAX,
"%s/%s.%u.%" PRIu32
".%" PRIu32
"%s", pl->dir,
1834 if (ret < 0 || (
size_t)ret >= PATH_MAX) {
1839 SCLogDebug(
"multi-mode: filename %s", filename);
1843 SCLogError(
"Error allocating memory. For filename");
1856 PcapFileNameFree(pf);
1869 static int profiling_pcaplog_enabled = 0;
1870 static int profiling_pcaplog_output_to_file = 0;
1871 static char *profiling_pcaplog_file_name = NULL;
1872 static const char *profiling_pcaplog_file_mode =
"a";
1874 static void FormatNumber(uint64_t num,
char *
str,
size_t size)
1877 snprintf(
str, size,
"%"PRIu64, num);
1878 else if (num < 1000000UL)
1879 snprintf(
str, size,
"%3.1fk", (
float)num/1000UL);
1880 else if (num < 1000000000UL)
1881 snprintf(
str, size,
"%3.1fm", (
float)num/1000000UL);
1883 snprintf(
str, size,
"%3.1fb", (
float)num/1000000000UL);
1888 char ticks_str[32] =
"n/a";
1889 char cnt_str[32] =
"n/a";
1890 char avg_str[32] =
"n/a";
1892 FormatNumber((uint64_t)p->
cnt, cnt_str,
sizeof(cnt_str));
1893 FormatNumber((uint64_t)p->
total, ticks_str,
sizeof(ticks_str));
1895 FormatNumber((uint64_t)(p->
total/p->
cnt), avg_str,
sizeof(avg_str));
1897 fprintf(fp,
"%-28s %-10s %-10s %-10s\n", name, cnt_str, avg_str, ticks_str);
1900 static void ProfileReport(FILE *fp,
PcapLogData *pl)
1905 ProfileReportPair(fp,
"rotate (incl open/close)", &pl->
profile_rotate);
1911 static void FormatBytes(uint64_t num,
char *
str,
size_t size)
1914 snprintf(
str, size,
"%"PRIu64, num);
1915 else if (num < 1048576UL)
1916 snprintf(
str, size,
"%3.1fKiB", (
float)num/1000UL);
1917 else if (num < 1073741824UL)
1918 snprintf(
str, size,
"%3.1fMiB", (
float)num/1000000UL);
1920 snprintf(
str, size,
"%3.1fGiB", (
float)num/1000000000UL);
1927 if (profiling_pcaplog_enabled == 0)
1930 if (profiling_pcaplog_output_to_file == 1) {
1931 fp = fopen(profiling_pcaplog_file_name, profiling_pcaplog_file_mode);
1933 SCLogError(
"failed to open %s: %s", profiling_pcaplog_file_name, strerror(errno));
1941 fprintf(fp,
"\n\nOperation Cnt Avg ticks Total ticks\n");
1942 fprintf(fp,
"---------------------------- ---------- ---------- -----------\n");
1944 ProfileReport(fp, pl);
1951 fprintf(fp,
"\nOverall: %"PRIu64
" bytes written, average %d bytes per write.\n",
1954 fprintf(fp,
" PCAP data structure overhead: %"PRIuMAX
" per write.\n",
1955 (uintmax_t)
sizeof(
struct pcap_pkthdr));
1960 fprintf(fp,
" Size written: %s\n", bytes_str);
1963 uint64_t ticks_per_mib = 0, ticks_per_gib = 0;
1966 ticks_per_mib = total/mib;
1967 char ticks_per_mib_str[32] =
"n/a";
1968 if (ticks_per_mib > 0)
1969 FormatNumber(ticks_per_mib, ticks_per_mib_str,
sizeof(ticks_per_mib_str));
1970 fprintf(fp,
" Ticks per MiB: %s\n", ticks_per_mib_str);
1974 ticks_per_gib = total/gib;
1975 char ticks_per_gib_str[32] =
"n/a";
1976 if (ticks_per_gib > 0)
1977 FormatNumber(ticks_per_gib, ticks_per_gib_str,
sizeof(ticks_per_gib_str));
1978 fprintf(fp,
" Ticks per GiB: %s\n", ticks_per_gib_str);
1988 profiling_pcaplog_enabled = 1;
1989 SCLogInfo(
"pcap-log profiling enabled");
1992 if (filename != NULL) {
1993 const char *log_dir;
1996 profiling_pcaplog_file_name =
SCMalloc(PATH_MAX);
1997 if (
unlikely(profiling_pcaplog_file_name == NULL)) {
2001 snprintf(profiling_pcaplog_file_name, PATH_MAX,
"%s/%s", log_dir, filename);
2005 profiling_pcaplog_file_mode =
"a";
2007 profiling_pcaplog_file_mode =
"w";
2010 profiling_pcaplog_output_to_file = 1;
2011 SCLogInfo(
"pcap-log profiling output goes to %s (mode %s)",
2012 profiling_pcaplog_file_name, profiling_pcaplog_file_mode);