tizen 2.3 release
[kernel/api/system-resource.git] / src / network / include / counter.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  *  @file: counter.h
21  *
22  *  @desc Entity for working with datausage counter.
23  *        In plans place to counter.c main counting procedure from main.c
24  */
25
26
27 #ifndef _RESOURCED_DATAUSAGE_COUNTER_H
28 #define _RESOURCED_DATAUSAGE_COUNTER_H
29
30 #include "app-stat.h"
31 #include "config.h"
32 #include "daemon-options.h"
33
34 #include <Ecore.h>
35
36 struct counter_arg {
37         int sock;
38         int ans_len;
39 #ifndef CONFIG_DATAUSAGE_NFACCT
40         pid_t pid;
41         int family_id_stat;
42         int family_id_restriction;
43 #else
44         GTree *nf_cntrs;
45         int initiate;
46         int noti_fd;
47         Ecore_Fd_Handler *noti_fd_handler;
48 #endif
49         struct daemon_opts *opts;
50         struct application_stat_tree *result;
51         traffic_stat_tree *in_tree;
52         traffic_stat_tree *out_tree;
53         Ecore_Timer *ecore_timer;
54         Ecore_Fd_Handler *ecore_fd_handler;
55         Ecore_Timer *store_result_timer;
56 };
57
58 /**
59  * @desc Reschedule existing traffic counter function
60  *  Rescheduling logic is following, we will postpone
61  *  execution on delay seconds.
62  */
63 void reschedule_count_timer(const struct counter_arg *carg, const double delay);
64
65 struct counter_arg *init_counter_arg(struct daemon_opts *opts);
66
67 void finalize_carg(struct counter_arg *carg);
68
69 #ifdef CONFIG_DATAUSAGE_NFACCT
70 GTree *create_nfacct_tree(void);
71 #endif /* CONFIG_DATAUSAGE_NFACCT */
72
73 #endif /* _RESOURCED_NETWORK_COUNTING_H_ */
74
75