]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1689 in SNORT/snort3 from ~SATHIRKA/snort3:port_service to master
authorShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Mon, 29 Jul 2019 22:51:53 +0000 (18:51 -0400)
committerShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Mon, 29 Jul 2019 22:51:53 +0000 (18:51 -0400)
Squashed commit of the following:

commit de926e3175877734017a6fb84939171ef326cfd7
Author: Sreeja Athirkandathil Narayanan <sathirka@cisco.com>
Date:   Mon Jul 29 10:23:10 2019 -0400

    Refactoring code

commit c5dfddd9350be50a0c71b168f27aa838963a638d
Author: Sreeja Athirkandathil Narayanan <sathirka@cisco.com>
Date:   Wed Jul 24 10:38:19 2019 -0400

    appid: Fix for app name not getting evaluated for port/protocol based detectors

src/network_inspectors/appid/appid_api.cc

index d4afb331393f90ce41ad2abbfd5cef0eeddea088..fd6286379966bd313923d431795d038bd5c61eac 100644 (file)
@@ -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;
 }