Fix bug in sorting when guessing flow direction. Issue #92
This commit is contained in:
parent
0082088cf2
commit
19a7b2d7e2
@ -1,3 +1,6 @@
|
|||||||
|
2018-04-20
|
||||||
|
- Fix bug in sorting when guessing flow direction. Issue #92
|
||||||
|
|
||||||
2018-04-01
|
2018-04-01
|
||||||
- Add program exit in nfx.c after panic with correupt data file
|
- Add program exit in nfx.c after panic with correupt data file
|
||||||
- Add missing size check when reading nfdump 1.5.x common record blocks
|
- Add missing size check when reading nfdump 1.5.x common record blocks
|
||||||
|
18
bin/nfstat.c
18
bin/nfstat.c
@ -442,6 +442,7 @@ struct order_mode_s {
|
|||||||
#define Default_PrintOrder 1 // order_mode[0].val
|
#define Default_PrintOrder 1 // order_mode[0].val
|
||||||
static uint32_t print_order_bits = 0;
|
static uint32_t print_order_bits = 0;
|
||||||
static uint32_t PrintOrder = 0;
|
static uint32_t PrintOrder = 0;
|
||||||
|
static uint32_t GuessDirection = 0;
|
||||||
static uint32_t NumStats = 0;
|
static uint32_t NumStats = 0;
|
||||||
|
|
||||||
static uint64_t byte_limit, packet_limit;
|
static uint64_t byte_limit, packet_limit;
|
||||||
@ -493,6 +494,12 @@ static uint64_t flows_record(FlowTableRecord_t *record, int inout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t packets_record(FlowTableRecord_t *record, int inout) {
|
static uint64_t packets_record(FlowTableRecord_t *record, int inout) {
|
||||||
|
if ( GuessDirection && (record->flowrecord.srcport < record->flowrecord.dstport) ) {
|
||||||
|
if (inout == IN)
|
||||||
|
inout = OUT;
|
||||||
|
else if (inout == OUT)
|
||||||
|
inout = IN;
|
||||||
|
}
|
||||||
if (inout == IN)
|
if (inout == IN)
|
||||||
return record->counter[INPACKETS];
|
return record->counter[INPACKETS];
|
||||||
else if (inout == OUT)
|
else if (inout == OUT)
|
||||||
@ -502,6 +509,12 @@ static uint64_t packets_record(FlowTableRecord_t *record, int inout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t bytes_record(FlowTableRecord_t *record, int inout) {
|
static uint64_t bytes_record(FlowTableRecord_t *record, int inout) {
|
||||||
|
if ( GuessDirection && (record->flowrecord.srcport < record->flowrecord.dstport) ) {
|
||||||
|
if (inout == IN)
|
||||||
|
inout = OUT;
|
||||||
|
else if (inout == OUT)
|
||||||
|
inout = IN;
|
||||||
|
}
|
||||||
if (inout == IN)
|
if (inout == IN)
|
||||||
return record->counter[INBYTES];
|
return record->counter[INBYTES];
|
||||||
else if (inout == OUT)
|
else if (inout == OUT)
|
||||||
@ -1435,6 +1448,7 @@ struct tm *tbuff;
|
|||||||
|
|
||||||
} // End of PrintCvsStatLine
|
} // End of PrintCvsStatLine
|
||||||
|
|
||||||
|
|
||||||
void PrintFlowTable(printer_t print_record, uint32_t topN, int tag, int GuessDir, extension_map_list_t *extension_map_list) {
|
void PrintFlowTable(printer_t print_record, uint32_t topN, int tag, int GuessDir, extension_map_list_t *extension_map_list) {
|
||||||
hash_FlowTable *FlowTable;
|
hash_FlowTable *FlowTable;
|
||||||
FlowTableRecord_t *r;
|
FlowTableRecord_t *r;
|
||||||
@ -1445,12 +1459,13 @@ uint32_t i;
|
|||||||
uint32_t maxindex, c;
|
uint32_t maxindex, c;
|
||||||
char *string;
|
char *string;
|
||||||
|
|
||||||
|
GuessDirection = GuessDir;
|
||||||
FlowTable = GetFlowTable();
|
FlowTable = GetFlowTable();
|
||||||
aggr_record_mask = GetMasterAggregateMask();
|
aggr_record_mask = GetMasterAggregateMask();
|
||||||
c = 0;
|
c = 0;
|
||||||
maxindex = FlowTable->NumRecords;
|
maxindex = FlowTable->NumRecords;
|
||||||
if ( PrintOrder ) {
|
if ( PrintOrder ) {
|
||||||
// Sort according the date
|
// Sort according the requested order
|
||||||
SortList = (SortElement_t *)calloc(maxindex, sizeof(SortElement_t));
|
SortList = (SortElement_t *)calloc(maxindex, sizeof(SortElement_t));
|
||||||
|
|
||||||
if ( !SortList ) {
|
if ( !SortList ) {
|
||||||
@ -1915,3 +1930,4 @@ uint32_t _tmp;
|
|||||||
flow_record->out_bytes = _tmp_l;
|
flow_record->out_bytes = _tmp_l;
|
||||||
|
|
||||||
} // End of SwapFlow
|
} // End of SwapFlow
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user