Changed cur classid path and initialize
[platform/core/connectivity/stc-manager.git] / src / helper / helper-net-cls.c
index 0f2ae30..ef5e4b3 100755 (executable)
@@ -26,7 +26,7 @@
 #include "helper-file.h"
 #include "helper-net-cls.h"
 
-#define CUR_CLASSID_PATH "/tmp/cur_classid"
+#define CUR_CLASSID_PATH   "/var/lib/stc/cur_classid"
 #define CLASSID_FILE_NAME "net_cls.classid"
 
 typedef GArray task_classid_array;
@@ -85,6 +85,23 @@ static uint32_t __get_classid_from_cgroup(const char *cgroup,
        return classid;
 }
 
+stc_error_e init_current_classid(void)
+{
+       int ret = 0;
+       struct stat stat_buf;
+
+       if (stat(STC_CGROUP_NETWORK, &stat_buf) != 0) {
+               uint32_t classid = STC_RESERVED_CLASSID_MAX;
+               ret = fwrite_uint(CUR_CLASSID_PATH, classid);
+               if (ret < 0) {
+                       STC_LOGE("Can not init current classid");
+                       return STC_ERROR_FAIL;
+               }
+       }
+
+       return STC_ERROR_NONE;
+}
+
 uint32_t get_classid_by_app_id(const char *app_id, int create)
 {
        int ret = 0;