From 3c7bd4b5d88ddd02eabe986db4fed121fb8d4096 Mon Sep 17 00:00:00 2001 From: "wootak.jung" Date: Thu, 14 Mar 2013 17:50:17 +0900 Subject: [PATCH] Transfer network interface UP/DOWN logic from modem plugin to ps plugin. --- src/tcore-interface.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/tcore-interface.c b/src/tcore-interface.c index 89bffa8..8d6279a 100644 --- a/src/tcore-interface.c +++ b/src/tcore-interface.c @@ -35,6 +35,10 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc { gpointer service = user_data; struct tnoti_ps_call_status *cstatus = NULL; + char *ifname; + gboolean netif_updown = FALSE; + GSList *contexts; + CoreObject *co_context; dbg("call status event"); g_return_val_if_fail(service != NULL, TCORE_HOOK_RETURN_STOP_PROPAGATION); @@ -43,6 +47,30 @@ static enum tcore_hook_return __on_hook_call_status(Server *s, CoreObject *sourc dbg("call status event cid(%d) state(%d)", cstatus->context_id, cstatus->state); + if (cstatus->state == PS_DATA_CALL_CTX_DEFINED) + goto out; + else if (cstatus->state == PS_DATA_CALL_CONNECTED) + netif_updown = TRUE; + else if (cstatus->state == PS_DATA_CALL_NOT_CONNECTED) + netif_updown = FALSE; + + contexts = tcore_ps_ref_context_by_id(source, cstatus->context_id); + for (; contexts != NULL; contexts = g_slist_next(contexts)) { + co_context = contexts->data; + ifname = tcore_context_get_ipv4_devname(co_context); + + if (ifname == NULL) + continue; + + if (tcore_util_netif(ifname, netif_updown) + != TCORE_RETURN_SUCCESS) { + g_slist_free(contexts); + g_free(ifname); + dbg("tcore_util_netif() failed."); + } + } + +out: //send activation event / deactivation event if (cstatus->state == PS_DATA_CALL_CTX_DEFINED) {/* OK: PDP define is complete. */ dbg("service is ready to activate"); -- 2.7.4