Support to multi connection 63/192763/1
authorhyunuktak <hyunuk.tak@samsung.com>
Fri, 9 Nov 2018 07:12:57 +0000 (16:12 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Fri, 9 Nov 2018 07:14:47 +0000 (16:14 +0900)
Change-Id: I817d87a99a4b24968652c0075ee47a90481c2b38
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
packaging/stc-manager.spec
src/monitor/include/stc-connection.h [moved from src/monitor/include/stc-default-connection.h with 77% similarity]
src/monitor/include/stc-monitor-app.h
src/monitor/include/stc-monitor-rstn.h
src/monitor/include/stc-monitor.h
src/monitor/stc-connection.c [moved from src/monitor/stc-default-connection.c with 62% similarity]
src/monitor/stc-monitor-app.c
src/monitor/stc-monitor-proc.c
src/monitor/stc-monitor-rstn.c
src/monitor/stc-monitor.c
src/stc-manager-gdbus.c

index e6285e0..9f4e7bd 100644 (file)
@@ -1,6 +1,6 @@
 Name:       stc-manager
 Summary:    STC(Smart Traffic Control) manager
-Version:    0.0.80
+Version:    0.0.81
 Release:    0
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
similarity index 77%
rename from src/monitor/include/stc-default-connection.h
rename to src/monitor/include/stc-connection.h
index 222e77b..85d27de 100644 (file)
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef __STC_DEFAULT_CONNECTION_H__
-#define __STC_DEFAULT_CONNECTION_H__
+#ifndef __STC_CONNECTION_H__
+#define __STC_CONNECTION_H__
 
 #include <glib.h>
 #include "stc-error.h"
@@ -39,7 +39,7 @@ typedef struct {
 } tether_iface_s;
 
 /**
- * @brief default connection information will be fetched from net-config
+ * @brief connection information will be fetched from connman
  */
 typedef struct {
        /* to identify each connection uniquely */
@@ -63,12 +63,11 @@ typedef struct {
 
        /* tethering interface */
        tether_iface_s tether_iface;
-} default_connection_s;
+} stc_connection_s;
 
-stc_error_e stc_default_connection_monitor_init(stc_s *stc);
-stc_error_e stc_default_connection_monitor_deinit(stc_s *stc);
+stc_error_e stc_connection_monitor_init(stc_s *stc);
+stc_error_e stc_connection_monitor_deinit(stc_s *stc);
 
-gchar *stc_default_connection_get_ifname(void);
-default_connection_s *stc_get_default_connection(void);
+GSList *stc_get_connection_list(void);
 
-#endif /* __STC_DEFAULT_CONNECTION_H__ */
+#endif /* __STC_CONNECTION_H__ */
index a00d262..3a312fb 100644 (file)
@@ -22,7 +22,7 @@
 #include "stc-error.h"
 #include "stc-manager.h"
 #include "stc-monitor-context.h"
-#include "stc-default-connection.h"
+#include "stc-connection.h"
 
 #define MAC_ADDRESS_LEN 18
 #define SUBSCRIBERID_NONE "none_subid"
@@ -56,7 +56,7 @@ void stc_monitor_app_add_by_iface(const char *app_id);
 void stc_monitor_app_add_monitor(gpointer key,
                                gpointer value, gpointer data);
 
-void stc_monitor_app_add_by_connection(default_connection_s *conn);
+void stc_monitor_app_add_by_connection(stc_connection_s *conn);
 
 void stc_monitor_app_add_accept(gpointer key,
                                gpointer value, gpointer data);
@@ -66,7 +66,7 @@ stc_error_e stc_monitor_app_remove(uint32_t classid, const char *app_id);
 void stc_monitor_app_remove_monitor(gpointer key,
                                gpointer value, gpointer data);
 
-void stc_monitor_app_remove_by_connection(default_connection_s *conn);
+void stc_monitor_app_remove_by_connection(stc_connection_s *conn);
 
 void stc_monitor_app_remove_accept(gpointer key,
                                gpointer value, gpointer data);
index 0480c3b..ecf404d 100644 (file)
@@ -22,7 +22,7 @@
 #include "stc-error.h"
 #include "stc-manager.h"
 #include "stc-monitor-context.h"
-#include "stc-default-connection.h"
+#include "stc-connection.h"
 #include "stc-restriction.h"
 #include "table-restrictions.h"
 
@@ -98,13 +98,13 @@ stc_error_e stc_monitor_rstn_add(const table_restrictions_info *info);
 
 void stc_monitor_rstn_add_for_app(uint32_t classid);
 
-void stc_monitor_rstn_add_by_connection(default_connection_s *conn);
+void stc_monitor_rstn_add_by_connection(stc_connection_s *conn);
 
 stc_error_e stc_monitor_rstn_remove(const table_restrictions_info *info);
 
 void stc_monitor_rstn_remove_for_app(uint32_t classid);
 
-void stc_monitor_rstn_remove_by_connection(default_connection_s *conn);
+void stc_monitor_rstn_remove_by_connection(stc_connection_s *conn);
 
 void stc_monitor_rstns_load(void);
 
index 8fa8bc9..32404b0 100644 (file)
@@ -78,7 +78,11 @@ void stc_monitor_set_background_state(gboolean value);
 
 gboolean stc_monitor_get_background_state(void);
 
-void stc_monitor_update_by_default_connection(void *data);
+void stc_monitor_update_by_connection(void *data);
+
+void stc_monitor_add_by_connection(void *data);
+
+void stc_monitor_remove_by_connection(void *data);
 
 stc_error_e stc_monitor_check_excn_by_cmdline(char *cmdline);
 
similarity index 62%
rename from src/monitor/stc-default-connection.c
rename to src/monitor/stc-connection.c
index 8c4b1ef..fb16297 100644 (file)
@@ -20,7 +20,7 @@
 #include "stc-monitor.h"
 #include "stc-firewall.h"
 #include "stc-manager-gdbus.h"
-#include "stc-default-connection.h"
+#include "stc-connection.h"
 
 /* connman service dbus details */
 #define CONNMAN_SERVICE                          "net.connman"
 
 #define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE     "db/telephony/dualsim/default_data_service"
 
-default_connection_s g_default_connection;
-guint g_default_connection_sub_id = 0;
+stc_connection_s *g_default_connection = NULL;
+GSList *g_connection_list = NULL;
+guint g_connection_sub_id = 0;
+
+static void __conn_list_free(gpointer value)
+{
+       stc_connection_s *conn = (stc_connection_s *)value;
+
+       FREE(conn->path);
+       FREE(conn->ifname);
+       FREE(conn->tether_iface.ifname);
+       FREE(conn);
+}
+
+static gint __conn_list_comp(gconstpointer a, gconstpointer b)
+{
+       stc_connection_s *conn = (stc_connection_s *)a;
+       char *path = (char *)b;
+
+       if (g_strcmp0(conn->path, path) == 0)
+               return 0;
+
+       return -1;
+}
+
+static void __update_monitor_by_conn(gpointer data, gpointer user_data)
+{
+       stc_connection_s *conn = (stc_connection_s *)data;
+
+       stc_monitor_update_by_connection(conn);
+}
 
 static int __telephony_get_current_sim(void)
 {
@@ -78,7 +107,7 @@ static int __telephony_get_current_sim(void)
        return current_sim;
 }
 
-static void __make_imsi_to_subscriber_id(char *imsi)
+static void __make_imsi_to_subscriber_id(stc_connection_s *conn, char *imsi)
 {
        int i = 0;
        SHA256_CTX ctx;
@@ -89,11 +118,11 @@ static void __make_imsi_to_subscriber_id(char *imsi)
        SHA256_Final(md, &ctx);
 
        for (i = 0; i < SHA256_DIGEST_LENGTH; ++i)
-               snprintf(g_default_connection.subscriber_id + (i * 2), 3, "%02x", md[i]);
+               snprintf(conn->subscriber_id + (i * 2), 3, "%02x", md[i]);
 }
 
 static void __telephony_get_modem_subscriber_id(GDBusConnection *connection,
-                                      const char *default_modem_name)
+                               stc_connection_s *conn, const char *default_modem_name)
 {
        GVariant *message = NULL;
        char tel_path[MAX_PATH_LENGTH];
@@ -130,14 +159,15 @@ static void __telephony_get_modem_subscriber_id(GDBusConnection *connection,
        }
 
        snprintf(imsi, IMSI_LENGTH, "%s%s", plmn, msin);
-       __make_imsi_to_subscriber_id(imsi);
+       __make_imsi_to_subscriber_id(conn, imsi);
 
 done:
        g_variant_unref(message);
        return;
 }
 
