Correct some typo and add missing feature define
[platform/core/telephony/tel-plugin-packetservice.git] / src / ps_service.c
1 /*
2  * tel-plugin-packetservice
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: DongHoo Park <donghoo.park@samsung.com>
7  *          Arun Shukla <arun.shukla@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #include "ps_common.h"
24 #include "ps_context.h"
25 #include "ps_master.h"
26 #include "ps_modem.h"
27 #include "ps_service.h"
28 #include "ps_hook.h"
29 #include "ps_tcore_interface.h"
30 #include "ps_service_interface.h"
31
32 #include <core_object.h>
33 #include <co_ps.h>
34 #include <co_context.h>
35 #include <co_network.h>
36 #include <storage.h>
37 #include <vconf.h>
38 #include <arpa/inet.h>
39
40 #include <tfeature.h>
41 #include <user_request.h>
42
43 #include "ps_log.h"
44
45 static guint __ps_service_convert_ipv4_address_int(char *ip_address)
46 {
47 #define HEX_ENCODING_VALUE 16
48         gchar **temp_str = NULL;
49         char *temp_address;
50         guint address;
51
52         if (!ip_address)
53                 return 0;
54
55         temp_str = g_strsplit(ip_address, ".", 5);
56         temp_address = g_strdup_printf("%02x%02x%02x%02x", atoi(temp_str[0]), atoi(temp_str[1]), atoi(temp_str[2]), atoi(temp_str[3]));
57         /* Free resources */
58         g_strfreev(temp_str);
59
60         address = strtoul(temp_address, (char **)NULL, HEX_ENCODING_VALUE);
61         g_free(temp_address);
62         return address;
63 }
64
65 void __remove_service_handler(gpointer data)
66 {
67         ps_service_t *service = data;
68
69         if (!service) {
70                 err("Service is Null");
71                 return;
72         }
73
74         ps_info_ex_svc(service, "Entered");
75         /*Need to remove the compelete hash table*/
76         g_slist_free(service->contexts);
77
78         /*Need to UNexport and Unref the master Object */
79         if (service->if_obj) {
80                 g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(service->if_obj));
81                 g_object_unref(service->if_obj);
82                 service->if_obj = NULL;
83         }
84
85         /*Need to free the memory of the internal structure*/
86         g_free(service->path);
87         g_free(service);
88 }
89
90 static char *__ps_service_act2string(enum telephony_network_access_technology act)
91 {
92         switch (act) {
93         case NETWORK_ACT_GSM:
94         case NETWORK_ACT_GPRS:
95         case NETWORK_ACT_EGPRS:
96         case NETWORK_ACT_UMTS:
97         case NETWORK_ACT_GSM_UTRAN:
98                 return "GSM";
99
100         case NETWORK_ACT_IS95A:
101         case NETWORK_ACT_IS95B:
102         case NETWORK_ACT_CDMA_1X:
103         case NETWORK_ACT_EVDO_REV0:
104         case NETWORK_ACT_CDMA_1X_EVDO_REV0:
105         case NETWORK_ACT_EVDO_REVA:
106         case NETWORK_ACT_CDMA_1X_EVDO_REVA:
107         case NETWORK_ACT_EVDV:
108                 return "CDMA";
109
110         case NETWORK_ACT_LTE:
111                 return "LTE";
112
113         case NETWORK_ACT_UNKNOWN:
114         default:
115                 return "unknown";
116         }
117
118         return NULL;
119 }
120
121 static gboolean __ps_service_check_connection_option(ps_service_t *service, ps_context_t *context)
122 {
123         gboolean b_connect = TRUE;
124         gboolean power = FALSE, sim = FALSE, data = FALSE, flight = FALSE;
125         gboolean profile_reset = FALSE;
126
127         enum co_context_role role = CONTEXT_ROLE_UNKNOWN;
128         gint ps_mode;
129 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
130         guchar hook_flag;
131         gboolean nw_ops = FALSE;
132 #endif
133
134         ps_modem_t *modem = _ps_service_ref_modem(service);
135         ps_master_t *master = _ps_modem_ref_master(modem);
136         CoreObject *co_context = _ps_context_ref_co_context(context);
137
138         if (TRUE != _ps_context_get_profile_enable(context)) {
139                 ps_warn_ex_svc(service, "Profile is disabled.");
140                 return FALSE;
141         }
142
143         sim = _ps_modem_get_sim_init(modem);
144         data = _ps_modem_get_data_allowed(modem);
145         flight = _ps_modem_get_flght_mode(modem);
146         profile_reset = _ps_modem_get_reset_profile(modem);
147 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
148         hook_flag = _ps_hook_get_hook_flag(modem);
149         if (hook_flag != PS_NO_PENDING_REQUEST)
150                 nw_ops = TRUE;
151 #endif
152         if (PS_MODEM_STATE_ONLINE == _ps_modem_get_power(modem))
153                 power = TRUE;
154
155         b_connect &= power;
156
157         role = tcore_context_get_role(co_context);
158         if (role == CONTEXT_ROLE_IMS || role == CONTEXT_ROLE_IMS_EMERGENCY || role == CONTEXT_ROLE_IMS_UT
159             || role == CONTEXT_ROLE_FOTA || role == CONTEXT_ROLE_BIP) {
160                 ps_info_ex_svc(service, "Do not check data and data roaming allowed value in case of IMS type");
161         } else {
162                 if (service->roaming) {
163                         gboolean roaming_allowed = FALSE;
164                         roaming_allowed = _ps_modem_get_data_roaming_allowed(modem);
165                         ps_warn_ex_svc(service, "roaming_allowed:[%d]", roaming_allowed);
166                         b_connect &= roaming_allowed;
167                 }
168
169                 b_connect &= data;
170         }
171
172         b_connect &= !flight;
173 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
174         b_connect &= !nw_ops;
175 #endif
176         b_connect &= !service->restricted;
177         b_connect &= !profile_reset;
178         if (role != CONTEXT_ROLE_IMS_EMERGENCY) {
179                 b_connect &= service->ps_attached;
180                 b_connect &= sim;
181         }
182         ps_mode = _ps_modem_get_psmode(modem);
183
184         /*
185          * Kiran PLM P141017-05702
186          * Problem: PDP retry when Wifi connected.
187          * Reproducible cases:
188          * 1) Wifi auto connected but PDP has never been connected.
189          * 2) Quick switch Wifi On -> Off before PDP establishment is complete.
190          * 2nd exceptional case is handled by Connmand but 1st case should be
191          * taken care of by telephony.
192          * Solution: Do not PDP retry until initial PDP connection when Wifi connected.
193          */
194         if (master && master->initial_pdp_conn == FALSE) {
195                 int wifi_state = PS_WIFI_STATE_OFF;
196
197                 wifi_state = _ps_master_get_storage_value_int(master, KEY_WIFI_STATE);
198                 if (wifi_state == PS_WIFI_STATE_CONNECTED) {
199                         if (service->wifi_connected_checked == FALSE) {
200                                 ps_info_ex_svc(service, "DO NOT set PDP retry timer when WiFi connected but PDP never been connected yet.");
201                                 b_connect = FALSE;
202                                 service->wifi_connected_checked = TRUE;
203                         } else {
204                                 ps_info_ex_svc(service, "Wifi connected state was already checked.");
205                         }
206                 }
207         }
208 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
209         ps_info_ex_svc(service, "b_connect(%d), power(%d), sim init(%d), data allowed(%d), flight mode(%d) restricted(%d) ps_attached(%d), ps_mode(%d), hook_flag(%d)",
210                        b_connect, power, sim, data, flight, service->restricted, service->ps_attached, ps_mode, hook_flag);
211 #else
212         ps_info_ex_svc(service, "b_connect(%d), power(%d), sim init(%d), data allowed(%d), flight mode(%d) restricted(%d) ps_attached(%d), ps_mode(%d)",
213                        b_connect, power, sim, data, flight, service->restricted, service->ps_attached, ps_mode);
214 #endif
215         /* In case of ME in LCD off & UPS mode.
216          * Do not allow PDP activation.
217          */
218         if (b_connect) {
219                 int ups_mode, emc_data_allowed;
220                 ups_mode = ps_mode & ~POWER_SAVING_MODE_DATA_ALLOWED;
221                 emc_data_allowed = ps_mode & POWER_SAVING_MODE_DATA_ALLOWED;
222                 if (emc_data_allowed == FALSE &&
223                     (ups_mode > POWER_SAVING_MODE_NORMAL && ups_mode < POWER_SAVING_MODE_WEARABLE)) {
224                         gint pm_state = _ps_master_get_storage_value_int(master, STORAGE_KEY_PM_STATE);
225                         if (pm_state == 3 &&
226                             (role != CONTEXT_ROLE_IMS &&  role != CONTEXT_ROLE_IMS_EMERGENCY &&  role != CONTEXT_ROLE_IMS_UT)) {
227                                 ps_warn_ex_svc(service, "PDP activation is not allowed in LCD off & UPS mode.");
228                                 b_connect = FALSE;
229                         }
230                 }
231         }
232         return b_connect;
233 }
234
235 static int __ps_service_connetion_timeout_handler(alarm_id_t alarm_id, void *context)
236 {
237         int rv = 0;
238         ps_context_t *ps_context = context;
239         ps_service_t *service = _ps_context_ref_service(ps_context);
240         enum co_context_role role;
241         if (service == NULL) {
242                 err("service is NULL!!!");
243                 return rv;
244         }
245
246         if (ps_context->timer_src > 0) {
247                 ps_info_ex_svc(service, "remove connection retry timer (%d)", ps_context->timer_src);
248                 alarmmgr_remove_alarm(ps_context->timer_src);
249                 ps_context->timer_src = 0;
250         }
251
252         role = tcore_context_get_role(_ps_context_ref_co_context(ps_context));
253         ps_info_ex_svc(service, "Re-try for %d type is_epdg_available: %d",
254                        role, service->is_epdg_available);
255         if ((role == CONTEXT_ROLE_IMS) && (service->is_epdg_available == TRUE)) {
256                 ps_info_ex_svc(service, "Do not re-try for IMS PDN as ePDG is available");
257                 return rv;
258         }
259
260         ps_info_ex_svc(service, "Re-try for context role [%d]", tcore_context_get_role(_ps_context_ref_co_context(ps_context)));
261         rv = _ps_service_activate_context(service, ps_context);
262         ps_info_ex_svc(service, "return rv(%d)", rv);
263         return rv;
264 }
265
266 static gboolean __ps_service_check_is_network_in_serivce(ps_service_t *service)
267 {
268         CoreObject *co_network = _ps_service_ref_co_network(service);
269         enum telephony_network_service_type service_type = NETWORK_SERVICE_TYPE_UNKNOWN;
270         gboolean rv = FALSE;
271
272         tcore_network_get_service_type(co_network, &service_type);
273         ps_warn_ex_svc(service, "service_type[%d]", service_type);
274         switch (service_type) {
275         case NETWORK_SERVICE_TYPE_UNKNOWN:
276         case NETWORK_SERVICE_TYPE_NO_SERVICE:
277         case NETWORK_SERVICE_TYPE_EMERGENCY:
278         case NETWORK_SERVICE_TYPE_SEARCH:
279                 break;
280
281         default:
282                 rv = TRUE;
283                 break;
284         }
285         return rv;
286 }
287
288 static TReturn __ps_service_set_attach_apn(ps_service_t *service, CoreObject *co_context, int set_cid)
289 {
290         TReturn rv;
291         char *apn = tcore_context_get_apn(co_context);
292         CoreObject *co_ps = _ps_service_ref_co_ps(service);
293
294         ps_dbg_ex_svc(service, "'Attach APN(%d)' [%s]", tcore_context_get_role(co_context), apn);
295
296         if (set_cid)
297                 tcore_context_set_id(co_context, set_cid);  // internet
298
299         if (tfeature_is_supported(TFEATURE_FUNCTION_SEND_APN_INFO)) {
300                 gboolean is_refresh_apn_info = FALSE;
301                 rv = tcore_ps_set_data_profile(co_ps, co_context, &is_refresh_apn_info);
302                 if (rv != TCORE_RETURN_SUCCESS)
303                         ps_err_ex_svc(service, "fail to set data profile");
304         } else {
305                 rv = tcore_ps_define_context(co_ps, co_context, NULL);
306                 if (rv != TCORE_RETURN_SUCCESS)
307                         ps_err_ex_svc(service, "fail to define context");
308         }
309
310         g_free(apn);
311         return rv;
312 }
313
314 void _ps_service_set_attach_apn(ps_service_t *service)
315 {
316         unsigned int index;
317         int default_data_subs;
318         ps_subs_type subs_type;
319         ps_modem_t *modem = NULL;
320         ps_master_t *master = NULL;
321
322         modem = _ps_service_ref_modem(service);
323         master = _ps_modem_ref_master(modem);
324
325         /* Check for default data subscription value if matchs for modem then only attach */
326         subs_type = _ps_modem_get_subs_type(modem);
327         default_data_subs = _ps_master_get_storage_value_int(master, STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT);
328         if (default_data_subs != (int)subs_type) {
329                 ps_warn_ex_svc(service, "Ignore Attach APN for non-dds sim [DDS - SIM%d]", default_data_subs + 1);
330                 return;
331         }
332
333         for (index = 0; index < g_slist_length(service->contexts); index++) {
334                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
335                 CoreObject *co_context = _ps_context_ref_co_context(context);
336                 gboolean attach_apn = tcore_context_get_attach_apn(co_context);
337                 if (attach_apn) {
338                         __ps_service_set_attach_apn(service, co_context, 0);
339                         /* Attach APN is only one. */
340                         break;
341                 }
342         }
343 }
344
345 ps_service_t *_ps_service_create_service(GDBusConnection *conn, TcorePlugin *p, ps_modem_t *modem,
346                                          CoreObject *co_network, CoreObject *co_ps, gchar *path)
347 {
348         ps_service_t *new_service;
349
350         g_return_val_if_fail(conn != NULL, NULL);
351         g_return_val_if_fail(modem != NULL, NULL);
352
353         ps_dbg_ex_modem(modem, "service object create");
354
355         /*Initializing the modem list for internal referencing*/
356         new_service = g_try_malloc0(sizeof(ps_service_t));
357         if (NULL == new_service) {
358                 ps_err_ex_modem(modem, "Unable to allocate memory for master");
359                 goto FAILURE;
360         }
361
362         new_service->conn = conn;
363         new_service->plg = p;
364         new_service->p_modem = modem;
365         new_service->co_network = co_network;
366         new_service->co_ps = co_ps;
367         new_service->path = g_strdup(path);
368         new_service->subs_type = modem->subs_type;
369
370         _ps_add_co_network_event(new_service);
371         _ps_get_co_network_values(new_service);
372         _ps_add_co_ps_event(new_service);
373
374         /*Setting up the interface for the service */
375         if (!ps_service_setup_interface(new_service)) {
376                 g_free(new_service->path);
377                 goto FAILURE;
378         }
379
380 //      new_service->connection_timeout = PDP_RETRY_TIME_OUT_DEFAULT;
381         ps_info_ex_modem(modem, "Successfully Created the service");
382         return new_service;
383
384  FAILURE:
385         /*To Do: Handle failure case*/
386         g_free(new_service);
387         return NULL;
388 }
389
390 gboolean _ps_service_ref_context(ps_service_t *service, ps_context_t *context)
391 {
392         gpointer tmp = NULL;
393
394         g_return_val_if_fail(service != NULL, FALSE);
395
396         ps_dbg_ex_svc(service, "service refer to context");
397
398         tmp = g_slist_find(service->contexts, context);
399         if (tmp) {
400                 ps_dbg_ex_svc(service, "context(%p) already existed", tmp);
401                 return FALSE;
402         }
403
404         _ps_context_set_service(context, service);
405         tcore_ps_add_context(_ps_service_ref_co_ps(service), _ps_context_ref_co_context(context));
406         service->contexts = g_slist_append(service->contexts, context);
407
408         ps_info_ex_svc(service, "context(%p) insert to linked-list", context);
409         ps_service_emit_context_added_signal(service, context);
410
411         return TRUE;
412 }
413
414 gboolean _ps_service_ref_contexts(ps_service_t *service, GSList *contexts, gchar *operator)
415 {
416         gboolean ret = TRUE;
417         int rv;
418         unsigned int index, count;
419
420         g_return_val_if_fail(service != NULL, FALSE);
421
422         count = g_slist_length(contexts);
423         ps_dbg_ex_svc(service, "service refer to contexts: count(%d)", count);
424
425         for (index = 0; index < count; index++) {
426                 gpointer tmp = NULL;
427                 ps_context_t *context = g_slist_nth_data(contexts, index);
428                 CoreObject *co_context = _ps_context_ref_co_context(context);
429
430                 tmp = g_slist_find(service->contexts, context);
431                 if (tmp) {
432                         ps_dbg_ex_svc(service, "context(%p) already existed", tmp);
433                         continue;
434                 }
435
436                 _ps_context_set_service(context, service);
437                 tcore_ps_add_context(_ps_service_ref_co_ps(service), co_context);
438                 service->contexts = g_slist_append(service->contexts, context);
439
440                 ps_info_ex_svc(service, "context(%p) path(%s) insert to linked-list", context, _ps_context_ref_path(context));
441                 ps_service_emit_context_added_signal(service, context);
442
443 #ifdef PREPAID_SIM_APN_SUPPORT
444                 ret = _ps_service_connect_last_connected_context_ex(service, context, NULL, operator);
445                 ps_info_ex_svc(service, "ret[%d]", ret);
446                 if (ret == TRUE) {
447                         /* process next available profile */
448                         continue;
449                 }
450 #endif
451
452                 if (service->ps_attached) {
453                         gboolean f_awo = _ps_context_get_alwayson_enable(context);
454                         gboolean ims_activation_requested = FALSE;
455
456                         if (f_awo) {
457                                 rv = _ps_service_define_context(service, context);
458                                 ps_info_ex_svc(service, "Always-on started, return rv(%d)", rv);
459                         }
460
461                         ims_activation_requested = _ps_service_get_ims_activation_requested(service);
462                         if (ims_activation_requested && (CONTEXT_ROLE_IMS == tcore_context_get_role(co_context))) {
463                                 rv = _ps_service_define_context(service, context);
464                                 ps_info_ex_svc(service, "IMS PDN rv(%d)", rv);
465                                 ims_activation_requested = FALSE;
466                         }
467                 }
468         }
469         ps_dbg_ex_svc(service, "service->contexts: count(%d)", g_slist_length(service->contexts));
470         _ps_update_cellular_state_key(service);
471         return ret;
472 }
473
474 gboolean _ps_service_get_properties_handler(ps_service_t *service, GVariantBuilder *properties)
475 {
476         g_return_val_if_fail(service != NULL, FALSE);
477         g_return_val_if_fail(properties != NULL, FALSE);
478
479         ps_info_ex_svc(service, "get service properties");
480
481         g_variant_builder_open(properties, G_VARIANT_TYPE("a{ss}"));
482         g_variant_builder_add(properties, "{ss}", "path", service->path);
483         g_variant_builder_add(properties, "{ss}", "ps_attached", BOOL2STRING(service->ps_attached));
484         g_variant_builder_add(properties, "{ss}", "roaming", BOOL2STRING(service->roaming));
485         g_variant_builder_add(properties, "{ss}", "act", __ps_service_act2string(service->act));
486         g_variant_builder_close(properties);
487
488         ps_dbg_ex_svc(service, "Exiting");
489         return TRUE;
490 }
491
492 GVariant *_ps_service_get_properties(ps_service_t *service, GVariantBuilder *properties)
493 {
494         g_return_val_if_fail(service != NULL, FALSE);
495         g_return_val_if_fail(properties != NULL, FALSE);
496
497         ps_info_ex_svc(service, "get service properties");
498
499         g_variant_builder_init(properties, G_VARIANT_TYPE("a{ss}"));
500
501         g_variant_builder_add(properties, "{ss}", "path", service->path);
502         g_variant_builder_add(properties, "{ss}", "ps_attached", BOOL2STRING(service->ps_attached));
503         g_variant_builder_add(properties, "{ss}", "roaming", BOOL2STRING(service->roaming));
504         g_variant_builder_add(properties, "{ss}", "act", __ps_service_act2string(service->act));
505
506         ps_dbg_ex_svc(service, "Exiting");
507         return g_variant_builder_end(properties);
508 }
509
510 gchar *_ps_service_ref_path(ps_service_t *service)
511 {
512         g_return_val_if_fail(service != NULL, NULL);
513         return service->path;
514 }
515
516 TcorePlugin *_ps_service_ref_plugin(ps_service_t *service)
517 {
518         g_return_val_if_fail(service != NULL, NULL);
519         return service->plg;
520 }
521
522 CoreObject *_ps_service_ref_co_network(ps_service_t *service)
523 {
524         g_return_val_if_fail(service != NULL, NULL);
525         return service->co_network;
526 }
527
528 CoreObject *_ps_service_ref_co_ps(ps_service_t *service)
529 {
530         g_return_val_if_fail(service != NULL, NULL);
531         return service->co_ps;
532 }
533
534 ps_modem_t *_ps_service_ref_modem(ps_service_t *service)
535 {
536         g_return_val_if_fail(service != NULL, NULL);
537         return service->p_modem;
538 }
539
540 gboolean _ps_service_set_context_devinfo(ps_service_t *service, struct tnoti_ps_pdp_ipconfiguration *devinfo)
541 {
542         GSList *co_contexts = NULL;
543         CoreObject *co_context = NULL;
544
545         g_return_val_if_fail(service != NULL, FALSE);
546         g_return_val_if_fail(devinfo != NULL, FALSE);
547
548         ps_info_ex_svc(service, "set context device info for cid %d", devinfo->context_id);
549
550         co_contexts = tcore_ps_ref_context_by_id(_ps_service_ref_co_ps(service), devinfo->context_id);
551         if (!co_contexts) {
552                 ps_err_ex_svc(service, "fail to ref context by cid.");
553                 return FALSE;
554         }
555
556         while (co_contexts) {
557                 ps_modem_t *modem = NULL;
558                 int role = CONTEXT_ROLE_UNKNOWN;
559
560                 co_context = co_contexts->data;
561                 if (!co_context) {
562                         co_contexts = co_contexts->next;
563                         continue;
564                 }
565
566                 /*TEMP*/
567                 role = tcore_context_get_role(co_context);
568                 modem = _ps_service_ref_modem(service);
569                 if (g_strcmp0(modem->operator, "45005") == 0 && role == CONTEXT_ROLE_IMS) {
570                         ps_dbg_ex_svc(service, "SKT IMS PDN");
571                         /*IPv4*/
572                         if (devinfo->pcscf_ipv4_count == 0) {
573                                 char ipv4[16];
574                                 snprintf(ipv4, 16, "%d.%d.%d.%d",
575                                          devinfo->ip_address[0], devinfo->ip_address[1],
576                                          devinfo->ip_address[2], devinfo->ip_address[3]);
577                                 if (!g_str_equal(ipv4, "0.0.0.0")) {
578                                         devinfo->pcscf_ipv4 = g_try_malloc0(sizeof(char *));
579                                         if (devinfo->pcscf_ipv4 == NULL)
580                                                 continue;
581                                         devinfo->pcscf_ipv4[0] = g_strdup("220.103.220.10");
582                                         devinfo->pcscf_ipv4_count = 1;
583                                 }
584                         }
585                         /*IPv6*/
586                         if (devinfo->pcscf_ipv6_count == 0) {
587                                 if (devinfo->ipv6_address != NULL) {
588                                         devinfo->pcscf_ipv6 = g_try_malloc0(sizeof(char *));
589                                         if (devinfo->pcscf_ipv6 == NULL)
590                                                 continue;
591                                         devinfo->pcscf_ipv6[0] = g_strdup("2001:2d8:00e0:0220::10");
592                                         devinfo->pcscf_ipv6_count = 1;
593                                 }
594                         }
595                 }
596
597                 tcore_context_set_devinfo(co_context, devinfo);
598
599                 co_contexts = co_contexts->next;
600         }
601
602         return TRUE;
603 }
604
605 gboolean _ps_service_set_context_bearerinfo(ps_service_t *service, struct tnoti_ps_dedicated_bearer_info *bearer_info)
606 {
607         GSList *co_contexts = NULL;
608         CoreObject *co_context = NULL;
609
610         g_return_val_if_fail(service != NULL, FALSE);
611         g_return_val_if_fail(bearer_info != NULL, FALSE);
612
613         ps_info_ex_svc(service, "set context bearer info");
614
615         co_contexts = tcore_ps_ref_context_by_id(_ps_service_ref_co_ps(service), bearer_info->primary_context_id);
616         if (!co_contexts) {
617                 ps_err_ex_svc(service, "fail to ref context by cid.");
618                 return FALSE;
619         }
620
621         while (co_contexts) {
622                 unsigned int index;
623
624                 co_context = co_contexts->data;
625                 if (!co_context) {
626                         co_contexts = co_contexts->next;
627                         continue;
628                 }
629
630                 for (index = 0; index < g_slist_length(service->contexts); index++) {
631                         ps_context_t *context = g_slist_nth_data(service->contexts, index);
632                         if (co_context == _ps_context_ref_co_context(context)) {
633                                 _ps_context_set_bearer_info(context, bearer_info);
634                                 break;
635                         }
636                 }
637
638                 co_contexts = co_contexts->next;
639         }
640
641         return TRUE;
642 }
643
644 int _ps_service_define_context(ps_service_t *service, ps_context_t *context)
645 {
646         CoreObject *co_context = NULL;
647         gboolean b_connect = TRUE;
648
649         g_return_val_if_fail(service != NULL, FALSE);
650         ps_dbg_ex_svc(service, "define context(%p)", context);
651
652         b_connect = __ps_service_check_connection_option(service, context);
653         if (!b_connect)
654                 return TCORE_RETURN_EPERM;
655
656         return tcore_ps_define_context(_ps_service_ref_co_ps(service), co_context, NULL);
657 }
658
659 int _ps_service_activate_context(ps_service_t *service, ps_context_t *context)
660 {
661         ps_modem_t *modem = NULL;
662         ps_master_t *master = NULL;
663         CoreObject *co_context = NULL;
664         gboolean b_connect = TRUE;
665         gboolean ps_defined;
666         int ret = TCORE_RETURN_SUCCESS;
667         int default_data_subs = 1;
668         ps_subs_type subs_type = 1;
669         CoreObject *co_ps = _ps_service_ref_co_ps(service);
670
671         g_return_val_if_fail(service != NULL, FALSE);
672
673         ps_dbg_ex_svc(service, "activate context(%p)", context);
674
675         modem = _ps_service_ref_modem(service);
676         master = _ps_modem_ref_master(modem);
677         ps_defined = _ps_context_get_ps_defined(context);
678         co_context = _ps_context_ref_co_context(context);
679 #ifdef TIZEN_SUPPORT_REQUEST_HOOK_PDP_CONTROL
680         if (modem->hook_flag != PS_NO_PENDING_REQUEST) {
681                 ps_info_ex_svc(service, "Pending request present in queue with flag %x", modem->hook_flag);
682                 ret = TCORE_RETURN_FAILURE;
683                 goto EXIT;
684         }
685 #endif
686         /* Check for default data subscription value if matchs for modem then only activate */
687         subs_type = _ps_modem_get_subs_type(modem);
688         default_data_subs = _ps_master_get_storage_value_int(master, STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT);
689         if ((default_data_subs != -1) && (default_data_subs != (int)subs_type)) {
690                 ps_warn_ex_svc(service, "activation  for only [SIM%d] selected by Setting", default_data_subs + 1);
691                 ret = TCORE_RETURN_FAILURE;
692                 goto EXIT;
693         }
694
695         b_connect = __ps_service_check_connection_option(service, context);
696         if (!b_connect) {
697                 ret = TCORE_RETURN_EPERM;
698                 goto EXIT;
699         }
700
701 #ifdef TIZEN_SUPPORT_VOLTE
702         if (CONTEXT_ROLE_IMS == tcore_context_get_role(co_context)) {
703                 enum telephony_network_service_type svc_type;
704                 CoreObject *co_network = _ps_service_ref_co_network(service);
705                 tcore_network_get_service_type(co_network, &svc_type);
706
707                 if (svc_type != NETWORK_SERVICE_TYPE_LTE) {
708                         ps_warn_ex_svc(service, "IMS PDN is not allowed in %d network", svc_type);
709                         goto EXIT;
710                 }
711                 tcore_network_set_ims_on_deregistering(_ps_service_ref_co_network(service), FALSE);
712         }
713 #endif
714
715         if (!ps_defined) {
716                 ps_info_ex_svc(service, "pdp profile is not defined yet, define first. ");
717                 ret = tcore_ps_define_context(co_ps, co_context, NULL);
718         } else {
719                 ps_info_ex_svc(service, "pdp profile is defined, activate context. ");
720                 ret = tcore_ps_activate_context(co_ps, co_context, NULL);
721         }
722  EXIT:
723         if (ret != TCORE_RETURN_SUCCESS) {
724                 if (ps_defined) {
725                         /*
726                          * CONTEXT_STATE_ACTIVATING : Never be happen.
727                          * CONTEXT_STATE_ACTIVATED : Never be happen.
728                          * CONTEXT_STATE_DEACTIVATING: Do not clear resources.
729                          */
730                         if (CONTEXT_STATE_DEACTIVATED == tcore_context_get_state(co_context)) {
731                                 ps_warn_ex_svc(service, "fail to activate context after PDP define complete, clear resources.");
732                                 _ps_context_set_ps_defined(context, FALSE);
733                                 tcore_ps_clear_context_id(co_ps, co_context);
734                         } else {
735                                 ps_err_ex_svc(service, "invalid context state.");
736                         }
737                 }
738         }
739         return ret;
740 }
741
742 int _ps_service_deactivate_context(ps_service_t *service, ps_context_t *context)
743 {
744 #ifdef TIZEN_SUPPORT_VOLTE
745         enum co_context_role role = CONTEXT_ROLE_UNKNOWN;
746         ps_modem_t *modem = NULL;
747         gboolean ims_registered = FALSE, ims_deregistering = FALSE;
748         struct tel_network_ims_registration_info ims_reg_info = { 0, };
749 #endif
750         CoreObject *co_context = _ps_context_ref_co_context(context);
751         CoreObject *co_ps = _ps_service_ref_co_ps(service);
752         TReturn ret = TCORE_RETURN_SUCCESS;
753
754         g_return_val_if_fail(service != NULL, FALSE);
755         ps_info_ex_svc(service, "deactivate context(%p)", context);
756
757 #ifdef TIZEN_SUPPORT_VOLTE
758         role = tcore_context_get_role(co_context);
759         modem = _ps_service_ref_modem(service);
760
761         tcore_network_get_ims_reg_info(_ps_service_ref_co_network(service), &ims_reg_info);
762         if (ims_reg_info.feature_mask & NET_IMS_MASK_REGI)
763                 ims_registered = TRUE;
764
765         ims_deregistering = tcore_network_get_ims_on_deregistering(_ps_service_ref_co_network(service));
766
767         ps_dbg_ex_svc(service, "role(%d), ims_registered(%d), ims_deregistering(%d), context_state(%d), flight_mode(%d)",
768                       role, ims_registered, ims_deregistering, tcore_context_get_state(co_context), modem->flight_mode);
769
770         if (!modem->flight_mode) {
771                 if (role == CONTEXT_ROLE_IMS && (tcore_context_get_state(co_context) == CONTEXT_STATE_ACTIVATED) && ims_registered && !ims_deregistering)
772                         if (_ps_context_deregister_ims(context) == TCORE_RETURN_SUCCESS)
773                                 return TCORE_RETURN_SUCCESS;
774
775                 ret = tcore_ps_deactivate_context(co_ps, co_context, NULL);
776         }
777 #else
778         ret = tcore_ps_deactivate_context(co_ps, co_context, NULL);
779 #endif
780         if (ret == TCORE_RETURN_PS_DEACTIVATED) {
781                         ps_info_ex_svc(service, "context is deactivated");
782                 return TCORE_RETURN_SUCCESS;
783         }
784         return ret;
785 }
786
787 void _ps_service_set_retry_timeout_value(ps_context_t *context, guint value)
788 {
789         ps_service_t *service = _ps_context_ref_service(context);
790         g_return_if_fail(context != NULL);
791
792         if (context->connection_timeout != value) {
793                 context->connection_timeout = value;
794                 ps_dbg_ex_svc(service, "current timeout (%d)", context->connection_timeout);
795         }
796 }
797
798 void _ps_service_connection_timer(ps_service_t *service, ps_context_t *context)
799 {
800         int result = 0;
801         gboolean f_awo = FALSE;
802         gboolean ims_activation_requested = FALSE;
803         int ret;
804         CoreObject *co_context = _ps_context_ref_co_context(context);
805
806         g_return_if_fail(service != NULL);
807
808         f_awo = _ps_context_get_alwayson_enable(context);
809         ims_activation_requested = _ps_service_get_ims_activation_requested(service);
810         if (!f_awo && (!ims_activation_requested && (CONTEXT_ROLE_IMS != tcore_context_get_role(co_context))))
811                 return;
812
813         if (context->timer_src > 0) {
814                 ps_info_ex_svc(service, "remove connection retry timer (%d)", context->timer_src);
815                 alarmmgr_remove_alarm(context->timer_src);
816                 context->timer_src = 0;
817         }
818
819         /* Acquire lock */
820         ret = device_power_request_lock(POWER_LOCK_CPU, 0);
821         if (ret < 0)
822                 ps_err_ex_svc(service, "ret : (0x%x)", ret);
823
824         result = alarmmgr_add_alarm_withcb(ALARM_TYPE_VOLATILE, (time_t)(context->connection_timeout),
825                                            0, __ps_service_connetion_timeout_handler, context, &(context->timer_src));
826
827         /* Release lock */
828         ret = device_power_release_lock(POWER_LOCK_CPU);
829         if (ret < 0)
830                 ps_err_ex_svc(service, "ret : (0x%x)", ret);
831
832         if (result != ALARMMGR_RESULT_SUCCESS) {
833                 ps_err_ex_svc(service, "Failed to add alarm(%d)", result);
834                 return;
835         }
836
837         ps_info_ex_svc(service, "cellular service timer started timer src(%d), timeout(%d)",
838                        context->timer_src, context->connection_timeout);
839         context->connection_timeout = (context->connection_timeout) * 2;
840         if (context->connection_timeout >= PDP_RETRY_TIME_OUT_MAX)
841                 context->connection_timeout = PDP_RETRY_TIME_OUT_MAX;
842 }
843
844 void _ps_service_reset_connection_timer(ps_context_t *context)
845 {
846         gboolean f_awo = FALSE;
847 #ifdef PREPAID_SIM_APN_SUPPORT
848         gboolean p_awo = FALSE;
849 #endif
850         gboolean ims_activation_requested = FALSE;
851         ps_service_t *service = NULL;
852
853         f_awo = _ps_context_get_alwayson_enable(context);
854         service = _ps_context_ref_service(context);
855         ims_activation_requested = _ps_service_get_ims_activation_requested(service);
856         if (!f_awo && (!ims_activation_requested && (CONTEXT_ROLE_IMS != tcore_context_get_role(_ps_context_ref_co_context(context)))))
857                 return;
858
859 #ifdef PREPAID_SIM_APN_SUPPORT
860         p_awo = _ps_context_get_prepaid_alwayson_enable(context);
861         if (!f_awo && !p_awo)
862                 return;
863 #endif
864
865         service = _ps_context_ref_service(context);
866         if (service == NULL) {
867                 err("service is NULL!!!");
868                 return;
869         }
870         context->connection_timeout = PDP_RETRY_TIME_OUT_DEFAULT;
871
872         if (context->timer_src > 0) {
873                 ps_warn_ex_svc(service, "remove connection retry timer (%d)", context->timer_src);
874                 alarmmgr_remove_alarm(context->timer_src);
875                 context->timer_src = 0;
876         }
877 }
878
879 gboolean _ps_service_unref_context(ps_service_t *service, ps_context_t *context)
880 {
881         ps_modem_t *modem = _ps_service_ref_modem(service);
882
883         g_return_val_if_fail(service != NULL, FALSE);
884         g_return_val_if_fail(modem != NULL, FALSE);
885         g_return_val_if_fail(context != NULL, FALSE);
886         g_return_val_if_fail(context->path != NULL, FALSE);
887
888         ps_dbg_ex_modem(modem, "service unref context (%s)", context->path);
889
890         _ps_service_deactivate_context(service, context);
891         /* remove context from the list (modem, service) */
892         modem->contexts = g_slist_remove(modem->contexts, context);
893         ps_service_emit_context_removed_signal(service, context);
894         return TRUE;
895 }
896
897 void _ps_service_remove_contexts(ps_service_t *service)
898 {
899         unsigned int index;
900         guint count;
901
902         g_return_if_fail(service != NULL);
903         count = g_slist_length(service->contexts);
904         ps_info_ex_svc(service, "service remove all contexts: count(%d)", count);
905
906         for (index = 0; index < count; index++) {
907                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
908                 ps_dbg_ex_svc(service, "path(%s), context(%p)", _ps_context_ref_path(context), context);
909                 _ps_service_unref_context(service, context);
910                 _ps_context_remove_context(context);
911         }
912         g_slist_free(service->contexts);
913         service->contexts = NULL;
914 }
915
916 void _ps_service_disconnect_contexts(ps_service_t *service)
917 {
918         unsigned int index;
919
920         g_return_if_fail(service != NULL);
921         ps_info_ex_svc(service, "service disconnect all contexts");
922
923         for (index = 0; index < g_slist_length(service->contexts); index++) {
924                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
925                 _ps_service_reset_connection_timer(context);
926                 _ps_service_deactivate_context(service, context);
927         }
928 }
929
930 void _ps_service_disconnect_internet_mms_tethering_contexts(ps_service_t *service)
931 {
932         unsigned int index;
933
934         g_return_if_fail(service != NULL);
935         ps_info_ex_svc(service, "Service disconnect Internet/MMS/Tethering contexts");
936
937         for (index = 0; index < g_slist_length(service->contexts); index++) {
938                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
939                 CoreObject *co_context = _ps_context_ref_co_context(context);
940                 enum co_context_role role = tcore_context_get_role(co_context);
941
942                 /*
943                  * Deactivate following type of contexts -
944                  *      - INTERNET
945                  *      - INTERNET_PREPAID
946                  *      - MMS
947                  *      - MMS_PREPAID
948                  *      - TETHERING
949                  */
950                 switch (role) {
951                 case CONTEXT_ROLE_INTERNET:
952                 case CONTEXT_ROLE_MMS:
953                 case CONTEXT_ROLE_PREPAID_INTERNET:
954                 case CONTEXT_ROLE_PREPAID_MMS:
955                 case CONTEXT_ROLE_TETHERING:
956                         _ps_service_reset_connection_timer(context);
957                         _ps_service_deactivate_context(service, context);
958                         break;
959
960                 default:
961                         ps_warn_ex_svc(service, "Need not deactivate for %d PDN type", role);
962                         continue;
963                 }
964         }
965 }
966
967 int _ps_service_connect_default_context(ps_service_t *service)
968 {
969         int rv = 0;
970         unsigned int index;
971         gboolean ims_activation_requested = FALSE;
972         gboolean reset_profile = FALSE;
973         ps_modem_t *modem = NULL;
974
975         g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
976
977         ps_dbg_ex_svc(service, "service connect default context");
978
979         modem = _ps_service_ref_modem(service);
980         reset_profile = _ps_modem_get_reset_profile(modem);
981         if (reset_profile) {
982                 ps_err_ex_svc(service, "reset_profile(%d) retun", reset_profile);
983                 return 0;
984         }
985
986         ims_activation_requested = _ps_service_get_ims_activation_requested(service);
987
988         for (index = 0; index < g_slist_length(service->contexts); index++) {
989                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
990                 gboolean f_awo = FALSE;
991
992                 f_awo = _ps_context_get_alwayson_enable(context);
993                 if (f_awo) {
994                         enum co_context_state context_state;
995
996                         /*  FIX: Kiran PLM P141111-07502 */
997                         /* _ps_service_reset_connection_timer(value); */
998                         rv = _ps_service_activate_context(service, context);
999                         context_state = tcore_context_get_state(_ps_context_ref_co_context(context));
1000                         if (context_state == CONTEXT_STATE_ACTIVATED) {
1001                                 ps_info_ex_svc(service, "context is already connected");
1002                                 _ps_context_set_connected(context, TRUE);
1003                         }
1004                         ps_info_ex_svc(service, "return rv(%d)", rv);
1005 //                      break;
1006                 }
1007
1008                 if (ims_activation_requested && (CONTEXT_ROLE_IMS == tcore_context_get_role(_ps_context_ref_co_context(context)))) {
1009                         rv = _ps_service_activate_context(service, context);
1010                         ps_info_ex_svc(service, "return rv(%d)", rv);
1011                         ims_activation_requested = FALSE;
1012                 }
1013         }
1014
1015         return rv;
1016 }
1017
1018 #ifdef PREPAID_SIM_APN_SUPPORT
1019 gboolean _ps_service_connect_last_connected_context_ex(ps_service_t *service, ps_context_t *context,
1020                                                        gboolean *defined, char *operator)
1021 {
1022         ps_modem_t *modem = NULL;
1023         ps_master_t *master = NULL;
1024         int profile_id = -1;
1025         int current_profile_id = -1;
1026         gchar *last_connected_operator = NULL;
1027         gboolean last_connected_profile = FALSE;
1028         int rv;
1029
1030         ps_info_ex_svc(service, "Entry");
1031         modem = _ps_service_ref_modem(service);
1032         master = _ps_modem_ref_master(modem);
1033         last_connected_profile = _ps_master_get_storage_value_bool(master, STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL);
1034         ps_info_ex_svc(service, "last_connected_profile [%s]", last_connected_profile ? "TRUE" : "FALSE");
1035         /* Last connected profile exist */
1036         if (last_connected_profile) {
1037                 /* Fetch last connected profile's operator */
1038                 last_connected_operator = _ps_master_get_storage_value_string(master, STORAGE_KEY_TELEPHONY_LAST_CONNECTED_CONTEXT_PLMN);
1039                 ps_info_ex_svc(service, "last_connected_operator[%s] current operator[%s]", last_connected_operator, operator);
1040
1041                 if (g_strcmp0(last_connected_operator, operator) != 0) {
1042                         /* different SIM, So reset STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL
1043                            and continue to activate default profile */
1044                         ps_info_ex_svc(service, "Different SIM, reset last connected context");
1045                         _ps_master_set_storage_value_bool(master, STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL, FALSE);
1046
1047                         /* should be freed due to dynamic memory allocated by tcore_storage_get_string() */
1048                         if (last_connected_operator) {
1049                                 free(last_connected_operator);
1050                                 last_connected_operator = NULL;
1051                         }
1052
1053                 } else {
1054                         /* Fetch last connected context profile id */
1055                         ps_info_ex_svc(service, "Fetch last connected context profile id");
1056                         profile_id = _ps_master_get_storage_value_int(master, STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID);
1057
1058                         /* Fetch current context profile id */
1059                         current_profile_id = _ps_context_get_profile_id(context);
1060                         ps_info_ex_svc(service, "last connected context profile id[%d], current context profile id[%d]", profile_id, current_profile_id);
1061
1062                         /* should be freed due to dynamic memory allocated by tcore_storage_get_string() */
1063                         if (last_connected_operator) {
1064                                 free(last_connected_operator);
1065                                 last_connected_operator = NULL;
1066                         }
1067
1068                         if (profile_id != current_profile_id) {
1069                                 ps_info_ex_svc(service, "Current context profile id and last connected profile does not match ..");
1070                                 /* Current context profile id and last connected profile does not match
1071                                    Check for next available profile */
1072                                 return TRUE;
1073                         } else {
1074                                 /* activate last connected context */
1075                                 ps_info_ex_svc(service, "activate last connected context");
1076                                 rv = _ps_service_define_context(service, context);
1077                                 ps_info_ex_svc(service, "return rv(%d)", rv);
1078                                 if (defined)
1079                                         *defined = TRUE;
1080                                 return TRUE;
1081                         }
1082                 }
1083         } else {
1084                 ps_info_ex_svc(service, "There is no last connected profile");
1085         }
1086
1087         return FALSE;
1088 }
1089
1090 gboolean _ps_service_connect_last_connected_context(ps_service_t *service)
1091 {
1092         gboolean ret;
1093         gboolean defined = FALSE;
1094         gchar *operator = NULL;
1095         unsigned int index;
1096
1097         g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
1098         operator = _ps_modem_ref_operator(_ps_service_ref_modem(service));
1099
1100         for (index = 0; index < g_slist_length(service->contexts); index++) {
1101                 ps_context_t *ps_context = g_slist_nth_data(service->contexts, index);
1102                 ret = _ps_service_connect_last_connected_context_ex(service, ps_context, &defined, operator);
1103                 ps_info_ex_svc(service, "ret[%d]", ret);
1104                 if (defined == TRUE) {
1105                         ps_info_ex_svc(service, "context[%p]", ps_context);
1106                         return defined;
1107                 }
1108         }
1109         return FALSE;
1110 }
1111
1112 int _ps_service_connect_default_prepaid_context(ps_service_t *service)
1113 {
1114         int rv = 0;
1115         unsigned int index;
1116
1117         g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
1118
1119         for (index = 0; index < g_slist_length(service->contexts); index++) {
1120                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
1121                 gboolean f_awo = FALSE;
1122                 f_awo = _ps_context_get_prepaid_alwayson_enable(context);
1123                 if (f_awo) {
1124                         _ps_service_reset_connection_timer(context);
1125                         rv = _ps_service_activate_context(service, context);
1126                         ps_info_ex_svc(service, "return rv(%d)", rv);
1127                         break;
1128                 }
1129         }
1130         ps_info_ex_svc(service, "Exit - rv[%d]", rv);
1131         return rv;
1132 }
1133
1134 ps_context_t *_ps_service_return_context_by_cid(ps_service_t *service, int context_id)
1135 {
1136         unsigned int index;
1137
1138         g_return_val_if_fail(service != NULL, NULL);
1139
1140         for (index = 0; index < g_slist_length(service->contexts); index++) {
1141                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
1142                 CoreObject *co_context = _ps_context_ref_co_context(context);
1143                 int tmp_cid = tcore_context_get_id(co_context);
1144
1145                 if (tmp_cid != context_id)
1146                         continue;
1147
1148                 return context;
1149         }
1150         return NULL;
1151 }
1152 #endif
1153
1154 ps_context_t *_ps_service_return_default_context(ps_service_t *service, int svc_cat_id)
1155 {
1156         unsigned int index;
1157
1158         g_return_val_if_fail(service != NULL, NULL);
1159
1160         for (index = 0; index < g_slist_length(service->contexts); index++) {
1161                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
1162                 gboolean b_default = FALSE;
1163                 b_default = _ps_context_get_default_context(context, svc_cat_id);
1164
1165                 if (b_default)
1166                         return context;
1167         }
1168
1169         return NULL;
1170 }
1171
1172 int _ps_service_update_roaming_apn(ps_service_t *service)
1173 {
1174         int rv = 0;
1175         ps_modem_t *modem = _ps_service_ref_modem(service);
1176         gboolean p_from = FALSE; /* default <FLASE> : Home newtwork */
1177         GSList *contexts = NULL;
1178
1179         g_return_val_if_fail(service != NULL, TCORE_RETURN_FAILURE);
1180         g_return_val_if_fail(modem != NULL, TCORE_RETURN_FAILURE);
1181
1182         ps_dbg_ex_svc(service, "roaming status: %d", service->roaming);
1183         /* 1) Remove all contexts
1184          * 2) Load Home/Roaming profiles from database.
1185
1186          * Home -> Roaming network:
1187          * 3-2) If Any roaming profile is not provided by service provider,
1188          *      load Home profiles from database.
1189          */
1190
1191         p_from = _ps_modem_get_roaming_apn_support(modem);
1192         if (p_from) {
1193                 _ps_service_remove_contexts(service);
1194                 contexts = _ps_context_create_hashtable((gpointer)modem, service->roaming);
1195                 if (contexts != NULL) {
1196                         rv = _ps_service_set_number_of_pdn_cnt(service, modem->operator);
1197                         rv = _ps_service_ref_contexts(service, contexts, modem->operator);
1198                 }
1199         } else {
1200                 /* Iterate through each context and check home and roaming pdp protocol type.
1201                   * If its same NO need to deactivate context.
1202                   * Otherwise de-activate context as home and roam pdp protocol type mismatched
1203                   */
1204                 enum co_context_type home_pdp_protocol, roam_pdp_protocol;
1205                 guint index;
1206
1207                 for (index = 0; index < g_slist_length(service->contexts); index++) {
1208                         ps_context_t *context = g_slist_nth_data(service->contexts, index);
1209                         home_pdp_protocol = tcore_context_get_type(_ps_context_ref_co_context(context));
1210                         roam_pdp_protocol = tcore_context_get_roam_pdp_type(_ps_context_ref_co_context(context));
1211                         if (home_pdp_protocol == roam_pdp_protocol) {
1212                                 ps_dbg_ex_svc(service, "home and roam pdp protocol type matched. No need to de-activate");
1213                                 continue;
1214                         }
1215
1216                         /* De-activate context as home and roam pdp protocol type mismatched */
1217                         ps_info_ex_modem(modem, "home[%d] and roam[%d] pdp protocol type mis-matched. De-activate if context is already activated",
1218                                          home_pdp_protocol, roam_pdp_protocol);
1219                         _ps_service_reset_connection_timer(context);
1220                         _ps_service_deactivate_context(service, context);
1221                 }
1222         }
1223         dbg("rv: %d", rv);
1224         return rv;
1225 }
1226
1227 gboolean _ps_service_processing_network_event(ps_service_t *service, gboolean ps_attached, gboolean roaming)
1228 {
1229 #ifdef PREPAID_SIM_APN_SUPPORT
1230         gboolean ret = TRUE;
1231 #endif
1232         gboolean prev_roaming_status;
1233         g_return_val_if_fail(service != NULL, FALSE);
1234
1235         prev_roaming_status = _ps_service_get_roaming(service);
1236         if (__ps_service_check_is_network_in_serivce(service) != TRUE &&
1237             !_ps_modem_get_roaming_apn_support(_ps_service_ref_modem(service)))
1238                 ps_warn_ex_svc(service, "Update roaming status only in IN SRV");
1239         else
1240                 _ps_service_set_roaming(service, roaming);
1241
1242         _ps_service_set_ps_attached(service, ps_attached);
1243         _ps_update_cellular_state_key(service);
1244
1245         if (prev_roaming_status != _ps_service_get_roaming(service)) {
1246                 gboolean roaming_allowed = FALSE;
1247                 roaming_allowed = _ps_modem_get_data_roaming_allowed(_ps_service_ref_modem(service));
1248                 _ps_service_update_roaming_apn(service);
1249
1250                 if (!roaming_allowed && roaming) {
1251                         ps_info_ex_svc(service, "Roaming allowed (%d), Roaming status (%d)", roaming_allowed, roaming);
1252                         _ps_service_disconnect_contexts(service);
1253                         return TRUE;
1254                 }
1255         }
1256
1257         if (service->ps_attached) {
1258                 ps_context_t *def_context = NULL;
1259 #ifdef PREPAID_SIM_APN_SUPPORT
1260                 ret = _ps_service_connect_last_connected_context(service);
1261                 ps_dbg_ex_svc(service, "ret[%d]", ret);
1262                 if (ret == TRUE)
1263                         return TRUE; /* No need to activate default context */
1264 #endif
1265                 def_context = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
1266                 if (def_context)
1267                         _ps_context_set_alwayson_enable(def_context, TRUE);
1268                 _ps_service_connect_default_context(service);
1269         }
1270
1271         return TRUE;
1272 }
1273
1274 gboolean _ps_service_set_connected(ps_service_t *service, gpointer cstatus, gboolean enabled)
1275 {
1276         unsigned int index;
1277         gboolean def_awo = FALSE, b_def_conn = FALSE;
1278         gpointer def_conn = NULL;
1279         gpointer requested_conn = NULL;
1280 #ifdef TIZEN_SUPPORT_VOLTE
1281         gboolean def_ims_activation = FALSE;
1282         ps_modem_t *modem = _ps_service_ref_modem(service);
1283 #endif
1284         ps_master_t *master = _ps_modem_ref_master(_ps_service_ref_modem(service));
1285
1286         struct tnoti_ps_call_status *call_status = NULL;
1287
1288         call_status = (struct tnoti_ps_call_status *)cstatus;
1289
1290         if (enabled && master && master->initial_pdp_conn == FALSE) {
1291                 ps_info_ex_svc(service, "Initial PDP connection.");
1292                 master->initial_pdp_conn = TRUE;
1293         }
1294
1295         for (index = 0; index < g_slist_length(service->contexts); index++) {
1296                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
1297                 CoreObject *co_context = _ps_context_ref_co_context(context);
1298                 int tmp_cid;
1299                 gboolean b_tmp_def = FALSE;
1300                 gpointer b_user_data = NULL;
1301
1302                 tmp_cid = tcore_context_get_id(co_context);
1303                 if (tmp_cid != call_status->context_id)
1304                         continue;
1305
1306                 /* if there is default context in disconnected cid, it has to retry auto connection */
1307                 b_tmp_def = _ps_context_get_default_context(context, CONTEXT_ROLE_INTERNET);
1308                 if (!b_def_conn)
1309                         b_def_conn = b_tmp_def;
1310
1311                 /* if disconnected connection has the user data, it is a priority connection. */
1312                 b_user_data = _ps_context_get_user_data(context);
1313                 if (b_user_data) {
1314                         def_conn = context;
1315                         requested_conn = b_user_data;
1316                 }
1317
1318                 if (!enabled) {
1319                         gchar *ipv4 = NULL;
1320                         gchar *devname = NULL;
1321                         ps_info_ex_svc(service, "Reset socket connections.");
1322                         tcore_ps_clear_context_id(_ps_service_ref_co_ps(service), co_context);
1323                         ipv4 = tcore_context_get_ipv4_addr(co_context);
1324                         devname = tcore_context_get_ipv4_devname(co_context);
1325                         tcore_util_reset_ipv4_socket((const char *)devname, (const char *)ipv4);
1326                         free(ipv4);
1327                         g_free(devname);
1328                 }
1329                 _ps_context_set_connected(context, enabled);
1330         }
1331
1332         /* connect to request profile */
1333         if (!enabled && requested_conn) {
1334                 ps_info_ex_svc(service, "connect to request profile (%p)", requested_conn);
1335                 _ps_connection_hdlr(requested_conn);
1336                 _ps_service_reset_connection_timer(def_conn);
1337                 _ps_context_reset_user_data(def_conn);
1338                 return TRUE;
1339         }
1340
1341         /* default context and always on is true. - request to connect */
1342         if (!enabled) {
1343                 gint ps_mode = 0;
1344                 def_conn = _ps_service_return_default_context(service, CONTEXT_ROLE_INTERNET);
1345                 def_awo = _ps_context_get_alwayson_enable(def_conn);
1346
1347                 if (def_awo) {
1348                         /*
1349                          * In case of ME in LCD off & UPS mode.
1350                          * Do not enable PDP retry timer for default internet context.
1351                          */
1352                         ps_mode = _ps_modem_get_psmode(_ps_service_ref_modem(service));
1353                         if (ps_mode > POWER_SAVING_MODE_NORMAL && ps_mode < POWER_SAVING_MODE_WEARABLE) {
1354                                 gint pm_state = _ps_master_get_storage_value_int(master, STORAGE_KEY_PM_STATE);
1355                                 if (pm_state == 3) {
1356                                         ps_warn_ex_svc(service, "PDP retry timer is not allowed in LCD off & UPS mode.");
1357                                         return TRUE;
1358                                 }
1359                         }
1360
1361                         /* always on TRUE and default connection - NORMAL RETRY */
1362                         /* always on TRUE and no default connection - WAIT 5 Secs for retry from application */
1363                         if (b_def_conn) {
1364                                 /* retry connection */
1365                                 _ps_service_connection_timer(service, def_conn);
1366                         } else {
1367
1368                                 /* with unexpected disconnection from network/me */
1369                                 _ps_service_set_retry_timeout_value(def_conn, PDP_RETRY_TIME_OUT_DEFAULT);
1370                                 _ps_service_connection_timer(service, def_conn);
1371                         }
1372                 }
1373
1374 #ifdef TIZEN_SUPPORT_VOLTE
1375                 if (tfeature_is_supported(TFEATURE_FUNCTION_IMS_PDN_AUTO_ACTIVATE))
1376                         def_ims_activation = _ps_service_get_ims_activation_requested(service);
1377
1378                 if (def_ims_activation) {
1379                         ps_context_t *def_ims = NULL;
1380                         CoreObject *co_network = NULL;
1381                         gboolean reset_profile = FALSE;
1382                         enum telephony_network_service_type svc_type;
1383
1384                         co_network = _ps_service_ref_co_network(service);
1385                         tcore_network_get_service_type(co_network, &svc_type);
1386                         def_ims = _ps_service_return_default_context(service, CONTEXT_ROLE_IMS);
1387                         reset_profile = _ps_modem_get_reset_profile(modem);
1388
1389                         ps_dbg_ex_svc(service, "svc_type[%d], reset_profile(%d)", svc_type, reset_profile);
1390
1391                         if (def_ims && svc_type == NETWORK_SERVICE_TYPE_LTE && !reset_profile) {
1392                                 ps_info_ex_svc(service, "Continue re-try for IMS PDN");
1393                                 _ps_service_connection_timer(service, def_ims);
1394                         } else {
1395                                 ps_warn_ex_svc(service, "IMS PDN retry timer is allowed in LTE mode.");
1396                         }
1397                 }
1398 #endif
1399         }
1400
1401         /* To send deactivation request of default profile */
1402         if (enabled && requested_conn) {
1403                 ps_info_ex_svc(service, "Send deactivation to default profile and connect to request profile (%p)", requested_conn);
1404                 return FALSE;
1405         }
1406
1407         return TRUE;
1408 }
1409
1410 void _ps_service_set_ps_defined(ps_service_t *service, gboolean value, int cid)
1411 {
1412         unsigned int index;
1413
1414         g_return_if_fail(service != NULL);
1415
1416         for (index = 0; index < g_slist_length(service->contexts); index++) {
1417                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
1418                 CoreObject *co_context = _ps_context_ref_co_context(context);
1419                 CoreObject *co_ps = _ps_service_ref_co_ps(service);
1420                 unsigned char context_id = tcore_context_get_id(co_context);
1421                 int role = tcore_context_get_role(co_context);
1422                 if (context_id == cid) {
1423                         gboolean proceed_activation = TRUE;
1424
1425                         /* Check attach apn complete */
1426                         if (value && (!service->attach_apn_complete && role != CONTEXT_ROLE_IMS_EMERGENCY)) {
1427                                 ps_info_ex_svc(service, "Initial define of attach APN is complete for profile role(%d)", role);
1428                                 service->attach_apn_complete = TRUE;
1429
1430                                 if (TRUE == _ps_context_get_default_context(context, CONTEXT_ROLE_INTERNET) && service->ps_attached)
1431                                         proceed_activation = TRUE;
1432                                 else {
1433                                         proceed_activation = FALSE;
1434                                         tcore_ps_clear_context_id(co_ps, co_context);
1435                                 }
1436                         }
1437                         proceed_activation &= value;
1438
1439                         /* Set 'ps_defined' */
1440                         _ps_context_set_ps_defined(context, proceed_activation);
1441
1442                         if (proceed_activation) {
1443                                 /* Activate if define is completed */
1444                                 ps_dbg_ex_svc(service, "define is complete, activate context for cid(%d)", cid);
1445                                 if (_ps_service_activate_context(service, context) == TCORE_RETURN_SUCCESS) {
1446                                         ps_dbg_ex_svc(service, "Successful activate context");
1447                                         tcore_ps_set_cid_active(co_ps, cid, TRUE);
1448                                 }
1449                         }
1450                         break;
1451                 }
1452         }
1453
1454 }
1455
1456 gboolean _ps_service_set_ps_attached(ps_service_t *service, gboolean value)
1457 {
1458         g_return_val_if_fail(service != NULL, FALSE);
1459
1460         if (service->ps_attached != value) {
1461                 service->ps_attached = value;
1462                 ps_info_ex_svc(service, "service(%p) ps_attached(%d)", service, service->ps_attached);
1463                 ps_service_emit_property_changed_signal(service);
1464         }
1465         return TRUE;
1466 }
1467
1468 gboolean _ps_service_get_restricted(ps_service_t *service)
1469 {
1470         g_return_val_if_fail(service != NULL, FALSE);
1471         return service->restricted;
1472 }
1473
1474 gboolean _ps_service_set_restricted(ps_service_t *service, gboolean value)
1475 {
1476         g_return_val_if_fail(service != NULL, FALSE);
1477
1478         if (service->restricted != value) {
1479                 service->restricted = value;
1480                 ps_info_ex_svc(service, "service(%p) restricted(%d)", service, service->restricted);
1481                 _ps_update_cellular_state_key(service);
1482         }
1483         return TRUE;
1484 }
1485
1486 gboolean _ps_service_set_ims_activation_requested(ps_service_t *service, gboolean enabled)
1487 {
1488         g_return_val_if_fail(service != NULL, FALSE);
1489         service->ims_activation_requested = enabled;
1490         ps_info_ex_svc(service, "service (%p) ims_activation_requested (%d)", service, service->ims_activation_requested);
1491         return TRUE;
1492 }
1493
1494 gboolean _ps_service_get_ims_activation_requested(ps_service_t *service)
1495 {
1496         g_return_val_if_fail(service != NULL, FALSE);
1497         ps_info_ex_svc(service, "service (%p) ims_activation_requested (%d)", service, service->ims_activation_requested);
1498
1499         if (_ps_service_get_epdg_status(service) == TRUE)
1500                 return FALSE;
1501
1502         return service->ims_activation_requested;
1503 }
1504
1505 gboolean _ps_service_set_epdg_ip_configuration(ps_service_t *service, gint cid, char *ipv4_addr, char *ipv6_addr)
1506 {
1507         GSList *contexts = NULL;
1508         CoreObject *co_context = NULL;
1509         guint pdp_address;
1510         unsigned char ip_address[IPV4_ADDR_LEN];
1511
1512         g_return_val_if_fail(service != NULL, FALSE);
1513
1514         ps_info_ex_svc(service, "service (%p) ipv4_addr (%s) ipv6_addr (%s)", service, ipv4_addr, ipv6_addr);
1515
1516         contexts = tcore_ps_ref_context_by_id(service->co_ps, cid);
1517         while (contexts) {
1518                 co_context = contexts->data;
1519                 if (!co_context) {
1520                         contexts = contexts->next;
1521                         continue;
1522                 }
1523                 if (tcore_context_get_role(co_context) == CONTEXT_ROLE_IMS) {
1524                         if (ipv4_addr) {
1525                                 char addr_buf[40];
1526                                 pdp_address = __ps_service_convert_ipv4_address_int(ipv4_addr);
1527                                 pdp_address = htonl(pdp_address);
1528                                 memcpy(&ip_address, &pdp_address, IPV4_ADDR_LEN);
1529                                 tcore_context_set_ipv4_addr(co_context, ip_address);
1530                                 snprintf(addr_buf, 20, "%d.%d.%d.%d", ip_address[0], ip_address[1], ip_address[2], ip_address[3]);
1531                                 ps_info_ex_svc(service, "[IPv4] IP Address: [%s]", addr_buf);
1532                         }
1533                         tcore_context_set_ipv6_addr(co_context, ipv6_addr);
1534                         break;
1535                 }
1536                 contexts = contexts->next;
1537         }
1538
1539         return TRUE;
1540 }
1541
1542 gboolean _ps_service_set_epdg_status(ps_service_t *service, gboolean available)
1543 {
1544         g_return_val_if_fail(service != NULL, FALSE);
1545         service->is_epdg_available = available;
1546         ps_info_ex_svc(service, "service (%p) available (%d) ", service, service->is_epdg_available);
1547
1548         return TRUE;
1549 }
1550
1551 gboolean _ps_service_get_epdg_status(ps_service_t *service)
1552 {
1553         g_return_val_if_fail(service != NULL, FALSE);
1554         return service->is_epdg_available;
1555 }
1556
1557 gboolean _ps_service_set_number_of_pdn_cnt(ps_service_t *service, gchar *operator)
1558 {
1559         int rv = 0;
1560         int num_of_pdn = 0;
1561         g_return_val_if_fail(service != NULL, FALSE);
1562
1563         ps_dbg_ex_svc(service, "Entered");
1564         num_of_pdn = _ps_context_get_number_of_pdn(operator, service);
1565         rv = tcore_ps_set_num_of_pdn(_ps_service_ref_co_ps(service), num_of_pdn);
1566
1567         if (rv != TCORE_RETURN_SUCCESS)
1568                 ps_err_ex_svc(service, "error to get maximum number of pdn");
1569
1570         dbg("Exiting");
1571         return TRUE;
1572 }
1573
1574 gboolean _ps_service_get_roaming(ps_service_t *service)
1575 {
1576         g_return_val_if_fail(service != NULL, FALSE);
1577         return service->roaming;
1578 }
1579
1580 gboolean _ps_service_set_roaming(ps_service_t *service, gboolean value)
1581 {
1582         g_return_val_if_fail(service != NULL, FALSE);
1583
1584         if (service->roaming != value) {
1585                 service->roaming = value;
1586                 ps_info_ex_svc(service, "service(%p) roaming(%d)", service, service->roaming);
1587                 ps_service_emit_property_changed_signal(service);
1588         }
1589
1590         return TRUE;
1591 }
1592
1593 static void _indicator_cb_dns_reply(GObject *src, GAsyncResult *res, gpointer user_data)
1594 {
1595         GList *list, *cur;
1596         GInetAddress *addr;
1597         gchar *str_addr;
1598         GError *error = NULL;
1599
1600         list = g_resolver_lookup_by_name_finish((GResolver *)src, res, &error);
1601         if (!list) {
1602                 err("fail to get dns resolving");
1603                 if (error) {
1604                         err("error:%d, %s", error->code, error->message);
1605                         g_error_free(error);
1606                 }
1607                 return;
1608         }
1609
1610         for (cur = list; cur; cur = cur->next) {
1611                 addr = cur->data;
1612                 str_addr = g_inet_address_to_string(addr);
1613                 if (!str_addr)
1614                         continue;
1615                 info("addr(%s)", str_addr);
1616
1617                 g_free(str_addr);
1618                 g_object_unref(cur->data);
1619                 break;
1620         }
1621
1622         g_object_unref(src);
1623         g_list_free(list);
1624         return;
1625 }
1626
1627 gboolean _ps_service_set_access_technology(ps_service_t *service,
1628                                            enum telephony_network_access_technology value)
1629 {
1630 #ifdef PREPAID_SIM_APN_SUPPORT
1631         gboolean ret = TRUE;
1632 #endif
1633         enum telephony_network_access_technology p_act = 0;
1634         g_return_val_if_fail(service != NULL, FALSE);
1635
1636         if (service->act != value) {
1637                 p_act = service->act;
1638                 service->act = value;
1639                 ps_info_ex_svc(service, "service(%p) P ACT(%d) Access Technology(%d)", service, p_act, service->act);
1640
1641                 if (p_act == NETWORK_ACT_LTE && (service->act >= NETWORK_ACT_GSM && service->act < NETWORK_ACT_LTE)) {
1642                         GResolver *r = NULL;
1643
1644                         ps_dbg_ex_svc(service, "send the dns pkt for keeping connection");
1645
1646                         r = g_resolver_get_default();
1647                         g_resolver_lookup_by_name_async(r, "www.tizen.org", NULL, _indicator_cb_dns_reply, NULL);
1648                 }
1649
1650                 if (service->act > NETWORK_ACT_UNKNOWN && service->act < NETWORK_ACT_NOT_SPECIFIED) {
1651                         _ps_update_cellular_state_key(service);
1652 #ifdef PREPAID_SIM_APN_SUPPORT
1653                         ret = _ps_service_connect_last_connected_context(service);
1654                         ps_info_ex_svc(service, "ret[%d]", ret);
1655                         if (ret == TRUE)
1656                                 return ret;  /* No need to activate default context */
1657 #endif
1658                         _ps_service_connect_default_context(service);
1659                 }
1660         }
1661
1662         return TRUE;
1663 }
1664
1665 enum telephony_ps_state _ps_service_check_cellular_state(ps_service_t *service)
1666 {
1667         gboolean state = FALSE;
1668         ps_modem_t *modem;
1669
1670         g_return_val_if_fail(service != NULL, TELEPHONY_PS_NO_SERVICE);
1671
1672         modem = _ps_service_ref_modem(service);
1673
1674         state = _ps_modem_get_flght_mode(modem);
1675         if (state)
1676                 return TELEPHONY_PS_FLIGHT_MODE;
1677
1678         state = _ps_modem_get_power(modem);
1679         if (!state)
1680                 return TELEPHONY_PS_NO_SERVICE;
1681
1682         state = _ps_modem_get_sim_init(modem);
1683         if (!state)
1684                 return TELEPHONY_PS_NO_SERVICE;
1685
1686         if (service->restricted)
1687                 return TELEPHONY_PS_RESTRICTED_SERVICE;
1688
1689         if (!service->ps_attached)
1690                 return TELEPHONY_PS_NO_SERVICE;
1691
1692         state = _ps_modem_get_data_allowed(modem);
1693         if (!state)
1694                 return TELEPHONY_PS_3G_OFF;
1695
1696         state = _ps_modem_get_data_roaming_allowed(modem);
1697         if (service->roaming && !state)
1698                 return TELEPHONY_PS_ROAMING_OFF;
1699
1700         return TELEPHONY_PS_ON;
1701 }
1702
1703 void _ps_service_handling_nas_timer(ps_service_t *service, gboolean state)
1704 {
1705         unsigned int index;
1706
1707         g_return_if_fail(service != NULL);
1708         ps_info_ex_svc(service, "Handleing nas timer, state(%d)", state);
1709
1710         for (index = 0; index < g_slist_length(service->contexts); index++) {
1711                 ps_context_t *context = g_slist_nth_data(service->contexts, index);
1712                 CoreObject *co_context = _ps_context_ref_co_context(context);
1713                 enum co_context_state co_state = tcore_context_get_state(co_context);
1714
1715                 if (co_state == CONTEXT_STATE_ACTIVATED) {
1716                         enum co_context_role role = tcore_context_get_role(co_context);
1717                         enum ims_data_pdn data_pdn = IMS_DATA_PDN_UNKNOWN;
1718                         enum ims_data_state data_state = IMS_DATA_STATE_RESUME;
1719                         gboolean drop_packet = FALSE;
1720
1721                         if (role == CONTEXT_ROLE_INTERNET)
1722                                 data_pdn = IMS_DATA_PDN_INTERNET;
1723                         else if (role == CONTEXT_ROLE_IMS)
1724                                 data_pdn = IMS_DATA_PDN_IMS;
1725                         else if (role == CONTEXT_ROLE_IMS_EMERGENCY)
1726                                 data_pdn = IMS_DATA_PDN_EMERGENCY;
1727                         else if (role == CONTEXT_ROLE_MMS)
1728                                 data_pdn = IMS_DATA_PDN_CBS;
1729
1730                         if (state == PS_NAS_TIMER_STATE_START) {
1731                                 data_state = IMS_DATA_STATE_SUSPEND;
1732                                 drop_packet = TRUE;
1733                         } else {
1734                                 data_state = IMS_DATA_STATE_RESUME;
1735                                 drop_packet = FALSE;
1736                         }
1737
1738                         ps_info_ex_svc(service, "co_context(%p) co_state(%d) role(%d) data_pdn(%d) data_state(%d) drop_packet(%d)",
1739                                 co_context, co_state, role, data_pdn, data_state, drop_packet);
1740
1741 /*
1742                         if (tcore_context_get_drop_packet(co_context) != drop_packet) {
1743                                 tcore_context_set_drop_packet(co_context, drop_packet);
1744                                 _ps_context_handling_nas_timer(context, drop_packet);
1745
1746                                 if (role == CONTEXT_ROLE_IMS)
1747                                         tcore_ps_set_ims_data_state(_ps_service_ref_co_ps(service), data_pdn, data_state);
1748                         }
1749 */
1750                 }
1751         }
1752 }