3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #include <sys/socket.h>
24 #include <glib/gprintf.h>
27 #include <sync_agent.h>
28 #include <plugin/plugin_slp_sysnoti_wap_push.h>
31 #include "common/dm_common_def.h"
32 #include "common/util/util.h"
33 #include "mo-handler/dm_mo_common_internal.h"
34 #include "mo-handler/dm_mo_common.h"
35 #include "dm-engine/cp/dm_cp_parser.h"
36 #include "dm-engine/cp/dm_cp_security.h"
37 #include "dm-engine/cp/dm_cp_processor.h"
39 #ifndef OMADM_AGENT_LOG
41 #define LOG_TAG "OMA_DM_CP"
44 #define IMSI_VALUE "310260487447094"
50 #define W5 "SyncML DS"
51 #define W7 "SyncML DM"
54 #define DELIMITER " : "
55 #define L_BRACKET " ["
56 #define R_BRACKET "] "
58 #define APPLICATION "Application : "
60 #define PROXY "Proxy : "
61 #define PORT "Port : "
62 #define BOOKMARK "Bookmark : " /* not used */
63 #define NO_DATA "No data "
64 #define DEFAULT_NAP_TYPE "APN : "
73 static GList *dm_cp_list = NULL;
75 static CP_ERROR _process_receieved_cp_stream(CP_TYPE cp_type, const char *msgBody, unsigned int msgSize, int ext_id);
76 static CP_ERROR __send_msg2mf(SENDMSG_TYPE send_type, void *send_msg);
77 static CP_ERROR _process_setting_oma_ds(DM_CP * dm_cp);
78 static CP_ERROR _process_setting_oma_dm(DM_CP * dm_cp);
80 static char __char2hex(char ch);
81 static char *_get_netpin_key(int *key_len);
82 static int __make_view_message(char **msgData, DM_CP * dm_cp);
84 CP_ERROR process_Recieved_CP_WBXML(const char *msgBody, unsigned int msgSize, int ext_id)
88 retvm_if((msgBody) == NULL, CP_ERROR_FAIL, "msgBody is NULL!!");
90 CP_ERROR ret = CP_ERROR_SUCCESS;
92 unsigned int wsp_header_size = (unsigned char)msgBody[2];
94 _DEBUG_INFO("wsp_header_size : %u", wsp_header_size);
96 unsigned int wbxml_size = msgSize - wsp_header_size;
97 _DEBUG_INFO("msgSize : %d, wbxml_size : %u", msgSize, wbxml_size);
100 * Register PIN CODE to File
102 char file_buffer[50] = { 0, };
103 snprintf(file_buffer, sizeof(file_buffer), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_SEC_FILE_NAME);
104 _DEBUG_INFO("file name : %s", file_buffer);
106 // int file_ret = sync_agent_write_file(CP_SEC_REPOSITORY_PATH, msgBody, wsp_header_size, 1, 1);
107 // int file_ret = sync_agent_write_whole_file(CP_SEC_REPOSITORY_PATH, msgBody, wsp_header_size, 1);
108 int file_ret = sync_agent_write_whole_file(file_buffer, msgBody, wsp_header_size, 1);
110 _DEBUG_INFO("Failed to repository CP PIN Info");
114 * Division CP WBXML to WSP Header
116 char *wbxml_body = (char *)calloc(wbxml_size, sizeof(char));
117 if (wbxml_body == NULL) {
118 _DEBUG_INFO("alloc fail");
121 memcpy(wbxml_body, msgBody + wsp_header_size, wbxml_size);
123 ret = _process_receieved_cp_stream(CP_TYPE_WBXML, wbxml_body, wbxml_size, ext_id);
124 _DEBUG_INFO("precess receive result : %d", ret);
132 CP_ERROR process_Recieved_CP_XML(const char *msgBody, unsigned int msgSize, int ext_id)
136 retvm_if((msgBody) == NULL, CP_ERROR_FAIL, "msgBody is NULL!!");
139 return _process_receieved_cp_stream(CP_TYPE_XML, msgBody, msgSize, ext_id);
142 CP_ERROR process_Check_Pincode(int is_initial, char *user_data, int *is_correct, int ext_id)
146 CP_ERROR ret = CP_ERROR_SUCCESS;
149 * 1. get CP header info in repository(file)
151 /*unsigned long required_length = 50;
153 unsigned long size_return = 0;
154 char *cp_pin_info = 0;
155 char *wbxml_body = 0;
156 unsigned long wbxml_size = 0;
161 char sec_file_name[50] = { 0, };
162 snprintf(sec_file_name, sizeof(sec_file_name), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_SEC_FILE_NAME);
163 _DEBUG_INFO("sec file name : %s", sec_file_name);
165 // int read_ret = sync_agent_read_file(CP_SEC_REPOSITORY_PATH, &cp_pin_info, required_length, &size_return, &isFinal);
166 // int read_ret = sync_agent_read_whole_file(CP_SEC_REPOSITORY_PATH, &cp_pin_info, &size_return);
167 int read_ret = sync_agent_read_whole_file(sec_file_name, &cp_pin_info, &size_return);
169 _DEBUG_INFO("Failed to sync_agent_read_file( CP_SEC_REPOSITORY_PATH ) !!");
170 return CP_ERROR_FAIL;
173 char wbxml_file_name[50] = { 0, };
174 snprintf(wbxml_file_name, sizeof(wbxml_file_name), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_WBXML_FILE_NAME);
175 _DEBUG_INFO("wbxml file name : %s", wbxml_file_name);
176 // read_ret = sync_agent_read_whole_file(CP_WBXML_REPOSITORY_PATH, &wbxml_body, &wbxml_size);
177 read_ret = sync_agent_read_whole_file(wbxml_file_name, &wbxml_body, &wbxml_size);
179 _DEBUG_INFO("Failed to sync_agent_read_file ( CP_WBXML_REPOSITORY_PATH ) !!");
180 return CP_ERROR_FAIL;
186 char sec = cp_pin_info[6];
189 sec_type = cp_pin_info[7];
191 _DEBUG_INFO("SEC : %u, %x, SEC_TYPE : %u, %x, %c", sec, sec, sec_type, sec_type, sec_type);
194 * Check Is Exist MAC in wbxml stream
196 int is_exist_mac = 0;
197 if (cp_pin_info[8] == CP_IS_EXIST_MAC) {
201 char mac[CP_MAC_LEN] = { 0, };
202 if (is_exist_mac != 0) {
204 for (; i < CP_MAC_LEN; i++) {
205 mac[i] = cp_pin_info[9 + i];
209 switch ((unsigned char)sec_type) {
210 case CP_SEC_TYPE_NETWPIN:
212 _DEBUG_INFO("SEC TYPE : NETWPIN");
215 temp = _get_netpin_key(&key_len);
217 _DEBUG_INFO("__get_NetPIN_key() failed !!");
222 key = (char *)calloc(key_len, sizeof(char));
224 _DEBUG_INFO("calloc failed !!");
232 memcpy(key, temp, key_len);
234 for (i = 0; i < key_len; i++) {
235 _DEBUG_INFO("key[%d] : 0x%02X", i, key[i]);
242 case CP_SEC_TYPE_USERPIN:
244 _DEBUG_INFO("SEC TYPE : USERPIN");
247 if (is_initial != 0) {
248 res = launch_oma_dm_cp_ui(1, ext_id);
250 _DEBUG_INFO("launch_oma_dm_cp_ui() fail !!");
253 _DEBUG_INFO("launch_oma_dm_cp_ui() success !!");
258 if (user_data != NULL) {
259 key_len = strlen(user_data);
261 key = (char *)calloc(key_len, sizeof(char));
263 _DEBUG_INFO("calloc failed !!");
268 strncpy(key, user_data, key_len);
269 _DEBUG_INFO("key : %s ( %d )", user_data, key_len);
271 _DEBUG_INFO("launch_oma_dm_cp_ui() fail !!");
278 case CP_SEC_TYPE_USERNETWPIN:
280 _DEBUG_INFO("SEC TYPE : USERNETWPIN");
283 if (is_initial != 0) {
284 res = launch_oma_dm_cp_ui(2, ext_id);
286 _DEBUG_INFO("launch_oma_dm_cp_ui() fail !!");
289 _DEBUG_INFO("launch_oma_dm_cp_ui() success !!");
294 /* USERNETWPIN checking logic */
295 int net_temp_len = 0;
297 net_temp = _get_netpin_key(&net_temp_len);
298 if (net_temp == NULL) {
300 _DEBUG_INFO("__get_NetPIN_key() failed !!");
304 for (i = 0; i < net_temp_len; i++) {
305 _DEBUG_INFO("net_temp[%d] : 0x%02X", i, net_temp[i]);
308 int user_data_len = strlen(user_data);
309 char *temp_user_data = (char *)calloc(user_data_len, sizeof(char));
310 if (temp_user_data == NULL) {
311 _DEBUG_INFO("calloc failed !!");
313 if (net_temp != NULL)
319 strncpy(temp_user_data, user_data, user_data_len);
320 _DEBUG_INFO("temp user data : %s", temp_user_data);
322 key_len = net_temp_len + user_data_len;
323 _DEBUG_INFO("key length : %d", key_len);
325 key = (char *)calloc(key_len, sizeof(char));
327 _DEBUG_INFO("calloc failed !!");
331 memcpy(key, net_temp, net_temp_len);
332 memcpy(key + net_temp_len, temp_user_data, user_data_len);
334 for (i = 0; i < key_len; i++) {
335 _DEBUG_INFO("key[%d] : 0x%02X", i, key[i]);
338 if (net_temp != NULL)
341 if (temp_user_data != NULL)
342 free(temp_user_data);
350 _DEBUG_INFO("start PIN checking logic !!");
352 unsigned char *hmac = sync_agent_encrypt_cryptograhic_hash_with_flags(SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_SHA1,
353 wbxml_body, wbxml_size,
355 SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUN_HMAC);
360 for (; i < 20; i++) {
361 char compare[3] = { 0, };
362 char *mac_cursor = mac + (i * 2);
363 strncpy(compare, mac_cursor, 2);
364 _DEBUG_INFO("hmac[%d] : %02X \t mac[%d, %d] : %s", i, hmac[i], i * 2, i * 2 + 1, compare);
368 for (; i < 20; i++) {
369 char data[3] = { 0, };
370 snprintf(data, 3, "%02X", hmac[i]);
372 char compare[3] = { 0, };
373 char *mac_cursor = mac + (i * 2);
374 strncpy(compare, mac_cursor, 2);
376 _DEBUG_INFO("data : %s, compare : %s ( cnt : %d )", data, compare, i);
378 if (strcasecmp(data, compare) != 0) {
379 _DEBUG_INFO("failed to compare data !!");
385 _DEBUG_INFO("end PIN checking logic !!");
391 sync_agent_free_file(&cp_pin_info);
393 if (wbxml_body != NULL)
394 sync_agent_free_file(&wbxml_body);
396 _DEBUG_INFO("End !!");
401 CP_ERROR process_Invalid_Pincode(int ext_id)
405 CP_ERROR ret = CP_ERROR_SUCCESS;
410 ret = process_Delete_CP_Data(ext_id);
411 if (ret != CP_ERROR_SUCCESS) {
412 _DEBUG_INFO("process_Delete_CP_Data() fail !!");
413 /* todo : exception handling */
415 _DEBUG_INFO("process_Delete_CP_Data() success !!");
419 * 2. send remove message to MF
422 ret = __send_msg2mf(REMOVE_MESSAGE, NULL);
425 _DEBUG_INFO("End !!");
430 CP_ERROR process_Setting_CP(int ext_id)
432 _DEBUG_INFO("Start !!");
434 CP_ERROR ret = CP_ERROR_SUCCESS;
436 unsigned long size_return = 0;
438 CP_TYPE cp_type = CP_TYPE_WBXML;
440 char type_file_name[50] = { 0, };
441 snprintf(type_file_name, sizeof(type_file_name), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_TYPE_FILE_NAME);
442 _DEBUG_INFO("type file name : %s", type_file_name);
445 // int read_ret = sync_agent_read_whole_file(CP_TYPE_REPOSITORY_PATH, &type, &size_return);
446 int read_ret = sync_agent_read_whole_file(type_file_name, &type, &size_return);
448 _DEBUG_INFO("Failed to sync_agent_read_file() : %s", type_file_name);
449 return CP_ERROR_FAIL;
452 if (strcmp("1", type) == 0) {
453 cp_type = CP_TYPE_XML;
454 } else if (strcmp("2", type) == 0) {
455 cp_type = CP_TYPE_WBXML;
457 cp_type = CP_TYPE_NONE;
460 char wbxml_file_name[50] = { 0, };
461 snprintf(wbxml_file_name, sizeof(wbxml_file_name), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_WBXML_FILE_NAME);
462 _DEBUG_INFO("wbxml file name : %s", wbxml_file_name);
465 // read_ret = sync_agent_read_whole_file(CP_WBXML_REPOSITORY_PATH, &cp_body, &size_return);
466 read_ret = sync_agent_read_whole_file(wbxml_file_name, &cp_body, &size_return);
468 _DEBUG_INFO("Failed to sync_agent_read_file() : %s", wbxml_file_name);
469 return CP_ERROR_FAIL;
472 // * Parse recieved CP to sturct DM_CP
474 // dm_cp = parsing_cp_stream(cp_type, cp_body, size_return);
478 for (iter = dm_cp_list; iter != 0; iter = g_list_next(iter)) {
480 if (iter->data != 0) {
481 if (((CP_Data *) (iter->data))->ext_id == ext_id) {
482 dm_cp = ((CP_Data *) (iter->data))->dm_cp;
489 /* checking app id for multiple app's */
490 if (dm_cp->applications->app_ID != NULL) {
491 if (strcmp(dm_cp->applications->app_ID, "w2") == 0) {
492 _DEBUG_INFO("app id : %s", W2);
495 * ret = __process_Setting_Browser(dm_cp);
497 } else if (strcmp(dm_cp->applications->app_ID, "w4") == 0) {
498 _DEBUG_INFO("app id : %s", W4);
501 * ret = __process_Setting_MMS(dm_cp);
503 } else if (strcmp(dm_cp->applications->app_ID, "w5") == 0) {
504 _DEBUG_INFO("app id : %s", W5);
505 ret = _process_setting_oma_ds(dm_cp);
506 if (ret != CP_ERROR_SUCCESS) {
507 _DEBUG_INFO("__process_Setting_OMA_DS() failed !!");
508 return CP_ERROR_FAIL;
510 _DEBUG_INFO("__process_Setting_OMA_DS() success !!");
512 } else if (strcmp(dm_cp->applications->app_ID, "w7") == 0) {
513 _DEBUG_INFO("app id : %s", W7);
514 ret = _process_setting_oma_dm(dm_cp);
515 if (ret != CP_ERROR_SUCCESS) {
516 _DEBUG_INFO("__process_Setting_OMA_DM() failed !!");
517 return CP_ERROR_FAIL;
519 _DEBUG_INFO("__process_Setting_OMA_DM() success !!");
521 } else if (strcmp(dm_cp->applications->app_ID, "wA") == 0) {
522 _DEBUG_INFO("app id : %s", WA);
525 * ret = __process_Setting_IM_N_PS(dm_cp);
528 _DEBUG_INFO("app id : undefined !!");
532 _DEBUG_INFO("not exist 'CP_Data' for ext_id : %d", ext_id);
533 return CP_ERROR_FAIL;
536 _DEBUG_INFO("End !!");
541 CP_ERROR process_Delete_All_CP_Data()
543 _DEBUG_INFO("Start !!");
545 CP_ERROR ret = CP_ERROR_SUCCESS;
547 /* delete registered all CP data */
549 for (iter = dm_cp_list; iter != 0;) {
550 if (iter->data != 0) {
551 CP_Data *temp = (CP_Data *) (iter->data);
552 char folder_name[50] = { 0, };
553 snprintf(folder_name, sizeof(folder_name), "%s/%d", CP_DATA_REPOSITORY_PATH, ((CP_Data *) (iter->data))->ext_id);
554 _DEBUG_INFO("folder name : %s", folder_name);
556 int file_ret = sync_agent_delete_directory(folder_name, TRUE);
558 _DEBUG_INFO("sync_agent_delete_directory( folder : %s ) failed !!", folder_name);
559 return CP_ERROR_FAIL;
562 dm_cp_list = g_list_remove(dm_cp_list, iter->data);
563 iter = g_list_next(iter);
565 if (temp->dm_cp != 0)
571 if (g_list_length(dm_cp_list) == 0) {
572 _DEBUG_INFO("dm_cp_list length : 0 !!");
573 g_list_free(dm_cp_list);
577 _DEBUG_INFO("End !!");
582 CP_ERROR process_Delete_CP_Data(int ext_id)
584 _DEBUG_INFO("Start !!");
586 CP_ERROR ret = CP_ERROR_SUCCESS;
590 for (iter = dm_cp_list; iter != 0; iter = g_list_next(iter)) {
591 if (iter->data != 0) {
592 if (((CP_Data *) (iter->data))->ext_id == ext_id) {
593 temp = (CP_Data *) (iter->data);
594 dm_cp_list = g_list_remove(dm_cp_list, iter->data);
595 if (temp->dm_cp != 0)
603 if (g_list_length(dm_cp_list) == 0) {
604 g_list_free(dm_cp_list);
608 char folder_name[50] = { 0, };
609 snprintf(folder_name, sizeof(folder_name), "%s/%d", CP_DATA_REPOSITORY_PATH, ext_id);
610 _DEBUG_INFO("folder name : %s", folder_name);
612 int file_ret = sync_agent_delete_directory(folder_name, TRUE);
614 _DEBUG_INFO("sync_agent_delete_directory( folder : %s ) failed !!", folder_name);
615 return CP_ERROR_FAIL;
618 _DEBUG_INFO("End !!");
623 void process_Set_msgId(int msgId)
625 _DEBUG_INFO("Start !!");
628 _DEBUG_INFO("g_msgId : %d", g_msgId);
630 _DEBUG_INFO("End !!");
633 /**************************** Impl static function *************************/
635 static CP_ERROR _process_receieved_cp_stream(CP_TYPE cp_type, const char *msgBody, unsigned int msgSize, int ext_id)
638 CP_ERROR ret = CP_ERROR_SUCCESS;
640 retvm_if((msgBody) == NULL, CP_ERROR_FAIL, "msgBody is NULL!!");
643 if (cp_type == CP_TYPE_XML) {
645 } else if (cp_type == CP_TYPE_WBXML) {
649 char type_file_name[50] = { 0, };
650 snprintf(type_file_name, sizeof(type_file_name), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_TYPE_FILE_NAME);
651 _DEBUG_TRACE("type file name : %s", type_file_name);
653 // int file_ret = sync_agent_write_file(CP_TYPE_REPOSITORY_PATH, type, 1, 1, 1);
654 // int file_ret = sync_agent_write_whole_file(CP_TYPE_REPOSITORY_PATH, type, 1, 1);
655 int file_ret = sync_agent_write_whole_file(type_file_name, type, 1, 1);
657 _DEBUG_TRACE("Failed to repository CP Type");
659 return CP_ERROR_FAIL;
663 * 3. Registry (DM_CP) to storage
665 char wbxml_file_name[50] = { 0, };
666 snprintf(wbxml_file_name, sizeof(wbxml_file_name), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_WBXML_FILE_NAME);
667 _DEBUG_TRACE("wbxml file name : %s", wbxml_file_name);
668 // file_ret = sync_agent_write_file(CP_WBXML_REPOSITORY_PATH, msgBody, msgSize, 1, 1);
669 // file_ret = sync_agent_write_whole_file(CP_WBXML_REPOSITORY_PATH, msgBody, msgSize, 1);
670 file_ret = sync_agent_write_whole_file(wbxml_file_name, msgBody, msgSize, 1);
672 _DEBUG_TRACE("Failed to repository CP Body");
674 return CP_ERROR_FAIL;
678 * 3. Handling Overwrite
680 CP_Data *dm_cp_data = (CP_Data *) calloc(1, sizeof(CP_Data));
681 if (dm_cp_data == NULL) {
682 _DEBUG_TRACE("CP_Data calloc failed !!");
684 return CP_ERROR_FAIL;
687 dm_cp_data->ext_id = ext_id;
689 * Parse recieved CP to sturct DM_CP
691 // dm_cp = parsing_cp_stream(cp_type, msgBody, msgSize);
693 // _DEBUG_TRACE("parsing_cp_stream() failed !!");
694 // /* todo : exception handling */
695 // return CP_ERROR_FAIL;
698 dm_cp_data->dm_cp = parsing_cp_stream(cp_type, msgBody, msgSize);
699 if (dm_cp_data->dm_cp == 0) {
700 _DEBUG_TRACE("parsing_cp_stream() failed !!");
701 /* todo : exception handling */
703 return CP_ERROR_FAIL;
706 dm_cp_list = g_list_append(dm_cp_list, dm_cp_data);
709 * 4. Interact Msg F/W
712 pmci_san_message_s *send_msg = (pmci_san_message_s *) calloc(1, sizeof(pmci_san_message_s));
713 if (send_msg == NULL) {
714 _DEBUG_TRACE("calloc fail !!");
716 return CP_ERROR_FAIL;
719 send_msg->ext_id = ext_id;
720 // send_msg->ext_id = 11; // ?? : temp setting value? unique management (id_provider available?) todo??
721 // send_msg->pin_code = pin_code; // PIN code
722 // char *msgData = "SYNCML";
723 char *msgData = NULL;
724 msgData = (char *)calloc(MSG_SIZE, sizeof(char));
726 if (msgData == NULL) {
727 _DEBUG_TRACE("calloc failed !!");
729 return CP_ERROR_FAIL;
732 int err = __make_view_message(&msgData, dm_cp_data->dm_cp);
734 _DEBUG_TRACE("__make_view_message() failed !!");
740 return CP_ERROR_FAIL;
743 _DEBUG_TRACE("__make_view_message() success !!");
744 _DEBUG_TRACE("msgData : %s", msgData);
747 // char *msgData = "Configuration message \n Application : Browser \n Proxy : wap_proxy \n Port : 9201 \n Received date : 17/04/2012";
749 send_msg->msg_data = strdup(msgData); // message that will be sent to MF
751 ret = __send_msg2mf(ADD_MESSAGE, (void *)send_msg);
752 if (ret != CP_ERROR_SUCCESS) {
753 _DEBUG_TRACE("__sendMsg2MF() failed !!");
755 _DEBUG_TRACE("__sendMsg2MF() success !!");
762 static CP_ERROR __send_msg2mf(SENDMSG_TYPE send_type, void *send_msg)
766 CP_ERROR res = CP_ERROR_SUCCESS;
767 sync_agent_pm_return_e err_sendMsg = SYNC_AGENT_PM_SUCCESS;
772 int out_add_item_id = 0; // meaningless value
774 /* send message (add) */
775 err_sendMsg = sync_agent_add_service_data(6, (void *)send_msg, &out_add_item_id);
776 if (err_sendMsg != SYNC_AGENT_PM_SUCCESS) {
777 _DEBUG_VERBOSE("send msg ( ADD_MESSAGE ) to MF fail !!");
780 /* todo : exception handling */
782 _DEBUG_VERBOSE("send msg ( ADD_MESSAGE ) to MF success !!");
784 _DEBUG_VERBOSE("---------------------------------------");
785 _DEBUG_VERBOSE("OUT ADD ITEM %d", out_add_item_id);
786 _DEBUG_VERBOSE("---------------------------------------");
791 /* send message (remove) */
792 err_sendMsg = sync_agent_remove_service_data(6, g_msgId);
793 if (err_sendMsg != SYNC_AGENT_PM_SUCCESS) {
794 _DEBUG_VERBOSE("send msg ( REMOVE_MESSAGE ) to MF fail !!");
797 /* todo : exception handling */
799 _DEBUG_VERBOSE("send msg ( REMOVE_MESSAGE ) to MF success !!");
808 if (send_msg != NULL) {
809 if (((pmci_san_message_s *) send_msg)->msg_data != NULL)
810 free(((pmci_san_message_s *) send_msg)->msg_data);
818 static CP_ERROR _process_setting_oma_ds(DM_CP * dm_cp)
821 CP_ERROR ret = CP_ERROR_SUCCESS;
823 retvm_if((dm_cp) == NULL, CP_ERROR_FAIL, "dm_cp is NULL!!");
826 /*sync_agent_event_error_e error; */
828 sync_agent_event_data_s *event = sync_agent_create_event(event_type);
830 _DEBUG_TRACE("event is NULL");
835 DM_CP_Application *cp_application = dm_cp->applications;
837 _DEBUG_TRACE("cp_application->name : %s", cp_application->name);
838 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_application->name); /* profileName */
840 String_Node *addr = cp_application->addr;
842 _DEBUG_TRACE("cp_application->addr : %s", addr->data);
843 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, addr->data); /* addr */
845 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, ""); /* addr */
848 DM_CP_Application_AppAuth *cp_auth = cp_application->appAuth;
849 if (cp_auth != NULL) {
850 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_auth->auth_name); /* id */
851 _DEBUG_TRACE("cp_application->auth_name : %s", cp_auth->auth_name);
852 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_auth->auth_secret); /* password */
853 _DEBUG_TRACE("cp_application->auth_secret : %s", cp_auth->auth_secret);
855 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, ""); /* id */
856 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, ""); /* password */
859 int categoryCount = 0;
860 DM_CP_Application_Resource *cp_resource = cp_application->resource;
861 while (cp_resource != 0) {
863 cp_resource = cp_resource->next;
865 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &categoryCount); /* categoryCount */
867 cp_resource = cp_application->resource;
869 while (cp_resource != 0) {
870 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_resource->name); /* name */
871 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_resource->accept); /* accept */
872 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_resource->auth_name); /* id */
873 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_resource->auth_secret); /* password */
874 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_resource->auth_type); /* auth_type */
875 sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_resource->auth_data); /* auth_data */
877 cp_resource = cp_resource->next;
881 * IPC ( send msg to OMA DS Agent )
882 * Below rutine is made by Hard Coding?! If that, So Terrible.. I should consider this situation. - RJW
887 struct sockaddr_un clientaddr;
889 client_sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
890 if (client_sockfd == -1) {
891 _DEBUG_TRACE("socket create Error!!");
892 sync_agent_free_event(event);
894 return CP_ERROR_FAIL;
897 bzero(&clientaddr, sizeof(clientaddr));
898 clientaddr.sun_family = AF_UNIX;
902 str_len = g_strlcpy(clientaddr.sun_path, IPC_DS, (int)sizeof(clientaddr.sun_path));
903 if (str_len >= sizeof(clientaddr.sun_path)) {
904 _DEBUG_TRACE("buffer overflow");
905 sync_agent_free_event(event);
906 close(client_sockfd);
908 return CP_ERROR_FAIL;
910 client_len = sizeof(clientaddr);
912 if (connect(client_sockfd, (struct sockaddr *)&clientaddr, client_len) < 0) {
913 _DEBUG_TRACE("socket connect error");
914 sync_agent_free_event(event);
915 close(client_sockfd);
917 return CP_ERROR_FAIL;
920 int send_data_size = (event->data - event->size) + 1;
921 int write_ret = write(client_sockfd, (void *)(event->size), send_data_size);
922 _DEBUG_TRACE("write ret : %d", write_ret);
923 close(client_sockfd);
924 sync_agent_free_event(event);
931 static CP_ERROR _process_setting_oma_dm(DM_CP * dm_cp)
935 CP_ERROR ret = CP_ERROR_SUCCESS;
936 DM_ERROR dm_ret = DM_OK;
938 retvm_if((dm_cp) == NULL, CP_ERROR_FAIL, "dm_cp is NULL!!");
940 DM_CP_Application *applications = dm_cp->applications;
941 dm_acc *dmaccount = NULL;
942 if (applications != NULL) {
943 if (applications->provider_ID != NULL) {
944 dmaccount = (dm_acc *) calloc(1, sizeof(dm_acc));
945 if (dmaccount == NULL) {
946 _DEBUG_TRACE("alloc fail");
950 char *server_id = NULL;
951 server_id = strdup(applications->provider_ID);
952 /*get_Serverid(SAMSUNG_FUMO_TYPE , &server_id); */
953 _DEBUG_TRACE("server id : %s", server_id);
955 dmaccount->server_id = strdup(applications->provider_ID);
956 _DEBUG_TRACE("server id : %s", dmaccount->server_id);
958 if (applications->addr != NULL) {
959 dmaccount->server_url = strdup(applications->addr->data);
960 _DEBUG_TRACE("server url : %s", dmaccount->server_url);
963 DM_CP_Application_AppAuth *appAuth = applications->appAuth;
965 if (appAuth != NULL) {
967 if (appAuth->auth_level != NULL) {
968 if (strcmp("APPSRV", appAuth->auth_level) == 0) {
969 if (appAuth->auth_secret != NULL) {
970 dmaccount->server_pw = strdup(appAuth->auth_secret);
971 _DEBUG_TRACE("server_pw : %s", dmaccount->server_pw);
973 if (appAuth->auth_type != NULL) {
974 if (strstr(appAuth->auth_type, "DIGEST") != NULL) {
975 dmaccount->server_auth_type = strdup("DIGEST");
976 _DEBUG_TRACE("server_auth_type : %s", dmaccount->server_auth_type);
977 } else if (strstr(appAuth->auth_type, "HMAC") != NULL) {
978 dmaccount->server_auth_type = strdup("HMAC");
979 _DEBUG_TRACE("server_auth_type : %s", dmaccount->server_auth_type);
980 } else if (strstr(appAuth->auth_type, "BASIC") != NULL) {
981 dmaccount->server_auth_type = strdup("BASIC");
982 _DEBUG_TRACE("server_auth_type : %s", dmaccount->server_auth_type);
984 _DEBUG_TRACE("server_auth_type: %s", appAuth->auth_type);
985 dmaccount->server_auth_type = strdup("DIGEST");
986 _DEBUG_TRACE("server_nextNonce : %s", dmaccount->server_auth_type);
988 } else if (appAuth->auth_type == NULL && dmaccount->server_auth_type == NULL) {
989 dmaccount->server_auth_type = strdup("DIGEST");
990 _DEBUG_TRACE("user_auth_type : %s", dmaccount->server_auth_type);
993 if (appAuth->auth_data != NULL) {
994 dmaccount->server_nextNonce = strdup(appAuth->auth_data);
995 _DEBUG_TRACE("server_nextNonce : %s", dmaccount->server_nextNonce);
997 } else if (!strcmp("CLIENT", appAuth->auth_level)) {
998 if (appAuth->auth_secret != NULL) {
999 dmaccount->user_pw = strdup(appAuth->auth_secret);
1000 _DEBUG_TRACE("user_pw : %s", dmaccount->user_pw);
1003 if (appAuth->auth_type != NULL) {
1004 if (strstr(appAuth->auth_type, "DIGEST") != NULL) {
1005 dmaccount->user_auth_type = strdup("DIGEST");
1006 _DEBUG_TRACE("user_auth_type : %s", dmaccount->user_auth_type);
1007 } else if (strstr(appAuth->auth_type, "HMAC") != NULL) {
1008 dmaccount->user_auth_type = strdup("HMAC");
1009 _DEBUG_TRACE("user_auth_type : %s", dmaccount->user_auth_type);
1010 } else if (strstr(appAuth->auth_type, "BASIC") != NULL) {
1011 dmaccount->user_auth_type = strdup("BASIC");
1012 _DEBUG_TRACE("user_auth_type : %s", dmaccount->user_auth_type);
1014 _DEBUG_TRACE("user_auth_type : %s", appAuth->auth_type);
1015 dmaccount->user_auth_type = strdup("DIGEST");
1016 _DEBUG_TRACE("user_auth_type : %s", dmaccount->user_auth_type);
1018 } else if (appAuth->auth_type == NULL && dmaccount->user_auth_type == NULL) {
1019 dmaccount->user_auth_type = strdup("DIGEST");
1020 _DEBUG_TRACE("user_auth_type : %s", dmaccount->user_auth_type);
1023 if (appAuth->auth_name != NULL) {
1024 dmaccount->user_id = strdup(appAuth->auth_name);
1025 _DEBUG_TRACE("user_id : %s", dmaccount->user_id);
1027 if (appAuth->auth_data != NULL) {
1028 dmaccount->user_nextNonce = strdup(appAuth->auth_data);
1029 _DEBUG_TRACE("user_auth_type: %s", dmaccount->user_nextNonce);
1033 ret = CP_ERROR_FAIL;
1034 free_dm_acc(dmaccount);
1038 if (appAuth->next != NULL) {
1039 appAuth = appAuth->next;
1046 if (server_id != NULL) {
1048 SERVICE_SERVER_TYPE dmacc_type = NO_ENGINE_TYPE;
1050 dmacc_type = get_engine_type_by_serverid(server_id);
1051 _DEBUG_TRACE(" dm acc type : %d", dmacc_type);
1053 if (dmacc_type != NO_ENGINE_TYPE) {
1054 dm_ret = is_exist_dmacc(dmacc_type, &is_exist);
1055 if (dm_ret != DM_OK) {
1056 _DEBUG_TRACE("error is exist dm acc ");
1057 ret = CP_ERROR_FAIL;
1061 if (is_exist == 1) {
1062 _DEBUG_TRACE("exist dm acc ");
1063 ret = update_dmacc(server_id, dmaccount);
1064 _DEBUG_TRACE("update dm acc %d", ret);
1066 first_server_bootstrap(server_id);
1067 ret = CP_ERROR_SUCCESS;
1069 ret = CP_ERROR_FAIL;
1073 _DEBUG_TRACE("not exist dm acc ");
1074 ret = CP_ERROR_FAIL;
1077 _DEBUG_TRACE("dmacc type is none");
1078 ret = CP_ERROR_FAIL;
1081 _DEBUG_TRACE("server id is null");
1082 ret = CP_ERROR_FAIL;
1085 _DEBUG_TRACE("update dm acc : %d", ret);
1086 free_dm_acc(dmaccount);
1089 ret = CP_ERROR_FAIL;
1097 _DEBUG_TRACE("error : %d", ret);
1103 static char __char2hex(char ch)
1143 _DEBUG_VERBOSE("ch : %c ( 0x%02X )", ch, ret);
1148 static char *_get_netpin_key(int *key_len)
1152 sync_agent_dev_return_e err = SYNC_AGENT_DEV_RETURN_SUCCESS;
1153 char *imsi_value = 0;
1154 char *trans_imsi_value = 0;
1157 // char key[8] = {0, };
1164 err = sync_agent_get_devinfo(2, "IMSI", &imsi_value);
1165 if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
1166 _DEBUG_TRACE("imsi value is error !!");
1170 _DEBUG_TRACE("sync_agent_get_devinfo( IMSI ) success !!");
1173 _DEBUG_TRACE("IMSI value : %s", imsi_value);
1176 imsi_len = strlen(imsi_value);
1177 if ((imsi_len % 2) == 1) {
1179 trans_imsi_value = (char *)calloc(imsi_len, sizeof(char));
1181 if (trans_imsi_value == NULL) {
1182 _DEBUG_TRACE("calloc failed !!");
1186 len = g_strlcat(trans_imsi_value, "9", imsi_len);
1187 len = g_strlcat(trans_imsi_value, imsi_value, imsi_len);
1189 if (len >= imsi_len) {
1190 _DEBUG_TRACE(" buffer overflow !!");
1191 /* todo : exception handling */
1196 trans_imsi_value = (char *)calloc(imsi_len, sizeof(char));
1198 if (trans_imsi_value == NULL) {
1199 _DEBUG_TRACE("calloc failed !!");
1203 len = g_strlcat(trans_imsi_value, "1", imsi_len);
1204 len = g_strlcat(trans_imsi_value, imsi_value, imsi_len);
1205 len = g_strlcat(trans_imsi_value, "F", imsi_len);
1207 if (len >= imsi_len) {
1208 _DEBUG_TRACE(" buffer overflow !!");
1209 /* todo : exception handling */
1214 *key_len = imsi_len / 2;
1215 _DEBUG_TRACE("imsi value len : %d", *key_len);
1217 key = (char *)calloc(*key_len, sizeof(char));
1219 _DEBUG_TRACE("calloc failed !!");
1223 for (; i < *key_len; i++) {
1224 temp1 = __char2hex(trans_imsi_value[i * 2 + 1]);
1225 temp2 = __char2hex(trans_imsi_value[i * 2]);
1226 key[i] = (temp1 << 4) | temp2;
1229 _DEBUG_TRACE("key[%d] : 0x%02X", i, key[i]);
1233 if ((imsi_value != NULL) && (flag == 1))
1236 if (trans_imsi_value != NULL)
1237 free(trans_imsi_value);
1243 static int __make_view_message(char **msgData, DM_CP * dm_cp)
1251 retvm_if((dm_cp) == NULL, 0, "dm_cp is NULL!!");
1253 len = g_strlcat(*msgData, APPLICATION, MSG_SIZE);
1254 if (dm_cp->applications->app_ID != NULL) {
1255 if (dm_cp->applications->name != NULL) {
1256 _DEBUG_VERBOSE("name : %s", dm_cp->applications->name);
1258 len = g_strlcat(*msgData, dm_cp->applications->name, MSG_SIZE);
1261 len = g_strlcat(*msgData, L_BRACKET, MSG_SIZE);
1262 if (strcmp(dm_cp->applications->app_ID, "w2") == 0) {
1263 _DEBUG_VERBOSE("app id : %s", W2);
1265 len = g_strlcat(*msgData, W2, MSG_SIZE);
1266 } else if (strcmp(dm_cp->applications->app_ID, "w4") == 0) {
1267 _DEBUG_VERBOSE("app id : %s", W4);
1269 len = g_strlcat(*msgData, W4, MSG_SIZE);
1270 } else if (strcmp(dm_cp->applications->app_ID, "w5") == 0) {
1271 _DEBUG_VERBOSE("app id : %s", W5);
1273 len = g_strlcat(*msgData, W5, MSG_SIZE);
1274 } else if (strcmp(dm_cp->applications->app_ID, "w7") == 0) {
1275 _DEBUG_VERBOSE("app id : %s", W7);
1277 len = g_strlcat(*msgData, W7, MSG_SIZE);
1278 } else if (strcmp(dm_cp->applications->app_ID, "wA") == 0) {
1279 _DEBUG_VERBOSE("app id : %s", WA);
1281 len = g_strlcat(*msgData, WA, MSG_SIZE);
1283 _DEBUG_VERBOSE("app id : undefined !!");
1284 len = g_strlcat(*msgData, "Undefined ", MSG_SIZE);
1287 len = g_strlcat(*msgData, R_BRACKET, MSG_SIZE);
1289 _DEBUG_VERBOSE("Application ID is not existed - Invalid format !!");
1294 len = g_strlcat(*msgData, LB, MSG_SIZE);
1295 // _DEBUG_VERBOSE("msg data : %s", *msgData);
1299 len = g_strlcat(*msgData, URL, MSG_SIZE);
1300 if (dm_cp->applications->addr != NULL) {
1301 if (dm_cp->applications->addr->data != NULL) {
1302 _DEBUG_VERBOSE("url : %s", dm_cp->applications->addr->data);
1304 len = g_strlcat(*msgData, dm_cp->applications->addr->data, MSG_SIZE);
1307 len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
1311 len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
1315 len = g_strlcat(*msgData, LB, MSG_SIZE);
1316 // _DEBUG_VERBOSE("msg data : %s", *msgData);
1319 if (dm_cp->napdefs != NULL) {
1320 if (dm_cp->napdefs->nap_addr_type != NULL) {
1321 _DEBUG_VERBOSE("nap addr type : %s", dm_cp->napdefs->nap_addr_type);
1323 len = g_strlcat(*msgData, dm_cp->napdefs->nap_addr_type, MSG_SIZE);
1324 len = g_strlcat(*msgData, DELIMITER, MSG_SIZE);
1325 if (dm_cp->napdefs->nap_address != NULL) {
1326 _DEBUG_VERBOSE("nap addr : %s", dm_cp->napdefs->nap_address);
1327 len = g_strlcat(*msgData, dm_cp->napdefs->nap_address, MSG_SIZE);
1332 len = g_strlcat(*msgData, DEFAULT_NAP_TYPE, MSG_SIZE);
1333 len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
1337 len = g_strlcat(*msgData, DEFAULT_NAP_TYPE, MSG_SIZE);
1338 len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
1341 len = g_strlcat(*msgData, LB, MSG_SIZE);
1343 // _DEBUG_VERBOSE("msg data : %s", *msgData);
1347 len = g_strlcat(*msgData, PROXY, MSG_SIZE);
1349 if (dm_cp->applications->to_proxy != NULL) {
1350 if (dm_cp->applications->to_proxy->data != NULL) {
1351 _DEBUG_VERBOSE("proxy : %s", dm_cp->applications->to_proxy->data);
1353 len = g_strlcat(*msgData, dm_cp->applications->to_proxy->data, MSG_SIZE);
1356 len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
1361 len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
1364 len = g_strlcat(*msgData, LB, MSG_SIZE);
1365 // _DEBUG_VERBOSE("msg data : %s", *msgData);
1369 len = g_strlcat(*msgData, PORT, MSG_SIZE);
1370 if (dm_cp->pxLogical != NULL) {
1371 if (dm_cp->pxLogical->port != NULL) {
1372 if (dm_cp->pxLogical->port->portnbr != NULL) {
1373 _DEBUG_VERBOSE("port : %s", dm_cp->pxLogical->port->portnbr);
1375 len = g_strlcat(*msgData, dm_cp->pxLogical->port->portnbr, MSG_SIZE);
1378 len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
1382 len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
1386 len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
1389 len = g_strlcat(*msgData, LB, MSG_SIZE);
1390 // _DEBUG_VERBOSE("msg data : %s", *msgData);
1392 if (len >= MSG_SIZE) {
1393 _DEBUG_VERBOSE("over flow error");
1401 void free_cp_application(DM_CP_Application * app)
1403 retm_if((app) == NULL, "dm_cp application is NULL!!");
1405 if (app->accept != NULL) {
1406 str_free(&(app->accept));
1409 if (app->addr != NULL) {
1410 free_string_node(app->addr);
1413 if (app->appAddr != NULL) {
1414 free_cp_application_app_addr(app->appAddr);
1415 app->appAddr = NULL;
1417 if (app->appAuth != NULL) {
1418 free_cp_application_app_auth(app->appAuth);
1419 app->appAuth = NULL;
1421 if (app->app_ID != NULL) {
1422 str_free(&(app->app_ID));
1425 if (app->name != NULL) {
1426 str_free(&(app->name));
1429 if (app->protocol != NULL) {
1430 str_free(&(app->protocol));
1431 app->protocol = NULL;
1433 if (app->provider_ID != NULL) {
1434 str_free(&(app->provider_ID));
1435 app->provider_ID = NULL;
1437 if (app->resource != NULL) {
1438 free_cp_application_resource(app->resource);
1439 app->resource = NULL;
1441 if (app->to_napid != NULL) {
1442 free_string_node(app->to_napid);
1443 app->to_napid = NULL;
1445 if (app->to_proxy != NULL) {
1446 free_string_node(app->to_proxy);
1447 app->to_proxy = NULL;
1449 if (app->next != NULL) {
1450 free_cp_application(app->next);
1457 void free_cp_application_app_addr(DM_CP_Application_AppAddr * app_addr)
1459 retm_if((app_addr) == NULL, "dm_cp is NULL!!");
1461 if (app_addr->addr != NULL) {
1462 str_free(&(app_addr->addr));
1463 app_addr->addr = NULL;
1466 if (app_addr->addr_type != NULL) {
1467 str_free(&(app_addr->addr_type));
1468 app_addr->addr_type = NULL;
1471 if (app_addr->port != NULL) {
1472 free_cp_port(app_addr->port);
1473 app_addr->port = NULL;
1476 if (app_addr->next != NULL) {
1477 free_cp_application_app_addr(app_addr->next);
1478 app_addr->next = NULL;
1485 void free_cp_application_app_auth(DM_CP_Application_AppAuth * appAuth)
1487 retm_if((appAuth) == NULL, "dm_cp appAuth is NULL!!");
1489 if (appAuth->auth_data != NULL) {
1490 str_free(&(appAuth->auth_data));
1491 appAuth->auth_data = NULL;
1493 if (appAuth->auth_level != NULL) {
1494 str_free(&(appAuth->auth_level));
1495 appAuth->auth_level = NULL;
1497 if (appAuth->auth_name != NULL) {
1498 str_free(&(appAuth->auth_name));
1499 appAuth->auth_name = NULL;
1501 if (appAuth->auth_secret != NULL) {
1502 str_free(&(appAuth->auth_secret));
1503 appAuth->auth_secret = NULL;
1506 if (appAuth->auth_type != NULL) {
1507 str_free(&(appAuth->auth_type));
1508 appAuth->auth_type = NULL;
1510 if (appAuth->next != NULL) {
1511 free_cp_application_app_auth(appAuth->next);
1512 appAuth->next = NULL;
1519 void free_cp_application_resource(DM_CP_Application_Resource * resource)
1521 retm_if((resource) == NULL, "dm_cp port is NULL!!");
1523 if (resource->accept != NULL) {
1524 str_free(&(resource->accept));
1525 resource->accept = NULL;
1527 if (resource->auth_data != NULL) {
1528 str_free(&(resource->auth_data));
1529 resource->auth_data = NULL;
1531 if (resource->auth_name != NULL) {
1532 str_free(&(resource->auth_name));
1533 resource->auth_name = NULL;
1535 if (resource->auth_secret != NULL) {
1536 str_free(&(resource->auth_secret));
1537 resource->auth_secret = NULL;
1539 if (resource->auth_type != NULL) {
1540 str_free(&(resource->auth_type));
1541 resource->auth_type = NULL;
1543 if (resource->name != NULL) {
1544 str_free(&(resource->name));
1545 resource->name = NULL;
1547 if (resource->start_page != NULL) {
1548 str_free(&(resource->start_page));
1549 resource->start_page = NULL;
1551 if (resource->uri != NULL) {
1552 str_free(&(resource->uri));
1553 resource->uri = NULL;
1555 if (resource->next != NULL) {
1556 free_cp_application_resource(resource->next);
1557 resource->next = NULL;
1564 void free_cp_port(DM_CP_Port * port)
1566 retm_if((port) == NULL, "dm_cp port is NULL!!");
1568 if (port->portnbr != NULL) {
1569 str_free(&(port->portnbr));
1570 port->portnbr = NULL;
1572 if (port->service != NULL) {
1573 free_string_node(port->service);
1574 port->service = NULL;
1576 if (port->next != NULL) {
1577 free_cp_port(port->next);
1585 void free_string_node(String_Node * service)
1587 retm_if((service) == NULL, "dm_cp string node is NULL!!");
1589 if (service->data != NULL) {
1590 str_free(&(service->data));
1591 service->data = NULL;
1593 if (service->next != NULL) {
1594 free_string_node(service->next);
1595 service->next = NULL;
1602 void free_cp_napdef(DM_CP_Napdef * napdef)
1604 retm_if((napdef) == NULL, "dm_cp napdef is NULL!!");
1606 if (napdef->auth_info != NULL) {
1607 free_cp_napdef_authinfo(napdef->auth_info);
1608 napdef->auth_info = NULL;
1610 if (napdef->bearer != NULL) {
1611 free_string_node(napdef->bearer);
1612 napdef->bearer = NULL;
1614 if (napdef->call_type != NULL) {
1615 str_free(&(napdef->call_type));
1616 napdef->call_type = NULL;
1618 if (napdef->delivery_err_sdu != NULL) {
1619 str_free(&(napdef->delivery_err_sdu));
1620 napdef->delivery_err_sdu = NULL;
1622 if (napdef->delivery_order != NULL) {
1623 str_free(&(napdef->delivery_order));
1624 napdef->delivery_order = NULL;
1626 if (napdef->dn_link_speed != NULL) {
1627 str_free(&(napdef->dn_link_speed));
1628 napdef->dn_link_speed = NULL;
1630 if (napdef->dns_addr != NULL) {
1631 free_string_node(napdef->dns_addr);
1632 napdef->dns_addr = NULL;
1634 if (napdef->first_retry_timeout != NULL) {
1635 str_free(&(napdef->first_retry_timeout));
1636 napdef->first_retry_timeout = NULL;
1638 if (napdef->guaranteed_bitrate_dnlink != NULL) {
1639 str_free(&(napdef->guaranteed_bitrate_dnlink));
1640 napdef->guaranteed_bitrate_dnlink = NULL;
1642 if (napdef->guaranteed_bitrate_uplink != NULL) {
1643 str_free(&(napdef->guaranteed_bitrate_uplink));
1644 napdef->guaranteed_bitrate_uplink = NULL;
1646 if (napdef->internet != NULL) {
1647 str_free(&(napdef->internet));
1648 napdef->internet = NULL;
1650 if (napdef->linger != NULL) {
1651 str_free(&(napdef->linger));
1652 napdef->linger = NULL;
1654 if (napdef->link_speed != NULL) {
1655 str_free(&(napdef->link_speed));
1656 napdef->link_speed = NULL;
1658 if (napdef->local_addr != NULL) {
1659 str_free(&(napdef->local_addr));
1660 napdef->local_addr = NULL;
1662 if (napdef->local_addr_type != NULL) {
1663 str_free(&(napdef->local_addr_type));
1664 napdef->local_addr_type = NULL;
1666 if (napdef->max_bitrate_dnlink != NULL) {
1667 str_free(&(napdef->max_bitrate_dnlink));
1668 napdef->max_bitrate_dnlink = NULL;
1670 if (napdef->max_bitrate_uplink != NULL) {
1671 str_free(&(napdef->max_bitrate_uplink));
1672 napdef->max_bitrate_uplink = NULL;
1674 if (napdef->max_num_retry != NULL) {
1675 str_free(&(napdef->max_num_retry));
1676 napdef->max_num_retry = NULL;
1678 if (napdef->max_sdu_size != NULL) {
1679 str_free(&(napdef->max_sdu_size));
1680 napdef->max_sdu_size = NULL;
1682 if (napdef->name != NULL) {
1683 str_free(&(napdef->name));
1684 napdef->name = NULL;
1686 if (napdef->nap_ID != NULL) {
1687 str_free(&(napdef->nap_ID));
1688 napdef->nap_ID = NULL;
1690 if (napdef->nap_addr_type != NULL) {
1691 str_free(&(napdef->nap_addr_type));
1692 napdef->nap_addr_type = NULL;
1694 if (napdef->nap_address != NULL) {
1695 str_free(&(napdef->nap_address));
1696 napdef->nap_address = NULL;
1698 if (napdef->rereg_threshold != NULL) {
1699 str_free(&(napdef->rereg_threshold));
1700 napdef->rereg_threshold = NULL;
1702 if (napdef->residual_ber != NULL) {
1703 str_free(&(napdef->residual_ber));
1704 napdef->residual_ber = NULL;
1706 if (napdef->sdu_error_ratio != NULL) {
1707 str_free(&(napdef->sdu_error_ratio));
1708 napdef->sdu_error_ratio = NULL;
1710 if (napdef->t_bit != NULL) {
1711 str_free(&(napdef->t_bit));
1712 napdef->t_bit = NULL;
1714 if (napdef->traffic_class != NULL) {
1715 str_free(&(napdef->traffic_class));
1716 napdef->traffic_class = NULL;
1718 if (napdef->traffic_handl_prio != NULL) {
1719 str_free(&(napdef->traffic_handl_prio));
1720 napdef->traffic_handl_prio = NULL;
1722 if (napdef->transfer_delay != NULL) {
1723 str_free(&(napdef->transfer_delay));
1724 napdef->transfer_delay = NULL;
1726 if (napdef->validity != NULL) {
1727 free_cp_napdef_validity(napdef->validity);
1728 napdef->validity = NULL;
1730 if (napdef->next != NULL) {
1731 free_cp_napdef(napdef->next);
1732 napdef->next = NULL;
1740 void free_cp_napdef_authinfo(DM_CP_Napdef_AuthInfo * auth_info)
1742 retm_if((auth_info) == NULL, "dm_cp napdef auth info is NULL!!");
1744 if (auth_info->auth_entity != NULL) {
1745 free_string_node(auth_info->auth_entity);
1746 auth_info->auth_entity = NULL;
1748 if (auth_info->auth_name != NULL) {
1749 str_free(&(auth_info->auth_name));
1750 auth_info->auth_name = NULL;
1752 if (auth_info->auth_secret != NULL) {
1753 str_free(&(auth_info->auth_secret));
1754 auth_info->auth_secret = NULL;
1756 if (auth_info->auth_type != NULL) {
1757 str_free(&(auth_info->auth_type));
1758 auth_info->auth_type = NULL;
1760 if (auth_info->spi != NULL) {
1761 str_free(&(auth_info->spi));
1762 auth_info->spi = NULL;
1764 if (auth_info->next != NULL) {
1765 free_cp_napdef_authinfo(auth_info->next);
1766 auth_info->next = NULL;
1773 void free_cp_napdef_validity(DM_CP_Napdef_validity * validity)
1775 retm_if((validity) == NULL, "dm_cp napdef validity is NULL!!");
1777 if (validity->country != NULL) {
1778 str_free(&(validity->country));
1779 validity->country = NULL;
1781 if (validity->network != NULL) {
1782 str_free(&(validity->network));
1783 validity->network = NULL;
1785 if (validity->sid != NULL) {
1786 str_free(&(validity->sid));
1787 validity->sid = NULL;
1789 if (validity->soc != NULL) {
1790 str_free(&(validity->soc));
1791 validity->soc = NULL;
1793 if (validity->validuntil != NULL) {
1794 str_free(&(validity->validuntil));
1795 validity->validuntil = NULL;
1797 if (validity->next != NULL) {
1798 free_cp_napdef_validity(validity->next);
1799 validity->next = NULL;
1806 void free_cp_bootstrap(DM_CP_Bootstrap * bootstraps)
1808 retm_if((bootstraps) == NULL, "dm_cp bootstraps is NULL!!");
1810 if (bootstraps->context_allow != NULL) {
1811 str_free(&(bootstraps->context_allow));
1812 bootstraps->context_allow = NULL;
1814 if (bootstraps->country != NULL) {
1815 str_free(&(bootstraps->country));
1816 bootstraps->country = NULL;
1818 if (bootstraps->name != NULL) {
1819 str_free(&(bootstraps->name));
1820 bootstraps->name = NULL;
1822 if (bootstraps->provurl != NULL) {
1823 str_free(&(bootstraps->provurl));
1824 bootstraps->provurl = NULL;
1826 if (bootstraps->network != NULL) {
1827 free_string_node(bootstraps->network);
1828 bootstraps->network = NULL;
1830 if (bootstraps->proxy_id != NULL) {
1831 free_string_node(bootstraps->proxy_id);
1832 bootstraps->proxy_id = NULL;
1834 if (bootstraps->next != NULL) {
1835 free_cp_bootstrap(bootstraps->next);
1836 bootstraps->next = NULL;
1843 void free_cp_pxlogical(DM_CP_PxLogical * pxLogical)
1845 retm_if((pxLogical) == NULL, "dm_cp pxlogical is NULL!!");
1847 if (pxLogical->bas_auth_id != NULL) {
1848 str_free(&(pxLogical->bas_auth_id));
1849 pxLogical->bas_auth_id = NULL;
1851 if (pxLogical->bas_auth_pw != NULL) {
1852 str_free(&(pxLogical->bas_auth_pw));
1853 pxLogical->bas_auth_pw = NULL;
1855 if (pxLogical->domain != NULL) {
1856 free_string_node(pxLogical->domain);
1857 pxLogical->domain = NULL;
1859 if (pxLogical->master != NULL) {
1860 str_free(&(pxLogical->master));
1861 pxLogical->master = NULL;
1863 if (pxLogical->name != NULL) {
1864 str_free(&(pxLogical->name));
1865 pxLogical->name = NULL;
1867 if (pxLogical->port != NULL) {
1868 free_cp_port(pxLogical->port);
1869 pxLogical->port = NULL;
1871 if (pxLogical->ppg_auth_type != NULL) {
1872 str_free(&(pxLogical->ppg_auth_type));
1873 pxLogical->ppg_auth_type = NULL;
1875 if (pxLogical->proxy_id != NULL) {
1876 str_free(&(pxLogical->proxy_id));
1877 pxLogical->proxy_id = NULL;
1879 if (pxLogical->proxy_provider_id != NULL) {
1880 str_free(&(pxLogical->proxy_provider_id));
1881 pxLogical->proxy_provider_id = NULL;
1883 if (pxLogical->proxy_pw != NULL) {
1884 str_free(&(pxLogical->proxy_pw));
1885 pxLogical->proxy_pw = NULL;
1887 if (pxLogical->pull_enabled != NULL) {
1888 str_free(&(pxLogical->pull_enabled));
1889 pxLogical->pull_enabled = NULL;
1891 if (pxLogical->pxAuthInfo != NULL) {
1892 free_cp_pxlogical_pxauthinfo(pxLogical->pxAuthInfo);
1893 pxLogical->pxAuthInfo = NULL;
1895 if (pxLogical->pxPhysical != NULL) {
1896 free_cp_pxLogical_pxphsical(pxLogical->pxPhysical);
1897 pxLogical->pxPhysical = NULL;
1899 if (pxLogical->start_page != NULL) {
1900 str_free(&(pxLogical->start_page));
1901 pxLogical->start_page = NULL;
1903 if (pxLogical->trust != NULL) {
1904 str_free(&(pxLogical->trust));
1905 pxLogical->trust = NULL;
1907 if (pxLogical->wsp_version != NULL) {
1908 str_free(&(pxLogical->wsp_version));
1909 pxLogical->wsp_version = NULL;
1911 if (pxLogical->next != NULL) {
1912 free_cp_pxlogical(pxLogical->next);
1913 pxLogical->next = NULL;
1920 void free_cp_pxlogical_pxauthinfo(DM_CP_PxLogical_PxAuthInfo * pxAuthInfo)
1922 retm_if((pxAuthInfo) == NULL, "dm_cp pxAuthInfo is NULL!!");
1924 if (pxAuthInfo->pxAuth_id != NULL) {
1925 str_free(&(pxAuthInfo->pxAuth_id));
1926 pxAuthInfo->pxAuth_id = NULL;
1928 if (pxAuthInfo->pxAuth_pw != NULL) {
1929 str_free(&(pxAuthInfo->pxAuth_pw));
1930 pxAuthInfo->pxAuth_pw = NULL;
1932 if (pxAuthInfo->pxAuth_type != NULL) {
1933 str_free(&(pxAuthInfo->pxAuth_type));
1934 pxAuthInfo->pxAuth_type = NULL;
1936 if (pxAuthInfo->next != NULL) {
1937 free_cp_pxlogical_pxauthinfo(pxAuthInfo->next);
1938 pxAuthInfo->next = NULL;
1946 void free_cp_pxLogical_pxphsical(DM_CP_PxLogical_PxPhysical * pxPhysical)
1948 retm_if((pxPhysical) == NULL, "dm_cp pxPhysical is NULL!!");
1950 if (pxPhysical->domain != NULL) {
1951 free_string_node(pxPhysical->domain);
1952 pxPhysical->domain = NULL;
1954 if (pxPhysical->physical_proxy_id != NULL) {
1955 str_free(&(pxPhysical->physical_proxy_id));
1956 pxPhysical->physical_proxy_id = NULL;
1958 if (pxPhysical->port != NULL) {
1959 free_cp_port(pxPhysical->port);
1960 pxPhysical->port = NULL;
1962 if (pxPhysical->pull_enabled != NULL) {
1963 str_free(&(pxPhysical->pull_enabled));
1964 pxPhysical->pull_enabled = NULL;
1966 if (pxPhysical->push_enabled != NULL) {
1967 str_free(&(pxPhysical->push_enabled));
1968 pxPhysical->push_enabled = NULL;
1971 if (pxPhysical->pxAddr != NULL) {
1972 str_free(&(pxPhysical->pxAddr));
1973 pxPhysical->pxAddr = NULL;
1975 if (pxPhysical->pxAddrType != NULL) {
1976 str_free(&(pxPhysical->pxAddrType));
1977 pxPhysical->pxAddrType = NULL;
1979 if (pxPhysical->pxAddr_FQDN != NULL) {
1980 str_free(&(pxPhysical->pxAddr_FQDN));
1981 pxPhysical->pxAddr_FQDN = NULL;
1983 if (pxPhysical->to_napid != NULL) {
1984 free_string_node(pxPhysical->to_napid);
1985 pxPhysical->to_napid = NULL;
1988 if (pxPhysical->wsp_version != NULL) {
1989 str_free(&(pxPhysical->wsp_version));
1990 pxPhysical->wsp_version = NULL;
1992 if (pxPhysical->next != NULL) {
1993 free_cp_pxLogical_pxphsical(pxPhysical->next);
1994 pxPhysical->next = NULL;