From 4455dabee827fb7c78843601029ada351f08d77d Mon Sep 17 00:00:00 2001 From: Alfredo Cardigliano Date: Tue, 17 Sep 2024 11:27:27 +0200 Subject: [PATCH] Add filterize on wlan info --- httpdocs/tables_config/flow_historical.json | 2 ++ scripts/lua/modules/historical_flow_utils.lua | 31 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/httpdocs/tables_config/flow_historical.json b/httpdocs/tables_config/flow_historical.json index 00215b84a04f..6cbddfd8c5c0 100644 --- a/httpdocs/tables_config/flow_historical.json +++ b/httpdocs/tables_config/flow_historical.json @@ -448,6 +448,7 @@ "data_field": "wlan_ssid", "min-width": "100px", "sortable": true, + "render_generic": "wlan_ssid", "class": [ "no-wrap" ] @@ -457,6 +458,7 @@ "data_field": "apn_mac", "min-width": "100px", "sortable": true, + "render_generic": "apn_mac", "class": [ "no-wrap" ] diff --git a/scripts/lua/modules/historical_flow_utils.lua b/scripts/lua/modules/historical_flow_utils.lua index 1ee31add35a1..d3bc7ff4cae3 100644 --- a/scripts/lua/modules/historical_flow_utils.lua +++ b/scripts/lua/modules/historical_flow_utils.lua @@ -349,12 +349,37 @@ end local function dt_format_mac(mac) if mac == nil then return "" end mac = tonumber(mac) - if mac == 0 then return "" end + if not mac or mac == 0 then return "" end return ntop.decodeMac64(mac) end -- ##################################### +local function dt_format_mac_obj(mac) + local mac_str = dt_format_mac(mac) + local formatted_mac = { + title = mac_str, + label = mac_str, + value = mac_str, + } + + return formatted_mac +end + +-- ##################################### + +local function dt_format_ssid_obj(ssid) + local formatted_ssid = { + title = ssid, + label = ssid, + value = ssid, + } + + return formatted_ssid +end + +-- ##################################### + local function dt_format_dscp(dscp_id) dscp_id = tonumber(dscp_id) local title = dscp_consts.dscp_class_descr(dscp_id) @@ -1119,8 +1144,8 @@ local flow_columns = { ['POST_NAT_SRC_PORT'] = { tag = "post_nat_src_port", dt_func = dt_format_port, db_type = "Number", db_raw_type = "Uint16" }, ['POST_NAT_IPV4_DST_ADDR'] = { tag = "post_nat_ipv4_dst_addr", dt_func = dt_format_nat_ip, select_func = "IPv4NumToString", db_type = "Number", db_raw_type = "Uint32" }, ['POST_NAT_DST_PORT'] = { tag = "post_nat_dst_port", dt_func = dt_format_port, db_type = "Number", db_raw_type = "Uint16" }, - ['WLAN_SSID'] = { tag = "wlan_ssid", db_type = "String", db_raw_type = "String" }, - ['WTP_MAC_ADDRESS'] = { tag = "apn_mac", dt_func = dt_format_mac, db_type = "Number", db_raw_type = "Uint64" }, + ['WLAN_SSID'] = { tag = "wlan_ssid", dt_func = dt_format_ssid_obj, db_type = "String", db_raw_type = "String" }, + ['WTP_MAC_ADDRESS'] = { tag = "apn_mac", dt_func = dt_format_mac_obj, db_type = "Number", db_raw_type = "Uint64" }, --[[ TODO: this column is for the aggregated_flow_columns but the parsing Function only parses these columns, so a new logic to parse only the aggregated_flow_columns