Skip to content

Commit 6a95f44

Browse files
committed
Add S7Comm learning period configuration
1 parent 8be49d4 commit 6a95f44

File tree

6 files changed

+29
-5
lines changed

6 files changed

+29
-5
lines changed

include/Prefs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ class Prefs {
6767
tls_quic_hostnaming;
6868
u_int32_t behaviour_analysis_learning_period;
6969
u_int32_t iec60870_learning_period, modbus_learning_period,
70-
devices_learning_period, mac_address_cache_duration;
70+
s7comm_learning_period, devices_learning_period,
71+
mac_address_cache_duration;
7172
u_int32_t host_port_learning_period;
7273
bool enable_flow_swap_heuristic;
7374
bool skip_dpi_for_collected_flows;
@@ -732,6 +733,7 @@ class Prefs {
732733
inline u_int64_t* getIEC104AllowedTypeIDs() { return (iec104_allowed_typeids); };
733734
inline u_int32_t getIEC60870LearingPeriod() { return (iec60870_learning_period); };
734735
inline u_int32_t getModbusLearningPeriod() { return (modbus_learning_period); };
736+
inline u_int32_t getS7CommLearningPeriod() { return (s7comm_learning_period); };
735737
#ifdef NTOPNG_PRO
736738
inline bool isAssetInventoryEnabled() { return(asset_inventory_enabled && !isASNModeEnabled()); };
737739
inline bool isSNMPTrapEnabled() { return snmp_trap_enabled; };

include/ntop_defines.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,8 @@
644644
#define CONST_DEVICES_LEARNING_TIME 7200 /* 2 hours */
645645
#define CONST_HOST_PORT_LEARNING_TIME 7200 /* 2 hours */
646646
#define CONST_IEC104_LEARNING_TIME 21600 /* 6 hours */
647-
#define CONST_MODBUS_LEARNING_TIME 3600 /* 1 hour */
647+
#define CONST_MODBUS_LEARNING_TIME 21600 /* 6 hours */
648+
#define CONST_S7COMM_LEARNING_TIME 21600 /* 6 hours */
648649
#define CONST_INFLUXDB_KEY_EXPORTED_POINTS \
649650
"ntopng.cache.influxdb.num_exported_points"
650651
#define CONST_INFLUXDB_FLUSH_TIME 10 /* sec */
@@ -806,6 +807,8 @@
806807
NTOPNG_PREFS_PREFIX ".iec60870_learning_period"
807808
#define CONST_PREFS_MODBUS_ANALYSIS_LEARNING_PERIOD \
808809
NTOPNG_PREFS_PREFIX ".modbus_learning_period"
810+
#define CONST_PREFS_S7COMM_ANALYSIS_LEARNING_PERIOD \
811+
NTOPNG_PREFS_PREFIX ".s7comm_learning_period"
809812
#define CONST_PREFS_HOST_PORT_LEARNING_PERIOD \
810813
NTOPNG_PREFS_PREFIX ".host_port_learning_period"
811814
#define CONST_PREFS_DEVICES_ANALYSIS_LEARNING_PERIOD \

scripts/locales/en.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7628,6 +7628,8 @@ local lang = {
76287628
["modbus_learning_period_description"] = "Configure the learning period for ModbusTCP traffic analysis. Default: 6 hours.",
76297629
["modbus_learning_period_title"] = "ModbusTCP Learning Period",
76307630
["mqtt"] = "MQTT",
7631+
["s7comm_learning_period_description"] = "Configure the learning period for S7Comm traffic analysis. Default: 6 hours.",
7632+
["s7comm_learning_period_title"] = "S7Comm Learning Period",
76317633
["multiple_ldap_account_type_description"] = "Choose the account type",
76327634
["multiple_ldap_account_type_title"] = "LDAP Accounts Type",
76337635
["multiple_timeseries_database_description"] = "The driver used for storing and retrieving timeseries data.<br><b>Note:</b> It's possible to use InfluxDB v.2 with a compatible v.1 bucket, however the Retention and the Buckets have to be managed by the InfluxDB GUI.<br>Minimum InfluxDB version supported: <b>1.5.1</b>",

scripts/lua/admin/prefs.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,11 +1261,11 @@ if auth.has_capability(auth.capabilities.preferences) then
12611261

12621262
print('<thead class="table-primary"><tr><th colspan=2 class="info">' .. i18n("prefs.ot_protocols") ..
12631263
'</th></tr></thead>')
1264-
-- By default 1 hour of learning
1264+
-- By default 6 hours of learning
12651265
prefsInputFieldPrefs(subpage_active.entries["iec60870_learning_period"].title,
12661266
subpage_active.entries["iec60870_learning_period"].description, "ntopng.prefs.", "iec60870_learning_period",
1267-
prefs.iec60870_learning_period or 3600, "number", nil, nil, nil, {
1268-
min = 21600,
1267+
prefs.iec60870_learning_period or 21600, "number", nil, nil, nil, {
1268+
min = 3600,
12691269
tformat = "hd"
12701270
})
12711271

@@ -1277,6 +1277,14 @@ if auth.has_capability(auth.capabilities.preferences) then
12771277
tformat = "hd"
12781278
})
12791279

1280+
-- By default 6 hours of learning
1281+
prefsInputFieldPrefs(subpage_active.entries["s7comm_learning_period"].title,
1282+
subpage_active.entries["s7comm_learning_period"].description, "ntopng.prefs.", "s7comm_learning_period",
1283+
prefs.s7comm_learning_period or 21600, "number", is_behaviour_analysis_enabled, nil, nil, {
1284+
min = 3600,
1285+
tformat = "hd"
1286+
})
1287+
12801288
print(
12811289
'<tr><th colspan=2 style="text-align:right;"><button type="submit" class="btn btn-primary" style="width:115px" disabled="disabled">' ..
12821290
i18n("save") .. '</button></th></tr>')

scripts/lua/modules/prefs_menu.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,10 @@ local menu_subpages = {{
518518
modbus_learning_period = {
519519
title = i18n("prefs.modbus_learning_period_title"),
520520
description = i18n("prefs.modbus_learning_period_description")
521+
},
522+
s7comm_learning_period = {
523+
title = i18n("prefs.s7comm_learning_period_title"),
524+
description = i18n("prefs.s7comm_learning_period_description")
521525
}
522526
}
523527
}, {

src/Prefs.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Prefs::Prefs(Ntop *_ntop) {
106106
behaviour_analysis_learning_status_post_learning = service_allowed;
107107
iec60870_learning_period = CONST_IEC104_LEARNING_TIME;
108108
modbus_learning_period = CONST_MODBUS_LEARNING_TIME;
109+
s7comm_learning_period = CONST_S7COMM_LEARNING_TIME;
109110
devices_learning_period = CONST_DEVICES_LEARNING_TIME;
110111
host_port_learning_period = CONST_HOST_PORT_LEARNING_TIME;
111112
auth_session_duration = HTTP_SESSION_DURATION;
@@ -1186,6 +1187,8 @@ void Prefs::refreshBehaviourAnalysis() {
11861187
CONST_IEC104_LEARNING_TIME);
11871188
modbus_learning_period = getDefaultPrefsValue(CONST_PREFS_MODBUS_ANALYSIS_LEARNING_PERIOD,
11881189
CONST_MODBUS_LEARNING_TIME);
1190+
s7comm_learning_period = getDefaultPrefsValue(CONST_PREFS_S7COMM_ANALYSIS_LEARNING_PERIOD,
1191+
CONST_S7COMM_LEARNING_TIME);
11891192
devices_learning_period = getDefaultPrefsValue(CONST_PREFS_DEVICES_ANALYSIS_LEARNING_PERIOD,
11901193
CONST_DEVICES_LEARNING_TIME);
11911194
host_port_learning_period = getDefaultPrefsValue(CONST_PREFS_HOST_PORT_LEARNING_PERIOD,
@@ -2917,6 +2920,8 @@ void Prefs::lua(lua_State *vm) {
29172920
iec60870_learning_period);
29182921
lua_push_uint64_table_entry(vm, "modbus_learning_period",
29192922
modbus_learning_period);
2923+
lua_push_uint64_table_entry(vm, "s7comm_learning_period",
2924+
s7comm_learning_period);
29202925
lua_push_uint64_table_entry(vm, "mac_address_cache_duration",
29212926
mac_address_cache_duration);
29222927
lua_push_bool_table_entry(vm, "enable_flow_swap_heuristic",

0 commit comments

Comments
 (0)