Functional mqtt

This commit is contained in:
Sorin Zamfir
2016-02-19 20:22:54 +02:00
parent a8050635fa
commit d18a1edb67
+33 -9
View File
@@ -135,7 +135,22 @@ void ndpi_search_mqtt (struct ndpi_detection_module_struct *ndpi_struct,
} }
if (pt == PUBLISH){ if (pt == PUBLISH){
u_int8_t qos = (u_int8_t) (flags & 0x06); u_int8_t qos = (u_int8_t) (flags & 0x06);
if (((qos == 1) || (qos == 2)) && (packet->payload_packet_len < 4)){ if (((qos == 1) || (qos == 2)) && (packet->payload_packet_len < 4)){ // at least topic + pkt identifier
NDPI_LOG(NDPI_PROTOCOL_MQTT, ndpi_struct, NDPI_LOG_DEBUG, "Excluding Mqtt\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MQTT);
return;
}
if ((qos == 0) && (packet->payload_packet_len < 3)){ // at least topic
NDPI_LOG(NDPI_PROTOCOL_MQTT, ndpi_struct, NDPI_LOG_DEBUG, "Excluding Mqtt\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MQTT);
return;
}
NDPI_LOG(NDPI_PROTOCOL_MQTT, ndpi_struct, NDPI_LOG_DEBUG, "Mqtt found [%d]\n",pt);
ndpi_int_mqtt_add_connection(ndpi_struct,flow);
return;
}
if ((pt == SUBSCRIBE) && (packet->payload_packet_len < 8)){ // at least one topic+filter is required in the payload
NDPI_LOG(NDPI_PROTOCOL_MQTT, ndpi_struct, NDPI_LOG_DEBUG, "Excluding Mqtt\n"); NDPI_LOG(NDPI_PROTOCOL_MQTT, ndpi_struct, NDPI_LOG_DEBUG, "Excluding Mqtt\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MQTT); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MQTT);
return; return;
@@ -144,16 +159,25 @@ void ndpi_search_mqtt (struct ndpi_detection_module_struct *ndpi_struct,
ndpi_int_mqtt_add_connection(ndpi_struct,flow); ndpi_int_mqtt_add_connection(ndpi_struct,flow);
return; return;
} }
}
if (pt == SUBSCRIBE){ if ((pt == SUBACK ) && (packet->payload_packet_len <5 )){ // must have at least a response code
// if () NDPI_LOG(NDPI_PROTOCOL_MQTT, ndpi_struct, NDPI_LOG_DEBUG, "Excluding Mqtt\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MQTT);
return;
} else {
NDPI_LOG(NDPI_PROTOCOL_MQTT, ndpi_struct, NDPI_LOG_DEBUG, "Mqtt found [%d]\n",pt);
ndpi_int_mqtt_add_connection(ndpi_struct,flow);
return;
} }
if (pt == SUBACK ){ if ((pt == UNSUBSCRIBE) && (packet->payload_packet_len < 7)) { // at least a topic
NDPI_LOG(NDPI_PROTOCOL_MQTT, ndpi_struct, NDPI_LOG_DEBUG, "Excluding Mqtt\n");
} NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MQTT);
if (pt == UNSUBSCRIBE){ return;
} else {
NDPI_LOG(NDPI_PROTOCOL_MQTT, ndpi_struct, NDPI_LOG_DEBUG, "Mqtt found [%d]\n",pt);
ndpi_int_mqtt_add_connection(ndpi_struct,flow);
return;
} }
NDPI_LOG(NDPI_PROTOCOL_MQTT, ndpi_struct, NDPI_LOG_DEBUG, "Excluding Mqtt ...\n"); NDPI_LOG(NDPI_PROTOCOL_MQTT, ndpi_struct, NDPI_LOG_DEBUG, "Excluding Mqtt ...\n");