-static void __telephony_update_default_modem_subscriber_id(GDBusConnection *connection)
+static void __telephony_update_default_modem_subscriber_id(GDBusConnection *connection,
+                               stc_connection_s *conn)
 {
        GVariant *message = NULL;
        GVariantIter *iter = NULL;
@@ -173,7 +203,7 @@ static void __telephony_update_default_modem_subscriber_id(GDBusConnection *conn
                current_sim--; //LCOV_EXCL_LINE
        }
 
-       __telephony_get_modem_subscriber_id(connection, default_modem_name);
+       __telephony_get_modem_subscriber_id(connection, conn, default_modem_name);
 
        FREE(default_modem_name);
        g_variant_iter_free(iter);
@@ -181,38 +211,27 @@ static void __telephony_update_default_modem_subscriber_id(GDBusConnection *conn
        return;
 }
 
-static void __print_default_connection_info(void)
+static void __print_connection_info(stc_connection_s *conn)
 {
-       STC_LOGI("============= default connection info ============");
-       STC_LOGI("path    [%s]", g_default_connection.path);
-       STC_LOGI("type    [%d]", g_default_connection.type);
-       STC_LOGI("ifname  [%s]", g_default_connection.ifname);
-       STC_LOGI("roaming [%u]", g_default_connection.roaming ? TRUE : FALSE);
-       if (g_default_connection.type == STC_IFACE_DATACALL)
-               STC_LOGI("sub_id  [%s]", g_default_connection.subscriber_id);
+       STC_LOGI("============= connection info ============");
+       STC_LOGI("path    [%s]", conn->path);
+       STC_LOGI("type    [%d]", conn->type);
+       STC_LOGI("ifname  [%s]", conn->ifname);
+       STC_LOGI("roaming [%u]", conn->roaming ? TRUE : FALSE);
+       if (conn->type == STC_IFACE_DATACALL)
+               STC_LOGI("sub_id  [%s]", conn->subscriber_id);
        STC_LOGI("==================================================");
 }
 
 static void __print_tether_connection_info(void)
 {
        STC_LOGI("============= tethering connection info ============");
-       STC_LOGI("mode    [%u]", g_default_connection.tether_state ? TRUE : FALSE);
-       STC_LOGI("type    [%d]", g_default_connection.tether_iface.type);
-       STC_LOGI("ifname  [%s]", g_default_connection.tether_iface.ifname);
+       STC_LOGI("mode    [%u]", g_default_connection->tether_state ? TRUE : FALSE);
+       STC_LOGI("type    [%d]", g_default_connection->tether_iface.type);
+       STC_LOGI("ifname  [%s]", g_default_connection->tether_iface.ifname);
        STC_LOGI("====================================================");
 }
 
-static void __reset_default_connection_data(void)
-{
-       FREE(g_default_connection.path);
-       FREE(g_default_connection.ifname);
-       FREE(g_default_connection.tether_iface.ifname);
-       g_default_connection.type = STC_IFACE_UNKNOWN;
-       g_default_connection.roaming = FALSE;
-       g_default_connection.tether_iface.type = STC_IFACE_UNKNOWN;
-       g_default_connection.tether_state = FALSE;
-}
-
 static gboolean __is_cellular_internet_profile(const char *profile)
 {
        const char internet_suffix[] = "_1";
@@ -293,8 +312,8 @@ static gboolean __is_connected(GVariantIter *array)
        return is_connected;
 }
 
-static void __get_default_connection_info(GDBusConnection *connection,
-                                         const char *object_path)
+static void __get_connection_info(GDBusConnection *connection,
+                               stc_connection_s *conn, const char *object_path)
 {
        GVariant *message = NULL;
        GVariantIter *iter = NULL;
@@ -338,8 +357,7 @@ static void __get_default_connection_info(GDBusConnection *connection,
                                        const gchar *value =
                                                g_variant_get_string(variant1,
                                                                     NULL);
-                                       g_default_connection.ifname =
-                                               g_strdup(value);
+                                       conn->ifname = g_strdup(value);
                                }
                        }
 
@@ -351,7 +369,7 @@ static void __get_default_connection_info(GDBusConnection *connection,
                        if (g_variant_is_of_type(variant,
                                                 G_VARIANT_TYPE_BOOLEAN)) {
                                roaming = g_variant_get_boolean(variant);
-                               g_default_connection.roaming = roaming;
+                               conn->roaming = roaming;
                        }
                }
        }
@@ -366,12 +384,14 @@ done:
        return;
 }
 
-static stc_error_e __get_default_profile(GDBusConnection *connection)
+static stc_error_e __get_connected_profiles(GDBusConnection *connection)
 {
        GVariant *message = NULL;
        GVariantIter *iter = NULL;
        GVariantIter *next;
        gchar *object_path;
+       stc_connection_s *conn;
+       gboolean default_conn = TRUE;
 
        message = stc_manager_gdbus_call_sync(connection,
                                              CONNMAN_SERVICE,
@@ -383,6 +403,8 @@ static stc_error_e __get_default_profile(GDBusConnection *connection)
                return STC_ERROR_FAIL; //LCOV_EXCL_LINE
        }
 
+       g_slist_free_full(g_connection_list, __conn_list_free);
+
        g_variant_get(message, "(a(oa{sv}))", &iter);
        while (g_variant_iter_loop(iter, "(oa{sv})", &object_path, &next)) {
                if (object_path == NULL)
@@ -393,105 +415,144 @@ static stc_error_e __get_default_profile(GDBusConnection *connection)
                        continue;
 
                if (__is_connected(next) == TRUE) {
-                       /* reset old default connection data */
-                       FREE(g_default_connection.path);
-                       FREE(g_default_connection.ifname);
-                       g_default_connection.type = STC_IFACE_UNKNOWN;
-                       g_default_connection.roaming = FALSE;
+                       conn = MALLOC0(stc_connection_s, 1);
+                       if (conn == NULL)
+                               continue;
+
+                       conn->path = g_strdup(object_path);
+                       conn->roaming = FALSE;
+
+                       if (__is_cellular_profile(conn->path)) {
+                               conn->type = STC_IFACE_DATACALL;
+                               __telephony_update_default_modem_subscriber_id(connection, conn);
+                       } else if (__is_wifi_profile(conn->path)) {
+                               conn->type = STC_IFACE_WIFI;
+                       } else if (__is_ethernet_profile(conn->path)) {
+                               conn->type = STC_IFACE_WIRED;
+                       } else if (__is_bluetooth_profile(conn->path)) {
+                               conn->type = STC_IFACE_BLUETOOTH;
+                       } else {
+                               conn->type = STC_IFACE_UNKNOWN;
+                       }
+
+                       __get_connection_info(connection, conn, conn->path);
+                       __print_connection_info(conn);
+
+                       if (default_conn == TRUE) {
+                               g_default_connection = conn;
+                               default_conn = FALSE;
+                       }
+
+                       g_connection_list = g_slist_append(g_connection_list, conn);
 
-                       g_default_connection.path = g_strdup(object_path);
                        g_free(object_path);
                        g_variant_iter_free(next);
-                       break;
+                       continue;
                }
        }
 
        g_variant_iter_free(iter);
        g_variant_unref(message);
 
-       if (__is_cellular_profile(g_default_connection.path)) {
-               g_default_connection.type = STC_IFACE_DATACALL; //LCOV_EXCL_LINE
-               __telephony_update_default_modem_subscriber_id(connection); //LCOV_EXCL_LINE
-       } else if (__is_wifi_profile(g_default_connection.path)) {
-               g_default_connection.type = STC_IFACE_WIFI; //LCOV_EXCL_LINE
-       } else if (__is_ethernet_profile(g_default_connection.path)) {
-               g_default_connection.type = STC_IFACE_WIRED; //LCOV_EXCL_LINE
-       } else if (__is_bluetooth_profile(g_default_connection.path)) {
-               g_default_connection.type = STC_IFACE_BLUETOOTH; //LCOV_EXCL_LINE
-       } else {
-               g_default_connection.type = STC_IFACE_UNKNOWN; //LCOV_EXCL_LINE
-       }
-
-       __get_default_connection_info(connection, g_default_connection.path);
-
-       __print_default_connection_info();
-
-       stc_monitor_update_by_default_connection(&g_default_connection);
+       g_slist_foreach(g_connection_list, __update_monitor_by_conn, NULL);
        stc_firewall_update();
 
        return STC_ERROR_NONE;
 }
 
