Tizen 2.0 Release
[framework/system/oma-dm-agent.git] / src / agent / dm-engine / cp / dm_cp_parser.c
1 /*
2  * oma-dm-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 /*lib*/
19 #include <glib.h>
20 #include <glib/gprintf.h>
21
22 /*sync-agent*/
23 #include <sync_agent.h>
24
25 /*dm-agent*/
26 #include "dm-engine/cp/dm_cp_struct.h"
27 #include "dm-engine/cp/dm_cp_parser.h"
28 #include "dm-engine/cp/dm_cp_processor.h"
29 #include "serviceadapter/protocolbinder/syncml_protocol_binder.h"
30
31 #ifndef OMADM_AGENT_LOG
32 #undef LOG_TAG
33 #define LOG_TAG "OMA_DM_CP"
34 #endif
35
36 static String_Node *___get_Last_String_Node(String_Node * node);
37 static DM_CP_Bootstrap *__parse_Bootstrap(WBXMLTreeNode * wbxml_dom_node);
38 static DM_CP_Napdef *__parse_Napdef(WBXMLTreeNode * wbxml_dom_node);
39 static DM_CP_Application *__parse_Application(WBXMLTreeNode * wbxml_dom_node);
40 static DM_CP_PxLogical *__parse_PxLogical(WBXMLTreeNode * wbxml_dom_node);
41 static void ___set_Param(WBXMLTreeNode * wbxml_dom_node, char **set_value);
42 static sync_agent_pb_error_e _characteristic_start_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
43
44 const sync_agent_pb_function_info_s cp_binder_function_info[] = {
45         {TNDS_TAG_CHARACTERISTIC_START, "characteristic", NULL, _characteristic_start_reverse_converter_function, false},
46 };
47
48 DM_CP *parsing_cp_stream(CP_TYPE cp_type, const char *wbxml_stream, unsigned int msgSize)
49 {
50         _EXTERN_FUNC_ENTER;
51
52         retvm_if((wbxml_stream) == NULL, NULL, "wbxml_stream is NULL!!");
53
54         sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
55         sync_agent_pb_error_e pb_error = sync_agent_init_binder_function_set(sizeof(cp_binder_function_info) / sizeof(sync_agent_pb_function_info_s),
56                                                                              (sync_agent_pb_function_info_s *) cp_binder_function_info, &pBinder_function_set);
57
58         if (pb_error != SYNC_AGENT_PB_RETURN_OK) {
59                 _DEBUG_INFO("Failed to sync_agent_init_binder_function_set()");
60                 _EXTERN_FUNC_EXIT;
61                 return 0;
62         }
63
64         /*
65          * reverse protocol binder initialization
66          */
67         sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_PROV10;
68         sync_agent_pb_protocol_binder_reverse_info_s *pBinder = 0;
69         DM_CP *dm_cp = (DM_CP *) calloc(1, sizeof(DM_CP));
70         if (dm_cp == NULL) {
71                 _DEBUG_INFO("alloc fail");
72                 free_syncml_binder_function_set(pBinder_function_set);
73                 _EXTERN_FUNC_EXIT;
74                 return 0;
75         }
76
77         switch (cp_type) {
78         case CP_TYPE_WBXML:
79                 pb_error = sync_agent_init_reverse_protocol_binder((char *)wbxml_stream, msgSize, SYNC_AGENT_PB_DECODING_WBXML, &protocol, pBinder_function_set, dm_cp, &pBinder);
80                 break;
81         case CP_TYPE_XML:
82                 pb_error = sync_agent_init_reverse_protocol_binder((char *)wbxml_stream, msgSize, SYNC_AGENT_PB_DECODING_XML, &protocol, pBinder_function_set, dm_cp, &pBinder);
83                 break;
84         case CP_TYPE_NONE:
85                 break;
86         default:
87                 break;
88         }
89
90         if (pb_error != SYNC_AGENT_PB_RETURN_OK) {
91                 _DEBUG_INFO("Failed to call sync_agent_init_reverse_protocol_binder() - [%d]", pb_error);
92         }
93
94         Protocol_Element protocol_element;
95         char *protocol_element_name = 0;
96         Content_Ptr content = 0;
97
98         while (1) {
99                 pb_error = sync_agent_next_element(pBinder, &protocol_element, &protocol_element_name, &content);
100
101                 if (pb_error == SYNC_AGENT_PB_RETURN_HAS_NO_MORE_ELEMENT) {
102                         break;
103                 } else if (pb_error != SYNC_AGENT_PB_RETURN_OK) {
104                         /*
105                          * process error code
106                          */
107                 }
108         }
109         _EXTERN_FUNC_EXIT;
110
111         return dm_cp;
112 }
113
114 static sync_agent_pb_error_e _characteristic_start_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
115 {
116         _INNER_FUNC_ENTER;
117
118         sync_agent_pb_error_e pb_error = SYNC_AGENT_PB_RETURN_OK;
119
120         retvm_if((pReverse_binder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pReverse_binder is NULL!!");
121         retvm_if((wbxml_dom_node) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "wbxml_dom_node is NULL!!");
122
123         void *user_data = sync_agent_get_user_data_from_reverse_protocol_binder(pReverse_binder);
124         DM_CP *dm_cp = (DM_CP *) user_data;
125
126         WBXMLList *attrs = wbxml_dom_node->attrs;
127         WB_ULONG index = 0;
128         WB_ULONG nb_attrs = wbxml_list_len(attrs);
129
130         while (index < nb_attrs) {
131                 WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attrs, index);
132
133                 if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(attr)) == 0) {
134                         if (WBXML_STRCMP("APPLICATION", wbxml_attribute_get_xml_value(attr)) == 0) {
135                                 DM_CP_Application *application = __parse_Application(wbxml_dom_node);
136                                 if (application == NULL) {
137                                         index++;
138                                         continue;
139                                 }
140                                 if (dm_cp->applications == NULL) {
141                                         dm_cp->applications = application;
142                                 } else {
143                                         DM_CP_Application *cursor_ptr = dm_cp->applications;
144                                         while (cursor_ptr != 0) {
145                                                 if (cursor_ptr->next == NULL) {
146                                                         cursor_ptr->next = application;
147                                                         break;
148                                                 }
149                                                 cursor_ptr = cursor_ptr->next;
150                                         }
151                                 }
152                         } else if (WBXML_STRCMP("BOOTSTRAP", wbxml_attribute_get_xml_value(attr)) == 0) {
153                                 DM_CP_Bootstrap *bootstrap = __parse_Bootstrap(wbxml_dom_node);
154                                 if (bootstrap == NULL) {
155                                         index++;
156                                         continue;
157                                 }
158                                 if (dm_cp->bootstraps == NULL) {
159                                         dm_cp->bootstraps = bootstrap;
160                                 } else {
161                                         DM_CP_Bootstrap *cursor_ptr = dm_cp->bootstraps;
162                                         while (cursor_ptr != NULL) {
163                                                 if (cursor_ptr->next == NULL) {
164                                                         cursor_ptr->next = bootstrap;
165                                                         break;
166                                                 }
167                                                 cursor_ptr = cursor_ptr->next;
168                                         }
169                                 }
170                         } else if (WBXML_STRCMP("NAPDEF", wbxml_attribute_get_xml_value(attr)) == 0) {
171                                 DM_CP_Napdef *napdef = __parse_Napdef(wbxml_dom_node);
172                                 if (napdef == NULL) {
173                                         index++;
174                                         continue;
175                                 }
176                                 if (dm_cp->napdefs == NULL) {
177                                         dm_cp->napdefs = napdef;
178                                 } else {
179                                         DM_CP_Napdef *cursor_ptr = dm_cp->napdefs;
180                                         while (cursor_ptr != NULL) {
181                                                 if (cursor_ptr->next == NULL) {
182                                                         cursor_ptr->next = napdef;
183                                                         break;
184                                                 }
185                                                 cursor_ptr = cursor_ptr->next;
186                                         }
187                                 }
188                         } else if (WBXML_STRCMP("PXLOGICAL", wbxml_attribute_get_xml_value(attr)) == 0) {
189                                 DM_CP_PxLogical *pxLogical = __parse_PxLogical(wbxml_dom_node);
190                                 if (pxLogical == NULL) {
191                                         index++;
192                                         continue;
193                                 }
194                                 if (dm_cp->pxLogical == NULL) {
195                                         dm_cp->pxLogical = pxLogical;
196                                 } else {
197                                         DM_CP_PxLogical *cursor_ptr = dm_cp->pxLogical;
198                                         while (cursor_ptr != NULL) {
199                                                 if (cursor_ptr->next == NULL) {
200                                                         cursor_ptr->next = pxLogical;
201                                                         break;
202                                                 }
203                                                 cursor_ptr = cursor_ptr->next;
204                                         }
205                                 }
206                         }
207                 }
208
209                 index++;
210         }
211
212         _INNER_FUNC_EXIT;
213         return pb_error;
214 }
215
216 static String_Node *___get_Last_String_Node(String_Node * node)
217 {
218         _INNER_FUNC_ENTER;
219
220         String_Node *new_node = (String_Node *) calloc(1, sizeof(String_Node));
221         if (new_node == NULL) {
222                 _DEBUG_VERBOSE("alloc fail");
223                 _INNER_FUNC_EXIT;
224                 return 0;
225         }
226         new_node->next = NULL;
227
228         String_Node *cursor_ptr = node;
229         while (cursor_ptr != NULL) {
230                 if (cursor_ptr->next == NULL) {
231                         cursor_ptr->next = new_node;
232                         break;
233                 }
234
235                 cursor_ptr = cursor_ptr->next;
236         }
237
238         _INNER_FUNC_EXIT;
239
240         return new_node;
241 }
242
243 static DM_CP_Bootstrap *__parse_Bootstrap(WBXMLTreeNode * wbxml_dom_node)
244 {
245         _INNER_FUNC_ENTER;
246
247         retvm_if((wbxml_dom_node) == NULL, NULL, "wbxml_dom_node is NULL!!");
248
249         DM_CP_Bootstrap *bootstrap = (DM_CP_Bootstrap *) calloc(1, sizeof(DM_CP_Bootstrap));
250         if (bootstrap == NULL) {
251                 _DEBUG_VERBOSE("alloc fail");
252                 _INNER_FUNC_EXIT;
253                 return 0;
254         }
255
256         WBXMLTreeNode *pCursor = wbxml_dom_node->children;
257
258         while (pCursor != NULL) {
259                 if (pCursor->type == WBXML_TREE_ELEMENT_NODE) {
260                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor->name);
261                         if (!strcmp((const char *)tag_name, "parm")) {
262                                 WBXMLList *param_attrs = pCursor->attrs;
263                                 WB_ULONG param_index = 0;
264                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
265                                 while (param_index < param_nb_attrs) {
266                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
267                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
268                                                 if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
269                                                         ___set_Param(pCursor, &(bootstrap->name));
270                                                         if(bootstrap->name != NULL) {
271                                                                 _DEBUG_VERBOSE("NAME : %s", bootstrap->name);
272                                                         }
273                                                 } else if (WBXML_STRCMP("NETWORK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
274                                                         String_Node *target_ptr = ___get_Last_String_Node(bootstrap->network);
275                                                         if (target_ptr == NULL) {
276                                                                 _DEBUG_VERBOSE("bootstrap network get null");
277                                                                 param_index++;
278                                                                 continue;
279                                                         }
280                                                         ___set_Param(pCursor, &(target_ptr->data));
281                                                         if(target_ptr->data != NULL) {
282                                                                 _DEBUG_VERBOSE("NETWORK : %s", target_ptr->data);
283                                                         }
284                                                         if (bootstrap->network == NULL) {
285                                                                 bootstrap->network = target_ptr;
286                                                         } else {
287                                                                 _DEBUG_VERBOSE("free network");
288                                                                 free_string_node(target_ptr);
289                                                         }
290                                                 } else if (WBXML_STRCMP("COUNTRY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
291                                                         ___set_Param(pCursor, &(bootstrap->country));
292                                                         if(bootstrap->country != NULL) {
293                                                                 _DEBUG_VERBOSE("COUNTRY : %s", bootstrap->country);
294                                                         }
295                                                 } else if (WBXML_STRCMP("PROXY-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
296                                                         String_Node *target_ptr = ___get_Last_String_Node(bootstrap->proxy_id);
297                                                         if (target_ptr == NULL) {
298                                                                 _DEBUG_VERBOSE("boot strap PROXY-ID get null");
299                                                                 param_index++;
300                                                                 continue;
301                                                         }
302                                                         ___set_Param(pCursor, &(target_ptr->data));
303                                                         if(target_ptr->data != NULL) {
304                                                                 _DEBUG_VERBOSE("PROXY-ID : %s", target_ptr->data);
305                                                         }
306                                                         if (bootstrap->proxy_id == NULL) {
307                                                                 bootstrap->proxy_id = target_ptr;
308                                                         } else {
309                                                                 _DEBUG_VERBOSE("free proxy id");
310                                                                 free_string_node(target_ptr);
311                                                         }
312                                                 } else if (WBXML_STRCMP("PROVURL", wbxml_attribute_get_xml_value(param_attr)) == 0) {
313                                                         ___set_Param(pCursor, &(bootstrap->provurl));
314                                                         if(bootstrap->provurl != NULL) {
315                                                                 _DEBUG_VERBOSE("PROVURL : %s", bootstrap->provurl);
316                                                         }
317                                                 } else if (WBXML_STRCMP("CONTEXT-ALLOW", wbxml_attribute_get_xml_value(param_attr)) == 0) {
318                                                         ___set_Param(pCursor, &(bootstrap->context_allow));
319                                                         if(bootstrap->context_allow != NULL) {
320                                                                 _DEBUG_VERBOSE("CONTEXT-ALLOW : %s", bootstrap->context_allow);
321                                                         }
322                                                 }
323                                         }
324                                         param_index++;
325                                 }
326                         }
327                 }
328                 pCursor = pCursor->next;
329         }
330
331         _INNER_FUNC_EXIT;
332         return bootstrap;
333 }
334
335 static DM_CP_Napdef *__parse_Napdef(WBXMLTreeNode * wbxml_dom_node)
336 {
337         _INNER_FUNC_ENTER;
338
339         retvm_if((wbxml_dom_node) == NULL, NULL, "wbxml_dom_node is NULL!!");
340
341         DM_CP_Napdef *napdef = (DM_CP_Napdef *) calloc(1, sizeof(DM_CP_Napdef));
342         if (napdef == NULL) {
343                 _DEBUG_VERBOSE("alloc fail");
344                 _INNER_FUNC_EXIT;
345                 return 0;
346         }
347         WBXMLTreeNode *pCursor = wbxml_dom_node->children;
348
349         while (pCursor != 0) {
350                 if (pCursor->type == WBXML_TREE_ELEMENT_NODE) {
351                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor->name);
352                         if (!strcmp((const char *)tag_name, "parm")) {
353                                 WBXMLList *param_attrs = pCursor->attrs;
354                                 WB_ULONG param_index = 0;
355                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
356                                 while (param_index < param_nb_attrs) {
357                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
358                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
359                                                 if (WBXML_STRCMP("NAPID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
360                                                         ___set_Param(pCursor, &(napdef->nap_ID));
361                                                         if(napdef->nap_ID != NULL) {
362                                                                 _DEBUG_VERBOSE("NAPID : %s", napdef->nap_ID);
363                                                         }
364                                                 } else if (WBXML_STRCMP("BEARER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
365                                                         String_Node *target_ptr = ___get_Last_String_Node(napdef->bearer);
366                                                         if(target_ptr == NULL) {
367                                                                 _DEBUG_VERBOSE("___get_Last_String_Node fail");
368                                                                 _INNER_FUNC_EXIT;
369                                                                 return 0;
370                                                         }
371                                                         ___set_Param(pCursor, &(target_ptr->data));
372                                                         if(target_ptr->data != NULL) {
373                                                                 _DEBUG_VERBOSE("BEARER : %s", target_ptr->data);
374                                                         }
375                                                         if (napdef->bearer == NULL) {
376                                                                 napdef->bearer = target_ptr;
377                                                         } else {
378                                                                 _DEBUG_VERBOSE("free BEARER ");
379                                                                 free_string_node(target_ptr);
380                                                         }
381                                                 } else if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
382                                                         ___set_Param(pCursor, &(napdef->name));
383                                                         if(napdef->name != NULL) {
384                                                                 _DEBUG_VERBOSE("NAME : %s", napdef->name);
385                                                         }
386                                                 } else if (WBXML_STRCMP("INTERNET", wbxml_attribute_get_xml_value(param_attr)) == 0) {
387                                                         ___set_Param(pCursor, &(napdef->internet));
388                                                         if(napdef->internet != NULL) {
389                                                                 _DEBUG_VERBOSE("INTERNET : %s", napdef->internet);
390                                                         }
391                                                 } else if (WBXML_STRCMP("NAP-ADDRESS", wbxml_attribute_get_xml_value(param_attr)) == 0) {
392                                                         ___set_Param(pCursor, &(napdef->nap_address));
393                                                         if(napdef->nap_address != NULL) {
394                                                                 _DEBUG_VERBOSE("NAP-ADDRESS : %s", napdef->nap_address);
395                                                         }
396                                                 } else if (WBXML_STRCMP("NAP-ADDRTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
397                                                         ___set_Param(pCursor, &(napdef->nap_addr_type));
398                                                         if(napdef->nap_addr_type != NULL) {
399                                                                 _DEBUG_VERBOSE("NAP-ADDRTYPE : %s", napdef->nap_addr_type);
400                                                         }
401                                                 } else if (WBXML_STRCMP("DNS-ADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
402                                                         String_Node *target_ptr = ___get_Last_String_Node(napdef->dns_addr);
403                                                         if (target_ptr == NULL) {
404                                                                 _DEBUG_VERBOSE("DNS-ADDR is NULL");
405                                                                 param_index++;
406                                                                 continue;
407                                                         }
408
409                                                         ___set_Param(pCursor, &(target_ptr->data));
410                                                         if(target_ptr->data != NULL) {
411                                                                 _DEBUG_VERBOSE("DNS-ADDR : %s", target_ptr->data);
412                                                         }
413                                                         if (napdef->dns_addr == NULL) {
414                                                                 napdef->dns_addr = target_ptr;
415                                                         } else {
416                                                                 _DEBUG_VERBOSE("free DNS-ADDR ");
417                                                                 free_string_node(target_ptr);
418                                                         }
419                                                 } else if (WBXML_STRCMP("CALLTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
420                                                         ___set_Param(pCursor, &(napdef->call_type));
421                                                         if(napdef->call_type != NULL) {
422                                                                 _DEBUG_VERBOSE("CALLTYPE : %s", napdef->call_type);
423                                                         }
424                                                 } else if (WBXML_STRCMP("LOCAL-ADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
425                                                         ___set_Param(pCursor, &(napdef->local_addr));
426                                                         if(napdef->local_addr != NULL) {
427                                                                 _DEBUG_VERBOSE("LOCAL-ADDR : %s", napdef->local_addr);
428                                                         }
429                                                 } else if (WBXML_STRCMP("LOCAL-ADDRTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
430                                                         ___set_Param(pCursor, &(napdef->local_addr_type));
431                                                         if(napdef->local_addr_type != NULL) {
432                                                                 _DEBUG_VERBOSE("LOCAL-ADDRTYPE : %s", napdef->local_addr_type);
433                                                         }
434                                                 } else if (WBXML_STRCMP("LINKSPEED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
435                                                         ___set_Param(pCursor, &(napdef->link_speed));
436                                                         if(napdef->link_speed != NULL) {
437                                                                 _DEBUG_VERBOSE("LINKSPEED : %s", napdef->link_speed);
438                                                         }
439                                                 } else if (WBXML_STRCMP("DNLINKSPEED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
440                                                         ___set_Param(pCursor, &(napdef->dn_link_speed));
441                                                         if(napdef->dn_link_speed != NULL) {
442                                                                 _DEBUG_VERBOSE("DNLINKSPEED : %s", napdef->dn_link_speed);
443                                                         }
444                                                 } else if (WBXML_STRCMP("LINGER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
445                                                         ___set_Param(pCursor, &(napdef->linger));
446                                                         if(napdef->linger != NULL) {
447                                                                 _DEBUG_VERBOSE("LINGER : %s", napdef->linger);
448                                                         }
449                                                 } else if (WBXML_STRCMP("DELIVERY-ERR-SDU", wbxml_attribute_get_xml_value(param_attr)) == 0) {
450                                                         ___set_Param(pCursor, &(napdef->delivery_err_sdu));
451                                                         if(napdef->delivery_err_sdu != NULL) {
452                                                                 _DEBUG_VERBOSE("DELIVERY-ERR-SDU : %s", napdef->delivery_err_sdu);
453                                                         }
454                                                 } else if (WBXML_STRCMP("DELIVERY-ORDER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
455                                                         ___set_Param(pCursor, &(napdef->delivery_order));
456                                                         if(napdef->delivery_order != NULL) {
457                                                                 _DEBUG_VERBOSE("DELIVERY-ORDER : %s", napdef->delivery_order);
458                                                         }
459                                                 } else if (WBXML_STRCMP("TRAFFIC-CLASS", wbxml_attribute_get_xml_value(param_attr)) == 0) {
460                                                         ___set_Param(pCursor, &(napdef->traffic_class));
461                                                         if(napdef->traffic_class != NULL) {
462                                                                 _DEBUG_VERBOSE("TRAFFIC-CLASS : %s", napdef->traffic_class);
463                                                         }
464                                                 } else if (WBXML_STRCMP("MAX-SDU-SIZE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
465                                                         ___set_Param(pCursor, &(napdef->max_sdu_size));
466                                                         if(napdef->max_sdu_size != NULL) {
467                                                                 _DEBUG_VERBOSE("MAX-SDU-SIZE : %s", napdef->max_sdu_size);
468                                                         }
469                                                 } else if (WBXML_STRCMP("MAX-BITRATE-UPLINK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
470                                                         ___set_Param(pCursor, &(napdef->max_bitrate_uplink));
471                                                         if(napdef->max_bitrate_uplink != NULL) {
472                                                                 _DEBUG_VERBOSE("MAX-BITRATE-UPLINK : %s", napdef->max_bitrate_uplink);
473                                                         }
474                                                 } else if (WBXML_STRCMP("MAX-BITRATE-DNLINK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
475                                                         ___set_Param(pCursor, &(napdef->max_bitrate_dnlink));
476                                                         if(napdef->max_bitrate_dnlink != NULL) {
477                                                                 _DEBUG_VERBOSE("MAX-BITRATE-DNLINK : %s", napdef->max_bitrate_dnlink);
478                                                         }
479                                                 } else if (WBXML_STRCMP("RESIDUAL-BER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
480                                                         ___set_Param(pCursor, &(napdef->residual_ber));
481                                                         if(napdef->residual_ber != NULL) {
482                                                                 _DEBUG_VERBOSE("RESIDUAL-BER : %s", napdef->residual_ber);
483                                                         }
484                                                 } else if (WBXML_STRCMP("SDU-ERROR-RATIO", wbxml_attribute_get_xml_value(param_attr)) == 0) {
485                                                         ___set_Param(pCursor, &(napdef->sdu_error_ratio));
486                                                         if(napdef->sdu_error_ratio != NULL) {
487                                                                 _DEBUG_VERBOSE("SDU-ERROR-RATIO : %s", napdef->sdu_error_ratio);
488                                                         }
489                                                 } else if (WBXML_STRCMP("TRAFFIC-HANDL-PRIO", wbxml_attribute_get_xml_value(param_attr)) == 0) {
490                                                         ___set_Param(pCursor, &(napdef->traffic_handl_prio));
491                                                         if(napdef->traffic_handl_prio != NULL) {
492                                                                 _DEBUG_VERBOSE("TRAFFIC-HANDL-PRIO : %s", napdef->traffic_handl_prio);
493                                                         }
494                                                 } else if (WBXML_STRCMP("TRANSFER-DELAY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
495                                                         ___set_Param(pCursor, &(napdef->transfer_delay));
496                                                         if(napdef->transfer_delay != NULL) {
497                                                                 _DEBUG_VERBOSE("TRANSFER-DELAY : %s", napdef->transfer_delay);
498                                                         }
499                                                 } else if (WBXML_STRCMP("GUARANTEED-BITRATE-UPLINK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
500                                                         ___set_Param(pCursor, &(napdef->guaranteed_bitrate_uplink));
501                                                         if(napdef->guaranteed_bitrate_uplink != NULL) {
502                                                                 _DEBUG_VERBOSE("GUARANTEED-BITRATE-UPLINK : %s", napdef->guaranteed_bitrate_uplink);
503                                                         }
504                                                 } else if (WBXML_STRCMP("GUARANTEED-BITRATE-DNLINK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
505                                                         ___set_Param(pCursor, &(napdef->guaranteed_bitrate_dnlink));
506                                                         if(napdef->guaranteed_bitrate_dnlink != NULL) {
507                                                                 _DEBUG_VERBOSE("GUARANTEED-BITRATE-DNLINK : %s", napdef->guaranteed_bitrate_dnlink);
508                                                         }
509                                                 } else if (WBXML_STRCMP("MAX-NUM-RETRY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
510                                                         ___set_Param(pCursor, &(napdef->max_num_retry));
511                                                         if(napdef->max_num_retry != NULL) {
512                                                                 _DEBUG_VERBOSE("MAX-NUM-RETRY : %s", napdef->max_num_retry);
513                                                         }
514                                                 } else if (WBXML_STRCMP("FIRST-RETRY-TIMEOUT", wbxml_attribute_get_xml_value(param_attr)) == 0) {
515                                                         ___set_Param(pCursor, &(napdef->first_retry_timeout));
516                                                         if(napdef->first_retry_timeout != NULL) {
517                                                                 _DEBUG_VERBOSE("FIRST-RETRY-TIMEOUT : %s", napdef->first_retry_timeout);
518                                                         }
519                                                 } else if (WBXML_STRCMP("REREG-THRESHOLD", wbxml_attribute_get_xml_value(param_attr)) == 0) {
520                                                         ___set_Param(pCursor, &(napdef->rereg_threshold));
521                                                         if(napdef->rereg_threshold != NULL) {
522                                                                 _DEBUG_VERBOSE("REREG-THRESHOLD : %s", napdef->rereg_threshold);
523                                                         }
524                                                 } else if (WBXML_STRCMP("T-BIT", wbxml_attribute_get_xml_value(param_attr)) == 0) {
525                                                         ___set_Param(pCursor, &(napdef->t_bit));
526                                                         if(napdef->t_bit != NULL) {
527                                                                 _DEBUG_VERBOSE("T-BIT : %s", napdef->t_bit);
528                                                         }
529                                                 }
530                                         }
531                                         param_index++;
532                                 }
533                         } else if (!strcmp((const char *)tag_name, "characteristic")) {
534                                 WBXMLList *attrs = pCursor->attrs;
535                                 WB_ULONG index = 0;
536                                 WB_ULONG nb_attrs = wbxml_list_len(attrs);
537
538                                 while (index < nb_attrs) {
539                                         WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attrs, index);
540                                         if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(attr)) == 0) {
541                                                 if (WBXML_STRCMP("NAPAUTHINFO", wbxml_attribute_get_xml_value(attr)) == 0) {
542                                                         DM_CP_Napdef_AuthInfo *auth_info = (DM_CP_Napdef_AuthInfo *) calloc(1, sizeof(DM_CP_Napdef_AuthInfo));
543                                                         if (auth_info == NULL) {
544                                                                 _DEBUG_VERBOSE("alloc fail");
545                                                                 free_cp_napdef(napdef);
546                                                                 napdef = NULL;
547                                                                 _INNER_FUNC_EXIT;
548                                                                 return 0;
549                                                         }
550                                                         if (napdef->auth_info == NULL) {
551                                                                 napdef->auth_info = auth_info;
552                                                         } else {
553                                                                 DM_CP_Napdef_AuthInfo *cursor_ptr = napdef->auth_info;
554                                                                 while (cursor_ptr != NULL) {
555                                                                         if (cursor_ptr->next == NULL) {
556                                                                                 cursor_ptr->next = auth_info;
557                                                                                 break;
558                                                                         }
559                                                                         cursor_ptr = cursor_ptr->next;
560                                                                 }
561                                                         }
562                                                         WBXMLTreeNode *pCursor_AuthInfo = pCursor->children;
563                                                         while (pCursor_AuthInfo != 0) {
564                                                                 if (pCursor_AuthInfo->type == WBXML_TREE_ELEMENT_NODE) {
565                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_AuthInfo->name);
566                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
567                                                                                 WBXMLList *param_attrs = pCursor_AuthInfo->attrs;
568                                                                                 WB_ULONG param_index = 0;
569                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
570                                                                                 while (param_index < param_nb_attrs) {
571                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
572                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
573                                                                                                 if (WBXML_STRCMP("AUTHTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
574                                                                                                         ___set_Param(pCursor_AuthInfo, &(auth_info->auth_type));
575                                                                                                         if(auth_info->auth_type != NULL) {
576                                                                                                                 _DEBUG_VERBOSE("AUTHTYPE : %s", auth_info->auth_type);
577                                                                                                         }
578                                                                                                 } else if (WBXML_STRCMP("AUTHNAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
579                                                                                                         ___set_Param(pCursor_AuthInfo, &(auth_info->auth_name));
580                                                                                                         if(auth_info->auth_name != NULL) {
581                                                                                                                 _DEBUG_VERBOSE("AUTHNAME : %s", auth_info->auth_name);
582                                                                                                         }
583                                                                                                 } else if (WBXML_STRCMP("AUTHSECRET", wbxml_attribute_get_xml_value(param_attr)) == 0) {
584                                                                                                         ___set_Param(pCursor_AuthInfo, &(auth_info->auth_secret));
585                                                                                                         if(auth_info->auth_secret != NULL) {
586                                                                                                                 _DEBUG_VERBOSE("AUTHSECRET : %s", auth_info->auth_secret);
587                                                                                                         }
588                                                                                                 } else if (WBXML_STRCMP("AUTH-ENTITY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
589                                                                                                         String_Node *target_ptr = ___get_Last_String_Node(auth_info->auth_entity);
590                                                                                                         if (target_ptr == NULL) {
591                                                                                                                 _DEBUG_VERBOSE("auth entity is NULL");
592                                                                                                                 param_index++;
593                                                                                                                 continue;
594                                                                                                         }
595                                                                                                         ___set_Param(pCursor_AuthInfo, &(target_ptr->data));
596                                                                                                         if(target_ptr->data != NULL) {
597                                                                                                                 _DEBUG_VERBOSE("AUTH-ENTITY : %s", target_ptr->data);
598                                                                                                         }
599                                                                                                         if (auth_info->auth_entity == NULL) {
600                                                                                                                 auth_info->auth_entity = target_ptr;
601                                                                                                         } else {
602                                                                                                                 _DEBUG_VERBOSE("free auth entity");
603                                                                                                                 free_string_node(target_ptr);
604                                                                                                         }
605                                                                                                 } else if (WBXML_STRCMP("SPI", wbxml_attribute_get_xml_value(param_attr)) == 0) {
606                                                                                                         ___set_Param(pCursor_AuthInfo, &(auth_info->spi));
607                                                                                                         if(auth_info->spi != NULL ) {
608                                                                                                                 _DEBUG_VERBOSE("SPI : %s", auth_info->spi);
609                                                                                                         }
610                                                                                                 }
611                                                                                                 break;
612                                                                                         }
613                                                                                         param_index++;
614                                                                                 }
615                                                                         }
616                                                                 }
617                                                                 pCursor_AuthInfo = pCursor_AuthInfo->next;
618                                                         }
619                                                 } else if (WBXML_STRCMP("VALIDITY", wbxml_attribute_get_xml_value(attr)) == 0) {
620                                                         DM_CP_Napdef_validity *validity = (DM_CP_Napdef_validity *) calloc(1, sizeof(DM_CP_Napdef_validity));
621                                                         if (validity == NULL) {
622                                                                 _DEBUG_VERBOSE("alloc fail");
623                                                                 free_cp_napdef(napdef);
624                                                                 napdef = NULL;
625                                                                 _INNER_FUNC_EXIT;
626                                                                 return 0;
627                                                         }
628                                                         if (napdef->validity == NULL) {
629                                                                 napdef->validity = validity;
630                                                         } else {
631                                                                 DM_CP_Napdef_validity *cursor_ptr = napdef->validity;
632                                                                 while (cursor_ptr != NULL) {
633                                                                         if (cursor_ptr->next == NULL) {
634                                                                                 cursor_ptr->next = validity;
635                                                                                 break;
636                                                                         }
637                                                                         cursor_ptr = cursor_ptr->next;
638                                                                 }
639                                                         }
640                                                         WBXMLTreeNode *pCursor_Validity = pCursor->children;
641                                                         while (pCursor_Validity != 0) {
642                                                                 if (pCursor_Validity->type == WBXML_TREE_ELEMENT_NODE) {
643                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Validity->name);
644                                                                         if (!strcmp((const char *)tag_name, "parm")) {
645                                                                                 WBXMLList *param_attrs = pCursor_Validity->attrs;
646                                                                                 WB_ULONG param_index = 0;
647                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
648                                                                                 while (param_index < param_nb_attrs) {
649                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
650                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
651                                                                                                 if (WBXML_STRCMP("COUNTRY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
652                                                                                                         ___set_Param(pCursor_Validity, &(validity->country));
653                                                                                                         if(validity->country != NULL) {
654                                                                                                                 _DEBUG_VERBOSE("COUNTRY : %s", validity->country);
655                                                                                                         }
656                                                                                                 } else if (WBXML_STRCMP("NETWORK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
657                                                                                                         ___set_Param(pCursor_Validity, &(validity->network));
658                                                                                                         if(validity->network != NULL) {
659                                                                                                                 _DEBUG_VERBOSE("NETWORK : %s", validity->network);
660                                                                                                         }
661                                                                                                 } else if (WBXML_STRCMP("SID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
662                                                                                                         ___set_Param(pCursor_Validity, &(validity->sid));
663                                                                                                         if(validity->sid != NULL) {
664                                                                                                                 _DEBUG_VERBOSE("SID : %s", validity->sid);
665                                                                                                         }
666                                                                                                 } else if (WBXML_STRCMP("SOC", wbxml_attribute_get_xml_value(param_attr)) == 0) {
667                                                                                                         ___set_Param(pCursor_Validity, &(validity->soc));
668                                                                                                         if(validity->soc != NULL) {
669                                                                                                                 _DEBUG_VERBOSE("SOC : %s", validity->soc);
670                                                                                                         }
671                                                                                                 } else if (WBXML_STRCMP("VALIDUNTIL", wbxml_attribute_get_xml_value(param_attr)) == 0) {
672                                                                                                         ___set_Param(pCursor_Validity, &(validity->validuntil));
673                                                                                                         if(validity->validuntil != NULL) {
674                                                                                                                 _DEBUG_VERBOSE("VALIDUNTIL : %s", validity->validuntil);
675                                                                                                         }
676                                                                                                 }
677                                                                                                 break;
678                                                                                         }
679                                                                                         param_index++;
680                                                                                 }
681                                                                         }
682                                                                 }
683                                                                 pCursor_Validity = pCursor_Validity->next;
684                                                         }
685                                                 }
686                                         }
687                                         index++;
688                                 }
689                         }
690                 }
691                 pCursor = pCursor->next;
692         }
693
694         _INNER_FUNC_EXIT;
695
696         return napdef;
697 }
698
699 static DM_CP_Application *__parse_Application(WBXMLTreeNode * wbxml_dom_node)
700 {
701         _INNER_FUNC_ENTER;
702
703         retvm_if((wbxml_dom_node) == NULL, NULL, "wbxml_dom_node is NULL!!");
704
705         DM_CP_Application *application = (DM_CP_Application *) calloc(1, sizeof(DM_CP_Application));
706         if (application == NULL) {
707                 _DEBUG_VERBOSE("alloc fail");
708                 _INNER_FUNC_EXIT;
709                 return 0;
710         }
711         WBXMLTreeNode *pCursor = wbxml_dom_node->children;
712
713         while (pCursor != 0) {
714                 if (pCursor->type == WBXML_TREE_ELEMENT_NODE) {
715                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor->name);
716                         if (strcmp((const char *)tag_name, "parm") == 0) {
717                                 WBXMLList *param_attrs = pCursor->attrs;
718                                 WB_ULONG param_index = 0;
719                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
720                                 while (param_index < param_nb_attrs) {
721                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
722                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
723                                                 if (WBXML_STRCMP("APPID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
724                                                         ___set_Param(pCursor, &(application->app_ID));
725                                                         if(application->app_ID != NULL) {
726                                                                 _DEBUG_VERBOSE("APPID : %s", application->app_ID);
727                                                         }
728                                                 } else if (WBXML_STRCMP("PROVIDER-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
729                                                         ___set_Param(pCursor, &(application->provider_ID));
730                                                         if(application->provider_ID != NULL) {
731                                                                 _DEBUG_VERBOSE("PROVIDER-ID : %s", application->provider_ID);
732                                                         }
733                                                 } else if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
734                                                         ___set_Param(pCursor, &(application->name));
735                                                         if(application->name != NULL) {
736                                                                 _DEBUG_VERBOSE("NAME : %s", application->name);
737                                                         }
738                                                 } else if (WBXML_STRCMP("AACCEPT", wbxml_attribute_get_xml_value(param_attr)) == 0) {
739                                                         ___set_Param(pCursor, &(application->accept));
740                                                         if(application->accept != NULL) {
741                                                                 _DEBUG_VERBOSE("AACCEPT : %s", application->accept);
742                                                         }
743                                                 } else if (WBXML_STRCMP("APROTOCOL", wbxml_attribute_get_xml_value(param_attr)) == 0) {
744                                                         ___set_Param(pCursor, &(application->protocol));
745                                                         if(application->protocol != NULL) {
746                                                                 _DEBUG_VERBOSE("APROTOCOL : %s", application->protocol);
747                                                         }
748                                                 } else if (WBXML_STRCMP("TO-PROXY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
749                                                         String_Node *target_ptr = ___get_Last_String_Node(application->to_proxy);
750                                                         if (target_ptr == NULL) {
751                                                                 _DEBUG_VERBOSE("TO-PROXY is NULL");
752                                                                 param_index++;
753                                                                 continue;
754                                                         }
755
756                                                         ___set_Param(pCursor, &(target_ptr->data));
757                                                         if(target_ptr->data != NULL) {
758                                                                 _DEBUG_VERBOSE("PROXY : %s", target_ptr->data);
759                                                         }
760
761                                                         if (application->to_proxy == NULL) {
762                                                                 application->to_proxy = target_ptr;
763                                                         } else {
764                                                                 _DEBUG_VERBOSE("free PROXY ");
765                                                                 free_string_node(target_ptr);
766                                                         }
767                                                 } else if (WBXML_STRCMP("TO-NAPID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
768                                                         String_Node *target_ptr = ___get_Last_String_Node(application->to_napid);
769                                                         if (target_ptr == NULL) {
770                                                                 _DEBUG_VERBOSE("TO-NAPID is NULL");
771                                                                 param_index++;
772                                                                 continue;
773                                                         }
774
775                                                         ___set_Param(pCursor, &(target_ptr->data));
776                                                         if(target_ptr->data != NULL) {
777                                                                 _DEBUG_VERBOSE("NAPID : %s", target_ptr->data);
778                                                         }
779                                                         if (application->to_napid == NULL) {
780                                                                 application->to_napid = target_ptr;
781                                                         } else {
782                                                                 _DEBUG_VERBOSE("free NAPID ");
783                                                                 free_string_node(target_ptr);
784                                                         }
785                                                 } else if (WBXML_STRCMP("ADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
786                                                         String_Node *target_ptr = ___get_Last_String_Node(application->addr);
787                                                         if (target_ptr == NULL) {
788                                                                 _DEBUG_VERBOSE("ADDR is NULL");
789                                                                 param_index++;
790                                                                 continue;
791                                                         }
792
793                                                         ___set_Param(pCursor, &(target_ptr->data));
794                                                         if(target_ptr->data != NULL) {
795                                                                 _DEBUG_VERBOSE("ADDR : %s", target_ptr->data);
796                                                         }
797                                                         if (application->addr == NULL) {
798                                                                 application->addr = target_ptr;
799                                                         } else {
800                                                                 _DEBUG_VERBOSE("free ADDR ");
801                                                                 free_string_node(target_ptr);
802                                                         }
803                                                 }
804                                                 break;
805                                         }
806                                         param_index++;
807                                 }
808                         } else if (!strcmp((const char *)tag_name, "characteristic")) {
809                                 WBXMLList *attrs = pCursor->attrs;
810                                 WB_ULONG index = 0;
811                                 WB_ULONG nb_attrs = wbxml_list_len(attrs);
812
813                                 while (index < nb_attrs) {
814                                         WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attrs, index);
815
816                                         if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(attr)) == 0) {
817
818                                                 if (WBXML_STRCMP("APPADDR", wbxml_attribute_get_xml_value(attr)) == 0) {
819                                                         DM_CP_Application_AppAddr *app_addr = (DM_CP_Application_AppAddr *) calloc(1, sizeof(DM_CP_Application_AppAddr));
820                                                         if (app_addr == NULL) {
821                                                                 _DEBUG_VERBOSE("alloc fail");
822                                                                 free_cp_application(application);
823                                                                 application = NULL;
824                                                                 _INNER_FUNC_EXIT;
825                                                                 return 0;
826                                                         }
827                                                         if (application->appAddr == NULL) {
828                                                                 application->appAddr = app_addr;
829                                                         } else {
830                                                                 DM_CP_Application_AppAddr *cursor_ptr = application->appAddr;
831                                                                 while (cursor_ptr != NULL) {
832                                                                         if (cursor_ptr->next == NULL) {
833                                                                                 cursor_ptr->next = app_addr;
834                                                                                 break;
835                                                                         }
836                                                                         cursor_ptr = cursor_ptr->next;
837                                                                 }
838                                                         }
839                                                         WBXMLTreeNode *pCursor_AppAddr = pCursor->children;
840                                                         while (pCursor_AppAddr != 0) {
841                                                                 if (pCursor_AppAddr->type == WBXML_TREE_ELEMENT_NODE) {
842                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_AppAddr->name);
843                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
844                                                                                 WBXMLList *param_attrs = pCursor_AppAddr->attrs;
845                                                                                 WB_ULONG param_index = 0;
846                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
847                                                                                 while (param_index < param_nb_attrs) {
848                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
849                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
850                                                                                                 if (WBXML_STRCMP("ADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
851                                                                                                         ___set_Param(pCursor_AppAddr, &(app_addr->addr));
852                                                                                                         if(app_addr->addr != NULL) {
853                                                                                                                 _DEBUG_VERBOSE("ADDR : %s", app_addr->addr);
854                                                                                                         }
855                                                                                                 } else if (WBXML_STRCMP("ADDRTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
856                                                                                                         ___set_Param(pCursor_AppAddr, &(app_addr->addr_type));
857                                                                                                         if(app_addr->addr_type != NULL) {
858                                                                                                                 _DEBUG_VERBOSE("ADDRTYPE : %s", app_addr->addr_type);
859                                                                                                         }
860                                                                                                 }
861                                                                                                 break;
862                                                                                         }
863                                                                                         param_index++;
864                                                                                 }
865                                                                         } else if (strcmp((const char *)tag_name, "characteristic") == 0) {
866                                                                                 WBXMLList *addr_attrs = pCursor_AppAddr->attrs;
867                                                                                 WB_ULONG addr_index = 0;
868                                                                                 WB_ULONG addr_nb_attrs = wbxml_list_len(addr_attrs);
869
870                                                                                 while (addr_index < addr_nb_attrs) {
871                                                                                         WBXMLAttribute *addr_attr = (WBXMLAttribute *) wbxml_list_get(addr_attrs, addr_index);
872                                                                                         if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(addr_attr)) == 0) {
873                                                                                                 if (WBXML_STRCMP("PORT", wbxml_attribute_get_xml_value(addr_attr)) == 0) {
874                                                                                                         DM_CP_Port *port = (DM_CP_Port *) calloc(1, sizeof(DM_CP_Port));
875                                                                                                         if (port == NULL) {
876                                                                                                                 _DEBUG_VERBOSE("alloc fail");
877                                                                                                                 free_cp_application(application);
878                                                                                                                 application = NULL;
879                                                                                                                 _INNER_FUNC_EXIT;
880                                                                                                                 return 0;
881                                                                                                         }
882                                                                                                         if (app_addr->port == NULL) {
883                                                                                                                 app_addr->port = port;
884                                                                                                         } else {
885                                                                                                                 DM_CP_Port *cursor_ptr = app_addr->port;
886                                                                                                                 while (cursor_ptr != NULL) {
887                                                                                                                         if (cursor_ptr->next == NULL) {
888                                                                                                                                 cursor_ptr->next = port;
889                                                                                                                                 break;
890                                                                                                                         }
891                                                                                                                         cursor_ptr = cursor_ptr->next;
892                                                                                                                 }
893                                                                                                         }
894                                                                                                         WBXMLTreeNode *pCursor_Port = pCursor_AppAddr->children;
895                                                                                                         while (pCursor_Port != 0) {
896                                                                                                                 if (pCursor_Port->type == WBXML_TREE_ELEMENT_NODE) {
897                                                                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Port->name);
898                                                                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
899                                                                                                                                 WBXMLList *_param_attrs = pCursor_Port->attrs;
900                                                                                                                                 WB_ULONG _param_index = 0;
901                                                                                                                                 WB_ULONG _param_nb_attrs = wbxml_list_len(_param_attrs);
902                                                                                                                                 while (_param_index < _param_nb_attrs) {
903                                                                                                                                         WBXMLAttribute *_param_attr = (WBXMLAttribute *) wbxml_list_get(_param_attrs, _param_index);
904                                                                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(_param_attr)) == 0) {
905                                                                                                                                                 if (WBXML_STRCMP("PORTNBR", wbxml_attribute_get_xml_value(_param_attr)) == 0) {
906                                                                                                                                                         ___set_Param(pCursor_Port, &(port->portnbr));
907                                                                                                                                                         if(port->portnbr != NULL) {
908                                                                                                                                                                 _DEBUG_VERBOSE("[%d] PORTNBR : %s", _param_index, port->portnbr);
909                                                                                                                                                         }
910                                                                                                                                                 } else if (WBXML_STRCMP("SERVICE", wbxml_attribute_get_xml_value(_param_attr)) == 0) {
911                                                                                                                                                         String_Node *target_ptr = ___get_Last_String_Node(port->service);
912                                                                                                                                                         if (target_ptr == NULL) {
913                                                                                                                                                                 _DEBUG_VERBOSE("SERVICE is NULL");
914                                                                                                                                                                 _param_index++;
915                                                                                                                                                                 continue;
916                                                                                                                                                         }
917
918                                                                                                                                                         ___set_Param(pCursor_Port, &(target_ptr->data));
919                                                                                                                                                         if(target_ptr->data != NULL) {
920                                                                                                                                                                 _DEBUG_VERBOSE("SERVICE : %s", target_ptr->data);
921                                                                                                                                                         }
922                                                                                                                                                         if (port->service == NULL) {
923                                                                                                                                                                 port->service = target_ptr;
924                                                                                                                                                         } else {
925                                                                                                                                                                 _DEBUG_VERBOSE("free port service");
926                                                                                                                                                                 free_string_node(target_ptr);
927                                                                                                                                                         }
928                                                                                                                                                 }
929                                                                                                                                                 break;
930                                                                                                                                         }
931                                                                                                                                         _param_index++;
932                                                                                                                                         _DEBUG_VERBOSE("param_index : %d", _param_index);
933                                                                                                                                 }
934                                                                                                                         }
935                                                                                                                 }
936                                                                                                                 pCursor_Port = pCursor_Port->next;
937                                                                                                         }
938                                                                                                 }
939                                                                                         }
940                                                                                         addr_index++;
941                                                                                 }
942                                                                         }
943                                                                 }
944
945                                                                 pCursor_AppAddr = pCursor_AppAddr->next;
946                                                         }
947                                                 } else if (WBXML_STRCMP("APPAUTH", wbxml_attribute_get_xml_value(attr)) == 0) {
948                                                         DM_CP_Application_AppAuth *app_auth = (DM_CP_Application_AppAuth *) calloc(1, sizeof(DM_CP_Application_AppAuth));
949                                                         if (app_auth == NULL) {
950                                                                 _DEBUG_VERBOSE("alloc fail");
951                                                                 free_cp_application(application);
952                                                                 application = NULL;
953                                                                 _INNER_FUNC_EXIT;
954                                                                 return 0;
955                                                         }
956                                                         if (application->appAuth == NULL) {
957                                                                 application->appAuth = app_auth;
958                                                         } else {
959                                                                 DM_CP_Application_AppAuth *cursor_ptr = application->appAuth;
960                                                                 while (cursor_ptr != NULL) {
961                                                                         if (cursor_ptr->next == NULL) {
962                                                                                 cursor_ptr->next = app_auth;
963                                                                                 break;
964                                                                         }
965                                                                         cursor_ptr = cursor_ptr->next;
966                                                                 }
967                                                         }
968                                                         WBXMLTreeNode *pCursor_AppAuth = pCursor->children;
969                                                         while (pCursor_AppAuth != 0) {
970                                                                 if (pCursor_AppAuth->type == WBXML_TREE_ELEMENT_NODE) {
971                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_AppAuth->name);
972                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
973                                                                                 WBXMLList *param_attrs = pCursor_AppAuth->attrs;
974                                                                                 WB_ULONG param_index = 0;
975                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
976                                                                                 while (param_index < param_nb_attrs) {
977                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
978                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
979                                                                                                 if (WBXML_STRCMP("AAUTHLEVEL", wbxml_attribute_get_xml_value(param_attr)) == 0) {
980                                                                                                         ___set_Param(pCursor_AppAuth, &(app_auth->auth_level));
981                                                                                                         if(app_auth->auth_level != NULL) {
982                                                                                                                 _DEBUG_VERBOSE("AAUTHLEVEL : %s", app_auth->auth_level);
983                                                                                                         }
984                                                                                                 } else if (WBXML_STRCMP("AAUTHTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
985                                                                                                         ___set_Param(pCursor_AppAuth, &(app_auth->auth_type));
986                                                                                                         if(app_auth->auth_type != NULL) {
987                                                                                                                 _DEBUG_VERBOSE("AAUTHTYPE : %s", app_auth->auth_type);
988                                                                                                         }
989                                                                                                 } else if (WBXML_STRCMP("AAUTHNAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
990                                                                                                         ___set_Param(pCursor_AppAuth, &(app_auth->auth_name));
991                                                                                                         if(app_auth->auth_name != NULL) {
992                                                                                                                 _DEBUG_VERBOSE("AAUTHNAME : %s", app_auth->auth_name);
993                                                                                                         }
994                                                                                                 } else if (WBXML_STRCMP("AAUTHSECRET", wbxml_attribute_get_xml_value(param_attr)) == 0) {
995                                                                                                         ___set_Param(pCursor_AppAuth, &(app_auth->auth_secret));
996                                                                                                         if(app_auth->auth_secret != NULL) {
997                                                                                                                 _DEBUG_VERBOSE("AAUTHSECRET : %s", app_auth->auth_secret);
998                                                                                                         }
999                                                                                                 } else if (WBXML_STRCMP("AAUTHDATA", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1000                                                                                                         ___set_Param(pCursor_AppAuth, &(app_auth->auth_data));
1001                                                                                                         if(app_auth->auth_data != NULL) {
1002                                                                                                                 _DEBUG_VERBOSE("AAUTHDATA : %s", app_auth->auth_data);
1003                                                                                                         }
1004                                                                                                 }
1005                                                                                                 break;
1006                                                                                         }
1007                                                                                         param_index++;
1008                                                                                 }
1009                                                                         }
1010                                                                 }
1011                                                                 pCursor_AppAuth = pCursor_AppAuth->next;
1012                                                         }
1013                                                 } else if (WBXML_STRCMP("RESOURCE", wbxml_attribute_get_xml_value(attr)) == 0) {
1014                                                         DM_CP_Application_Resource *app_resource = (DM_CP_Application_Resource *) calloc(1, sizeof(DM_CP_Application_Resource));
1015                                                         if (app_resource == NULL) {
1016                                                                 _DEBUG_VERBOSE("alloc fail");
1017                                                                 free_cp_application(application);
1018                                                                 application = NULL;
1019                                                                 _INNER_FUNC_EXIT;
1020                                                                 return 0;
1021                                                         }
1022                                                         if (application->resource == NULL) {
1023                                                                 application->resource = app_resource;
1024                                                         } else {
1025                                                                 DM_CP_Application_Resource *cursor_ptr = application->resource;
1026                                                                 while (cursor_ptr != NULL) {
1027                                                                         if (cursor_ptr->next == NULL) {
1028                                                                                 cursor_ptr->next = app_resource;
1029                                                                                 break;
1030                                                                         }
1031                                                                         cursor_ptr = cursor_ptr->next;
1032                                                                 }
1033                                                         }
1034                                                         WBXMLTreeNode *pCursor_Resource = pCursor->children;
1035                                                         while (pCursor_Resource != 0) {
1036                                                                 if (pCursor_Resource->type == WBXML_TREE_ELEMENT_NODE) {
1037                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Resource->name);
1038                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
1039                                                                                 WBXMLList *param_attrs = pCursor_Resource->attrs;
1040                                                                                 WB_ULONG param_index = 0;
1041                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
1042                                                                                 while (param_index < param_nb_attrs) {
1043                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
1044                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
1045                                                                                                 if (WBXML_STRCMP("URI", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1046                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->uri));
1047                                                                                                         if(app_resource->uri != NULL) {
1048                                                                                                                 _DEBUG_VERBOSE("URI : %s", app_resource->uri);
1049                                                                                                         }
1050                                                                                                 } else if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1051                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->name));
1052                                                                                                         if(app_resource->name != NULL) {
1053                                                                                                                 _DEBUG_VERBOSE("NAME : %s", app_resource->name);
1054                                                                                                         }
1055                                                                                                 } else if (WBXML_STRCMP("AACCEPT", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1056                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->accept));
1057                                                                                                         if(app_resource->accept != NULL) {
1058                                                                                                                 _DEBUG_VERBOSE("AACCEPT : %s", app_resource->accept);
1059                                                                                                         }
1060                                                                                                 } else if (WBXML_STRCMP("AAUTHTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1061                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->auth_type));
1062                                                                                                         if(app_resource->auth_type != NULL) {
1063                                                                                                                 _DEBUG_VERBOSE("AAUTHTYPE : %s", app_resource->auth_type);
1064                                                                                                         }
1065                                                                                                 } else if (WBXML_STRCMP("AAUTHNAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1066                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->auth_name));
1067                                                                                                         if(app_resource->auth_name != NULL) {
1068                                                                                                                 _DEBUG_VERBOSE("AAUTHNAME : %s", app_resource->auth_name);
1069                                                                                                         }
1070                                                                                                 } else if (WBXML_STRCMP("AAUTHSECRET", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1071                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->auth_secret));
1072                                                                                                         if(app_resource->auth_secret != NULL) {
1073                                                                                                                 _DEBUG_VERBOSE("AAUTHSECRET : %s", app_resource->auth_secret);
1074                                                                                                         }
1075                                                                                                 } else if (WBXML_STRCMP("AAUTHDATA", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1076                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->auth_data));
1077                                                                                                         if(app_resource->auth_data != NULL) {
1078                                                                                                                 _DEBUG_VERBOSE("AAUTHDATA : %s", app_resource->auth_data);
1079                                                                                                         }
1080                                                                                                 } else if (WBXML_STRCMP("STARTPAGE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1081                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->start_page));
1082                                                                                                         if(app_resource->start_page != NULL) {
1083                                                                                                                 _DEBUG_VERBOSE("STARTPAGE : %s", app_resource->start_page);
1084                                                                                                         }
1085                                                                                                 }
1086                                                                                                 break;
1087                                                                                         }
1088                                                                                         param_index++;
1089                                                                                 }
1090                                                                         }
1091                                                                 }
1092                                                                 pCursor_Resource = pCursor_Resource->next;
1093                                                         }
1094                                                 }
1095                                         }
1096
1097                                         index++;
1098                                 }
1099                         }
1100                 }
1101
1102                 pCursor = pCursor->next;
1103         }
1104
1105         _INNER_FUNC_EXIT;
1106
1107         return application;
1108 }
1109
1110 static DM_CP_PxLogical *__parse_PxLogical(WBXMLTreeNode * wbxml_dom_node)
1111 {
1112         _INNER_FUNC_ENTER;
1113
1114         retvm_if((wbxml_dom_node) == NULL, NULL, "wbxml_dom_node is NULL!!");
1115
1116         DM_CP_PxLogical *pxLogical = (DM_CP_PxLogical *) calloc(1, sizeof(DM_CP_PxLogical));
1117         if (pxLogical == NULL) {
1118                 _DEBUG_VERBOSE("alloc fail");
1119                 _INNER_FUNC_EXIT;
1120                 return 0;
1121         }
1122         WBXMLTreeNode *pCursor = wbxml_dom_node->children;
1123
1124         while (pCursor != 0) {
1125                 if (pCursor->type == WBXML_TREE_ELEMENT_NODE) {
1126                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor->name);
1127                         if (strcmp((const char *)tag_name, "parm") == 0) {
1128                                 WBXMLList *param_attrs = pCursor->attrs;
1129                                 WB_ULONG param_index = 0;
1130                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
1131                                 while (param_index < param_nb_attrs) {
1132                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
1133                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
1134                                                 if (WBXML_STRCMP("PROXY-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1135                                                         ___set_Param(pCursor, &(pxLogical->proxy_id));
1136                                                         if(pxLogical->proxy_id != NULL) {
1137                                                                 _DEBUG_VERBOSE("PROXY-ID : %s", pxLogical->proxy_id);
1138                                                         }
1139                                                 } else if (WBXML_STRCMP("PROXY-PW", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1140                                                         ___set_Param(pCursor, &(pxLogical->proxy_pw));
1141                                                         if(pxLogical->proxy_pw != NULL) {
1142                                                                 _DEBUG_VERBOSE("PROXY-PW : %s", pxLogical->proxy_pw);
1143                                                         }
1144                                                 } else if (WBXML_STRCMP("PPGAUTH-TYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1145                                                         ___set_Param(pCursor, &(pxLogical->ppg_auth_type));
1146                                                         if(pxLogical->ppg_auth_type != NULL) {
1147                                                                 _DEBUG_VERBOSE("PPGAUTH-TYPE : %s", pxLogical->ppg_auth_type);
1148                                                         }
1149                                                 } else if (WBXML_STRCMP("PROXY-PROVIDER-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1150                                                         ___set_Param(pCursor, &(pxLogical->proxy_provider_id));
1151                                                         if(pxLogical->proxy_provider_id != NULL) {
1152                                                                 _DEBUG_VERBOSE("PROXY-PROVIDER-ID : %s", pxLogical->proxy_provider_id);
1153                                                         }
1154                                                 } else if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1155                                                         ___set_Param(pCursor, &(pxLogical->name));
1156                                                         if(pxLogical->name != NULL) {
1157                                                                 _DEBUG_VERBOSE("NAME : %s", pxLogical->name);
1158                                                         }
1159                                                 } else if (WBXML_STRCMP("DOMAIN", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1160                                                         String_Node *target_ptr = ___get_Last_String_Node(pxLogical->domain);
1161                                                         if(target_ptr == NULL) {
1162                                                                 _DEBUG_VERBOSE("___get_Last_String_Node fail");
1163                                                                 _INNER_FUNC_EXIT;
1164                                                                 return 0;
1165                                                         }
1166                                                         ___set_Param(pCursor, &(target_ptr->data));
1167                                                         if(target_ptr->data != NULL) {
1168                                                                 _DEBUG_VERBOSE("DOMAIN : %s", target_ptr->data);
1169                                                         }
1170                                                         if (pxLogical->domain == 0) {
1171                                                                 pxLogical->domain = target_ptr;
1172                                                         } else {
1173                                                                 _DEBUG_VERBOSE("free DOMAIN ");
1174                                                                 free_string_node(target_ptr);
1175                                                         }
1176                                                 } else if (WBXML_STRCMP("TRUST", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1177                                                         ___set_Param(pCursor, &(pxLogical->trust));
1178                                                         if(pxLogical->trust != NULL) {
1179                                                                 _DEBUG_VERBOSE("TRUST : %s", pxLogical->trust);
1180                                                         }
1181                                                 } else if (WBXML_STRCMP("MASTER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1182                                                         ___set_Param(pCursor, &(pxLogical->master));
1183                                                         if(pxLogical->master != NULL) {
1184                                                                 _DEBUG_VERBOSE("MASTER : %s", pxLogical->master);
1185                                                         }
1186                                                 } else if (WBXML_STRCMP("STARTPAGE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1187                                                         ___set_Param(pCursor, &(pxLogical->start_page));
1188                                                         if(pxLogical->start_page != NULL) {
1189                                                                 _DEBUG_VERBOSE("STARTPAGE : %s", pxLogical->start_page);
1190                                                         }
1191                                                 } else if (WBXML_STRCMP("BASAUTH-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1192                                                         ___set_Param(pCursor, &(pxLogical->bas_auth_id));
1193                                                         if(pxLogical->bas_auth_id != NULL) {
1194                                                                 _DEBUG_VERBOSE("BASAUTH-ID : %s", pxLogical->bas_auth_id);
1195                                                         }
1196                                                 } else if (WBXML_STRCMP("BASAUTH-PW", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1197                                                         ___set_Param(pCursor, &(pxLogical->bas_auth_pw));
1198                                                         if(pxLogical->bas_auth_pw != NULL) {
1199                                                                 _DEBUG_VERBOSE("BASAUTH-PW : %s", pxLogical->bas_auth_pw);
1200                                                         }
1201                                                 } else if (WBXML_STRCMP("WSP-VERSION", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1202                                                         ___set_Param(pCursor, &(pxLogical->wsp_version));
1203                                                         if(pxLogical->wsp_version != NULL) {
1204                                                                 _DEBUG_VERBOSE("WSP-VERSION : %s", pxLogical->wsp_version);
1205                                                         }
1206                                                 } else if (WBXML_STRCMP("PUSHENABLED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1207                                                         ___set_Param(pCursor, &(pxLogical->push_enabled));
1208                                                         if(pxLogical->push_enabled != NULL) {
1209                                                                 _DEBUG_VERBOSE("PUSHENABLED : %s", pxLogical->push_enabled);
1210                                                         }
1211                                                 } else if (WBXML_STRCMP("PULLENABLED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1212                                                         ___set_Param(pCursor, &(pxLogical->pull_enabled));
1213                                                         if(pxLogical->pull_enabled != NULL) {
1214                                                                 _DEBUG_VERBOSE("PULLENABLED : %s", pxLogical->pull_enabled);
1215                                                         }
1216                                                 }
1217                                                 break;
1218                                         }
1219                                         param_index++;
1220                                 }
1221                         } else if (!strcmp((const char *)tag_name, "characteristic")) {
1222                                 WBXMLList *attrs = pCursor->attrs;
1223                                 WB_ULONG index = 0;
1224                                 WB_ULONG nb_attrs = wbxml_list_len(attrs);
1225
1226                                 while (index < nb_attrs) {
1227                                         WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attrs, index);
1228
1229                                         if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(attr)) == 0) {
1230
1231                                                 if (WBXML_STRCMP("PXAUTHINFO", wbxml_attribute_get_xml_value(attr)) == 0) {
1232                                                         DM_CP_PxLogical_PxAuthInfo *pxAuthInfo = (DM_CP_PxLogical_PxAuthInfo *) calloc(1, sizeof(DM_CP_PxLogical_PxAuthInfo));
1233                                                         if (pxAuthInfo == NULL) {
1234                                                                 _DEBUG_VERBOSE("alloc fail");
1235                                                                 free_cp_pxlogical(pxLogical);
1236                                                                 pxLogical = NULL;
1237                                                                 _INNER_FUNC_EXIT;
1238                                                                 return 0;
1239                                                         }
1240                                                         if (pxLogical->pxAuthInfo == NULL) {
1241                                                                 pxLogical->pxAuthInfo = pxAuthInfo;
1242                                                         } else {
1243                                                                 DM_CP_PxLogical_PxAuthInfo *cursor_ptr = pxLogical->pxAuthInfo;
1244                                                                 while (cursor_ptr != NULL) {
1245                                                                         if (cursor_ptr->next == NULL) {
1246                                                                                 cursor_ptr->next = pxAuthInfo;
1247                                                                                 break;
1248                                                                         }
1249                                                                         cursor_ptr = cursor_ptr->next;
1250                                                                 }
1251                                                         }
1252                                                         WBXMLTreeNode *pCursor_PxAuthInfo = pCursor->children;
1253                                                         while (pCursor_PxAuthInfo != 0) {
1254                                                                 if (pCursor_PxAuthInfo->type == WBXML_TREE_ELEMENT_NODE) {
1255                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_PxAuthInfo->name);
1256                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
1257                                                                                 WBXMLList *param_attrs = pCursor_PxAuthInfo->attrs;
1258                                                                                 WB_ULONG param_index = 0;
1259                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
1260                                                                                 while (param_index < param_nb_attrs) {
1261                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
1262                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
1263                                                                                                 if (WBXML_STRCMP("PXAUTH-TYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1264                                                                                                         ___set_Param(pCursor_PxAuthInfo, &(pxAuthInfo->pxAuth_type));
1265                                                                                                         if(pxAuthInfo->pxAuth_type != NULL) {
1266                                                                                                                 _DEBUG_VERBOSE("PXAUTH-TYPE : %s", pxAuthInfo->pxAuth_type);
1267                                                                                                         }
1268                                                                                                 } else if (WBXML_STRCMP("PXAUTH-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1269                                                                                                         ___set_Param(pCursor_PxAuthInfo, &(pxAuthInfo->pxAuth_id));
1270                                                                                                         if(pxAuthInfo->pxAuth_id != NULL) {
1271                                                                                                                 _DEBUG_VERBOSE("PXAUTH-ID : %s", pxAuthInfo->pxAuth_id);
1272                                                                                                         }
1273                                                                                                 } else if (WBXML_STRCMP("PXAUTH-PW", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1274                                                                                                         ___set_Param(pCursor_PxAuthInfo, &(pxAuthInfo->pxAuth_pw));
1275                                                                                                         if(pxAuthInfo->pxAuth_pw != NULL) {
1276                                                                                                                 _DEBUG_VERBOSE("PXAUTH-PW : %s", pxAuthInfo->pxAuth_pw);
1277                                                                                                         }
1278                                                                                                 }
1279                                                                                                 break;
1280                                                                                         }
1281                                                                                         param_index++;
1282                                                                                 }
1283                                                                         }
1284                                                                 }
1285                                                                 pCursor_PxAuthInfo = pCursor_PxAuthInfo->next;
1286                                                         }
1287                                                 } else if (WBXML_STRCMP("PORT", wbxml_attribute_get_xml_value(attr)) == 0) {
1288                                                         DM_CP_Port *port = (DM_CP_Port *) calloc(1, sizeof(DM_CP_Port));
1289                                                         if (port == NULL) {
1290                                                                 _DEBUG_VERBOSE("alloc fail");
1291                                                                 free_cp_pxlogical(pxLogical);
1292                                                                 pxLogical = NULL;
1293                                                                 _INNER_FUNC_EXIT;
1294                                                                 return 0;
1295                                                         }
1296                                                         if (pxLogical->port == NULL) {
1297                                                                 pxLogical->port = port;
1298                                                         } else {
1299                                                                 DM_CP_Port *cursor_ptr = pxLogical->port;
1300                                                                 while (cursor_ptr != NULL) {
1301                                                                         if (cursor_ptr->next == NULL) {
1302                                                                                 cursor_ptr->next = port;
1303                                                                                 break;
1304                                                                         }
1305                                                                         cursor_ptr = cursor_ptr->next;
1306                                                                 }
1307                                                         }
1308                                                         WBXMLTreeNode *pCursor_Port = pCursor->children;
1309                                                         while (pCursor_Port != 0) {
1310                                                                 if (pCursor_Port->type == WBXML_TREE_ELEMENT_NODE) {
1311                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Port->name);
1312                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
1313                                                                                 WBXMLList *param_attrs = pCursor_Port->attrs;
1314                                                                                 WB_ULONG param_index = 0;
1315                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
1316                                                                                 while (param_index < param_nb_attrs) {
1317                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
1318                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
1319                                                                                                 if (WBXML_STRCMP("PORTNBR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1320                                                                                                         ___set_Param(pCursor_Port, &(port->portnbr));
1321                                                                                                         if(port->portnbr != NULL) {
1322                                                                                                                 _DEBUG_VERBOSE("AAUTHLEVEL : %s", port->portnbr);
1323                                                                                                         }
1324                                                                                                 } else if (WBXML_STRCMP("SERVICE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1325                                                                                                         String_Node *target_ptr = ___get_Last_String_Node(port->service);
1326                                                                                                         ___set_Param(pCursor_Port, &(target_ptr->data));
1327                                                                                                         if(target_ptr->data != NULL) {
1328                                                                                                                 _DEBUG_VERBOSE("SERVICE : %s", target_ptr->data);
1329                                                                                                         }
1330                                                                                                         if (port->service == NULL) {
1331                                                                                                                 port->service = target_ptr;
1332                                                                                                         } else {
1333                                                                                                                 _DEBUG_VERBOSE("free SERVICE ");
1334                                                                                                                 free_string_node(target_ptr);
1335                                                                                                         }
1336                                                                                                 }
1337                                                                                                 break;
1338                                                                                         }
1339                                                                                         param_index++;
1340                                                                                 }
1341                                                                         }
1342                                                                 }
1343                                                                 pCursor_Port = pCursor_Port->next;
1344                                                         }
1345                                                 } else if (WBXML_STRCMP("PXPHYSICAL", wbxml_attribute_get_xml_value(attr)) == 0) {
1346                                                         DM_CP_PxLogical_PxPhysical *pxPhysical = (DM_CP_PxLogical_PxPhysical *) calloc(1, sizeof(DM_CP_PxLogical_PxPhysical));
1347                                                         if (pxPhysical == NULL) {
1348                                                                 _DEBUG_VERBOSE("alloc fail");
1349                                                                 free_cp_pxlogical(pxLogical);
1350                                                                 pxLogical = NULL;
1351                                                                 _INNER_FUNC_EXIT;
1352                                                                 return 0;
1353                                                         }
1354                                                         if (pxLogical->pxPhysical == NULL) {
1355                                                                 pxLogical->pxPhysical = pxPhysical;
1356                                                         } else {
1357                                                                 DM_CP_PxLogical_PxPhysical *cursor_ptr = pxLogical->pxPhysical;
1358                                                                 while (cursor_ptr != NULL) {
1359                                                                         if (cursor_ptr->next == NULL) {
1360                                                                                 cursor_ptr->next = pxPhysical;
1361                                                                                 break;
1362                                                                         }
1363                                                                         cursor_ptr = cursor_ptr->next;
1364                                                                 }
1365                                                         }
1366                                                         WBXMLTreeNode *pCursor_PxPhysical = pCursor->children;
1367                                                         while (pCursor_PxPhysical != 0) {
1368                                                                 if (pCursor_PxPhysical->type == WBXML_TREE_ELEMENT_NODE) {
1369                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_PxPhysical->name);
1370                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
1371                                                                                 WBXMLList *param_attrs = pCursor_PxPhysical->attrs;
1372                                                                                 WB_ULONG param_index = 0;
1373                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
1374                                                                                 while (param_index < param_nb_attrs) {
1375                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
1376                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
1377                                                                                                 if (WBXML_STRCMP("PHYSICAL-PROXY-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1378                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->physical_proxy_id));
1379                                                                                                         if(pxPhysical->physical_proxy_id != NULL) {
1380                                                                                                                 _DEBUG_VERBOSE("PHYSICAL-PROXY-ID : %s", pxPhysical->physical_proxy_id);
1381                                                                                                         }
1382                                                                                                 } else if (WBXML_STRCMP("DOMAIN", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1383                                                                                                         String_Node *target_ptr = ___get_Last_String_Node(pxPhysical->domain);
1384                                                                                                         if(target_ptr == NULL) {
1385                                                                                                                 _DEBUG_VERBOSE("___get_Last_String_Node fail");
1386                                                                                                                 _INNER_FUNC_EXIT;
1387                                                                                                                 return 0;
1388                                                                                                         }
1389                                                                                                         ___set_Param(pCursor_PxPhysical, &(target_ptr->data));
1390                                                                                                         if(target_ptr->data != NULL) {
1391                                                                                                                 _DEBUG_VERBOSE("DOMAIN : %s", target_ptr->data);
1392                                                                                                         }
1393                                                                                                         if (pxPhysical->domain == NULL) {
1394                                                                                                                 pxPhysical->domain = target_ptr;
1395                                                                                                         } else {
1396                                                                                                                 _DEBUG_VERBOSE("free DOMAIN ");
1397                                                                                                                 free_string_node(target_ptr);
1398                                                                                                         }
1399                                                                                                 } else if (WBXML_STRCMP("PXADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1400                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->pxAddr));
1401                                                                                                         if(pxPhysical->pxAddr != NULL) {
1402                                                                                                                 _DEBUG_VERBOSE("PXADDR : %s", pxPhysical->pxAddr);
1403                                                                                                         }
1404                                                                                                 } else if (WBXML_STRCMP("PXADDRTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1405                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->pxAddrType));
1406                                                                                                         if(pxPhysical->pxAddrType != NULL) {
1407                                                                                                                 _DEBUG_VERBOSE("PXADDRTYPE : %s", pxPhysical->pxAddrType);
1408                                                                                                         }
1409                                                                                                 } else if (WBXML_STRCMP("PXADDR-FQDN", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1410                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->pxAddr_FQDN));
1411                                                                                                         if(pxPhysical->pxAddr_FQDN != NULL) {
1412                                                                                                                 _DEBUG_VERBOSE("PXADDR-FQDN : %s", pxPhysical->pxAddr_FQDN);
1413                                                                                                         }
1414                                                                                                 } else if (WBXML_STRCMP("WSP-VERSION", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1415                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->wsp_version));
1416                                                                                                         if(pxPhysical->wsp_version != NULL) {
1417                                                                                                                 _DEBUG_VERBOSE("WSP-VERSION : %s", pxPhysical->wsp_version);
1418                                                                                                         }
1419                                                                                                 } else if (WBXML_STRCMP("PUSHENABLED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1420                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->push_enabled));
1421                                                                                                         if(pxPhysical->push_enabled != NULL) {
1422                                                                                                                 _DEBUG_VERBOSE("PUSHENABLED : %s", pxPhysical->push_enabled);
1423                                                                                                         }
1424                                                                                                 } else if (WBXML_STRCMP("PULLENABLED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1425                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->pull_enabled));
1426                                                                                                         if(pxPhysical->pull_enabled != NULL) {
1427                                                                                                                 _DEBUG_VERBOSE("PULLENABLED : %s", pxPhysical->pull_enabled);
1428                                                                                                         }
1429                                                                                                 } else if (WBXML_STRCMP("TO-NAPID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1430                                                                                                         String_Node *target_ptr = ___get_Last_String_Node(pxPhysical->to_napid);
1431                                                                                                         if(target_ptr == NULL) {
1432                                                                                                                 _DEBUG_VERBOSE("___get_Last_String_Node fail");
1433                                                                                                                 _INNER_FUNC_EXIT;
1434                                                                                                                 return 0;
1435                                                                                                         }
1436                                                                                                         ___set_Param(pCursor_PxPhysical, &(target_ptr->data));
1437                                                                                                         if(target_ptr->data != NULL) {
1438                                                                                                                 _DEBUG_VERBOSE("TO-NAPID : %s", target_ptr->data);
1439                                                                                                         }
1440                                                                                                         if (pxPhysical->to_napid == NULL) {
1441                                                                                                                 pxPhysical->to_napid = target_ptr;
1442                                                                                                         } else {
1443                                                                                                                 _DEBUG_VERBOSE("free TO-NAPID ");
1444                                                                                                                 free_string_node(target_ptr);
1445                                                                                                         }
1446                                                                                                 }
1447                                                                                                 break;
1448                                                                                         }
1449                                                                                         param_index++;
1450                                                                                 }
1451                                                                         } else if (strcmp((const char *)tag_name, "characteristic") == 0) {
1452                                                                                 WBXMLList *addr_attrs = pCursor_PxPhysical->attrs;
1453                                                                                 WB_ULONG addr_index = 0;
1454                                                                                 WB_ULONG addr_nb_attrs = wbxml_list_len(addr_attrs);
1455
1456                                                                                 while (addr_index < addr_nb_attrs) {
1457                                                                                         WBXMLAttribute *addr_attr = (WBXMLAttribute *) wbxml_list_get(addr_attrs, addr_index);
1458                                                                                         if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(addr_attr)) == 0) {
1459                                                                                                 if (WBXML_STRCMP("PORT", wbxml_attribute_get_xml_value(addr_attr)) == 0) {
1460                                                                                                         DM_CP_Port *port = (DM_CP_Port *) calloc(1, sizeof(DM_CP_Port));
1461                                                                                                         if (port == NULL) {
1462                                                                                                                 _DEBUG_VERBOSE("alloc fail");
1463                                                                                                                 free_cp_pxlogical(pxLogical);
1464                                                                                                                 pxLogical = NULL;
1465                                                                                                                 _INNER_FUNC_EXIT;
1466                                                                                                                 return 0;
1467                                                                                                         }
1468                                                                                                         if (pxPhysical->port == NULL) {
1469                                                                                                                 pxPhysical->port = port;
1470                                                                                                         } else {
1471                                                                                                                 DM_CP_Port *cursor_ptr = pxPhysical->port;
1472                                                                                                                 while (cursor_ptr != NULL) {
1473                                                                                                                         if (cursor_ptr->next == NULL) {
1474                                                                                                                                 cursor_ptr->next = port;
1475                                                                                                                                 break;
1476                                                                                                                         }
1477                                                                                                                         cursor_ptr = cursor_ptr->next;
1478                                                                                                                 }
1479                                                                                                         }
1480                                                                                                         WBXMLTreeNode *pCursor_Port = pCursor_PxPhysical->children;
1481                                                                                                         while (pCursor_Port != 0) {
1482                                                                                                                 if (pCursor_Port->type == WBXML_TREE_ELEMENT_NODE) {
1483                                                                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Port->name);
1484                                                                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
1485                                                                                                                                 WBXMLList *_param_attrs = pCursor_Port->attrs;
1486                                                                                                                                 WB_ULONG _param_index = 0;
1487                                                                                                                                 WB_ULONG _param_nb_attrs = wbxml_list_len(_param_attrs);
1488                                                                                                                                 while (_param_index < _param_nb_attrs) {
1489                                                                                                                                         WBXMLAttribute *_param_attr = (WBXMLAttribute *) wbxml_list_get(_param_attrs, _param_index);
1490                                                                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(_param_attr)) == 0) {
1491                                                                                                                                                 if (WBXML_STRCMP("PORTNBR", wbxml_attribute_get_xml_value(_param_attr)) == 0) {
1492                                                                                                                                                         ___set_Param(pCursor_Port, &(port->portnbr));
1493                                                                                                                                                         if(port->portnbr != NULL) {
1494                                                                                                                                                                 _DEBUG_VERBOSE("[%d] PORTNBR : %s", _param_index, port->portnbr);
1495                                                                                                                                                         }
1496                                                                                                                                                 } else if (WBXML_STRCMP("SERVICE", wbxml_attribute_get_xml_value(_param_attr)) == 0) {
1497                                                                                                                                                         String_Node *target_ptr = ___get_Last_String_Node(port->service);
1498                                                                                                                                                         if(target_ptr==NULL) {
1499                                                                                                                                                                 _DEBUG_VERBOSE("___get_Last_String_Node fail");
1500                                                                                                                                                                 _INNER_FUNC_EXIT;
1501                                                                                                                                                                 return 0;
1502                                                                                                                                                         }
1503                                                                                                                                                         ___set_Param(pCursor_Port, &(target_ptr->data));
1504                                                                                                                                                         if(target_ptr->data != NULL) {
1505                                                                                                                                                                 _DEBUG_VERBOSE("SERVICE : %s", target_ptr->data);
1506                                                                                                                                                         }
1507                                                                                                                                                         if (port->service == NULL) {
1508                                                                                                                                                                 port->service = target_ptr;
1509                                                                                                                                                         } else {
1510                                                                                                                                                                 _DEBUG_VERBOSE("free port service");
1511                                                                                                                                                                 free_string_node(target_ptr);
1512                                                                                                                                                         }
1513                                                                                                                                                 }
1514                                                                                                                                                 break;
1515                                                                                                                                         }
1516                                                                                                                                         _param_index++;
1517                                                                                                                                         _DEBUG_VERBOSE("param_index : %d", _param_index);
1518                                                                                                                                 }
1519                                                                                                                         }
1520                                                                                                                 }
1521                                                                                                                 pCursor_Port = pCursor_Port->next;
1522                                                                                                         }
1523                                                                                                 }
1524                                                                                         }
1525                                                                                         addr_index++;
1526                                                                                 }
1527                                                                         }
1528                                                                 }
1529                                                                 pCursor_PxPhysical = pCursor_PxPhysical->next;
1530                                                         }
1531                                                 }
1532                                         }
1533                                         index++;
1534                                 }
1535                         }
1536                 }
1537
1538                 pCursor = pCursor->next;
1539         }
1540
1541         _INNER_FUNC_EXIT;
1542
1543         return pxLogical;
1544 }
1545
1546 static void ___set_Param(WBXMLTreeNode * wbxml_dom_node, char **set_value)
1547 {
1548         _INNER_FUNC_ENTER;
1549
1550         retm_if((wbxml_dom_node) == NULL, "wbxml_dom_node is NULL!!");
1551
1552         WBXMLList *attr_list = wbxml_dom_node->attrs;
1553         WB_ULONG index = 0;
1554         WB_ULONG nb_attrs = wbxml_list_len(attr_list);
1555
1556         while (index < nb_attrs) {
1557                 WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attr_list, index);
1558                 if (WBXML_STRCMP("value", wbxml_attribute_get_xml_name(attr)) == 0) {
1559                         const char *value_str = 0;
1560                         value_str = (const char *)wbxml_attribute_get_xml_value(attr);
1561                         int value_len = 0;
1562                         if (value_str != NULL) {
1563                                 value_len = strlen(value_str);
1564                         }
1565                         int str_len = 0;
1566                         *set_value = (char *)calloc(value_len + 1, sizeof(char));
1567                         if (*set_value == NULL) {
1568                                 break;
1569                         }
1570
1571                         str_len = g_strlcpy(*set_value, value_str, value_len + 1);
1572                         if (str_len >= sizeof(*set_value)) {
1573                                 _DEBUG_VERBOSE("buffer overflow");
1574                                 break;
1575                         }
1576                         break;
1577                 }
1578                 index++;
1579         }
1580         _INNER_FUNC_EXIT;
1581 }