Reworked IEC60870 dissector

This commit is contained in:
Luca Deri
2020-11-04 14:29:11 +01:00
parent 044a11faca
commit f6cb869c63
+20 -23
View File
@@ -20,8 +20,6 @@
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>. * along with nDPI. If not, see <http://www.gnu.org/licenses/>.
* *
* Origianally created by Cesar HM <cesar91hoyos@gmail.com>
*
*/ */
#include "ndpi_protocol_ids.h" #include "ndpi_protocol_ids.h"
@@ -38,27 +36,26 @@ void ndpi_search_iec60870_tcp(struct ndpi_detection_module_struct *ndpi_struct,
NDPI_LOG_DBG(ndpi_struct, "search IEC60870\n"); NDPI_LOG_DBG(ndpi_struct, "search IEC60870\n");
if(packet->tcp) { if(packet->tcp) {
/* The start byte of 104 is 0x68 */ u_int16_t offset = 0, found = 0;
if(packet->payload[0] == 0x68) {
/* while(offset < packet->payload_packet_len) {
Teoretically there is a port to use but it is not compulsory /* The start byte of 104 is 0x68 */
to use it hence better not count on it if(packet->payload[offset] == 0x68) {
*/ u_int8_t len = packet->payload[offset+1];
#ifdef CHECK_PORT
u_int16_t iec104_port = htons(2404); // port used by IEC60870 if(len == 0)
break;
if((packet->tcp->dest == iec104_port) || (packet->tcp->source == iec104_port)) else
#endif offset += len + 2, found = 1;
{ } else
u_int8_t len = packet->payload[1]; break;
}
if(packet->payload_packet_len == (len+2)) {
NDPI_LOG_INFO(ndpi_struct, "Found IEC60870-104\n"); if(found) {
NDPI_LOG_INFO(ndpi_struct, "Found IEC60870-104\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_IEC60870, NDPI_PROTOCOL_UNKNOWN);
return; ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_IEC60870, NDPI_PROTOCOL_UNKNOWN);
} return;
}
} }
} }