aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCampus <campus@ntop.org>2017-02-14 01:23:47 +0100
committerCampus <campus@ntop.org>2017-02-14 01:23:47 +0100
commitb35c1ab696672257eeebe8e22448373e486c5e82 (patch)
tree4784c9c412947471f41ec23dafffb28cab65b01f /src
parent5c1c8b80e2bb9911f774c6f6e098de3cd4973e2d (diff)
minor fix mgcp dissector
Diffstat (limited to 'src')
-rw-r--r--src/lib/protocols/mgcp.c104
1 files changed, 41 insertions, 63 deletions
diff --git a/src/lib/protocols/mgcp.c b/src/lib/protocols/mgcp.c
index 779caa0eb..e16091642 100644
--- a/src/lib/protocols/mgcp.c
+++ b/src/lib/protocols/mgcp.c
@@ -1,8 +1,7 @@
/*
* mgcp.c
*
- * Copyright (C) 2009-2011 by ipoque GmbH
- * Copyright (C) 2011-15 - ntop.org
+ * Copyright (C) 2017 - 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
@@ -21,12 +20,11 @@
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
-
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_MGCP
+
static void ndpi_int_mgcp_add_connection(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow)
{
@@ -34,67 +32,47 @@ static void ndpi_int_mgcp_add_connection(struct ndpi_detection_module_struct
}
-
-#if !defined(WIN32)
- static inline
-#else
-__forceinline static
-#endif
- void ndpi_search_mgcp_connection(struct ndpi_detection_module_struct
- *ndpi_struct, struct ndpi_flow_struct *flow)
-{
-
- struct ndpi_packet_struct *packet = &flow->packet;
-
-// struct ndpi_id_struct *src=ndpi_struct->src;
-// struct ndpi_id_struct *dst=ndpi_struct->dst;
-
- /* information about MGCP taken from http://en.wikipedia.org/wiki/MGCP */
-
- u_int16_t pos = 5;
-
- if (packet->payload_packet_len < 8) {
- goto mgcp_excluded;
- }
-
- /* packet must end with 0x0d0a or with 0x0a */
- if (packet->payload[packet->payload_packet_len - 1] != 0x0a) {
- goto mgcp_excluded;
- }
-
-
-
- if (packet->payload[0] != 'A' && packet->payload[0] != 'C' && packet->payload[0] != 'D' &&
- packet->payload[0] != 'E' && packet->payload[0] != 'M' && packet->payload[0] != 'N' &&
- packet->payload[0] != 'R') {
- goto mgcp_excluded;
- }
- if (memcmp(packet->payload, "AUEP ", 5) != 0 && memcmp(packet->payload, "AUCX ", 5) != 0 &&
- memcmp(packet->payload, "CRCX ", 5) != 0 && memcmp(packet->payload, "DLCX ", 5) != 0 &&
- memcmp(packet->payload, "EPCF ", 5) != 0 && memcmp(packet->payload, "MDCX ", 5) != 0 &&
- memcmp(packet->payload, "NTFY ", 5) != 0 && memcmp(packet->payload, "RQNT ", 5) != 0 &&
- memcmp(packet->payload, "RSIP ", 5) != 0) {
- goto mgcp_excluded;
- }
- // now search for string "MGCP " in the rest of the message
- while ((pos + 4) < packet->payload_packet_len) {
- if (memcmp(&packet->payload[pos], "MGCP ", 5) == 0) {
- NDPI_LOG(NDPI_PROTOCOL_MGCP, ndpi_struct, NDPI_LOG_DEBUG, "MGCP match.\n");
- ndpi_int_mgcp_add_connection(ndpi_struct, flow);
- return;
- }
- pos++;
- }
-
- mgcp_excluded:
- NDPI_LOG(NDPI_PROTOCOL_MGCP, ndpi_struct, NDPI_LOG_DEBUG, "exclude MGCP.\n");
- NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MGCP);
-}
-
-
void ndpi_search_mgcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
- ndpi_search_mgcp_connection(ndpi_struct, flow);
+
+ struct ndpi_packet_struct *packet = &flow->packet;
+
+ u_int16_t pos = 5;
+
+ if (packet->payload_packet_len < 8) {
+ goto mgcp_excluded;
+ }
+
+ /* packet must end with 0x0d0a or with 0x0a */
+ if (packet->payload[packet->payload_packet_len - 1] != 0x0a) {
+ goto mgcp_excluded;
+ }
+
+ if (packet->payload[0] != 'A' && packet->payload[0] != 'C' && packet->payload[0] != 'D' &&
+ packet->payload[0] != 'E' && packet->payload[0] != 'M' && packet->payload[0] != 'N' &&
+ packet->payload[0] != 'R') {
+ goto mgcp_excluded;
+ }
+ if (memcmp(packet->payload, "AUEP ", 5) != 0 && memcmp(packet->payload, "AUCX ", 5) != 0 &&
+ memcmp(packet->payload, "CRCX ", 5) != 0 && memcmp(packet->payload, "DLCX ", 5) != 0 &&
+ memcmp(packet->payload, "EPCF ", 5) != 0 && memcmp(packet->payload, "MDCX ", 5) != 0 &&
+ memcmp(packet->payload, "NTFY ", 5) != 0 && memcmp(packet->payload, "RQNT ", 5) != 0 &&
+ memcmp(packet->payload, "RSIP ", 5) != 0) {
+ goto mgcp_excluded;
+ }
+ // now search for string "MGCP " in the rest of the message
+ while ((pos + 4) < packet->payload_packet_len) {
+ if (memcmp(&packet->payload[pos], "MGCP ", 5) == 0) {
+ NDPI_LOG(NDPI_PROTOCOL_MGCP, ndpi_struct, NDPI_LOG_DEBUG, "MGCP match.\n");
+ ndpi_int_mgcp_add_connection(ndpi_struct, flow);
+ return;
+ }
+ pos++;
+ }
+
+ mgcp_excluded:
+ NDPI_LOG(NDPI_PROTOCOL_MGCP, ndpi_struct, NDPI_LOG_DEBUG, "exclude MGCP.\n");
+ NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MGCP);
}