Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 30 additions & 14 deletions common/argus_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -13919,6 +13919,8 @@ ArgusPrintDirection (struct ArgusParserStruct *parser, char *buf, struct ArgusRe
struct ArgusMetricStruct *metric = (struct ArgusMetricStruct *)argus->dsrs[ARGUS_METRIC_INDEX];
struct ArgusFlow *flow = (struct ArgusFlow *)argus->dsrs[ARGUS_FLOW_INDEX];
struct ArgusNetworkStruct *net = (struct ArgusNetworkStruct *)argus->dsrs[ARGUS_NETWORK_INDEX];
struct ArgusNetspatialStruct *local = (struct ArgusNetspatialStruct *) argus->dsrs[ARGUS_LOCAL_INDEX];

int type, src_count = 0, dst_count = 0;

if (metric == NULL) {
Expand All @@ -13929,13 +13931,15 @@ ArgusPrintDirection (struct ArgusParserStruct *parser, char *buf, struct ArgusRe

} else {
if (strcmp("%d", format) == 0) {
int dirInt = 0;
if ((dst_count = metric->dst.pkts) == 0)
dirInt = 1;
if ((src_count = metric->src.pkts) == 0)
dirInt = -1;
if ((src_count == 0) && (dst_count == 0))
dirInt = 0;
int dFactor = 1;
int dValue = 1;

if (local != NULL) {
if (local->sloc >= local->dloc)
dFactor = 1;
if (local->sloc < local->dloc)
dFactor = -1;
}

if (flow != NULL) {
switch (flow->hdr.subtype & 0x3F) {
Expand All @@ -13947,13 +13951,13 @@ ArgusPrintDirection (struct ArgusParserStruct *parser, char *buf, struct ArgusRe
if (net != NULL) {
struct ArgusTCPObject *tcp = (struct ArgusTCPObject *)&net->net_union.tcp;
if (!((tcp->status & ARGUS_SAW_SYN) || (tcp->status & ARGUS_SAW_SYN_SENT))) {
dirInt = 0;
dFactor = 0;
}
if ((tcp->status & ARGUS_SAW_SYN) || (tcp->status & ARGUS_SAW_SYN_SENT)) {
if (flow->hdr.subtype & ARGUS_REVERSE) {
dirInt = -1;
dFactor = -1;
} else {
dirInt = 1;
dFactor = 1;
}
}
}
Expand All @@ -13968,13 +13972,13 @@ ArgusPrintDirection (struct ArgusParserStruct *parser, char *buf, struct ArgusRe
if (net != NULL) {
struct ArgusTCPObject *tcp = (struct ArgusTCPObject *)&net->net_union.tcp;
if (!((tcp->status & ARGUS_SAW_SYN) || (tcp->status & ARGUS_SAW_SYN_SENT))) {
dirInt = 0;
dFactor = 0;
} else {
if ((tcp->status & ARGUS_SAW_SYN) || (tcp->status & ARGUS_SAW_SYN_SENT)) {
if (flow->hdr.subtype & ARGUS_REVERSE) {
dirInt = -1;
dFactor = -1;
} else {
dirInt = 1;
dFactor = 1;
}
}
}
Expand All @@ -13988,8 +13992,20 @@ ArgusPrintDirection (struct ArgusParserStruct *parser, char *buf, struct ArgusRe
}
}
}
/*
2 is for both directions
3 payloads in both directions
*/
if (((dst_count = metric->dst.pkts) > 0) &&
((src_count = metric->src.pkts) > 0)) {
dValue = 2;
if ((ArgusFetchSrcAppByteCount(argus) > 0) &&
(ArgusFetchDstAppByteCount(argus) > 0)) {
dValue = 3;
}
}

sprintf (buf, "%*d ", len, dirInt);
sprintf (buf, "%*d ", len, (dFactor * dValue));

} else {
char dirStr[16];
Expand Down
Loading