From: Shravan Rangarajuvenkata (shrarang) Date: Mon, 29 Jul 2019 22:51:53 +0000 (-0400) Subject: Merge pull request #1689 in SNORT/snort3 from ~SATHIRKA/snort3:port_service to master X-Git-Tag: 3.0.0-259~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=387bd1cd18b0135ceaf01058f26f95401a6f7f3f;p=thirdparty%2Fsnort3.git Merge pull request #1689 in SNORT/snort3 from ~SATHIRKA/snort3:port_service to master Squashed commit of the following: commit de926e3175877734017a6fb84939171ef326cfd7 Author: Sreeja Athirkandathil Narayanan Date: Mon Jul 29 10:23:10 2019 -0400 Refactoring code commit c5dfddd9350be50a0c71b168f27aa838963a638d Author: Sreeja Athirkandathil Narayanan Date: Wed Jul 24 10:38:19 2019 -0400 appid: Fix for app name not getting evaluated for port/protocol based detectors --- diff --git a/src/network_inspectors/appid/appid_api.cc b/src/network_inspectors/appid/appid_api.cc index d4afb3313..fd6286379 100644 --- a/src/network_inspectors/appid/appid_api.cc +++ b/src/network_inspectors/appid/appid_api.cc @@ -58,28 +58,28 @@ const char* AppIdApi::get_application_name(AppId app_id) const char* AppIdApi::get_application_name(Flow& flow, bool from_client) { const char* app_name = nullptr; + AppId appid = APP_ID_NONE; AppIdSession* asd = get_appid_session(flow); if ( asd ) { - if ( asd->payload.get_id() ) - app_name = AppInfoManager::get_instance().get_app_name(asd->payload.get_id()); - else if ( asd->misc_app_id ) - app_name = AppInfoManager::get_instance().get_app_name(asd->misc_app_id); - else if ( from_client ) + appid = asd->pick_payload_app_id(); + if ( !appid ) + appid = asd->pick_misc_app_id(); + if ( !appid and from_client) { - if ( asd->client.get_id() ) - app_name = AppInfoManager::get_instance().get_app_name(asd->client.get_id()); - else - app_name = AppInfoManager::get_instance().get_app_name(asd->service.get_id()); + appid = asd->pick_client_app_id(); + if ( !appid) + appid = asd->pick_service_app_id(); } - else + else if ( !appid ) { - if ( asd->service.get_id() ) - app_name = AppInfoManager::get_instance().get_app_name(asd->service.get_id()); - else - app_name = AppInfoManager::get_instance().get_app_name(asd->client.get_id()); + appid = asd->pick_service_app_id(); + if ( !appid) + appid = asd->pick_client_app_id(); } } + if (appid > APP_ID_NONE && appid < SF_APPID_MAX) + app_name = AppInfoManager::get_instance().get_app_name(appid); return app_name; }