tizen 2.3 release
[kernel/api/system-resource.git] / src / network / include / net-cls-cgroup.h
1 /*
2  * resourced
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 /*
21  *  @file: net-cls-cgroup.h
22  *
23  *  @desc Performance management daemon. Helper function
24  *              for working with classid table.
25  *  @version 1.0
26  *
27  */
28
29
30 #ifndef _RESOURCED_NET_CLS_CGROUP_H_
31 #define _RESOURCED_NET_CLS_CGROUP_H_
32
33 #include <sys/types.h>
34 #include <glib.h>
35 #include <stdbool.h>
36
37 #include "resourced.h"
38
39 typedef GArray int_array;
40
41 /**
42  * @desc Get all pids from cgroup
43  *     Should be invoked after update_classids
44  * @return array, you should free it
45  */
46 int_array *get_monitored_pids(void);
47
48 /**
49  * @desc update class id - pid table. At present one pid per classid.
50  */
51 int update_classids(void);
52
53 /**
54  * @desc Get appid from classid task table. At present it is package name.
55  */
56 char *get_app_id_by_pid(const pid_t pid);
57 char *get_app_id_by_classid(const u_int32_t classid, const bool update_state);
58
59 /**
60  * @desc take classid from net_cls cgroup by appid
61  *      This function converts appid to pkgname.
62  * @param pkg_name - name of the cgroup
63  * @param create - in case of true - create cgroup if it's not exists
64  * @return classid
65  */
66 u_int32_t get_classid_by_app_id(const char *app_id, int create);
67
68 /**
69  * @desc take classid from net_cls cgroup with name pkg_name
70  * @param pkg_name - name of the cgroup
71  * @param create - in case of true - create cgroup if it's not exists
72  * @return classid
73  */
74 u_int32_t get_classid_by_pkg_name(const char *pkg_name, int create);
75
76 /**
77  * @desc Make net_cls cgroup and put in it the given pid and
78  * generated classid.
79  * If cgroup alreay exists function just put pid in it.
80  * @param pid - process, that will be added to cgroup pkg_name,
81  * @param pkg_name - package name.
82  */
83 resourced_ret_c make_net_cls_cgroup_with_pid(const int pid,
84         const char *pkg_name);
85
86 #endif  /*_RESOURCED_NET_CLS_CGROUP_H_*/