Initialize smart traffic control package 16/118516/36 accepted/tizen/unified/20170502.041158 submit/tizen/20170502.020209
authorhyunuktak <hyunuk.tak@samsung.com>
Mon, 13 Mar 2017 02:25:22 +0000 (11:25 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Tue, 2 May 2017 01:50:33 +0000 (10:50 +0900)
Change-Id: I3b4e97a29164a450ed780658d7d516cd1adba3a6
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
42 files changed:
CMakeLists.txt [new file with mode: 0755]
LICENSE [new file with mode: 0755]
capi-network-stc.manifest [new file with mode: 0755]
doc/stc_doc.h [new file with mode: 0755]
include/CMakeLists.txt [new file with mode: 0755]
include/stc.h [new file with mode: 0755]
include/stc_internal.h [new file with mode: 0755]
packaging/capi-network-stc.spec [new file with mode: 0755]
pkgconfig/CMakeLists.txt [new file with mode: 0755]
pkgconfig/capi-network-stc.pc.in [new file with mode: 0755]
src/CMakeLists.txt [new file with mode: 0755]
src/include/stc-info.h [new file with mode: 0755]
src/include/stc-manager.h [new file with mode: 0755]
src/include/stc-reset.h [new file with mode: 0755]
src/include/stc-restriction.h [new file with mode: 0755]
src/include/stc-statistics.h [new file with mode: 0755]
src/internal/include/stc-dbus.h [new file with mode: 0755]
src/internal/include/stc-event.h [new file with mode: 0755]
src/internal/include/stc-log.h [new file with mode: 0755]
src/internal/include/stc-network-option.h [new file with mode: 0755]
src/internal/include/stc-private.h [new file with mode: 0755]
src/internal/include/stc-signal.h [new file with mode: 0755]
src/internal/include/stc-util.h [new file with mode: 0755]
src/internal/stc-dbus.c [new file with mode: 0755]
src/internal/stc-event.c [new file with mode: 0755]
src/internal/stc-private.c [new file with mode: 0755]
src/internal/stc-signal.c [new file with mode: 0755]
src/stc-info.c [new file with mode: 0755]
src/stc-manager.c [new file with mode: 0755]
src/stc-reset.c [new file with mode: 0755]
src/stc-restriction.c [new file with mode: 0755]
src/stc-statistics.c [new file with mode: 0755]
src/stc.c [new file with mode: 0755]
test/CMakeLists.txt [new file with mode: 0755]
test/restriction.c [new file with mode: 0755]
test/restriction.h [new file with mode: 0755]
test/statistics.c [new file with mode: 0755]
test/statistics.h [new file with mode: 0755]
test/stc_menu.c [new file with mode: 0755]
test/stc_menu.h [new file with mode: 0755]
test/stc_test.c [new file with mode: 0755]
test/stc_test.h [new file with mode: 0755]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..8c5f60c
--- /dev/null
@@ -0,0 +1,66 @@
+# Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+# @file        CMakeLists.txt
+#
+
+############################# Check minimum CMake version #####################
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
+SET(fw_name "capi-network-stc")
+PROJECT(${fw_name})
+
+############################# cmake packages ##################################
+
+INCLUDE(FindPkgConfig)
+
+########################## search for packages ################################
+
+SET(COMMON_DEPS "dlog glib-2.0 gio-2.0 capi-base-common capi-system-info gio-unix-2.0 gthread-2.0")
+SET(PC_DEPS "capi-base-common")
+
+
+PKG_CHECK_MODULES(STC_DEPS REQUIRED ${COMMON_DEPS})
+
+#########################  package configuration  #############################
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${PC_DEPS})
+SET(PC_LDFLAGS -l${fw_name})
+
+############################# compiler flags ##################################
+FOREACH(flag ${STC_DEPS_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall")
+SET(CMAKE_C_FLAGS_DEBUG      "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE    "-O2 -g")
+
+# Don't export symbols by default
+ADD_DEFINITIONS("-fvisibility=hidden")
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIBDIR}")
+
+SET(TARGET_STC "capi-network-stc")
+SET(TARGET_STC_TEST "stc_test")
+
+SET(STC_PATH ${PROJECT_SOURCE_DIR}/src)
+SET(STC_INTERNAL_PATH ${PROJECT_SOURCE_DIR}/src/internal)
+
+ADD_SUBDIRECTORY(include)
+ADD_SUBDIRECTORY(src)
+ADD_SUBDIRECTORY(pkgconfig)
+ADD_SUBDIRECTORY(test)
diff --git a/LICENSE b/LICENSE
new file mode 100755 (executable)
index 0000000..bedddac
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,203 @@
+Copyright (c) 2014 - 2017 Samsung Electronics Co., Ltd. All rights reserved.
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/capi-network-stc.manifest b/capi-network-stc.manifest
new file mode 100755 (executable)
index 0000000..a76fdba
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
diff --git a/doc/stc_doc.h b/doc/stc_doc.h
new file mode 100755 (executable)
index 0000000..8ae28a6
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_NETWORK_STC_DOC_H__
+#define __TIZEN_NETWORK_STC_DOC_H__
+
+/**
+ * @defgroup CAPI_NETWORK_STC_MODULE STC
+ * @brief The STC API provides functions for managing and monitoring network packets.
+ * @ingroup CAPI_NETWORK_FRAMEWORK
+ *
+ * @section CAPI_NETWORK_STC_MODULE_HEADER Required Header
+ *   \#include <stc.h>
+ *
+ * @section CAPI_NETWORK_STC_MODULE_OVERVIEW Overview
+ * This functions is used to initialize the settings of Smart Traffic Control.
+ * @section CAPI_NETWORK_STC_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.stc\n
+ *
+ * It is recommended to use features in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on using features in your application can be found in the <a href="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>feature element description</b></a>.
+ *
+ */
+
+
+/**
+ * @defgroup CAPI_NETWORK_STC_MANAGER_MODULE STC Manager
+ * @brief The STC Manager API provides functions for managing STC.
+ * @ingroup CAPI_NETWORK_STC_MODULE
+ *
+ * @section CAPI_NETWORK_STC_MANAGER_MODULE_HEADER Required Header
+ *   \#include <stc.h>
+ *
+ * @section CAPI_NETWORK_STC_MANAGER_MODULE_OVERVIEW Overview
+ * To use STC manager API, first create the STC handle using stc_initialize(). After that, you can obtain STC information.
+ * You should destroy the created STC handle if you do not need it anymore.
+ * The STC manager API provides functions for managing STC.
+ * Using the STC manager, you can implement features that allow the users of your application to:
+ * - Reset / Get  / Update the statistics information
+ * - Set / Get / Remove / Exclude the restriction rule
+ * @section CAPI_NETWORK_STC_MANAGER_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.stc\n
+ *
+ * It is recommended to use features in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on using features in your application can be found in the <a href="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>feature element description</b></a>.
+ *
+ */
+
+
+/**
+ * @defgroup CAPI_NETWORK_STC_NETWORK_STATISTICS_MODULE STC Statistics
+ * @brief The STC statistics API provides functions for managing STC statistics.
+ * @ingroup CAPI_NETWORK_STC_MODULE
+ *
+ * @section CAPI_NETWORK_STC_STATISTICS_MODULE_HEADER Required Header
+ *   \#include <stc.h>
+ *
+ * @section CAPI_NETWORK_STC_STATISTICS_MODULE_OVERVIEW Overview
+ * To use STC statistics API, first create the STC handle using stc_initialize(). After that, you can obtain STC information.
+ * You should destroy the created STC handle if you do not need it anymore.
+ * The STC statistics API provides functions for managing STC statistics.
+ * @section CAPI_NETWORK_STC_STATISTICS_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.stc\n
+ *
+ * It is recommended to use features in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on using features in your application can be found in the <a href="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>feature element description</b></a>.
+ *
+ */
+
+
+/**
+ * @defgroup CAPI_NETWORK_STC_RESTRICTION_MODULE STC Restriction
+ * @brief The STC restriction API provides functions for managing STC restriction.
+ * @ingroup CAPI_NETWORK_STC_MODULE
+ *
+ * @section CAPI_NETWORK_STC_RESTRICTION_MODULE_HEADER Required Header
+ *   \#include <stc.h>
+ *
+ * @section CAPI_NETWORK_STC_RESTRICTION_MODULE_OVERVIEW Overview
+ * To use STC restriction API, first create the STC handle using stc_initialize(). After that, you can obtain STC information.
+ * You should destroy the created STC handle if you do not need it anymore.
+ * The STC restriction API provides functions for managing STC restrictions.
+ * @section CAPI_NETWORK_STC_RESTRICTION_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.stc\n
+ *
+ * It is recommended to use features in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on using features in your application can be found in the <a href="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>feature element description</b></a>.
+ *
+ */
+
+#endif /* __TIZEN_NETWORK_STC_DOC_H__ */
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..c56f247
--- /dev/null
@@ -0,0 +1,22 @@
+# Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+# @file        CMakeLists.txt
+#
+
+INSTALL(FILES
+    ${CMAKE_SOURCE_DIR}/include/stc.h
+    ${CMAKE_SOURCE_DIR}/include/stc_internal.h
+    DESTINATION ${INCLUDE_DIR}/network
+    )
diff --git a/include/stc.h b/include/stc.h
new file mode 100755 (executable)
index 0000000..6de29d0
--- /dev/null
@@ -0,0 +1,886 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __TIZEN_STC_H__
+#define __TIZEN_STC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file stc.h
+ */
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#include <tizen.h>
+#include <time.h>
+#include <inttypes.h>
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_MODULE
+ * @{
+ */
+
+/**
+ * @brief The smart traffic control handle.
+ * @since_tizen 4.0
+ */
+typedef void *stc_h;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_NETWORK_STATISTICS_MODULE
+ * @{
+ */
+
+/**
+ * @brief The statistics rule handle.
+ * @since_tizen 4.0
+ */
+typedef void *stc_stats_rule_h;
+
+/**
+ * @brief The statistics information handle.
+ * @since_tizen 4.0
+ */
+typedef void *stc_stats_info_h;
+
+
+/*****************************************************************************
+ *  Enumeration
+ *****************************************************************************/
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_MODULE
+ * @{
+ */
+
+#ifndef TIZEN_ERROR_STC
+#define TIZEN_ERROR_STC -0x02F80000
+#endif
+
+/**
+ * @brief Enumeration for Smart Traffic Control (STC) error type.
+ * @since_tizen 4.0
+ */
+typedef enum {
+       STC_ERROR_NONE = TIZEN_ERROR_NONE,                           /**< Successful */
+       STC_ERROR_NOT_PERMITTED = TIZEN_ERROR_NOT_PERMITTED,         /**< Operation not permitted(1) */
+       STC_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,         /**< Out of memory(12) */
+       STC_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied(13) */
+       STC_ERROR_RESOURCE_BUSY = TIZEN_ERROR_RESOURCE_BUSY,         /**< Device or resource busy(16) */
+       STC_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation(38) */
+       STC_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter(22) */
+       STC_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED,         /**< Not supported */
+
+       STC_ERROR_OPERATION_FAILED = TIZEN_ERROR_STC|0x01,           /**< Operation failed */
+       STC_ERROR_NOT_INITIALIZED = TIZEN_ERROR_STC|0x02,            /**< Not initialized */
+       STC_ERROR_ALREADY_INITIALIZED = TIZEN_ERROR_STC|0x03,        /**< Already initialized */
+       STC_ERROR_IN_PROGRESS = TIZEN_ERROR_STC|0x04,                /**< In progress */
+} stc_error_e;
+
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_MANAGER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for time period.
+ * @since_tizen 4.0
+ */
+typedef enum {
+       STC_TIME_PERIOD_UNKNOWN = 0,
+       STC_TIME_PERIOD_HOUR = 3600,
+       STC_TIME_PERIOD_DAY = 86400,
+       STC_TIME_PERIOD_WEEK = 604800,
+       STC_TIME_PERIOD_MONTH = 2419200,
+} stc_time_period_e;
+
+/**
+ * @brief Enumeration for network interface type.
+ * @since_tizen 4.0
+ */
+typedef enum {
+       STC_IFACE_UNKNOWN,      /**< Unknown interface */
+       STC_IFACE_DATACALL,     /**< Mobile data */
+       STC_IFACE_WIFI,         /**< Wifi data */
+       STC_IFACE_WIRED,        /**< Wired interface */
+       STC_IFACE_BLUETOOTH,    /**< Bluetooth interface */
+       STC_IFACE_ALL,          /**< Enumerate all network interface types */
+} stc_iface_type_e;
+
+/**
+ * @brief Enumeration for network roaming type.
+ * @since_tizen 4.0
+ */
+typedef enum {
+       STC_ROAMING_UNKNOWN,     /**< Roaming unknown */
+       STC_ROAMING_ENABLED,     /**< In roaming */
+       STC_ROAMING_DISABLED,    /**< Not in roaming */
+} stc_roaming_type_e;
+
+/**
+ * @brief Enumeration for hardware network protocol type.
+ * @since_tizen 4.0
+ */
+typedef enum {
+       STC_PROTOCOL_UNKNOWN,               /**< Network unknown */
+       STC_PROTOCOL_DATACALL_NOSVC,        /**< Network no service */
+       STC_PROTOCOL_DATACALL_EMERGENCY,    /**< Network emergency */
+       STC_PROTOCOL_DATACALL_SEARCH,       /**< Network search 1900 */
+       STC_PROTOCOL_DATACALL_2G,           /**< Network 2G */
+       STC_PROTOCOL_DATACALL_2_5G,         /**< Network 2.5G */
+       STC_PROTOCOL_DATACALL_2_5G_EDGE,    /**< Network EDGE */
+       STC_PROTOCOL_DATACALL_3G,           /**< Network UMTS */
+       STC_PROTOCOL_DATACALL_HSDPA,        /**< Network HSDPA */
+       STC_PROTOCOL_DATACALL_LTE,          /**< Network LTE */
+} stc_protocol_type_e;
+
+/**
+ * @brief Enumeration for monitored process state.
+ * @since_tizen 4.0
+ */
+typedef enum {
+       STC_PROCESS_STATE_UNKNOWN = 0,
+       STC_PROCESS_STATE_FOREGROUND = 1 << 1,      /** < Foreground state */
+       STC_PROCESS_STATE_BACKGROUND = 1 << 2,      /** < Background state */
+} stc_process_state_e;
+
+/**
+ * @brief Enumeration for network connection period type.
+ * @details Last received/sent mean counting data from the first connection of each interface.
+ * @since_tizen 4.0
+ */
+typedef enum {
+       STC_CONN_PERIOD_UNKNOWN,                /**< Unknown period */
+       STC_CONN_PERIOD_LAST_RECEIVED_DATA,     /**< Last received data */
+       STC_CONN_PERIOD_LAST_SENT_DATA,         /**< Last sent data */
+       STC_CONN_PERIOD_TOTAL_RECEIVED_DATA,    /**< Total received data */
+       STC_CONN_PERIOD_TOTAL_SENT_DATA,        /**< Total sent data */
+} stc_conn_period_e;
+
+/**
+ * @brief Enumeration for return type of the callback.
+ * @since_tizen 4.0
+ */
+typedef enum {
+       STC_CALLBACK_CANCEL,        /**< Cancel */
+       STC_CALLBACK_CONTINUE,      /**< Continue */
+} stc_callback_ret_e;
+
+
+/*****************************************************************************
+ *  Callback functions
+ *****************************************************************************/
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_MANAGER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called for each available statistics information.
+ * @since_tizen 4.0
+ *
+ * @param[in] result        The result, one of:\n
+ *   #STC_ERROR_INVALID_OPERATION   No reply\n
+ *   #STC_ERROR_OPERATION_FAILED    Operation failed\n
+ *   #STC_ERROR_PERMISSION_DENIED   Access or permission denied
+ * @param[in] info          The statistics information handle
+ * @param[in] user_data     The user data passed from the statistics provider function
+ * @return  #STC_CALLBACK_CONTINUE to continue with the next iteration of the loop,
+ * otherwise #STC_CALLBACK_CANCEL to break out of the loop
+ *
+ * @pre stc_get_stats() will invoke this callback.
+ * @pre stc_foreach_stats() will invoke this callback.
+ * @pre stc_get_total_stats() will invoke this callback.
+ * @see stc_stats_info_get_app_id()
+ * @see stc_stats_info_get_iface_name()
+ * @see stc_stats_info_get_imsi()
+ * @see stc_stats_info_get_time_interval()
+ * @see stc_stats_info_get_iface_type()
+ * @see stc_stats_info_get_counter()
+ * @see stc_stats_info_get_roaming_type()
+ * @see stc_stats_info_get_protocol_type()
+ * @see stc_stats_info_get_process_state()
+ * @see stc_get_stats()
+ * @see stc_foreach_stats()
+ * @see stc_get_total_stats()
+ */
+typedef stc_callback_ret_e (*stc_stats_info_cb)(
+               stc_error_e result, stc_stats_info_h info, void *user_data);
+
+/**
+ * @}
+ */
+
+
+/*****************************************************************************
+ *  Core API functions
+ *****************************************************************************/
+
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_MODULE
+ * @{
+ */
+
+/**
+ * @brief Initializes STC (Smart Traffic Control).
+ * @since_tizen 4.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @remarks You must release @a handle using stc_deinitialize().
+ *
+ * @param[out] stc The STC handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED       Permission denied
+ *
+ * @see stc_h
+ * @see stc_deinitialize()
+ */
+int stc_initialize(stc_h *stc);
+
+/**
+ * @brief Deinitializes STC.
+ * @since_tizen 4.0
+ *
+ * @param[in] stc The STC handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_h
+ * @see stc_initialize()
+ */
+int stc_deinitialize(stc_h stc);
+
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_MANAGER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Gets the statistics information an application matched rule asynchronously.
+ * @since_tizen 4.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] stc           The STC handle
+ * @param[in] rule          The statistics rule handle
+ * @param[in] info_cb       The callback is called for each application
+ * that used network in between timestamps specified
+ * @param[in] user_data     The user data passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED       Permission denied
+ *
+ * @see stc_h
+ * @see stc_stats_rule_h
+ * @see stc_initialize()
+ * @see stc_stats_rule_create()
+ * @see stc_stats_rule_destroy()
+ * @see stc_stats_rule_set_app_id()
+ * @see stc_stats_rule_set_time_interval()
+ * @see stc_stats_rule_set_iface_type()
+ * @see stc_stats_rule_set_time_period()
+ * @see stc_stats_rule_get_app_id()
+ * @see stc_stats_rule_get_time_interval()
+ * @see stc_stats_rule_get_iface_type()
+ * @see stc_stats_rule_get_time_period()
+ * @see stc_stats_info_cb()
+ * @see stc_foreach_stats()
+ * @see stc_get_total_stats()
+ */
+int stc_get_stats(stc_h stc, stc_stats_rule_h rule,
+               stc_stats_info_cb info_cb,      void *user_data);
+
+/**
+ * @brief Gets the statistics information of each application asynchronously.
+ * @details The callback is called for each application that used network
+ * in between timestamps specified.
+ * If interface name is not specified, each application will only appear
+ * once with the total traffic used over all interfaces.
+ *
+ * @since_tizen 4.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] stc           The STC handle
+ * @param[in] rule          The statistics rule handle
+ * @param[in] info_cb The callback is called for each application
+ * that used network in between timestamps specified
+ * @param[in] user_data     The user data passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED       Permission denied
+ *
+ * @see stc_h
+ * @see stc_stats_rule_h
+ * @see stc_initialize()
+ * @see stc_stats_rule_create()
+ * @see stc_stats_rule_destroy()
+ * @see stc_stats_rule_set_app_id()
+ * @see stc_stats_rule_set_time_interval()
+ * @see stc_stats_rule_set_iface_type()
+ * @see stc_stats_rule_set_time_period()
+ * @see stc_stats_rule_get_app_id()
+ * @see stc_stats_rule_get_time_interval()
+ * @see stc_stats_rule_get_iface_type()
+ * @see stc_stats_rule_get_time_period()
+ * @see stc_stats_info_cb()
+ * @see stc_get_stats()
+ * @see stc_get_total_stats()
+ */
+int stc_foreach_stats(stc_h stc, stc_stats_rule_h rule,
+               stc_stats_info_cb info_cb, void *user_data);
+
+/**
+ * @brief Gets the total statistics information by interface type asynchronously.
+ * @since_tizen 4.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ *
+ * @param[in] stc           The STC handle
+ * @param[in] rule          The statistics rule handle
+ * @param[in] info_cb       The callback is called for each application
+ * that used network in between timestamps specified
+ * @param[in] user_data     The user data passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED       Permission denied
+ *
+ * @see stc_h
+ * @see stc_stats_rule_h
+ * @see stc_initialize()
+ * @see stc_stats_rule_create()
+ * @see stc_stats_rule_destroy()
+ * @see stc_stats_rule_set_app_id()
+ * @see stc_stats_rule_set_time_interval()
+ * @see stc_stats_rule_set_iface_type()
+ * @see stc_stats_rule_set_time_period()
+ * @see stc_stats_rule_get_app_id()
+ * @see stc_stats_rule_get_time_interval()
+ * @see stc_stats_rule_get_iface_type()
+ * @see stc_stats_rule_get_time_period()
+ * @see stc_stats_info_cb()
+ * @see stc_get_stats()
+ * @see stc_foreach_stats()
+ */
+int stc_get_total_stats(stc_h stc, stc_stats_rule_h rule,
+               stc_stats_info_cb info_cb,      void *user_data);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_NETWORK_STATISTICS_MODULE
+ * @{
+ */
+
+
+/**
+ * @brief Creates the statistics rule handle.
+ * @since_tizen 4.0
+ * @remarks You must release @a handle using stc_stats_rule_destroy().
+ *
+ * @param[in] stc           The STC handle
+ * @param[out] rule         The statistics rule handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_h
+ * @see stc_stats_rule_h
+ * @see stc_initialize()
+ * @see stc_stats_rule_destroy()
+ */
+int stc_stats_rule_create(stc_h stc, stc_stats_rule_h *rule);
+
+/**
+ * @brief Destroys the statistics rule handle.
+ * @since_tizen 4.0
+ *
+ * @param[in] rule          The statistics rule handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_rule_h
+ * @see stc_stats_rule_create()
+ */
+int stc_stats_rule_destroy(stc_stats_rule_h rule);
+
+/**
+ * @brief Sets the application ID for statistics rule.
+ * @since_tizen 4.0
+ *
+ * @param[in] rule          The statistics rule handle
+ * @param[in] app_id        The application ID
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_rule_h
+ * @see stc_stats_rule_create()
+ * @see stc_stats_rule_destroy()
+ * @see stc_stats_rule_get_app_id()
+ */
+int stc_stats_rule_set_app_id(stc_stats_rule_h rule,
+               const char *app_id);
+
+/**
+ * @brief Sets the time interval for statistics rule.
+ * @since_tizen 4.0
+ *
+ * @param[in] rule          The statistics rule handle
+ * @param[in] from          The beginning of the time interval
+ * @param[in] to            The end of the time interval
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_rule_h
+ * @see stc_stats_rule_create()
+ * @see stc_stats_rule_destroy()
+ * @see stc_stats_rule_get_time_interval()
+ */
+int stc_stats_rule_set_time_interval(stc_stats_rule_h rule,
+               time_t from, time_t to);
+
+/**
+ * @brief Sets the interface type for statistics rule.
+ * @since_tizen 4.0
+ *
+ * @param[in] rule          The stats rule handle
+ * @param[in] iface_type    The interface type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_rule_h
+ * @see stc_iface_type_e
+ * @see stc_stats_rule_create()
+ * @see stc_stats_rule_destroy()
+ * @see stc_stats_rule_get_iface_type()
+ */
+int stc_stats_rule_set_iface_type(stc_stats_rule_h rule,
+               stc_iface_type_e iface_type);
+
+/**
+ * @brief Sets the time period for statistics rule.
+ * @since_tizen 4.0
+ *
+ * @param[in] rule          The statistics rule handle
+ * @param[in] time_period   The time period
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_rule_h
+ * @see stc_time_period_e
+ * @see stc_stats_rule_create()
+ * @see stc_stats_rule_destroy()
+ * @see stc_stats_rule_get_time_period()
+ */
+int stc_stats_rule_set_time_period(stc_stats_rule_h rule,
+               stc_time_period_e time_period);
+
+/**
+ * @brief Gets the application ID for statistics rule.
+ * @since_tizen 4.0
+ * @remarks You must release @a app_id using free().
+ *
+ * @param[in] rule          The statistics rule handle
+ * @param[out] app_id       The application ID
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_rule_h
+ * @see stc_stats_rule_create()
+ * @see stc_stats_rule_destroy()
+ * @see stc_stats_rule_set_app_id()
+ */
+int stc_stats_rule_get_app_id(stc_stats_rule_h rule, char **app_id);
+
+/**
+ * @brief Gets the time interval for statistics rule.
+ * @since_tizen 4.0
+ *
+ * @param[in] rule          The statistics rule handle
+ * @param[out] from         The beginning of the time interval
+ * @param[out] to           The end of the time interval
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_rule_h
+ * @see stc_stats_rule_create()
+ * @see stc_stats_rule_destroy()
+ * @see stc_stats_rule_set_time_interval()
+ */
+int stc_stats_rule_get_time_interval(stc_stats_rule_h rule,
+               time_t *from, time_t *to);
+
+/**
+ * @brief Gets the interface type for statistics rule.
+ * @since_tizen 4.0
+ *
+ * @param[in] rule          The statistics rule handle
+ * @param[out] iface_type   The interface type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_rule_h
+ * @see stc_iface_type_e
+ * @see stc_stats_rule_create()
+ * @see stc_stats_rule_destroy()
+ * @see stc_stats_rule_set_iface_type()
+ */
+int stc_stats_rule_get_iface_type(stc_stats_rule_h rule,
+               stc_iface_type_e *iface_type);
+
+/**
+ * @brief Gets the time period for statistics rule.
+ * @since_tizen 4.0
+ *
+ * @param[in] rule          The statistics rule handle
+ * @param[out] time_period  The time period
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_rule_h
+ * @see stc_time_period_e
+ * @see stc_stats_rule_create()
+ * @see stc_stats_rule_destroy()
+ * @see stc_stats_rule_set_time_period()
+ */
+int stc_stats_rule_get_time_period(stc_stats_rule_h rule,
+               stc_time_period_e *time_period);
+
+/**
+ * @brief Gets the application ID from statistics information.
+ * @since_tizen 4.0
+ * @remarks You must release @a app_id using free().
+ *
+ * @param[in] info          The statistics information handle
+ * @param[out] app_id       The application ID
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_info_h
+ * @see stc_stats_info_cb()
+ */
+int stc_stats_info_get_app_id(stc_stats_info_h info, char **app_id);
+
+/**
+ * @brief Gets the interface name from statistics information.
+ * @since_tizen 4.0
+ * @remarks You must release @a iface_name using free().
+ *
+ * @param[in] info          The statistics information handle
+ * @param[out] iface_name   The interface name
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_info_h
+ * @see stc_stats_info_cb()
+ */
+int stc_stats_info_get_iface_name(stc_stats_info_h info, char **iface_name);
+
+/**
+ * @brief Gets the time interval from statistics information.
+ * @since_tizen 4.0
+ *
+ * @param[in] info          The statistics information handle
+ * @param[out] from         The beginning of the time interval
+ * @param[out] to           The end of the time interval
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_info_h
+ * @see stc_stats_info_cb()
+ */
+int stc_stats_info_get_time_interval(stc_stats_info_h info,
+               time_t *from, time_t *to);
+
+/**
+ * @brief Gets the interface type from statistics information.
+ * @since_tizen 4.0
+ *
+ * @param[in] info          The statistics information handle
+ * @param[out] iface_type   The interface type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_info_h
+ * @see stc_iface_type_e
+ * @see stc_stats_info_cb()
+ */
+int stc_stats_info_get_iface_type(stc_stats_info_h info,
+               stc_iface_type_e *iface_type);
+
+/**
+ * @brief Gets the counters from statistics information.
+ * @since_tizen 4.0
+ *
+ * @param[in] info          The statistics information handle
+ * @param[out] incoming     The incoming counter
+ * @param[out] outgoing     The outgoing counter
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_info_h
+ * @see stc_stats_info_cb()
+ */
+int stc_stats_info_get_counter(stc_stats_info_h info,
+               uint64_t *incoming, uint64_t *outgoing);
+
+/**
+ * @brief Gets the roaming type from statistics information.
+ * @since_tizen 4.0
+ *
+ * @param[in] info          The statistics information handle
+ * @param[out] roaming_type The roaming type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_info_h
+ * @see stc_roaming_type_e
+ * @see stc_stats_info_cb()
+ */
+int stc_stats_info_get_roaming_type(stc_stats_info_h info,
+               stc_roaming_type_e *roaming_type);
+
+/**
+ * @brief Gets the protocol type from statistics information.
+ * @since_tizen 4.0
+ *
+ * @param[in] info          The statistics information handle
+ * @param[out] protocol     The protocol type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_info_h
+ * @see stc_protocol_type_e
+ * @see stc_stats_info_cb()
+ */
+int stc_stats_info_get_protocol_type(stc_stats_info_h info,
+               stc_protocol_type_e *protocol);
+
+/**
+ * @brief Gets the process state from statistics information.
+ * @since_tizen 4.0
+ *
+ * @param[in] info          The statistics information handle
+ * @param[out] process      The process state
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ *
+ * @see stc_stats_info_h
+ * @see stc_process_state_e
+ * @see stc_stats_info_cb()
+ */
+int stc_stats_info_get_process_state(stc_stats_info_h info,
+               stc_process_state_e *state);
+
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_STC_H__ */
diff --git a/include/stc_internal.h b/include/stc_internal.h
new file mode 100755 (executable)
index 0000000..e502a55
--- /dev/null
@@ -0,0 +1,1499 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __TIZEN_STC_INTERNAL_H__
+#define __TIZEN_STC_INTERNAL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file stc_internal.h
+ */
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#include <tizen.h>
+#include <time.h>
+#include <inttypes.h>
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_NETWORK_STATISTICS_MODULE
+ * @{
+ */
+
+/**
+ * @brief The reset rule handle.
+ * @since_tizen 4.0
+ */
+typedef void *stc_reset_rule_h;
+
+
+/**
+* @}
+*/
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_RESTRICTION_MODULE
+ * @{
+ */
+
+/**
+ * @brief The restriction rule handle.
+ * @since_tizen 4.0
+ */
+typedef void *stc_restriction_rule_h;
+
+/**
+ * @brief The restriction information handle.
+ * @since_tizen 4.0
+ */
+typedef void *stc_restriction_info_h;
+
+/**
+* @}
+*/
+
+/*****************************************************************************
+ *  Enumeration
+ *****************************************************************************/
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_RESTRICTION_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for network restriction status.
+ * @since_tizen 4.0
+ */
+typedef enum {
+       STC_RESTRICTION_UNKNOWN,
+       STC_RESTRICTION_ACTIVATED,      /** < restriction has been activated */
+       STC_RESTRICTION_REMOVED,        /** < restriction has been removed */
+       STC_RESTRICTION_EXCLUDED,       /** < restriction has been excluded */
+       STC_RESTRICTION_BACKGROUND,     /** < background restriction has been activated */
+       STC_RESTRICTION_LAST_ELEM,
+} stc_restriction_status_e;
+
+/**
+* @}
+*/
+
+/*****************************************************************************
+ *  Callback functions
+ *****************************************************************************/
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_MANAGER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Called for enumerate restriction information.
+ * @since_tizen 4.0
+ *
+ * @param[in] result           The result
+ * @param[in] info                     The restriction information handle
+ * @param[in] user_data        The user data passed from the callback registration function
+ * @return     @c STC_CALLBACK_CONTINUE to continue with the next iteration of the loop,
+ *                     otherwise @c STC_CALLBACK_CANCEL to break out of the loop
+ *
+ * @pre        stc_get_restriction() will invoke this callback.
+ * @pre        stc_foreach_restriction() will invoke this callback.
+ * @see stc_restriction_info_get_app_id()
+ * @see stc_restriction_info_get_iface_name()
+ * @see stc_restriction_info_get_imsi()
+ * @see stc_restriction_info_get_status()
+ * @see stc_restriction_info_get_iface_type()
+ * @see stc_restriction_info_get_limit()
+ * @see stc_restriction_info_get_warning_limit()
+ * @see stc_restriction_info_get_roaming_type()
+ * @see        stc_get_restriction()
+ * @see        stc_foreach_restriction()
+ */
+typedef stc_callback_ret_e(*stc_restriction_info_cb)(
+               stc_error_e result, stc_restriction_info_h info, void *user_data);
+
+/**
+* @}
+*/
+
+
+/*****************************************************************************
+ *  Core API functions
+ *****************************************************************************/
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_MANAGER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Resets stats information..
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] stc The stc handle
+ * @param[in] rule The reset rule handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_h
+ * @see #stc_reset_rule_h
+ * @see stc_initialize()
+ * @see stc_reset_rule_create()
+ * @see stc_reset_rule_destroy()
+ * @see stc_reset_rule_set_app_id()
+ * @see stc_reset_rule_set_imsi()
+ * @see stc_reset_rule_set_iface_type()
+ * @see stc_reset_rule_set_time_interval()
+ * @see stc_reset_rule_set_connection_period()
+ * @see stc_reset_rule_get_app_id()
+ * @see stc_reset_rule_get_imsi()
+ * @see stc_reset_rule_get_iface_type()
+ * @see stc_reset_rule_get_time_interval()
+ * @see stc_reset_rule_get_connection_period()
+ */
+int stc_reset_stats(stc_h stc, stc_reset_rule_h rule);
+
+
+/**
+ * @brief Sets the restriction for application.
+ * @details Sets and applies restriction for application.
+ *                     It will creates new restriction or modify existing.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] stc The stc handle
+ * @param[in] rule The restriction rule handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_h
+ * @see #stc_restriction_rule_h
+ * @see stc_initialize()
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_app_id()
+ * @see stc_restriction_rule_set_iface_name()
+ * @see stc_restriction_rule_set_iface_type()
+ * @see stc_restriction_rule_set_limit()
+ * @see stc_restriction_rule_set_warning_limit()
+ * @see stc_restriction_rule_set_roaming_type()
+ * @see stc_restriction_rule_set_imsi()
+ * @see stc_restriction_rule_get_app_id()
+ * @see stc_restriction_rule_get_iface_type()
+ * @see stc_restriction_rule_get_limit()
+ * @see stc_restriction_rule_get_warning_limit()
+ * @see stc_restriction_rule_get_roaming_type()
+ * @see stc_restriction_rule_get_imsi()
+ * @see stc_restriction_rule_get_process_state()
+ * @see stc_get_restriction()
+ * @see stc_foreach_restriction()
+ * @see stc_get_restriction_status()
+ * @see stc_unset_restriction()
+ * @see stc_exclude_restriction()
+ */
+int stc_set_restriction(stc_h stc, stc_restriction_rule_h rule);
+
+/**
+ * @brief Excludes the application from network restriction.
+ * @details Excluded application will be granted to
+ *                     internet access, in case of whole network restriction.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] stc The stc handle
+ * @param[in] rule The restriction rule handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_h
+ * @see #stc_restriction_rule_h
+ * @see stc_initialize()
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_app_id()
+ * @see stc_restriction_rule_set_iface_name()
+ * @see stc_restriction_rule_set_iface_type()
+ * @see stc_restriction_rule_set_limit()
+ * @see stc_restriction_rule_set_warning_limit()
+ * @see stc_restriction_rule_set_roaming_type()
+ * @see stc_restriction_rule_set_imsi()
+ * @see stc_restriction_rule_get_app_id()
+ * @see stc_restriction_rule_get_iface_type()
+ * @see stc_restriction_rule_get_limit()
+ * @see stc_restriction_rule_get_warning_limit()
+ * @see stc_restriction_rule_get_roaming_type()
+ * @see stc_restriction_rule_get_imsi()
+ * @see stc_restriction_rule_get_process_state()
+ * @see stc_set_restriction()
+ * @see stc_get_restriction()
+ * @see stc_foreach_restriction()
+ * @see stc_get_restriction_status()
+ * @see stc_unset_restriction()
+ */
+int stc_exclude_restriction(stc_h stc, stc_restriction_rule_h rule);
+
+/**
+ * @brief Unsets the existing restriction for application.
+ * @details Unsets the existing restriction for application.
+ *                     It will delete restriction rule in kernel.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] stc The stc handle
+ * @param[in] rule The restriction rule handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_h
+ * @see #stc_restriction_rule_h
+ * @see stc_initialize()
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_app_id()
+ * @see stc_restriction_rule_set_iface_name()
+ * @see stc_restriction_rule_set_iface_type()
+ * @see stc_restriction_rule_set_limit()
+ * @see stc_restriction_rule_set_warning_limit()
+ * @see stc_restriction_rule_set_roaming_type()
+ * @see stc_restriction_rule_set_imsi()
+ * @see stc_restriction_rule_get_app_id()
+ * @see stc_restriction_rule_get_iface_type()
+ * @see stc_restriction_rule_get_limit()
+ * @see stc_restriction_rule_get_warning_limit()
+ * @see stc_restriction_rule_get_roaming_type()
+ * @see stc_restriction_rule_get_imsi()
+ * @see stc_restriction_rule_get_process_state()
+ * @see stc_set_restriction()
+ * @see stc_get_restriction()
+ * @see stc_foreach_restriction()
+ * @see stc_get_restriction_status()
+ * @see stc_exclude_restriction()
+ */
+int stc_unset_restriction(stc_h stc, stc_restriction_rule_h rule);
+
+/**
+ * @brief Gets the restriction information per application.
+ * @details The callback is called for each application that applied restriction.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] stc The stc handle
+ * @param[in] rule The restriction rule handle
+ * @param[in] info_cb The callback is called for each application
+ *                     that applied restriction in interface specified
+ * @param[in] user_data User data will be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_h
+ * @see #stc_restriction_rule_h
+ * @see stc_initialize()
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_app_id()
+ * @see stc_restriction_rule_set_iface_name()
+ * @see stc_restriction_rule_set_iface_type()
+ * @see stc_restriction_rule_set_limit()
+ * @see stc_restriction_rule_set_warning_limit()
+ * @see stc_restriction_rule_set_roaming_type()
+ * @see stc_restriction_rule_set_imsi()
+ * @see stc_restriction_rule_get_app_id()
+ * @see stc_restriction_rule_get_iface_type()
+ * @see stc_restriction_rule_get_limit()
+ * @see stc_restriction_rule_get_warning_limit()
+ * @see stc_restriction_rule_get_roaming_type()
+ * @see stc_restriction_rule_get_imsi()
+ * @see stc_restriction_rule_get_process_state()
+ * @see stc_restriction_info_cb()
+ * @see stc_set_restriction()
+ * @see stc_foreach_restriction()
+ * @see stc_get_restriction_status()
+ * @see stc_unset_restriction()
+ * @see stc_exclude_restriction()
+ */
+int stc_get_restriction(stc_h stc, stc_restriction_rule_h rule,
+               stc_restriction_info_cb info_cb, void *user_data);
+
+/**
+ * @brief Gets the restriction information of all application.
+ * @details The callback is called for each application that applied restriction.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] stc The stc handle
+ * @param[in] rule The restriction rule handle
+ * @param[in] info_cb The callback is called for each application
+ *                     that applied restriction in interface specified
+ * @param[in] user_data User data will be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_h
+ * @see #stc_restriction_rule_h
+ * @see stc_initialize()
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_app_id()
+ * @see stc_restriction_rule_set_iface_name()
+ * @see stc_restriction_rule_set_iface_type()
+ * @see stc_restriction_rule_set_limit()
+ * @see stc_restriction_rule_set_warning_limit()
+ * @see stc_restriction_rule_set_roaming_type()
+ * @see stc_restriction_rule_set_imsi()
+ * @see stc_restriction_rule_get_app_id()
+ * @see stc_restriction_rule_get_iface_type()
+ * @see stc_restriction_rule_get_limit()
+ * @see stc_restriction_rule_get_warning_limit()
+ * @see stc_restriction_rule_get_roaming_type()
+ * @see stc_restriction_rule_get_imsi()
+ * @see stc_restriction_rule_get_process_state()
+ * @see stc_restriction_info_cb()
+ * @see stc_set_restriction()
+ * @see stc_get_restriction()
+ * @see stc_get_restriction_status()
+ * @see stc_unset_restriction()
+ * @see stc_exclude_restriction()
+ */
+int stc_foreach_restriction(stc_h stc, stc_restriction_rule_h rule,
+               stc_restriction_info_cb info_cb, void *user_data);
+
+/**
+ * @brief Gets the restriction status information.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] stc The stc handle
+ * @param[in] rule The restriction rule handle
+ * @param[out] status The restriction status
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_h
+ * @see #stc_restriction_rule_h
+ * @see #stc_restriction_status_e
+ * @see stc_initialize()
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_app_id()
+ * @see stc_restriction_rule_set_iface_name()
+ * @see stc_restriction_rule_set_iface_type()
+ * @see stc_restriction_rule_set_limit()
+ * @see stc_restriction_rule_set_warning_limit()
+ * @see stc_restriction_rule_set_roaming_type()
+ * @see stc_restriction_rule_set_imsi()
+ * @see stc_restriction_rule_get_app_id()
+ * @see stc_restriction_rule_get_iface_type()
+ * @see stc_restriction_rule_get_limit()
+ * @see stc_restriction_rule_get_warning_limit()
+ * @see stc_restriction_rule_get_roaming_type()
+ * @see stc_restriction_rule_get_imsi()
+ * @see stc_restriction_rule_get_process_state()
+ * @see stc_set_restriction()
+ * @see stc_get_restriction()
+ * @see stc_foreach_restriction()
+ * @see stc_unset_restriction()
+ * @see stc_exclude_restriction()
+ */
+int stc_get_restriction_status(stc_h stc, stc_restriction_rule_h rule,
+               stc_restriction_status_e *status);
+
+/**
+* @}
+*/
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_NETWORK_STATISTICS_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates the reset rule handle.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ * @remarks You must release @a handle using stc_reset_rule_destroy().
+ *
+ * @param[in] stc The stc handle
+ * @param[out] rule The reset rule handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_h
+ * @see #stc_reset_rule_h
+ * @see stc_initialize()
+ * @see stc_reset_rule_destroy()
+ */
+int stc_reset_rule_create(stc_h stc, stc_reset_rule_h *rule);
+
+/**
+ * @brief Destroys the reset rule handle.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The reset rule handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_reset_rule_h
+ * @see stc_reset_rule_create()
+ */
+int stc_reset_rule_destroy(stc_reset_rule_h rule);
+
+/**
+ * @brief Sets the application ID for reset rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The reset rule handle
+ * @param[in] app_id The application ID
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_reset_rule_h
+ * @see stc_reset_rule_create()
+ * @see stc_reset_rule_destroy()
+ * @see stc_reset_rule_get_app_id()
+ */
+int stc_reset_rule_set_app_id(stc_reset_rule_h rule, const char *app_id);
+
+/**
+ * @brief Sets the imsi for reset rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The reset rule handle
+ * @param[in] imsi The imsi
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_reset_rule_h
+ * @see stc_reset_rule_create()
+ * @see stc_reset_rule_destroy()
+ * @see stc_reset_rule_get_imsi()
+ */
+int stc_reset_rule_set_imsi(stc_reset_rule_h rule, const char *imsi);
+
+/**
+ * @brief Sets the interface type for reset rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The reset rule handle
+ * @param[in] iface_type The interface type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_reset_rule_h
+ * @see #stc_iface_type_e
+ * @see stc_reset_rule_create()
+ * @see stc_reset_rule_destroy()
+ * @see stc_reset_rule_get_iface_type()
+ */
+int stc_reset_rule_set_iface_type(stc_reset_rule_h rule,
+               stc_iface_type_e iface_type);
+
+/**
+ * @brief Sets the time interval for reset rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The reset rule handle
+ * @param[in] from The time interval from
+ * @param[in] to The time interval to
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_reset_rule_h
+ * @see stc_reset_rule_create()
+ * @see stc_reset_rule_destroy()
+ * @see stc_reset_rule_get_time_interval()
+ */
+int stc_reset_rule_set_time_interval(stc_reset_rule_h rule,
+               time_t from, time_t to);
+
+/**
+ * @brief Sets the connection period for reset rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The reset rule handle
+ * @param[in] period The connection period
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_reset_rule_h
+ * @see #stc_conn_period_e
+ * @see stc_reset_rule_create()
+ * @see stc_reset_rule_destroy()
+ * @see stc_reset_rule_get_connection_period()
+ */
+int stc_reset_rule_set_connection_period(stc_reset_rule_h rule,
+               stc_conn_period_e period);
+
+/**
+ * @brief Gets the application ID for reset.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The reset rule handle
+ * @param[out] app_id The application ID
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_reset_rule_h
+ * @see stc_reset_rule_create()
+ * @see stc_reset_rule_destroy()
+ * @see stc_reset_rule_set_app_id()
+ */
+int stc_reset_rule_get_app_id(stc_reset_rule_h rule, char **app_id);
+
+/**
+ * @brief Gets the imsi for reset rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The reset rule handle
+ * @param[out] imsi The imsi
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_reset_rule_h
+ * @see stc_reset_rule_create()
+ * @see stc_reset_rule_destroy()
+ * @see stc_reset_rule_set_imsi()
+ */
+int stc_reset_rule_get_imsi(stc_reset_rule_h rule, char **imsi);
+
+/**
+ * @brief Gets the interface type for reset rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The reset rule handle
+ * @param[out] iface_type The interface type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_reset_rule_h
+ * @see #stc_iface_type_e
+ * @see stc_reset_rule_create()
+ * @see stc_reset_rule_destroy()
+ * @see stc_reset_rule_set_iface_type()
+ */
+int stc_reset_rule_get_iface_type(stc_reset_rule_h rule,
+               stc_iface_type_e *iface_type);
+
+/**
+ * @brief Gets the time interval for reset rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The reset rule handle
+ * @param[out] from The time interval from
+ * @param[out] to The time interval to
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_reset_rule_h
+ * @see stc_reset_rule_create()
+ * @see stc_reset_rule_destroy()
+ * @see stc_reset_rule_set_time_interval()
+ */
+int stc_reset_rule_get_time_interval(stc_reset_rule_h rule,
+               time_t *from, time_t *to);
+
+/**
+ * @brief Gets the connection period for reset rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The reset rule handle
+ * @param[out] period The connection period
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_reset_rule_h
+ * @see #stc_conn_period_e
+ * @see stc_reset_rule_create()
+ * @see stc_reset_rule_destroy()
+ * @see stc_reset_rule_set_connection_period()
+ */
+int stc_reset_rule_get_connection_period(stc_reset_rule_h rule,
+               stc_conn_period_e *period);
+
+
+/**
+* @}
+*/
+
+/**
+ * @addtogroup CAPI_NETWORK_STC_RESTRICTION_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates the restriction rule handle.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ * @remarks You must release @a handle using stc_restriction_rule_destroy().
+ *
+ * @param[in] stc The stc handle
+ * @param[out] rule The restriction rule handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_h
+ * @see #stc_restriction_rule_h
+ * @see stc_initialize()
+ * @see stc_restriction_rule_destroy()
+ */
+int stc_restriction_rule_create(stc_h stc, stc_restriction_rule_h *rule);
+
+/**
+ * @brief Destroys the restriction rule handle.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ */
+int stc_restriction_rule_destroy(stc_restriction_rule_h rule);
+
+/**
+ * @brief Sets the application ID for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[in] app_id The application ID
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_get_app_id()
+ */
+int stc_restriction_rule_set_app_id(stc_restriction_rule_h rule,
+               const char *app_id);
+
+/**
+ * @brief Sets the interface name for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[in] iface_name The interface name
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see #stc_iface_type_e
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_get_iface_name()
+ */
+int stc_restriction_rule_set_iface_name(       stc_restriction_rule_h rule,
+               const char *iface_name);
+
+/**
+ * @brief Sets the interface type for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[in] iface_type The interface type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see #stc_iface_type_e
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_get_iface_type()
+ */
+int stc_restriction_rule_set_iface_type(stc_restriction_rule_h rule,
+               stc_iface_type_e iface_type);
+
+/**
+ * @brief Sets the limit for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[in] rx_limit The receive limit
+ * @param[in] tx_limit The send limit
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_get_limit()
+ */
+int stc_restriction_rule_set_limit(stc_restriction_rule_h rule,
+               uint64_t rx_limit, uint64_t tx_limit);
+
+/**
+ * @brief Sets the warning limit for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[in] rx_warning_limit The receive warning limit
+ * @param[in] tx_warning_limit The send warning limit
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_get_warning_limit()
+ */
+int stc_restriction_rule_set_warning_limit(stc_restriction_rule_h rule,
+               uint64_t rx_warning_limit, uint64_t tx_warning_limit);
+
+/**
+ * @brief Sets the roaming type for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[in] roaming_type The roaming type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see #stc_roaming_type_e
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_get_roaming_type()
+ */
+int stc_restriction_rule_set_roaming_type(stc_restriction_rule_h rule,
+               stc_roaming_type_e roaming_type);
+
+/**
+ * @brief Sets the imsi for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[in] imsi The imsi
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_get_imsi()
+ */
+int stc_restriction_rule_set_imsi(stc_restriction_rule_h rule, const char *imsi);
+
+/**
+ * @brief Gets the application ID for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[out] app_id The application ID
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_app_id()
+ */
+int stc_restriction_rule_get_app_id(stc_restriction_rule_h rule, char **app_id);
+
+/**
+ * @brief Gets the interface name for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[out] iface_name The interface name
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see #stc_iface_type_e
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_iface_name()
+ */
+int stc_restriction_rule_get_iface_name(stc_restriction_rule_h rule,
+               char **iface_name);
+
+/**
+ * @brief Gets the interface type for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[out] iface_type The interface type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see #stc_iface_type_e
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_iface_type()
+ */
+int stc_restriction_rule_get_iface_type(stc_restriction_rule_h rule,
+               stc_iface_type_e *iface_type);
+
+/**
+ * @brief Gets the limit for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[out] rx_limit The receive limit
+ * @param[out] tx_limit The send limit
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_limit()
+ */
+int stc_restriction_rule_get_limit(stc_restriction_rule_h rule,
+               uint64_t *rx_limit, uint64_t *tx_limit);
+
+/**
+ * @brief Gets the warning limit for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[out] rx_warning_limit The receive warning limit
+ * @param[out] tx_warning_limit The send warning limit
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_warning_limit()
+ */
+int stc_restriction_rule_get_warning_limit(stc_restriction_rule_h rule,
+               uint64_t *rx_warning_limit, uint64_t *tx_warning_limit);
+
+/**
+ * @brief Gets the roaming type for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[out] roaming The roaming type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see #stc_roaming_type_e
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_roaming_type()
+ */
+int stc_restriction_rule_get_roaming_type(stc_restriction_rule_h rule,
+               stc_roaming_type_e *roaming_type);
+
+/**
+ * @brief Gets the imsi for restriction rule.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] rule The restriction rule handle
+ * @param[out] imsi The imsi
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_rule_h
+ * @see stc_restriction_rule_create()
+ * @see stc_restriction_rule_destroy()
+ * @see stc_restriction_rule_set_imsi()
+ */
+int stc_restriction_rule_get_imsi(stc_restriction_rule_h rule, char **imsi);
+
+/**
+ * @brief Gets the IMSI from statistics information.
+ * @since_tizen 4.0
+ * @remarks You must release @a imsi using free().
+ *
+ * @param[in] info          The statistics information handle
+ * @param[out] imsi         The IMSI
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE                    Successful
+ * @retval #STC_ERROR_OPERATION_FAILED        General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY           Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER       Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION       Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED         Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED           Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED       Permission denied
+ *
+ * @see stc_stats_info_h
+ * @see stc_stats_info_cb()
+ */
+int stc_stats_info_get_imsi(stc_stats_info_h info, char **imsi);
+
+/**
+ * @brief Gets the application ID for restriction information.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] info The restriction information handle
+ * @param[out] app_id The application ID
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_info_h
+ * @see stc_restriction_info_cb()
+ */
+int stc_restriction_info_get_app_id(stc_restriction_info_h info, char **app_id);
+
+/**
+ * @brief Gets the interface name for restriction information.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] info The restriction information handle
+ * @param[out] iface_name The interface name
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_info_h
+ * @see stc_restriction_info_cb()
+ */
+int stc_restriction_info_get_iface_name(stc_restriction_info_h info,
+               char **iface_name);
+
+/**
+ * @brief Gets the imsi for restriction information.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] info The restriction information handle
+ * @param[out] imsi The imsi
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_info_h
+ * @see stc_restriction_info_cb()
+ */
+int stc_restriction_info_get_imsi(stc_restriction_info_h info, char **imsi);
+
+/**
+ * @brief Gets the restriction status for restriction information.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] info The restriction information handle
+ * @param[out] status The restriction status
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_info_h
+ * @see #stc_restriction_status_e
+ * @see stc_restriction_info_cb()
+ */
+int stc_restriction_info_get_status(stc_restriction_info_h info,
+               stc_restriction_status_e *status);
+
+/**
+ * @brief Gets the interface type for restriction information.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] info The restriction information handle
+ * @param[out] iface_type The interface type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_info_h
+ * @see #stc_iface_type_e
+ * @see stc_restriction_info_cb()
+ */
+int stc_restriction_info_get_iface_type(stc_restriction_info_h info,
+               stc_iface_type_e *iface_type);
+
+/**
+ * @brief Gets the limit for restriction information.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] info The restriction information handle
+ * @param[out] rx_limit The receive limit
+ * @param[out] tx_limit The send limit
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_info_h
+ * @see stc_restriction_info_cb()
+ */
+int stc_restriction_info_get_limit(stc_restriction_info_h info,
+               uint64_t *rx_limit, uint64_t *tx_limit);
+
+/**
+ * @brief Gets the warning limit for restriction information.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] info The restriction information handle
+ * @param[out] rx_warning_limit The receive warning limit
+ * @param[out] tx_warning_limit The send warning limit
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_info_h
+ * @see stc_restriction_info_cb()
+ */
+int stc_restriction_info_get_warning_limit(stc_restriction_info_h info,
+               uint64_t *rx_warning_limit, uint64_t *tx_warning_limit);
+
+/**
+ * @brief Gets the roaming type for restriction information.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/network.stc
+ *
+ * @param[in] info The restriction information handle
+ * @param[out] roaming The roaming type
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STC_ERROR_NONE Successful
+ * @retval #STC_ERROR_OPERATION_FAILED General error
+ * @retval #STC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #STC_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #STC_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STC_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see #stc_restriction_info_h
+ * @see #stc_roaming_type_e
+ * @see stc_restriction_info_cb()
+ */
+int stc_restriction_info_get_roaming_type(stc_restriction_info_h info,
+               stc_roaming_type_e *roaming_type);
+
+/**
+* @}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_STC_INTERNAL_H__ */
diff --git a/packaging/capi-network-stc.spec b/packaging/capi-network-stc.spec
new file mode 100755 (executable)
index 0000000..f55a891
--- /dev/null
@@ -0,0 +1,84 @@
+Name:       capi-network-stc
+Summary:    A Smart Traffic Control (STC) libraries in Native API
+Version:    0.0.1
+Release:    1
+Group:      Network & Connectivity/API
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(gobject-2.0)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(gio-2.0)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires:  pkgconfig(capi-system-info)
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+Smart Traffic Control (STC) library in Tizen C API
+
+%package devel
+Summary:  An Smart Traffic Control (STC) in Native API (Development)
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+Requires: capi-base-common-devel
+
+%description devel
+An Smart Traffic Control (STC) library in Tizen CAPI (Shared Library) (Development)
+
+%package test
+Summary:    STC - STC test binaries
+
+%description test
+Test Application for Smart Traffic Control (STC)
+
+%prep
+%setup -q
+chmod 644 %{SOURCE0}
+
+%ifarch %{arm}
+export ARCH=arm
+%else
+export ARCH=i586
+%endif
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%cmake . \
+        -DCMAKE_BUILD_TYPE=%{?build_type} \
+        -DCMAKE_VERBOSE_MAKEFILE=ON \
+        -DLIB_DIR:PATH=%{_libdir} \
+        -DBIN_DIR:PATH=%{_bindir} \
+        -DINCLUDE_DIR:PATH=%{_includedir} \
+        -DLOCAL_STATE_DIR:PATH=%{_localstatedir} \
+        -DDATA_ROOT_DIR:PATH=%{_datadir} \
+        -DFULLVER=%{version} \
+        -DMAJORVER=${MAJORVER}
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%manifest capi-network-stc.manifest
+%license LICENSE
+%defattr(-,root,root,-)
+%{_libdir}/*.so*
+%{_bindir}/stc_test
+%attr(755,root,root) %{_bindir}/stc_test
+
+
+%files devel
+%defattr(-,root,root,-)
+%{_libdir}/pkgconfig/*.pc
+%{_includedir}/network/*.h
+%{_libdir}/*.so
diff --git a/pkgconfig/CMakeLists.txt b/pkgconfig/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..b5114fb
--- /dev/null
@@ -0,0 +1,28 @@
+# Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+# @file        CMakeLists.txt
+#
+
+CONFIGURE_FILE(
+    ${fw_name}.pc.in
+    ${fw_name}.pc
+    @ONLY
+    )
+
+INSTALL(FILES
+    ${CMAKE_BINARY_DIR}/pkgconfig/${fw_name}.pc
+    DESTINATION
+    ${LIB_DIR}/pkgconfig
+    )
diff --git a/pkgconfig/capi-network-stc.pc.in b/pkgconfig/capi-network-stc.pc.in
new file mode 100755 (executable)
index 0000000..e65a44d
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=@LIB_DIR@
+includedir=${prefix}/include/network
+
+Name: @PC_NAME@
+Description: capi network stc package
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..2c0d61e
--- /dev/null
@@ -0,0 +1,41 @@
+# Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+# @file        CMakeLists.txt
+#
+INCLUDE_DIRECTORIES(
+    ${CMAKE_SOURCE_DIR}/include
+    ${STC_PATH}/include
+    ${STC_INTERNAL_PATH}/include
+    )
+
+ADD_DEFINITIONS("-fvisibility=default")
+
+aux_source_directory(${STC_PATH} STC_SOURCES)
+aux_source_directory(${STC_INTERNAL_PATH} STC_SOURCES)
+ADD_LIBRARY(${TARGET_STC} SHARED ${STC_SOURCES})
+
+SET_TARGET_PROPERTIES(
+    ${TARGET_STC}
+    PROPERTIES
+        SOVERSION ${MAJORVER}
+        VERSION ${FULLVER}
+    )
+
+TARGET_LINK_LIBRARIES(${TARGET_STC}
+    ${STC_DEPS_LIBRARIES}
+    dl
+    )
+
+INSTALL(TARGETS ${TARGET_STC} DESTINATION ${LIB_DIR})
diff --git a/src/include/stc-info.h b/src/include/stc-info.h
new file mode 100755 (executable)
index 0000000..6cc834f
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc-data-info.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __TIZEN_STC_INFO_H__
+#define __TIZEN_STC_INFO_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+#include "stc-private.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+#define STC_STATS_INFO_APP_ID                          "app_id"
+#define STC_STATS_INFO_IFTYPE                          "iftype"
+#define STC_STATS_INFO_IFNAME                          "ifname"
+#define STC_STATS_INFO_IMSI                                    "imsi"
+#define STC_STATS_INFO_INTERVAL_FROM           "interval_from"
+#define STC_STATS_INFO_INTERVAL_TO                     "interval_to"
+#define STC_STATS_INFO_OUTGOING_BYTES          "cnt_out_bytes"
+#define STC_STATS_INFO_INCOMING_BYTES          "cnt_in_bytes"
+#define STC_STATS_INFO_ROAMING                         "roaming"
+#define STC_STATS_INFO_PROTOCOL_TYPE           "hw_net_protocol_type"
+#define STC_STATS_INFO_PROCESS_STATE           "ground"
+
+#define STC_RESTRICTION_INFO_APP_ID                            "app_id"
+#define STC_RESTRICTION_INFO_IFTYPE                            "iftype"
+#define STC_RESTRICTION_INFO_IFNAME                            "ifname"
+#define STC_RESTRICTION_INFO_RX_LIMIT                  "rcv_limit"
+#define STC_RESTRICTION_INFO_TX_LIMIT                  "send_limit"
+#define STC_RESTRICTION_INFO_RX_WARNING_LIMIT  "rcv_warn_limit"
+#define STC_RESTRICTION_INFO_TX_WARNING_LIMIT  "send_warn_limit"
+#define STC_RESTRICTION_INFO_RST_STATUS                        "rst_state"
+#define STC_RESTRICTION_INFO_ROAMING                   "roaming"
+#define STC_RESTRICTION_INFO_IMSI                              "imsi"
+
+typedef struct {
+       uint64_t incoming_bytes;        /** <incoming_bytes is the Total bytes =  Incoming + outgoing */
+       uint64_t outgoing_bytes;        /** Actual outgoing bytes */
+} stc_data_counters_s;
+
+typedef struct {
+       char app_id[STC_APP_ID_LEN];
+       char iface_name[STC_IFNAME_LEN];
+       char imsi[STC_IMSI_LEN];
+       stc_time_interval_s interval;
+       stc_iface_type_e iface_type;
+       stc_data_counters_s cnt;
+       stc_roaming_type_e roaming_type;
+       stc_protocol_type_e protocol_type;
+       stc_process_state_e process_state;
+} stc_stats_info_s;
+
+typedef struct {
+       char app_id[STC_APP_ID_LEN];
+       char iface_name[STC_IFNAME_LEN];
+       char imsi[STC_IMSI_LEN];
+       stc_iface_type_e iface_type;
+       stc_restriction_status_e rst_status;
+       uint64_t rx_limit;
+       uint64_t tx_limit;
+       uint64_t rx_warning_limit;
+       uint64_t tx_warning_limit;
+       stc_roaming_type_e roaming_type;
+} stc_restriction_info_s;
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __TIZEN_STC_INFO_H__ */
diff --git a/src/include/stc-manager.h b/src/include/stc-manager.h
new file mode 100755 (executable)
index 0000000..caa2e06
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc-manager.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __TIZEN_STC_MANAGER_H__
+#define __TIZEN_STC_MANAGER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __TIZEN_STC_MANAGER_H__ */
diff --git a/src/include/stc-reset.h b/src/include/stc-reset.h
new file mode 100755 (executable)
index 0000000..09485a4
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc-reset.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __TIZEN_STC_RESET_H__
+#define __TIZEN_STC_RESET_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+#include "stc-private.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+#define RESET_TIMER_INTERVAL 3600              /* one hour */
+#define RESET_INTERVAL 3600 * 24 * 40  /* 40 days */
+
+#define STC_RESET_RULE_APP_ID                  "app_id"
+#define STC_RESET_RULE_IMSI                            "imsi"
+#define STC_RESET_RULE_IFTYPE                  "iftype"
+#define STC_RESET_RULE_INTERVAL_FROM   "from"
+#define STC_RESET_RULE_INTERVAL_TO             "to"
+#define STC_RESET_RULE_CONNECION_STATE "connection_state"
+
+typedef struct {
+       char app_id[STC_APP_ID_LEN];
+       char imsi[STC_IMSI_LEN];
+       stc_iface_type_e iface_type;
+       stc_time_interval_s interval;
+       stc_conn_period_e conn_period;
+} stc_reset_rule_s;
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+stc_error_e _stc_reset_check_rule(stc_reset_rule_h rule);
+stc_error_e _stc_reset_stats(stc_reset_rule_h rule);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __TIZEN_STC_RESET_H__ */
diff --git a/src/include/stc-restriction.h b/src/include/stc-restriction.h
new file mode 100755 (executable)
index 0000000..4203136
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc-restriction.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __TIZEN_STC_RESTRICTION_H__
+#define __TIZEN_STC_RESTRICTION_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+#define STC_RESTRICTION_RULE_APP_ID                            "app_id"
+#define STC_RESTRICTION_RULE_IFNAME                            "ifname"
+#define STC_RESTRICTION_RULE_IFTYPE                            "iftype"
+#define STC_RESTRICTION_RULE_ROAMING                   "roaming"
+#define STC_RESTRICTION_RULE_IMSI                              "imsi"
+#define STC_RESTRICTION_RULE_RX_LIMIT                  "rcv_limit"
+#define STC_RESTRICTION_RULE_TX_LIMIT                  "send_limit"
+#define STC_RESTRICTION_RULE_RX_WARNING_LIMIT  "rcv_warn_limit"
+#define STC_RESTRICTION_RULE_TX_WARNING_LIMIT  "send_warn_limit"
+
+typedef enum {
+       STC_RST_TYPE_UNDEF,
+       STC_RST_TYPE_SET,
+       STC_RST_TYPE_UNSET,
+       STC_RST_TYPE_EXCLUDE,
+       STC_RST_TYPE_MAX_VALUE,
+} stc_restriction_type_e;
+
+typedef struct {
+       char app_id[STC_APP_ID_LEN];
+       char iface_name[STC_IFNAME_LEN];
+       char imsi[STC_IMSI_LEN];
+       stc_iface_type_e iface_type;
+       stc_restriction_status_e rst_state;
+       uint64_t tx_limit;
+       uint64_t rx_limit;
+       uint64_t tx_warning_limit;
+       uint64_t rx_warning_limit;
+       stc_roaming_type_e roaming_type;
+} stc_restriction_rule_s;
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+stc_error_e _stc_restriction_validate_rule(
+               stc_restriction_rule_h rule, stc_restriction_type_e rst_type);
+stc_error_e _stc_restriction_check_get_rule(stc_restriction_rule_h rule);
+stc_error_e _stc_restriction_check_get_all_rule(
+                       stc_restriction_rule_h rule);
+stc_error_e _stc_restriction_check_get_status_rule(
+                       stc_restriction_rule_h rule);
+stc_error_e _stc_restriction_set(stc_restriction_rule_h rule);
+stc_error_e _stc_restriction_exclude(stc_restriction_rule_h rule);
+stc_error_e _stc_restriction_unset(stc_restriction_rule_h rule);
+stc_error_e _stc_restriction_get_status(stc_restriction_rule_h rule,
+                       stc_restriction_status_e *status);
+stc_error_e _stc_restriction_get(stc_restriction_rule_h rule);
+stc_error_e _stc_restriction_get_all(stc_restriction_rule_h rule);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __TIZEN_STC_RESTRICTION_H__ */
diff --git a/src/include/stc-statistics.h b/src/include/stc-statistics.h
new file mode 100755 (executable)
index 0000000..3975376
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc-statistics.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __TIZEN_STC_STATS_H__
+#define __TIZEN_STC_STATS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+#include "stc-private.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+#define STC_STATS_RULE_APP_ID                  "app_id"
+#define STC_STATS_RULE_INTERVAL_FROM   "from"
+#define STC_STATS_RULE_INTERVAL_TO             "to"
+#define STC_STATS_RULE_IFTYPE                  "iface_type"
+#define STC_STATS_RULE_TIME_PERIOD             "granularity"
+
+typedef struct {
+       char app_id[STC_APP_ID_LEN];
+       stc_time_interval_s interval;
+       stc_iface_type_e iface_type;
+       stc_time_period_e time_period;
+} stc_stats_rule_s;
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+stc_error_e _stc_stats_check_get_rule(
+                       stc_stats_rule_h rule);
+stc_error_e _stc_stats_check_get_all_rule(
+                       stc_stats_rule_h rule);
+stc_error_e _stc_stats_check_get_total_rule(
+                       stc_stats_rule_h rule);
+
+stc_error_e _stc_stats_get(stc_stats_rule_h rule);
+stc_error_e _stc_stats_get_all(stc_stats_rule_h rule);
+stc_error_e _stc_stats_get_total(stc_stats_rule_h rule);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __TIZEN_STC_STATS_H__ */
diff --git a/src/internal/include/stc-dbus.h b/src/internal/include/stc-dbus.h
new file mode 100755 (executable)
index 0000000..0c98cf3
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc-dbus.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __TIZEN_STC_DBUS_H__
+#define __TIZEN_STC_DBUS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#include <glib.h>
+#include <gio/gio.h>
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc-private.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+#define STC_DBUS_REPLY_TIMEOUT (120 * 1000)
+
+#define STC_MANAGER_SERVICE                            "net.stc"
+#define STC_MANAGER_STATS_INTERFACE    STC_MANAGER_SERVICE ".statistics"
+#define STC_MANAGER_RESTRICTION_INTERFACE      STC_MANAGER_SERVICE ".restriction"
+
+#define STC_MANAGER_STATS_PATH                 "/net/stc/statistics"
+#define STC_MANAGER_RESTRICTION_PATH   "/net/stc/restriction"
+
+#define STC_MANAGER_METHOD_STATS_GET_PER_APP_ID                "Get"
+#define STC_MANAGER_METHOD_STATS_GET_ALL                       "GetAll"
+#define STC_MANAGER_METHOD_STATS_GET_TOTAL                     "Get"
+#define STC_MANAGER_METHOD_STATS_RESET                         "Reset"
+
+#define STC_MANAGER_METHOD_RESTRICTION_SET                             "Set"
+#define STC_MANAGER_METHOD_RESTRICTION_GET_STATUS              "GetState"
+#define STC_MANAGER_METHOD_RESTRICTION_GET_PER_APP_ID  "Get"
+#define STC_MANAGER_METHOD_RESTRICTION_GET_ALL                 "GetAll"
+#define STC_MANAGER_METHOD_RESTRICTION_UNSET                   "Remove"
+#define STC_MANAGER_METHOD_RESTRICTION_EXCLUDE                 "Exclude"
+
+#define STC_DEBUG_GDBUS_VARIANT(str, parameters) \
+       do { \
+               char *params_str = NULL; \
+               if (parameters) { \
+                       params_str = g_variant_print(parameters, \
+                                            TRUE); \
+               } \
+               STC_LOGD("%s[%s]", str, \
+                        params_str ? params_str : "NULL"); \
+               g_free(params_str); \
+       } while (0)
+
+#define STC_DEBUG_GDBUS_KEY_VALUE(key, value) \
+       do { \
+               if (key) { \
+                       STC_LOGD("Key : [%s]", key); \
+               } \
+               if (value) { \
+                       STC_DEBUG_GDBUS_VARIANT("Value: ", value); \
+               } \
+       } while (0)
+
+typedef struct {
+       GDBusConnection *connection;
+       GCancellable *cancellable;
+} stc_dbus_connection_data_s;
+
+typedef void (*stc_dbus_dict_cb) (const char *key, GVariant *value, void *user_data);
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+int _stc_dbus_create(void);
+int _stc_dbus_destroy(void);
+GDBusConnection *_stc_dbus_get_connection(void);
+GCancellable *_stc_dbus_get_cancellable(void);
+void _stc_dbus_dictionary_foreach(GVariantIter *iter,
+                       stc_dbus_dict_cb cb, void *user_data);
+
+GVariant *_stc_dbus_invoke_method(const char *dest,
+                       const char *path, const char *interface_name, const char *method,
+                       GVariant *params, int *dbus_error);
+int _stc_dbus_invoke_method_nonblock(const char *dest,
+                       const char *path, const char *interface_name, const char *method,
+                       GVariant *params, int timeout,
+                       GAsyncReadyCallback notify_func, void *user_data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __TIZEN_STC_DBUS_H__ */
diff --git a/src/internal/include/stc-event.h b/src/internal/include/stc-event.h
new file mode 100755 (executable)
index 0000000..9fb23e9
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc-event.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __TIZEN_STC_EVENT_H__
+#define __TIZEN_STC_EVENT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#include <glib.h>
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+typedef enum {
+       STC_EVENT_UNKNOWN,
+       STC_EVENT_STATS_GET_RSP,
+       STC_EVENT_STATS_GET_ALL_RSP,
+       STC_EVENT_STATS_GET_TOTAL_RSP,
+       STC_EVENT_RESTRICTION_GET_RSP,
+       STC_EVENT_RESTRICTION_GET_ALL_RSP,
+       STC_EVENT_LAST_ELEM,
+} stc_event_e;
+
+typedef enum {
+       STC_REQUEST_TABLE_UNKNOWN,
+       STC_REQUEST_TABLE_STATS_GET,
+       STC_REQUEST_TABLE_STATS_GET_ALL,
+       STC_REQUEST_TABLE_STATS_GET_TOTAL,
+       STC_REQUEST_TABLE_RESTRICTION_GET,
+       STC_REQUEST_TABLE_RESTRICTION_GET_ALL,
+       STC_REQUEST_TABLE_LAST_ELEM,
+} stc_request_table_e;
+
+typedef struct {
+       stc_event_e event;
+       stc_error_e error;
+       int datalength;
+       void *info_data;
+} stc_event_info_s;
+
+typedef void (*stc_event_cb)(const stc_event_info_s* stc_event, void* user_data);
+
+typedef struct {
+       stc_event_cb event_callback;
+       void* user_data;
+       int ref_count;
+       guint handler_id;
+} stc_event_handle_info_s;
+
+typedef struct {
+       int state;
+} stc_request_table_s;
+
+typedef struct {
+       stc_event_info_s *event_data;
+       void *user_data;
+       guint id;
+} stc_managed_idle_data_s;
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+int _stc_register_event_cb(stc_event_cb event_cb, void *user_data);
+int _stc_deregister_event_cb(void);
+void _stc_event_clear_request_table(void);
+guint _stc_event_add_client_idle_cb(stc_event_info_s *event_data,
+                       void *user_data);
+void _stc_event_clear_client_cb(void);
+int _stc_event_get_ref_count(void);
+bool _stc_event_get_request_table_state(int num);
+void _stc_event_set_request_table_state(int num, int state);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __TIZEN_STC_EVENT_H__ */
diff --git a/src/internal/include/stc-log.h b/src/internal/include/stc-log.h
new file mode 100755 (executable)
index 0000000..4eb5a2f
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares macros for logging.
+ *
+ * @file               stc-log.h
+ * @author             Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version            0.1
+ */
+
+#ifndef __TIZEN_STC_LOG_H__
+#define __TIZEN_STC_LOG_H__
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+#ifdef USE_DLOG
+#include <dlog.h>
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+#undef LOG_TAG
+#define LOG_TAG "CAPI_NETWORK_STC"
+
+#define STC_LOGD(format, args...)      LOGD(format, ##args)
+#define STC_LOGI(format, args...)      LOGI(format, ##args)
+#define STC_LOGW(format, args...)      LOGW(format, ##args)
+#define STC_LOGE(format, args...)      LOGE(format, ##args)
+
+#define STC_SECLOGI(format, args...)   SECURE_LOG(LOG_INFO, LOG_TAG, format, ##args)
+#define STC_SECLOGD(format, args...)   SECURE_LOG(LOG_DEBUG, LOG_TAG, format, ##args)
+
+#define __STC_LOG_FUNC_START__         LOGV("Enter")
+#define __STC_LOG_FUNC_END__           LOGV("Quit")
+
+#else /** USE_DLOG */
+
+#define STC_LOGD(format, args...)
+#define STC_LOGI(format, args...)
+#define STC_LOGW(format, args...)
+#define STC_LOGE(format, args...)
+
+#define __STC_LOG_FUNC_START__
+#define __STC_LOG_FUNC_END__
+
+#define STC_SECLOGI(format, args...)
+#define STC_SECLOGD(format, args...)
+
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+
+
+
+
+#endif /** USE_DLOG */
+#endif /** __TIZEN_STC_LOG_H__ */
diff --git a/src/internal/include/stc-network-option.h b/src/internal/include/stc-network-option.h
new file mode 100755 (executable)
index 0000000..d3431b8
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc-network-option.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __TIZEN_STC_NETWORK_OPTION_H__
+#define __TIZEN_STC_NETWORK_OPTION_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+/**
+ * @brief Structure for set of the options
+ * @since_tizen 4.0
+ * @details
+ * wifi - enable/disable wifi, STC_OPTION_UNDEF to leave option as is
+ * datacall - enable/disable datacall, STC_OPTION_UNDEF to leave option as is
+ * timer - set period of the updating data from the kernel,
+ *             0 to leave option as is
+ * datacall_logging - enable/disable datacall_logging,
+ *             STC_OPTION_UNDEF to leave option as is
+ */
+typedef struct {
+       stc_option_state_e wifi;
+       stc_option_state_e datacall;
+       time_t timer;
+       stc_option_state_e datacall_logging;
+} stc_network_option_s;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __TIZEN_STC_NETWORK_OPTION_H__ */
diff --git a/src/internal/include/stc-private.h b/src/internal/include/stc-private.h
new file mode 100755 (executable)
index 0000000..95700b9
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc-private.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __TIZEN_STC_PRIVATE_H__
+#define __TIZEN_STC_PRIVATE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+#include "stc_internal.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+#define STC_INVALID_TIME_INTERVAL      -1
+
+#define STC_HR_SINGLE  "----------------------------------------" \
+                                               "-------------------------"
+#define STC_HR_DOUBLE  "========================================" \
+                                               "========================="
+
+typedef struct {
+       stc_stats_info_cb stats_cb;
+       void *stats_user_data;
+       stc_stats_info_cb stats_all_cb;
+       void *stats_all_user_data;
+       stc_stats_info_cb stats_total_cb;
+       void *stats_total_user_data;
+
+       stc_restriction_info_cb restriction_cb;
+       void *restriction_user_data;
+       stc_restriction_info_cb restriction_all_cb;
+       void *restriction_all_user_data;
+} stc_handle_s;
+
+/**
+ * @brief Structure for time interval
+ * @details It's time interval. Zero interval since 0 til 0 means entires interval.
+ */
+typedef struct {
+       time_t from;
+       time_t to;
+} stc_time_interval_s;
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+const char *_stc_convert_error_type_to_string(stc_error_e err);
+int _stc_convert_error_string_to_enum(const char *error);
+const char *_stc_convert_iface_type_to_string(stc_iface_type_e type);
+const char *_stc_convert_roaming_to_string(stc_roaming_type_e type);
+const char *_stc_convert_rst_status_to_string(stc_restriction_status_e state);
+const char *_stc_convert_protocol_to_string(stc_protocol_type_e type);
+const char *_stc_convert_process_state_to_string(stc_process_state_e state);
+const char *_stc_convert_connection_period_to_string(
+                       stc_conn_period_e state);
+const char *_stc_convert_time_period_to_string(
+                       stc_time_period_e period);
+
+int _stc_initialize(void);
+int _stc_deinitialize(void);
+int _stc_handle_create(stc_h *stc);
+int _stc_handle_add(stc_h *stc);
+int _stc_handle_remove(stc_h stc);
+bool _stc_handle_check_validity(stc_h stc);
+int _stc_handle_get_count(void);
+
+void _stc_callback_set_stats_info(stc_h stc,
+                       stc_stats_info_cb user_cb,      void *user_data);
+void _stc_callback_set_stats_all_info(stc_h stc,
+                       stc_stats_info_cb user_cb,      void *user_data);
+void _stc_callback_set_stats_total_info(stc_h stc,
+                       stc_stats_info_cb user_cb,      void *user_data);
+
+void _stc_callback_set_restriction_info(stc_h stc,
+                       stc_restriction_info_cb user_cb, void *user_data);
+void _stc_callback_set_restriction_all_info(stc_h stc,
+                       stc_restriction_info_cb user_cb, void *user_data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __TIZEN_STC_PRIVATE_H__ */
diff --git a/src/internal/include/stc-signal.h b/src/internal/include/stc-signal.h
new file mode 100755 (executable)
index 0000000..447c066
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc-signal.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __TIZEN_STC_SIGNAL_H__
+#define __TIZEN_STC_SIGNAL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+#define STC_MANAGER_SIGNAL_STATS                       "Statistics"
+#define STC_MANAGER_SIGNAL_RESTRICTION         "Restriction"
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+int _stc_register_signal(void);
+int _stc_deregister_signal(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __TIZEN_STC_SIGNAL_H__ */
diff --git a/src/internal/include/stc-util.h b/src/internal/include/stc-util.h
new file mode 100755 (executable)
index 0000000..754d48c
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file implements Smart Traffic Control (STC) user library.
+ *
+ * @file        stc-util.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __TIZEN_STC_UTIL_H__
+#define __TIZEN_STC_UTIL_H__
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+#include <system_info.h>
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc-log.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+#define STC_APP_ID_LEN 128
+#define STC_IFNAME_LEN 16
+#define STC_IMSI_LEN 64
+
+#define STC_RETURN_VAL_IF(expr, val, fmt, arg...) do { \
+       if (expr) { \
+               STC_LOGE(fmt, ##arg); \
+               return val; \
+       } \
+} while (0)
+
+#define TIZEN_FEATURE_STC "tizen.org/feature/network.stc"
+
+#if 0
+#define CHECK_FEATURE_SUPPORTED(feature_name)\
+       do {\
+               bool feature_supported = FALSE;\
+               if (!system_info_get_platform_bool(feature_name, &feature_supported)) {\
+                       if (feature_supported == FALSE) {\
+                               LOGE("%s feature is disabled", feature_name);\
+                               return STC_ERROR_NOT_SUPPORTED;\
+                       } \
+               } else {\
+                       LOGE("Failed to get feature from system info");\
+                       return STC_ERROR_OPERATION_FAILED;\
+               } \
+       } while (0)
+
+#else
+#define CHECK_FEATURE_SUPPORTED(feature_name)
+#endif
+
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+
+
+#endif /** __TIZEN_STC_UTIL_H__ */
diff --git a/src/internal/stc-dbus.c b/src/internal/stc-dbus.c
new file mode 100755 (executable)
index 0000000..64c6c39
--- /dev/null
@@ -0,0 +1,195 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file implements Smart Traffic Control (STC) user library.
+ *
+ * @file        stc-dbus.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#include <glib.h>
+#include <gio/gio.h>
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+#include "stc-private.h"
+
+#include "stc-log.h"
+#include "stc-util.h"
+
+#include "stc-dbus.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+static __thread stc_dbus_connection_data_s g_stc_dbus_conn = { NULL, NULL };
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+int _stc_dbus_create(void)
+{
+       GError *err = NULL;
+
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+       g_type_init();
+#endif
+
+       g_stc_dbus_conn.connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+       if (g_stc_dbus_conn.connection == NULL) {
+               if (err != NULL) {
+                       STC_LOGE("Failed to connect to the D-BUS daemon [%s]", err->message);
+                       g_error_free(err);
+               }
+               return STC_ERROR_OPERATION_FAILED;
+       }
+
+       g_stc_dbus_conn.cancellable = g_cancellable_new();
+
+       return STC_ERROR_NONE;
+}
+
+int _stc_dbus_destroy(void)
+{
+       g_cancellable_cancel(g_stc_dbus_conn.cancellable);
+       g_object_unref(g_stc_dbus_conn.cancellable);
+       g_stc_dbus_conn.cancellable = NULL;
+
+       g_object_unref(g_stc_dbus_conn.connection);
+       g_stc_dbus_conn.connection = NULL;
+
+       return STC_ERROR_NONE;
+}
+
+GDBusConnection *_stc_dbus_get_connection(void)
+{
+       return g_stc_dbus_conn.connection;
+}
+
+GCancellable *_stc_dbus_get_cancellable(void)
+{
+       return g_stc_dbus_conn.cancellable;
+}
+
+void _stc_dbus_dictionary_foreach(GVariantIter *iter,
+                       stc_dbus_dict_cb cb, void *user_data)
+{
+       char *key = NULL;
+       GVariant *value = NULL;
+
+       if (!cb)
+               return;
+
+       while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+               /* STC_DEBUG_GDBUS_KEY_VALUE(key, value); */
+               if (key && cb)
+                       cb(key, value, user_data);
+       }
+}
+
+GVariant *_stc_dbus_invoke_method(const char *dest,
+                       const char *path, const char *interface_name, const char *method,
+                       GVariant *params, int *dbus_error)
+{
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       *dbus_error = STC_ERROR_NONE;
+       GDBusConnection *connection;
+
+       connection = _stc_dbus_get_connection();
+       if (connection == NULL) {
+               STC_LOGE("GDBusconnection is NULL");
+               *dbus_error = STC_ERROR_NOT_INITIALIZED;
+               return reply;
+       }
+
+       reply = g_dbus_connection_call_sync(connection,
+                       dest,
+                       path,
+                       interface_name,
+                       method,
+                       params,
+                       NULL,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       STC_DBUS_REPLY_TIMEOUT,
+                       _stc_dbus_get_cancellable(),
+                       &error);
+
+       if (reply == NULL) {
+               if (error != NULL) {
+                       STC_LOGE("g_dbus_connection_call_sync() failed "
+                               "error [%d: %s]", error->code, error->message);
+                       *dbus_error = _stc_convert_error_string_to_enum(error->message);
+                       g_error_free(error);
+               } else {
+                       STC_LOGE("g_dbus_connection_call_sync() failed");
+                       *dbus_error = STC_ERROR_OPERATION_FAILED;
+               }
+
+               return NULL;
+       }
+
+       return reply;
+}
+
+int _stc_dbus_invoke_method_nonblock(const char *dest,
+                       const char *path, const char *interface_name, const char *method,
+                       GVariant *params, int timeout,
+                       GAsyncReadyCallback notify_func, void *user_data)
+{
+       GDBusConnection *connection;
+
+       connection = _stc_dbus_get_connection();
+       if (connection == NULL) {
+               STC_LOGE("GDBusconnection is NULL");
+               return STC_ERROR_NOT_INITIALIZED;
+       }
+
+       g_dbus_connection_call(connection,
+                                                       dest,
+                                                       path,
+                                                       interface_name,
+                                                       method,
+                                                       params,
+                                                       NULL,
+                                                       G_DBUS_CALL_FLAGS_NONE,
+                                                       timeout,
+                                                       _stc_dbus_get_cancellable(),
+                                                       (GAsyncReadyCallback) notify_func,
+                                                       (gpointer)user_data);
+
+       return STC_ERROR_NONE;
+}
diff --git a/src/internal/stc-event.c b/src/internal/stc-event.c
new file mode 100755 (executable)
index 0000000..c94739e
--- /dev/null
@@ -0,0 +1,245 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file implements Smart Traffic Control (STC) user library.
+ *
+ * @file        stc-event.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+#include "stc-private.h"
+
+#include "stc-dbus.h"
+#include "stc-log.h"
+#include "stc-util.h"
+#include "stc-signal.h"
+
+#include "stc-event.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+static __thread stc_request_table_s g_stc_request_table[STC_EVENT_LAST_ELEM] = { { 0 }, };
+static __thread stc_event_handle_info_s g_stc_event_handle = { 0, };
+static __thread GSList *g_stc_managed_idler_list = NULL;
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+static void __stc_event_destroy_client_idle_cb(gpointer data)
+{
+       if (!data)
+               return;
+
+       g_stc_managed_idler_list = g_slist_remove(g_stc_managed_idler_list, data);
+       g_free(data);
+       data = NULL;
+}
+
+static gboolean __stc_event_client_idle_cb(gpointer idle_data)
+{
+       stc_managed_idle_data_s *data = (stc_managed_idle_data_s *)idle_data;
+
+       if (!data)
+               return false;
+
+       stc_event_info_s *event_data = (stc_event_info_s *)data->event_data;
+       void *user_data = data->user_data;
+
+       if (g_stc_event_handle.event_callback != NULL)
+               g_stc_event_handle.event_callback(event_data, user_data);
+
+       g_free(event_data);
+
+       return false;
+}
+
+int _stc_register_event_cb(stc_event_cb event_cb, void *user_data)
+{
+       int ret = STC_ERROR_NONE;
+
+       STC_RETURN_VAL_IF(event_cb == NULL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid event callback parameter");
+
+       STC_RETURN_VAL_IF(g_stc_event_handle.event_callback != NULL,
+               STC_ERROR_ALREADY_INITIALIZED,
+               "STC event callback already registered");
+
+       if (_stc_event_get_ref_count() < 1) {
+               ret = _stc_dbus_create();
+               if (ret != STC_ERROR_NONE) {
+                       STC_LOGE("Failed to create DBus [%s]",
+                               _stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+
+               ret = _stc_register_signal();
+               if (ret != STC_ERROR_NONE && ret != STC_ERROR_ALREADY_INITIALIZED) {
+                       STC_LOGE("Failed to register DBus signal [%s]",
+                               _stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
+       g_stc_event_handle.event_callback = event_cb;
+       g_stc_event_handle.user_data = user_data;
+
+       __sync_fetch_and_add(&g_stc_event_handle.ref_count, 1);
+
+       return STC_ERROR_NONE;
+}
+
+int _stc_deregister_event_cb(void)
+{
+       STC_RETURN_VAL_IF(_stc_event_get_ref_count() < 1,
+               STC_ERROR_NOT_INITIALIZED,
+               "Event callback is not registered");
+
+       STC_RETURN_VAL_IF(g_stc_event_handle.event_callback == NULL,
+               STC_ERROR_NOT_INITIALIZED,
+               "Event callback was not registered");
+
+       g_stc_event_handle.event_callback = NULL;
+       g_stc_event_handle.user_data = NULL;
+
+       if (__sync_sub_and_fetch(&g_stc_event_handle.ref_count, 1) < 1) {
+               _stc_deregister_signal();
+               _stc_event_clear_request_table();
+               _stc_event_clear_client_cb();
+       }
+
+       return STC_ERROR_NONE;
+}
+
+void _stc_event_clear_request_table(void)
+{
+       int i;
+
+       for (i = 0; i < STC_EVENT_LAST_ELEM; ++i)
+               memset(&g_stc_request_table[i], 0, sizeof(stc_request_table_s));
+}
+
+guint _stc_event_add_client_idle_cb(stc_event_info_s *event_data,
+                       void *user_data)
+{
+       guint id;
+       stc_managed_idle_data_s *idle_data;
+       GMainContext *context;
+       GSource *src;
+       stc_event_info_s *data;
+
+       idle_data = g_try_new0(stc_managed_idle_data_s, 1);
+       if (!idle_data)
+               return 0;
+
+       data = g_try_new0(stc_event_info_s, 1);
+       if (!data)
+               return 0;
+
+       memcpy(data, event_data, sizeof(stc_event_info_s));
+
+       idle_data->event_data = data;
+       idle_data->user_data = user_data;
+
+       context = g_main_context_get_thread_default();
+       src = g_idle_source_new();
+       g_source_set_callback(src, __stc_event_client_idle_cb, idle_data,
+                       __stc_event_destroy_client_idle_cb);
+       id = g_source_attach(src, context);
+       g_source_unref(src);
+
+       if (!id) {
+               g_slist_free(idle_data->event_data->info_data);
+               g_free(idle_data);
+               idle_data = NULL;
+               return id;
+       }
+
+       idle_data->id = id;
+
+       g_stc_managed_idler_list = g_slist_append(g_stc_managed_idler_list, idle_data);
+
+       return id;
+}
+
+void _stc_event_clear_client_cb(void)
+{
+       GSList *cur = g_stc_managed_idler_list;
+       GSource *src;
+       stc_managed_idle_data_s *data;
+
+       while (cur) {
+               GSList *next = cur->next;
+               data = (stc_managed_idle_data_s *)cur->data;
+
+               src = g_main_context_find_source_by_id(g_main_context_default(), data->id);
+               if (src) {
+                       g_source_destroy(src);
+                       cur = g_stc_managed_idler_list;
+               } else
+                       cur = next;
+       }
+
+       g_slist_free(g_stc_managed_idler_list);
+       g_stc_managed_idler_list = NULL;
+}
+
+int _stc_event_get_ref_count(void)
+{
+       return g_stc_event_handle.ref_count;
+}
+
+bool _stc_event_get_request_table_state(int num)
+{
+       return g_stc_request_table[num].state;
+}
+
+void _stc_event_set_request_table_state(int num, int state)
+{
+       g_stc_request_table[num].state = state;
+}
diff --git a/src/internal/stc-private.c b/src/internal/stc-private.c
new file mode 100755 (executable)
index 0000000..e05f99d
--- /dev/null
@@ -0,0 +1,513 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file implements Smart Traffic Control (STC) user library.
+ *
+ * @file        stc-private.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+#include <system_info.h>
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+#include "stc-private.h"
+
+#include "stc-dbus.h"
+#include "stc-log.h"
+#include "stc-util.h"
+#include "stc-event.h"
+#include "stc-signal.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+static __thread GSList *g_stc_handle_list = NULL;
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+const char *_stc_convert_error_type_to_string(stc_error_e err)
+{
+       switch (err) {
+       case STC_ERROR_NOT_PERMITTED:
+               return "Operation not permitted";
+       case STC_ERROR_OUT_OF_MEMORY:
+               return "Out of memory";
+       case STC_ERROR_PERMISSION_DENIED:
+               return "Permission denied";
+       case STC_ERROR_RESOURCE_BUSY:
+               return "Device or resource busy";
+       case STC_ERROR_INVALID_OPERATION:
+               return "Invalid operation";
+       case STC_ERROR_INVALID_PARAMETER:
+               return "Invalid parameter";
+       case STC_ERROR_NOT_SUPPORTED:
+               return "Not supported";
+       case STC_ERROR_OPERATION_FAILED:
+               return "Operation failed";
+       case STC_ERROR_NOT_INITIALIZED:
+               return "Not initialized";
+       case STC_ERROR_ALREADY_INITIALIZED:
+               return "Already initialized";
+       case STC_ERROR_IN_PROGRESS:
+               return "In progress";
+       default:
+               return "Unknown";
+       }
+}
+
+int _stc_convert_error_string_to_enum(const char *error)
+{
+       STC_LOGI("Passed error value [%s]", error);
+
+       if (NULL != strstr(error, "NoReply"))
+               return STC_ERROR_INVALID_OPERATION;
+       else if (NULL != strstr(error, "Failed"))
+               return STC_ERROR_OPERATION_FAILED;
+       else if (NULL != strstr(error, "UnknownMethod"))
+               return STC_ERROR_INVALID_OPERATION;
+       else if (NULL != strstr(error, "InvalidArguments"))
+               return STC_ERROR_INVALID_PARAMETER;
+       else if (NULL != strstr(error, "AccessDenied"))
+               return STC_ERROR_PERMISSION_DENIED;
+       else if (NULL != strstr(error, "PermissionDenied"))
+               return STC_ERROR_PERMISSION_DENIED;
+       else if (NULL != strstr(error, "NotSupported"))
+               return STC_ERROR_NOT_SUPPORTED;
+       else if (NULL != strstr(error, "InProgress"))
+               return STC_ERROR_IN_PROGRESS;
+
+       return STC_ERROR_OPERATION_FAILED;
+}
+
+const char *_stc_convert_iface_type_to_string(stc_iface_type_e type)
+{
+       switch (type) {
+       case STC_IFACE_UNKNOWN:
+               return "Undefined";
+       case STC_IFACE_DATACALL:
+               return "Data Call";
+       case STC_IFACE_WIFI:
+               return "Wi-Fi";
+       case STC_IFACE_WIRED:
+               return "Wired";
+       case STC_IFACE_BLUETOOTH:
+               return "Bluetooth";
+       case STC_IFACE_ALL:
+               return "All";
+       default:
+               return "Unknown";
+       }
+}
+
+const char *_stc_convert_roaming_to_string(stc_roaming_type_e type)
+{
+       switch (type) {
+       case STC_ROAMING_UNKNOWN:
+               return "Unknown";
+       case STC_ROAMING_ENABLED:
+               return "Enable";
+       case STC_ROAMING_DISABLED:
+               return "Disable";
+       default:
+               return "Unknown";
+       }
+}
+
+const char *_stc_convert_rst_status_to_string(stc_restriction_status_e status)
+{
+       switch (status) {
+       case STC_RESTRICTION_UNKNOWN:
+               return "Undefined";
+       case STC_RESTRICTION_ACTIVATED:
+               return "Activated";
+       case STC_RESTRICTION_REMOVED:
+               return "Removed";
+       case STC_RESTRICTION_EXCLUDED:
+               return "Excluded";
+       case STC_RESTRICTION_BACKGROUND:
+               return "Background";
+       default:
+               return "Unknown";
+       }
+}
+
+const char *_stc_convert_protocol_to_string(stc_protocol_type_e type)
+{
+       switch (type) {
+       case STC_PROTOCOL_UNKNOWN:
+               return "Unknown";
+       case STC_PROTOCOL_DATACALL_NOSVC:
+               return "No service";
+       case STC_PROTOCOL_DATACALL_EMERGENCY:
+               return "Emergency";
+       case STC_PROTOCOL_DATACALL_SEARCH:
+               return "Search 1900";
+       case STC_PROTOCOL_DATACALL_2G:
+               return "2G";
+       case STC_PROTOCOL_DATACALL_2_5G:
+               return "2.5G";
+       case STC_PROTOCOL_DATACALL_2_5G_EDGE:
+               return "EDGE";
+       case STC_PROTOCOL_DATACALL_3G:
+               return "UMTS";
+       case STC_PROTOCOL_DATACALL_HSDPA:
+               return "HSDPA";
+       case STC_PROTOCOL_DATACALL_LTE:
+               return "LTE";
+       default:
+               return "Unknown";
+       }
+}
+
+const char *_stc_convert_process_state_to_string(
+                       stc_process_state_e state)
+{
+       switch (state) {
+       case STC_PROCESS_STATE_UNKNOWN:
+               return "Unknown";
+       case STC_PROCESS_STATE_FOREGROUND:
+               return "Foreground";
+       case STC_PROCESS_STATE_BACKGROUND:
+               return "Background";
+       default:
+               return "Unknown";
+       }
+}
+
+const char *_stc_convert_connection_period_to_string(
+                       stc_conn_period_e state)
+{
+       switch (state) {
+       case STC_CONN_PERIOD_UNKNOWN:
+               return "Undefined";
+       case STC_CONN_PERIOD_LAST_RECEIVED_DATA:
+               return "Last received data";
+       case STC_CONN_PERIOD_LAST_SENT_DATA:
+               return "Last sent data";
+       case STC_CONN_PERIOD_TOTAL_RECEIVED_DATA:
+               return "Total received data";
+       case STC_CONN_PERIOD_TOTAL_SENT_DATA:
+               return "Total sent data";
+       default:
+               return "Unknown";
+       }
+}
+
+const char *_stc_convert_time_period_to_string(
+                       stc_time_period_e period)
+{
+       switch (period) {
+       case STC_TIME_PERIOD_UNKNOWN:
+               return "Undefined";
+       case STC_TIME_PERIOD_HOUR:
+               return "Hour";
+       case STC_TIME_PERIOD_DAY:
+               return "Day";
+       case STC_TIME_PERIOD_WEEK:
+               return "Week";
+       case STC_TIME_PERIOD_MONTH:
+               return "Month";
+       default:
+               return "Unknown";
+       }
+}
+
+static bool __stc_handle_find(stc_h stc)
+{
+       if (g_slist_find(g_stc_handle_list, stc) != NULL)
+               return true;
+       else
+               return false;
+}
+
+static void __stc_callback_foreach(stc_event_e e,
+                       stc_error_e err, GSList *info_data)
+{
+       GSList *list, *data;
+       int ret = STC_ERROR_NONE;
+
+       for (list = g_stc_handle_list; list; list = list->next) {
+               stc_handle_s *handle = (stc_handle_s *)list->data;
+               switch (e) {
+               case STC_EVENT_STATS_GET_RSP:
+                       if (handle->stats_cb) {
+                               if (err == STC_ERROR_NONE) {
+                                       for (data = info_data; data; data = data->next) {
+                                               stc_stats_info_h info = data->data;
+                                               ret = handle->stats_cb(err,
+                                                       info, handle->stats_user_data);
+
+                                               if (ret == STC_CALLBACK_CANCEL)
+                                                       break;
+                                       }
+                               } else {
+                                       handle->stats_cb(err, NULL, NULL);
+                               }
+
+                               handle->stats_cb = NULL;
+                               handle->stats_user_data = NULL;
+                       }
+                       break;
+               case STC_EVENT_STATS_GET_ALL_RSP:
+                       if (handle->stats_all_cb) {
+                               if (err == STC_ERROR_NONE) {
+                                       for (data = info_data; data; data = data->next) {
+                                               stc_stats_info_h info = data->data;
+                                               ret = handle->stats_all_cb(err,
+                                                       info, handle->stats_all_user_data);
+
+                                               if (ret == STC_CALLBACK_CANCEL)
+                                                       break;
+                                       }
+                               } else {
+                                       handle->stats_all_cb(err, NULL, NULL);
+                               }
+
+                               handle->stats_all_cb = NULL;
+                               handle->stats_all_user_data = NULL;
+                       }
+                       break;
+               case STC_EVENT_STATS_GET_TOTAL_RSP:
+                       if (handle->stats_total_cb) {
+                               if (err == STC_ERROR_NONE) {
+                                       for (data = info_data; data; data = data->next) {
+                                               stc_stats_info_h info = data->data;
+                                               ret = handle->stats_total_cb(err,
+                                                       info, handle->stats_total_user_data);
+
+                                               if (ret == STC_CALLBACK_CANCEL)
+                                                       break;
+                                       }
+                               } else {
+                                       handle->stats_total_cb(err, NULL, NULL);
+                               }
+
+                               handle->stats_total_cb = NULL;
+                               handle->stats_total_user_data = NULL;
+                       }
+                       break;
+               case STC_EVENT_RESTRICTION_GET_RSP:
+                       if (handle->restriction_cb) {
+                               if (err == STC_ERROR_NONE) {
+                                       for (data = info_data; data; data = data->next) {
+                                               stc_restriction_info_h info = data->data;
+                                               ret = handle->restriction_cb(err,
+                                                       info, handle->restriction_user_data);
+
+                                               if (ret == STC_CALLBACK_CANCEL)
+                                                       break;
+                                       }
+                               } else {
+                                       handle->restriction_cb(err, NULL, NULL);
+                               }
+
+                               handle->restriction_cb = NULL;
+                               handle->restriction_user_data = NULL;
+                       }
+                       break;
+               case STC_EVENT_RESTRICTION_GET_ALL_RSP:
+                       if (handle->restriction_all_cb) {
+                               if (err == STC_ERROR_NONE) {
+                                       for (data = info_data; data; data = data->next) {
+                                               stc_restriction_info_h info = data->data;
+                                               ret = handle->restriction_all_cb(err,
+                                                       info, handle->restriction_all_user_data);
+
+                                               if (ret == STC_CALLBACK_CANCEL)
+                                                       break;
+                                       }
+                               } else {
+                                       handle->restriction_all_cb(err, NULL, NULL);
+                               }
+
+                               handle->restriction_all_cb = NULL;
+                               handle->restriction_all_user_data = NULL;
+                       }
+                       break;
+               default:
+                       break;
+               }
+       }
+}
+
+static void __stc_event_cb(stc_event_info_s *event_info, void *user_data)
+{
+       STC_LOGI("STC event callback [%d]", event_info->event);
+
+       switch (event_info->event) {
+       case STC_EVENT_STATS_GET_RSP:
+       case STC_EVENT_STATS_GET_ALL_RSP:
+       case STC_EVENT_STATS_GET_TOTAL_RSP:
+       case STC_EVENT_RESTRICTION_GET_RSP:
+       case STC_EVENT_RESTRICTION_GET_ALL_RSP:
+               {
+                       stc_error_e error = event_info->error;
+                       GSList *info_data = (GSList *)event_info->info_data;
+                       __stc_callback_foreach(
+                               event_info->event,
+                               error, info_data);
+                       g_slist_free(info_data);
+               }
+               break;
+       default:
+               break;
+       }
+}
+
+int _stc_initialize(void)
+{
+       int ret = STC_ERROR_NONE;
+
+       ret = _stc_register_event_cb((stc_event_cb)__stc_event_cb, NULL);
+       if (ret != STC_ERROR_NONE && ret != STC_ERROR_ALREADY_INITIALIZED) {
+               STC_LOGE("Failed to register event callback [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+int _stc_deinitialize(void)
+{
+       int ret = STC_ERROR_NONE;
+
+       ret = _stc_deregister_event_cb();
+       if (ret != STC_ERROR_NONE && ret != STC_ERROR_NOT_INITIALIZED) {
+               STC_LOGE("Failed to deregister event callback [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       return STC_ERROR_NONE;;
+}
+
+int _stc_handle_create(stc_h *stc)
+{
+       *stc = g_try_malloc0(sizeof(stc_handle_s));
+       if (*stc == NULL) {
+               STC_LOGE("Failed to create stc handle");
+               return STC_ERROR_OUT_OF_MEMORY;
+       }
+
+       STC_LOGI("Create new handle [%p]", *stc);
+       return STC_ERROR_NONE;
+}
+
+int _stc_handle_add(stc_h *stc)
+{
+       g_stc_handle_list = g_slist_append(g_stc_handle_list, *stc);
+       return STC_ERROR_NONE;
+}
+
+int _stc_handle_remove(stc_h stc)
+{
+       g_stc_handle_list = g_slist_remove(g_stc_handle_list, stc);
+
+       g_free(stc);
+       stc = NULL;
+
+       return STC_ERROR_NONE;
+}
+
+bool _stc_handle_check_validity(stc_h stc)
+{
+       STC_RETURN_VAL_IF(stc == NULL,
+               false, "STC handle is null");
+
+       return __stc_handle_find(stc);
+}
+
+int _stc_handle_get_count(void)
+{
+       return ((int)g_slist_length(g_stc_handle_list));
+}
+
+void _stc_callback_set_stats_info(stc_h stc,
+                       stc_stats_info_cb user_cb,      void *user_data)
+{
+       stc_handle_s *handle = (stc_handle_s *)stc;
+
+       handle->stats_cb = user_cb;
+       handle->stats_user_data = user_data;
+}
+
+void _stc_callback_set_stats_all_info(stc_h stc,
+                       stc_stats_info_cb user_cb,      void *user_data)
+{
+       stc_handle_s *handle = (stc_handle_s *)stc;
+
+       handle->stats_all_cb = user_cb;
+       handle->stats_all_user_data = user_data;
+}
+
+void _stc_callback_set_stats_total_info(stc_h stc,
+                       stc_stats_info_cb user_cb,      void *user_data)
+{
+       stc_handle_s *handle = (stc_handle_s *)stc;
+
+       handle->stats_total_cb = user_cb;
+       handle->stats_total_user_data = user_data;
+}
+
+void _stc_callback_set_restriction_info(stc_h stc,
+                       stc_restriction_info_cb user_cb, void *user_data)
+{
+       stc_handle_s *handle = (stc_handle_s *)stc;
+
+       handle->restriction_cb = user_cb;
+       handle->restriction_user_data = user_data;
+}
+
+void _stc_callback_set_restriction_all_info(stc_h stc,
+                       stc_restriction_info_cb user_cb, void *user_data)
+{
+       stc_handle_s *handle = (stc_handle_s *)stc;
+
+       handle->restriction_all_cb = user_cb;
+       handle->restriction_all_user_data = user_data;
+}
+
diff --git a/src/internal/stc-signal.c b/src/internal/stc-signal.c
new file mode 100755 (executable)
index 0000000..2eef46e
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file implements Smart Traffic Control (STC) user library.
+ *
+ * @file        stc-signal.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#include <glib.h>
+#include <gio/gio.h>
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+#include "stc-private.h"
+#include "stc-dbus.h"
+#include "stc-log.h"
+#include "stc-util.h"
+
+#include "stc-signal.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+static __thread guint gdbus_subscribe_id_stc_manager_stats = 0;
+static __thread guint gdbus_subscribe_id_stc_manager_restriction = 0;
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+static int __stc_handle_stats(GVariant *param)
+{
+       return STC_ERROR_NONE;
+}
+
+static int __stc_handle_restriction(GVariant *param)
+{
+       return STC_ERROR_NONE;
+}
+
+static void __stc_stats_signal_filter(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       if (g_strcmp0(sig, STC_MANAGER_SIGNAL_STATS) == 0)
+               __stc_handle_stats(param);
+}
+
+static void __stc_restriction_signal_filter(GDBusConnection *conn,
+               const gchar *name, const gchar *path, const gchar *interface,
+               const gchar *sig, GVariant *param, gpointer user_data)
+{
+       if (g_strcmp0(sig, STC_MANAGER_SIGNAL_RESTRICTION) == 0)
+               __stc_handle_restriction(param);
+}
+
+int _stc_register_signal(void)
+{
+       GDBusConnection *connection;
+       stc_error_e err = STC_ERROR_NONE;
+
+       connection = _stc_dbus_get_connection();
+       if (connection == NULL)
+               return STC_ERROR_NOT_INITIALIZED;
+
+       gdbus_subscribe_id_stc_manager_stats = g_dbus_connection_signal_subscribe(
+                       connection,
+                       STC_MANAGER_SERVICE,
+                       STC_MANAGER_STATS_INTERFACE,
+                       NULL,
+                       STC_MANAGER_STATS_PATH,
+                       NULL,
+                       G_DBUS_SIGNAL_FLAGS_NONE,
+                       __stc_stats_signal_filter,
+                       NULL,
+                       NULL);
+
+       gdbus_subscribe_id_stc_manager_restriction = g_dbus_connection_signal_subscribe(
+                       connection,
+                       STC_MANAGER_SERVICE,
+                       STC_MANAGER_RESTRICTION_INTERFACE,
+                       NULL,
+                       STC_MANAGER_RESTRICTION_PATH,
+                       NULL,
+                       G_DBUS_SIGNAL_FLAGS_NONE,
+                       __stc_restriction_signal_filter,
+                       NULL,
+                       NULL);
+
+       if (gdbus_subscribe_id_stc_manager_stats == 0 ||
+               gdbus_subscribe_id_stc_manager_restriction == 0) {
+               STC_LOGE("Failed register signals stc_monitor[%d], stc_manager[%d]",
+                       gdbus_subscribe_id_stc_manager_stats,
+                       gdbus_subscribe_id_stc_manager_restriction);
+               err = STC_ERROR_NOT_INITIALIZED;
+       }
+
+       return err;
+}
+
+int _stc_deregister_signal(void)
+{
+       GDBusConnection *connection;
+       stc_error_e err = STC_ERROR_NONE;
+
+       connection = _stc_dbus_get_connection();
+       if (connection == NULL) {
+               STC_LOGE("Already de-registered");
+               return STC_ERROR_NOT_INITIALIZED;
+       }
+
+       g_dbus_connection_signal_unsubscribe(connection,
+                                               gdbus_subscribe_id_stc_manager_stats);
+       g_dbus_connection_signal_unsubscribe(connection,
+                                               gdbus_subscribe_id_stc_manager_restriction);
+
+       err = _stc_dbus_destroy();
+       if (err != STC_ERROR_NONE)
+               return err;
+
+       return err;
+}
diff --git a/src/stc-info.c b/src/stc-info.c
new file mode 100755 (executable)
index 0000000..7be8c26
--- /dev/null
@@ -0,0 +1,425 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file implements Smart Traffic Control (STC) user library.
+ *
+ * @file        stc-info.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#include <glib.h>
+#include <gio/gio.h>
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+#include "stc-private.h"
+
+#include "stc-dbus.h"
+#include "stc-log.h"
+#include "stc-util.h"
+#include "stc-event.h"
+
+#include "stc-info.h"
+#include "stc-statistics.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+EXPORT_API int stc_stats_info_get_app_id(stc_stats_info_h info, char **app_id)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL || app_id == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_info_s *stats_info =
+               (stc_stats_info_s *)info;
+
+       *app_id = g_strdup(stats_info->app_id);
+       if (*app_id == NULL)
+               return STC_ERROR_OUT_OF_MEMORY;
+
+       STC_LOGI("App id [%s]", *app_id);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_info_get_iface_name(stc_stats_info_h info, char **iface_name)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL || iface_name == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_info_s *stats_info =
+               (stc_stats_info_s *)info;
+
+       *iface_name = g_strdup(stats_info->iface_name);
+       if (*iface_name == NULL)
+               return STC_ERROR_OUT_OF_MEMORY;
+
+       STC_LOGI("Ifname [%s]", *iface_name);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_info_get_imsi(stc_stats_info_h info, char **imsi)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL || imsi == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_info_s *stats_info =
+               (stc_stats_info_s *)info;
+
+       *imsi = g_strdup(stats_info->imsi);
+       if (*imsi == NULL)
+               return STC_ERROR_OUT_OF_MEMORY;
+
+       STC_LOGI("Imsi [%s]", *imsi);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_info_get_time_interval(stc_stats_info_h info,
+               time_t *from, time_t *to)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_info_s *stats_info =
+               (stc_stats_info_s *)info;
+
+       *from = stats_info->interval.from;
+       *to = stats_info->interval.to;
+
+       STC_LOGI("Time interval from[%lu] to[%lu]", *from, *to);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_info_get_iface_type(stc_stats_info_h info,
+               stc_iface_type_e *iface_type)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_info_s *stats_info =
+               (stc_stats_info_s *)info;
+
+       *iface_type = stats_info->iface_type;
+
+       STC_LOGI("Iftype [%s]",
+               _stc_convert_iface_type_to_string(*iface_type));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_info_get_counter(stc_stats_info_h info,
+               uint64_t *incoming, uint64_t *outgoing)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_info_s *stats_info =
+               (stc_stats_info_s *)info;
+
+       *incoming = stats_info->cnt.incoming_bytes;
+       *outgoing = stats_info->cnt.outgoing_bytes;
+
+       STC_LOGI("Counters incoming[%llu] outgoing[%llu]",
+               *incoming, *outgoing);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_info_get_roaming_type(stc_stats_info_h info,
+               stc_roaming_type_e *roaming_type)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_info_s *stats_info =
+               (stc_stats_info_s *)info;
+
+       *roaming_type = stats_info->roaming_type;
+
+       STC_LOGI("Roaming type [%s]",
+               _stc_convert_roaming_to_string(*roaming_type));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_info_get_protocol_type(stc_stats_info_h info,
+               stc_protocol_type_e *protocol)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_info_s *stats_info =
+               (stc_stats_info_s *)info;
+
+       *protocol = stats_info->protocol_type;
+
+       STC_LOGI("Protocol type [%s]",
+               _stc_convert_protocol_to_string(*protocol));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_info_get_process_state(stc_stats_info_h info,
+               stc_process_state_e *state)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_info_s *stats_info =
+               (stc_stats_info_s *)info;
+
+       *state = stats_info->process_state;
+
+       STC_LOGI("Process state [%s]",
+               _stc_convert_process_state_to_string(*state));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_info_get_app_id(stc_restriction_info_h info, char **app_id)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL || app_id == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_info_s *restriction_info =
+               (stc_restriction_info_s *)info;
+
+       *app_id = g_strdup(restriction_info->app_id);
+       if (*app_id == NULL)
+               return STC_ERROR_OUT_OF_MEMORY;
+
+       STC_LOGI("App id [%s]", *app_id);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_info_get_iface_name(stc_restriction_info_h info,
+               char **iface_name)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL || iface_name == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_info_s *restriction_info =
+               (stc_restriction_info_s *)info;
+
+       *iface_name = g_strdup(restriction_info->iface_name);
+       if (*iface_name == NULL)
+               return STC_ERROR_OUT_OF_MEMORY;
+
+       STC_LOGI("Ifname [%s]", *iface_name);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_info_get_imsi(stc_restriction_info_h info, char **imsi)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL || imsi == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_info_s *restriction_info =
+               (stc_restriction_info_s *)info;
+
+       *imsi = g_strdup(restriction_info->imsi);
+       if (*imsi == NULL)
+               return STC_ERROR_OUT_OF_MEMORY;
+
+       STC_LOGI("Imsi [%s]", *imsi);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_info_get_status(stc_restriction_info_h info,
+               stc_restriction_status_e *status)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_info_s *restriction_info =
+               (stc_restriction_info_s *)info;
+
+       *status = restriction_info->rst_status;
+
+       STC_LOGI("Status [%s]",
+               _stc_convert_rst_status_to_string(*status));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_info_get_iface_type(stc_restriction_info_h info,
+               stc_iface_type_e *iface_type)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_info_s *restriction_info =
+               (stc_restriction_info_s *)info;
+
+       *iface_type = restriction_info->iface_type;
+
+       STC_LOGI("Iftype [%s]",
+               _stc_convert_iface_type_to_string(*iface_type));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_info_get_limit(stc_restriction_info_h info,
+               uint64_t *rx_limit, uint64_t *tx_limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_info_s *restriction_info =
+               (stc_restriction_info_s *)info;
+
+       *rx_limit = restriction_info->rx_limit;
+       *tx_limit = restriction_info->tx_limit;
+
+       STC_LOGI("Limit rx[%llu] tx[%llu]",
+               *rx_limit, *tx_limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_info_get_warning_limit(stc_restriction_info_h info,
+               uint64_t *rx_warning_limit, uint64_t *tx_warning_limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_info_s *restriction_info =
+               (stc_restriction_info_s *)info;
+
+       *rx_warning_limit = restriction_info->rx_warning_limit;
+       *tx_warning_limit = restriction_info->tx_warning_limit;
+
+       STC_LOGI("Warning limit rx[%llu] tx[%llu]",
+               *rx_warning_limit, *tx_warning_limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_info_get_roaming_type(stc_restriction_info_h info,
+               stc_roaming_type_e *roaming_type)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (info == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_info_s *restriction_info =
+               (stc_restriction_info_s *)info;
+
+       *roaming_type = restriction_info->roaming_type;
+
+       STC_LOGI("Roaming type [%s]",
+               _stc_convert_roaming_to_string(*roaming_type));
+
+       return STC_ERROR_NONE;
+}
+
diff --git a/src/stc-manager.c b/src/stc-manager.c
new file mode 100755 (executable)
index 0000000..5a086f3
--- /dev/null
@@ -0,0 +1,397 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file implements Smart Traffic Control (STC) user library.
+ *
+ * @file        stc-manager.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#include <glib.h>
+#include <gio/gio.h>
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+#include "stc-private.h"
+
+#include "stc-dbus.h"
+#include "stc-log.h"
+#include "stc-util.h"
+
+#include "stc-reset.h"
+#include "stc-statistics.h"
+#include "stc-restriction.h"
+
+#include "stc-manager.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+EXPORT_API int stc_reset_stats(stc_h stc, stc_reset_rule_h rule)
+{
+       int ret = STC_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _stc_reset_check_rule(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Invalid reset rule [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       ret = _stc_reset_stats(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Failed to reset stats [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       STC_LOGI("Reset stats");
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_get_stats(stc_h stc, stc_stats_rule_h rule,
+               stc_stats_info_cb info_cb, void *user_data)
+{
+       int ret = STC_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (info_cb == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _stc_stats_check_get_rule(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Invalid stats rule [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       _stc_callback_set_stats_info(stc,
+               info_cb, user_data);
+
+       ret = _stc_stats_get(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Failed to request stats info [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_foreach_stats(stc_h stc, stc_stats_rule_h rule,
+               stc_stats_info_cb info_cb, void *user_data)
+{
+       int ret = STC_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (info_cb == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _stc_stats_check_get_all_rule(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Invalid stats rule [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       _stc_callback_set_stats_all_info(stc,
+               info_cb, user_data);
+
+       ret = _stc_stats_get_all(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Failed to request stats all info [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_get_total_stats(stc_h stc, stc_stats_rule_h rule,
+               stc_stats_info_cb info_cb, void *user_data)
+{
+       int ret = STC_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (info_cb == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _stc_stats_check_get_total_rule(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Invalid stats rule [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       _stc_callback_set_stats_total_info(stc,
+               info_cb, user_data);
+
+       ret = _stc_stats_get_total(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Failed to request stats total info [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_set_restriction(stc_h stc,
+                       stc_restriction_rule_h rule)
+{
+       int ret = STC_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _stc_restriction_validate_rule(rule, STC_RST_TYPE_SET);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Invalid restriction rule [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       ret = _stc_restriction_set(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Failed to set restriction [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_exclude_restriction(stc_h stc, stc_restriction_rule_h rule)
+{
+       int ret = STC_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _stc_restriction_validate_rule(rule, STC_RST_TYPE_EXCLUDE);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Invalid restriction rule [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       ret = _stc_restriction_exclude(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Failed to exclude restriction [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_unset_restriction(stc_h stc, stc_restriction_rule_h rule)
+{
+       int ret = STC_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _stc_restriction_validate_rule(rule, STC_RST_TYPE_UNSET);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Invalid restriction rule [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       ret = _stc_restriction_unset(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Failed to unset restriction [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_get_restriction(stc_h stc, stc_restriction_rule_h rule,
+               stc_restriction_info_cb info_cb, void *user_data)
+{
+       int ret = STC_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (info_cb == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _stc_restriction_check_get_rule(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Invalid restriction rule [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       _stc_callback_set_restriction_info(stc,
+               info_cb, user_data);
+
+       ret = _stc_restriction_get(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Failed to request restriction info [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_foreach_restriction(stc_h stc, stc_restriction_rule_h rule,
+               stc_restriction_info_cb info_cb, void *user_data)
+{
+       int ret = STC_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (info_cb == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _stc_restriction_check_get_all_rule(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Invalid restriction rule [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       _stc_callback_set_restriction_all_info(stc,
+               info_cb, user_data);
+
+       ret = _stc_restriction_get_all(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Failed to request restriction all info [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_get_restriction_status(stc_h stc, stc_restriction_rule_h rule,
+               stc_restriction_status_e *status)
+{
+       int ret = STC_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _stc_restriction_check_get_status_rule(rule);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Invalid restriction rule [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       ret = _stc_restriction_get_status(rule, status);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Failed to get restriction status [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       STC_LOGI("Get restriction status");
+
+       return STC_ERROR_NONE;
+}
+
diff --git a/src/stc-reset.c b/src/stc-reset.c
new file mode 100755 (executable)
index 0000000..7dd18f2
--- /dev/null
@@ -0,0 +1,438 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file implements Smart Traffic Control (STC) user library.
+ *
+ * @file        stc-reset.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#include <glib.h>
+#include <gio/gio.h>
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+#include "stc-private.h"
+
+#include "stc-dbus.h"
+#include "stc-log.h"
+#include "stc-util.h"
+#include "stc-event.h"
+
+#include "stc-reset.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+static void __stc_reset_init_rule(stc_reset_rule_s *rule)
+{
+       rule->iface_type = STC_IFACE_UNKNOWN;
+       time_t until = time(0);
+       until -= RESET_INTERVAL;
+       rule->interval.from = 0;
+       rule->interval.to = until;
+}
+
+static void __stc_reset_deinit_rule(stc_reset_rule_h rule)
+{
+       g_free(rule);
+}
+
+static void __stc_reset_stats_make_params(
+                       stc_reset_rule_h rule, GVariant **params)
+{
+       GVariantBuilder *builder;
+       stc_reset_rule_s *reset_rule = rule;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESET_RULE_INTERVAL_FROM,
+               g_variant_new_uint64(reset_rule->interval.from));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESET_RULE_INTERVAL_TO,
+               g_variant_new_uint64(reset_rule->interval.to));
+
+       if (reset_rule->app_id[0] != '\0') {
+               g_variant_builder_add(builder, "{sv}",
+                       STC_RESET_RULE_APP_ID,
+                       g_variant_new_string(reset_rule->app_id));
+       }
+
+       if (reset_rule->imsi[0] != '\0') {
+               g_variant_builder_add(builder, "{sv}",
+                       STC_RESET_RULE_IMSI,
+                       g_variant_new_string(reset_rule->imsi));
+       }
+
+       if (reset_rule->iface_type != STC_IFACE_UNKNOWN) {
+               g_variant_builder_add(builder, "{sv}",
+                       STC_RESET_RULE_IFTYPE,
+                       g_variant_new_uint16(reset_rule->iface_type));
+       }
+
+       if (reset_rule->conn_period != STC_CONN_PERIOD_UNKNOWN) {
+               g_variant_builder_add(builder, "{sv}",
+                       STC_RESET_RULE_CONNECION_STATE,
+                       g_variant_new_int32(reset_rule->conn_period));
+       }
+
+       *params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+}
+
+stc_error_e _stc_reset_check_rule(stc_reset_rule_h rule)
+{
+       stc_reset_rule_s *reset_rule = (stc_reset_rule_s *)rule;
+
+       STC_RETURN_VAL_IF(reset_rule == NULL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Reset rule should be set");
+
+       STC_RETURN_VAL_IF(reset_rule->interval.from <= STC_INVALID_TIME_INTERVAL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid time interval for [from]");
+
+       STC_RETURN_VAL_IF(reset_rule->interval.to <= STC_INVALID_TIME_INTERVAL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid time interval for [to]");
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_reset_stats(stc_reset_rule_h rule)
+{
+       GVariant *message = NULL;
+       GVariant *params = NULL;
+       stc_error_e error = STC_ERROR_NONE;
+       int result = 0;
+
+       __stc_reset_stats_make_params(rule, &params);
+
+       message = _stc_dbus_invoke_method(
+               STC_MANAGER_SERVICE,
+               STC_MANAGER_STATS_PATH,
+               STC_MANAGER_STATS_INTERFACE,
+               STC_MANAGER_METHOD_STATS_RESET,
+               params,
+               &error);
+
+       STC_RETURN_VAL_IF(message == NULL,
+               error, "Failed to invoke dbus method");
+
+       g_variant_get(message, "(i)", &result);
+       STC_LOGI("Successfully reset stats [%d]", result);
+       g_variant_unref(message);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_reset_rule_create(stc_h stc, stc_reset_rule_h *rule)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_reset_rule_s *reset_rule = g_try_malloc0(sizeof(stc_reset_rule_s));
+       if (reset_rule == NULL) {
+               STC_LOGE("Memory allocation failed");
+               return STC_ERROR_OUT_OF_MEMORY;
+       }
+
+       __stc_reset_init_rule(reset_rule);
+       *rule = (stc_reset_rule_h)reset_rule;
+       STC_LOGI("Reset rule successfully created");
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_reset_rule_destroy(stc_reset_rule_h rule)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       __stc_reset_deinit_rule(rule);
+       STC_LOGI("Reset rule successfully destroyed");
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_reset_rule_set_app_id(stc_reset_rule_h rule, const char *app_id)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_reset_rule_s *reset_rule = rule;
+
+       if (app_id == NULL)
+               reset_rule->app_id[0] = '\0';
+       else
+               g_strlcpy(reset_rule->app_id, app_id, STC_APP_ID_LEN);
+
+       STC_LOGI("App id [%s]", reset_rule->app_id);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_reset_rule_set_imsi(stc_reset_rule_h rule, const char *imsi)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_reset_rule_s *reset_rule = rule;
+
+       if (imsi == NULL)
+               reset_rule->imsi[0] = '\0';
+       else
+               g_strlcpy(reset_rule->imsi, imsi, STC_IMSI_LEN);
+
+       STC_LOGI("Imsi [%s]", reset_rule->imsi);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_reset_rule_set_iface_type(stc_reset_rule_h rule,
+               stc_iface_type_e iface_type)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_reset_rule_s *reset_rule = rule;
+
+       switch (iface_type) {
+       case STC_IFACE_UNKNOWN:
+       case STC_IFACE_DATACALL:
+       case STC_IFACE_WIFI:
+       case STC_IFACE_WIRED:
+       case STC_IFACE_BLUETOOTH:
+       case STC_IFACE_ALL:
+               reset_rule->iface_type = iface_type;
+               break;
+       default:
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       STC_LOGI("Iface type [%s]",
+               _stc_convert_iface_type_to_string(reset_rule->iface_type));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_reset_rule_set_time_interval(stc_reset_rule_h rule,
+               time_t from, time_t to)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (from < 0 || to < 0) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_reset_rule_s *reset_rule = (stc_reset_rule_s *)rule;
+       reset_rule->interval.from = from;
+       reset_rule->interval.to = to;
+
+       STC_LOGI("Time interval from[%lu] to[%lu]",
+               reset_rule->interval.from, reset_rule->interval.to);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_reset_rule_set_connection_period(stc_reset_rule_h rule,
+               stc_conn_period_e period)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_reset_rule_s *reset_rule = rule;
+
+       switch (period) {
+       case STC_CONN_PERIOD_UNKNOWN:
+       case STC_CONN_PERIOD_LAST_RECEIVED_DATA:
+       case STC_CONN_PERIOD_LAST_SENT_DATA:
+       case STC_CONN_PERIOD_TOTAL_RECEIVED_DATA:
+       case STC_CONN_PERIOD_TOTAL_SENT_DATA:
+               reset_rule->conn_period = period;
+               break;
+       default:
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       STC_LOGI("Connection period [%s]",
+               _stc_convert_connection_period_to_string(reset_rule->conn_period));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_reset_rule_get_app_id(stc_reset_rule_h rule, char **app_id)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL || app_id == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_reset_rule_s *reset_rule = (stc_reset_rule_s *)rule;
+
+       *app_id = g_strdup(reset_rule->app_id);
+       if (*app_id == NULL)
+               return STC_ERROR_OUT_OF_MEMORY;
+
+       STC_LOGI("App id [%s]", *app_id);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_reset_rule_get_imsi(stc_reset_rule_h rule, char **imsi)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL || imsi == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_reset_rule_s *reset_rule = (stc_reset_rule_s *)rule;
+
+       *imsi = g_strdup(reset_rule->imsi);
+       if (*imsi == NULL)
+               return STC_ERROR_OUT_OF_MEMORY;
+
+       STC_LOGI("Imsi [%s]", *imsi);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_reset_rule_get_iface_type(stc_reset_rule_h rule,
+               stc_iface_type_e *iface_type)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_reset_rule_s *reset_rule = (stc_reset_rule_s *)rule;
+
+       *iface_type = reset_rule->iface_type;
+
+       STC_LOGI("Iftype [%s]", _stc_convert_iface_type_to_string(*iface_type));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_reset_rule_get_time_interval(stc_reset_rule_h rule,
+               time_t *from, time_t *to)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_reset_rule_s *reset_rule = (stc_reset_rule_s *)rule;
+
+       *from = reset_rule->interval.from;
+       *to = reset_rule->interval.to;
+
+       STC_LOGI("Time interval from[%lu] to[%lu]", *from, *to);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_reset_rule_get_connection_period(stc_reset_rule_h rule,
+               stc_conn_period_e *period)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_reset_rule_s *reset_rule = (stc_reset_rule_s *)rule;
+
+       *period = reset_rule->conn_period;
+
+       STC_LOGI("Connection period [%s]",
+               _stc_convert_connection_period_to_string(*period));
+
+       return STC_ERROR_NONE;
+}
+
diff --git a/src/stc-restriction.c b/src/stc-restriction.c
new file mode 100755 (executable)
index 0000000..dccc15e
--- /dev/null
@@ -0,0 +1,1187 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file implements Smart Traffic Control (STC) user library.
+ *
+ * @file        stc-restriction.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#include <glib.h>
+#include <gio/gio.h>
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+#include "stc-private.h"
+
+#include "stc-dbus.h"
+#include "stc-log.h"
+#include "stc-util.h"
+#include "stc-event.h"
+
+#include "stc-info.h"
+#include "stc-restriction.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+static void __stc_restriction_init_rule(stc_restriction_rule_s *rule)
+{
+       rule->app_id[0] = '\0';
+       rule->iface_name[0] = '\0';
+       rule->iface_type = STC_IFACE_ALL;
+       rule->rst_state = STC_RESTRICTION_REMOVED;
+       rule->tx_limit = 0;
+       rule->rx_limit = 0;
+       rule->tx_warning_limit = 0;
+       rule->rx_warning_limit = 0;
+       rule->roaming_type = STC_ROAMING_DISABLED;
+       rule->imsi[0] = '\0';
+}
+
+static void __stc_restriction_deinit_rule(stc_restriction_rule_h rule)
+{
+       g_free(rule);
+}
+
+static void __stc_restriction_rule_make_params(
+                       stc_restriction_rule_h rule,
+                       GVariant **params)
+{
+       GVariantBuilder *builder;
+       stc_restriction_rule_s *restriction_rule = rule;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESTRICTION_RULE_APP_ID,
+               g_variant_new_string(restriction_rule->app_id));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESTRICTION_RULE_IFNAME,
+               g_variant_new_string(restriction_rule->iface_name));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESTRICTION_RULE_IFTYPE,
+               g_variant_new_uint16(restriction_rule->iface_type));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESTRICTION_RULE_ROAMING,
+               g_variant_new_uint16(restriction_rule->roaming_type));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESTRICTION_RULE_IMSI,
+               g_variant_new_string(restriction_rule->imsi));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESTRICTION_RULE_RX_LIMIT,
+               g_variant_new_uint64(restriction_rule->rx_limit));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESTRICTION_RULE_TX_LIMIT,
+               g_variant_new_uint64(restriction_rule->tx_limit));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESTRICTION_RULE_RX_WARNING_LIMIT,
+               g_variant_new_uint64(restriction_rule->rx_warning_limit));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_RESTRICTION_RULE_TX_WARNING_LIMIT,
+               g_variant_new_uint64(restriction_rule->tx_warning_limit));
+
+       *params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+       g_variant_builder_unref(builder);
+}
+
+static void __stc_restriction_get_make_params(
+                       stc_restriction_rule_h rule, GVariant **params)
+{
+       stc_restriction_rule_s *restriction_rule = rule;
+
+       *params = g_variant_new("(s)", restriction_rule->app_id);
+}
+
+static void __stc_restriction_get_status_make_params(
+                       stc_restriction_rule_h rule,
+                       GVariant **params)
+{
+       stc_restriction_rule_s *restriction_rule = rule;
+
+       *params = g_variant_new("(si)",
+               restriction_rule->app_id, restriction_rule->iface_type);
+}
+
+static void __stc_restriction_extract_info_cb(const char *key,
+                       GVariant *value, void *user_data)
+{
+       stc_restriction_info_s *restriction_info =
+               (stc_restriction_info_s *)user_data;
+
+       if (restriction_info == NULL)
+               return;
+
+       if (!g_strcmp0(key, STC_RESTRICTION_INFO_APP_ID)) {
+               const char *app_id = g_variant_get_string(value, NULL);
+               if (app_id != NULL)
+                       g_strlcpy(restriction_info->app_id,
+                               app_id, strlen(restriction_info->app_id));
+
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_IFNAME)) {
+               const char *iface_name = g_variant_get_string(value, NULL);
+               if (iface_name != NULL)
+                       g_strlcpy(restriction_info->iface_name,
+                               iface_name, strlen(restriction_info->iface_name));
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_IMSI)) {
+               const char *imsi = g_variant_get_string(value, NULL);
+               if (imsi != NULL)
+                       g_strlcpy(restriction_info->imsi,
+                               imsi, strlen(restriction_info->imsi));
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_IFTYPE)) {
+               restriction_info->iface_type =
+                       (stc_iface_type_e)g_variant_get_uint16(value);
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_RST_STATUS)) {
+               restriction_info->rst_status =
+                       (stc_restriction_status_e)g_variant_get_uint16(value);
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_RX_LIMIT)) {
+               restriction_info->rx_limit = g_variant_get_uint64(value);
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_TX_LIMIT)) {
+               restriction_info->tx_limit = g_variant_get_uint64(value);
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_RX_WARNING_LIMIT)) {
+               restriction_info->rx_warning_limit = g_variant_get_uint64(value);
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_TX_WARNING_LIMIT)) {
+               restriction_info->tx_warning_limit = g_variant_get_uint64(value);
+
+       } else if (!g_strcmp0(key, STC_RESTRICTION_INFO_ROAMING)) {
+               restriction_info->roaming_type =
+                       (stc_roaming_type_e)g_variant_get_uint16(value);
+
+       }
+
+}
+
+static void __stc_restriction_print_info(
+                       stc_restriction_info_s *info)
+{
+       STC_LOGD("App_id: [%s] Ifname: [%s] Iftype: [%s] Imsi: [%s] Roaming: [%s] "
+               "Status: [%s] Limit: Rx [%llu] Tx [%llu] Warning_limit: Rx [%llu] Tx [%llu]",
+               (info->app_id[0] != '\0') ? info->app_id : "NULL",
+               (info->iface_name[0] != '\0') ? info->iface_name : "NULL",
+               _stc_convert_iface_type_to_string(info->iface_type),
+               (info->imsi[0] != '\0') ? info->imsi : "NULL",
+               _stc_convert_roaming_to_string(info->roaming_type),
+               _stc_convert_rst_status_to_string(info->rst_status),
+               info->rx_limit, info->tx_limit,
+               info->rx_warning_limit, info->tx_warning_limit);
+}
+
+static void __stc_restriction_get_per_app_id_reply(
+                       GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+       GDBusConnection *conn = NULL;
+       GError *dbus_error = NULL;
+       GVariant *dbus_data = NULL;
+       GVariantIter *iter = NULL;
+       stc_error_e dbus_result = STC_ERROR_NONE;
+       stc_error_e error = STC_ERROR_NONE;
+       stc_restriction_info_s *restriction_info = NULL;
+       GSList *restriction_list = NULL;
+       stc_event_info_s event_data = { 0, };
+
+       conn = G_DBUS_CONNECTION(source_object);
+       dbus_data = g_dbus_connection_call_finish(conn, res, &dbus_error);
+       if (dbus_error != NULL) {
+               error = _stc_convert_error_string_to_enum(dbus_error->message);
+               g_error_free(dbus_error);
+       }
+
+       if (_stc_event_get_request_table_state(STC_REQUEST_TABLE_RESTRICTION_GET))
+               _stc_event_set_request_table_state(STC_REQUEST_TABLE_RESTRICTION_GET, false);
+
+       if (error == STC_ERROR_NONE) {
+               g_variant_get(dbus_data, "(ia{sv})", &dbus_result, &iter);
+
+               if (iter != NULL) {
+                       restriction_info = g_try_malloc0(
+                               sizeof(stc_restriction_info_s));
+
+                       _stc_dbus_dictionary_foreach(iter,
+                               __stc_restriction_extract_info_cb, restriction_info);
+
+                       __stc_restriction_print_info(restriction_info);
+
+                       restriction_list = g_slist_append(restriction_list,
+                               (stc_restriction_info_s *)restriction_info);
+
+                       g_variant_iter_free(iter);
+               }
+
+               event_data.event = STC_EVENT_RESTRICTION_GET_RSP;
+               event_data.info_data = (GSList *)restriction_list;
+               event_data.datalength = g_slist_length(restriction_list);
+               event_data.error = dbus_result;
+       } else {
+               STC_LOGE("Get restriction per app id response error [%s]",
+                       _stc_convert_error_type_to_string(error));
+
+               event_data.event = STC_EVENT_RESTRICTION_GET_RSP;
+               event_data.info_data = NULL;
+               event_data.datalength = 0;
+               event_data.error = error;
+       }
+
+       _stc_event_add_client_idle_cb(&event_data, user_data);
+}
+
+static void __stc_restriction_get_all_reply(
+                       GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+       GDBusConnection *conn = NULL;
+       GError *dbus_error = NULL;
+       GVariant *dbus_data = NULL;
+       GVariantIter *iter = NULL;
+       GVariantIter *iter_row = NULL;
+       stc_error_e dbus_result = STC_ERROR_NONE;
+       stc_error_e error = STC_ERROR_NONE;
+       stc_restriction_info_s *restriction_info = NULL;
+       GSList *restriction_list = NULL;
+       stc_event_info_s event_data = { 0, };
+
+       conn = G_DBUS_CONNECTION(source_object);
+       dbus_data = g_dbus_connection_call_finish(conn, res, &dbus_error);
+       if (dbus_error != NULL) {
+               error = _stc_convert_error_string_to_enum(dbus_error->message);
+               g_error_free(dbus_error);
+       }
+
+       if (_stc_event_get_request_table_state(STC_REQUEST_TABLE_RESTRICTION_GET_ALL))
+               _stc_event_set_request_table_state(STC_REQUEST_TABLE_RESTRICTION_GET_ALL, false);
+
+       if (error == STC_ERROR_NONE) {
+               g_variant_get(dbus_data, "(iaa{sv})", &dbus_result, &iter);
+
+               while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
+                       restriction_info = g_try_malloc0(
+                               sizeof(stc_restriction_info_s));
+
+                       _stc_dbus_dictionary_foreach(iter_row,
+                               __stc_restriction_extract_info_cb, restriction_info);
+
+                       __stc_restriction_print_info(restriction_info);
+
+                       restriction_list = g_slist_append(restriction_list,
+                               (stc_restriction_info_s *)restriction_info);
+
+                       g_variant_iter_free(iter_row);
+               }
+               g_variant_iter_free(iter);
+
+               event_data.event = STC_EVENT_RESTRICTION_GET_ALL_RSP;
+               event_data.info_data = (GSList *)restriction_list;
+               event_data.datalength = g_slist_length(restriction_list);
+               event_data.error = dbus_result;
+       } else {
+               STC_LOGE("Get restriction all response error [%s]",
+                       _stc_convert_error_type_to_string(error));
+
+               event_data.event = STC_EVENT_RESTRICTION_GET_ALL_RSP;
+               event_data.info_data = NULL;
+               event_data.datalength = 0;
+               event_data.error = error;
+       }
+
+       _stc_event_add_client_idle_cb(&event_data, user_data);
+}
+
+stc_error_e __stc_restriction_get_per_app_id(
+                       stc_restriction_rule_h rule)
+{
+       GVariant *params = NULL;
+       stc_error_e error = STC_ERROR_NONE;
+
+       STC_RETURN_VAL_IF(
+               _stc_event_get_request_table_state(
+               STC_REQUEST_TABLE_RESTRICTION_GET),
+               STC_ERROR_IN_PROGRESS,
+               "Request in progress");
+
+       _stc_event_set_request_table_state(
+               STC_REQUEST_TABLE_RESTRICTION_GET, true);
+
+       __stc_restriction_get_make_params(rule, &params);
+
+       error = _stc_dbus_invoke_method_nonblock(
+               STC_MANAGER_SERVICE,
+               STC_MANAGER_RESTRICTION_PATH,
+               STC_MANAGER_RESTRICTION_INTERFACE,
+               STC_MANAGER_METHOD_RESTRICTION_GET_PER_APP_ID,
+               params,
+               STC_DBUS_REPLY_TIMEOUT,
+               __stc_restriction_get_per_app_id_reply,
+               NULL);
+
+       if (error != STC_ERROR_NONE) {
+               STC_LOGE("Failed to invoke dbus method nonblock");
+
+               _stc_event_set_request_table_state(
+                       STC_REQUEST_TABLE_RESTRICTION_GET, false);
+               return error;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e __stc_restriction_get_all(
+                       stc_restriction_rule_h rule)
+{
+       stc_error_e error = STC_ERROR_NONE;
+
+       STC_RETURN_VAL_IF(
+               _stc_event_get_request_table_state(
+               STC_REQUEST_TABLE_RESTRICTION_GET_ALL),
+               STC_ERROR_IN_PROGRESS,
+               "Request in progress");
+
+       _stc_event_set_request_table_state(
+               STC_REQUEST_TABLE_RESTRICTION_GET_ALL, true);
+
+       error = _stc_dbus_invoke_method_nonblock(
+               STC_MANAGER_SERVICE,
+               STC_MANAGER_RESTRICTION_PATH,
+               STC_MANAGER_RESTRICTION_INTERFACE,
+               STC_MANAGER_METHOD_RESTRICTION_GET_ALL,
+               NULL,
+               STC_DBUS_REPLY_TIMEOUT,
+               __stc_restriction_get_all_reply,
+               NULL);
+
+       if (error != STC_ERROR_NONE) {
+               STC_LOGE("Failed to invoke dbus method nonblock");
+
+               _stc_event_set_request_table_state(
+                       STC_REQUEST_TABLE_RESTRICTION_GET_ALL, false);
+               return error;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_restriction_validate_rule(
+               stc_restriction_rule_h rule, stc_restriction_type_e rst_type)
+
+{
+       stc_restriction_rule_s *restriction_rule = rule;
+
+       STC_RETURN_VAL_IF(restriction_rule == NULL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Restriction rule should be set");
+
+       STC_RETURN_VAL_IF(rst_type <= STC_RST_TYPE_UNDEF ||
+               rst_type >= STC_RST_TYPE_MAX_VALUE,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid restriction type");
+
+       STC_RETURN_VAL_IF(restriction_rule->app_id[0] == '\0',
+               STC_ERROR_INVALID_PARAMETER,
+               "Application ID is required argument");
+
+       STC_RETURN_VAL_IF(restriction_rule->iface_type <= STC_IFACE_UNKNOWN ||
+               restriction_rule->iface_type > STC_IFACE_ALL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid restriction network interface type [%s]",
+               _stc_convert_iface_type_to_string(restriction_rule->iface_type));
+
+       if (rst_type == STC_RST_TYPE_SET) {
+               STC_RETURN_VAL_IF(restriction_rule->tx_limit < 0,
+                       STC_ERROR_INVALID_PARAMETER,
+                       "Invalid tx limit [%llu]",
+                       restriction_rule->tx_limit);
+
+               STC_RETURN_VAL_IF(restriction_rule->rx_limit < 0,
+                       STC_ERROR_INVALID_PARAMETER,
+                       "Invalid rx limit [%llu]",
+                       restriction_rule->rx_limit);
+
+               STC_RETURN_VAL_IF(restriction_rule->tx_warning_limit < 0,
+                       STC_ERROR_INVALID_PARAMETER,
+                       "Invalid tx warning limit [%llu]",
+                       restriction_rule->tx_warning_limit);
+
+               STC_RETURN_VAL_IF(restriction_rule->rx_warning_limit < 0,
+                       STC_ERROR_INVALID_PARAMETER,
+                       "Invalid rx warning limit [%llu]",
+                       restriction_rule->rx_warning_limit);
+       }
+
+       STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
+               restriction_rule->roaming_type > STC_ROAMING_DISABLED,
+               STC_ERROR_INVALID_PARAMETER,
+               "Roaming type is not valid [%s]",
+               _stc_convert_roaming_to_string(restriction_rule->roaming_type));
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_restriction_check_set_rule(
+                       stc_restriction_rule_h rule)
+{
+       stc_restriction_rule_s *restriction_rule = rule;
+
+       STC_RETURN_VAL_IF(restriction_rule == NULL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Restriction rule should be set");
+
+       STC_RETURN_VAL_IF(restriction_rule->app_id[0] == '\0',
+               STC_ERROR_INVALID_PARAMETER,
+               "Application ID is required argument");
+
+       STC_RETURN_VAL_IF(restriction_rule->iface_type <= STC_IFACE_UNKNOWN ||
+               restriction_rule->iface_type > STC_IFACE_ALL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid restriction network interface type [%s]",
+               _stc_convert_iface_type_to_string(restriction_rule->iface_type));
+
+       STC_RETURN_VAL_IF(restriction_rule->tx_limit < 0,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid tx limit [%llu]",
+               restriction_rule->tx_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->rx_limit < 0,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid rx limit [%llu]",
+               restriction_rule->rx_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->tx_warning_limit < 0,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid tx warning limit [%llu]",
+               restriction_rule->tx_warning_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->rx_warning_limit < 0,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid rx warning limit [%llu]",
+               restriction_rule->rx_warning_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
+               restriction_rule->roaming_type > STC_ROAMING_DISABLED,
+               STC_ERROR_INVALID_PARAMETER,
+               "Roaming type is not valid [%s]",
+               _stc_convert_roaming_to_string(restriction_rule->roaming_type));
+
+       STC_RETURN_VAL_IF(restriction_rule->imsi[0] == '\0',
+               STC_ERROR_INVALID_PARAMETER,
+               "Imsi is not valid");
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_restriction_check_get_rule(
+                       stc_restriction_rule_h rule)
+{
+       stc_restriction_rule_s *restriction_rule = rule;
+
+       STC_RETURN_VAL_IF(restriction_rule == NULL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Restriction rule should be set");
+
+       STC_RETURN_VAL_IF(restriction_rule->app_id[0] == '\0',
+               STC_ERROR_INVALID_PARAMETER,
+               "Application ID is required argument");
+
+       STC_RETURN_VAL_IF(restriction_rule->iface_type <= STC_IFACE_UNKNOWN ||
+               restriction_rule->iface_type > STC_IFACE_ALL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid restriction network interface type [%d]",
+               restriction_rule->iface_type);
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_restriction_check_get_all_rule(
+                       stc_restriction_rule_h rule)
+{
+       stc_restriction_rule_s *restriction_rule = rule;
+
+       STC_RETURN_VAL_IF(restriction_rule == NULL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Restriction rule should be set");
+
+       STC_RETURN_VAL_IF(restriction_rule->iface_type <= STC_IFACE_UNKNOWN ||
+               restriction_rule->iface_type > STC_IFACE_ALL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid restriction network interface type [%d]",
+               restriction_rule->iface_type);
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_restriction_check_get_status_rule(
+                       stc_restriction_rule_h rule)
+{
+       stc_restriction_rule_s *restriction_rule = rule;
+
+       STC_RETURN_VAL_IF(restriction_rule == NULL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Restriction rule should be set");
+
+       STC_RETURN_VAL_IF(restriction_rule->app_id[0] == '\0',
+               STC_ERROR_INVALID_PARAMETER,
+               "Application ID is required argument");
+
+       STC_RETURN_VAL_IF(restriction_rule->iface_type <= STC_IFACE_UNKNOWN ||
+               restriction_rule->iface_type > STC_IFACE_ALL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid restriction network interface type [%d]",
+               restriction_rule->iface_type);
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_restriction_check_remove_rule(
+                       stc_restriction_rule_h rule)
+{
+       stc_restriction_rule_s *restriction_rule = rule;
+
+       STC_RETURN_VAL_IF(restriction_rule == NULL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Restriction rule should be set");
+
+       STC_RETURN_VAL_IF(restriction_rule->app_id[0] == '\0',
+               STC_ERROR_INVALID_PARAMETER,
+               "Application ID is required argument");
+
+       STC_RETURN_VAL_IF(restriction_rule->iface_type <= STC_IFACE_UNKNOWN ||
+               restriction_rule->iface_type > STC_IFACE_ALL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid restriction network interface type [%d]",
+               restriction_rule->iface_type);
+
+       STC_RETURN_VAL_IF(restriction_rule->tx_limit < 0,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid tx limit [%llu]",
+               restriction_rule->tx_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->rx_limit < 0,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid rx limit [%llu]",
+               restriction_rule->rx_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->tx_warning_limit < 0,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid tx warning limit [%llu]",
+               restriction_rule->tx_warning_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->rx_warning_limit < 0,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid rx warning limit [%llu]",
+               restriction_rule->rx_warning_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
+               restriction_rule->roaming_type > STC_ROAMING_DISABLED,
+               STC_ERROR_INVALID_PARAMETER,
+               "Roaming type is not valid [%d]",
+               restriction_rule->roaming_type);
+
+       STC_RETURN_VAL_IF(restriction_rule->imsi[0] == '\0',
+               STC_ERROR_INVALID_PARAMETER,
+               "Imsi is not valid");
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_restriction_check_exclude_rule(
+                       stc_restriction_rule_h rule)
+{
+       stc_restriction_rule_s *restriction_rule = rule;
+
+       STC_RETURN_VAL_IF(restriction_rule == NULL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Restriction rule should be set");
+
+       STC_RETURN_VAL_IF(restriction_rule->app_id[0] == '\0',
+               STC_ERROR_INVALID_PARAMETER,
+               "Application ID is required argument");
+
+       STC_RETURN_VAL_IF(restriction_rule->iface_type <= STC_IFACE_UNKNOWN ||
+               restriction_rule->iface_type > STC_IFACE_ALL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid restriction network interface type [%d]",
+               restriction_rule->iface_type);
+
+       STC_RETURN_VAL_IF(restriction_rule->tx_limit < 0,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid tx limit [%llu]",
+               restriction_rule->tx_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->rx_limit < 0,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid rx limit [%llu]",
+               restriction_rule->rx_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->tx_warning_limit < 0,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid tx warning limit [%llu]",
+               restriction_rule->tx_warning_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->rx_warning_limit < 0,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid rx warning limit [%llu]",
+               restriction_rule->rx_warning_limit);
+
+       STC_RETURN_VAL_IF(restriction_rule->roaming_type <= STC_ROAMING_UNKNOWN ||
+               restriction_rule->roaming_type > STC_ROAMING_DISABLED,
+               STC_ERROR_INVALID_PARAMETER,
+               "Roaming type is not valid [%d]",
+               restriction_rule->roaming_type);
+
+       STC_RETURN_VAL_IF(restriction_rule->imsi[0] == '\0',
+               STC_ERROR_INVALID_PARAMETER,
+               "Imsi is not valid");
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_restriction_set(
+                       stc_restriction_rule_h rule)
+{
+       GVariant *message = NULL;
+       GVariant *params = NULL;
+       stc_error_e error = STC_ERROR_NONE;
+       int result = 0;
+
+       __stc_restriction_rule_make_params(rule, &params);
+
+       message = _stc_dbus_invoke_method(
+               STC_MANAGER_SERVICE,
+               STC_MANAGER_RESTRICTION_PATH,
+               STC_MANAGER_RESTRICTION_INTERFACE,
+               STC_MANAGER_METHOD_RESTRICTION_SET,
+               params,
+               &error);
+
+       STC_RETURN_VAL_IF(message == NULL,
+               error, "Failed to invoke dbus method");
+
+       g_variant_get(message, "(i)", &result);
+       STC_LOGI("Successfully set restriction [%d]", result);
+       g_variant_unref(message);
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_restriction_exclude(
+                       stc_restriction_rule_h rule)
+{
+       GVariant *message = NULL;
+       GVariant *params = NULL;
+       stc_error_e error = STC_ERROR_NONE;
+       int result = 0;
+
+       __stc_restriction_rule_make_params(rule, &params);
+
+       message = _stc_dbus_invoke_method(
+               STC_MANAGER_SERVICE,
+               STC_MANAGER_RESTRICTION_PATH,
+               STC_MANAGER_RESTRICTION_INTERFACE,
+               STC_MANAGER_METHOD_RESTRICTION_EXCLUDE,
+               params,
+               &error);
+
+       STC_RETURN_VAL_IF(message == NULL,
+               error, "Failed to invoke dbus method");
+
+       g_variant_get(message, "(i)", &result);
+       STC_LOGI("Successfully exclude restriction [%d]", result);
+       g_variant_unref(message);
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_restriction_unset(
+                       stc_restriction_rule_h rule)
+{
+       GVariant *message = NULL;
+       GVariant *params = NULL;
+       stc_error_e error = STC_ERROR_NONE;
+       int result = 0;
+
+       __stc_restriction_rule_make_params(rule, &params);
+
+       message = _stc_dbus_invoke_method(
+               STC_MANAGER_SERVICE,
+               STC_MANAGER_RESTRICTION_PATH,
+               STC_MANAGER_RESTRICTION_INTERFACE,
+               STC_MANAGER_METHOD_RESTRICTION_UNSET,
+               params,
+               &error);
+
+       STC_RETURN_VAL_IF(message == NULL,
+               error, "Failed to invoke dbus method");
+
+       g_variant_get(message, "(i)", &result);
+       STC_LOGI("Successfully unset restriction [%d]", result);
+       g_variant_unref(message);
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_restriction_get(
+                       stc_restriction_rule_h rule)
+{
+       STC_RETURN_VAL_IF(_stc_event_get_ref_count() < 1,
+               STC_ERROR_NOT_INITIALIZED,
+               "Event callback is not registered");
+
+       return __stc_restriction_get_per_app_id(rule);
+}
+
+stc_error_e _stc_restriction_get_all(
+                       stc_restriction_rule_h rule)
+{
+       STC_RETURN_VAL_IF(_stc_event_get_ref_count() < 1,
+               STC_ERROR_NOT_INITIALIZED,
+               "Event callback is not registered");
+
+       return __stc_restriction_get_all(rule);
+}
+
+stc_error_e _stc_restriction_get_status(
+                       stc_restriction_rule_h rule,
+                       stc_restriction_status_e *status)
+{
+       GVariant *message = NULL;
+       GVariant *params = NULL;
+       stc_error_e error = STC_ERROR_NONE;
+       int result = 0;
+
+       __stc_restriction_get_status_make_params(rule, &params);
+
+       message = _stc_dbus_invoke_method(
+               STC_MANAGER_SERVICE,
+               STC_MANAGER_RESTRICTION_PATH,
+               STC_MANAGER_RESTRICTION_INTERFACE,
+               STC_MANAGER_METHOD_RESTRICTION_GET_STATUS,
+               params,
+               &error);
+
+       STC_RETURN_VAL_IF(message == NULL,
+               error, "Failed to invoke dbus method");
+
+       g_variant_get(message, "(ii)", &result, status);
+       STC_LOGI("Successfully get restriction status [%s]",
+               _stc_convert_rst_status_to_string(*status));
+       g_variant_unref(message);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_create(stc_h stc, stc_restriction_rule_h *rule)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               g_try_malloc0(sizeof(stc_restriction_rule_s));
+       if (restriction_rule == NULL) {
+               STC_LOGE("Memory allocation failed");
+               return STC_ERROR_OUT_OF_MEMORY;
+       }
+
+       __stc_restriction_init_rule(restriction_rule);
+       *rule = (stc_restriction_rule_h)restriction_rule;
+       STC_LOGI("Restriction rule successfully created");
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_destroy(stc_restriction_rule_h rule)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       __stc_restriction_deinit_rule(rule);
+       STC_LOGI("Restriction rule successfully destroyed");
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_set_app_id(stc_restriction_rule_h rule,
+               const char *app_id)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       if (app_id == NULL || strlen(app_id) == 0)
+               restriction_rule->app_id[0] = '\0';
+       else
+               g_strlcpy(restriction_rule->app_id, app_id, STC_APP_ID_LEN);
+
+       STC_LOGI("App id [%s]", restriction_rule->app_id);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_set_iface_name(stc_restriction_rule_h rule,
+               const char *iface_name)
+
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       if (iface_name == NULL || strlen(iface_name) == 0)
+               restriction_rule->iface_name[0] = '\0';
+       else
+               g_strlcpy(restriction_rule->iface_name, iface_name, STC_IFNAME_LEN);
+
+       STC_LOGI("Ifname [%s]", restriction_rule->iface_name);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_set_iface_type(stc_restriction_rule_h rule,
+               stc_iface_type_e iface_type)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       switch (iface_type) {
+       case STC_IFACE_UNKNOWN:
+       case STC_IFACE_DATACALL:
+       case STC_IFACE_WIFI:
+       case STC_IFACE_WIRED:
+       case STC_IFACE_BLUETOOTH:
+       case STC_IFACE_ALL:
+               restriction_rule->iface_type = iface_type;
+               break;
+       default:
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       STC_LOGI("Iface type [%s]",
+               _stc_convert_iface_type_to_string(restriction_rule->iface_type));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_set_limit(stc_restriction_rule_h rule,
+               uint64_t rx_limit, uint64_t tx_limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       restriction_rule->rx_limit = rx_limit;
+       restriction_rule->tx_limit = tx_limit;
+
+       STC_LOGI("Limit rx[%llu] tx[%llu]",
+               restriction_rule->rx_limit, restriction_rule->tx_limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_set_warning_limit(stc_restriction_rule_h rule,
+               uint64_t rx_warning_limit, uint64_t tx_warning_limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       restriction_rule->rx_warning_limit = rx_warning_limit;
+       restriction_rule->tx_warning_limit = tx_warning_limit;
+
+       STC_LOGI("Warning limit rx[%llu] tx[%llu]",
+               restriction_rule->rx_warning_limit, restriction_rule->tx_warning_limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_set_roaming_type(stc_restriction_rule_h rule,
+               stc_roaming_type_e roaming_type)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       switch (roaming_type) {
+       case STC_ROAMING_UNKNOWN:
+       case STC_ROAMING_ENABLED:
+       case STC_ROAMING_DISABLED:
+               restriction_rule->roaming_type = roaming_type;
+               break;
+       default:
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       STC_LOGI("Roaming type [%s]",
+               _stc_convert_roaming_to_string(restriction_rule->roaming_type));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_set_imsi(stc_restriction_rule_h rule, const char *imsi)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       if (imsi == NULL || strlen(imsi) == 0)
+               restriction_rule->imsi[0] = '\0';
+       else
+               g_strlcpy(restriction_rule->imsi, imsi, STC_IMSI_LEN);
+
+       STC_LOGI("Imsi [%s]", restriction_rule->imsi);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_get_app_id(stc_restriction_rule_h rule, char **app_id)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL || app_id == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       *app_id = g_strdup(restriction_rule->app_id);
+       if (*app_id == NULL)
+               return STC_ERROR_OUT_OF_MEMORY;
+
+       STC_LOGI("App id [%s]", *app_id);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_get_iface_name(stc_restriction_rule_h rule,
+               char **iface_name)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL || iface_name == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       *iface_name = g_strdup(restriction_rule->iface_name);
+       if (*iface_name == NULL)
+               return STC_ERROR_OUT_OF_MEMORY;
+
+       STC_LOGI("Ifname [%s]", *iface_name);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_get_iface_type(stc_restriction_rule_h rule,
+               stc_iface_type_e *iface_type)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       *iface_type = restriction_rule->iface_type;
+
+       STC_LOGI("Iftype [%s]", _stc_convert_iface_type_to_string(*iface_type));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_get_limit(stc_restriction_rule_h rule,
+               uint64_t *rx_limit, uint64_t *tx_limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       *rx_limit = restriction_rule->rx_limit;
+       *tx_limit = restriction_rule->tx_limit;
+
+       STC_LOGI("Limit rx[%llu] tx[%llu]", *rx_limit, *tx_limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_get_warning_limit(stc_restriction_rule_h rule,
+               uint64_t *rx_warning_limit, uint64_t *tx_warning_limit)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       *rx_warning_limit = restriction_rule->rx_warning_limit;
+       *tx_warning_limit = restriction_rule->tx_warning_limit;
+
+       STC_LOGI("Warning limit rx[%llu] tx[%llu]",
+               *rx_warning_limit, *tx_warning_limit);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_get_roaming_type(stc_restriction_rule_h rule,
+               stc_roaming_type_e *roaming_type)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       *roaming_type = restriction_rule->roaming_type;
+
+       STC_LOGI("Roaming type [%s]",
+               _stc_convert_roaming_to_string(*roaming_type));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_restriction_rule_get_imsi(stc_restriction_rule_h rule, char **imsi)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL || imsi == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_restriction_rule_s *restriction_rule =
+               (stc_restriction_rule_s *)rule;
+
+       *imsi = g_strdup(restriction_rule->imsi);
+       if (*imsi == NULL)
+               return STC_ERROR_OUT_OF_MEMORY;
+
+       STC_LOGI("Imsi [%s]", *imsi);
+
+       return STC_ERROR_NONE;
+}
+
diff --git a/src/stc-statistics.c b/src/stc-statistics.c
new file mode 100755 (executable)
index 0000000..59510a1
--- /dev/null
@@ -0,0 +1,879 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file implements Smart Traffic Control (STC) user library.
+ *
+ * @file        stc-statistics.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+#include <glib.h>
+#include <gio/gio.h>
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+#include "stc-private.h"
+
+#include "stc-dbus.h"
+#include "stc-log.h"
+#include "stc-util.h"
+#include "stc-event.h"
+
+#include "stc-info.h"
+#include "stc-statistics.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+static void __stc_stats_init_rule(stc_stats_rule_s *rule)
+{
+       rule->iface_type = STC_IFACE_UNKNOWN;
+       rule->interval.from = STC_INVALID_TIME_INTERVAL;
+       rule->interval.to = STC_INVALID_TIME_INTERVAL;
+       rule->time_period = STC_CONN_PERIOD_UNKNOWN;
+}
+
+static void __stc_stats_deinit_rule(stc_stats_rule_h rule)
+{
+       g_free(rule);
+}
+
+static void __stc_stats_get_make_params(
+                       stc_stats_rule_h rule, GVariant **params)
+{
+       GVariantBuilder *builder;
+       stc_stats_rule_s *stats_rule = rule;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_STATS_RULE_INTERVAL_FROM,
+               g_variant_new_uint64(stats_rule->interval.from));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_STATS_RULE_INTERVAL_TO,
+               g_variant_new_uint64(stats_rule->interval.to));
+
+       if (stats_rule->iface_type != STC_IFACE_UNKNOWN) {
+               g_variant_builder_add(builder, "{sv}",
+                       STC_STATS_RULE_IFTYPE,
+                       g_variant_new_uint16(stats_rule->iface_type));
+       }
+
+       if (stats_rule->time_period != STC_TIME_PERIOD_UNKNOWN) {
+               g_variant_builder_add(builder, "{sv}",
+                       STC_STATS_RULE_TIME_PERIOD,
+                       g_variant_new_uint16(stats_rule->time_period));
+       }
+
+       *params = g_variant_new("(s@a{sv})",
+               stats_rule->app_id, g_variant_builder_end(builder));
+
+       g_variant_builder_unref(builder);
+}
+
+static void __stc_stats_get_all_make_params(
+                       stc_stats_rule_h rule, GVariant **params)
+{
+       GVariantBuilder *builder;
+       stc_stats_rule_s *stats_rule = rule;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_STATS_RULE_INTERVAL_FROM,
+               g_variant_new_uint64(stats_rule->interval.from));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_STATS_RULE_INTERVAL_TO,
+               g_variant_new_uint64(stats_rule->interval.to));
+
+       if (stats_rule->iface_type != STC_IFACE_UNKNOWN) {
+               g_variant_builder_add(builder, "{sv}",
+                       STC_STATS_RULE_IFTYPE,
+                       g_variant_new_uint16(stats_rule->iface_type));
+       }
+
+       if (stats_rule->time_period != STC_TIME_PERIOD_UNKNOWN) {
+               g_variant_builder_add(builder, "{sv}",
+                       STC_STATS_RULE_TIME_PERIOD,
+                       g_variant_new_uint16(stats_rule->time_period));
+       }
+
+       *params = g_variant_new("(@a{sv})", g_variant_builder_end(builder));
+
+       g_variant_builder_unref(builder);
+}
+
+static void __stc_stats_get_total_make_params(
+                       stc_stats_rule_h rule, GVariant **params)
+{
+       GVariantBuilder *builder;
+       stc_stats_rule_s *stats_rule = rule;
+
+       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_STATS_RULE_INTERVAL_FROM,
+               g_variant_new_uint64(stats_rule->interval.from));
+
+       g_variant_builder_add(builder, "{sv}",
+               STC_STATS_RULE_INTERVAL_TO,
+               g_variant_new_uint64(stats_rule->interval.to));
+
+       if (stats_rule->iface_type != STC_IFACE_UNKNOWN) {
+               g_variant_builder_add(builder, "{sv}",
+                       STC_STATS_RULE_IFTYPE,
+                       g_variant_new_uint16(stats_rule->iface_type));
+       }
+
+       if (stats_rule->time_period != STC_TIME_PERIOD_UNKNOWN) {
+               g_variant_builder_add(builder, "{sv}",
+                       STC_STATS_RULE_TIME_PERIOD,
+                       g_variant_new_uint16(stats_rule->time_period));
+       }
+
+       *params = g_variant_new("(s@a{sv})",
+               "", g_variant_builder_end(builder));
+
+       g_variant_builder_unref(builder);
+}
+
+static void __stc_stats_extract_info_cb(const char *key,
+                       GVariant *value, void *user_data)
+{
+       stc_stats_info_s *stats_info = (stc_stats_info_s *)user_data;
+
+       if (stats_info == NULL)
+               return;
+
+       if (!g_strcmp0(key, STC_STATS_INFO_APP_ID)) {
+               const char *app_id = g_variant_get_string(value, NULL);
+               if (app_id != NULL)
+                       g_strlcpy(stats_info->app_id, app_id, strlen(stats_info->app_id));
+
+       } else if (!g_strcmp0(key, STC_STATS_INFO_IFNAME)) {
+               const char *iface_name = g_variant_get_string(value, NULL);
+               if (iface_name != NULL)
+                       g_strlcpy(stats_info->iface_name, iface_name, strlen(stats_info->iface_name));
+
+       } else if (!g_strcmp0(key, STC_STATS_INFO_IMSI)) {
+               const char *imsi = g_variant_get_string(value, NULL);
+               if (imsi != NULL)
+                       g_strlcpy(stats_info->imsi, imsi, strlen(stats_info->imsi));
+
+       } else if (!g_strcmp0(key, STC_STATS_INFO_INTERVAL_FROM)) {
+               stats_info->interval.from = g_variant_get_uint64(value);
+
+       } else if (!g_strcmp0(key, STC_STATS_INFO_INTERVAL_TO)) {
+               stats_info->interval.to = g_variant_get_uint64(value);
+
+       } else if (!g_strcmp0(key, STC_STATS_INFO_OUTGOING_BYTES)) {
+               stats_info->cnt.outgoing_bytes = g_variant_get_uint64(value);
+
+       } else if (!g_strcmp0(key, STC_STATS_INFO_INCOMING_BYTES)) {
+               stats_info->cnt.incoming_bytes = g_variant_get_uint64(value);
+
+       } else if (!g_strcmp0(key, STC_STATS_INFO_IFTYPE)) {
+               stats_info->iface_type =
+                       (stc_iface_type_e)g_variant_get_uint16(value);
+
+       } else if (!g_strcmp0(key, STC_STATS_INFO_ROAMING)) {
+               stats_info->roaming_type =
+                       (stc_roaming_type_e)g_variant_get_uint16(value);
+
+       } else if (!g_strcmp0(key, STC_STATS_INFO_PROTOCOL_TYPE)) {
+               stats_info->protocol_type =
+                       (stc_protocol_type_e)g_variant_get_uint16(value);
+
+       } else if (!g_strcmp0(key, STC_STATS_INFO_PROCESS_STATE)) {
+               stats_info->process_state =
+                       (stc_process_state_e)g_variant_get_uint16(value);
+
+       }
+
+}
+
+static void __stc_stats_print_info(stc_stats_info_s *info)
+{
+       STC_LOGD(STC_HR_SINGLE);
+
+       STC_LOGD("App_id:   [%s]", (info->app_id[0] != '\0') ? info->app_id : "NULL");
+       STC_LOGD("Ifname:   [%s]", (info->iface_name[0] != '\0') ? info->iface_name : "NULL");
+
+       if (info->iface_type != STC_IFACE_UNKNOWN)
+               STC_LOGD("Iftype:   [%d]", info->iface_type);
+
+       if (info->imsi[0] != '\0')
+               STC_LOGD("Imsi:     [%s]", info->imsi);
+
+       if (info->roaming_type != STC_ROAMING_UNKNOWN)
+               STC_LOGD("Roaming:  [%d]", info->roaming_type);
+
+       STC_LOGD("Received: [%llu]", info->cnt.incoming_bytes);
+       STC_LOGD("Sent:     [%llu]", info->cnt.outgoing_bytes);
+
+       if (info->protocol_type != STC_PROTOCOL_UNKNOWN)
+               STC_LOGD("Protocol: [%d]", info->protocol_type);
+
+       if (info->process_state != STC_PROCESS_STATE_UNKNOWN)
+               STC_LOGD("Process:  [%d]", info->process_state);
+
+       if (info->interval.from > 0)
+               STC_LOGD("From:     [%lu]", info->interval.from);
+
+       if (info->interval.to > 0)
+               STC_LOGD("To:       [%lu]", info->interval.to);
+
+       STC_LOGD(STC_HR_SINGLE);
+}
+
+static void __stc_stats_get_per_app_id_reply(
+                       GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+       GDBusConnection *conn = NULL;
+       GError *dbus_error = NULL;
+       GVariant *dbus_data = NULL;
+       GVariantIter *iter = NULL;
+       stc_error_e dbus_result = STC_ERROR_NONE;
+       stc_error_e error = STC_ERROR_NONE;
+       stc_stats_info_s *stats_info = NULL;
+       GSList *stats_list = NULL;
+       stc_event_info_s event_data = { 0, };
+
+       conn = G_DBUS_CONNECTION(source_object);
+       dbus_data = g_dbus_connection_call_finish(conn, res, &dbus_error);
+       if (dbus_error != NULL) {
+               error = _stc_convert_error_string_to_enum(dbus_error->message);
+               g_error_free(dbus_error);
+       }
+
+       if (_stc_event_get_request_table_state(STC_REQUEST_TABLE_STATS_GET))
+               _stc_event_set_request_table_state(STC_REQUEST_TABLE_STATS_GET, false);
+
+       if (error == STC_ERROR_NONE) {
+               g_variant_get(dbus_data, "(ia{sv})", &dbus_result, &iter);
+
+               if (iter != NULL) {
+                       stats_info = g_try_malloc0(sizeof(stc_stats_info_s));
+                       if (stats_info != NULL) {
+                               _stc_dbus_dictionary_foreach(iter,
+                                       __stc_stats_extract_info_cb, stats_info);
+
+                               __stc_stats_print_info(stats_info);
+
+                               stats_list = g_slist_append(stats_list,
+                                       (stc_stats_info_s *)stats_info);
+
+                               g_variant_iter_free(iter);
+                       }
+               }
+
+               event_data.event = STC_EVENT_STATS_GET_RSP;
+               event_data.info_data = (GSList *)stats_list;
+               event_data.datalength = g_slist_length(stats_list);
+               event_data.error = dbus_result;
+       } else {
+               STC_LOGE("Get stats per app id response error [%s]",
+                       _stc_convert_error_type_to_string(error));
+
+               event_data.event = STC_EVENT_STATS_GET_RSP;
+               event_data.info_data = NULL;
+               event_data.datalength = 0;
+               event_data.error = error;
+       }
+
+       _stc_event_add_client_idle_cb(&event_data, user_data);
+}
+
+static void __stc_stats_get_all_reply(
+                       GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+       GDBusConnection *conn = NULL;
+       GError *dbus_error = NULL;
+       GVariant *dbus_data = NULL;
+       GVariantIter *iter = NULL;
+       GVariantIter *iter_row = NULL;
+       stc_error_e dbus_result = STC_ERROR_NONE;
+       stc_error_e error = STC_ERROR_NONE;
+       stc_stats_info_s *stats_info = NULL;
+       GSList *stats_list = NULL;
+       stc_event_info_s event_data = { 0, };
+
+       conn = G_DBUS_CONNECTION(source_object);
+       dbus_data = g_dbus_connection_call_finish(conn, res, &dbus_error);
+       if (dbus_error != NULL) {
+               error = _stc_convert_error_string_to_enum(dbus_error->message);
+               g_error_free(dbus_error);
+       }
+
+       if (_stc_event_get_request_table_state(STC_REQUEST_TABLE_STATS_GET_ALL))
+               _stc_event_set_request_table_state(STC_REQUEST_TABLE_STATS_GET_ALL, false);
+
+       if (error == STC_ERROR_NONE) {
+               g_variant_get(dbus_data, "(iaa{sv})", &dbus_result, &iter);
+
+               while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
+                       stats_info = g_try_malloc0(sizeof(stc_stats_info_s));
+                       if (stats_info != NULL) {
+                               _stc_dbus_dictionary_foreach(iter_row,
+                                       __stc_stats_extract_info_cb, stats_info);
+
+                               __stc_stats_print_info(stats_info);
+
+                               stats_list = g_slist_append(stats_list,
+                                       (stc_stats_info_s *)stats_info);
+
+                               g_variant_iter_free(iter_row);
+                       }
+               }
+               g_variant_iter_free(iter);
+
+               event_data.event = STC_EVENT_STATS_GET_ALL_RSP;
+               event_data.info_data = (GSList *)stats_list;
+               event_data.datalength = g_slist_length(stats_list);
+               event_data.error = dbus_result;
+       } else {
+               STC_LOGE("Get stats all response error [%s]",
+                       _stc_convert_error_type_to_string(error));
+
+               event_data.event = STC_EVENT_STATS_GET_ALL_RSP;
+               event_data.info_data = NULL;
+               event_data.datalength = 0;
+               event_data.error = error;
+       }
+
+       _stc_event_add_client_idle_cb(&event_data, user_data);
+}
+
+static void __stc_stats_get_total_reply(
+                       GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+       GDBusConnection *conn = NULL;
+       GError *dbus_error = NULL;
+       GVariant *dbus_data = NULL;
+       GVariantIter *iter = NULL;
+       stc_error_e dbus_result = STC_ERROR_NONE;
+       stc_error_e error = STC_ERROR_NONE;
+       stc_stats_info_s *stats_info = NULL;
+       GSList *stats_list = NULL;
+       stc_event_info_s event_data = { 0, };
+
+       conn = G_DBUS_CONNECTION(source_object);
+       dbus_data = g_dbus_connection_call_finish(conn, res, &dbus_error);
+       if (dbus_error != NULL) {
+               error = _stc_convert_error_string_to_enum(dbus_error->message);
+               g_error_free(dbus_error);
+       }
+
+       if (_stc_event_get_request_table_state(STC_REQUEST_TABLE_STATS_GET_TOTAL))
+               _stc_event_set_request_table_state(STC_REQUEST_TABLE_STATS_GET_TOTAL, false);
+
+       if (error == STC_ERROR_NONE) {
+               g_variant_get(dbus_data, "(ia{sv})", &dbus_result, &iter);
+
+               if (iter != NULL) {
+                       stats_info = g_try_malloc0(sizeof(stc_stats_info_s));
+                       if (stats_info != NULL) {
+                               _stc_dbus_dictionary_foreach(iter,
+                                       __stc_stats_extract_info_cb, stats_info);
+
+                               __stc_stats_print_info(stats_info);
+
+                               stats_list = g_slist_append(stats_list,
+                                       (stc_stats_info_s *)stats_info);
+
+                               g_variant_iter_free(iter);
+                       }
+               }
+
+               event_data.event = STC_EVENT_STATS_GET_TOTAL_RSP;
+               event_data.info_data = (GSList *)stats_list;
+               event_data.datalength = g_slist_length(stats_list);
+               event_data.error = dbus_result;
+       } else {
+               STC_LOGE("Get stats total response error [%s]",
+                       _stc_convert_error_type_to_string(error));
+
+               event_data.event = STC_EVENT_STATS_GET_TOTAL_RSP;
+               event_data.info_data = NULL;
+               event_data.datalength = 0;
+               event_data.error = error;
+       }
+
+       _stc_event_add_client_idle_cb(&event_data, user_data);
+}
+
+stc_error_e __stc_stats_get_per_app_id(
+                       stc_stats_rule_h rule)
+{
+       GVariant *params = NULL;
+       stc_error_e error = STC_ERROR_NONE;
+
+       STC_RETURN_VAL_IF(
+               _stc_event_get_request_table_state(
+               STC_REQUEST_TABLE_STATS_GET),
+               STC_ERROR_IN_PROGRESS,
+               "Request in progress");
+
+       _stc_event_set_request_table_state(
+               STC_REQUEST_TABLE_STATS_GET, true);
+
+       __stc_stats_get_make_params(rule, &params);
+
+       error = _stc_dbus_invoke_method_nonblock(
+               STC_MANAGER_SERVICE,
+               STC_MANAGER_STATS_PATH,
+               STC_MANAGER_STATS_INTERFACE,
+               STC_MANAGER_METHOD_STATS_GET_PER_APP_ID,
+               params,
+               STC_DBUS_REPLY_TIMEOUT,
+               __stc_stats_get_per_app_id_reply,
+               NULL);
+
+       if (error != STC_ERROR_NONE) {
+               STC_LOGE("Failed to invoke dbus method nonblock");
+
+               _stc_event_set_request_table_state(
+                       STC_REQUEST_TABLE_STATS_GET, false);
+               return error;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e __stc_stats_get_all(
+                       stc_stats_rule_h rule)
+{
+       GVariant *params = NULL;
+       stc_error_e error = STC_ERROR_NONE;
+
+       STC_RETURN_VAL_IF(
+               _stc_event_get_request_table_state(
+               STC_REQUEST_TABLE_STATS_GET_ALL),
+               STC_ERROR_IN_PROGRESS,
+               "Request in progress");
+
+       _stc_event_set_request_table_state(
+               STC_REQUEST_TABLE_STATS_GET_ALL, true);
+
+       __stc_stats_get_all_make_params(rule, &params);
+
+       error = _stc_dbus_invoke_method_nonblock(
+               STC_MANAGER_SERVICE,
+               STC_MANAGER_STATS_PATH,
+               STC_MANAGER_STATS_INTERFACE,
+               STC_MANAGER_METHOD_STATS_GET_ALL,
+               params,
+               STC_DBUS_REPLY_TIMEOUT,
+               __stc_stats_get_all_reply,
+               NULL);
+
+       if (error != STC_ERROR_NONE) {
+               STC_LOGE("Failed to invoke dbus method nonblock");
+
+               _stc_event_set_request_table_state(
+                       STC_REQUEST_TABLE_STATS_GET_ALL, false);
+               return error;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e __stc_stats_get_total(
+                       stc_stats_rule_h rule)
+{
+       GVariant *params = NULL;
+       stc_error_e error = STC_ERROR_NONE;
+
+       STC_RETURN_VAL_IF(
+               _stc_event_get_request_table_state(
+               STC_REQUEST_TABLE_STATS_GET_TOTAL),
+               STC_ERROR_IN_PROGRESS,
+               "Request in progress");
+
+       _stc_event_set_request_table_state(
+               STC_REQUEST_TABLE_STATS_GET_TOTAL, true);
+
+       __stc_stats_get_total_make_params(rule, &params);
+
+       error = _stc_dbus_invoke_method_nonblock(
+               STC_MANAGER_SERVICE,
+               STC_MANAGER_STATS_PATH,
+               STC_MANAGER_STATS_INTERFACE,
+               STC_MANAGER_METHOD_STATS_GET_TOTAL,
+               params,
+               STC_DBUS_REPLY_TIMEOUT,
+               __stc_stats_get_total_reply,
+               NULL);
+
+       if (error != STC_ERROR_NONE) {
+               STC_LOGE("Failed to invoke dbus method nonblock");
+
+               _stc_event_set_request_table_state(
+                       STC_REQUEST_TABLE_STATS_GET_TOTAL, false);
+               return error;
+       }
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_stats_check_get_rule(
+                       stc_stats_rule_h rule)
+{
+       stc_stats_rule_s *stats_rule = (stc_stats_rule_s *)rule;
+
+       STC_RETURN_VAL_IF(stats_rule == NULL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Stats rule should be set");
+
+       STC_RETURN_VAL_IF(stats_rule->app_id[0] == '\0',
+               STC_ERROR_INVALID_PARAMETER,
+               "Application ID is required argument");
+
+       STC_RETURN_VAL_IF(stats_rule->interval.from <= STC_INVALID_TIME_INTERVAL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid time interval for [from]");
+
+       STC_RETURN_VAL_IF(stats_rule->interval.to <= STC_INVALID_TIME_INTERVAL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid time interval for [to]");
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_stats_check_get_all_rule(
+                       stc_stats_rule_h rule)
+{
+       stc_stats_rule_s *stats_rule = (stc_stats_rule_s *)rule;
+
+       STC_RETURN_VAL_IF(stats_rule == NULL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Stats rule should be set");
+
+       STC_RETURN_VAL_IF(stats_rule->interval.from <= STC_INVALID_TIME_INTERVAL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid time interval for [from]");
+
+       STC_RETURN_VAL_IF(stats_rule->interval.to <= STC_INVALID_TIME_INTERVAL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid time interval for [to]");
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_stats_check_get_total_rule(
+                       stc_stats_rule_h rule)
+{
+       stc_stats_rule_s *stats_rule = (stc_stats_rule_s *)rule;
+
+       STC_RETURN_VAL_IF(stats_rule == NULL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Stats rule should be set");
+
+       STC_RETURN_VAL_IF(stats_rule->interval.from <= STC_INVALID_TIME_INTERVAL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid time interval for [from]");
+
+       STC_RETURN_VAL_IF(stats_rule->interval.to <= STC_INVALID_TIME_INTERVAL,
+               STC_ERROR_INVALID_PARAMETER,
+               "Invalid time interval for [to]");
+
+       return STC_ERROR_NONE;
+}
+
+stc_error_e _stc_stats_get(stc_stats_rule_h rule)
+{
+       STC_RETURN_VAL_IF(_stc_event_get_ref_count() < 1,
+               STC_ERROR_NOT_INITIALIZED,
+               "Event callback is not registered");
+
+       return __stc_stats_get_per_app_id(rule);
+}
+
+stc_error_e _stc_stats_get_all(stc_stats_rule_h rule)
+{
+       STC_RETURN_VAL_IF(_stc_event_get_ref_count() < 1,
+               STC_ERROR_NOT_INITIALIZED,
+               "Event callback is not registered");
+
+       return __stc_stats_get_all(rule);
+}
+
+stc_error_e _stc_stats_get_total(stc_stats_rule_h rule)
+{
+       STC_RETURN_VAL_IF(_stc_event_get_ref_count() < 1,
+               STC_ERROR_NOT_INITIALIZED,
+               "Event callback is not registered");
+
+       return __stc_stats_get_total(rule);
+}
+
+EXPORT_API int stc_stats_rule_create(stc_h stc, stc_stats_rule_h *rule)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_rule_s *stats_rule = g_try_malloc0(sizeof(stc_stats_rule_s));
+       if (stats_rule == NULL) {
+               STC_LOGE("Memory allocation failed");
+               return STC_ERROR_OUT_OF_MEMORY;
+       }
+
+       __stc_stats_init_rule(stats_rule);
+       *rule = (stc_stats_rule_h)stats_rule;
+       STC_LOGI("Stats rule successfully created");
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_rule_destroy(stc_stats_rule_h rule)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       __stc_stats_deinit_rule(rule);
+       STC_LOGI("Stats rule successfully destroyed");
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_rule_set_app_id(stc_stats_rule_h rule,
+               const char *app_id)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_rule_s *stats_rule = (stc_stats_rule_s *)rule;
+
+       if (app_id == NULL)
+               stats_rule->app_id[0] = '\0';
+       else
+               g_strlcpy(stats_rule->app_id, app_id, strlen(app_id) + 1);
+
+       STC_LOGI("App id [%s]", stats_rule->app_id);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_rule_set_time_interval(stc_stats_rule_h rule,
+               time_t from, time_t to)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (from < 0 || to < 0) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_rule_s *stats_rule = (stc_stats_rule_s *)rule;
+       stats_rule->interval.from = from;
+       stats_rule->interval.to = to;
+
+       STC_LOGI("Time interval from[%lu] to[%lu]",
+               stats_rule->interval.from, stats_rule->interval.to);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_rule_set_iface_type(
+                       stc_stats_rule_h rule, stc_iface_type_e iface_type)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_rule_s *stats_rule = (stc_stats_rule_s *)rule;
+
+       switch (iface_type) {
+       case STC_IFACE_UNKNOWN:
+       case STC_IFACE_DATACALL:
+       case STC_IFACE_WIFI:
+       case STC_IFACE_WIRED:
+       case STC_IFACE_BLUETOOTH:
+       case STC_IFACE_ALL:
+               stats_rule->iface_type = iface_type;
+               break;
+       default:
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       STC_LOGI("Iface type [%s]",
+               _stc_convert_iface_type_to_string(stats_rule->iface_type));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_rule_set_time_period(stc_stats_rule_h rule,
+               stc_time_period_e time_period)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_rule_s *stats_rule = (stc_stats_rule_s *)rule;
+
+       switch (time_period) {
+       case STC_TIME_PERIOD_UNKNOWN:
+       case STC_TIME_PERIOD_HOUR:
+       case STC_TIME_PERIOD_DAY:
+       case STC_TIME_PERIOD_WEEK:
+       case STC_TIME_PERIOD_MONTH:
+               stats_rule->time_period = time_period;
+               break;
+       default:
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       STC_LOGI("Time period [%s]",
+               _stc_convert_time_period_to_string(stats_rule->time_period));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_rule_get_app_id(stc_stats_rule_h rule, char **app_id)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL || app_id == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_rule_s *stats_rule = (stc_stats_rule_s *)rule;
+
+       *app_id = g_strdup(stats_rule->app_id);
+       if (*app_id == NULL)
+               return STC_ERROR_OUT_OF_MEMORY;
+
+       STC_LOGI("App id [%s]", *app_id);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_rule_get_time_interval(stc_stats_rule_h rule,
+               time_t *from, time_t *to)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_rule_s *stats_rule = (stc_stats_rule_s *)rule;
+
+       *from = stats_rule->interval.from;
+       *to = stats_rule->interval.to;
+
+       STC_LOGI("Time interval from[%lu] to[%lu]", *from, *to);
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_rule_get_iface_type(stc_stats_rule_h rule,
+               stc_iface_type_e *iface_type)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_rule_s *stats_rule = (stc_stats_rule_s *)rule;
+
+       *iface_type = stats_rule->iface_type;
+
+       STC_LOGI("Iftype [%s]", _stc_convert_iface_type_to_string(*iface_type));
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_stats_rule_get_time_period(stc_stats_rule_h rule,
+               stc_time_period_e *time_period)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (rule == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       stc_stats_rule_s *stats_rule = (stc_stats_rule_s *)rule;
+
+       *time_period = stats_rule->time_period;
+
+       STC_LOGI("Time period [%s]",
+               _stc_convert_time_period_to_string(*time_period));
+
+       return STC_ERROR_NONE;
+}
+
diff --git a/src/stc.c b/src/stc.c
new file mode 100755 (executable)
index 0000000..e11b58c
--- /dev/null
+++ b/src/stc.c
@@ -0,0 +1,119 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file implements Smart Traffic Control (STC) user library.
+ *
+ * @file        stc.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+/*****************************************************************************
+ *  Standard headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  System headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Smart Traffic Control (STC) library headers
+ *****************************************************************************/
+#include "stc.h"
+
+#include "stc-private.h"
+
+#include "stc-dbus.h"
+#include "stc-log.h"
+#include "stc-util.h"
+
+/*****************************************************************************
+ *  Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+
+EXPORT_API int stc_initialize(stc_h *stc)
+{
+       int ret = STC_ERROR_NONE;
+
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (stc == NULL) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (_stc_handle_check_validity(*stc)) {
+               STC_LOGE("Already initialized");
+               return STC_ERROR_ALREADY_INITIALIZED;
+       }
+
+       ret = _stc_initialize();
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Init failed [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       ret = _stc_handle_create(stc);
+       if (ret != STC_ERROR_NONE) {
+               STC_LOGE("Create handle failed [%s]",
+                       _stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       _stc_handle_add(stc);
+       STC_LOGE("STC successfully initialized");
+
+       return STC_ERROR_NONE;
+}
+
+EXPORT_API int stc_deinitialize(stc_h stc)
+{
+       CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_STC);
+
+       if (!(_stc_handle_check_validity(stc))) {
+               STC_LOGE("Invalid parameter");
+               return STC_ERROR_INVALID_PARAMETER;
+       }
+
+       STC_LOGI("Destroy handle [%p]", stc);
+       _stc_handle_remove(stc);
+
+       if (_stc_handle_get_count() == 0) {
+               int ret = _stc_deinitialize();
+               if (ret != STC_ERROR_NONE) {
+                       STC_LOGE("Deinit failed [%s]",
+                               _stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
+       STC_LOGI("STC successfully de-initialized");
+
+       return STC_ERROR_NONE;
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..48eda13
--- /dev/null
@@ -0,0 +1,28 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(stc_test C)
+
+SET(STC_TEST_INCLUDE_DIR ${STC_TEST_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../include)
+INCLUDE_DIRECTORIES(${STC_TEST_INCLUDE_DIR})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(TARGET_STC_TEST REQUIRED ${COMMON_DEPS})
+FOREACH(flag ${TARGET_STC_TEST_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+       MESSAGE(${flag})
+ENDFOREACH()
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+SET(stc_test
+       restriction.c
+       statistics.c
+       stc_menu.c
+       stc_test.c
+)
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${stc_test})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${TARGET_STC} ${TARGET_STC_TEST_LDFLAGS})
+
+
+INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${BIN_DIR})
diff --git a/test/restriction.c b/test/restriction.c
new file mode 100755 (executable)
index 0000000..205af3c
--- /dev/null
@@ -0,0 +1,420 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        restriction.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+#include <assert.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <stc.h>
+#include <stc_internal.h>
+
+#include "stc_test.h"
+#include "stc_menu.h"
+
+static char g_app_id[MENU_DATA_SIZE] = "";
+static char g_iface_name[MENU_DATA_SIZE] = "";
+static char g_iface_type[MENU_DATA_SIZE] = "0";
+static char g_roaming[MENU_DATA_SIZE] = "0";
+static char g_imsi[MENU_DATA_SIZE] = "";
+static char g_rx_limit[MENU_DATA_SIZE] = "0";
+static char g_tx_limit[MENU_DATA_SIZE] = "0";
+static char g_rx_warning_limit[MENU_DATA_SIZE] = "0";
+static char g_tx_warning_limit[MENU_DATA_SIZE] = "0";
+
+extern stc_h g_stc;
+static stc_restriction_rule_h g_restriction_rule = NULL;
+
+static stc_callback_ret_e __test_stc_restriction_info_cb(
+                       stc_error_e result, stc_restriction_info_h info, void *user_data)
+{
+       if (result != STC_ERROR_NONE) {
+               msg("Response restriction info error " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(result));
+               return STC_CALLBACK_CANCEL;
+       }
+
+       int ret = STC_ERROR_NONE;
+       char *app_id;
+       char *iface_name;
+       char *imsi;
+       stc_restriction_status_e rst_status;
+       stc_iface_type_e iface_type;
+       uint64_t rx_limit;
+       uint64_t tx_limit;
+       uint64_t rx_warning_limit;
+       uint64_t tx_warning_limit;
+       stc_roaming_type_e roaming;
+
+       msg(HR_SINGLE);
+
+       ret = stc_restriction_info_get_app_id(info, &app_id);
+       if (ret == STC_ERROR_NONE)
+               msg("App_id:    " LOG_CYAN "[%s]" LOG_END, app_id);
+
+       ret = stc_restriction_info_get_iface_name(info, &iface_name);
+       if (ret == STC_ERROR_NONE)
+               msg("Ifname:    [%s]", iface_name);
+
+       ret = stc_restriction_info_get_imsi(info, &imsi);
+       if (ret == STC_ERROR_NONE)
+               msg("Imsi:      [%s]", imsi);
+
+       ret = stc_restriction_info_get_status(info, &rst_status);
+       if (ret == STC_ERROR_NONE)
+               msg("Status:    [%s]", test_stc_convert_rst_status_to_string(rst_status));
+
+       ret = stc_restriction_info_get_iface_type(info, &iface_type);
+       if (ret == STC_ERROR_NONE)
+               msg("Iftype:    [%s]", test_stc_convert_iface_type_to_string(iface_type));
+
+       ret = stc_restriction_info_get_roaming_type(info, &roaming);
+       if (ret == STC_ERROR_NONE)
+               msg("Roaming:   [%s]", test_stc_convert_roaming_to_string(roaming));
+
+       ret = stc_restriction_info_get_limit(info, &rx_limit, &tx_limit);
+       if (ret == STC_ERROR_NONE) {
+               msg("Rx_limit: [%llu]", rx_limit);
+               msg("Tx_limit: [%llu]", tx_limit);
+       }
+
+       ret = stc_restriction_info_get_warning_limit(info,
+               &rx_warning_limit, &tx_warning_limit);
+       if (ret == STC_ERROR_NONE) {
+               msg("Rx_warning_limit: [%llu]", rx_warning_limit);
+               msg("Tx_warning_limit: [%llu]", tx_warning_limit);
+       }
+
+       msg(HR_SINGLE);
+
+       g_free(app_id);
+       g_free(iface_name);
+       g_free(imsi);
+
+       return STC_CALLBACK_CONTINUE;
+}
+
+static int __test_stc_set_restriction_rule(MManager *mm, struct menu_data *menu)
+{
+       stc_iface_type_e iface_type = (int)strtol(g_iface_type, NULL, 10);
+       stc_roaming_type_e roaming = (int)strtol(g_roaming, NULL, 10);
+       uint64_t rx_limit = (uint64_t)strtol(g_rx_limit, NULL, 10);
+       uint64_t tx_limit = (uint64_t)strtol(g_tx_limit, NULL, 10);
+       uint64_t rx_warning_limit = (uint64_t)strtol(g_rx_warning_limit, NULL, 10);
+       uint64_t tx_warning_limit = (uint64_t)strtol(g_tx_warning_limit, NULL, 10);
+       char *app_id = NULL;
+       char *imsi = NULL;
+       char *iface_name = NULL;
+       int ret = STC_ERROR_NONE;
+
+       ret = stc_restriction_rule_set_app_id(g_restriction_rule, g_app_id);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to set application ID" LOG_END);
+       else {
+               msg("Fail to set application ID " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       if (iface_type > STC_IFACE_UNKNOWN && iface_type <= STC_IFACE_ALL) {
+               ret = stc_restriction_rule_set_iface_type(g_restriction_rule, iface_type);
+               if (ret == STC_ERROR_NONE)
+                       msg(LOG_GREEN "Success to set interface type" LOG_END);
+               else {
+                       msg("Fail to set interface type " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
+       ret = stc_restriction_rule_set_iface_name(g_restriction_rule, g_iface_name);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to set interface name" LOG_END);
+       else {
+               msg("Fail to set interface name " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       if (roaming > STC_ROAMING_UNKNOWN && roaming <= STC_ROAMING_DISABLED) {
+               ret = stc_restriction_rule_set_roaming_type(g_restriction_rule, roaming);
+               if (ret == STC_ERROR_NONE)
+                       msg(LOG_GREEN "Success to set roaming type" LOG_END);
+               else {
+                       msg("Fail to set roaming type " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
+       ret = stc_restriction_rule_set_imsi(g_restriction_rule, g_imsi);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to set imsi" LOG_END);
+       else {
+               msg("Fail to set imsi " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       if ((rx_limit >= 0 && rx_limit < G_MAXUINT64) &&
+               (tx_limit >= 0 && tx_limit < G_MAXUINT64)) {
+               ret = stc_restriction_rule_set_limit(g_restriction_rule,
+                                       rx_limit, tx_limit);
+               if (ret == STC_ERROR_NONE)
+                       msg(LOG_GREEN "Success to set limit" LOG_END);
+               else {
+                       msg("Fail to set limit " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
+       if ((rx_warning_limit >= 0 && rx_warning_limit < G_MAXUINT64) &&
+               (tx_warning_limit >= 0 && tx_warning_limit < G_MAXUINT64)) {
+               ret = stc_restriction_rule_set_warning_limit(g_restriction_rule,
+                                       rx_warning_limit, tx_warning_limit);
+               if (ret == STC_ERROR_NONE)
+                       msg(LOG_GREEN "Success to set warning limit" LOG_END);
+               else {
+                       msg("Fail to set warning limit " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
+       msg(HR_SINGLE);
+
+       ret = stc_restriction_rule_get_app_id(g_restriction_rule, &app_id);
+       if (ret == STC_ERROR_NONE) {
+               msg("App_id:    " LOG_CYAN "[%s]" LOG_END, app_id);
+               g_free(app_id);
+       }
+
+       ret = stc_restriction_rule_get_imsi(g_restriction_rule, &imsi);
+       if (ret == STC_ERROR_NONE) {
+               msg("Imsi:      " LOG_CYAN "[%s]" LOG_END, imsi);
+               g_free(imsi);
+       }
+
+       ret = stc_restriction_rule_get_iface_type(g_restriction_rule, &iface_type);
+       if (ret == STC_ERROR_NONE)
+               msg("Iftype:    " LOG_CYAN "[%s]" LOG_END,
+                       test_stc_convert_iface_type_to_string(iface_type));
+
+       ret = stc_restriction_rule_get_iface_name(g_restriction_rule, &iface_name);
+       if (ret == STC_ERROR_NONE) {
+               msg("Ifname:    " LOG_CYAN "[%s]" LOG_END, iface_name);
+               g_free(iface_name);
+       }
+
+       ret = stc_restriction_rule_get_roaming_type(g_restriction_rule, &roaming);
+       if (ret == STC_ERROR_NONE)
+               msg("Roaming:   " LOG_CYAN "[%s]" LOG_END,
+                       test_stc_convert_roaming_to_string(roaming));
+
+       rx_limit = 0;
+       tx_limit = 0;
+       ret = stc_restriction_rule_get_limit(g_restriction_rule, &rx_limit, &tx_limit);
+       if (ret == STC_ERROR_NONE) {
+               msg("Rx_limit: " LOG_CYAN "[%llu]" LOG_END, rx_limit);
+               msg("Tx_limit: " LOG_CYAN "[%llu]" LOG_END, tx_limit);
+       }
+
+       rx_warning_limit = 0;
+       tx_warning_limit = 0;
+       ret = stc_restriction_rule_get_warning_limit(g_restriction_rule,
+               &rx_warning_limit, &tx_warning_limit);
+       if (ret == STC_ERROR_NONE) {
+               msg("Rx_warning_limit: " LOG_CYAN "[%llu]" LOG_END, rx_warning_limit);
+               msg("Tx_warning_limit: " LOG_CYAN "[%llu]" LOG_END, tx_warning_limit);
+       }
+
+       msg(HR_SINGLE);
+
+       return STC_ERROR_NONE;
+}
+
+static int __test_stc_restriction_set(MManager *mm, struct menu_data *menu)
+{
+       int ret = STC_ERROR_NONE;
+
+       ret = stc_set_restriction(g_stc, g_restriction_rule);
+
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to set restriction" LOG_END);
+       else
+               msg("Fail to set restriction " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       return ret;
+}
+
+static int __test_stc_restriction_get(MManager *mm, struct menu_data *menu)
+{
+       int ret = STC_ERROR_NONE;
+
+       ret = stc_get_restriction(g_stc,
+               g_restriction_rule,
+               __test_stc_restriction_info_cb,
+               NULL);
+
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to request restriction info" LOG_END);
+       else
+               msg("Fail to request restriction info " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       return ret;
+}
+
+static int __test_stc_restriction_get_all(MManager *mm, struct menu_data *menu)
+{
+       int ret = STC_ERROR_NONE;
+
+       ret = stc_foreach_restriction(g_stc,
+               g_restriction_rule,
+               __test_stc_restriction_info_cb,
+               NULL);
+
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to request restriction all info" LOG_END);
+       else
+               msg("Fail to request restriction all info " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       return ret;
+}
+
+static int __test_stc_restriction_get_status(MManager *mm, struct menu_data *menu)
+{
+       int ret = STC_ERROR_NONE;
+       stc_restriction_status_e rst_status;
+
+       ret = stc_get_restriction_status(g_stc, g_restriction_rule, &rst_status);
+
+       if (ret == STC_ERROR_NONE) {
+               msg("Restriction status " LOG_CYAN "[%s]" LOG_END,
+                       test_stc_convert_rst_status_to_string(rst_status));
+               msg(LOG_GREEN "Success to get restriction status" LOG_END);
+       } else
+               msg("Fail to get restriction status " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       return ret;
+}
+
+static int __test_stc_restriction_unset(MManager *mm, struct menu_data *menu)
+{
+       int ret = STC_ERROR_NONE;
+
+       ret = stc_unset_restriction(g_stc,
+               g_restriction_rule);
+
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to unset restriction" LOG_END);
+       else
+               msg("Fail to unset restriction " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       return ret;
+}
+
+static int __test_stc_restriction_exclude(MManager *mm, struct menu_data *menu)
+{
+       int ret = STC_ERROR_NONE;
+
+       ret = stc_exclude_restriction(g_stc, g_restriction_rule);
+
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to exclude restriction" LOG_END);
+       else
+               msg("Fail to exclude restriction " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       return ret;
+}
+
+int test_stc_restriction_rule_create(void)
+{
+       int ret = stc_restriction_rule_create(g_stc, &g_restriction_rule);
+
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to create restriction rule" LOG_END);
+       else
+               msg("Fail to create restriction rule " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       return ret;
+}
+
+int test_stc_restriction_rule_destroy(void)
+{
+       int ret = STC_ERROR_NONE;
+
+       if (g_restriction_rule) {
+               ret = stc_restriction_rule_destroy(g_restriction_rule);
+
+               if (ret == STC_ERROR_NONE)
+                       msg(LOG_GREEN "Success to destroy restriction rule" LOG_END);
+               else
+                       msg("Fail to destroy restriction rule " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+       }
+
+       return ret;
+}
+
+static struct menu_data menu_restriction_rule[] = {
+       { "1", "Application ID", NULL, NULL, g_app_id},
+       { "2", "Imsi", NULL, NULL, g_imsi},
+       { "3", "Interface type(1.Tel/2.Wifi/3.Wired/4.BT/5.All)", NULL, NULL, g_iface_type},
+       { "4", "Interface name", NULL, NULL, g_iface_name},
+       { "5", "Roaming(1.Enable/2.Disable)", NULL, NULL, g_roaming},
+       { "6", "Receive limit", NULL, NULL, g_rx_limit},
+       { "7", "Send limit", NULL, NULL, g_tx_limit},
+       { "8", "Receive warning limit", NULL, NULL, g_rx_warning_limit},
+       { "9", "Send warning limit", NULL, NULL, g_tx_warning_limit},
+       { "s", LOG_LIGHTMAGENTA "[Set]" LOG_END, NULL, __test_stc_set_restriction_rule, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_restriction[] = {
+       { "1", LOG_LIGHTMAGENTA "[Set]" LOG_END " restriction rule", menu_restriction_rule, NULL, NULL},
+       { "2", LOG_LIGHTBLUE "[Get]" LOG_END " restriction", NULL, __test_stc_restriction_get, NULL},
+       { "3", LOG_LIGHTBLUE "[Get]" LOG_END " all restrictions", NULL, __test_stc_restriction_get_all, NULL},
+       { "4", LOG_LIGHTBLUE "[Get]" LOG_END " restriction status", NULL, __test_stc_restriction_get_status, NULL},
+       { "5", LOG_LIGHTMAGENTA "[Set]" LOG_END " restriction", NULL, __test_stc_restriction_set, NULL},
+       { "6", LOG_LIGHTMAGENTA "[Remove]" LOG_END " restriction", NULL, __test_stc_restriction_unset, NULL},
+       { "7", LOG_LIGHTMAGENTA "[Exlcude]" LOG_END " restriction", NULL, __test_stc_restriction_exclude, NULL},
+       { NULL, NULL, },
+};
diff --git a/test/restriction.h b/test/restriction.h
new file mode 100755 (executable)
index 0000000..ec2989f
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        restriction.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __TEST_STC_RESTRICTION_H__
+#define __TEST_STC_RESTRICTION_H__
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+int test_stc_restriction_rule_create(void);
+int test_stc_restriction_rule_destroy(void);
+
+#endif /** __TEST_STC_RESTRICTION_H__ */
+
diff --git a/test/statistics.c b/test/statistics.c
new file mode 100755 (executable)
index 0000000..0e37c89
--- /dev/null
@@ -0,0 +1,503 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        statistics.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+#include <assert.h>
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <stc.h>
+#include <stc_internal.h>
+
+#include "stc_test.h"
+#include "stc_menu.h"
+
+static char g_reset_app_id[MENU_DATA_SIZE] = "";
+static char g_reset_imsi[MENU_DATA_SIZE] = "";
+static char g_reset_iface_type[MENU_DATA_SIZE] = "0";
+static char g_reset_conn_period[MENU_DATA_SIZE] = "0";
+
+static char g_stats_app_id[MENU_DATA_SIZE] = "";
+static char g_stats_iface_type[MENU_DATA_SIZE] = "0";
+static char g_stats_time_period[MENU_DATA_SIZE] = "0";
+
+extern stc_h g_stc;
+static stc_reset_rule_h g_reset_rule = NULL;
+static stc_stats_rule_h g_stats_rule = NULL;
+
+static time_t __test_stc_make_time(int year, int mon, int day, int hour, int min)
+{
+       struct tm curr = { 0, };
+       curr.tm_year = year - 1900;
+       curr.tm_mon = mon - 1;
+       curr.tm_mday = day;
+       curr.tm_hour = hour;
+       curr.tm_min = min;
+       return mktime(&curr);
+}
+
+static stc_callback_ret_e __test_stc_stats_info_cb(
+                       stc_error_e result, stc_stats_info_h info, void *user_data)
+{
+       if (result != STC_ERROR_NONE) {
+               msg("Response stats info error " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(result));
+               return STC_CALLBACK_CANCEL;
+       }
+
+       int ret = STC_ERROR_NONE;
+       char *app_id;
+       char *iface_name;
+       char *imsi;
+       time_t from;
+       time_t to;
+       stc_iface_type_e iface_type;
+       uint64_t incoming;
+       uint64_t outgoing;
+       stc_roaming_type_e roaming;
+       stc_protocol_type_e prototype;
+       stc_process_state_e procstate;
+
+       msg(HR_SINGLE);
+
+       ret = stc_stats_info_get_app_id(info, &app_id);
+       if (ret == STC_ERROR_NONE)
+               msg("App_id:   " LOG_CYAN "[%s]" LOG_END, app_id);
+
+       ret = stc_stats_info_get_iface_name(info, &iface_name);
+       if (ret == STC_ERROR_NONE)
+               msg("Ifname:   [%s]", iface_name);
+
+       ret = stc_stats_info_get_imsi(info, &imsi);
+       if (ret == STC_ERROR_NONE)
+               msg("Imsi:     [%s]", imsi);
+
+       ret = stc_stats_info_get_iface_type(info, &iface_type);
+       if (ret == STC_ERROR_NONE)
+               msg("Iftype:   [%s]", test_stc_convert_iface_type_to_string(iface_type));
+
+       ret = stc_stats_info_get_counter(info, &incoming, &outgoing);
+       if (ret == STC_ERROR_NONE) {
+               msg("Received: [%llu]", incoming);
+               msg("Sent:     [%llu]", outgoing);
+       }
+
+       ret = stc_stats_info_get_roaming_type(info, &roaming);
+       if (ret == STC_ERROR_NONE)
+               msg("Roaming:  [%s]", test_stc_convert_roaming_to_string(roaming));
+
+       ret = stc_stats_info_get_protocol_type(info, &prototype);
+       if (ret == STC_ERROR_NONE)
+               msg("Protocol: [%s]", test_stc_convert_protocol_to_string(prototype));
+
+       ret = stc_stats_info_get_process_state(info, &procstate);
+       if (ret == STC_ERROR_NONE)
+               msg("Process:  [%s]", test_stc_convert_process_state_to_string(procstate));
+
+       ret = stc_stats_info_get_time_interval(info, &from, &to);
+       if (ret == STC_ERROR_NONE) {
+               msg("From:     [%lu]", from);
+               msg("To:       [%lu]", to);
+       }
+
+       msg(HR_SINGLE);
+
+       g_free(app_id);
+       g_free(iface_name);
+       g_free(imsi);
+
+       return STC_CALLBACK_CONTINUE;
+}
+
+static int __test_stc_set_reset_rule(MManager *mm, struct menu_data *menu)
+{
+       int ret = STC_ERROR_NONE;
+       stc_iface_type_e iface_type = (int)strtol(g_reset_iface_type, NULL, 10);
+       stc_conn_period_e conn_period =
+               (int)strtol(g_reset_conn_period, NULL, 10);
+       char *app_id = NULL;
+       char *imsi = NULL;
+
+       ret = stc_reset_rule_set_app_id(g_reset_rule, g_reset_app_id);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to set application ID" LOG_END);
+       else {
+               msg("Fail to set application ID " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       ret = stc_reset_rule_set_imsi(g_reset_rule, g_reset_imsi);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to set imsi" LOG_END);
+       else {
+               msg("Fail to set imsi " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       if (iface_type > STC_IFACE_UNKNOWN && iface_type <= STC_IFACE_ALL) {
+               ret = stc_reset_rule_set_iface_type(g_reset_rule, iface_type);
+               if (ret == STC_ERROR_NONE)
+                       msg(LOG_GREEN "Success to set interface type" LOG_END);
+               else {
+                       msg("Fail to set interface type " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
+       if (conn_period > STC_CONN_PERIOD_UNKNOWN &&
+               conn_period <= STC_CONN_PERIOD_TOTAL_SENT_DATA) {
+               ret = stc_reset_rule_set_connection_period(g_reset_rule, conn_period);
+               if (ret == STC_ERROR_NONE)
+                       msg(LOG_GREEN "Success to set time period" LOG_END);
+               else {
+                       msg("Fail to set time period " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
+       msg(HR_SINGLE);
+
+       ret = stc_reset_rule_get_app_id(g_reset_rule, &app_id);
+       if (ret == STC_ERROR_NONE) {
+               msg("App_id:      " LOG_CYAN "[%s]" LOG_END, app_id);
+               g_free(app_id);
+       }
+
+       ret = stc_reset_rule_get_imsi(g_reset_rule, &imsi);
+       if (ret == STC_ERROR_NONE) {
+               msg("Imsi:        " LOG_CYAN "[%s]" LOG_END, imsi);
+               g_free(imsi);
+       }
+
+       ret = stc_reset_rule_get_iface_type(g_reset_rule, &iface_type);
+       if (ret == STC_ERROR_NONE)
+               msg("Iftype:      " LOG_CYAN "[%s]" LOG_END,
+                       test_stc_convert_iface_type_to_string(iface_type));
+
+       ret = stc_reset_rule_get_connection_period(g_reset_rule, &conn_period);
+       if (ret == STC_ERROR_NONE)
+               msg("Conn period: " LOG_CYAN "[%s]" LOG_END,
+                       test_stc_convert_period_to_string(conn_period));
+
+       msg(HR_SINGLE);
+
+       return STC_ERROR_NONE;
+}
+
+static int __test_stc_stats_reset(MManager *mm, struct menu_data *menu)
+{
+       int ret = STC_ERROR_NONE;
+       time_t from = 0;
+       time_t to = 0;
+
+       from = __test_stc_make_time(2000, 1, 1, 1, 1);
+       time(&to);
+       ret = stc_reset_rule_set_time_interval(g_reset_rule, from, to);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to set time interval" LOG_END);
+       else
+               msg("Fail to set time interval " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       ret = stc_reset_stats(g_stc, g_reset_rule);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to reset stats" LOG_END);
+       else
+               msg("Fail to reset stats " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       return ret;
+}
+
+static int __test_stc_set_stats_rule(MManager *mm, struct menu_data *menu)
+{
+       int ret = STC_ERROR_NONE;
+       stc_iface_type_e iface_type = (int)strtol(g_stats_iface_type, NULL, 10);
+       int time_period = (int)strtol(g_stats_time_period, NULL, 10);
+       char *app_id = NULL;
+       stc_time_period_e tm_period = STC_CONN_PERIOD_UNKNOWN;
+
+       ret = stc_stats_rule_set_app_id(g_stats_rule, g_stats_app_id);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to set application ID" LOG_END);
+       else {
+               msg("Fail to set application ID " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       if (iface_type > STC_IFACE_UNKNOWN && iface_type <= STC_IFACE_ALL) {
+               ret = stc_stats_rule_set_iface_type(g_stats_rule, iface_type);
+               if (ret == STC_ERROR_NONE)
+                       msg(LOG_GREEN "Success to set interface type" LOG_END);
+               else {
+                       msg("Fail to set interface type " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
+       if (time_period > 0 && time_period < 5) {
+               switch (time_period) {
+               case 1:
+                       tm_period = STC_TIME_PERIOD_HOUR;
+                       break;
+               case 2:
+                       tm_period = STC_TIME_PERIOD_DAY;
+                       break;
+               case 3:
+                       tm_period = STC_TIME_PERIOD_WEEK;
+                       break;
+               case 4:
+                       tm_period = STC_TIME_PERIOD_MONTH;
+                       break;
+               default:
+                       break;
+               }
+               ret = stc_stats_rule_set_time_period(g_stats_rule, tm_period);
+               if (ret == STC_ERROR_NONE)
+                       msg(LOG_GREEN "Success to set time period" LOG_END);
+               else {
+                       msg("Fail to set time period " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+                       return ret;
+               }
+       }
+
+       msg(HR_SINGLE);
+
+       ret = stc_stats_rule_get_app_id(g_stats_rule, &app_id);
+       if (ret == STC_ERROR_NONE) {
+               msg("App_id:      " LOG_CYAN "[%s]" LOG_END, app_id);
+               g_free(app_id);
+       }
+
+       ret = stc_stats_rule_get_iface_type(g_stats_rule, &iface_type);
+       if (ret == STC_ERROR_NONE)
+               msg("Iftype:      " LOG_CYAN "[%s]" LOG_END,
+                       test_stc_convert_iface_type_to_string(iface_type));
+
+       ret = stc_stats_rule_get_time_period(g_stats_rule, &tm_period);
+       if (ret == STC_ERROR_NONE)
+               msg("Time period: " LOG_CYAN "[%s]" LOG_END,
+                       test_stc_convert_time_period_to_string(tm_period));
+
+       msg(HR_SINGLE);
+
+       return STC_ERROR_NONE;
+}
+
+static int __test_stc_stats_get(MManager *mm, struct menu_data *menu)
+{
+       int ret = STC_ERROR_NONE;
+       time_t from = 0;
+       time_t to = 0;
+
+       from = __test_stc_make_time(2000, 1, 1, 1, 1);
+       time(&to);
+       ret = stc_stats_rule_set_time_interval(g_stats_rule, from, to);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to set time interval" LOG_END);
+       else
+               msg("Fail to set time interval " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       ret = stc_get_stats(g_stc,
+               g_stats_rule,
+               __test_stc_stats_info_cb,
+               NULL);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to request stats info" LOG_END);
+       else
+               msg("Fail to request stats info " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       return ret;
+}
+
+static int __test_stc_foreach_stats(MManager *mm, struct menu_data *menu)
+{
+       int ret = STC_ERROR_NONE;
+       time_t from = 0;
+       time_t to = 0;
+
+       from = __test_stc_make_time(2000, 1, 1, 1, 1);
+       time(&to);
+       ret = stc_stats_rule_set_time_interval(g_stats_rule, from, to);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to set time interval" LOG_END);
+       else
+               msg("Fail to set time interval " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       ret = stc_foreach_stats(g_stc,
+               g_stats_rule,
+               __test_stc_stats_info_cb,
+               NULL);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to request stats all info" LOG_END);
+       else
+               msg("Fail to request stats all info " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       return ret;
+}
+
+static int __test_stc_stats_get_total(MManager *mm, struct menu_data *menu)
+{
+       int ret = STC_ERROR_NONE;
+       time_t from = 0;
+       time_t to = 0;
+
+       from = __test_stc_make_time(2000, 1, 1, 1, 1);
+       time(&to);
+       ret = stc_stats_rule_set_time_interval(g_stats_rule, from, to);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to set time interval" LOG_END);
+       else
+               msg("Fail to set time interval " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       ret = stc_get_total_stats(g_stc,
+               g_stats_rule,
+               __test_stc_stats_info_cb,
+               NULL);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to request stats total info" LOG_END);
+       else
+               msg("Fail to request stats total info " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       return ret;
+}
+
+int test_stc_reset_rule_create(void)
+{
+       int ret = stc_reset_rule_create(g_stc, &g_reset_rule);
+
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to create reset rule" LOG_END);
+       else
+               msg("Fail to create reset rule " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       return ret;
+}
+
+int test_stc_reset_rule_destroy(void)
+{
+       int ret = STC_ERROR_NONE;
+
+       if (g_reset_rule) {
+               ret = stc_reset_rule_destroy(g_reset_rule);
+
+               if (ret == STC_ERROR_NONE)
+                       msg(LOG_GREEN "Success to destroy reset rule" LOG_END);
+               else
+                       msg("Fail to destroy reset rule " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+       }
+
+       return ret;
+}
+
+int test_stc_stats_rule_create(void)
+{
+       int ret = stc_stats_rule_create(g_stc, &g_stats_rule);
+
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to create stats rule" LOG_END);
+       else
+               msg("Fail to create stats rule " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+
+       return ret;
+}
+
+int test_stc_stats_rule_destroy(void)
+{
+       int ret = STC_ERROR_NONE;
+
+       if (g_stats_rule) {
+               ret = stc_stats_rule_destroy(g_stats_rule);
+
+               if (ret == STC_ERROR_NONE)
+                       msg(LOG_GREEN "Success to destroy stats rule" LOG_END);
+               else
+                       msg("Fail to destroy stats rule " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+       }
+
+       return ret;
+}
+
+static struct menu_data menu_reset_rule[] = {
+       { "1", "Application ID", NULL, NULL, g_reset_app_id},
+       { "2", "Imsi", NULL, NULL, g_reset_imsi},
+       { "3", "Interface type (1.Tel/2.Wifi/3.Wired/4.BT/5.All)", NULL, NULL, g_reset_iface_type},
+       { "4", "Connection state", NULL, NULL, g_reset_conn_period},
+       { "s", LOG_LIGHTMAGENTA "[Set]" LOG_END, NULL, __test_stc_set_reset_rule, NULL},
+       { NULL, NULL, },
+};
+
+static struct menu_data menu_stats_rule[] = {
+       { "1", "Application ID", NULL, NULL, g_stats_app_id},
+       { "2", "Interface type (1.Tel/2.Wifi/3.Wired/4.BT/5.All)", NULL, NULL, g_stats_iface_type},
+       { "3", "Time period (1.Hour/2.Day/3.Week/4.Month)", NULL, NULL, g_stats_time_period},
+       { "s", LOG_LIGHTMAGENTA "[Set]" LOG_END, NULL, __test_stc_set_stats_rule, NULL},
+       { NULL, NULL, },
+};
+
+static struct menu_data menu_reset[] = {
+       { "1", LOG_LIGHTMAGENTA "[Set]" LOG_END " reset rule", menu_reset_rule, NULL, NULL},
+       { "2", LOG_LIGHTMAGENTA "[Reset]" LOG_END " stats", NULL, __test_stc_stats_reset, NULL},
+       { NULL, NULL, },
+};
+
+static struct menu_data menu_stats[] = {
+       { "1", LOG_LIGHTMAGENTA "[Set]" LOG_END " stats rule", menu_stats_rule, NULL, NULL},
+       { "2", LOG_LIGHTBLUE "[Get]" LOG_END " stats", NULL, __test_stc_stats_get, NULL},
+       { "3", LOG_LIGHTBLUE "[Get]" LOG_END " all stats", NULL, __test_stc_foreach_stats, NULL},
+       { "4", LOG_LIGHTBLUE "[Get]" LOG_END " total stats", NULL, __test_stc_stats_get_total, NULL},
+       { NULL, NULL, },
+};
+
+struct menu_data menu_statistics[] = {
+       { "1", LOG_LIGHTBLUE "[Stats]" LOG_END, menu_stats, NULL, NULL},
+       { "2", LOG_LIGHTMAGENTA "[Reset]" LOG_END, menu_reset, NULL, NULL},
+       { NULL, NULL, },
+};
diff --git a/test/statistics.h b/test/statistics.h
new file mode 100755 (executable)
index 0000000..2df33c0
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        statistics.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __TEST_STC_STATS_H__
+#define __TEST_STC_STATS_H__
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+int test_stc_reset_rule_create(void);
+int test_stc_reset_rule_destroy(void);
+int test_stc_stats_rule_create(void);
+int test_stc_stats_rule_destroy(void);
+
+#endif /** __TEST_STC_STATS_H__ */
diff --git a/test/stc_menu.c b/test/stc_menu.c
new file mode 100755 (executable)
index 0000000..16b4369
--- /dev/null
@@ -0,0 +1,386 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc_menu.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <glib.h>
+#include <asm/unistd.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "stc_menu.h"
+
+#define DEFAULT_MENU_MENU      "m"
+#define DEFAULT_MENU_PREV      "p"
+#define DEFAULT_MENU_QUIT      "q"
+#define DEFAULT_MENU_NONE      "-"
+#define TAB_SPACE     "  "
+
+struct menu_manager {
+       GQueue *stack;
+       GQueue *title_stack;
+
+       struct menu_data *menu;
+
+       char *buf;
+
+       void *user_data;
+       GMainLoop *mainloop;
+};
+
+
+char key_buffer[MENU_DATA_SIZE];
+int flag_pid_display = 1;
+
+
+static void _show_prompt(void)
+{
+       msgn("(%5d) >> ", get_tid());
+}
+
+static void _show_reserved_menu(void)
+{
+       msg(LOG_DARKGRAY HR_SINGLE2 LOG_END);
+       msg(LOG_DARKGRAY " [ " LOG_END "%s" LOG_DARKGRAY
+                       " ] " LOG_END "Previous Menu " , DEFAULT_MENU_PREV);
+       msg(LOG_DARKGRAY " [ " LOG_END "%s" LOG_DARKGRAY
+                       " ] " LOG_END "Show Menu " , DEFAULT_MENU_MENU);
+       msg(LOG_DARKGRAY " [ " LOG_END "%s" LOG_DARKGRAY
+                       " ] " LOG_END "Quit " , DEFAULT_MENU_QUIT);
+}
+
+static void _show_input_ok(void)
+{
+       msg("OK.");
+}
+
+static void _show_menu(MManager *m, struct menu_data menu[])
+{
+       int i = 0;
+       int len = 0;
+       struct menu_data *item;
+       char title_buf[256] = { 0, };
+
+       if (!menu)
+               return;
+
+       msg("");
+       msg(HR_DOUBLE);
+
+       len = g_queue_get_length(m->title_stack);
+       msgn(LOG_YELLOW " Main");
+       if (len > 0) {
+               for (i = 0; i < len; i++) {
+                       msgn(LOG_END " >> " LOG_YELLOW "%s",
+                                       (char *)g_queue_peek_nth(m->title_stack, i));
+               }
+       }
+       msg(LOG_END);
+       msg(HR_SINGLE);
+
+       hide_pid();
+       i = 0;
+
+       while (1) {
+               item = menu + i;
+               if (item->key == NULL)
+                       break;
+
+               if (!g_strcmp0(item->key, "-")) {
+                       msgn("       ");
+               } else if (!g_strcmp0(item->key, "_")) {
+                       msg(LOG_DARKGRAY HR_SINGLE2 LOG_END);
+
+                       if (item->callback)
+                               item->callback(m, item);
+
+                       i++;
+
+                       continue;
+               } else if (!g_strcmp0(item->key, "*")) {
+                       msg(" %s", item->title);
+                       if (item->callback)
+                               item->callback(m, item);
+               } else {
+                       msgn(LOG_DARKGRAY " [" LOG_END "%3s"
+                                       LOG_DARKGRAY "] " LOG_END,      item->key);
+               }
+
+               memset(title_buf, 0, 256);
+               if (item->title) {
+                       snprintf(title_buf, MAX_TITLE, "%s", item->title);
+
+                       if (strlen(item->title) >= MAX_TITLE) {
+                               title_buf[MAX_TITLE - 2] = '.';
+                               title_buf[MAX_TITLE - 1] = '.';
+                       }
+               }
+
+               if (item->data) {
+                       msg("%s " LOG_LIGHTBLUE "(%s)" LOG_END,
+                                       title_buf, item->data);
+               } else if (!g_strcmp0(item->key, "*")) {
+                       /* none */
+               } else {
+                       msg("%s", title_buf);
+               }
+
+               if (item->sub_menu)
+                       msg("\e[1A\e[%dC >", (int)POS_MORE);
+
+               i++;
+       }
+
+       show_pid();
+
+       _show_reserved_menu();
+
+       msg(HR_DOUBLE);
+
+       _show_prompt();
+}
+
+static void _show_item_data_input_msg(struct menu_data *item)
+{
+       msg("");
+       msg(HR_DOUBLE);
+       msg(" Input [%s] data ", item->title);
+       msg(HR_SINGLE);
+       msg(" current = [%s]", item->data);
+       msgn(" new >> ");
+}
+
+static void _move_menu(MManager *mm, struct menu_data menu[], char *key)
+{
+       struct menu_data *item;
+       int i = 0;
+
+       if (!mm->menu)
+               return;
+
+       if (!g_strcmp0(DEFAULT_MENU_PREV, key)) {
+               if (g_queue_get_length(mm->stack) > 0) {
+                       mm->menu = g_queue_pop_tail(mm->stack);
+                       g_queue_pop_tail(mm->title_stack);
+               }
+
+               _show_menu(mm, mm->menu);
+               mm->buf = key_buffer;
+
+               return;
+       } else if (!g_strcmp0(DEFAULT_MENU_MENU, key)) {
+               _show_menu(mm, mm->menu);
+               return;
+       } else if (!g_strcmp0(DEFAULT_MENU_QUIT, key)) {
+               g_main_loop_quit(mm->mainloop);
+               return;
+       } else if (!g_strcmp0(DEFAULT_MENU_NONE, key)) {
+               _show_prompt();
+               return;
+       }
+
+       while (1) {
+               int ret = RET_SUCCESS;
+               item = menu + i;
+               if (item->key == NULL)
+                       break;
+
+               if (!g_strcmp0(item->key, key)) {
+                       if (item->callback) {
+                               ret = item->callback(mm, item);
+                               _show_prompt();
+                       }
+
+                       if (RET_SUCCESS == ret) {
+                               if (item->sub_menu) {
+                                       g_queue_push_tail(mm->stack, mm->menu);
+                                       g_queue_push_tail(mm->title_stack, (gpointer *)item->title);
+
+                                       mm->menu = item->sub_menu;
+                                       _show_menu(mm, mm->menu);
+                                       mm->buf = key_buffer;
+                               }
+
+                               if (item->data) {
+                                       _show_item_data_input_msg(item);
+                                       mm->buf = item->data;
+                               }
+                       }
+
+                       return;
+               }
+
+               i++;
+       }
+
+       _show_prompt();
+}
+
+MManager *menu_manager_new(struct menu_data items[], GMainLoop *mainloop)
+{
+       MManager *mm;
+
+       mm = calloc(sizeof(struct menu_manager), 1);
+       if (!mm)
+               return NULL;
+
+       mm->stack = g_queue_new();
+       mm->title_stack = g_queue_new();
+       mm->menu = items;
+       mm->mainloop = mainloop;
+
+       return mm;
+}
+
+int menu_manager_run(MManager *mm)
+{
+       _show_menu(mm, mm->menu);
+
+       mm->buf = key_buffer;
+
+       return 0;
+}
+
+int menu_manager_set_user_data(MManager *mm, void *user_data)
+{
+       if (!mm)
+               return -1;
+
+       mm->user_data = user_data;
+
+       return 0;
+}
+
+void *menu_manager_ref_user_data(MManager *mm)
+{
+       if (!mm)
+               return NULL;
+
+       return mm->user_data;
+}
+
+gboolean on_menu_manager_keyboard(GIOChannel *src, GIOCondition con,
+               gpointer data)
+{
+       MManager *mm = data;
+       char local_buf[MENU_DATA_SIZE + 1] = { 0, };
+
+       if (fgets(local_buf, MENU_DATA_SIZE, stdin) == NULL)
+               return TRUE;
+
+       if (strlen(local_buf) > 0) {
+               if (local_buf[strlen(local_buf) - 1] == '\n')
+                       local_buf[strlen(local_buf) - 1] = '\0';
+       }
+
+       if (mm->buf == key_buffer) {
+               if (strlen(local_buf) < 1) {
+                       _show_prompt();
+                       return TRUE;
+               }
+
+               _move_menu(mm, mm->menu, local_buf);
+       } else {
+               if (mm->buf) {
+                       memset(mm->buf, 0, MENU_DATA_SIZE);
+                       memcpy(mm->buf, local_buf, MENU_DATA_SIZE);
+                       _show_input_ok();
+               }
+               mm->buf = key_buffer;
+               _move_menu(mm, mm->menu, (char *)DEFAULT_MENU_MENU);
+       }
+
+       return TRUE;
+}
+
+pid_t get_tid()
+{
+       return syscall(__NR_gettid);
+}
+
+void hide_pid()
+{
+       flag_pid_display = 0;
+}
+
+void show_pid()
+{
+       flag_pid_display = 1;
+}
+
+int is_pid_show()
+{
+       return flag_pid_display;
+}
+
+static void _hex_dump(const char *pad, int size, const void *data)
+{
+       char buf[255] = {0, };
+       char hex[4] = {0, };
+       int i;
+       unsigned char *p;
+
+       if (size <= 0) {
+               msg("%sno data", pad);
+               return;
+       }
+       p = (unsigned char *)data;
+
+       snprintf(buf, 255, "%s%04X: ", pad, 0);
+       for (i = 0; i < size; i++) {
+               snprintf(hex, 4, "%02X ", p[i]);
+               strncat(buf, hex, strlen(hex));
+
+               if ((i + 1) % 8 == 0) {
+                       if ((i + 1) % 16 == 0) {
+                               msg("%s", buf);
+                               memset(buf, 0, 255);
+                               snprintf(buf, 255, "%s%04X: ", pad, i + 1);
+                       } else {
+                               strncat(buf, TAB_SPACE, strlen(TAB_SPACE));
+                       }
+               }
+       }
+
+       msg("%s", buf);
+}
+
+void menu_print_dump(int data_len, void *data)
+{
+       if (!data)
+               return;
+
+       msg("");
+       msg("  \tlen=%d", data_len);
+       _hex_dump("        ", data_len, data);
+
+       msg("");
+}
+
diff --git a/test/stc_menu.h b/test/stc_menu.h
new file mode 100755 (executable)
index 0000000..9e62335
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc_menu.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#ifndef __STC_MENU_H__
+#define __STC_MENU_H__
+
+__BEGIN_DECLS
+
+#define LOG_END                        "\e[0m"
+
+#define LOG_BLACK                      "\e[0;30m"
+#define LOG_RED                                "\e[0;31m"
+#define LOG_GREEN                      "\e[0;32m"
+#define LOG_BROWN                      "\e[0;33m"
+#define LOG_BLUE                       "\e[0;34m"
+#define LOG_MAGENTA                    "\e[0;35m"
+#define LOG_CYAN                       "\e[0;36m"
+#define LOG_LIGHTGRAY          "\e[0;37m"
+
+#define LOG_DARKGRAY           "\e[1;30m"
+#define LOG_LIGHTRED           "\e[1;31m"
+#define LOG_LIGHTGREEN         "\e[1;32m"
+#define LOG_YELLOW                     "\e[1;33m"
+#define LOG_LIGHTBLUE          "\e[1;34m"
+#define LOG_LIGHTMAGENTA       "\e[1;35m"
+#define LOG_LIGHTCYAN          "\e[1;36m"
+#define LOG_WHITE                      "\e[1;37m"
+
+
+#define msg(fmt,args...)       do { fprintf(stdout, fmt "\n", ##args); \
+               fflush(stdout); } while (0)
+#define msgn(fmt,args...)      do { fprintf(stdout, fmt, ##args); \
+               fflush(stdout); } while (0)
+
+/* Bold (green) */
+#define msgb(fmt,args...)  do { fprintf(stdout, LOG_LIGHTGREEN fmt \
+               LOG_END "\n", ##args); fflush(stdout); } while (0)
+
+/* Property message */
+#define msgp(fmt,args...) do { fprintf(stdout, LOG_LIGHTMAGENTA fmt \
+               LOG_END "\n", ##args); fflush(stdout); } while (0)
+
+#define msgt(n,fmt,args...) do { fprintf(stdout, "\e[%dC" fmt "\n", \
+               3 + ((n) * 2), ##args); fflush(stdout); } while (0)
+
+#define pmsg(fmt,args...) do { \
+       if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
+       fprintf(stdout, fmt "\n", ##args); fflush(stdout); } while (0)
+
+#define pmsgb(fmt,args...) do { \
+       if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
+       fprintf(stdout, LOG_LIGHTGREEN fmt \
+                       LOG_END "\n", ##args); fflush(stdout); } while (0)
+
+#define pmsgt(n,fmt,args...) do { \
+       if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
+       fprintf(stdout, "\e[%dC" fmt "\n", \
+                       3 + ((n) * 2), ##args); fflush(stdout); } while (0)
+
+#define MENU_DATA_SIZE 255
+
+
+
+/*
+ * Horizontal Line - width: 65
+ *                                     .12345678901234567890123456789012345678901234567890.
+ */
+#define HR_SINGLE      "----------------------------------------" \
+                                       "-------------------------"
+#define HR_DOUBLE      "========================================" \
+                                       "========================="
+#define HR_SINGLE2     " ---------------------------------------" \
+                                       "------------------------ "
+
+#define MAX_WIDTH      strlen (HR_SINGLE)
+#define MAX_TITLE      ((MAX_WIDTH) - 10)
+#define POS_MORE       ((MAX_WIDTH) - 3)
+#define RET_SUCCESS 0
+#define RET_FAILURE -1
+
+typedef struct menu_manager MManager;
+
+struct menu_data {
+       const char *key;
+       const char *title;
+       struct menu_data *sub_menu;
+       int (*callback)(MManager *mm, struct menu_data *menu);
+       char *data;
+};
+
+MManager* menu_manager_new(struct menu_data items[], GMainLoop *mainloop);
+int       menu_manager_run(MManager *mm);
+int       menu_manager_set_user_data(MManager *mm, void *user_data);
+void*     menu_manager_ref_user_data(MManager *mm);
+
+gboolean  on_menu_manager_keyboard(GIOChannel *src, GIOCondition con,
+               gpointer data);
+
+pid_t     get_tid ();
+void      hide_pid ();
+void      show_pid ();
+int       is_pid_show ();
+void      menu_print_dump(int data_len, void *data);
+
+__END_DECLS
+
+#endif
diff --git a/test/stc_test.c b/test/stc_test.c
new file mode 100755 (executable)
index 0000000..25aeca2
--- /dev/null
@@ -0,0 +1,316 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc_test.c
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <stc.h>
+#include <stc_internal.h>
+
+#include "stc_test.h"
+#include "stc_menu.h"
+#include "statistics.h"
+#include "restriction.h"
+
+#define STC_APP_ID_LEN 128
+#define STC_IFNAME_LEN 16
+#define STC_IMSI_LEN 64
+
+extern struct menu_data menu_statistics[];
+extern struct menu_data menu_restriction[];
+
+stc_h g_stc = NULL;
+
+const char *test_stc_convert_error_type_to_string(stc_error_e err)
+{
+       switch (err) {
+       case STC_ERROR_NONE:
+               return "None";
+       case STC_ERROR_NOT_PERMITTED:
+               return "Operation not permitted";
+       case STC_ERROR_OUT_OF_MEMORY:
+               return "Out of memory";
+       case STC_ERROR_PERMISSION_DENIED:
+               return "Permission denied";
+       case STC_ERROR_RESOURCE_BUSY:
+               return "Device or resource busy";
+       case STC_ERROR_INVALID_OPERATION:
+               return "Invalid operation";
+       case STC_ERROR_INVALID_PARAMETER:
+               return "Invalid parameter";
+       case STC_ERROR_NOT_SUPPORTED:
+               return "Not supported";
+       case STC_ERROR_OPERATION_FAILED:
+               return "Operation failed";
+       case STC_ERROR_NOT_INITIALIZED:
+               return "Cgroup doen't mounted or daemon not started";
+       case STC_ERROR_ALREADY_INITIALIZED:
+               return "Already initialized";
+       case STC_ERROR_IN_PROGRESS:
+               return "In progress";
+       default:
+               return "Unknown";
+       }
+}
+
+const char *test_stc_convert_iface_type_to_string(stc_iface_type_e type)
+{
+       switch (type) {
+       case STC_IFACE_UNKNOWN:
+               return "Undefined";
+       case STC_IFACE_DATACALL:
+               return "Data Call";
+       case STC_IFACE_WIFI:
+               return "Wi-Fi";
+       case STC_IFACE_WIRED:
+               return "Wired";
+       case STC_IFACE_BLUETOOTH:
+               return "Bluetooth";
+       case STC_IFACE_ALL:
+               return "All";
+       default:
+               return "Unknown";
+       }
+}
+
+const char *test_stc_convert_roaming_to_string(stc_roaming_type_e type)
+{
+       switch (type) {
+       case STC_ROAMING_UNKNOWN:
+               return "Unknown";
+       case STC_ROAMING_ENABLED:
+               return "Enable";
+       case STC_ROAMING_DISABLED:
+               return "Disable";
+       default:
+               return "Unknown";
+       }
+}
+
+const char *test_stc_convert_rst_status_to_string(stc_restriction_status_e status)
+{
+       switch (status) {
+       case STC_RESTRICTION_UNKNOWN:
+               return "Undefined";
+       case STC_RESTRICTION_ACTIVATED:
+               return "Activated";
+       case STC_RESTRICTION_REMOVED:
+               return "Removed";
+       case STC_RESTRICTION_EXCLUDED:
+               return "Excluded";
+       case STC_RESTRICTION_BACKGROUND:
+               return "Background";
+       default:
+               return "Unknown";
+       }
+}
+
+const char *test_stc_convert_protocol_to_string(stc_protocol_type_e type)
+{
+       switch (type) {
+       case STC_PROTOCOL_UNKNOWN:
+               return "Unknown";
+       case STC_PROTOCOL_DATACALL_NOSVC:
+               return "No service";
+       case STC_PROTOCOL_DATACALL_EMERGENCY:
+               return "Emergency";
+       case STC_PROTOCOL_DATACALL_SEARCH:
+               return "Search 1900";
+       case STC_PROTOCOL_DATACALL_2G:
+               return "2G";
+       case STC_PROTOCOL_DATACALL_2_5G:
+               return "2.5G";
+       case STC_PROTOCOL_DATACALL_2_5G_EDGE:
+               return "EDGE";
+       case STC_PROTOCOL_DATACALL_3G:
+               return "UMTS";
+       case STC_PROTOCOL_DATACALL_HSDPA:
+               return "HSDPA";
+       case STC_PROTOCOL_DATACALL_LTE:
+               return "LTE";
+       default:
+               return "Unknown";
+       }
+}
+
+const char *test_stc_convert_process_state_to_string(stc_process_state_e state)
+{
+       switch (state) {
+       case STC_PROCESS_STATE_UNKNOWN:
+               return "Unknown";
+       case STC_PROCESS_STATE_FOREGROUND:
+               return "Foreground";
+       case STC_PROCESS_STATE_BACKGROUND:
+               return "Background";
+       default:
+               return "Unknown";
+       }
+}
+
+const char *test_stc_convert_time_period_to_string(stc_time_period_e time)
+{
+       switch (time) {
+       case STC_TIME_PERIOD_UNKNOWN:
+               return "Undefined";
+       case STC_TIME_PERIOD_HOUR:
+               return "Hour";
+       case STC_TIME_PERIOD_DAY:
+               return "Day";
+       case STC_TIME_PERIOD_WEEK:
+               return "Week";
+       case STC_TIME_PERIOD_MONTH:
+               return "Month";
+       default:
+               return "Unknown";
+       }
+}
+
+const char *test_stc_convert_period_to_string(
+                       stc_conn_period_e period)
+{
+       switch (period) {
+       case STC_CONN_PERIOD_UNKNOWN:
+               return "Undefined";
+       case STC_CONN_PERIOD_LAST_RECEIVED_DATA:
+               return "Last received data";
+       case STC_CONN_PERIOD_LAST_SENT_DATA:
+               return "Last sent data";
+       case STC_CONN_PERIOD_TOTAL_RECEIVED_DATA:
+               return "Total received data";
+       case STC_CONN_PERIOD_TOTAL_SENT_DATA:
+               return "Total sent data";
+       default:
+               return "Unknown";
+       }
+}
+
+static struct menu_data menu_main[] = {
+       { "1", LOG_LIGHTBLUE "[Statistics]" LOG_END, menu_statistics, NULL, NULL},
+       { "2", LOG_LIGHTMAGENTA "[Restriction]" LOG_END, menu_restriction, NULL, NULL},
+       { NULL, NULL, },
+};
+
+static int __test_stc_initialize(MManager *mm, struct menu_data *menu)
+{
+       int ret = STC_ERROR_NONE;
+
+       if (g_stc) {
+               stc_deinitialize(g_stc);
+               g_stc = NULL;
+       }
+
+       ret = stc_initialize(&g_stc);
+       if (ret == STC_ERROR_NONE)
+               msg(LOG_GREEN "Success to initialize STC" LOG_END);
+       else {
+               msg("Fail to initialize STC " LOG_RED "[%s]" LOG_END,
+                       test_stc_convert_error_type_to_string(ret));
+               return ret;
+       }
+
+       test_stc_reset_rule_create();
+       test_stc_stats_rule_create();
+       test_stc_restriction_rule_create();
+
+       menu_manager_set_user_data(mm, g_stc);
+
+       return ret;
+}
+
+static int __test_stc_deinitialize(void)
+{
+       int ret = STC_ERROR_NONE;
+
+       test_stc_reset_rule_destroy();
+       test_stc_stats_rule_destroy();
+       test_stc_restriction_rule_destroy();
+
+       if (g_stc) {
+               ret = stc_deinitialize(g_stc);
+               if (ret == STC_ERROR_NONE)
+                       msg(LOG_GREEN "Success to initialize STC" LOG_END);
+               else
+                       msg("Fail to initialize STC " LOG_RED "[%s]" LOG_END,
+                               test_stc_convert_error_type_to_string(ret));
+       }
+
+       g_stc = NULL;
+       return ret;
+}
+
+static gboolean __test_stc_create_init_menu(struct menu_data init_menu[1])
+{
+       init_menu[0].key = "1";
+       init_menu[0].title = LOG_YELLOW "STC" LOG_END;
+       init_menu[0].sub_menu = menu_main;
+       init_menu[0].callback = __test_stc_initialize;
+       init_menu[0].data = NULL;
+
+       return TRUE;
+}
+
+int main(int arg, char **argv)
+{
+       GMainLoop *mainloop = NULL;
+       GIOChannel *channel = g_io_channel_unix_new(STDIN_FILENO);
+       MManager *manager;
+       struct menu_data init_menu[1+1] = { {NULL, NULL, } };
+
+#if !GLIB_CHECK_VERSION(2, 35, 0)
+       g_type_init();
+#endif
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       msg("");
+       msg("* STC Test application ");
+       msg("* Build On: %s  %s", __DATE__, __TIME__);
+
+       if (__test_stc_create_init_menu(init_menu) == FALSE)
+               goto OUT;
+
+       manager = menu_manager_new(init_menu, mainloop);
+       if (!manager)
+               goto OUT;
+
+       menu_manager_run(manager);
+
+       g_io_add_watch(channel, (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL),
+                       on_menu_manager_keyboard, manager);
+       g_main_loop_run(mainloop);
+
+OUT:
+       __test_stc_deinitialize();
+       g_main_loop_unref(mainloop);
+       msg("******* Bye bye *******");
+
+       return 0;
+}
diff --git a/test/stc_test.h b/test/stc_test.h
new file mode 100755 (executable)
index 0000000..140ae09
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Smart Traffic Control (STC)
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This file declares definitions, macros and structures.
+ *
+ * @file        stc_test.h
+ * @author      Tak hyunuk (hyunuk.tak@samsung.com)
+ * @version     0.1
+ */
+
+/*****************************************************************************
+ *  Local Functions Definition
+ *****************************************************************************/
+const char *test_stc_convert_error_type_to_string(stc_error_e err);
+const char *test_stc_convert_iface_type_to_string(stc_iface_type_e type);
+const char *test_stc_convert_roaming_to_string(stc_roaming_type_e type);
+const char *test_stc_convert_rst_status_to_string(stc_restriction_status_e status);
+const char *test_stc_convert_protocol_to_string(stc_protocol_type_e type);
+const char *test_stc_convert_process_state_to_string(stc_process_state_e state);
+const char *test_stc_convert_time_period_to_string(stc_time_period_e time);
+const char *test_stc_convert_period_to_string(stc_conn_period_e period);
+