aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDenis Volpato Martins <denisvm@gmail.com>2016-12-06 18:48:26 -0200
committerDenis Volpato Martins <denisvm@gmail.com>2016-12-06 18:48:26 -0200
commit483eb6340809a686b855f8ca1e35c18e2c314b6e (patch)
treeb8a69ea0870b78c409f2e9207783798d802c6e3e /src
parentb019dcd11a0c62bd9eb3f28d37ecc68e99e8c294 (diff)
Removed some magic numbers
Diffstat (limited to 'src')
-rw-r--r--src/lib/ndpi_main.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index ce9a8ce66..0e1e05bed 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -2786,7 +2786,7 @@ static u_int8_t ndpi_detection_get_l4_internal(struct ndpi_detection_module_stru
iph = (const struct ndpi_iphdr *) l3;
- if(iph->version == 4 && iph->ihl >= 5) {
+ if(iph->version == IPVERSION && iph->ihl >= 5) {
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG, "ipv4 header\n");
}
#ifdef NDPI_DETECTION_SUPPORT_IPV6
@@ -2902,7 +2902,7 @@ static int ndpi_init_packet_header(struct ndpi_detection_module_struct *ndpi_str
}
#endif /* NDPI_DETECTION_SUPPORT_IPV6 */
- if(decaps_iph && decaps_iph->version == 4 && decaps_iph->ihl >= 5) {
+ if(decaps_iph && decaps_iph->version == IPVERSION && decaps_iph->ihl >= 5) {
NDPI_LOG(NDPI_PROTOCOL_UNKNOWN, ndpi_struct, NDPI_LOG_DEBUG, "ipv4 header\n");
}
#ifdef NDPI_DETECTION_SUPPORT_IPV6
@@ -2941,7 +2941,7 @@ static int ndpi_init_packet_header(struct ndpi_detection_module_struct *ndpi_str
flow->packet.l4_packet_len = l4len;
/* tcp / udp detection */
- if(l4protocol == 6 /* TCP */ &&flow->packet.l4_packet_len >= 20 /* min size of tcp */ ) {
+ if(l4protocol == IPPROTO_TCP && flow->packet.l4_packet_len >= 20 /* min size of tcp */ ) {
/* tcp */
flow->packet.tcp = (struct ndpi_tcphdr *) l4ptr;
@@ -2969,7 +2969,7 @@ static int ndpi_init_packet_header(struct ndpi_detection_module_struct *ndpi_str
/* tcp header not complete */
flow->packet.tcp = NULL;
}
- } else if(l4protocol == 17 /* udp */ &&flow->packet.l4_packet_len >= 8 /* size of udp */ ) {
+ } else if(l4protocol == IPPROTO_UDP && flow->packet.l4_packet_len >= 8 /* size of udp */ ) {
flow->packet.udp = (struct ndpi_udphdr *) l4ptr;
flow->packet.payload_packet_len =flow->packet.l4_packet_len - 8;
flow->packet.payload = ((u_int8_t *)flow->packet.udp) + 8;