diff --git a/include/Paginator.h b/include/Paginator.h
index c5c3cfc148..9f99604c93 100644
--- a/include/Paginator.h
+++ b/include/Paginator.h
@@ -36,7 +36,7 @@ class Paginator {
u_int16_t vlan_id_filter;
u_int8_t ip_version /* Either 4 or 6 */;
int8_t unicast_traffic, unidirectional_traffic, alerted_flows, filtered_flows;
- u_int32_t client_asn, server_asn;
+ u_int32_t asn_filter;
u_int32_t deviceIP;
u_int16_t inIndex, outIndex;
u_int16_t pool_filter;
@@ -117,12 +117,8 @@ class Paginator {
if(server_mode) { (*f) = server_mode; return true; } return false;
}
- inline bool clientASN(u_int32_t *f) const {
- if(client_asn != (u_int32_t)-1) { (*f) = client_asn; return true; } return false;
- }
-
- inline bool serverASN(u_int32_t *f) const {
- if(server_asn != (u_int32_t)-1) { (*f) = server_asn; return true; } return false;
+ inline bool asnFilter(u_int32_t *f) const {
+ if(asn_filter != (u_int32_t)-1) { (*f) = asn_filter; return true; } return false;
}
inline bool unidirectionalTraffic(bool *f) const {
diff --git a/scripts/locales/en.lua b/scripts/locales/en.lua
index e3d2d4d081..4507149964 100644
--- a/scripts/locales/en.lua
+++ b/scripts/locales/en.lua
@@ -1309,10 +1309,17 @@ local en = {
network_details = {
network = "Network",
- network_parameter_missing_message = "Network parameter is missing (internal error ?)",
+ network_parameter_missing_message = "Network parameter is missing (internal error?)",
no_available_stats_for_network = "No available stats for network %{network}",
},
+ as_details = {
+ as = "Autonomous System",
+ as_parameter_missing_message = "Autonomous System parameter is missing (internal error?)",
+ no_available_data_for_as = "No available data for AS %{asn}.",
+ as_timeseries_enable_message = "AS timeseries can be enabled from the %{icon_flask} Preferences. Few minutes are necessary to see the first data points.",
+ },
+
port_details = {
l4_port = "L4 Port",
active_flows_for_host_and_port = "Active Flows for %{host}:%{port}",
diff --git a/scripts/lua/as_details.lua b/scripts/lua/as_details.lua
new file mode 100644
index 0000000000..ca6bc6f85b
--- /dev/null
+++ b/scripts/lua/as_details.lua
@@ -0,0 +1,233 @@
+--
+-- (C) 2013-17 - ntop.org
+--
+
+dirs = ntop.getDirs()
+package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
+
+if(ntop.isPro()) then
+ package.path = dirs.installdir .. "/pro/scripts/lua/modules/?.lua;" .. package.path
+ require "snmp_utils"
+end
+
+require "lua_utils"
+require "graph_utils"
+
+local asn = tonumber(_GET["asn"])
+local page = _GET["page"]
+
+local application = _GET["application"]
+
+interface.select(ifname)
+
+local as_info = interface.getASInfo(asn) or {}
+local ifId = getInterfaceId(ifname)
+local asname = as_info["asname"]
+
+local label = (asn or '')..''
+if not isEmptyString(asname) then
+ label = label.." ["..shortenString(asname).."]"
+end
+
+sendHTTPContentTypeHeader('text/html')
+ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc")
+dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
+
+if isEmptyString(asn) then
+ print("
 .. )
".. i18n("as_details.as_parameter_missing_message") .. "
")
+ dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
+ return
+end
+
+--[[
+Create Menu Bar with buttons
+--]]
+local nav_url = ntop.getHttpPrefix().."/lua/as_details.lua?asn="..tonumber(asn)
+print [[
+
+]]
+
+if isEmptyString(page) or page == "historical" then
+ local rrdname = getRRDName(ifId, 'asn:'..asn, 'bytes.rrd')
+
+ if(not ntop.exists(rrdname)) then
+ print(" .. )
"..i18n("as_details.no_available_data_for_as",{asn = label}))
+ print(" "..i18n("as_details.as_timeseries_enable_message",{url = ntop.getHttpPrefix().."/lua/admin/prefs.lua?tab=on_disk_ts",icon_flask="
"})..'
')
+
+ else
+ local rrdfile = "bytes.rrd"
+ if not isEmptyString(_GET["rrd_file"]) then
+ rrdfile=_GET["rrd_file"]
+ end
+
+ local asn_url = ntop.getHttpPrefix()..'/lua/as_details.lua?ifid='..ifId..'&asn='..asn..'&page=historical'
+ drawRRD(ifId, 'asn:'..asn, rrdfile, _GET["zoom"], asn_url, 1, _GET["epoch"], nil, makeTopStatsScriptsArray())
+ end
+
+elseif page == "flows" then
+
+print [[
+
+
+
+ ]]
+
+end
+
+dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
diff --git a/scripts/lua/get_flows_data.lua b/scripts/lua/get_flows_data.lua
index d809b87d7b..9b006ae628 100644
--- a/scripts/lua/get_flows_data.lua
+++ b/scripts/lua/get_flows_data.lua
@@ -32,8 +32,7 @@ local deviceIP = _GET["deviceIP"]
local inIfIdx = _GET["inIfIdx"]
local outIfIdx = _GET["outIfIdx"]
-local client_asn = _GET["client_asn"]
-local server_asn = _GET["server_asn"]
+local asn = _GET["asn"]
local vhost = _GET["vhost"]
local flowhosts_type = _GET["flowhosts_type"]
@@ -170,12 +169,8 @@ if not isEmptyString(deviceIP) then
end
end
-if not isEmptyString(client_asn) then
- pageinfo["clientASNFilter"] = tonumber(client_asn)
-end
-
-if not isEmptyString(server_asn) then
- pageinfo["serverASNFilter"] = tonumber(server_asn)
+if not isEmptyString(asn) then
+ pageinfo["asnFilter"] = tonumber(asn)
end
local flows_stats = interface.getFlowsInfo(host, pageinfo)
diff --git a/scripts/lua/get_grouped_hosts_data.lua b/scripts/lua/get_grouped_hosts_data.lua
index f0e31422b8..966884e85a 100644
--- a/scripts/lua/get_grouped_hosts_data.lua
+++ b/scripts/lua/get_grouped_hosts_data.lua
@@ -167,9 +167,9 @@ function print_single_group(value)
elseif(group_col == "asn") then
print(value["id"]..'", ')
print('"column_chart": "')
- local asnstats_rrd = fixPath(dirs.workingdir .. "/" .. ifstats.id..'/asnstats/'..value["id"]..'/bytes.rrd')
+ local asnstats_rrd = getRRDName(ifstats.id, 'asn:'..value["id"], 'bytes.rrd')
if ntop.exists(asnstats_rrd) then
- print('')
+ print('')
else
print('')
end
diff --git a/scripts/lua/modules/as_utils.lua b/scripts/lua/modules/as_utils.lua
index 5539077adc..ef3c662b2c 100644
--- a/scripts/lua/modules/as_utils.lua
+++ b/scripts/lua/modules/as_utils.lua
@@ -32,7 +32,7 @@ function as2record(as)
record["column_chart"] = ""
local asnstats_rrd = fixPath(dirs.workingdir .. "/" ..getInterfaceId(ifname)..'/asnstats/'..as["asn"]..'/bytes.rrd')
if ntop.exists(asnstats_rrd) then
- record["column_chart"] = ''
+ record["column_chart"] = ''
end
return record
diff --git a/src/NetworkInterface.cpp b/src/NetworkInterface.cpp
index 3f5d670aa5..d685fa463e 100644
--- a/src/NetworkInterface.cpp
+++ b/src/NetworkInterface.cpp
@@ -2930,7 +2930,7 @@ static bool flow_matches(Flow *f, struct flowHostRetriever *retriever) {
LocationPolicy client_policy;
LocationPolicy server_policy;
bool unicast, unidirectional, alerted_flows;
- u_int32_t client_asn, server_asn;
+ u_int32_t asn_filter;
u_int32_t deviceIP;
u_int16_t inIndex, outIndex;
#ifdef NTOPNG_PRO
@@ -2969,13 +2969,10 @@ static bool flow_matches(Flow *f, struct flowHostRetriever *retriever) {
}
if(retriever->pag
- && retriever->pag->clientASN(&client_asn)
- && (!f->get_cli_host() || f->get_cli_host()->get_asn() != client_asn))
- return(false);
-
- if(retriever->pag
- && retriever->pag->serverASN(&server_asn)
- && (!f->get_srv_host() || f->get_srv_host()->get_asn() != server_asn))
+ && retriever->pag->asnFilter(&asn_filter)
+ && f->get_cli_host() && f->get_srv_host()
+ && f->get_cli_host()->get_asn() != asn_filter
+ && f->get_srv_host()->get_asn() != asn_filter)
return(false);
if(retriever->pag
diff --git a/src/Paginator.cpp b/src/Paginator.cpp
index 4903b24cb4..4d14003fc8 100644
--- a/src/Paginator.cpp
+++ b/src/Paginator.cpp
@@ -51,7 +51,7 @@ Paginator::Paginator() {
mac_filter = NULL;
deviceIP = inIndex = outIndex = 0;
- client_asn = server_asn = (u_int32_t)-1;
+ asn_filter = (u_int32_t)-1;
details_level = details_normal;
details_level_set = false;
@@ -61,7 +61,6 @@ Paginator::Paginator() {
osFilter
vlanFilter
- asnFilter
*/
};
@@ -165,10 +164,8 @@ void Paginator::readOptions(lua_State *L, int index) {
ip_version = lua_tointeger(L, -1);
else if(!strcmp(key, "poolFilter"))
pool_filter = lua_tointeger(L, -1);
- else if(!strcmp(key, "clientASNFilter"))
- client_asn = lua_tointeger(L, -1);
- else if(!strcmp(key, "serverASNFilter"))
- server_asn = lua_tointeger(L, -1);
+ else if(!strcmp(key, "asnFilter"))
+ asn_filter = lua_tointeger(L, -1);
//else
//ntop->getTrace()->traceEvent(TRACE_ERROR, "Invalid int type (%d) for option %s", lua_tointeger(L, -1), key);