Skip to content

Commit cb3e15d

Browse files
committed
Collect s7comm stats
1 parent 6d53107 commit cb3e15d

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

include/Flow.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class Flow : public GenericHashEntry {
203203
IEC104Stats *iec104;
204204
#ifdef NTOPNG_PRO
205205
ModbusStats *modbus;
206+
S7CommStats *s7comm;
206207
#endif
207208
char *suspicious_dga_domain; /* Stores the suspicious DGA domain for flows
208209
with NDPI_SUSPICIOUS_DGA_DOMAIN */
@@ -553,6 +554,7 @@ class Flow : public GenericHashEntry {
553554
}
554555
inline bool isIEC60870() const { return (isProto(NDPI_PROTOCOL_IEC60870)); }
555556
inline bool isModbus() const { return (isProto(NDPI_PROTOCOL_MODBUS)); }
557+
inline bool isS7Comm() const { return (isProto(NDPI_PROTOCOL_S7COMM)); }
556558
inline bool isMDNS() const { return (isProto(NDPI_PROTOCOL_MDNS)); }
557559
inline bool isSSDP() const { return (isProto(NDPI_PROTOCOL_SSDP)); }
558560
inline bool isNetBIOS() const { return (isProto(NDPI_PROTOCOL_NETBIOS)); }
@@ -1210,6 +1212,7 @@ class Flow : public GenericHashEntry {
12101212
void updateTCPWinScale(bool src2dst_direction, u_int8_t winscale);
12111213
void updateTCPWin(bool src2dst_direction, u_int16_t win);
12121214
void getModbusInfo(ndpi_serializer *serializer);
1215+
void getS7CommInfo(ndpi_serializer *serializer);
12131216

12141217
#if !defined(HAVE_NEDGE)
12151218
inline void updateProfile() { trafficProfile = iface->getFlowProfile(this); }

include/ntop_includes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ using namespace clickhouse;
485485
#ifdef NTOPNG_PRO
486486
#include "FlowRTP.h"
487487
#include "ModbusStats.h"
488+
#include "S7CommStats.h"
488489
#include "MessageBroker.h"
489490
#include "NatsBroker.h"
490491
#endif

src/Flow.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ Flow::Flow(NetworkInterface *_iface,
289289

290290
#ifdef NTOPNG_PRO
291291
modbus = NULL;
292+
s7comm = NULL;
292293
lateral_movement = false;
293294
periodicity_status = periodicity_status_unknown;
294295
#ifndef HAVE_NEDGE
@@ -599,6 +600,7 @@ Flow::~Flow() {
599600
if(iec104) delete iec104;
600601
#ifdef NTOPNG_PRO
601602
if(modbus) delete modbus;
603+
if(s7comm) delete s7comm;
602604
#endif
603605

604606
if(suspicious_dga_domain) free(suspicious_dga_domain);
@@ -3317,6 +3319,7 @@ void Flow::lua(lua_State *vm, AddressTree *ptree,
33173319

33183320
#ifdef NTOPNG_PRO
33193321
if(modbus) modbus->lua(vm);
3322+
if(s7comm) s7comm->lua(vm);
33203323
#endif
33213324

33223325
if(!has_json_info) lua_push_str_table_entry(vm, "moreinfo.json", "{}");
@@ -5692,6 +5695,7 @@ std::string Flow::getFlowInfo(bool isLuaRequest) {
56925695
if(iec104) return (iec104->getFlowInfo());
56935696
#ifdef NTOPNG_PRO
56945697
if(modbus) return (modbus->getFlowInfo());
5698+
if(s7comm) return (s7comm->getFlowInfo());
56955699
#endif
56965700

56975701
if(isDNS() && protos.dns.last_query) {
@@ -8021,6 +8025,14 @@ void Flow::getProtocolJSONInfo(ndpi_serializer *serializer) {
80218025
ndpi_serialize_end_of_block(serializer);
80228026
break;
80238027
#endif
8028+
8029+
#ifdef NTOPNG_PRO
8030+
case NDPI_PROTOCOL_S7COMM:
8031+
ndpi_serialize_start_of_block(serializer, "s7comm");
8032+
getS7CommInfo(serializer);
8033+
ndpi_serialize_end_of_block(serializer);
8034+
break;
8035+
#endif
80248036
}
80258037

80268038
if(getErrorCode() != 0)

src/ParserInterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ bool ParserInterface::processFlow(ParsedFlow *zflow) {
614614
}
615615

616616
#ifdef NTOPNG_PRO
617-
if (flow->isModbus()) {
617+
if (flow->isModbus() || flow->isS7Comm()) {
618618
flow->updateOTStats(zflow);
619619
}
620620
#endif

src/ZMQParserInterface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,8 +1107,8 @@ bool ZMQParserInterface::parsePENNtopField(ParsedFlow *const flow,
11071107
#if 0
11081108
ntop->getTrace()->traceEvent(TRACE_NORMAL, "[value: %s][master: %u][app: %u]",
11091109
value->string ? value->string : "(int)",
1110-
flow->l7_proto.master_protocol,
1111-
flow->l7_proto.app_protocol);
1110+
flow->l7_proto.proto.master_protocol,
1111+
flow->l7_proto.proto.app_protocol);
11121112
#endif
11131113
break;
11141114

0 commit comments

Comments
 (0)