aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/dhcp.c
diff options
context:
space:
mode:
authorCampus <campus@ntop.org>2016-09-07 10:31:11 +0200
committerCampus <campus@ntop.org>2016-09-07 10:31:11 +0200
commit3ceb19a9c681dd5711d083fa9af894e643036fc3 (patch)
tree1a16394979325cacb4f44df30d720b744c84a1f4 /src/lib/protocols/dhcp.c
parent95974b0d2462a08b631680f5220c92be8e21877b (diff)
fixed dhcp dissector
Diffstat (limited to 'src/lib/protocols/dhcp.c')
-rw-r--r--src/lib/protocols/dhcp.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/lib/protocols/dhcp.c b/src/lib/protocols/dhcp.c
index 8ffc04d51..e33a7c011 100644
--- a/src/lib/protocols/dhcp.c
+++ b/src/lib/protocols/dhcp.c
@@ -1,8 +1,7 @@
/*
* dhcp.c
*
- * Copyright (C) 2009-2011 by ipoque GmbH
- * Copyright (C) 2011-15 - ntop.org
+ * Copyright (C) 2016 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -43,16 +42,18 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
/* this detection also works for asymmetric dhcp traffic */
/*check standard DHCP 0.0.0.0:68 -> 255.255.255.255:67 */
- if (packet->payload_packet_len >= 244 && (packet->udp->source == htons(67)
- || packet->udp->source == htons(68))
- && (packet->udp->dest == htons(67) || packet->udp->dest == htons(68))
- && get_u_int32_t(packet->payload, 236) == htonl(0x63825363)
- && get_u_int16_t(packet->payload, 240) == htons(0x3501)) {
-
- NDPI_LOG(NDPI_PROTOCOL_DHCP, ndpi_struct, NDPI_LOG_DEBUG, "DHCP request\n");
-
- ndpi_int_dhcp_add_connection(ndpi_struct, flow);
- return;
+ if(packet->udp) {
+ if(packet->payload_packet_len >= 244 &&
+ (packet->udp->source == htons(67) || packet->udp->source == htons(68)) &&
+ (packet->udp->dest == htons(67) || packet->udp->dest == htons(68)) &&
+ get_u_int32_t(packet->payload, 236) == htonl(0x63825363) &&
+ get_u_int16_t(packet->payload, 240) == htons(0x3501)) {
+
+ NDPI_LOG(NDPI_PROTOCOL_DHCP, ndpi_struct, NDPI_LOG_DEBUG, "DHCP request\n");
+
+ ndpi_int_dhcp_add_connection(ndpi_struct, flow);
+ return;
+ }
}
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DHCP);