[Add] tethering client monitoring
[platform/core/connectivity/stc-manager.git] / src / helper / helper-net-cls.c
old mode 100755 (executable)
new mode 100644 (file)
index c1460dc..238b7de
@@ -132,8 +132,13 @@ uint32_t get_classid_by_app_id(const char *app_id, int create)
        if (!strcmp(app_id, STC_TOTAL_IPV6))
                return STC_TOTAL_IPV6_CLASSID;
 
+       if (!strcmp(app_id, STC_TOTAL_TETHERING))
+               return STC_TETHERING_APP_CLASSID;
+
        if (strstr(app_id, STC_BACKGROUND_APP_SUFFIX))
                path_to_net_cgroup_dir = BACKGROUND_CGROUP_NETWORK;
+       else if (strstr(app_id, STC_TETHERING_APP_SUFFIX))
+               path_to_net_cgroup_dir = TETHERING_CGROUP_NETWORK;
        else
                path_to_net_cgroup_dir = FOREGROUND_CGROUP_NETWORK;
 
@@ -169,7 +174,7 @@ handle_error:
 
 stc_error_e place_pids_to_net_cgroup(const int pid, const char *app_id)
 {
-       char child_buf[21 + MAX_DEC_SIZE(int) + MAX_DEC_SIZE(int)];
+       char child_buf[21 + MAX_DEC_SIZE(int) + MAX_DEC_SIZE(int) + 1];
        const char *path_to_net_cgroup_dir = NULL;
 
        snprintf(child_buf, sizeof(child_buf), PROC_TASK_CHILDREN, pid, pid);
@@ -183,14 +188,13 @@ stc_error_e place_pids_to_net_cgroup(const int pid, const char *app_id)
                path_to_net_cgroup_dir = STC_CGROUP_NETWORK;
        else if (strstr(app_id, STC_BACKGROUND_APP_SUFFIX))
                path_to_net_cgroup_dir = BACKGROUND_CGROUP_NETWORK;
+       else if (strstr(app_id, STC_TETHERING_APP_SUFFIX))
+               path_to_net_cgroup_dir = TETHERING_CGROUP_NETWORK;
        else
                path_to_net_cgroup_dir = FOREGROUND_CGROUP_NETWORK; //LCOV_EXCL_LINE
 
-       if (access(child_buf, F_OK)) {
-               if (STC_DEBUG_LOG)
-                       STC_LOGD("%s of %s is not existed", child_buf, app_id); //LCOV_EXCL_LINE
+       if (access(child_buf, F_OK))
                return cgroup_write_pid(path_to_net_cgroup_dir, app_id, pid);
-       }
 
        return cgroup_write_pidtree(path_to_net_cgroup_dir, app_id, pid); //LCOV_EXCL_LINE
 }