diff --git a/include/ntop_flow.h b/include/ntop_flow.h index 297681ca03..4aafe6fd02 100644 --- a/include/ntop_flow.h +++ b/include/ntop_flow.h @@ -501,5 +501,7 @@ #define COMMUNITY_ID NTOP_BASE_ID+524 #define L7_CATEGORY NTOP_BASE_ID+509 #define FLOW_RISK NTOP_BASE_ID+508 +#define SRC_ASN NTOP_BASE_ID+525 +#define DST_ASN NTOP_BASE_ID+526 #endif /* _NTOP_FLOW_H_ */ diff --git a/scripts/locales/en.lua b/scripts/locales/en.lua index bbd7365716..5fc8ab0b75 100644 --- a/scripts/locales/en.lua +++ b/scripts/locales/en.lua @@ -3750,6 +3750,7 @@ local lang = { ["nindex"] = { ["bytes"] = "Bytes", ["cli_port"] = "Cli Port", + ["cli_asn"] = "Cli ASN", ["client"] = "Client", ["client_name"] = "Client Name", ["extract_flow_info"] = "Actions", @@ -3768,6 +3769,7 @@ local lang = { ["server"] = "Server", ["server_name"] = "Server Name", ["src2dst_dscp"] = "Client DSCP", + ["srv_asn"] = "Srv ASN", ["srv_port"] = "Srv Port", ["status"] = "Status", ["throughput"] = "Thpt", @@ -3776,6 +3778,7 @@ local lang = { ["tags"] = { ["cli_ip"] = "Client IP", ["cli_port"] = "Client Port", + ["cli_asn"] = "Client ASN", ["flow_risk"] = "Flow Risk", ["l4proto"] = "Protocol", ["l7_proto"] = "Application", @@ -3786,6 +3789,7 @@ local lang = { ["src2dst_dscp"] = "Client DSCP", ["srv_ip"] = "Server IP", ["srv_port"] = "Server Port", + ["srv_asn"] = "Server ASN", ["status"] = "Status", }, }, diff --git a/scripts/lua/modules/http_lint.lua b/scripts/lua/modules/http_lint.lua index e2f14771db..59ff25053d 100644 --- a/scripts/lua/modules/http_lint.lua +++ b/scripts/lua/modules/http_lint.lua @@ -1359,6 +1359,8 @@ local known_parameters = { ["srv_ip"] = validateEmptyOr(validateFilters(validateHost)), -- An IPv4 or IPv6 address ["cli_port"] = validateFilters(validatePort), --Client port ["srv_port"] = validateFilters(validatePort), --Server port + ["cli_asn"] = validateFilters(validateNumber), + ["srv_asn"] = validateFilters(validateNumber), ["tot_pkts"] = validateFilters(validateNumber), --Total packtes, used by nindex query ["tot_bytes"] = validateFilters(validateNumber), --Total bytes, used by nindex query ["src2dst_dscp"] = validateEmptyOr(validateFilters(validateUnquoted)), --Client DSCP, used by nindex query diff --git a/scripts/lua/modules/tag_utils.lua b/scripts/lua/modules/tag_utils.lua index 235da7c487..a00f703cee 100644 --- a/scripts/lua/modules/tag_utils.lua +++ b/scripts/lua/modules/tag_utils.lua @@ -39,6 +39,8 @@ tag_utils.nindex_tags_to_where_v4 = { ["info"] = "INFO", ["srv_label"] = "DST_LABEL", ["cli_label"] = "SRC_LABEL", + ["cli_asn"] = "SRC_ASN", + ["srv_asn"] = "DST_ASN", } -- ##################################### @@ -60,6 +62,8 @@ tag_utils.nindex_tags_to_where_v6 = { ["src2dst_dscp"] = "SRC2DST_DSCP", ["dst2src_dscp"] = "DST2SRC_DSCP", ["info"] = "INFO", + ["cli_asn"] = "SRC_ASN", + ["srv_asn"] = "DST_ASN", } -- ##################################### diff --git a/src/LuaEngineNtop.cpp b/src/LuaEngineNtop.cpp index 3c8e51ff03..c404b5207d 100644 --- a/src/LuaEngineNtop.cpp +++ b/src/LuaEngineNtop.cpp @@ -5927,6 +5927,25 @@ static int ntop_reload_device_protocols(lua_State *vm) { /* ****************************************** */ +static int ntop_get_asn_name(lua_State *vm) { + IpAddress a; + char *as_name; + u_int32_t asn = 0; + + if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TSTRING) != CONST_LUA_OK) + return(CONST_LUA_PARAM_ERROR); + + a.set((char*)lua_tostring(vm, 1)); + + ntop->getGeolocation()->getAS(&a, &asn, &as_name); + + lua_pushstring(vm, as_name); + + return(CONST_LUA_OK); +} + +/* ****************************************** */ + static int ntop_get_ndpi_protocol_category(lua_State* vm) { NetworkInterface *ntop_interface = getCurrentInterface(vm); u_int proto; @@ -6311,6 +6330,9 @@ static luaL_Reg _ntop_reg[] = { { "getLocalNetworkAlias", ntop_check_local_network_alias }, { "getLocalNetworkID", ntop_get_local_network_id }, + /* ASN */ + { "getASName", ntop_get_asn_name }, + /* Mac */ { "setMacDeviceType", ntop_set_mac_device_type },