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;
202 static const char timestamp_pattern[] =
".*?(\\d+)(\\.(\\d+))?";
203 static pcre2_code *pcre_timestamp_code = NULL;
204 static pcre2_match_data *pcre_timestamp_match = NULL;
214 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); \
289 SCLogError(
"SCFmemopen failed: %s", strerror(errno));
308 uint64_t bytes_written = LZ4F_compressEnd(comp->lz4f_context,
310 if (LZ4F_isError(bytes_written)) {
311 SCLogError(
"LZ4F_compressEnd: %s", LZ4F_getErrorName(bytes_written));
314 if (fwrite(comp->
buffer, 1, bytes_written, comp->
file) < bytes_written) {
315 SCLogError(
"fwrite failed: %s", strerror(errno));
357 if (PcapLogCloseFile(t,pl) < 0) {
373 PcapFileNameFree(pf);
377 if (PcapLogOpenFileCtx(pl) < 0) {
378 SCLogError(
"opening new pcap log file failed");
398 SCLogDebug(
"Setting pcap-log link type to %u", datalink);
405 struct bpf_program bpfp;
412 if (pl->
bpfp == NULL) {
413 FatalError(
"Failed to allocate memory for BPF filter, aborting");
424 if (!pl->pcap_open_err) {
426 pl->pcap_open_err =
true;
430 pl->pcap_open_err =
false;
438 if (comp->
file == NULL) {
439 if (errno != pl->fopen_err) {
440 SCLogError(
"Error opening file for compressed output: %s", strerror(errno));
441 pl->fopen_err = errno;
450 if (!pl->pcap_open_err) {
452 pl->pcap_open_err =
true;
458 pl->pcap_open_err =
false;
461 uint64_t bytes_written = LZ4F_compressBegin(comp->lz4f_context,
463 if (LZ4F_isError(bytes_written)) {
464 SCLogError(
"LZ4F_compressBegin: %s", LZ4F_getErrorName(bytes_written));
467 if (fwrite(comp->
buffer, 1, bytes_written, comp->
file) < bytes_written) {
468 SCLogError(
"fwrite failed: %s", strerror(errno));
505 static inline int PcapWrite(
508 struct timeval current_dump;
509 gettimeofday(¤t_dump, NULL);
513 if (pcap_offline_filter(pl->
bpfp, pl->
h, data) == 0) {
514 SCLogDebug(
"Packet doesn't match filter, will not be logged.");
532 SCLogError(
"ftell failed with: %s", strerror(errno));
535 uint64_t out_size = LZ4F_compressUpdate(comp->lz4f_context, comp->
buffer, comp->
buffer_size,
536 comp->
pcap_buf, (uint64_t)in_size, NULL);
537 if (LZ4F_isError(
len)) {
538 SCLogError(
"LZ4F_compressUpdate: %s", LZ4F_getErrorName(
len));
542 SCLogError(
"fseek failed: %s", strerror(errno));
545 if (fwrite(comp->
buffer, 1, out_size, comp->
file) < out_size) {
546 SCLogError(
"fwrite failed: %s", strerror(errno));
560 pl->last_pcap_dump = current_dump;
569 static int PcapLogSegmentCallback(
570 const Packet *p,
TcpSegment *seg,
void *data,
const uint8_t *buf, uint32_t buflen)
581 MemBufferReset(pctx->
td->
buf);
641 ret = PcapLogOpenFileCtx(pl);
652 if (PcapLogRotateFile(
tv, pl) < 0) {
668 if (PcapLogRotateFile(
tv, pl) < 0) {
691 if (PacketIsTCP(p)) {
693 PcapLogDumpSegments(
tv,
td, p);
731 SCLogDebug(
"pl->size_current %"PRIu64
", pl->size_limit %"PRIu64,
752 copy->prefix =
SCStrdup(pl->prefix);
753 if (
unlikely(copy->prefix == NULL)) {
759 copy->suffix = pl->suffix;
765 copy->use_ringbuffer = pl->use_ringbuffer;
766 copy->timestamp_format = pl->timestamp_format;
781 copy_comp->lz4f_prefs = comp->lz4f_prefs;
786 if (copy_comp->
buffer == NULL) {
787 SCLogError(
"SCMalloc failed: %s", strerror(errno));
794 SCLogError(
"SCMalloc failed: %s", strerror(errno));
803 SCLogError(
"SCFmemopen failed: %s", strerror(errno));
813 LZ4F_errorCode_t errcode =
814 LZ4F_createCompressionContext(©_comp->lz4f_context, 1);
815 if (LZ4F_isError(errcode)) {
816 SCLogError(
"LZ4F_createCompressionContext failed: %s", LZ4F_getErrorName(errcode));
827 copy_comp->
file = NULL;
835 strlcpy(copy->dir, pl->dir,
sizeof(copy->dir));
837 for (
int i = 0; i < pl->filename_part_cnt && i <
MAX_TOKS; i++)
838 copy->filename_parts[i] = pl->filename_parts[i];
839 copy->filename_part_cnt = pl->filename_part_cnt;
848 #ifdef INIT_RING_BUFFER
849 static int PcapLogGetTimeOfFile(
const char *filename, uint64_t *secs,
855 int n = pcre2_match(pcre_timestamp_code, (PCRE2_SPTR8)filename, strlen(filename), 0, 0,
856 pcre_timestamp_match, NULL);
857 if (n != 2 && n != 4) {
864 copylen =
sizeof(buf);
865 if (pcre2_substring_copy_bynumber(pcre_timestamp_match, 1, (PCRE2_UCHAR8 *)buf, ©len) <
875 copylen =
sizeof(buf);
876 if (pcre2_substring_copy_bynumber(pcre_timestamp_match, 3, (PCRE2_UCHAR8 *)buf, ©len) <
890 char pattern[PATH_MAX];
892 SCLogInfo(
"Initializing PCAP ring buffer for %s/%s.",
893 pl->dir, pl->prefix);
895 strlcpy(pattern, pl->dir, PATH_MAX);
896 if (pattern[strlen(pattern) - 1] !=
'/') {
897 strlcat(pattern,
"/", PATH_MAX);
900 for (
int i = 0; i < pl->filename_part_cnt; i++) {
901 char *part = pl->filename_parts[i];
902 if (part == NULL || strlen(part) == 0) {
905 if (part[0] !=
'%' || strlen(part) < 2) {
906 strlcat(pattern, part, PATH_MAX);
911 SCLogError(
"Thread ID not allowed in ring buffer mode.");
915 snprintf(tmp, PATH_MAX,
"%"PRIu32, pl->thread_number);
916 strlcat(pattern, tmp, PATH_MAX);
920 strlcat(pattern,
"*", PATH_MAX);
923 SCLogError(
"Unsupported format character: %%%s", part);
928 strlcat(pattern, pl->prefix, PATH_MAX);
929 strlcat(pattern,
".*", PATH_MAX);
931 strlcat(pattern, pl->suffix, PATH_MAX);
933 char *basename = strrchr(pattern,
'/');
937 DIR *dir = opendir(pattern);
939 SCLogWarning(
"Failed to open directory %s: %s", pattern, strerror(errno));
944 struct dirent *entry = readdir(dir);
948 if (fnmatch(basename, entry->d_name, 0) != 0) {
955 if (!PcapLogGetTimeOfFile(entry->d_name, &secs, &usecs)) {
966 if (snprintf(path, PATH_MAX,
"%s/%s", pattern, entry->d_name) == PATH_MAX)
1021 PcapFileNameFree(pf);
1037 static TmEcode PcapLogDataInit(
ThreadVars *t,
const void *initdata,
void **data)
1039 if (initdata == NULL) {
1040 SCLogDebug(
"Error getting context for LogPcap. \"initdata\" argument NULL");
1054 td->
pcap_log = PcapLogDataCopy(pl);
1061 FatalError(
"Pcap logging with multiple link type is not supported.");
1072 FatalError(
"Can't have multiple link types in pcap conditional mode.");
1075 SCLogWarning(
"Using multiple link types can result in invalid pcap output");
1111 #ifdef INIT_RING_BUFFER
1116 SCLogInfo(
"Unable to initialize ring buffer on this platform.");
1127 PcapLogOpenFileCtx(pl);
1137 dst->profile_open.total +=
src->profile_open.total;
1138 dst->profile_open.cnt +=
src->profile_open.cnt;
1140 dst->profile_close.total +=
src->profile_close.total;
1141 dst->profile_close.cnt +=
src->profile_close.cnt;
1143 dst->profile_write.total +=
src->profile_write.total;
1144 dst->profile_write.cnt +=
src->profile_write.cnt;
1146 dst->profile_rotate.total +=
src->profile_rotate.total;
1147 dst->profile_rotate.cnt +=
src->profile_rotate.cnt;
1149 dst->profile_handles.total +=
src->profile_handles.total;
1150 dst->profile_handles.cnt +=
src->profile_handles.cnt;
1152 dst->profile_lock.total +=
src->profile_lock.total;
1153 dst->profile_lock.cnt +=
src->profile_lock.cnt;
1155 dst->profile_unlock.total +=
src->profile_unlock.total;
1156 dst->profile_unlock.cnt +=
src->profile_unlock.cnt;
1158 dst->profile_data_size +=
src->profile_data_size;
1165 while ((pf =
TAILQ_FIRST(&pl->pcap_file_list)) != NULL) {
1167 PcapFileNameFree(pf);
1169 if (pl == g_pcap_data) {
1170 for (
int i = 0; i <
MAX_TOKS; i++) {
1171 if (pl->filename_parts[i] != NULL) {
1172 SCFree(pl->filename_parts[i]);
1185 pcap_freecode(pl->
bpfp);
1191 SCFree(pl->compression.buffer);
1192 fclose(pl->compression.pcap_buf_wrapper);
1193 SCFree(pl->compression.pcap_buf);
1194 LZ4F_errorCode_t errcode =
1195 LZ4F_freeCompressionContext(pl->compression.lz4f_context);
1196 if (LZ4F_isError(errcode)) {
1218 if (PcapLogCloseFile(t,pl) < 0) {
1225 StatsMerge(g_pcap_data, pl);
1226 g_pcap_data->reported++;
1227 if (g_pcap_data->threads == g_pcap_data->reported)
1228 PcapLogProfilingDump(g_pcap_data);
1231 if (pl->reported == 0) {
1232 PcapLogProfilingDump(pl);
1237 if (pl != g_pcap_data) {
1238 PcapLogDataFree(pl);
1249 static int ParseFilename(
PcapLogData *pl,
const char *filename)
1256 size_t filename_len = 0;
1259 filename_len = strlen(filename);
1265 for (
int i = 0; i < (int)strlen(filename); i++) {
1267 SCLogError(
"invalid filename option. Max 2 %%-sign options");
1271 str[s++] = filename[i];
1273 if (filename[i] ==
'%') {
1284 if (i+1 < (
int)strlen(filename)) {
1286 SCLogError(
"invalid filename option. Max 2 %%-sign options");
1290 if (filename[i+1] !=
'n' && filename[i+1] !=
't' && filename[i+1] !=
'i') {
1292 "invalid filename option. Valid %%-sign options: %%n, %%i and %%t");
1296 str[1] = filename[i+1];
1308 SCLogError(
"Invalid filename for multimode. Need at least one %%-sign option");
1314 SCLogError(
"invalid filename option. Max 3 %%-sign options");
1326 for (
int i = 0; i < tok; i++) {
1327 if (toks[i] == NULL)
1331 pl->filename_parts[i] = toks[i];
1333 pl->filename_part_cnt = tok;
1337 for (
int x = 0; x <
MAX_TOKS; x++) {
1338 if (toks[x] != NULL)
1355 FatalError(
"A pcap-log instance is already active, only one can be enabled.");
1360 FatalError(
"Failed to allocate Memory for PcapLogData");
1364 if (pl->
h == NULL) {
1365 FatalError(
"Failed to allocate Memory for pcap header struct");
1382 pcre_timestamp_code =
1383 pcre2_compile((PCRE2_SPTR8)timestamp_pattern, PCRE2_ZERO_TERMINATED, 0, &en, &eo, NULL);
1384 if (pcre_timestamp_code == NULL) {
1385 PCRE2_UCHAR errbuffer[256];
1386 pcre2_get_error_message(en, errbuffer,
sizeof(errbuffer));
1388 "Failed to compile \"%s\" at offset %d: %s", timestamp_pattern, (
int)eo, errbuffer);
1390 pcre_timestamp_match = pcre2_match_data_create_from_pattern(pcre_timestamp_code, NULL);
1394 const char *filename = NULL;
1400 if (filename == NULL)
1403 if ((pl->prefix =
SCStrdup(filename)) == NULL) {
1411 const char *s_limit = NULL;
1413 if (s_limit != NULL) {
1415 SCLogError(
"Failed to initialize pcap output, invalid limit: %s", s_limit);
1419 SCLogInfo(
"pcap-log \"limit\" value of %"PRIu64
" assumed to be pre-1.2 "
1421 uint64_t size = pl->
size_limit * 1024 * 1024;
1424 FatalError(
"Fail to initialize pcap-log output, limit less than "
1425 "allowed minimum of %d bytes.",
1432 const char *s_mode = NULL;
1434 if (s_mode != NULL) {
1435 if (strcasecmp(s_mode,
"multi") == 0) {
1437 }
else if (strcasecmp(s_mode,
"normal") != 0) {
1438 FatalError(
"log-pcap: invalid mode \"%s\". Valid options: \"normal\""
1439 "or \"multi\" mode ",
1444 const char *s_dir = NULL;
1446 if (s_dir == NULL) {
1447 const char *log_dir = NULL;
1450 strlcpy(pl->dir, log_dir,
sizeof(pl->dir));
1455 s_dir,
sizeof(pl->dir));
1457 const char *log_dir = NULL;
1460 snprintf(pl->dir,
sizeof(pl->dir),
"%s/%s",
1464 struct stat stat_buf;
1465 if (stat(pl->dir, &stat_buf) != 0) {
1467 "supplied doesn't exist. Shutting down the engine",
1476 if (compression_str == NULL || strcmp(compression_str,
"none") == 0) {
1484 }
else if (strcmp(compression_str,
"lz4") == 0) {
1494 SCLogError(
"SCMalloc failed: %s", strerror(errno));
1500 SCLogError(
"SCFmemopen failed: %s", strerror(errno));
1506 memset(&comp->lz4f_prefs,
'\0',
sizeof(comp->lz4f_prefs));
1507 comp->lz4f_prefs.frameInfo.blockSizeID = LZ4F_max4MB;
1508 comp->lz4f_prefs.frameInfo.blockMode = LZ4F_blockLinked;
1510 comp->lz4f_prefs.frameInfo.contentChecksumFlag = 1;
1512 comp->lz4f_prefs.frameInfo.contentChecksumFlag = 0;
1518 }
else if (lvl < 0) {
1524 comp->lz4f_prefs.compressionLevel = (int)lvl;
1528 LZ4F_errorCode_t errcode =
1529 LZ4F_createCompressionContext(&pl->compression.lz4f_context, 1);
1531 if (LZ4F_isError(errcode)) {
1532 SCLogError(
"LZ4F_createCompressionContext failed: %s", LZ4F_getErrorName(errcode));
1544 "lz4 output buffer.");
1551 pl->suffix =
".lz4";
1554 "in pcap-log, but suricata was not compiled with lz4 "
1556 PcapLogDataFree(pl);
1562 "compression format: %s",
1564 PcapLogDataFree(pl);
1568 SCLogInfo(
"Selected pcap-log compression method: %s",
1569 compression_str ? compression_str :
"none");
1572 if (s_conditional != NULL) {
1573 if (strcasecmp(s_conditional,
"alerts") == 0) {
1576 }
else if (strcasecmp(s_conditional,
"tag") == 0) {
1579 }
else if (strcasecmp(s_conditional,
"all") != 0) {
1580 FatalError(
"log-pcap: invalid conditional \"%s\". Valid options: \"all\", "
1581 "\"alerts\", or \"tag\" mode ",
1587 "Selected pcap-log conditional logging: %s", s_conditional ? s_conditional :
"all");
1590 if (ParseFilename(pl, filename) != 0)
1597 const char *max_number_of_files_s = NULL;
1599 if (max_number_of_files_s != NULL) {
1601 max_number_of_files_s) == -1) {
1603 "pcap-log output, invalid number of files limit: %s",
1604 max_number_of_files_s);
1606 }
else if (max_file_limit < 1) {
1607 FatalError(
"Failed to initialize pcap-log output, limit less than "
1608 "allowed minimum.");
1616 const char *ts_format = NULL;
1620 if (ts_format != NULL) {
1621 if (strcasecmp(ts_format,
"usec") == 0) {
1623 }
else if (strcasecmp(ts_format,
"sec") != 0) {
1624 SCLogError(
"log-pcap ts_format specified %s is invalid must be"
1625 " \"sec\" or \"usec\"",
1631 const char *use_stream_depth = NULL;
1635 if (use_stream_depth != NULL) {
1641 FatalError(
"log-pcap use_stream_depth specified is invalid must be");
1645 const char *honor_pass_rules = NULL;
1649 if (honor_pass_rules != NULL) {
1655 FatalError(
"log-pcap honor-pass-rules specified is invalid");
1664 if (
unlikely(output_ctx == NULL)) {
1665 FatalError(
"Failed to allocate memory for OutputCtx.");
1667 output_ctx->
data = pl;
1668 output_ctx->
DeInit = PcapLogFileDeInitCtx;
1671 result.
ctx = output_ctx;
1676 static void PcapLogFileDeInitCtx(
OutputCtx *output_ctx)
1678 if (output_ctx == NULL)
1687 PcapLogDataFree(pl);
1690 pcre2_code_free(pcre_timestamp_code);
1691 pcre2_match_data_free(pcre_timestamp_match);
1704 char *filename = NULL;
1731 ret = snprintf(filename, PATH_MAX,
"%s/%s.%" PRIu32
"%s", pl->dir, pl->prefix,
1734 ret = snprintf(filename, PATH_MAX,
"%s/%s.%" PRIu32
".%" PRIu32
"%s", pl->dir,
1737 if (ret < 0 || (
size_t)ret >= PATH_MAX) {
1742 if (pl->filename_part_cnt > 0) {
1745 strlcpy(filename, pl->dir, PATH_MAX);
1746 strlcat(filename,
"/", PATH_MAX);
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(filename, pl->filename_parts[i], PATH_MAX);
1784 strlcat(filename, pl->suffix, PATH_MAX);
1789 ret = snprintf(filename, PATH_MAX,
"%s/%s.%u.%" PRIu32
"%s", pl->dir, pl->prefix,
1792 ret = snprintf(filename, PATH_MAX,
"%s/%s.%u.%" PRIu32
".%" PRIu32
"%s", pl->dir,
1796 if (ret < 0 || (
size_t)ret >= PATH_MAX) {
1801 SCLogDebug(
"multi-mode: filename %s", filename);
1805 SCLogError(
"Error allocating memory. For filename");
1818 PcapFileNameFree(pf);
1831 static int profiling_pcaplog_enabled = 0;
1832 static int profiling_pcaplog_output_to_file = 0;
1833 static char *profiling_pcaplog_file_name = NULL;
1834 static const char *profiling_pcaplog_file_mode =
"a";
1836 static void FormatNumber(uint64_t num,
char *
str,
size_t size)
1839 snprintf(
str, size,
"%"PRIu64, num);
1840 else if (num < 1000000UL)
1841 snprintf(
str, size,
"%3.1fk", (
float)num/1000UL);
1842 else if (num < 1000000000UL)
1843 snprintf(
str, size,
"%3.1fm", (
float)num/1000000UL);
1845 snprintf(
str, size,
"%3.1fb", (
float)num/1000000000UL);
1850 char ticks_str[32] =
"n/a";
1851 char cnt_str[32] =
"n/a";
1852 char avg_str[32] =
"n/a";
1854 FormatNumber((uint64_t)p->
cnt, cnt_str,
sizeof(cnt_str));
1855 FormatNumber((uint64_t)p->
total, ticks_str,
sizeof(ticks_str));
1857 FormatNumber((uint64_t)(p->
total/p->
cnt), avg_str,
sizeof(avg_str));
1859 fprintf(fp,
"%-28s %-10s %-10s %-10s\n",
name, cnt_str, avg_str, ticks_str);
1862 static void ProfileReport(FILE *fp,
PcapLogData *pl)
1867 ProfileReportPair(fp,
"rotate (incl open/close)", &pl->
profile_rotate);
1873 static void FormatBytes(uint64_t num,
char *
str,
size_t size)
1876 snprintf(
str, size,
"%"PRIu64, num);
1877 else if (num < 1048576UL)
1878 snprintf(
str, size,
"%3.1fKiB", (
float)num/1000UL);
1879 else if (num < 1073741824UL)
1880 snprintf(
str, size,
"%3.1fMiB", (
float)num/1000000UL);
1882 snprintf(
str, size,
"%3.1fGiB", (
float)num/1000000000UL);
1889 if (profiling_pcaplog_enabled == 0)
1892 if (profiling_pcaplog_output_to_file == 1) {
1893 fp = fopen(profiling_pcaplog_file_name, profiling_pcaplog_file_mode);
1895 SCLogError(
"failed to open %s: %s", profiling_pcaplog_file_name, strerror(errno));
1903 fprintf(fp,
"\n\nOperation Cnt Avg ticks Total ticks\n");
1904 fprintf(fp,
"---------------------------- ---------- ---------- -----------\n");
1906 ProfileReport(fp, pl);
1913 fprintf(fp,
"\nOverall: %"PRIu64
" bytes written, average %d bytes per write.\n",
1916 fprintf(fp,
" PCAP data structure overhead: %"PRIuMAX
" per write.\n",
1917 (uintmax_t)
sizeof(
struct pcap_pkthdr));
1922 fprintf(fp,
" Size written: %s\n", bytes_str);
1925 uint64_t ticks_per_mib = 0, ticks_per_gib = 0;
1928 ticks_per_mib = total/mib;
1929 char ticks_per_mib_str[32] =
"n/a";
1930 if (ticks_per_mib > 0)
1931 FormatNumber(ticks_per_mib, ticks_per_mib_str,
sizeof(ticks_per_mib_str));
1932 fprintf(fp,
" Ticks per MiB: %s\n", ticks_per_mib_str);
1936 ticks_per_gib = total/gib;
1937 char ticks_per_gib_str[32] =
"n/a";
1938 if (ticks_per_gib > 0)
1939 FormatNumber(ticks_per_gib, ticks_per_gib_str,
sizeof(ticks_per_gib_str));
1940 fprintf(fp,
" Ticks per GiB: %s\n", ticks_per_gib_str);
1950 profiling_pcaplog_enabled = 1;
1951 SCLogInfo(
"pcap-log profiling enabled");
1954 if (filename != NULL) {
1955 const char *log_dir;
1958 profiling_pcaplog_file_name =
SCMalloc(PATH_MAX);
1959 if (
unlikely(profiling_pcaplog_file_name == NULL)) {
1963 snprintf(profiling_pcaplog_file_name, PATH_MAX,
"%s/%s", log_dir, filename);
1967 profiling_pcaplog_file_mode =
"a";
1969 profiling_pcaplog_file_mode =
"w";
1972 profiling_pcaplog_output_to_file = 1;
1973 SCLogInfo(
"pcap-log profiling output goes to %s (mode %s)",
1974 profiling_pcaplog_file_name, profiling_pcaplog_file_mode);