Skip to content

Commit d92c0db

Browse files
committed
Added s7comm to historical flows / added details to historical
1 parent 4ace03f commit d92c0db

File tree

12 files changed

+72
-8
lines changed

12 files changed

+72
-8
lines changed

http_src/vue/ntop_vue.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ import { default as PageExporterInterfaceOverview } from "./page-exporter-interf
9494

9595
/* Flow Details pages */
9696
import { default as PageFlowDetailsModbus } from "./page-flow-details-modbus.vue"
97+
import { default as PageFlowDetailsS7Comm } from "./page-flow-details-s7comm.vue"
9798

9899
/* Config pages */
99100
import { default as PageSNMPConfig } from "./page-snmp-config.vue"
@@ -206,6 +207,7 @@ let ntopVue = {
206207

207208
/* Flow Details pages */
208209
PageFlowDetailsModbus: PageFlowDetailsModbus,
210+
PageFlowDetailsS7Comm: PageFlowDetailsS7Comm,
209211

210212
/* SNMP */
211213
PageSNMPDevices: PageSNMPDevices,

http_src/vue/page-assets.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ const map_table_def_columns = (columns) => {
188188
if (!dataUtils.isEmptyOrNull(host.is_modbus_server)) {
189189
icons = `${icons} <span class="badge bg-success">${i18n("details.label_modbus_server")}</span>`
190190
}
191+
if (!dataUtils.isEmptyOrNull(host.is_s7comm_server)) {
192+
icons = `${icons} <span class="badge bg-success">${i18n("details.label_s7comm_server")}</span>`
193+
}
191194
192195
const host_url = create_button_host_details(row);
193196

http_src/vue/page-flow-details-s7comm.vue

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
<template>
22
<div class="m-2 mb-3 row">
33
<div class="row">
4+
<Transition name="add-effect" mode="out-in">
5+
<div class="position-relative col-6">
6+
<div class="card card-shadow">
7+
<div class="card-body">
8+
<NetworkMap ref="s7comm_map" :empty_message="no_transitions_message" :height="'30vh'"
9+
:page_csrf="props.context.csrf" :url="s7comm_map_url" :url_params="getExtraParameters()"
10+
:map_id="'s7comm_transition_map'">
11+
</NetworkMap>
12+
</div>
13+
</div>
14+
</div>
15+
</Transition>
416
<Transition name="add-effect" mode="out-in">
517
<div class="position-relative col-6">
618
<BootstrapTable id="s7comm_bootstrap_table" :columns="stats_columns" :rows="stats_rows"
@@ -9,9 +21,11 @@
921
</BootstrapTable>
1022
</div>
1123
</Transition>
24+
</div>
25+
<div class="mt-2 row">
1226
<Transition name="add-effect" mode="out-in">
1327
<div class="position-relative col-6">
14-
<TableWithConfig ref="table_s7comm_function_codes" :table_id="'s7comm_functions'"
28+
<TableWithConfig ref="table_s7comm_function_codes" :table_id="'s7comm_function_codes'"
1529
:showLoading="true" :f_map_columns="mapTableColumns" :f_sort_rows="columnsSorting"
1630
:get_extra_params_obj="getExtraParameters">
1731
<template v-slot:custom_header>
@@ -28,6 +42,7 @@
2842

2943
<script setup>
3044
import { ref, onMounted, onBeforeMount, computed } from "vue";
45+
import { default as NetworkMap } from "./network-map.vue";
3146
import { default as BootstrapTable } from "./bootstrap-table.vue";
3247
import { default as sortingFunctions } from "../utilities/sorting-utils.js";
3348
import { default as TableWithConfig } from "./table-with-config.vue";
@@ -43,6 +58,8 @@ const table_s7comm_functions = ref(null);
4358
const stats_rows = ref([]);
4459
const s7comm_general_stats_url = '/lua/pro/rest/v2/get/flow/s7comm/general_stats.lua'
4560
const no_transitions_message = i18n('flow_details.s7comm_no_transitions')
61+
const s7comm_map = ref(null)
62+
const s7comm_map_url = `${http_prefix}/lua/pro/rest/v2/get/flow/s7comm/map.lua`
4663
const stats_columns = ref([{
4764
name: _i18n("map_page.info"),
4865
id: "info"
@@ -111,7 +128,7 @@ function print_stats_row(col, row) {
111128
112129
function columnsSorting(col, r0, r1) {
113130
if (col != null) {
114-
if (col.id == "s7comm_function") {
131+
if (col.id == "s7comm_function_code") {
115132
return sortingFunctions.sortByName(r0.s7comm_function_code, r1.s7comm_function_code, col.sort);
116133
} else if (col.id == "num_uses") {
117134
return sortingFunctions.sortByNumber(r0.num_uses, r1.num_uses, col.sort);
@@ -125,7 +142,7 @@ function columnsSorting(col, r0, r1) {
125142
126143
const mapTableColumns = (columns) => {
127144
let map_columns = {
128-
"s7comm_function": (value) => {
145+
"s7comm_function_code": (value) => {
129146
return value;
130147
},
131148
"num_uses": (value) => {

httpdocs/tables_config/s7comm_function.json renamed to httpdocs/tables_config/s7comm_function_codes.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"id": "s7comm_functions",
3-
"data_url": "lua/pro/rest/v2/get/flow/s7comm/functions.lua",
2+
"id": "s7comm_function_codes",
3+
"data_url": "lua/pro/rest/v2/get/flow/s7comm/function_codes.lua",
44
"use_current_page": false,
55
"enable_search": true,
66
"paging": false,
@@ -12,7 +12,7 @@
1212
"columns": [
1313
{
1414
"title_i18n": "id",
15-
"data_field": "s7comm_function",
15+
"data_field": "s7comm_function_code",
1616
"min-width": "80px",
1717
"sortable": true,
1818
"class": []

include/Host.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ class Host : public GenericHashEntry,
248248
return (host_services_bitmap & (1 << HOST_IS_MODBUS_SERVER));
249249
}
250250
virtual void setModbusServer();
251+
252+
inline bool isS7CommServer() const {
253+
return (host_services_bitmap & (1 << HOST_IS_S7COMM_SERVER));
254+
}
255+
virtual void setS7CommServer();
251256

252257
inline bool isSmtpServer() const {
253258
return (host_services_bitmap & (1 << HOST_IS_SMTP_SERVER));

include/IpAddress.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct ipAddress {
3030

3131
u_int8_t dnsServer : 1, dhcpServer : 1, smtpServer : 1, ntpServer : 1,
3232
imapServer : 1, popServer : 1, gateway: 1, httpServer : 1;
33-
u_int8_t sshServer : 1, rdpServer : 1, modbusServer : 1, unused : 5;
33+
u_int8_t sshServer : 1, rdpServer : 1, modbusServer : 1, s7commServer : 1, unused : 4;
3434

3535
union {
3636
struct ndpi_in6_addr ipv6;
@@ -129,6 +129,8 @@ class IpAddress {
129129
inline void setDnsServer() { addr.dnsServer = true; }
130130
inline bool isModbusServer() const { return (addr.modbusServer); }
131131
inline void setModbusServer() { addr.modbusServer = true; }
132+
inline bool isS7CommServer() const { return (addr.s7commServer); }
133+
inline void setS7CommServer() { addr.s7commServer = true; }
132134
inline bool isSmtpServer() const { return (addr.smtpServer); }
133135
inline void setSmtpServer() { addr.smtpServer = true; }
134136
inline bool isImapServer() const { return (addr.imapServer); }

include/LocalHost.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class LocalHost : public Host {
207207
void setDnsServer();
208208
void setSmtpServer();
209209
void setModbusServer();
210+
void setModbusServer();
210211
void setNtpServer();
211212
void setImapServer();
212213
void setPopServer();

include/ntop_defines.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@
398398
#define HOST_IS_HTTP_SERVER 0x07
399399
#define HOST_IS_SSH_SERVER 0x08
400400
#define HOST_IS_RDP_SERVER 0x09
401-
#define HOST_IS_MODBUS_SERVER 0x10
401+
#define HOST_IS_MODBUS_SERVER 0x0A
402+
#define HOST_IS_S7COMM_SERVER 0x0B
402403

403404
#define MAX_DYNAMIC_STATS_VALUES 12
404405

scripts/locales/en.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,6 +2743,7 @@ local lang = {
27432743
["label_ssh_server"] = "SSH",
27442744
["label_rdp_server"] = "RDP",
27452745
["label_modbus_server"] = "Modbus",
2746+
["label_s7comm_server"] = "S7Comm",
27462747
["label_private_ip"] = "Private",
27472748
["label_remote"] = "Remote",
27482749
["label_short_blackhole"] = "H",
@@ -3588,6 +3589,7 @@ local lang = {
35883589
["modbus_transitions"] = "Function Code Transitions",
35893590
["modbus_function_codes_transitions"] = "Transitions",
35903591
["modbus_no_transitions"] = "No Transitions",
3592+
["s7comm_no_transitions"] = "No Transitions",
35913593
["s7comm_errors"] = "Errors",
35923594
["s7comm_requests"] = "Requests",
35933595
["s7comm_responses"] = "Responses",

scripts/lua/flow_details.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ local flow_key = _GET["flow_key"]
550550
local flow_hash_id = _GET["flow_hash_id"]
551551

552552
flow = interface.findFlowByKeyAndHashId(tonumber(flow_key), tonumber(flow_hash_id))
553+
--tprint(flow)
553554

554555
local ifid = interface.name2id(ifname)
555556
local label = getFlowLabel(flow, nil, nil, nil, nil, nil, false)
@@ -566,6 +567,11 @@ page_utils.print_navbar(title, url, {{
566567
active = page == "modbus",
567568
page_name = "modbus",
568569
label = i18n("details.label_modbus_server")
570+
}, {
571+
hidden = not (flow.s7comm) or not ntop.isEnterpriseL(),
572+
active = page == "s7comm",
573+
page_name = "s7comm",
574+
label = i18n("details.label_s7comm_server")
569575
}})
570576

571577
if isEmptyString(page) or page == "overview" then
@@ -2411,5 +2417,15 @@ elseif page == "modbus" then
24112417
vue_page_name = "PageFlowDetailsModbus",
24122418
page_context = json_context
24132419
})
2420+
elseif page == "s7comm" then
2421+
local json = require "dkjson"
2422+
local json_context = json.encode({
2423+
csrf = ntop.getRandomCSRFValue()
2424+
})
2425+
2426+
template.render("pages/vue_page.template", {
2427+
vue_page_name = "PageFlowDetailsS7Comm",
2428+
page_context = json_context
2429+
})
24142430
end
24152431
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")

0 commit comments

Comments
 (0)