2 * Smart Traffic Control (STC)
4 * Copyright (c) 2017 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.
20 #ifndef __TIZEN_STC_MGR_INTERNAL_H__
21 #define __TIZEN_STC_MGR_INTERNAL_H__
28 * @file stc_internal.h
31 /*****************************************************************************
33 *****************************************************************************/
38 /*****************************************************************************
39 * Smart Traffic Control (STC) library headers
40 *****************************************************************************/
41 #include "stc_stat_internal.h"
42 #include "stc_rstn_internal.h"
44 /*****************************************************************************
46 *****************************************************************************/
48 /*****************************************************************************
50 *****************************************************************************/
52 /*****************************************************************************
54 *****************************************************************************/
57 * @addtogroup CAPI_NETWORK_STC_MANAGER_MODULE
62 * @brief Called for enumerate restriction rule.
65 * @param[in] result The result
66 * @param[in] rule The restriction rule handle
67 * @param[in] user_data The user data passed from the callback registration function
68 * @return @c STC_CALLBACK_CONTINUE to continue with the next iteration of the loop,
69 * otherwise @c STC_CALLBACK_CANCEL to break out of the loop
71 * @pre stc_get_restriction() will invoke this callback.
72 * @pre stc_foreach_restriction() will invoke this callback.
73 * @see stc_restriction_rule_get_app_id()
74 * @see stc_restriction_rule_get_iface_name()
75 * @see stc_restriction_rule_get_subscriber_id()
76 * @see stc_restriction_rule_get_type()
77 * @see stc_restriction_rule_get_iface_type()
78 * @see stc_restriction_rule_get_limit()
79 * @see stc_restriction_rule_get_warning_limit()
80 * @see stc_restriction_rule_get_monthly_limit()
81 * @see stc_restriction_rule_get_weekly_limit()
82 * @see stc_restriction_rule_get_daily_limit()
83 * @see stc_restriction_rule_get_month_start_date()
84 * @see stc_restriction_rule_get_roaming_type()
85 * @see stc_get_restriction()
86 * @see stc_foreach_restriction()
88 typedef stc_callback_ret_e (*stc_restriction_rule_cb)(stc_error_e result,
89 stc_restriction_rule_h rule, void *user_data);
91 typedef void (*stc_threshold_crossed_cb)(stc_restriction_rule_h rule,
98 /*****************************************************************************
100 *****************************************************************************/
103 * @addtogroup CAPI_NETWORK_STC_MANAGER_MODULE
108 * @brief Resets stats information.
110 * @privlevel platform
111 * @privilege %http://tizen.org/privilege/network.get
113 * @param[in] stc The stc handle
114 * @param[in] rule The reset rule handle
116 * @return 0 on success, otherwise a negative error value
117 * @retval #STC_ERROR_NONE Successful
118 * @retval #STC_ERROR_OPERATION_FAILED General error
119 * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
120 * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
121 * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
122 * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
123 * @retval #STC_ERROR_NOT_SUPPORTED Not supported
124 * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
127 * @see #stc_reset_rule_h
128 * @see stc_initialize()
129 * @see stc_reset_rule_create()
130 * @see stc_reset_rule_destroy()
131 * @see stc_reset_rule_set_app_id()
132 * @see stc_reset_rule_set_subscriber_id()
133 * @see stc_reset_rule_set_iface_type()
134 * @see stc_reset_rule_set_time_interval()
135 * @see stc_reset_rule_get_app_id()
136 * @see stc_reset_rule_get_subscriber_id()
137 * @see stc_reset_rule_get_iface_type()
138 * @see stc_reset_rule_get_time_interval()
140 int stc_reset_stats(stc_h stc, stc_reset_rule_h rule);
144 * @brief Sets the restriction for application.
145 * @details Sets and applies restriction for application.
146 * It will creates new restriction or modify existing.
148 * @privlevel platform
149 * @privilege %http://tizen.org/privilege/network.get
151 * @param[in] stc The stc handle
152 * @param[in] rule The restriction rule handle
154 * @return 0 on success, otherwise a negative error value
155 * @retval #STC_ERROR_NONE Successful
156 * @retval #STC_ERROR_OPERATION_FAILED General error
157 * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
158 * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
159 * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
160 * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
161 * @retval #STC_ERROR_NOT_SUPPORTED Not supported
162 * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
165 * @see #stc_restriction_rule_h
166 * @see stc_initialize()
167 * @see stc_restriction_rule_create()
168 * @see stc_restriction_rule_destroy()
169 * @see stc_restriction_rule_set_app_id()
170 * @see stc_restriction_rule_set_iface_name()
171 * @see stc_restriction_rule_set_iface_type()
172 * @see stc_restriction_rule_set_limit()
173 * @see stc_restriction_rule_set_warning_limit()
174 * @see stc_restriction_rule_set_roaming_type()
175 * @see stc_restriction_rule_set_subscriber_id()
176 * @see stc_restriction_rule_get_app_id()
177 * @see stc_restriction_rule_get_iface_type()
178 * @see stc_restriction_rule_get_limit()
179 * @see stc_restriction_rule_get_warning_limit()
180 * @see stc_restriction_rule_get_roaming_type()
181 * @see stc_restriction_rule_get_subscriber_id()
182 * @see stc_restriction_rule_get_process_state()
183 * @see stc_get_restriction()
184 * @see stc_foreach_restriction()
185 * @see stc_get_restriction_type()
186 * @see stc_unset_restriction()
188 int stc_set_restriction(stc_h stc, stc_restriction_rule_h rule);
191 * @brief Unsets the existing restriction for application.
192 * @details Unsets the existing restriction for application.
193 * It will delete restriction rule in kernel.
195 * @privlevel platform
196 * @privilege %http://tizen.org/privilege/network.get
198 * @param[in] stc The stc handle
199 * @param[in] rule The restriction rule handle
201 * @return 0 on success, otherwise a negative error value
202 * @retval #STC_ERROR_NONE Successful
203 * @retval #STC_ERROR_OPERATION_FAILED General error
204 * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
205 * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
206 * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
207 * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
208 * @retval #STC_ERROR_NOT_SUPPORTED Not supported
209 * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
212 * @see #stc_restriction_rule_h
213 * @see stc_initialize()
214 * @see stc_restriction_rule_create()
215 * @see stc_restriction_rule_destroy()
216 * @see stc_restriction_rule_set_app_id()
217 * @see stc_restriction_rule_set_iface_name()
218 * @see stc_restriction_rule_set_iface_type()
219 * @see stc_restriction_rule_set_limit()
220 * @see stc_restriction_rule_set_warning_limit()
221 * @see stc_restriction_rule_set_roaming_type()
222 * @see stc_restriction_rule_set_subscriber_id()
223 * @see stc_restriction_rule_get_app_id()
224 * @see stc_restriction_rule_get_iface_type()
225 * @see stc_restriction_rule_get_limit()
226 * @see stc_restriction_rule_get_warning_limit()
227 * @see stc_restriction_rule_get_roaming_type()
228 * @see stc_restriction_rule_get_subscriber_id()
229 * @see stc_restriction_rule_get_process_state()
230 * @see stc_set_restriction()
231 * @see stc_get_restriction()
232 * @see stc_foreach_restriction()
233 * @see stc_get_restriction_type()
235 int stc_unset_restriction(stc_h stc, stc_restriction_rule_h rule);
238 * @brief Gets the restriction rule per application.
239 * @details The callback is called for each application that applied restriction.
241 * @privlevel platform
242 * @privilege %http://tizen.org/privilege/network.get
244 * @param[in] stc The stc handle
245 * @param[in] rule The restriction rule handle
246 * @param[in] rule_cb The callback is called for each application
247 * that applied restriction in interface specified
248 * @param[in] user_data User data will be passed to the callback function
250 * @return 0 on success, otherwise a negative error value
251 * @retval #STC_ERROR_NONE Successful
252 * @retval #STC_ERROR_OPERATION_FAILED General error
253 * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
254 * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
255 * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
256 * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
257 * @retval #STC_ERROR_NOT_SUPPORTED Not supported
258 * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
261 * @see #stc_restriction_rule_h
262 * @see stc_initialize()
263 * @see stc_restriction_rule_create()
264 * @see stc_restriction_rule_destroy()
265 * @see stc_restriction_rule_set_app_id()
266 * @see stc_restriction_rule_set_iface_name()
267 * @see stc_restriction_rule_set_iface_type()
268 * @see stc_restriction_rule_set_limit()
269 * @see stc_restriction_rule_set_warning_limit()
270 * @see stc_restriction_rule_set_roaming_type()
271 * @see stc_restriction_rule_set_subscriber_id()
272 * @see stc_restriction_rule_get_app_id()
273 * @see stc_restriction_rule_get_iface_type()
274 * @see stc_restriction_rule_get_limit()
275 * @see stc_restriction_rule_get_warning_limit()
276 * @see stc_restriction_rule_get_roaming_type()
277 * @see stc_restriction_rule_get_subscriber_id()
278 * @see stc_restriction_rule_get_process_state()
279 * @see stc_restriction_rule_cb()
280 * @see stc_set_restriction()
281 * @see stc_foreach_restriction()
282 * @see stc_get_restriction_type()
283 * @see stc_unset_restriction()
285 int stc_get_restriction(stc_h stc, stc_restriction_rule_h rule,
286 stc_restriction_rule_cb rule_cb, void *user_data);
288 int stc_set_restriction_threshold_crossed_cb(stc_h stc,
289 stc_threshold_crossed_cb crossed_cb, void *user_data);
291 int stc_unset_restriction_threshold_crossed_cb(stc_h stc);
293 int stc_set_warn_threshold_crossed_cb(stc_h stc,
294 stc_threshold_crossed_cb crossed_cb, void *user_data);
296 int stc_unset_warn_threshold_crossed_cb(stc_h stc);
299 * @brief Gets the restriction rule of all application.
300 * @details The callback is called for each application that applied restriction.
302 * @privlevel platform
303 * @privilege %http://tizen.org/privilege/network.get
305 * @param[in] stc The stc handle
306 * @param[in] rule The restriction rule handle
307 * @param[in] rule_cb The callback is called for each application
308 * that applied restriction in interface specified
309 * @param[in] user_data User data will be passed to the callback function
311 * @return 0 on success, otherwise a negative error value
312 * @retval #STC_ERROR_NONE Successful
313 * @retval #STC_ERROR_OPERATION_FAILED General error
314 * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
315 * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
316 * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
317 * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
318 * @retval #STC_ERROR_NOT_SUPPORTED Not supported
319 * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
322 * @see #stc_restriction_rule_h
323 * @see stc_initialize()
324 * @see stc_restriction_rule_create()
325 * @see stc_restriction_rule_destroy()
326 * @see stc_restriction_rule_set_app_id()
327 * @see stc_restriction_rule_set_iface_name()
328 * @see stc_restriction_rule_set_iface_type()
329 * @see stc_restriction_rule_set_limit()
330 * @see stc_restriction_rule_set_warning_limit()
331 * @see stc_restriction_rule_set_roaming_type()
332 * @see stc_restriction_rule_set_subscriber_id()
333 * @see stc_restriction_rule_get_app_id()
334 * @see stc_restriction_rule_get_iface_type()
335 * @see stc_restriction_rule_get_limit()
336 * @see stc_restriction_rule_get_warning_limit()
337 * @see stc_restriction_rule_get_roaming_type()
338 * @see stc_restriction_rule_get_subscriber_id()
339 * @see stc_restriction_rule_get_process_state()
340 * @see stc_restriction_rule_cb()
341 * @see stc_set_restriction()
342 * @see stc_get_restriction()
343 * @see stc_get_restriction_type()
344 * @see stc_unset_restriction()
346 int stc_foreach_restriction(stc_h stc, stc_restriction_rule_h rule,
347 stc_restriction_rule_cb rule_cb, void *user_data);
350 * @brief Gets the restriction type.
352 * @privlevel platform
353 * @privilege %http://tizen.org/privilege/network.get
355 * @param[in] stc The stc handle
356 * @param[in] rule The restriction rule handle
357 * @param[out] type The restriction type
359 * @return 0 on success, otherwise a negative error value
360 * @retval #STC_ERROR_NONE Successful
361 * @retval #STC_ERROR_OPERATION_FAILED General error
362 * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
363 * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
364 * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
365 * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
366 * @retval #STC_ERROR_NOT_SUPPORTED Not supported
367 * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
370 * @see #stc_restriction_rule_h
371 * @see #stc_restriction_type_e
372 * @see stc_initialize()
373 * @see stc_restriction_rule_create()
374 * @see stc_restriction_rule_destroy()
375 * @see stc_restriction_rule_set_app_id()
376 * @see stc_restriction_rule_set_iface_name()
377 * @see stc_restriction_rule_set_iface_type()
378 * @see stc_restriction_rule_set_limit()
379 * @see stc_restriction_rule_set_warning_limit()
380 * @see stc_restriction_rule_set_roaming_type()
381 * @see stc_restriction_rule_set_subscriber_id()
382 * @see stc_restriction_rule_get_app_id()
383 * @see stc_restriction_rule_get_iface_type()
384 * @see stc_restriction_rule_get_limit()
385 * @see stc_restriction_rule_get_warning_limit()
386 * @see stc_restriction_rule_get_roaming_type()
387 * @see stc_restriction_rule_get_subscriber_id()
388 * @see stc_restriction_rule_get_process_state()
389 * @see stc_set_restriction()
390 * @see stc_get_restriction()
391 * @see stc_foreach_restriction()
392 * @see stc_unset_restriction()
394 int stc_get_restriction_type(stc_h stc, stc_restriction_rule_h rule,
395 stc_restriction_type_e *type);
405 #endif /* __TIZEN_STC_MGR_INTERNAL_H__ */