flow: track bytes per direction

Track bytes in both flow directions for logging purposes.
pull/1058/head
Victor Julien 11 years ago
parent f828793f8f
commit c66a29b67d

@ -221,7 +221,7 @@ static TmEcode AlertDebugLogger(ThreadVars *tv, const Packet *p, void *thread_da
"FLOW PKTS TOSRC: %"PRIu32"\n"
"FLOW Total Bytes: %"PRIu64"\n",
p->flow->todstpktcnt, p->flow->tosrcpktcnt,
p->flow->bytecnt);
p->flow->todstbytecnt + p->flow->tosrcbytecnt);
#endif
MemBufferWriteString(aft->buffer,
"FLOW IPONLY SET: TOSERVER: %s, TOCLIENT: %s\n"

@ -33,7 +33,8 @@
#define RESET_COUNTERS(f) do { \
(f)->todstpktcnt = 0; \
(f)->tosrcpktcnt = 0; \
(f)->bytecnt = 0; \
(f)->todstbytecnt = 0; \
(f)->tosrcbytecnt = 0; \
} while (0)
#else
#define RESET_COUNTERS(f)

@ -256,6 +256,7 @@ void FlowHandlePacket(ThreadVars *tv, Packet *p)
}
#ifdef DEBUG
f->todstpktcnt++;
f->todstbytecnt += GET_PKT_LEN(p);
#endif
p->flowflags |= FLOW_PKT_TOSERVER;
} else {
@ -264,11 +265,11 @@ void FlowHandlePacket(ThreadVars *tv, Packet *p)
}
#ifdef DEBUG
f->tosrcpktcnt++;
f->tosrcbytecnt += GET_PKT_LEN(p);
#endif
p->flowflags |= FLOW_PKT_TOCLIENT;
}
#ifdef DEBUG
f->bytecnt += GET_PKT_LEN(p);
#endif
if ((f->flags & FLOW_TO_DST_SEEN) && (f->flags & FLOW_TO_SRC_SEEN)) {

@ -380,7 +380,8 @@ typedef struct Flow_
#ifdef DEBUG
uint32_t todstpktcnt;
uint32_t tosrcpktcnt;
uint64_t bytecnt;
uint64_t todstbytecnt;
uint64_t tosrcbytecnt;
#endif
} Flow;

@ -193,8 +193,10 @@ static void JsonFlowLogJSON(JsonFlowLogThread *aft, json_t *js, Flow *f)
json_integer(f->todstpktcnt));
json_object_set_new(hjs, "pkts_toclient",
json_integer(f->tosrcpktcnt));
json_object_set_new(hjs, "bytes",
json_integer(f->bytecnt));
json_object_set_new(hjs, "bytes_toserver",
json_integer(f->todstbytecnt));
json_object_set_new(hjs, "bytes_toclient",
json_integer(f->tosrcbytecnt));
#endif

Loading…
Cancel
Save