4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * @desc Entity for storing applications statistics
25 * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
31 #include "data_usage.h"
32 #include "datausage-restriction.h"
34 #include "net-cls-cgroup.h"
35 #include "rd-network.h"
36 #include "resourced.h"
38 API network_error_e network_set_option(const network_option_s *options)
40 return (network_error_e)set_resourced_options((const resourced_options*)options);
43 API network_error_e network_get_option(network_option_s *options)
45 return (network_error_e)get_resourced_options((resourced_options*)options);
48 API network_error_e network_make_cgroup_with_pid(const int pid,
51 return (network_error_e)make_net_cls_cgroup_with_pid(pid, pkg_name);
54 API u_int32_t network_get_classid_by_pkg_name(const char *pkg_name, int create)
56 return (network_error_e)get_classid_by_pkg_name(pkg_name, create);
59 API network_error_e network_set_restriction(const char *app_id,
60 const network_restriction_s *restriction)
62 return (network_error_e)set_net_restriction(app_id,
63 (const resourced_net_restrictions*)restriction);
66 API network_error_e network_restriction_foreach(network_restriction_cb restriction_cb,
69 return (network_error_e)restrictions_foreach((resourced_restriction_cb)restriction_cb, user_data);
72 API network_error_e network_remove_restriction(const char *app_id)
74 return (network_error_e)remove_restriction(app_id);
77 API network_error_e network_remove_restriction_by_iftype(const char *app_id,
78 const network_iface_e iftype)
80 return (network_error_e)remove_restriction_by_iftype(app_id, (const resourced_iface_type)iftype);
83 API network_error_e network_exclude_restriction(const char *app_id)
85 return (network_error_e)exclude_restriction(app_id);
88 API network_error_e network_exclude_restriction_by_iftype(
89 const char *app_id, const network_iface_e iftype)
91 return (network_error_e)exclude_restriction_by_iftype(
92 app_id, (const resourced_iface_type)iftype);
95 API network_error_e network_register_activity_cb(network_activity_cb activity_cb)
97 return (network_error_e)register_net_activity_cb((net_activity_cb)activity_cb);
100 API network_error_e network_join_app_performance(const char *app_id, const pid_t pid)
102 return (network_error_e)join_app_performance(app_id, pid);
105 API network_error_e network_update_statistics(void)
107 return (network_error_e)resourced_update_statistics();
110 API network_error_e network_foreach(const network_selection_rule_s *rule,
111 network_info_cb info_cb, void *user_data)
113 return (network_error_e)data_usage_foreach(
114 (const data_usage_selection_rule*)rule,
115 (data_usage_info_cb)info_cb,
119 API network_error_e network_details_foreach(const char *app_id,
120 network_selection_rule_s *rule,
121 network_info_cb info_cb,
124 return (network_error_e)data_usage_details_foreach(app_id,
125 (data_usage_selection_rule*)rule,
126 (data_usage_info_cb)info_cb,
130 API network_error_e network_reset(const network_reset_rule_s *rule)
132 return (network_error_e)reset_data_usage((const data_usage_reset_rule*)rule);
135 API network_error_e network_remove_quota(
136 const network_quota_reset_rule_s *rule)
138 return (network_error_e)remove_datausage_quota(
139 (const struct datausage_quota_reset_rule*)rule);
142 API network_error_e network_remove_quota_by_iftype(
143 const char *app_id, const network_iface_e iftype)
145 return (network_error_e)remove_datausage_quota_by_iftype(app_id,
146 (const resourced_iface_type)iftype);
149 API network_error_e network_set_quota(const char *app_id,
150 const network_quota_s *quota)
152 return (network_error_e)set_datausage_quota(app_id,
153 (const data_usage_quota*)quota);
156 API network_error_e network_get_restriction_state(const char *pkg_id,
157 network_iface_e iftype, network_restriction_state *state)
159 return (network_error_e)get_restriction_state(pkg_id,
160 (const resourced_iface_type)iftype,
161 (resourced_restriction_state *)state);