aboutsummaryrefslogtreecommitdiff
path: root/src/lib/ndpi_main.c
diff options
context:
space:
mode:
authorLuca Deri <lucaderi@users.noreply.github.com>2019-01-20 23:18:46 +0100
committerGitHub <noreply@github.com>2019-01-20 23:18:46 +0100
commitb9ae65014634237691aeef5ddc6bafb13fb26144 (patch)
tree82e5cab667bc43e3067f49403526d8fa1420f47b /src/lib/ndpi_main.c
parent72edc508ebaded90d5ef463b070eca661feaa10d (diff)
parent2c672a4ea2a79fc1dad555c55a59b807fdfdd65b (diff)
Merge pull request #659 from cavedon/direction-endianness
Compute packet_direction consistently independently from endianness
Diffstat (limited to 'src/lib/ndpi_main.c')
-rw-r--r--src/lib/ndpi_main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 8ea0de499..fcf86449a 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -3693,7 +3693,7 @@ void ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_struct,
if(ndpi_struct->direction_detect_disable) {
packet->packet_direction = flow->packet_direction;
} else {
- if(iph != NULL && iph->saddr < iph->daddr)
+ if(iph != NULL && le32toh(iph->saddr) < le32toh(iph->daddr))
packet->packet_direction = 1;
#ifdef NDPI_DETECTION_SUPPORT_IPV6
@@ -3717,7 +3717,7 @@ void ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_struct,
packet->num_retried_bytes = 0;
if(!ndpi_struct->direction_detect_disable)
- packet->packet_direction = (tcph->source < tcph->dest) ? 1 : 0;
+ packet->packet_direction = (le16toh(tcph->source) < le16toh(tcph->dest)) ? 1 : 0;
if(tcph->syn != 0 && tcph->ack == 0 && flow->l4.tcp.seen_syn == 0 && flow->l4.tcp.seen_syn_ack == 0
&& flow->l4.tcp.seen_ack == 0) {
@@ -3781,7 +3781,7 @@ void ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_struct,
}
} else if(udph != NULL) {
if(!ndpi_struct->direction_detect_disable)
- packet->packet_direction = (udph->source < udph->dest) ? 1 : 0;
+ packet->packet_direction = (le16toh(udph->source) < le16toh(udph->dest)) ? 1 : 0;
}
if(flow->packet_counter < MAX_PACKET_COUNTER && packet->payload_packet_len) {