77 SCLogError(
"Failed to allocate OutputTx list");
128 if (t->
id * 2ULL > UINT32_MAX) {
164 const uint64_t tx_id,
AppLayerTxData *txd,
const bool tx_complete,
const bool ts_ready,
165 const bool tc_ready,
const bool ts_eof,
const bool tc_eof,
const bool eof)
168 uint8_t opposing_dir;
169 bool packet_dir_ready;
170 const bool opposing_dir_ready = eof;
171 bool opposing_tx_ready;
173 packet_dir = STREAM_TOSERVER;
174 opposing_dir = STREAM_TOCLIENT;
175 packet_dir_ready = eof | ts_ready | ts_eof;
176 opposing_tx_ready = tc_ready;
178 packet_dir = STREAM_TOCLIENT;
179 opposing_dir = STREAM_TOSERVER;
180 packet_dir_ready = eof | tc_ready | tc_eof;
181 opposing_tx_ready = ts_ready;
187 SCLogDebug(
"eof %d ts_ready %d ts_eof %d", eof, ts_ready, ts_eof);
188 SCLogDebug(
"eof %d tc_ready %d tc_eof %d", eof, tc_ready, tc_eof);
190 SCLogDebug(
"packet dir %s opposing %s packet_dir_ready %d opposing_dir_ready %d",
191 packet_dir == STREAM_TOSERVER ?
"TOSERVER" :
"TOCLIENT",
192 opposing_dir == STREAM_TOSERVER ?
"TOSERVER" :
"TOCLIENT", packet_dir_ready,
202 bool opposing_finished =
203 ffc_opposing == NULL || (ffc_opposing->
head == NULL && opposing_tx_ready);
204 SCLogDebug(
"opposing_finished %d ffc_opposing %p ffc_opposing->head %p opposing_tx_ready %d",
205 opposing_finished, ffc_opposing, ffc_opposing ? ffc_opposing->
head : NULL,
208 if (ffc || ffc_opposing)
209 SCLogDebug(
"pcap_cnt %" PRIu64
" flow %p tx %p tx_id %" PRIu64
210 " ffc %p ffc_opposing %p tx_complete %d",
216 SCLogDebug(
"tx: calling files: ffc %p head %p file_close %d file_trunc %d", ffc, ffc->
head,
217 file_close, file_trunc);
220 file_close, file_trunc, packet_dir);
223 tv, file_td,
p, ffc, tx, tx_id, txd, file_close, file_trunc, packet_dir);
226 if (opposing_dir_ready && ffc_opposing != NULL) {
229 opposing_finished =
true;
230 SCLogDebug(
"tx: calling for opposing direction files: file_close:%s file_trunc:%s",
231 file_close ?
"true" :
"false", file_trunc ?
"true" :
"false");
234 opposing_dir, file_close, file_trunc, opposing_dir);
240 const bool tx_done = packet_dir_ready && opposing_finished;
241 SCLogDebug(
"tx_done %d packet_dir_ready %d opposing_finished %d", tx_done, packet_dir_ready,
245 const bool is_file_tx = (ffc != NULL || ffc_opposing != NULL);
246 if (!is_file_tx || tx_done) {
247 SCLogDebug(
"is_file_tx %d tx_done %d", is_file_tx, tx_done);
257 SCLogDebug(
"pcap_cnt %" PRIu64
" flow %p tx %p tx_id %" PRIu64
258 " NOT SETTING FILE FLAGS ffc %p ffc_opposing %p tx_complete %d",
264 Flow *f,
void *tx,
const uint64_t tx_id)
273 while (logger && store) {
284 logger = logger->
next;
300 const bool eof,
const int tx_progress_ts,
const int tx_progress_tc,
struct Ctx *
ctx)
306 while (logger && store) {
310 SCLogDebug(
"logger %p, Alproto %d LogCondition %p, ts_log_progress %d "
311 "tc_log_progress %d",
317 SCLogDebug(
"pcap_cnt %" PRIu64
", tx_id %" PRIu64
" logger %d. EOF %s",
321 SCLogDebug(
"logger:%s flow:%s: skip logger for wrong sub state: logger %u tx %u",
332 SCLogDebug(
"conditions not met, not logging");
336 if (tx_progress_tc < logger->tc_log_progress) {
337 SCLogDebug(
"progress not far enough, not logging");
341 if (tx_progress_ts < logger->ts_log_progress) {
342 SCLogDebug(
"progress not far enough, not logging");
357 logger = logger->
next;
373 SCLogDebug(
"not pseudo, no app update: skip");
379 SCLogDebug(
"pseudo, or app update: run output");
384 const uint8_t ipproto = f->
proto;
389 const bool file_logging_active = (op_thread_data->
file || op_thread_data->
filedata);
390 if (!file_logging_active) {
400 if (alstate == NULL) {
405 if (logger_expectation == 0) {
406 SCLogDebug(
"bail: logger_expectation %u. LOGGER_FILE %u LOGGER_FILEDATA %u",
416 const bool eof = last_pseudo || (ts_eof && tc_eof);
417 SCLogDebug(
"eof %d last_pseudo %d ts_eof %d tc_eof %d", eof, last_pseudo, ts_eof, tc_eof);
421 SCLogDebug(
"ts_disrupt_flags %02x tc_disrupt_flags %02x", ts_disrupt_flags, tc_disrupt_flags);
424 uint64_t max_id = tx_id;
435 memset(&state, 0,
sizeof(state));
437 const int default_complete_ts =
439 const int default_complete_tc =
445 void *
const tx = ires.
tx_ptr;
447 SCLogDebug(
"STARTING tx_id %" PRIu64
", tx %p", tx_id, tx);
450 int complete_ts, complete_tc;
452 complete_ts = default_complete_ts;
453 complete_tc = default_complete_tc;
459 const int tx_progress_ts =
461 const int tx_progress_tc =
463 const bool tx_complete = (tx_progress_ts == complete_ts && tx_progress_tc == complete_tc);
465 SCLogDebug(
"file_thread_data %p filedata_thread_data %p", op_thread_data->
file,
468 if (file_logging_active) {
471 const bool ts_ready = (tx_progress_ts == complete_ts);
472 const bool tc_ready = (tx_progress_tc == complete_tc);
473 SCLogDebug(
"ts_ready %d tc_ready %d", ts_ready, tc_ready);
475 const bool eval_files = ts_ready | tc_ready | tx_complete | ts_eof | tc_eof | eof;
477 SCLogDebug(
"eval_files: %u, ts_ready %u, tc_ready %u, tx_complete %u, ts_eof %u, "
479 eval_files, ts_ready, tc_ready, tx_complete, ts_eof, tc_eof, eof);
486 if (eval_files || ((txd->
file_tx & pkt_dir) != 0)) {
487 OutputTxLogFiles(
tv, op_thread_data->
file, op_thread_data->
filedata,
p, f, tx,
488 tx_id, txd, tx_complete, ts_ready, tc_ready, ts_eof, tc_eof, eof);
490 }
else if (support_files) {
491 if (op_thread_data->
file) {
501 SCLogDebug(
"logger: expect %08x, have %08x", logger_expectation, txd->
logged);
503 !(tx_progress_tc == complete_tc) && !ts_eof && !tc_eof) {
509 OutputTxLogList0(
tv, op_thread_data,
p, f, tx, tx_id);
510 if (list[alproto] == NULL)
514 SCLogDebug(
"tx %p/%" PRIu64
" txd %p: log_flags %x logger_expectation %x", tx, tx_id, txd,
519 txd->
logged |= logger_expectation;
523 if (txd->
logged == logger_expectation) {
529 SCLogDebug(
"logger: expect %08x, have %08x", logger_expectation, txd->
logged);
533 SCLogDebug(
"logger: expect %08x, have %08x", logger_expectation,
ctx.tx_logged);
535 OutputTxLogCallLoggers(
tv, op_thread_data, logger, store,
p, f, alstate, tx, tx_id, txd,
536 alproto, eof, tx_progress_ts, tx_progress_tc, &
ctx);
538 SCLogDebug(
"logger: expect %08x, have %08x", logger_expectation,
ctx.tx_logged);
539 if (
ctx.tx_logged !=
ctx.tx_logged_old) {
540 SCLogDebug(
"logger: storing %08x (was %08x)",
ctx.tx_logged,
ctx.tx_logged_old);
551 if (!gap &&
ctx.tx_logged == logger_expectation) {
552 SCLogDebug(
"no gap %d, %08x == %08x", gap,
ctx.tx_logged, logger_expectation);
568 SCLogDebug(
"updating log tx_id %"PRIu64, max_id);
587 SCLogDebug(
"OutputTxLogThreadInit happy (*data %p)", *data);
599 ts->thread_data = retptr;
601 if (td->
store[alproto] == NULL) {
605 while (tmp->
next != NULL)
614 logger = logger->
next;
620 FatalError(
"failed to set up file thread data");
625 FatalError(
"failed to set up filedata thread data");
642 while (logger && store) {
650 logger = logger->
next;
654 if (op_thread_data->
file) {
665 static uint32_t OutputTxLoggerGetActiveCount(
void)
698 FatalError(
"Failed to allocate OutputTx list");
701 OutputTxLoggerGetActiveCount);
715 logger = next_logger;
717 list[alproto] = NULL;