-static void _service_signal_cb(GDBusConnection *conn,
-                              const gchar *name, const gchar *path,
-                              const gchar *interface, const gchar *sig,
-                              GVariant *param, gpointer user_data)
+static stc_error_e __get_default_connection(GDBusConnection *connection)
 {
-       gchar *sigvalue = NULL;
-       GVariant *variant = NULL;
-       stc_s *stc = (stc_s *)stc_get_manager();
-       ret_msg_if(stc == NULL, "failed to get stc data");
+       GVariant *message = NULL;
+       GVariantIter *iter = NULL;
+       GVariantIter *next;
+       gchar *object_path;
 
-       if (path == NULL || param == NULL)
-               goto done;
+       message = stc_manager_gdbus_call_sync(connection,
+                                             CONNMAN_SERVICE,
+                                             CONNMAN_MANAGER_PATH,
+                                             CONNMAN_MANAGER_INTERFACE,
+                                             "GetServices", NULL);
+       if (message == NULL) {
+               STC_LOGE("Failed to get profiles"); //LCOV_EXCL_LINE
+               return STC_ERROR_FAIL; //LCOV_EXCL_LINE
+       }
 
-       g_variant_get(param, "(sv)", &sigvalue, &variant);
-       if (sigvalue == NULL)
-               goto done;
+       g_variant_get(message, "(a(oa{sv}))", &iter);
+       while (g_variant_iter_loop(iter, "(oa{sv})", &object_path, &next)) {
+               if (object_path == NULL)
+                       continue; //LCOV_EXCL_LINE
 
-       if (g_strcmp0(sig, CONNMAN_SIGNAL_PROPERTY_CHANGED) != 0)
-               goto done;
+               if (__is_cellular_profile(object_path) &&
+                   !__is_cellular_internet_profile(object_path))
+                       continue;
 
-       if (g_strcmp0(sigvalue, "State") == 0 &&
-           g_variant_is_of_type(variant, G_VARIANT_TYPE_STRING)) {
-               const gchar *state = NULL;
+               if (__is_connected(next) == TRUE) {
+                       GSList *comp = g_slist_find_custom(g_connection_list,
+                                                               object_path, __conn_list_comp);
+                       if (comp && comp->data)
+                               g_default_connection = comp->data;
 
-               state = g_variant_get_string(variant, NULL);
-               if (g_strcmp0(state, "ready") == 0 ||
-                   g_strcmp0(state, "online") == 0) {
-                       if (g_strcmp0(g_default_connection.path, path)) {
-                               __reset_default_connection_data();
-                               __get_default_profile(stc->connection);
-                       }
-               } else {
-                       if (g_strcmp0(g_default_connection.path, path) == 0) {
-                               __reset_default_connection_data(); //LCOV_EXCL_LINE
-                               __get_default_profile(stc->connection); //LCOV_EXCL_LINE
-                       }
+                       break;
                }
-       } else if (g_strcmp0(sigvalue, "Roaming") == 0) {
-               //LCOV_EXCL_START
-               if (g_strcmp0(g_default_connection.path, path) == 0) {
-                       gboolean roaming = 0;
+       }
 
-                       if (g_variant_is_of_type(variant,
-                                                G_VARIANT_TYPE_BOOLEAN)) {
-                               roaming = g_variant_get_boolean(variant);
-                               g_default_connection.roaming = roaming;
-                       }
-               }
-               //LCOV_EXCL_STOP
+       g_variant_iter_free(iter);
+       g_variant_unref(message);
+
+       return STC_ERROR_NONE;
+}
+
+static void __append_connected_profile(GDBusConnection *connection,
+                               const char *path)
+{
+       stc_connection_s *conn;
+
+       conn = MALLOC0(stc_connection_s, 1);
+       if (conn == NULL)
+               return;
+
+       conn->path = g_strdup(path);
+       conn->roaming = FALSE;
+
+       if (__is_cellular_profile(conn->path)) {
+               conn->type = STC_IFACE_DATACALL;
+               __telephony_update_default_modem_subscriber_id(connection, conn);
+       } else if (__is_wifi_profile(conn->path)) {
+               conn->type = STC_IFACE_WIFI;
+       } else if (__is_ethernet_profile(conn->path)) {
+               conn->type = STC_IFACE_WIRED;
+       } else if (__is_bluetooth_profile(conn->path)) {
+               conn->type = STC_IFACE_BLUETOOTH;
        } else {
-               ;//Do nothing
+               conn->type = STC_IFACE_UNKNOWN;
        }
-done:
-       if (sigvalue)
-               g_free(sigvalue);
 
-       if (variant)
-               g_variant_unref(variant);
+       __get_connection_info(connection, conn, conn->path);
+       __print_connection_info(conn);
 
-       return;
+       g_connection_list = g_slist_append(g_connection_list, conn);
+
+       stc_monitor_add_by_connection(conn);
+       stc_firewall_update();
+
+       __get_default_connection(connection);
+}
+
+static void __remove_disconnected_profile(GDBusConnection *connection,
+                               stc_connection_s *conn)
+{
+       __print_connection_info(conn);
+
+       stc_monitor_remove_by_connection(conn);
+
+       g_connection_list = g_slist_remove(g_connection_list, conn);
+
+       __get_default_connection(connection);
+
+       FREE(conn->path);
+       FREE(conn->ifname);
+       FREE(conn->tether_iface.ifname);
+       FREE(conn);
 }
 
 static void __vconf_key_callback(keynode_t *node, void *user_data)
@@ -503,6 +564,9 @@ static void __vconf_key_callback(keynode_t *node, void *user_data)
                return;
        }
 
+       if (g_default_connection == NULL)
+               return;
+
        if (vconf_keynode_get_type(node) != VCONF_TYPE_INT) {
                STC_LOGE("Invalid vconf key type");
                return;
@@ -514,31 +578,31 @@ static void __vconf_key_callback(keynode_t *node, void *user_data)
        switch (vconf_key) {
        case VCONFKEY_MOBILE_HOTSPOT_MODE_USB:
                STC_LOGI("Hotspot mode USB type !");
-               g_default_connection.tether_state = TRUE;
-               g_default_connection.tether_iface.ifname = g_strdup(TETHERING_USB_IF);
-               g_default_connection.tether_iface.type = STC_IFACE_USB;
+               g_default_connection->tether_state = TRUE;
+               g_default_connection->tether_iface.ifname = g_strdup(TETHERING_USB_IF);
+               g_default_connection->tether_iface.type = STC_IFACE_USB;
                break;
        case VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI:
                STC_LOGI("Hotspot mode Wi-Fi type !");
-               g_default_connection.tether_state = TRUE;
-               g_default_connection.tether_iface.ifname = g_strdup(TETHERING_WIFI_IF);
-               g_default_connection.tether_iface.type = STC_IFACE_WIFI;
+               g_default_connection->tether_state = TRUE;
+               g_default_connection->tether_iface.ifname = g_strdup(TETHERING_WIFI_IF);
+               g_default_connection->tether_iface.type = STC_IFACE_WIFI;
                break;
        case VCONFKEY_MOBILE_HOTSPOT_MODE_BT:
                STC_LOGI("Hotspot mode Bluetooth type !");
-               g_default_connection.tether_state = TRUE;
-               g_default_connection.tether_iface.ifname = g_strdup(TETHERING_BT_IF);
-               g_default_connection.tether_iface.type = STC_IFACE_BLUETOOTH;
+               g_default_connection->tether_state = TRUE;
+               g_default_connection->tether_iface.ifname = g_strdup(TETHERING_BT_IF);
+               g_default_connection->tether_iface.type = STC_IFACE_BLUETOOTH;
                break;
        case VCONFKEY_MOBILE_HOTSPOT_MODE_P2P:
                STC_LOGI("Hotspot mode P2P type !");
-               g_default_connection.tether_state = TRUE;
-               g_default_connection.tether_iface.ifname = g_strdup(TETHERING_P2P_IF);
-               g_default_connection.tether_iface.type = STC_IFACE_P2P;
+               g_default_connection->tether_state = TRUE;
+               g_default_connection->tether_iface.ifname = g_strdup(TETHERING_P2P_IF);
+               g_default_connection->tether_iface.type = STC_IFACE_P2P;
                break;
        case VCONFKEY_MOBILE_HOTSPOT_MODE_NONE:
                STC_LOGI("Hotspot mode none");
-               g_default_connection.tether_state = FALSE;
+               g_default_connection->tether_state = FALSE;
                break;
        default:
                STC_LOGE("Unknown Hotspot mode type !");
@@ -546,32 +610,98 @@ static void __vconf_key_callback(keynode_t *node, void *user_data)
        }
 
        /* add monitoring for tethering if active found */
-       if (g_default_connection.tether_state == TRUE && g_default_connection.tether_iface.ifname) {
+       if (g_default_connection->tether_state == TRUE && g_default_connection->tether_iface.ifname) {
                __print_tether_connection_info();
-               stc_monitor_update_by_default_connection(&g_default_connection);
+               stc_monitor_update_by_connection(&g_default_connection);
                stc_firewall_update();
                STC_LOGI("Data monitoring started for tethering iface !");
                return;
        }
 
        /* remove monitoring for tethering if in-active found */
-       if (g_default_connection.tether_state == FALSE && g_default_connection.tether_iface.ifname) {
-               stc_monitor_update_by_default_connection(&g_default_connection);
-               g_free(g_default_connection.tether_iface.ifname);
-               g_default_connection.tether_iface.ifname = NULL;
-               g_default_connection.tether_iface.type = STC_IFACE_UNKNOWN;
+       if (g_default_connection->tether_state == FALSE && g_default_connection->tether_iface.ifname) {
+               stc_monitor_update_by_connection(&g_default_connection);
+               g_free(g_default_connection->tether_iface.ifname);
+               g_default_connection->tether_iface.ifname = NULL;
+               g_default_connection->tether_iface.type = STC_IFACE_UNKNOWN;
                STC_LOGI("Data monitoring stopped for tethering iface !");
                return;
        }
 }
 
-stc_error_e stc_default_connection_monitor_init(stc_s *stc)
+static void _service_signal_cb(GDBusConnection *connection,
+                              const gchar *name, const gchar *path,
+                              const gchar *interface, const gchar *sig,
+                              GVariant *param, gpointer user_data)
+{
+       gchar *sigvalue = NULL;
+       GVariant *variant = NULL;
+       stc_s *stc = (stc_s *)stc_get_manager();
+       ret_msg_if(stc == NULL, "failed to get stc data");
+
+       if (path == NULL || param == NULL)
+               goto done;
+
+       g_variant_get(param, "(sv)", &sigvalue, &variant);
+       if (sigvalue == NULL)
+               goto done;
+
+       if (g_strcmp0(sig, CONNMAN_SIGNAL_PROPERTY_CHANGED) != 0)
+               goto done;
+
+       if (g_strcmp0(sigvalue, "State") == 0 &&
+           g_variant_is_of_type(variant, G_VARIANT_TYPE_STRING)) {
+               const gchar *state = NULL;
+
+               state = g_variant_get_string(variant, NULL);
+               if (g_strcmp0(state, "ready") == 0 ||
+                   g_strcmp0(state, "online") == 0) {
+                       GSList *comp = g_slist_find_custom(g_connection_list,
+                                                               path, __conn_list_comp);
+                       if (!comp)
+                               __append_connected_profile(stc->connection, path);
+               } else if (g_strcmp0(state, "idle") == 0 ||
+                       g_strcmp0(state, "disconnect") == 0) {
+                       GSList *comp = g_slist_find_custom(g_connection_list,
+                                                               path, __conn_list_comp);
+                       if (comp && comp->data)
+                               __remove_disconnected_profile(stc->connection, comp->data);
+               }
+       } else if (g_strcmp0(sigvalue, "Roaming") == 0) {
+               //LCOV_EXCL_START
+               GSList *comp = g_slist_find_custom(g_connection_list,
+                                                       path, __conn_list_comp);
+
+               if (comp) {
+                       stc_connection_s *conn = comp->data;
+                       gboolean roaming = 0;
+
+                       if (g_variant_is_of_type(variant, G_VARIANT_TYPE_BOOLEAN)) {
+                               roaming = g_variant_get_boolean(variant);
+                               conn->roaming = roaming;
+                       }
+               }
+               //LCOV_EXCL_STOP
+       } else {
+               ;//Do nothing
+       }
+done:
+       if (sigvalue)
+               g_free(sigvalue);
+
+       if (variant)
+               g_variant_unref(variant);
+
+       return;
+}
+
+stc_error_e stc_connection_monitor_init(stc_s *stc)
 {
        int ret;
        ret_value_msg_if(stc == NULL, STC_ERROR_INVALID_PARAMETER, "failed to get stc data");
 
-       __get_default_profile(stc->connection);
-       g_default_connection_sub_id =
+       __get_connected_profiles(stc->connection);
+       g_connection_sub_id =
                stc_manager_gdbus_subscribe_signal(stc->connection,
                                                   CONNMAN_SERVICE,
                                                   CONNMAN_SERVICE_INTERFACE,
@@ -589,23 +719,19 @@ stc_error_e stc_default_connection_monitor_init(stc_s *stc)
        return STC_ERROR_NONE;
 }
 
-stc_error_e stc_default_connection_monitor_deinit(stc_s *stc)
+stc_error_e stc_connection_monitor_deinit(stc_s *stc)
 {
        ret_value_msg_if(stc == NULL, STC_ERROR_INVALID_PARAMETER, "failed to get stc data");
 
        stc_manager_gdbus_unsubscribe_signal(stc->connection,
-                                            g_default_connection_sub_id);
-       FREE(g_default_connection.path);
-       FREE(g_default_connection.ifname);
-       return STC_ERROR_NONE;
-}
+                                            g_connection_sub_id);
 
-gchar *stc_default_connection_get_ifname(void)
-{
-       return g_strdup(g_default_connection.ifname);
+       g_slist_free_full(g_connection_list, __conn_list_free);
+
+       return STC_ERROR_NONE;
 }
 
-default_connection_s *stc_get_default_connection(void)
+GSList *stc_get_connection_list(void)
 {
-       return &g_default_connection;
+       return g_connection_list;
 }
index 16f0f72..6441593 100644 (file)
@@ -46,74 +46,77 @@ static void __app_update_statistics(gpointer key,
 {
        stc_app_value_s *app_value = (stc_app_value_s *)value;
        time_t *touch_time = (time_t *)data;
-       stc_db_classid_iftype_key stat_key;
-       stc_db_app_stats stat;
-       default_connection_s *default_connection = stc_get_default_connection();
-
-       memset(&stat_key, 0, sizeof(stc_db_classid_iftype_key));
-       memset(&stat, 0 , sizeof(stc_db_app_stats));
-
-       /* Do not update statistics for Tethering
-        * if tethering is in-active found */
-       if (default_connection &&
-               default_connection->tether_state == FALSE &&
-               !strcmp(app_value->app_id, STC_TOTAL_TETHERING))
-               return;
+       GSList *conn_list = stc_get_connection_list();
 
-       /* Do not update statistics for Wi-Fi
-        * if tethering is active on wlan0 iface */
-       if (default_connection && default_connection->tether_state &&
-               default_connection->tether_iface.type == STC_IFACE_WIFI &&
-               !strcmp(app_value->app_id, STC_TOTAL_WIFI))
-               return;
+       for (; conn_list != NULL; conn_list = conn_list->next) {
+               stc_connection_s *conn = conn_list->data;
+               stc_db_classid_iftype_key stat_key;
+               stc_db_app_stats stat;
+
+               memset(&stat_key, 0, sizeof(stc_db_classid_iftype_key));
+               memset(&stat, 0 , sizeof(stc_db_app_stats));
+
+               /* Do not update statistics for Tethering
+                * if tethering is in-active found */
+               if (conn && conn->tether_state == FALSE &&
+                       !strcmp(app_value->app_id, STC_TOTAL_TETHERING))
+                       return;
+
+               /* Do not update statistics for Wi-Fi
+                * if tethering is active on wlan0 iface */
+               if (conn && conn->tether_state &&
+                       conn->tether_iface.type == STC_IFACE_WIFI &&
+                       !strcmp(app_value->app_id, STC_TOTAL_WIFI))
+                       return;
+
+               stat_key.classid = app_value->classid;
 
-       stat_key.classid = app_value->classid;
-
-       if (app_value->classid == STC_TETHERING_APP_CLASSID &&
-               default_connection->tether_state == TRUE)
-               stat_key.iftype = default_connection->tether_iface.type;
-       else if (g_str_has_suffix(app_value->app_id, STC_TETHERING_APP_SUFFIX))
-               stat_key.iftype = default_connection->tether_iface.type;
-       else
-               stat_key.iftype = default_connection->type;
-
-       if (STC_IFACE_DATACALL == stat_key.iftype)
-               stat_key.subscriber_id = g_strdup(default_connection->subscriber_id);
-       else
-               stat_key.subscriber_id = g_strdup(SUBSCRIBERID_NONE);
-
-       if (app_value->classid == STC_TETHERING_APP_CLASSID &&
-               default_connection->tether_state == TRUE)
-               g_strlcpy(stat_key.ifname, default_connection->tether_iface.ifname,
-                         MAX_IFACE_LENGTH);
-       else if (g_str_has_suffix(app_value->app_id, STC_TETHERING_APP_SUFFIX))
-               g_strlcpy(stat_key.ifname, default_connection->tether_iface.ifname,
-                         MAX_IFACE_LENGTH);
-       else
-               g_strlcpy(stat_key.ifname, default_connection->ifname,
-                         MAX_IFACE_LENGTH);
-
-       stat.app_id = g_strdup(app_value->app_id);
-       stat.snd_count = app_value->counter.out_bytes;
-       stat.rcv_count = app_value->counter.in_bytes;
-       stat.is_roaming = default_connection->roaming;
-
-       if (strstr(stat.app_id, "_BACKGROUND")) {
-               stat.ground = STC_APP_STATE_BACKGROUND;
-       } else {
-               if (strstr(stat.app_id, "TOTAL_"))
-                       stat.ground = STC_APP_STATE_UNKNOWN;
+               if (app_value->classid == STC_TETHERING_APP_CLASSID &&
+                       conn->tether_state == TRUE)
+                       stat_key.iftype = conn->tether_iface.type;
+               else if (g_str_has_suffix(app_value->app_id, STC_TETHERING_APP_SUFFIX))
+                       stat_key.iftype = conn->tether_iface.type;
                else
-                       stat.ground = STC_APP_STATE_FOREGROUND;
-       }
+                       stat_key.iftype = conn->type;
+
+               if (STC_IFACE_DATACALL == stat_key.iftype)
+                       stat_key.subscriber_id = g_strdup(conn->subscriber_id);
+               else
+                       stat_key.subscriber_id = g_strdup(SUBSCRIBERID_NONE);
+
+               if (app_value->classid == STC_TETHERING_APP_CLASSID &&
+                       conn->tether_state == TRUE)
+                       g_strlcpy(stat_key.ifname, conn->tether_iface.ifname,
+                                 MAX_IFACE_LENGTH);
+               else if (g_str_has_suffix(app_value->app_id, STC_TETHERING_APP_SUFFIX))
+                       g_strlcpy(stat_key.ifname, conn->tether_iface.ifname,
+                                 MAX_IFACE_LENGTH);
+               else
+                       g_strlcpy(stat_key.ifname, conn->ifname,
+                                 MAX_IFACE_LENGTH);
 
-       table_statistics_insert(&stat_key, &stat, *touch_time);
+               stat.app_id = g_strdup(app_value->app_id);
+               stat.snd_count = app_value->counter.out_bytes;
+               stat.rcv_count = app_value->counter.in_bytes;
+               stat.is_roaming = conn->roaming;
+
+               if (strstr(stat.app_id, "_BACKGROUND")) {
+                       stat.ground = STC_APP_STATE_BACKGROUND;
+               } else {
+                       if (strstr(stat.app_id, "TOTAL_"))
+                               stat.ground = STC_APP_STATE_UNKNOWN;
+                       else
+                               stat.ground = STC_APP_STATE_FOREGROUND;
+               }
 
-       app_value->counter.out_bytes = 0;
-       app_value->counter.in_bytes = 0;
+               table_statistics_insert(&stat_key, &stat, *touch_time);
 
-       FREE(stat.app_id);
-       FREE(stat_key.subscriber_id);
+               app_value->counter.out_bytes = 0;
+               app_value->counter.in_bytes = 0;
+
+               FREE(stat.app_id);
+               FREE(stat_key.subscriber_id);
+       }
 
        return;
 }
@@ -122,7 +125,7 @@ static gboolean __add_app_monitor_for_tethering(gpointer key,
                                    gpointer value, gpointer data)
 {
        stc_app_value_s *app_value = (stc_app_value_s *)value;
-       default_connection_s *connection = (default_connection_s *)data;
+       stc_connection_s *connection = (stc_connection_s *)data;
        stc_s *stc = stc_get_manager();
        struct nfacct_rule counter;
        char *ipaddr = NULL;
@@ -172,7 +175,7 @@ static gboolean __remove_app_monitor_for_tethering(gpointer key,
                                gpointer value, gpointer data)
 {
        stc_app_value_s *app_value = (stc_app_value_s *)value;
-       default_connection_s *connection = (default_connection_s *)data;
+       stc_connection_s *connection = (stc_connection_s *)data;
        stc_s *stc = stc_get_manager();
        struct nfacct_rule counter;
        char *ipaddr = NULL;
@@ -347,6 +350,7 @@ API stc_error_e stc_monitor_app_add(uint32_t classid,
        stc_app_value_s *lookup_value;
 
        GHashTable *apps = stc_monitor_get_system_apps();
+       GSList *conn_list = stc_get_connection_list();
 
        if (!apps)
                return STC_ERROR_NO_DATA;
@@ -391,13 +395,16 @@ API stc_error_e stc_monitor_app_add(uint32_t classid,
 
        g_hash_table_insert(apps, GUINT_TO_POINTER(classid), app_value);
 
-       /* add nfacct rule for this classid */
-       stc_monitor_app_add_monitor(GUINT_TO_POINTER(classid),
-                               app_value, stc_get_default_connection());
+       for (; conn_list != NULL; conn_list = conn_list->next) {
+               stc_connection_s *conn = conn_list->data;
+               /* add nfacct rule for this classid */
+               stc_monitor_app_add_monitor(GUINT_TO_POINTER(classid),
+                                       app_value, conn);
 
-       if (app_value->state == STC_APP_STATE_FOREGROUND)
-               stc_monitor_app_add_accept(GUINT_TO_POINTER(classid),
-                               app_value, stc_get_default_connection());
+               if (app_value->state == STC_APP_STATE_FOREGROUND)
+                       stc_monitor_app_add_accept(GUINT_TO_POINTER(classid),
+                                       app_value, conn);
+       }
 
        stc_monitor_rstn_add_for_app(classid);
 
@@ -431,7 +438,7 @@ void stc_monitor_app_add_monitor(gpointer key,
                                gpointer value, gpointer data)
 {
        stc_app_value_s *app_value = (stc_app_value_s *)value;
-       default_connection_s *connection = (default_connection_s *)data;
+       stc_connection_s *connection = (stc_connection_s *)data;
        stc_s *stc = stc_get_manager();
 
        if (app_value->classid == STC_TOTAL_DATACALL_CLASSID ||
@@ -485,7 +492,7 @@ void stc_monitor_app_add_monitor(gpointer key,
        }
 }
 
-void stc_monitor_app_add_by_connection(default_connection_s *conn)
+void stc_monitor_app_add_by_connection(stc_connection_s *conn)
 {
        GHashTable *apps = stc_monitor_get_system_apps();
 
@@ -493,13 +500,14 @@ void stc_monitor_app_add_by_connection(default_connection_s *conn)
                return;
 
        g_hash_table_foreach(apps, stc_monitor_app_add_monitor, conn);
+       g_hash_table_foreach(apps, stc_monitor_app_add_accept, conn);
 }
 
 void stc_monitor_app_add_accept(gpointer key,
                                gpointer value, gpointer data)
 {
        stc_app_value_s *app_value = (stc_app_value_s *)value;
-       default_connection_s *connection = (default_connection_s *)data;
+       stc_connection_s *connection = (stc_connection_s *)data;
        stc_s *stc = stc_get_manager();
 
        if (app_value->classid == STC_TOTAL_DATACALL_CLASSID ||
@@ -507,6 +515,9 @@ void stc_monitor_app_add_accept(gpointer key,
            app_value->classid == STC_TOTAL_BLUETOOTH_CLASSID)
                return;
 
+       if (app_value->state != STC_APP_STATE_FOREGROUND)
+               return;
+
        if (stc && connection && connection->ifname) {
                struct nfacct_rule counter;
 
@@ -547,6 +558,7 @@ API stc_error_e stc_monitor_app_remove(uint32_t classid, const char *app_id)
 {
        stc_app_value_s *app_lookup;
        GHashTable *apps = stc_monitor_get_system_apps();
+       GSList *conn_list = stc_get_connection_list();
 
        if (!apps)
                return STC_ERROR_NO_DATA;
@@ -560,9 +572,16 @@ API stc_error_e stc_monitor_app_remove(uint32_t classid, const char *app_id)
                return STC_ERROR_FAIL;
        }
 
-       /* remove nfacct rule for this classid */
-       stc_monitor_app_remove_monitor(GUINT_TO_POINTER(classid),
-                               app_lookup, stc_get_default_connection());
+       for (; conn_list != NULL; conn_list = conn_list->next) {
+               stc_connection_s *conn = conn_list->data;
+               /* remove nfacct rule for this classid */
+               stc_monitor_app_remove_monitor(GUINT_TO_POINTER(classid),
+                                       app_lookup, conn);
+
+               if (app_lookup->state == STC_APP_STATE_FOREGROUND)
+                       stc_monitor_app_remove_accept(GUINT_TO_POINTER(classid),
+                                               app_lookup, conn);
+       }
 
        /* remove ristrictions if any */
        stc_monitor_rstn_remove_for_app(classid);
@@ -580,7 +599,7 @@ void stc_monitor_app_remove_monitor(gpointer key,
                                gpointer value, gpointer data)
 {
        stc_app_value_s *app_value = (stc_app_value_s *)value;
-       default_connection_s *connection = (default_connection_s *)data;
+       stc_connection_s *connection = (stc_connection_s *)data;
        stc_s *stc = stc_get_manager();
 
        if (stc && connection && connection->ifname) {
@@ -632,7 +651,7 @@ void stc_monitor_app_remove_monitor(gpointer key,
        return;
 }
 
-void stc_monitor_app_remove_by_connection(default_connection_s *conn)
+void stc_monitor_app_remove_by_connection(stc_connection_s *conn)
 {
        GHashTable *apps = stc_monitor_get_system_apps();
 
@@ -640,15 +659,24 @@ void stc_monitor_app_remove_by_connection(default_connection_s *conn)
                return;
 
        g_hash_table_foreach(apps, stc_monitor_app_remove_monitor, conn);
+       g_hash_table_foreach(apps, stc_monitor_app_remove_accept, conn);
 }
 
 void stc_monitor_app_remove_accept(gpointer key,
                                gpointer value, gpointer data)
 {
        stc_app_value_s *app_value = (stc_app_value_s *)value;
-       default_connection_s *connection = (default_connection_s *)data;
+       stc_connection_s *connection = (stc_connection_s *)data;
        stc_s *stc = stc_get_manager();
 
+       if (app_value->classid == STC_TOTAL_DATACALL_CLASSID ||
+           app_value->classid == STC_TOTAL_WIFI_CLASSID ||
+           app_value->classid == STC_TOTAL_BLUETOOTH_CLASSID)
+               return;
+
+       if (app_value->state != STC_APP_STATE_FOREGROUND)
+               return;
+
        if (stc && connection && connection->ifname) {
                struct nfacct_rule counter;
 
index 8b9dfdd..e472421 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "stc-monitor.h"
 #include "stc-monitor-proc.h"
-#include "stc-default-connection.h"
+#include "stc-connection.h"
 #include "helper-net-cls.h"
 
 static void __print_proc(gpointer key, gpointer value,
@@ -176,6 +176,7 @@ API stc_error_e stc_monitor_proc_remove(uint32_t classid,
        stc_app_value_s *app_lookup = NULL;
        guint pid_count = 0;
        GHashTable *apps = stc_monitor_get_system_apps();
+       GSList *conn_list = stc_get_connection_list();
        remove_pid_context_s context = {
                .pid = pid,
                .app_value = NULL,
@@ -219,13 +220,16 @@ API stc_error_e stc_monitor_proc_remove(uint32_t classid,
        pid_count = g_hash_table_size(app_lookup->processes);
 
        if (!pid_count) {
-               /* remove nfacct rule for this classid */
-               stc_monitor_app_remove_monitor(GUINT_TO_POINTER(classid),
-                                       app_lookup, stc_get_default_connection());
-
-               if (app_lookup->state == STC_APP_STATE_FOREGROUND)
-                       stc_monitor_app_remove_accept(GUINT_TO_POINTER(classid),
-                                       app_lookup, stc_get_default_connection());
+               for (; conn_list != NULL; conn_list = conn_list->next) {
+                       stc_connection_s *conn = conn_list->data;
+                       /* remove nfacct rule for this classid */
+                       stc_monitor_app_remove_monitor(GUINT_TO_POINTER(classid),
+                                               app_lookup, conn);
+
+                       if (app_lookup->state == STC_APP_STATE_FOREGROUND)
+                               stc_monitor_app_remove_accept(GUINT_TO_POINTER(classid),
+                                               app_lookup, conn);
+               }
 
                stc_monitor_rstn_remove_for_app(classid);
 
@@ -245,6 +249,7 @@ API stc_error_e stc_monitor_proc_move(uint32_t from,
        stc_error_e ret = STC_ERROR_NONE;
        stc_app_value_s *from_lookup = NULL;
        stc_app_value_s *to_lookup = NULL;
+       GSList *conn_list = stc_get_connection_list();
        GHashTable *apps = stc_monitor_get_system_apps();
 
        if (!apps)
@@ -284,12 +289,15 @@ API stc_error_e stc_monitor_proc_move(uint32_t from,
                                "[\033[1;36m%d\033[0;m]", from);
                }
 
-               stc_monitor_app_remove_monitor(GUINT_TO_POINTER(from),
-                                       from_lookup, stc_get_default_connection());
+               for (; conn_list != NULL; conn_list = conn_list->next) {
+                       stc_connection_s *conn = conn_list->data;
+                       stc_monitor_app_remove_monitor(GUINT_TO_POINTER(from),
+                                               from_lookup, conn);
 
-               if (from_lookup->state == STC_APP_STATE_FOREGROUND)
-                       stc_monitor_app_remove_accept(GUINT_TO_POINTER(from),
-                                       from_lookup, stc_get_default_connection());
+                       if (from_lookup->state == STC_APP_STATE_FOREGROUND)
+                               stc_monitor_app_remove_accept(GUINT_TO_POINTER(from),
+                                               from_lookup, conn);
+               }
 
                stc_monitor_rstn_remove_for_app(from);
 
index d717326..ce3fa63 100644 (file)
@@ -104,7 +104,7 @@ static stc_cb_ret_e __statistics_info_cb(const table_statistics_info *info,
 static void __rstn_add_tether_rule(int64_t classid, gchar *mac,
                nfacct_rule_intend intend, stc_iface_type_e iftype)
 {
-       default_connection_s *connection = stc_get_default_connection();
+       GSList *conn_list = stc_get_connection_list();
        struct nfacct_rule counter;
        stc_s *stc = stc_get_manager();
        char *ipaddr = NULL;
@@ -113,42 +113,46 @@ static void __rstn_add_tether_rule(int64_t classid, gchar *mac,
        if (!stc || !mac)
                return;
 
-       if (!stc->carg) {
-               stc->carg = MALLOC0(counter_arg_s, 1);
-               if (stc->carg == NULL)
-                       return;
+       for (; conn_list != NULL; conn_list = conn_list->next) {
+               stc_connection_s *conn = conn_list->data;
 
-               stc->carg->sock = stc_monitor_get_contr_sock();
-       }
+               if (!stc->carg) {
+                       stc->carg = MALLOC0(counter_arg_s, 1);
+                       if (stc->carg == NULL)
+                               return;
 
-       memset(&counter, 0, sizeof(struct nfacct_rule));
+                       stc->carg->sock = stc_monitor_get_contr_sock();
+               }
 
-       counter.carg = stc->carg;
-       counter.classid = classid;
-       counter.intend = intend;
+               memset(&counter, 0, sizeof(struct nfacct_rule));
 
-       if (connection->tether_state != TRUE ||
-               connection->tether_iface.ifname == NULL)
-       return;
+               counter.carg = stc->carg;
+               counter.classid = classid;
+               counter.intend = intend;
 
-       counter.iftype = connection->tether_iface.type;
-       g_strlcpy(counter.ifname, connection->tether_iface.ifname, MAX_IFACE_LENGTH);
+               if (conn->tether_state != TRUE ||
+                       conn->tether_iface.ifname == NULL)
+                       return;
 
-       /* get connected station ip based on its mac */
-       ret = stc_plugin_tether_get_station_ip(mac, &ipaddr);
-       if (ret != STC_ERROR_NONE)
-               return;
+               counter.iftype = conn->tether_iface.type;
+               g_strlcpy(counter.ifname, conn->tether_iface.ifname, MAX_IFACE_LENGTH);
 
-       /* tethering iptables rule */
-       stc_monitor_tether_add_in(&counter, ipaddr);
-       stc_monitor_tether_add_out(&counter, ipaddr);
-       g_free(ipaddr);
+               /* get connected station ip based on its mac */
+               ret = stc_plugin_tether_get_station_ip(mac, &ipaddr);
+               if (ret != STC_ERROR_NONE)
+                       return;
+
+               /* tethering iptables rule */
+               stc_monitor_tether_add_in(&counter, ipaddr);
+               stc_monitor_tether_add_out(&counter, ipaddr);
+               g_free(ipaddr);
+       }
 }
 
 static void __rstn_del_tether_rule(int64_t classid, gchar *mac,
                nfacct_rule_intend intend, stc_iface_type_e iftype)
 {
-       default_connection_s *connection = stc_get_default_connection();
+       GSList *conn_list = stc_get_connection_list();
        struct nfacct_rule counter;
        stc_s *stc = stc_get_manager();
        char *ipaddr = NULL;
@@ -157,134 +161,134 @@ static void __rstn_del_tether_rule(int64_t classid, gchar *mac,
        if (!stc || !mac)
                return;
 
-       if (!stc->carg) {
-               stc->carg = MALLOC0(counter_arg_s, 1);
-               if (stc->carg == NULL)
-                       return;
+       for (; conn_list != NULL; conn_list = conn_list->next) {
+               stc_connection_s *conn = conn_list->data;
 
-               stc->carg->sock = stc_monitor_get_contr_sock();
-       }
+               if (!stc->carg) {
+                       stc->carg = MALLOC0(counter_arg_s, 1);
+                       if (stc->carg == NULL)
+                               return;
 
-       memset(&counter, 0, sizeof(struct nfacct_rule));
+                       stc->carg->sock = stc_monitor_get_contr_sock();
+               }
 
-       counter.carg = stc->carg;
-       counter.classid = classid;
-       counter.intend = intend;
+               memset(&counter, 0, sizeof(struct nfacct_rule));
 
-       if (connection->tether_state != TRUE ||
-               connection->tether_iface.ifname == NULL)
-       return;
+               counter.carg = stc->carg;
+               counter.classid = classid;
+               counter.intend = intend;
 
-       counter.iftype = connection->tether_iface.type;
-       g_strlcpy(counter.ifname, connection->tether_iface.ifname, MAX_IFACE_LENGTH);
+               if (conn->tether_state != TRUE ||
+                       conn->tether_iface.ifname == NULL)
+                       return;
 
-       /* get connected station ip based on its mac */
-       ret = stc_plugin_tether_get_station_ip(mac, &ipaddr);
-       if (ret != STC_ERROR_NONE) {
-               STC_LOGE("Error: no IP found for station mac(%s)", mac);
-               return;
-       }
+               counter.iftype = conn->tether_iface.type;
+               g_strlcpy(counter.ifname, conn->tether_iface.ifname, MAX_IFACE_LENGTH);
+
+               /* get connected station ip based on its mac */
+               ret = stc_plugin_tether_get_station_ip(mac, &ipaddr);
+               if (ret != STC_ERROR_NONE) {
+                       STC_LOGE("Error: no IP found for station mac(%s)", mac);
+                       return;
+               }
 
-       /* tethering iptables rule */
-       stc_monitor_tether_del_in(&counter, ipaddr);
-       stc_monitor_tether_del_out(&counter, ipaddr);
-       g_free(ipaddr);
+               /* tethering iptables rule */
+               stc_monitor_tether_del_in(&counter, ipaddr);
+               stc_monitor_tether_del_out(&counter, ipaddr);
+               g_free(ipaddr);
+       }
 }
 
 static void __rstn_add_ipt_rule(int64_t classid, nfacct_rule_intend intend,
                                stc_iface_type_e iftype)
 {
-       char *default_ifname = stc_default_connection_get_ifname();
-       default_connection_s *connection = stc_get_default_connection();
+       GSList *conn_list = stc_get_connection_list();
        struct nfacct_rule counter;
        stc_s *stc = stc_get_manager();
-       if (!stc) {
-               g_free(default_ifname);
+
+       if (!stc)
                return;
-       }
 
-       if (!stc->carg) {
-               stc->carg = MALLOC0(counter_arg_s, 1);
-               if (stc->carg == NULL) {
-                       g_free(default_ifname);
-                       return;
-               }
+       for (; conn_list != NULL; conn_list = conn_list->next) {
+               stc_connection_s *conn = conn_list->data;
 
-               stc->carg->sock = stc_monitor_get_contr_sock();
-       }
+               if (!stc->carg) {
+                       stc->carg = MALLOC0(counter_arg_s, 1);
+                       if (stc->carg == NULL)
+                               return;
 
-       memset(&counter, 0, sizeof(struct nfacct_rule));
+                       stc->carg->sock = stc_monitor_get_contr_sock();
+               }
 
-       counter.carg = stc->carg;
-       counter.classid = classid;
-       counter.intend = intend;
+               memset(&counter, 0, sizeof(struct nfacct_rule));
 
-       if (connection && connection->tether_iface.ifname != NULL &&
-               classid == STC_TETHERING_APP_CLASSID) {
-               counter.iftype = connection->tether_iface.type;
-               g_strlcpy(counter.ifname, connection->tether_iface.ifname, MAX_IFACE_LENGTH);
-       } else {
-               counter.iftype = iftype;
-               g_strlcpy(counter.ifname, default_ifname, MAX_IFACE_LENGTH);
-       }
+               counter.carg = stc->carg;
+               counter.classid = classid;
+               counter.intend = intend;
 
-       g_free(default_ifname);
+               if (conn && conn->tether_iface.ifname != NULL &&
+                       classid == STC_TETHERING_APP_CLASSID) {
+                       counter.iftype = conn->tether_iface.type;
+                       g_strlcpy(counter.ifname, conn->tether_iface.ifname, MAX_IFACE_LENGTH);
+               } else {
+                       counter.iftype = iftype;
+                       g_strlcpy(counter.ifname, conn->ifname, MAX_IFACE_LENGTH);
+               }
 
-       /* iptables rule */
-       stc_monitor_ipt_add_in(&counter);
-       stc_monitor_ipt_add_out(&counter);
+               /* iptables rule */
+               stc_monitor_ipt_add_in(&counter);
+               stc_monitor_ipt_add_out(&counter);
 
-       /* ip6tables rule */
-       stc_monitor_ip6t_add_in(&counter);
-       stc_monitor_ip6t_add_out(&counter);
+               /* ip6tables rule */
+               stc_monitor_ip6t_add_in(&counter);
+               stc_monitor_ip6t_add_out(&counter);
+       }
 }
 
 static void __rstn_del_ipt_rule(int64_t classid, nfacct_rule_intend intend,
                                stc_iface_type_e iftype)
 {
-       char *default_ifname = stc_default_connection_get_ifname();
-       default_connection_s *connection = stc_get_default_connection();
+       GSList *conn_list = stc_get_connection_list();
        struct nfacct_rule counter;
        stc_s *stc = stc_get_manager();
-       if (!stc) {
-               g_free(default_ifname);
+
+       if (!stc)
                return;
-       }
 
-       if (!stc->carg) {
-               stc->carg = MALLOC0(counter_arg_s, 1);
-               if (stc->carg == NULL) {
-                       g_free(default_ifname);
-                       return;
-               }
+       for (; conn_list != NULL; conn_list = conn_list->next) {
+               stc_connection_s *conn = conn_list->data;
 
-               stc->carg->sock = stc_monitor_get_contr_sock();
-       }
+               if (!stc->carg) {
+                       stc->carg = MALLOC0(counter_arg_s, 1);
+                       if (stc->carg == NULL)
+                               return;
 
-       memset(&counter, 0, sizeof(struct nfacct_rule));
+                       stc->carg->sock = stc_monitor_get_contr_sock();
+               }
 
-       counter.carg = stc->carg;
-       counter.classid = classid;
-       counter.intend = intend;
+               memset(&counter, 0, sizeof(struct nfacct_rule));
 
-       if (connection && connection->tether_iface.ifname != NULL &&
-               classid == STC_TETHERING_APP_CLASSID) {
-               counter.iftype = connection->tether_iface.type;
-               g_strlcpy(counter.ifname, connection->tether_iface.ifname, MAX_IFACE_LENGTH);
-       } else {
-               counter.iftype = iftype;
-               g_strlcpy(counter.ifname, default_ifname, MAX_IFACE_LENGTH);
-       }
+               counter.carg = stc->carg;
+               counter.classid = classid;
+               counter.intend = intend;
 
-       g_free(default_ifname);
+               if (conn && conn->tether_iface.ifname != NULL &&
+                       classid == STC_TETHERING_APP_CLASSID) {
+                       counter.iftype = conn->tether_iface.type;
+                       g_strlcpy(counter.ifname, conn->tether_iface.ifname, MAX_IFACE_LENGTH);
+               } else {
+                       counter.iftype = iftype;
+                       g_strlcpy(counter.ifname, conn->ifname, MAX_IFACE_LENGTH);
+               }
 
-       /* iptables rule */
-       stc_monitor_ipt_del_in(&counter);
-       stc_monitor_ipt_del_out(&counter);
+               /* iptables rule */
+               stc_monitor_ipt_del_in(&counter);
+               stc_monitor_ipt_del_out(&counter);
 
-       /* ip6tables rule */
-       stc_monitor_ip6t_del_in(&counter);
-       stc_monitor_ip6t_del_out(&counter);
+               /* ip6tables rule */
+               stc_monitor_ip6t_del_in(&counter);
+               stc_monitor_ip6t_del_out(&counter);
+       }
 }
 
 static void __rstn_set_noti_state(int value)
@@ -305,23 +309,36 @@ static void __rstn_set_noti_state(int value)
 static void __rstn_tethering_process(enum traffic_restriction_type rstn_type,
                                char *app_id, stc_rstn_data_s *rstn_data, void *data)
 {
-       default_connection_s *old_connection = (default_connection_s *)data;
-       default_connection_s *connection = NULL;
+       stc_connection_s *old_connection = (stc_connection_s *)data;
+       stc_connection_s *connection = NULL;
        char *mac_str = NULL;
 
-       if (old_connection != NULL)
+       if (old_connection != NULL) {
                connection = old_connection;
-       else
-               connection = stc_get_default_connection();
+               if (connection->tether_state == FALSE)
+                       return;
 
-       /* in case tethering is not active */
-       if (connection->tether_state == FALSE)
-               return;
+               /* rstn not applicable for this interface */
+               if (rstn_data->ifname != NULL &&
+                       g_strcmp0("", rstn_data->ifname) != 0 &&
+                       g_strcmp0(connection->tether_iface.ifname, rstn_data->ifname) != 0)
+                       return;
+       } else {
+               GSList *conn_list = stc_get_connection_list();
+               for (; conn_list != NULL; conn_list = conn_list->next) {
+                       stc_connection_s *conn = conn_list->data;
+                       if (conn->tether_state == FALSE)
+                               continue;
+
+                       if (rstn_data->ifname != NULL &&
+                               g_strcmp0(rstn_data->ifname, "") != 0 &&
+                               g_strcmp0(conn->tether_iface.ifname, rstn_data->ifname) == 0)
+                               connection = conn;
+               }
 
-       /* rstn not applicable for this interface */
-       if (rstn_data->ifname != NULL && g_strcmp0("", rstn_data->ifname) != 0 &&
-                       (g_strcmp0(connection->tether_iface.ifname, rstn_data->ifname) != 0))
-               return;
+               if (connection == NULL)
+                       return;
+       }
 
        /* in case appid not a tethering app */
        if (!g_str_has_suffix(app_id, STC_TETHERING_APP_SUFFIX))
@@ -443,24 +460,37 @@ static void __rstn_tethering_process(enum traffic_restriction_type rstn_type,
 static void __rstn_process(enum traffic_restriction_type rstn_type,
                                  char *app_id, stc_rstn_data_s *rstn_data, void *data)
 {
-       default_connection_s *old_connection = (default_connection_s *)data;
-       default_connection_s *connection = NULL;
+       stc_connection_s *old_connection = (stc_connection_s *)data;
+       stc_connection_s *connection = NULL;
 
-       if (old_connection != NULL)
+       if (old_connection != NULL) {
                connection = old_connection;
-       else
-               connection = stc_get_default_connection();
+               if (connection->ifname == NULL)
+                       return;
 
-       /* no default ifname */
-       if (connection->ifname == NULL)
-               return;
+               /* rstn not applicable for this interface */
+               if (rstn_data->ifname != NULL &&
+                       g_strcmp0(rstn_data->ifname, "") != 0 &&
+                   g_strcmp0(connection->ifname, rstn_data->ifname) != 0 &&
+                   g_strcmp0(connection->tether_iface.ifname, rstn_data->ifname) != 0)
+                   return;
+       } else {
+               GSList *conn_list = stc_get_connection_list();
+               for (; conn_list != NULL; conn_list = conn_list->next) {
+                       stc_connection_s *conn = conn_list->data;
+                       if (conn == NULL || conn->ifname == NULL)
+                               continue;
+
+                       if (rstn_data->ifname != NULL &&
+                               g_strcmp0(rstn_data->ifname, "") != 0 &&
+                               g_strcmp0(conn->ifname, rstn_data->ifname) == 0 &&
+                               g_strcmp0(conn->tether_iface.ifname, rstn_data->ifname) == 0)
+                               connection = conn;
+               }
 
-       /* rstn not applicable for this interface */
-       if (rstn_data->ifname != NULL &&
-               g_strcmp0(rstn_data->ifname, "") != 0 &&
-           (g_strcmp0(connection->ifname, rstn_data->ifname) != 0) &&
-               (g_strcmp0(connection->tether_iface.ifname, rstn_data->ifname) != 0))
-               return;
+               if (connection == NULL)
+                       return;
+       }
 
        /* classid is invalid */
        if (rstn_data->classid <= STC_UNKNOWN_CLASSID)
@@ -986,47 +1016,46 @@ static void __reset_time_counter_foreach_rstn_data(gpointer data,
 
                        if (rstn_data->limit_exceeded & (1 << i)) {
                                /* remove iptables rule */
-                               char *default_ifname = stc_default_connection_get_ifname();
+                               GSList *conn_list = stc_get_connection_list();
                                struct nfacct_rule counter;
                                stc_s *stc = stc_get_manager();
                                if (stc == NULL) {
                                        STC_LOGE("Can't get stc data");
-                                       g_free(default_ifname);
                                        goto try_next_callback;
                                }
 
                                if (!stc->carg) {
                                        stc->carg = MALLOC0(counter_arg_s, 1);
                                        if (stc->carg == NULL) {
-                                               g_free(default_ifname);
                                                goto try_next_callback;
                                        }
 
                                        stc->carg->sock = stc_monitor_get_contr_sock();
                                }
 
-                               memset(&counter, 0, sizeof(struct nfacct_rule));
+                               for (; conn_list != NULL; conn_list = conn_list->next) {
+                                       stc_connection_s *conn = conn_list->data;
 
-                               counter.carg = stc->carg;
-                               counter.classid = rstn_data->classid;
-                               counter.intend = NFACCT_BLOCK;
-                               counter.iftype = rstn_data->iftype;
-                               g_strlcpy(counter.ifname, default_ifname,
-                                         MAX_IFACE_LENGTH);
+                                       memset(&counter, 0, sizeof(struct nfacct_rule));
 
-                               g_free(default_ifname);
+                                       counter.carg = stc->carg;
+                                       counter.classid = rstn_data->classid;
+                                       counter.intend = NFACCT_BLOCK;
+                                       counter.iftype = rstn_data->iftype;
+                                       g_strlcpy(counter.ifname, conn->ifname, MAX_IFACE_LENGTH);
 
-                               /* iptables rule */
-                               stc_monitor_ipt_del_in(&counter);
-                               stc_monitor_ipt_del_out(&counter);
+                                       /* iptables rule */
+                                       stc_monitor_ipt_del_in(&counter);
+                                       stc_monitor_ipt_del_out(&counter);
 
-                               /* ip6tables rule */
-                               stc_monitor_ip6t_del_in(&counter);
-                               stc_monitor_ip6t_del_out(&counter);
+                                       /* ip6tables rule */
+                                       stc_monitor_ip6t_del_in(&counter);
+                                       stc_monitor_ip6t_del_out(&counter);
 
-                               rstn_data->rstn_state = STC_RSTN_STATE_DEACTIVATED;
-                               rstn_data->limit_exceeded &= ~(1 << i);
-                               rstn_data->limit_notified &= ~(1 << i);
+                                       rstn_data->rstn_state = STC_RSTN_STATE_DEACTIVATED;
+                                       rstn_data->limit_exceeded &= ~(1 << i);
+                                       rstn_data->limit_notified &= ~(1 << i);
+                               }
                        }
                }
        }
@@ -1084,69 +1113,73 @@ void stc_monitor_rstn_update_counter(gpointer data,
        int i;
        stc_rstn_data_s *rstn_data = (stc_rstn_data_s *)data;
        classid_bytes_context_s *context = (classid_bytes_context_s *)user_data;
-       default_connection_s *default_connection = stc_get_default_connection();
-
-       if (rstn_data->iftype != context->counter->iftype)
-               return;
+       GSList *conn_list = stc_get_connection_list();
 
-       if (rstn_data->ifname != NULL &&
-               g_strcmp0(rstn_data->ifname, "") &&
-               g_strcmp0(rstn_data->ifname, context->counter->ifname) != 0)
-               return;
+       for (; conn_list != NULL; conn_list = conn_list->next) {
+               stc_connection_s *conn = conn_list->data;
 
-       if (rstn_data->subscriber_id != NULL &&
-               g_strcmp0(rstn_data->subscriber_id, "") &&
-               g_strcmp0(rstn_data->subscriber_id, default_connection->subscriber_id) != 0)
-               return;
+               if (rstn_data->iftype != context->counter->iftype)
+                       return;
 
-       if (rstn_data->roaming != default_connection->roaming)
-               return;
+               if (rstn_data->ifname != NULL &&
+                       g_strcmp0(rstn_data->ifname, "") &&
+                       g_strcmp0(rstn_data->ifname, context->counter->ifname) != 0)
+                       return;
 
-       if (rstn_data->limit_exceeded != 0) {
-               context->data_limit_exceeded = TRUE;
-               return;
-       }
+               if (rstn_data->subscriber_id != NULL &&
+                       g_strcmp0(rstn_data->subscriber_id, "") &&
+                       g_strcmp0(rstn_data->subscriber_id, conn->subscriber_id) != 0)
+                       return;
 
-       switch (context->counter->iotype) {
-       case NFACCT_COUNTER_IN:
-       case NFACCT_COUNTER_OUT:
-               if ((rstn_data->counter[STC_RSTN_LIMIT_TYPE_DATA] == 0 &&
-                       rstn_data->limit[STC_RSTN_LIMIT_TYPE_DATA] >= 0) ||
-                       (rstn_data->counter[STC_RSTN_LIMIT_TYPE_DATA_WARN] == 0 &&
-                       rstn_data->limit[STC_RSTN_LIMIT_TYPE_DATA_WARN] >= 0) ||
-                       (rstn_data->counter[STC_RSTN_LIMIT_TYPE_MONTHLY] == 0 &&
-                       rstn_data->limit[STC_RSTN_LIMIT_TYPE_MONTHLY] >= 0) ||
-                       (rstn_data->counter[STC_RSTN_LIMIT_TYPE_WEEKLY] == 0 &&
-                       rstn_data->limit[STC_RSTN_LIMIT_TYPE_WEEKLY] >= 0) ||
-                       (rstn_data->counter[STC_RSTN_LIMIT_TYPE_DAILY] == 0 &&
-                       rstn_data->limit[STC_RSTN_LIMIT_TYPE_DAILY] >= 0)) {
-                       table_counters_info info;
-                       memset(&info, 0, sizeof(table_counters_info));
-                       table_counters_get(rstn_data->restriction_id, &info);
+               if (rstn_data->roaming != conn->roaming)
+                       return;
 
-                       rstn_data->counter[STC_RSTN_LIMIT_TYPE_DATA] = info.data_counter;
-                       rstn_data->counter[STC_RSTN_LIMIT_TYPE_DATA_WARN] = info.warn_counter;
-                       rstn_data->counter[STC_RSTN_LIMIT_TYPE_MONTHLY] = info.monthly_counter;
-                       rstn_data->counter[STC_RSTN_LIMIT_TYPE_WEEKLY] = info.weekly_counter;
-                       rstn_data->counter[STC_RSTN_LIMIT_TYPE_DAILY] = info.daily_counter;
+               if (rstn_data->limit_exceeded != 0) {
+                       context->data_limit_exceeded = TRUE;
+                       return;
                }
 
-               for (i = 0; i < STC_RSTN_LIMIT_TYPE_MAX; i++) {
-                       if (rstn_data->limit[i] >= 0 &&
-                               !(rstn_data->limit_notified & (1 << i))) {
-                               rstn_data->counter[i] += context->bytes;
-                               if (rstn_data->limit[i] <= rstn_data->counter[i])
-                                       stc_monitor_rstn_action_when_limit_exceeded(i,
-                                                                               rstn_data,
-                                                                               context);
+               switch (context->counter->iotype) {
+               case NFACCT_COUNTER_IN:
+               case NFACCT_COUNTER_OUT:
+                       if ((rstn_data->counter[STC_RSTN_LIMIT_TYPE_DATA] == 0 &&
+                               rstn_data->limit[STC_RSTN_LIMIT_TYPE_DATA] >= 0) ||
+                               (rstn_data->counter[STC_RSTN_LIMIT_TYPE_DATA_WARN] == 0 &&
+                               rstn_data->limit[STC_RSTN_LIMIT_TYPE_DATA_WARN] >= 0) ||
+                               (rstn_data->counter[STC_RSTN_LIMIT_TYPE_MONTHLY] == 0 &&
+                               rstn_data->limit[STC_RSTN_LIMIT_TYPE_MONTHLY] >= 0) ||
+                               (rstn_data->counter[STC_RSTN_LIMIT_TYPE_WEEKLY] == 0 &&
+                               rstn_data->limit[STC_RSTN_LIMIT_TYPE_WEEKLY] >= 0) ||
+                               (rstn_data->counter[STC_RSTN_LIMIT_TYPE_DAILY] == 0 &&
+                               rstn_data->limit[STC_RSTN_LIMIT_TYPE_DAILY] >= 0)) {
+                               table_counters_info info;
+                               memset(&info, 0, sizeof(table_counters_info));
+                               table_counters_get(rstn_data->restriction_id, &info);
+
+                               rstn_data->counter[STC_RSTN_LIMIT_TYPE_DATA] = info.data_counter;
+                               rstn_data->counter[STC_RSTN_LIMIT_TYPE_DATA_WARN] = info.warn_counter;
+                               rstn_data->counter[STC_RSTN_LIMIT_TYPE_MONTHLY] = info.monthly_counter;
+                               rstn_data->counter[STC_RSTN_LIMIT_TYPE_WEEKLY] = info.weekly_counter;
+                               rstn_data->counter[STC_RSTN_LIMIT_TYPE_DAILY] = info.daily_counter;
                        }
-               }
 
-               stc_monitor_set_rstns_updated(TRUE);
-               __print_rstn(rstn_data);
-               break;
-       default:
-               STC_LOGE("Unknown iotype");
+                       for (i = 0; i < STC_RSTN_LIMIT_TYPE_MAX; i++) {
+                               if (rstn_data->limit[i] >= 0 &&
+                                       !(rstn_data->limit_notified & (1 << i))) {
+                                       rstn_data->counter[i] += context->bytes;
+                                       if (rstn_data->limit[i] <= rstn_data->counter[i])
+                                               stc_monitor_rstn_action_when_limit_exceeded(i,
+                                                                                       rstn_data,
+                                                                                       context);
+                               }
+                       }
+
+                       stc_monitor_set_rstns_updated(TRUE);
+                       __print_rstn(rstn_data);
+                       break;
+               default:
+                       STC_LOGE("Unknown iotype");
+               }
        }
 }
 
@@ -1351,7 +1384,7 @@ void stc_monitor_rstn_add_for_app(uint32_t classid)
        g_slist_foreach(lookup_value->rules, __rstn_add, NULL);
 }
 
-void stc_monitor_rstn_add_by_connection(default_connection_s *conn)
+void stc_monitor_rstn_add_by_connection(stc_connection_s *conn)
 {
        GHashTable *rstns = stc_monitor_get_system_rstns();
 
@@ -1402,7 +1435,7 @@ void stc_monitor_rstn_remove_for_app(uint32_t classid)
        g_slist_foreach(lookup_value->rules, __rstn_remove, NULL);
 }
 
-void stc_monitor_rstn_remove_by_connection(default_connection_s *conn)
+void stc_monitor_rstn_remove_by_connection(stc_connection_s *conn)
 {
        GHashTable *rstns = stc_monitor_get_system_rstns();
 
index 5d60749..0bfc5a5 100644 (file)
@@ -18,7 +18,7 @@
 #include <vconf.h>
 #include <vconf-keys.h>
 
-#include "stc-default-connection.h"
+#include "stc-connection.h"
 #include "helper-nl.h"
 #include "helper-nfacct-rule.h"
 #include "helper-net-cls.h"
@@ -534,37 +534,38 @@ gboolean stc_monitor_get_background_state(void)
        return g_system->background_state;
 }
 
-void stc_monitor_update_by_default_connection(void *data)
+void stc_monitor_update_by_connection(void *data)
 {
-       static default_connection_s old_connection;
-       default_connection_s *new_connection = (default_connection_s *)data;
+       stc_connection_s *connection = (stc_connection_s *)data;
 
-       if (old_connection.path != NULL) {
-               stc_monitor_app_remove_by_connection(&old_connection);
-               stc_monitor_rstn_remove_by_connection(&old_connection);
+       if (connection != NULL && connection->path != NULL) {
+               stc_monitor_app_remove_by_connection(connection);
+               stc_monitor_rstn_remove_by_connection(connection);
 
                iptables_flush_chains();
+
+               stc_monitor_app_add_by_connection(connection);
+               stc_monitor_rstn_add_by_connection(connection);
        }
+}
+
+void stc_monitor_add_by_connection(void *data)
+{
+       stc_connection_s *connection = (stc_connection_s *)data;
+
+       if (connection != NULL && connection->path != NULL) {
+               stc_monitor_app_add_by_connection(connection);
+               stc_monitor_rstn_add_by_connection(connection);
+       }
+}
+
+void stc_monitor_remove_by_connection(void *data)
+{
+       stc_connection_s *connection = (stc_connection_s *)data;
 
-       FREE(old_connection.path);
-       FREE(old_connection.ifname);
-       FREE(old_connection.tether_iface.ifname);
-       old_connection.type = 0;
-       old_connection.roaming = 0;
-       old_connection.tether_state = FALSE;
-       old_connection.tether_iface.type = 0;
-
-       if (new_connection != NULL && new_connection->path != NULL) {
-               stc_monitor_app_add_by_connection(new_connection);
-               stc_monitor_rstn_add_by_connection(new_connection);
-
-               old_connection.path = g_strdup(new_connection->path);
-               old_connection.ifname = g_strdup(new_connection->ifname);
-               old_connection.tether_iface.ifname = g_strdup(new_connection->tether_iface.ifname);
-               old_connection.type = new_connection->type;
-               old_connection.roaming = new_connection->roaming;
-               old_connection.tether_state = new_connection->tether_state;
-               old_connection.tether_iface.type = new_connection->tether_iface.type;
+       if (connection != NULL && connection->path != NULL) {
+               stc_monitor_app_remove_by_connection(connection);
+               stc_monitor_rstn_remove_by_connection(connection);
        }
 }
 
index 2e5803c..04af66c 100644 (file)
@@ -19,7 +19,7 @@
 #include "stc-statistics.h"
 #include "stc-restriction.h"
 #include "stc-firewall.h"
-#include "stc-default-connection.h"
+#include "stc-connection.h"
 #include "stc-manager-util.h"
 #include "stc-manager-plugin-appstatus.h"
 #include "stc-manager-plugin-procfs.h"
@@ -306,7 +306,7 @@ static void __stc_manager_gdbus_on_bus_acquired(GDBusConnection *connection,
                                                    stc->connection);
 
        iptables_init();
-       stc_default_connection_monitor_init(stc);
+       stc_connection_monitor_init(stc);
 
        stc_plugin_appstatus_register_state_changed_cb(stc,
                        stc_plugin_procfs_app_status_changed, NULL);
@@ -353,7 +353,7 @@ void stc_manager_gdbus_deinit(gpointer stc_data)
        stc_s *stc = (stc_s *)stc_data;
 
        stc_plugin_appstatus_deregister_state_changed_cb(stc);
-       stc_default_connection_monitor_deinit(stc);
+       stc_connection_monitor_deinit(stc);
 
        g_bus_unown_name(stc->gdbus_owner_id);