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                                                                 free_cp_napdef(napdef);
369                                                                 napdef = NULL;
370                                                                 _INNER_FUNC_EXIT;
371                                                                 return 0;
372                                                         }
373                                                         ___set_Param(pCursor, &(target_ptr->data));
374                                                         if(target_ptr->data != NULL) {
375                                                                 _DEBUG_VERBOSE("BEARER : %s", target_ptr->data);
376                                                         }
377                                                         if (napdef->bearer == NULL) {
378                                                                 napdef->bearer = target_ptr;
379                                                         } else {
380                                                                 _DEBUG_VERBOSE("free BEARER ");
381                                                                 free_string_node(target_ptr);
382                                                         }
383                                                 } else if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
384                                                         ___set_Param(pCursor, &(napdef->name));
385                                                         if(napdef->name != NULL) {
386                                                                 _DEBUG_VERBOSE("NAME : %s", napdef->name);
387                                                         }
388                                                 } else if (WBXML_STRCMP("INTERNET", wbxml_attribute_get_xml_value(param_attr)) == 0) {
389                                                         ___set_Param(pCursor, &(napdef->internet));
390                                                         if(napdef->internet != NULL) {
391                                                                 _DEBUG_VERBOSE("INTERNET : %s", napdef->internet);
392                                                         }
393                                                 } else if (WBXML_STRCMP("NAP-ADDRESS", wbxml_attribute_get_xml_value(param_attr)) == 0) {
394                                                         ___set_Param(pCursor, &(napdef->nap_address));
395                                                         if(napdef->nap_address != NULL) {
396                                                                 _DEBUG_VERBOSE("NAP-ADDRESS : %s", napdef->nap_address);
397                                                         }
398                                                 } else if (WBXML_STRCMP("NAP-ADDRTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
399                                                         ___set_Param(pCursor, &(napdef->nap_addr_type));
400                                                         if(napdef->nap_addr_type != NULL) {
401                                                                 _DEBUG_VERBOSE("NAP-ADDRTYPE : %s", napdef->nap_addr_type);
402                                                         }
403                                                 } else if (WBXML_STRCMP("DNS-ADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
404                                                         String_Node *target_ptr = ___get_Last_String_Node(napdef->dns_addr);
405                                                         if (target_ptr == NULL) {
406                                                                 _DEBUG_VERBOSE("DNS-ADDR is NULL");
407                                                                 param_index++;
408                                                                 continue;
409                                                         }
410
411                                                         ___set_Param(pCursor, &(target_ptr->data));
412                                                         if(target_ptr->data != NULL) {
413                                                                 _DEBUG_VERBOSE("DNS-ADDR : %s", target_ptr->data);
414                                                         }
415                                                         if (napdef->dns_addr == NULL) {
416                                                                 napdef->dns_addr = target_ptr;
417                                                         } else {
418                                                                 _DEBUG_VERBOSE("free DNS-ADDR ");
419                                                                 free_string_node(target_ptr);
420                                                         }
421                                                 } else if (WBXML_STRCMP("CALLTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
422                                                         ___set_Param(pCursor, &(napdef->call_type));
423                                                         if(napdef->call_type != NULL) {
424                                                                 _DEBUG_VERBOSE("CALLTYPE : %s", napdef->call_type);
425                                                         }
426                                                 } else if (WBXML_STRCMP("LOCAL-ADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
427                                                         ___set_Param(pCursor, &(napdef->local_addr));
428                                                         if(napdef->local_addr != NULL) {
429                                                                 _DEBUG_VERBOSE("LOCAL-ADDR : %s", napdef->local_addr);
430                                                         }
431                                                 } else if (WBXML_STRCMP("LOCAL-ADDRTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
432                                                         ___set_Param(pCursor, &(napdef->local_addr_type));
433                                                         if(napdef->local_addr_type != NULL) {
434                                                                 _DEBUG_VERBOSE("LOCAL-ADDRTYPE : %s", napdef->local_addr_type);
435                                                         }
436                                                 } else if (WBXML_STRCMP("LINKSPEED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
437                                                         ___set_Param(pCursor, &(napdef->link_speed));
438                                                         if(napdef->link_speed != NULL) {
439                                                                 _DEBUG_VERBOSE("LINKSPEED : %s", napdef->link_speed);
440                                                         }
441                                                 } else if (WBXML_STRCMP("DNLINKSPEED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
442                                                         ___set_Param(pCursor, &(napdef->dn_link_speed));
443                                                         if(napdef->dn_link_speed != NULL) {
444                                                                 _DEBUG_VERBOSE("DNLINKSPEED : %s", napdef->dn_link_speed);
445                                                         }
446                                                 } else if (WBXML_STRCMP("LINGER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
447                                                         ___set_Param(pCursor, &(napdef->linger));
448                                                         if(napdef->linger != NULL) {
449                                                                 _DEBUG_VERBOSE("LINGER : %s", napdef->linger);
450                                                         }
451                                                 } else if (WBXML_STRCMP("DELIVERY-ERR-SDU", wbxml_attribute_get_xml_value(param_attr)) == 0) {
452                                                         ___set_Param(pCursor, &(napdef->delivery_err_sdu));
453                                                         if(napdef->delivery_err_sdu != NULL) {
454                                                                 _DEBUG_VERBOSE("DELIVERY-ERR-SDU : %s", napdef->delivery_err_sdu);
455                                                         }
456                                                 } else if (WBXML_STRCMP("DELIVERY-ORDER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
457                                                         ___set_Param(pCursor, &(napdef->delivery_order));
458                                                         if(napdef->delivery_order != NULL) {
459                                                                 _DEBUG_VERBOSE("DELIVERY-ORDER : %s", napdef->delivery_order);
460                                                         }
461                                                 } else if (WBXML_STRCMP("TRAFFIC-CLASS", wbxml_attribute_get_xml_value(param_attr)) == 0) {
462                                                         ___set_Param(pCursor, &(napdef->traffic_class));
463                                                         if(napdef->traffic_class != NULL) {
464                                                                 _DEBUG_VERBOSE("TRAFFIC-CLASS : %s", napdef->traffic_class);
465                                                         }
466                                                 } else if (WBXML_STRCMP("MAX-SDU-SIZE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
467                                                         ___set_Param(pCursor, &(napdef->max_sdu_size));
468                                                         if(napdef->max_sdu_size != NULL) {
469                                                                 _DEBUG_VERBOSE("MAX-SDU-SIZE : %s", napdef->max_sdu_size);
470                                                         }
471                                                 } else if (WBXML_STRCMP("MAX-BITRATE-UPLINK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
472                                                         ___set_Param(pCursor, &(napdef->max_bitrate_uplink));
473                                                         if(napdef->max_bitrate_uplink != NULL) {
474                                                                 _DEBUG_VERBOSE("MAX-BITRATE-UPLINK : %s", napdef->max_bitrate_uplink);
475                                                         }
476                                                 } else if (WBXML_STRCMP("MAX-BITRATE-DNLINK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
477                                                         ___set_Param(pCursor, &(napdef->max_bitrate_dnlink));
478                                                         if(napdef->max_bitrate_dnlink != NULL) {
479                                                                 _DEBUG_VERBOSE("MAX-BITRATE-DNLINK : %s", napdef->max_bitrate_dnlink);
480                                                         }
481                                                 } else if (WBXML_STRCMP("RESIDUAL-BER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
482                                                         ___set_Param(pCursor, &(napdef->residual_ber));
483                                                         if(napdef->residual_ber != NULL) {
484                                                                 _DEBUG_VERBOSE("RESIDUAL-BER : %s", napdef->residual_ber);
485                                                         }
486                                                 } else if (WBXML_STRCMP("SDU-ERROR-RATIO", wbxml_attribute_get_xml_value(param_attr)) == 0) {
487                                                         ___set_Param(pCursor, &(napdef->sdu_error_ratio));
488                                                         if(napdef->sdu_error_ratio != NULL) {
489                                                                 _DEBUG_VERBOSE("SDU-ERROR-RATIO : %s", napdef->sdu_error_ratio);
490                                                         }
491                                                 } else if (WBXML_STRCMP("TRAFFIC-HANDL-PRIO", wbxml_attribute_get_xml_value(param_attr)) == 0) {
492                                                         ___set_Param(pCursor, &(napdef->traffic_handl_prio));
493                                                         if(napdef->traffic_handl_prio != NULL) {
494                                                                 _DEBUG_VERBOSE("TRAFFIC-HANDL-PRIO : %s", napdef->traffic_handl_prio);
495                                                         }
496                                                 } else if (WBXML_STRCMP("TRANSFER-DELAY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
497                                                         ___set_Param(pCursor, &(napdef->transfer_delay));
498                                                         if(napdef->transfer_delay != NULL) {
499                                                                 _DEBUG_VERBOSE("TRANSFER-DELAY : %s", napdef->transfer_delay);
500                                                         }
501                                                 } else if (WBXML_STRCMP("GUARANTEED-BITRATE-UPLINK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
502                                                         ___set_Param(pCursor, &(napdef->guaranteed_bitrate_uplink));
503                                                         if(napdef->guaranteed_bitrate_uplink != NULL) {
504                                                                 _DEBUG_VERBOSE("GUARANTEED-BITRATE-UPLINK : %s", napdef->guaranteed_bitrate_uplink);
505                                                         }
506                                                 } else if (WBXML_STRCMP("GUARANTEED-BITRATE-DNLINK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
507                                                         ___set_Param(pCursor, &(napdef->guaranteed_bitrate_dnlink));
508                                                         if(napdef->guaranteed_bitrate_dnlink != NULL) {
509                                                                 _DEBUG_VERBOSE("GUARANTEED-BITRATE-DNLINK : %s", napdef->guaranteed_bitrate_dnlink);
510                                                         }
511                                                 } else if (WBXML_STRCMP("MAX-NUM-RETRY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
512                                                         ___set_Param(pCursor, &(napdef->max_num_retry));
513                                                         if(napdef->max_num_retry != NULL) {
514                                                                 _DEBUG_VERBOSE("MAX-NUM-RETRY : %s", napdef->max_num_retry);
515                                                         }
516                                                 } else if (WBXML_STRCMP("FIRST-RETRY-TIMEOUT", wbxml_attribute_get_xml_value(param_attr)) == 0) {
517                                                         ___set_Param(pCursor, &(napdef->first_retry_timeout));
518                                                         if(napdef->first_retry_timeout != NULL) {
519                                                                 _DEBUG_VERBOSE("FIRST-RETRY-TIMEOUT : %s", napdef->first_retry_timeout);
520                                                         }
521                                                 } else if (WBXML_STRCMP("REREG-THRESHOLD", wbxml_attribute_get_xml_value(param_attr)) == 0) {
522                                                         ___set_Param(pCursor, &(napdef->rereg_threshold));
523                                                         if(napdef->rereg_threshold != NULL) {
524                                                                 _DEBUG_VERBOSE("REREG-THRESHOLD : %s", napdef->rereg_threshold);
525                                                         }
526                                                 } else if (WBXML_STRCMP("T-BIT", wbxml_attribute_get_xml_value(param_attr)) == 0) {
527                                                         ___set_Param(pCursor, &(napdef->t_bit));
528                                                         if(napdef->t_bit != NULL) {
529                                                                 _DEBUG_VERBOSE("T-BIT : %s", napdef->t_bit);
530                                                         }
531                                                 }
532                                         }
533                                         param_index++;
534                                 }
535                         } else if (!strcmp((const char *)tag_name, "characteristic")) {
536                                 WBXMLList *attrs = pCursor->attrs;
537                                 WB_ULONG index = 0;
538                                 WB_ULONG nb_attrs = wbxml_list_len(attrs);
539
540                                 while (index < nb_attrs) {
541                                         WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attrs, index);
542                                         if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(attr)) == 0) {
543                                                 if (WBXML_STRCMP("NAPAUTHINFO", wbxml_attribute_get_xml_value(attr)) == 0) {
544                                                         DM_CP_Napdef_AuthInfo *auth_info = (DM_CP_Napdef_AuthInfo *) calloc(1, sizeof(DM_CP_Napdef_AuthInfo));
545                                                         if (auth_info == NULL) {
546                                                                 _DEBUG_VERBOSE("alloc fail");
547                                                                 free_cp_napdef(napdef);
548                                                                 napdef = NULL;
549                                                                 _INNER_FUNC_EXIT;
550                                                                 return 0;
551                                                         }
552                                                         if (napdef->auth_info == NULL) {
553                                                                 napdef->auth_info = auth_info;
554                                                         } else {
555                                                                 DM_CP_Napdef_AuthInfo *cursor_ptr = napdef->auth_info;
556                                                                 while (cursor_ptr != NULL) {
557                                                                         if (cursor_ptr->next == NULL) {
558                                                                                 cursor_ptr->next = auth_info;
559                                                                                 break;
560                                                                         }
561                                                                         cursor_ptr = cursor_ptr->next;
562                                                                 }
563                                                         }
564                                                         WBXMLTreeNode *pCursor_AuthInfo = pCursor->children;
565                                                         while (pCursor_AuthInfo != 0) {
566                                                                 if (pCursor_AuthInfo->type == WBXML_TREE_ELEMENT_NODE) {
567                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_AuthInfo->name);
568                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
569                                                                                 WBXMLList *param_attrs = pCursor_AuthInfo->attrs;
570                                                                                 WB_ULONG param_index = 0;
571                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
572                                                                                 while (param_index < param_nb_attrs) {
573                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
574                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
575                                                                                                 if (WBXML_STRCMP("AUTHTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
576                                                                                                         ___set_Param(pCursor_AuthInfo, &(auth_info->auth_type));
577                                                                                                         if(auth_info->auth_type != NULL) {
578                                                                                                                 _DEBUG_VERBOSE("AUTHTYPE : %s", auth_info->auth_type);
579                                                                                                         }
580                                                                                                 } else if (WBXML_STRCMP("AUTHNAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
581                                                                                                         ___set_Param(pCursor_AuthInfo, &(auth_info->auth_name));
582                                                                                                         if(auth_info->auth_name != NULL) {
583                                                                                                                 _DEBUG_VERBOSE("AUTHNAME : %s", auth_info->auth_name);
584                                                                                                         }
585                                                                                                 } else if (WBXML_STRCMP("AUTHSECRET", wbxml_attribute_get_xml_value(param_attr)) == 0) {
586                                                                                                         ___set_Param(pCursor_AuthInfo, &(auth_info->auth_secret));
587                                                                                                         if(auth_info->auth_secret != NULL) {
588                                                                                                                 _DEBUG_VERBOSE("AUTHSECRET : %s", auth_info->auth_secret);
589                                                                                                         }
590                                                                                                 } else if (WBXML_STRCMP("AUTH-ENTITY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
591                                                                                                         String_Node *target_ptr = ___get_Last_String_Node(auth_info->auth_entity);
592                                                                                                         if (target_ptr == NULL) {
593                                                                                                                 _DEBUG_VERBOSE("auth entity is NULL");
594                                                                                                                 param_index++;
595                                                                                                                 continue;
596                                                                                                         }
597                                                                                                         ___set_Param(pCursor_AuthInfo, &(target_ptr->data));
598                                                                                                         if(target_ptr->data != NULL) {
599                                                                                                                 _DEBUG_VERBOSE("AUTH-ENTITY : %s", target_ptr->data);
600                                                                                                         }
601                                                                                                         if (auth_info->auth_entity == NULL) {
602                                                                                                                 auth_info->auth_entity = target_ptr;
603                                                                                                         } else {
604                                                                                                                 _DEBUG_VERBOSE("free auth entity");
605                                                                                                                 free_string_node(target_ptr);
606                                                                                                         }
607                                                                                                 } else if (WBXML_STRCMP("SPI", wbxml_attribute_get_xml_value(param_attr)) == 0) {
608                                                                                                         ___set_Param(pCursor_AuthInfo, &(auth_info->spi));
609                                                                                                         if(auth_info->spi != NULL ) {
610                                                                                                                 _DEBUG_VERBOSE("SPI : %s", auth_info->spi);
611                                                                                                         }
612                                                                                                 }
613                                                                                                 break;
614                                                                                         }
615                                                                                         param_index++;
616                                                                                 }
617                                                                         }
618                                                                 }
619                                                                 pCursor_AuthInfo = pCursor_AuthInfo->next;
620                                                         }
621                                                 } else if (WBXML_STRCMP("VALIDITY", wbxml_attribute_get_xml_value(attr)) == 0) {
622                                                         DM_CP_Napdef_validity *validity = (DM_CP_Napdef_validity *) calloc(1, sizeof(DM_CP_Napdef_validity));
623                                                         if (validity == NULL) {
624                                                                 _DEBUG_VERBOSE("alloc fail");
625                                                                 free_cp_napdef(napdef);
626                                                                 napdef = NULL;
627                                                                 _INNER_FUNC_EXIT;
628                                                                 return 0;
629                                                         }
630                                                         if (napdef->validity == NULL) {
631                                                                 napdef->validity = validity;
632                                                         } else {
633                                                                 DM_CP_Napdef_validity *cursor_ptr = napdef->validity;
634                                                                 while (cursor_ptr != NULL) {
635                                                                         if (cursor_ptr->next == NULL) {
636                                                                                 cursor_ptr->next = validity;
637                                                                                 break;
638                                                                         }
639                                                                         cursor_ptr = cursor_ptr->next;
640                                                                 }
641                                                         }
642                                                         WBXMLTreeNode *pCursor_Validity = pCursor->children;
643                                                         while (pCursor_Validity != 0) {
644                                                                 if (pCursor_Validity->type == WBXML_TREE_ELEMENT_NODE) {
645                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Validity->name);
646                                                                         if (!strcmp((const char *)tag_name, "parm")) {
647                                                                                 WBXMLList *param_attrs = pCursor_Validity->attrs;
648                                                                                 WB_ULONG param_index = 0;
649                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
650                                                                                 while (param_index < param_nb_attrs) {
651                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
652                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
653                                                                                                 if (WBXML_STRCMP("COUNTRY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
654                                                                                                         ___set_Param(pCursor_Validity, &(validity->country));
655                                                                                                         if(validity->country != NULL) {
656                                                                                                                 _DEBUG_VERBOSE("COUNTRY : %s", validity->country);
657                                                                                                         }
658                                                                                                 } else if (WBXML_STRCMP("NETWORK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
659                                                                                                         ___set_Param(pCursor_Validity, &(validity->network));
660                                                                                                         if(validity->network != NULL) {
661                                                                                                                 _DEBUG_VERBOSE("NETWORK : %s", validity->network);
662                                                                                                         }
663                                                                                                 } else if (WBXML_STRCMP("SID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
664                                                                                                         ___set_Param(pCursor_Validity, &(validity->sid));
665                                                                                                         if(validity->sid != NULL) {
666                                                                                                                 _DEBUG_VERBOSE("SID : %s", validity->sid);
667                                                                                                         }
668                                                                                                 } else if (WBXML_STRCMP("SOC", wbxml_attribute_get_xml_value(param_attr)) == 0) {
669                                                                                                         ___set_Param(pCursor_Validity, &(validity->soc));
670                                                                                                         if(validity->soc != NULL) {
671                                                                                                                 _DEBUG_VERBOSE("SOC : %s", validity->soc);
672                                                                                                         }
673                                                                                                 } else if (WBXML_STRCMP("VALIDUNTIL", wbxml_attribute_get_xml_value(param_attr)) == 0) {
674                                                                                                         ___set_Param(pCursor_Validity, &(validity->validuntil));
675                                                                                                         if(validity->validuntil != NULL) {
676                                                                                                                 _DEBUG_VERBOSE("VALIDUNTIL : %s", validity->validuntil);
677                                                                                                         }
678                                                                                                 }
679                                                                                                 break;
680                                                                                         }
681                                                                                         param_index++;
682                                                                                 }
683                                                                         }
684                                                                 }
685                                                                 pCursor_Validity = pCursor_Validity->next;
686                                                         }
687                                                 }
688                                         }
689                                         index++;
690                                 }
691                         }
692                 }
693                 pCursor = pCursor->next;
694         }
695
696         _INNER_FUNC_EXIT;
697
698         return napdef;
699 }
700
701 static DM_CP_Application *__parse_Application(WBXMLTreeNode * wbxml_dom_node)
702 {
703         _INNER_FUNC_ENTER;
704
705         retvm_if((wbxml_dom_node) == NULL, NULL, "wbxml_dom_node is NULL!!");
706
707         DM_CP_Application *application = (DM_CP_Application *) calloc(1, sizeof(DM_CP_Application));
708         if (application == NULL) {
709                 _DEBUG_VERBOSE("alloc fail");
710                 _INNER_FUNC_EXIT;
711                 return 0;
712         }
713         WBXMLTreeNode *pCursor = wbxml_dom_node->children;
714
715         while (pCursor != 0) {
716                 if (pCursor->type == WBXML_TREE_ELEMENT_NODE) {
717                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor->name);
718                         if (strcmp((const char *)tag_name, "parm") == 0) {
719                                 WBXMLList *param_attrs = pCursor->attrs;
720                                 WB_ULONG param_index = 0;
721                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
722                                 while (param_index < param_nb_attrs) {
723                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
724                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
725                                                 if (WBXML_STRCMP("APPID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
726                                                         ___set_Param(pCursor, &(application->app_ID));
727                                                         if(application->app_ID != NULL) {
728                                                                 _DEBUG_VERBOSE("APPID : %s", application->app_ID);
729                                                         }
730                                                 } else if (WBXML_STRCMP("PROVIDER-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
731                                                         ___set_Param(pCursor, &(application->provider_ID));
732                                                         if(application->provider_ID != NULL) {
733                                                                 _DEBUG_VERBOSE("PROVIDER-ID : %s", application->provider_ID);
734                                                         }
735                                                 } else if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
736                                                         ___set_Param(pCursor, &(application->name));
737                                                         if(application->name != NULL) {
738                                                                 _DEBUG_VERBOSE("NAME : %s", application->name);
739                                                         }
740                                                 } else if (WBXML_STRCMP("AACCEPT", wbxml_attribute_get_xml_value(param_attr)) == 0) {
741                                                         ___set_Param(pCursor, &(application->accept));
742                                                         if(application->accept != NULL) {
743                                                                 _DEBUG_VERBOSE("AACCEPT : %s", application->accept);
744                                                         }
745                                                 } else if (WBXML_STRCMP("APROTOCOL", wbxml_attribute_get_xml_value(param_attr)) == 0) {
746                                                         ___set_Param(pCursor, &(application->protocol));
747                                                         if(application->protocol != NULL) {
748                                                                 _DEBUG_VERBOSE("APROTOCOL : %s", application->protocol);
749                                                         }
750                                                 } else if (WBXML_STRCMP("TO-PROXY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
751                                                         String_Node *target_ptr = ___get_Last_String_Node(application->to_proxy);
752                                                         if (target_ptr == NULL) {
753                                                                 _DEBUG_VERBOSE("TO-PROXY is NULL");
754                                                                 param_index++;
755                                                                 continue;
756                                                         }
757
758                                                         ___set_Param(pCursor, &(target_ptr->data));
759                                                         if(target_ptr->data != NULL) {
760                                                                 _DEBUG_VERBOSE("PROXY : %s", target_ptr->data);
761                                                         }
762
763                                                         if (application->to_proxy == NULL) {
764                                                                 application->to_proxy = target_ptr;
765                                                         } else {
766                                                                 _DEBUG_VERBOSE("free PROXY ");
767                                                                 free_string_node(target_ptr);
768                                                         }
769                                                 } else if (WBXML_STRCMP("TO-NAPID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
770                                                         String_Node *target_ptr = ___get_Last_String_Node(application->to_napid);
771                                                         if (target_ptr == NULL) {
772                                                                 _DEBUG_VERBOSE("TO-NAPID is NULL");
773                                                                 param_index++;
774                                                                 continue;
775                                                         }
776
777                                                         ___set_Param(pCursor, &(target_ptr->data));
778                                                         if(target_ptr->data != NULL) {
779                                                                 _DEBUG_VERBOSE("NAPID : %s", target_ptr->data);
780                                                         }
781                                                         if (application->to_napid == NULL) {
782                                                                 application->to_napid = target_ptr;
783                                                         } else {
784                                                                 _DEBUG_VERBOSE("free NAPID ");
785                                                                 free_string_node(target_ptr);
786                                                         }
787                                                 } else if (WBXML_STRCMP("ADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
788                                                         String_Node *target_ptr = ___get_Last_String_Node(application->addr);
789                                                         if (target_ptr == NULL) {
790                                                                 _DEBUG_VERBOSE("ADDR is NULL");
791                                                                 param_index++;
792                                                                 continue;
793                                                         }
794
795                                                         ___set_Param(pCursor, &(target_ptr->data));
796                                                         if(target_ptr->data != NULL) {
797                                                                 _DEBUG_VERBOSE("ADDR : %s", target_ptr->data);
798                                                         }
799                                                         if (application->addr == NULL) {
800                                                                 application->addr = target_ptr;
801                                                         } else {
802                                                                 _DEBUG_VERBOSE("free ADDR ");
803                                                                 free_string_node(target_ptr);
804                                                         }
805                                                 }
806                                                 break;
807                                         }
808                                         param_index++;
809                                 }
810                         } else if (!strcmp((const char *)tag_name, "characteristic")) {
811                                 WBXMLList *attrs = pCursor->attrs;
812                                 WB_ULONG index = 0;
813                                 WB_ULONG nb_attrs = wbxml_list_len(attrs);
814
815                                 while (index < nb_attrs) {
816                                         WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attrs, index);
817
818                                         if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(attr)) == 0) {
819
820                                                 if (WBXML_STRCMP("APPADDR", wbxml_attribute_get_xml_value(attr)) == 0) {
821                                                         DM_CP_Application_AppAddr *app_addr = (DM_CP_Application_AppAddr *) calloc(1, sizeof(DM_CP_Application_AppAddr));
822                                                         if (app_addr == NULL) {
823                                                                 _DEBUG_VERBOSE("alloc fail");
824                                                                 free_cp_application(application);
825                                                                 application = NULL;
826                                                                 _INNER_FUNC_EXIT;
827                                                                 return 0;
828                                                         }
829                                                         if (application->appAddr == NULL) {
830                                                                 application->appAddr = app_addr;
831                                                         } else {
832                                                                 DM_CP_Application_AppAddr *cursor_ptr = application->appAddr;
833                                                                 while (cursor_ptr != NULL) {
834                                                                         if (cursor_ptr->next == NULL) {
835                                                                                 cursor_ptr->next = app_addr;
836                                                                                 break;
837                                                                         }
838                                                                         cursor_ptr = cursor_ptr->next;
839                                                                 }
840                                                         }
841                                                         WBXMLTreeNode *pCursor_AppAddr = pCursor->children;
842                                                         while (pCursor_AppAddr != 0) {
843                                                                 if (pCursor_AppAddr->type == WBXML_TREE_ELEMENT_NODE) {
844                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_AppAddr->name);
845                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
846                                                                                 WBXMLList *param_attrs = pCursor_AppAddr->attrs;
847                                                                                 WB_ULONG param_index = 0;
848                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
849                                                                                 while (param_index < param_nb_attrs) {
850                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
851                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
852                                                                                                 if (WBXML_STRCMP("ADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
853                                                                                                         ___set_Param(pCursor_AppAddr, &(app_addr->addr));
854                                                                                                         if(app_addr->addr != NULL) {
855                                                                                                                 _DEBUG_VERBOSE("ADDR : %s", app_addr->addr);
856                                                                                                         }
857                                                                                                 } else if (WBXML_STRCMP("ADDRTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
858                                                                                                         ___set_Param(pCursor_AppAddr, &(app_addr->addr_type));
859                                                                                                         if(app_addr->addr_type != NULL) {
860                                                                                                                 _DEBUG_VERBOSE("ADDRTYPE : %s", app_addr->addr_type);
861                                                                                                         }
862                                                                                                 }
863                                                                                                 break;
864                                                                                         }
865                                                                                         param_index++;
866                                                                                 }
867                                                                         } else if (strcmp((const char *)tag_name, "characteristic") == 0) {
868                                                                                 WBXMLList *addr_attrs = pCursor_AppAddr->attrs;
869                                                                                 WB_ULONG addr_index = 0;
870                                                                                 WB_ULONG addr_nb_attrs = wbxml_list_len(addr_attrs);
871
872                                                                                 while (addr_index < addr_nb_attrs) {
873                                                                                         WBXMLAttribute *addr_attr = (WBXMLAttribute *) wbxml_list_get(addr_attrs, addr_index);
874                                                                                         if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(addr_attr)) == 0) {
875                                                                                                 if (WBXML_STRCMP("PORT", wbxml_attribute_get_xml_value(addr_attr)) == 0) {
876                                                                                                         DM_CP_Port *port = (DM_CP_Port *) calloc(1, sizeof(DM_CP_Port));
877                                                                                                         if (port == NULL) {
878                                                                                                                 _DEBUG_VERBOSE("alloc fail");
879                                                                                                                 free_cp_application(application);
880                                                                                                                 application = NULL;
881                                                                                                                 _INNER_FUNC_EXIT;
882                                                                                                                 return 0;
883                                                                                                         }
884                                                                                                         if (app_addr->port == NULL) {
885                                                                                                                 app_addr->port = port;
886                                                                                                         } else {
887                                                                                                                 DM_CP_Port *cursor_ptr = app_addr->port;
888                                                                                                                 while (cursor_ptr != NULL) {
889                                                                                                                         if (cursor_ptr->next == NULL) {
890                                                                                                                                 cursor_ptr->next = port;
891                                                                                                                                 break;
892                                                                                                                         }
893                                                                                                                         cursor_ptr = cursor_ptr->next;
894                                                                                                                 }
895                                                                                                         }
896                                                                                                         WBXMLTreeNode *pCursor_Port = pCursor_AppAddr->children;
897                                                                                                         while (pCursor_Port != 0) {
898                                                                                                                 if (pCursor_Port->type == WBXML_TREE_ELEMENT_NODE) {
899                                                                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Port->name);
900                                                                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
901                                                                                                                                 WBXMLList *_param_attrs = pCursor_Port->attrs;
902                                                                                                                                 WB_ULONG _param_index = 0;
903                                                                                                                                 WB_ULONG _param_nb_attrs = wbxml_list_len(_param_attrs);
904                                                                                                                                 while (_param_index < _param_nb_attrs) {
905                                                                                                                                         WBXMLAttribute *_param_attr = (WBXMLAttribute *) wbxml_list_get(_param_attrs, _param_index);
906                                                                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(_param_attr)) == 0) {
907                                                                                                                                                 if (WBXML_STRCMP("PORTNBR", wbxml_attribute_get_xml_value(_param_attr)) == 0) {
908                                                                                                                                                         ___set_Param(pCursor_Port, &(port->portnbr));
909                                                                                                                                                         if(port->portnbr != NULL) {
910                                                                                                                                                                 _DEBUG_VERBOSE("[%d] PORTNBR : %s", _param_index, port->portnbr);
911                                                                                                                                                         }
912                                                                                                                                                 } else if (WBXML_STRCMP("SERVICE", wbxml_attribute_get_xml_value(_param_attr)) == 0) {
913                                                                                                                                                         String_Node *target_ptr = ___get_Last_String_Node(port->service);
914                                                                                                                                                         if (target_ptr == NULL) {
915                                                                                                                                                                 _DEBUG_VERBOSE("SERVICE is NULL");
916                                                                                                                                                                 _param_index++;
917                                                                                                                                                                 continue;
918                                                                                                                                                         }
919
920                                                                                                                                                         ___set_Param(pCursor_Port, &(target_ptr->data));
921                                                                                                                                                         if(target_ptr->data != NULL) {
922                                                                                                                                                                 _DEBUG_VERBOSE("SERVICE : %s", target_ptr->data);
923                                                                                                                                                         }
924                                                                                                                                                         if (port->service == NULL) {
925                                                                                                                                                                 port->service = target_ptr;
926                                                                                                                                                         } else {
927                                                                                                                                                                 _DEBUG_VERBOSE("free port service");
928                                                                                                                                                                 free_string_node(target_ptr);
929                                                                                                                                                         }
930                                                                                                                                                 }
931                                                                                                                                                 break;
932                                                                                                                                         }
933                                                                                                                                         _param_index++;
934                                                                                                                                         _DEBUG_VERBOSE("param_index : %d", _param_index);
935                                                                                                                                 }
936                                                                                                                         }
937                                                                                                                 }
938                                                                                                                 pCursor_Port = pCursor_Port->next;
939                                                                                                         }
940                                                                                                 }
941                                                                                         }
942                                                                                         addr_index++;
943                                                                                 }
944                                                                         }
945                                                                 }
946
947                                                                 pCursor_AppAddr = pCursor_AppAddr->next;
948                                                         }
949                                                 } else if (WBXML_STRCMP("APPAUTH", wbxml_attribute_get_xml_value(attr)) == 0) {
950                                                         DM_CP_Application_AppAuth *app_auth = (DM_CP_Application_AppAuth *) calloc(1, sizeof(DM_CP_Application_AppAuth));
951                                                         if (app_auth == NULL) {
952                                                                 _DEBUG_VERBOSE("alloc fail");
953                                                                 free_cp_application(application);
954                                                                 application = NULL;
955                                                                 _INNER_FUNC_EXIT;
956                                                                 return 0;
957                                                         }
958                                                         if (application->appAuth == NULL) {
959                                                                 application->appAuth = app_auth;
960                                                         } else {
961                                                                 DM_CP_Application_AppAuth *cursor_ptr = application->appAuth;
962                                                                 while (cursor_ptr != NULL) {
963                                                                         if (cursor_ptr->next == NULL) {
964                                                                                 cursor_ptr->next = app_auth;
965                                                                                 break;
966                                                                         }
967                                                                         cursor_ptr = cursor_ptr->next;
968                                                                 }
969                                                         }
970                                                         WBXMLTreeNode *pCursor_AppAuth = pCursor->children;
971                                                         while (pCursor_AppAuth != 0) {
972                                                                 if (pCursor_AppAuth->type == WBXML_TREE_ELEMENT_NODE) {
973                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_AppAuth->name);
974                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
975                                                                                 WBXMLList *param_attrs = pCursor_AppAuth->attrs;
976                                                                                 WB_ULONG param_index = 0;
977                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
978                                                                                 while (param_index < param_nb_attrs) {
979                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
980                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
981                                                                                                 if (WBXML_STRCMP("AAUTHLEVEL", wbxml_attribute_get_xml_value(param_attr)) == 0) {
982                                                                                                         ___set_Param(pCursor_AppAuth, &(app_auth->auth_level));
983                                                                                                         if(app_auth->auth_level != NULL) {
984                                                                                                                 _DEBUG_VERBOSE("AAUTHLEVEL : %s", app_auth->auth_level);
985                                                                                                         }
986                                                                                                 } else if (WBXML_STRCMP("AAUTHTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
987                                                                                                         ___set_Param(pCursor_AppAuth, &(app_auth->auth_type));
988                                                                                                         if(app_auth->auth_type != NULL) {
989                                                                                                                 _DEBUG_VERBOSE("AAUTHTYPE : %s", app_auth->auth_type);
990                                                                                                         }
991                                                                                                 } else if (WBXML_STRCMP("AAUTHNAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
992                                                                                                         ___set_Param(pCursor_AppAuth, &(app_auth->auth_name));
993                                                                                                         if(app_auth->auth_name != NULL) {
994                                                                                                                 _DEBUG_VERBOSE("AAUTHNAME : %s", app_auth->auth_name);
995                                                                                                         }
996                                                                                                 } else if (WBXML_STRCMP("AAUTHSECRET", wbxml_attribute_get_xml_value(param_attr)) == 0) {
997                                                                                                         ___set_Param(pCursor_AppAuth, &(app_auth->auth_secret));
998                                                                                                         if(app_auth->auth_secret != NULL) {
999                                                                                                                 _DEBUG_VERBOSE("AAUTHSECRET : %s", app_auth->auth_secret);
1000                                                                                                         }
1001                                                                                                 } else if (WBXML_STRCMP("AAUTHDATA", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1002                                                                                                         ___set_Param(pCursor_AppAuth, &(app_auth->auth_data));
1003                                                                                                         if(app_auth->auth_data != NULL) {
1004                                                                                                                 _DEBUG_VERBOSE("AAUTHDATA : %s", app_auth->auth_data);
1005                                                                                                         }
1006                                                                                                 }
1007                                                                                                 break;
1008                                                                                         }
1009                                                                                         param_index++;
1010                                                                                 }
1011                                                                         }
1012                                                                 }
1013                                                                 pCursor_AppAuth = pCursor_AppAuth->next;
1014                                                         }
1015                                                 } else if (WBXML_STRCMP("RESOURCE", wbxml_attribute_get_xml_value(attr)) == 0) {
1016                                                         DM_CP_Application_Resource *app_resource = (DM_CP_Application_Resource *) calloc(1, sizeof(DM_CP_Application_Resource));
1017                                                         if (app_resource == NULL) {
1018                                                                 _DEBUG_VERBOSE("alloc fail");
1019                                                                 free_cp_application(application);
1020                                                                 application = NULL;
1021                                                                 _INNER_FUNC_EXIT;
1022                                                                 return 0;
1023                                                         }
1024                                                         if (application->resource == NULL) {
1025                                                                 application->resource = app_resource;
1026                                                         } else {
1027                                                                 DM_CP_Application_Resource *cursor_ptr = application->resource;
1028                                                                 while (cursor_ptr != NULL) {
1029                                                                         if (cursor_ptr->next == NULL) {
1030                                                                                 cursor_ptr->next = app_resource;
1031                                                                                 break;
1032                                                                         }
1033                                                                         cursor_ptr = cursor_ptr->next;
1034                                                                 }
1035                                                         }
1036                                                         WBXMLTreeNode *pCursor_Resource = pCursor->children;
1037                                                         while (pCursor_Resource != 0) {
1038                                                                 if (pCursor_Resource->type == WBXML_TREE_ELEMENT_NODE) {
1039                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Resource->name);
1040                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
1041                                                                                 WBXMLList *param_attrs = pCursor_Resource->attrs;
1042                                                                                 WB_ULONG param_index = 0;
1043                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
1044                                                                                 while (param_index < param_nb_attrs) {
1045                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
1046                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
1047                                                                                                 if (WBXML_STRCMP("URI", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1048                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->uri));
1049                                                                                                         if(app_resource->uri != NULL) {
1050                                                                                                                 _DEBUG_VERBOSE("URI : %s", app_resource->uri);
1051                                                                                                         }
1052                                                                                                 } else if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1053                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->name));
1054                                                                                                         if(app_resource->name != NULL) {
1055                                                                                                                 _DEBUG_VERBOSE("NAME : %s", app_resource->name);
1056                                                                                                         }
1057                                                                                                 } else if (WBXML_STRCMP("AACCEPT", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1058                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->accept));
1059                                                                                                         if(app_resource->accept != NULL) {
1060                                                                                                                 _DEBUG_VERBOSE("AACCEPT : %s", app_resource->accept);
1061                                                                                                         }
1062                                                                                                 } else if (WBXML_STRCMP("AAUTHTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1063                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->auth_type));
1064                                                                                                         if(app_resource->auth_type != NULL) {
1065                                                                                                                 _DEBUG_VERBOSE("AAUTHTYPE : %s", app_resource->auth_type);
1066                                                                                                         }
1067                                                                                                 } else if (WBXML_STRCMP("AAUTHNAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1068                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->auth_name));
1069                                                                                                         if(app_resource->auth_name != NULL) {
1070                                                                                                                 _DEBUG_VERBOSE("AAUTHNAME : %s", app_resource->auth_name);
1071                                                                                                         }
1072                                                                                                 } else if (WBXML_STRCMP("AAUTHSECRET", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1073                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->auth_secret));
1074                                                                                                         if(app_resource->auth_secret != NULL) {
1075                                                                                                                 _DEBUG_VERBOSE("AAUTHSECRET : %s", app_resource->auth_secret);
1076                                                                                                         }
1077                                                                                                 } else if (WBXML_STRCMP("AAUTHDATA", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1078                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->auth_data));
1079                                                                                                         if(app_resource->auth_data != NULL) {
1080                                                                                                                 _DEBUG_VERBOSE("AAUTHDATA : %s", app_resource->auth_data);
1081                                                                                                         }
1082                                                                                                 } else if (WBXML_STRCMP("STARTPAGE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1083                                                                                                         ___set_Param(pCursor_Resource, &(app_resource->start_page));
1084                                                                                                         if(app_resource->start_page != NULL) {
1085                                                                                                                 _DEBUG_VERBOSE("STARTPAGE : %s", app_resource->start_page);
1086                                                                                                         }
1087                                                                                                 }
1088                                                                                                 break;
1089                                                                                         }
1090                                                                                         param_index++;
1091                                                                                 }
1092                                                                         }
1093                                                                 }
1094                                                                 pCursor_Resource = pCursor_Resource->next;
1095                                                         }
1096                                                 }
1097                                         }
1098
1099                                         index++;
1100                                 }
1101                         }
1102                 }
1103
1104                 pCursor = pCursor->next;
1105         }
1106
1107         _INNER_FUNC_EXIT;
1108
1109         return application;
1110 }
1111
1112 static DM_CP_PxLogical *__parse_PxLogical(WBXMLTreeNode * wbxml_dom_node)
1113 {
1114         _INNER_FUNC_ENTER;
1115
1116         retvm_if((wbxml_dom_node) == NULL, NULL, "wbxml_dom_node is NULL!!");
1117
1118         DM_CP_PxLogical *pxLogical = (DM_CP_PxLogical *) calloc(1, sizeof(DM_CP_PxLogical));
1119         if (pxLogical == NULL) {
1120                 _DEBUG_VERBOSE("alloc fail");
1121                 _INNER_FUNC_EXIT;
1122                 return 0;
1123         }
1124         WBXMLTreeNode *pCursor = wbxml_dom_node->children;
1125
1126         while (pCursor != 0) {
1127                 if (pCursor->type == WBXML_TREE_ELEMENT_NODE) {
1128                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor->name);
1129                         if (strcmp((const char *)tag_name, "parm") == 0) {
1130                                 WBXMLList *param_attrs = pCursor->attrs;
1131                                 WB_ULONG param_index = 0;
1132                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
1133                                 while (param_index < param_nb_attrs) {
1134                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
1135                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
1136                                                 if (WBXML_STRCMP("PROXY-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1137                                                         ___set_Param(pCursor, &(pxLogical->proxy_id));
1138                                                         if(pxLogical->proxy_id != NULL) {
1139                                                                 _DEBUG_VERBOSE("PROXY-ID : %s", pxLogical->proxy_id);
1140                                                         }
1141                                                 } else if (WBXML_STRCMP("PROXY-PW", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1142                                                         ___set_Param(pCursor, &(pxLogical->proxy_pw));
1143                                                         if(pxLogical->proxy_pw != NULL) {
1144                                                                 _DEBUG_VERBOSE("PROXY-PW : %s", pxLogical->proxy_pw);
1145                                                         }
1146                                                 } else if (WBXML_STRCMP("PPGAUTH-TYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1147                                                         ___set_Param(pCursor, &(pxLogical->ppg_auth_type));
1148                                                         if(pxLogical->ppg_auth_type != NULL) {
1149                                                                 _DEBUG_VERBOSE("PPGAUTH-TYPE : %s", pxLogical->ppg_auth_type);
1150                                                         }
1151                                                 } else if (WBXML_STRCMP("PROXY-PROVIDER-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1152                                                         ___set_Param(pCursor, &(pxLogical->proxy_provider_id));
1153                                                         if(pxLogical->proxy_provider_id != NULL) {
1154                                                                 _DEBUG_VERBOSE("PROXY-PROVIDER-ID : %s", pxLogical->proxy_provider_id);
1155                                                         }
1156                                                 } else if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1157                                                         ___set_Param(pCursor, &(pxLogical->name));
1158                                                         if(pxLogical->name != NULL) {
1159                                                                 _DEBUG_VERBOSE("NAME : %s", pxLogical->name);
1160                                                         }
1161                                                 } else if (WBXML_STRCMP("DOMAIN", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1162                                                         String_Node *target_ptr = ___get_Last_String_Node(pxLogical->domain);
1163                                                         if(target_ptr == NULL) {
1164                                                                 _DEBUG_VERBOSE("___get_Last_String_Node fail");
1165                                                                 free_cp_pxlogical(pxLogical);
1166                                                                 pxLogical = NULL;
1167                                                                 _INNER_FUNC_EXIT;
1168                                                                 return 0;
1169                                                         }
1170                                                         ___set_Param(pCursor, &(target_ptr->data));
1171                                                         if(target_ptr->data != NULL) {
1172                                                                 _DEBUG_VERBOSE("DOMAIN : %s", target_ptr->data);
1173                                                         }
1174                                                         if (pxLogical->domain == 0) {
1175                                                                 pxLogical->domain = target_ptr;
1176                                                         } else {
1177                                                                 _DEBUG_VERBOSE("free DOMAIN ");
1178                                                                 free_string_node(target_ptr);
1179                                                         }
1180                                                 } else if (WBXML_STRCMP("TRUST", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1181                                                         ___set_Param(pCursor, &(pxLogical->trust));
1182                                                         if(pxLogical->trust != NULL) {
1183                                                                 _DEBUG_VERBOSE("TRUST : %s", pxLogical->trust);
1184                                                         }
1185                                                 } else if (WBXML_STRCMP("MASTER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1186                                                         ___set_Param(pCursor, &(pxLogical->master));
1187                                                         if(pxLogical->master != NULL) {
1188                                                                 _DEBUG_VERBOSE("MASTER : %s", pxLogical->master);
1189                                                         }
1190                                                 } else if (WBXML_STRCMP("STARTPAGE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1191                                                         ___set_Param(pCursor, &(pxLogical->start_page));
1192                                                         if(pxLogical->start_page != NULL) {
1193                                                                 _DEBUG_VERBOSE("STARTPAGE : %s", pxLogical->start_page);
1194                                                         }
1195                                                 } else if (WBXML_STRCMP("BASAUTH-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1196                                                         ___set_Param(pCursor, &(pxLogical->bas_auth_id));
1197                                                         if(pxLogical->bas_auth_id != NULL) {
1198                                                                 _DEBUG_VERBOSE("BASAUTH-ID : %s", pxLogical->bas_auth_id);
1199                                                         }
1200                                                 } else if (WBXML_STRCMP("BASAUTH-PW", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1201                                                         ___set_Param(pCursor, &(pxLogical->bas_auth_pw));
1202                                                         if(pxLogical->bas_auth_pw != NULL) {
1203                                                                 _DEBUG_VERBOSE("BASAUTH-PW : %s", pxLogical->bas_auth_pw);
1204                                                         }
1205                                                 } else if (WBXML_STRCMP("WSP-VERSION", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1206                                                         ___set_Param(pCursor, &(pxLogical->wsp_version));
1207                                                         if(pxLogical->wsp_version != NULL) {
1208                                                                 _DEBUG_VERBOSE("WSP-VERSION : %s", pxLogical->wsp_version);
1209                                                         }
1210                                                 } else if (WBXML_STRCMP("PUSHENABLED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1211                                                         ___set_Param(pCursor, &(pxLogical->push_enabled));
1212                                                         if(pxLogical->push_enabled != NULL) {
1213                                                                 _DEBUG_VERBOSE("PUSHENABLED : %s", pxLogical->push_enabled);
1214                                                         }
1215                                                 } else if (WBXML_STRCMP("PULLENABLED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1216                                                         ___set_Param(pCursor, &(pxLogical->pull_enabled));
1217                                                         if(pxLogical->pull_enabled != NULL) {
1218                                                                 _DEBUG_VERBOSE("PULLENABLED : %s", pxLogical->pull_enabled);
1219                                                         }
1220                                                 }
1221                                                 break;
1222                                         }
1223                                         param_index++;
1224                                 }
1225                         } else if (!strcmp((const char *)tag_name, "characteristic")) {
1226                                 WBXMLList *attrs = pCursor->attrs;
1227                                 WB_ULONG index = 0;
1228                                 WB_ULONG nb_attrs = wbxml_list_len(attrs);
1229
1230                                 while (index < nb_attrs) {
1231                                         WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attrs, index);
1232
1233                                         if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(attr)) == 0) {
1234
1235                                                 if (WBXML_STRCMP("PXAUTHINFO", wbxml_attribute_get_xml_value(attr)) == 0) {
1236                                                         DM_CP_PxLogical_PxAuthInfo *pxAuthInfo = (DM_CP_PxLogical_PxAuthInfo *) calloc(1, sizeof(DM_CP_PxLogical_PxAuthInfo));
1237                                                         if (pxAuthInfo == NULL) {
1238                                                                 _DEBUG_VERBOSE("alloc fail");
1239                                                                 free_cp_pxlogical(pxLogical);
1240                                                                 pxLogical = NULL;
1241                                                                 _INNER_FUNC_EXIT;
1242                                                                 return 0;
1243                                                         }
1244                                                         if (pxLogical->pxAuthInfo == NULL) {
1245                                                                 pxLogical->pxAuthInfo = pxAuthInfo;
1246                                                         } else {
1247                                                                 DM_CP_PxLogical_PxAuthInfo *cursor_ptr = pxLogical->pxAuthInfo;
1248                                                                 while (cursor_ptr != NULL) {
1249                                                                         if (cursor_ptr->next == NULL) {
1250                                                                                 cursor_ptr->next = pxAuthInfo;
1251                                                                                 break;
1252                                                                         }
1253                                                                         cursor_ptr = cursor_ptr->next;
1254                                                                 }
1255                                                         }
1256                                                         WBXMLTreeNode *pCursor_PxAuthInfo = pCursor->children;
1257                                                         while (pCursor_PxAuthInfo != 0) {
1258                                                                 if (pCursor_PxAuthInfo->type == WBXML_TREE_ELEMENT_NODE) {
1259                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_PxAuthInfo->name);
1260                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
1261                                                                                 WBXMLList *param_attrs = pCursor_PxAuthInfo->attrs;
1262                                                                                 WB_ULONG param_index = 0;
1263                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
1264                                                                                 while (param_index < param_nb_attrs) {
1265                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
1266                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
1267                                                                                                 if (WBXML_STRCMP("PXAUTH-TYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1268                                                                                                         ___set_Param(pCursor_PxAuthInfo, &(pxAuthInfo->pxAuth_type));
1269                                                                                                         if(pxAuthInfo->pxAuth_type != NULL) {
1270                                                                                                                 _DEBUG_VERBOSE("PXAUTH-TYPE : %s", pxAuthInfo->pxAuth_type);
1271                                                                                                         }
1272                                                                                                 } else if (WBXML_STRCMP("PXAUTH-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1273                                                                                                         ___set_Param(pCursor_PxAuthInfo, &(pxAuthInfo->pxAuth_id));
1274                                                                                                         if(pxAuthInfo->pxAuth_id != NULL) {
1275                                                                                                                 _DEBUG_VERBOSE("PXAUTH-ID : %s", pxAuthInfo->pxAuth_id);
1276                                                                                                         }
1277                                                                                                 } else if (WBXML_STRCMP("PXAUTH-PW", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1278                                                                                                         ___set_Param(pCursor_PxAuthInfo, &(pxAuthInfo->pxAuth_pw));
1279                                                                                                         if(pxAuthInfo->pxAuth_pw != NULL) {
1280                                                                                                                 _DEBUG_VERBOSE("PXAUTH-PW : %s", pxAuthInfo->pxAuth_pw);
1281                                                                                                         }
1282                                                                                                 }
1283                                                                                                 break;
1284                                                                                         }
1285                                                                                         param_index++;
1286                                                                                 }
1287                                                                         }
1288                                                                 }
1289                                                                 pCursor_PxAuthInfo = pCursor_PxAuthInfo->next;
1290                                                         }
1291                                                 } else if (WBXML_STRCMP("PORT", wbxml_attribute_get_xml_value(attr)) == 0) {
1292                                                         DM_CP_Port *port = (DM_CP_Port *) calloc(1, sizeof(DM_CP_Port));
1293                                                         if (port == NULL) {
1294                                                                 _DEBUG_VERBOSE("alloc fail");
1295                                                                 free_cp_pxlogical(pxLogical);
1296                                                                 pxLogical = NULL;
1297                                                                 _INNER_FUNC_EXIT;
1298                                                                 return 0;
1299                                                         }
1300                                                         if (pxLogical->port == NULL) {
1301                                                                 pxLogical->port = port;
1302                                                         } else {
1303                                                                 DM_CP_Port *cursor_ptr = pxLogical->port;
1304                                                                 while (cursor_ptr != NULL) {
1305                                                                         if (cursor_ptr->next == NULL) {
1306                                                                                 cursor_ptr->next = port;
1307                                                                                 break;
1308                                                                         }
1309                                                                         cursor_ptr = cursor_ptr->next;
1310                                                                 }
1311                                                         }
1312                                                         WBXMLTreeNode *pCursor_Port = pCursor->children;
1313                                                         while (pCursor_Port != 0) {
1314                                                                 if (pCursor_Port->type == WBXML_TREE_ELEMENT_NODE) {
1315                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Port->name);
1316                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
1317                                                                                 WBXMLList *param_attrs = pCursor_Port->attrs;
1318                                                                                 WB_ULONG param_index = 0;
1319                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
1320                                                                                 while (param_index < param_nb_attrs) {
1321                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
1322                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
1323                                                                                                 if (WBXML_STRCMP("PORTNBR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1324                                                                                                         ___set_Param(pCursor_Port, &(port->portnbr));
1325                                                                                                         if(port->portnbr != NULL) {
1326                                                                                                                 _DEBUG_VERBOSE("AAUTHLEVEL : %s", port->portnbr);
1327                                                                                                         }
1328                                                                                                 } else if (WBXML_STRCMP("SERVICE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1329                                                                                                         String_Node *target_ptr = ___get_Last_String_Node(port->service);
1330                                                                                                         ___set_Param(pCursor_Port, &(target_ptr->data));
1331                                                                                                         if(target_ptr->data != NULL) {
1332                                                                                                                 _DEBUG_VERBOSE("SERVICE : %s", target_ptr->data);
1333                                                                                                         }
1334                                                                                                         if (port->service == NULL) {
1335                                                                                                                 port->service = target_ptr;
1336                                                                                                         } else {
1337                                                                                                                 _DEBUG_VERBOSE("free SERVICE ");
1338                                                                                                                 free_string_node(target_ptr);
1339                                                                                                         }
1340                                                                                                 }
1341                                                                                                 break;
1342                                                                                         }
1343                                                                                         param_index++;
1344                                                                                 }
1345                                                                         }
1346                                                                 }
1347                                                                 pCursor_Port = pCursor_Port->next;
1348                                                         }
1349                                                 } else if (WBXML_STRCMP("PXPHYSICAL", wbxml_attribute_get_xml_value(attr)) == 0) {
1350                                                         DM_CP_PxLogical_PxPhysical *pxPhysical = (DM_CP_PxLogical_PxPhysical *) calloc(1, sizeof(DM_CP_PxLogical_PxPhysical));
1351                                                         if (pxPhysical == NULL) {
1352                                                                 _DEBUG_VERBOSE("alloc fail");
1353                                                                 free_cp_pxlogical(pxLogical);
1354                                                                 pxLogical = NULL;
1355                                                                 _INNER_FUNC_EXIT;
1356                                                                 return 0;
1357                                                         }
1358                                                         if (pxLogical->pxPhysical == NULL) {
1359                                                                 pxLogical->pxPhysical = pxPhysical;
1360                                                         } else {
1361                                                                 DM_CP_PxLogical_PxPhysical *cursor_ptr = pxLogical->pxPhysical;
1362                                                                 while (cursor_ptr != NULL) {
1363                                                                         if (cursor_ptr->next == NULL) {
1364                                                                                 cursor_ptr->next = pxPhysical;
1365                                                                                 break;
1366                                                                         }
1367                                                                         cursor_ptr = cursor_ptr->next;
1368                                                                 }
1369                                                         }
1370                                                         WBXMLTreeNode *pCursor_PxPhysical = pCursor->children;
1371                                                         while (pCursor_PxPhysical != 0) {
1372                                                                 if (pCursor_PxPhysical->type == WBXML_TREE_ELEMENT_NODE) {
1373                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_PxPhysical->name);
1374                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
1375                                                                                 WBXMLList *param_attrs = pCursor_PxPhysical->attrs;
1376                                                                                 WB_ULONG param_index = 0;
1377                                                                                 WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
1378                                                                                 while (param_index < param_nb_attrs) {
1379                                                                                         WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
1380                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
1381                                                                                                 if (WBXML_STRCMP("PHYSICAL-PROXY-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1382                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->physical_proxy_id));
1383                                                                                                         if(pxPhysical->physical_proxy_id != NULL) {
1384                                                                                                                 _DEBUG_VERBOSE("PHYSICAL-PROXY-ID : %s", pxPhysical->physical_proxy_id);
1385                                                                                                         }
1386                                                                                                 } else if (WBXML_STRCMP("DOMAIN", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1387                                                                                                         String_Node *target_ptr = ___get_Last_String_Node(pxPhysical->domain);
1388                                                                                                         if(target_ptr == NULL) {
1389                                                                                                                 _DEBUG_VERBOSE("___get_Last_String_Node fail");
1390                                           free_cp_pxlogical(pxLogical);
1391                                           pxLogical = NULL;
1392                                                                                                                 _INNER_FUNC_EXIT;
1393                                                                                                                 return 0;
1394                                                                                                         }
1395                                                                                                         ___set_Param(pCursor_PxPhysical, &(target_ptr->data));
1396                                                                                                         if(target_ptr->data != NULL) {
1397                                                                                                                 _DEBUG_VERBOSE("DOMAIN : %s", target_ptr->data);
1398                                                                                                         }
1399                                                                                                         if (pxPhysical->domain == NULL) {
1400                                                                                                                 pxPhysical->domain = target_ptr;
1401                                                                                                         } else {
1402                                                                                                                 _DEBUG_VERBOSE("free DOMAIN ");
1403                                                                                                                 free_string_node(target_ptr);
1404                                                                                                         }
1405                                                                                                 } else if (WBXML_STRCMP("PXADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1406                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->pxAddr));
1407                                                                                                         if(pxPhysical->pxAddr != NULL) {
1408                                                                                                                 _DEBUG_VERBOSE("PXADDR : %s", pxPhysical->pxAddr);
1409                                                                                                         }
1410                                                                                                 } else if (WBXML_STRCMP("PXADDRTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1411                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->pxAddrType));
1412                                                                                                         if(pxPhysical->pxAddrType != NULL) {
1413                                                                                                                 _DEBUG_VERBOSE("PXADDRTYPE : %s", pxPhysical->pxAddrType);
1414                                                                                                         }
1415                                                                                                 } else if (WBXML_STRCMP("PXADDR-FQDN", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1416                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->pxAddr_FQDN));
1417                                                                                                         if(pxPhysical->pxAddr_FQDN != NULL) {
1418                                                                                                                 _DEBUG_VERBOSE("PXADDR-FQDN : %s", pxPhysical->pxAddr_FQDN);
1419                                                                                                         }
1420                                                                                                 } else if (WBXML_STRCMP("WSP-VERSION", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1421                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->wsp_version));
1422                                                                                                         if(pxPhysical->wsp_version != NULL) {
1423                                                                                                                 _DEBUG_VERBOSE("WSP-VERSION : %s", pxPhysical->wsp_version);
1424                                                                                                         }
1425                                                                                                 } else if (WBXML_STRCMP("PUSHENABLED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1426                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->push_enabled));
1427                                                                                                         if(pxPhysical->push_enabled != NULL) {
1428                                                                                                                 _DEBUG_VERBOSE("PUSHENABLED : %s", pxPhysical->push_enabled);
1429                                                                                                         }
1430                                                                                                 } else if (WBXML_STRCMP("PULLENABLED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1431                                                                                                         ___set_Param(pCursor_PxPhysical, &(pxPhysical->pull_enabled));
1432                                                                                                         if(pxPhysical->pull_enabled != NULL) {
1433                                                                                                                 _DEBUG_VERBOSE("PULLENABLED : %s", pxPhysical->pull_enabled);
1434                                                                                                         }
1435                                                                                                 } else if (WBXML_STRCMP("TO-NAPID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
1436                                                                                                         String_Node *target_ptr = ___get_Last_String_Node(pxPhysical->to_napid);
1437                                                                                                         if(target_ptr == NULL) {
1438                                                                                                                 _DEBUG_VERBOSE("___get_Last_String_Node fail");
1439                                           free_cp_pxlogical(pxLogical);
1440                                           pxLogical = NULL;
1441                                                                                                                 _INNER_FUNC_EXIT;
1442                                                                                                                 return 0;
1443                                                                                                         }
1444                                                                                                         ___set_Param(pCursor_PxPhysical, &(target_ptr->data));
1445                                                                                                         if(target_ptr->data != NULL) {
1446                                                                                                                 _DEBUG_VERBOSE("TO-NAPID : %s", target_ptr->data);
1447                                                                                                         }
1448                                                                                                         if (pxPhysical->to_napid == NULL) {
1449                                                                                                                 pxPhysical->to_napid = target_ptr;
1450                                                                                                         } else {
1451                                                                                                                 _DEBUG_VERBOSE("free TO-NAPID ");
1452                                                                                                                 free_string_node(target_ptr);
1453                                                                                                         }
1454                                                                                                 }
1455                                                                                                 break;
1456                                                                                         }
1457                                                                                         param_index++;
1458                                                                                 }
1459                                                                         } else if (strcmp((const char *)tag_name, "characteristic") == 0) {
1460                                                                                 WBXMLList *addr_attrs = pCursor_PxPhysical->attrs;
1461                                                                                 WB_ULONG addr_index = 0;
1462                                                                                 WB_ULONG addr_nb_attrs = wbxml_list_len(addr_attrs);
1463
1464                                                                                 while (addr_index < addr_nb_attrs) {
1465                                                                                         WBXMLAttribute *addr_attr = (WBXMLAttribute *) wbxml_list_get(addr_attrs, addr_index);
1466                                                                                         if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(addr_attr)) == 0) {
1467                                                                                                 if (WBXML_STRCMP("PORT", wbxml_attribute_get_xml_value(addr_attr)) == 0) {
1468                                                                                                         DM_CP_Port *port = (DM_CP_Port *) calloc(1, sizeof(DM_CP_Port));
1469                                                                                                         if (port == NULL) {
1470                                                                                                                 _DEBUG_VERBOSE("alloc fail");
1471                                                                                                                 free_cp_pxlogical(pxLogical);
1472                                                                                                                 pxLogical = NULL;
1473                                                                                                                 _INNER_FUNC_EXIT;
1474                                                                                                                 return 0;
1475                                                                                                         }
1476                                                                                                         if (pxPhysical->port == NULL) {
1477                                                                                                                 pxPhysical->port = port;
1478                                                                                                         } else {
1479                                                                                                                 DM_CP_Port *cursor_ptr = pxPhysical->port;
1480                                                                                                                 while (cursor_ptr != NULL) {
1481                                                                                                                         if (cursor_ptr->next == NULL) {
1482                                                                                                                                 cursor_ptr->next = port;
1483                                                                                                                                 break;
1484                                                                                                                         }
1485                                                                                                                         cursor_ptr = cursor_ptr->next;
1486                                                                                                                 }
1487                                                                                                         }
1488                                                                                                         WBXMLTreeNode *pCursor_Port = pCursor_PxPhysical->children;
1489                                                                                                         while (pCursor_Port != 0) {
1490                                                                                                                 if (pCursor_Port->type == WBXML_TREE_ELEMENT_NODE) {
1491                                                                                                                         const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Port->name);
1492                                                                                                                         if (strcmp((const char *)tag_name, "parm") == 0) {
1493                                                                                                                                 WBXMLList *_param_attrs = pCursor_Port->attrs;
1494                                                                                                                                 WB_ULONG _param_index = 0;
1495                                                                                                                                 WB_ULONG _param_nb_attrs = wbxml_list_len(_param_attrs);
1496                                                                                                                                 while (_param_index < _param_nb_attrs) {
1497                                                                                                                                         WBXMLAttribute *_param_attr = (WBXMLAttribute *) wbxml_list_get(_param_attrs, _param_index);
1498                                                                                                                                         if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(_param_attr)) == 0) {
1499                                                                                                                                                 if (WBXML_STRCMP("PORTNBR", wbxml_attribute_get_xml_value(_param_attr)) == 0) {
1500                                                                                                                                                         ___set_Param(pCursor_Port, &(port->portnbr));
1501                                                                                                                                                         if(port->portnbr != NULL) {
1502                                                                                                                                                                 _DEBUG_VERBOSE("[%d] PORTNBR : %s", _param_index, port->portnbr);
1503                                                                                                                                                         }
1504                                                                                                                                                 } else if (WBXML_STRCMP("SERVICE", wbxml_attribute_get_xml_value(_param_attr)) == 0) {
1505                                                                                                                                                         String_Node *target_ptr = ___get_Last_String_Node(port->service);
1506                                                                                                                                                         if(target_ptr==NULL) {
1507                                                                                                                                                                 _DEBUG_VERBOSE("___get_Last_String_Node fail");
1508                                                             free_cp_pxlogical(pxLogical);
1509                                                             pxLogical = NULL;
1510                                                                                                                                                                 _INNER_FUNC_EXIT;
1511                                                                                                                                                                 return 0;
1512                                                                                                                                                         }
1513                                                                                                                                                         ___set_Param(pCursor_Port, &(target_ptr->data));
1514                                                                                                                                                         if(target_ptr->data != NULL) {
1515                                                                                                                                                                 _DEBUG_VERBOSE("SERVICE : %s", target_ptr->data);
1516                                                                                                                                                         }
1517                                                                                                                                                         if (port->service == NULL) {
1518                                                                                                                                                                 port->service = target_ptr;
1519                                                                                                                                                         } else {
1520                                                                                                                                                                 _DEBUG_VERBOSE("free port service");
1521                                                                                                                                                                 free_string_node(target_ptr);
1522                                                                                                                                                         }
1523                                                                                                                                                 }
1524                                                                                                                                                 break;
1525                                                                                                                                         }
1526                                                                                                                                         _param_index++;
1527                                                                                                                                         _DEBUG_VERBOSE("param_index : %d", _param_index);
1528                                                                                                                                 }
1529                                                                                                                         }
1530                                                                                                                 }
1531                                                                                                                 pCursor_Port = pCursor_Port->next;
1532                                                                                                         }
1533                                                                                                 }
1534                                                                                         }
1535                                                                                         addr_index++;
1536                                                                                 }
1537                                                                         }
1538                                                                 }
1539                                                                 pCursor_PxPhysical = pCursor_PxPhysical->next;
1540                                                         }
1541                                                 }
1542                                         }
1543                                         index++;
1544                                 }
1545                         }
1546                 }
1547
1548                 pCursor = pCursor->next;
1549         }
1550
1551         _INNER_FUNC_EXIT;
1552
1553         return pxLogical;
1554 }
1555
1556 static void ___set_Param(WBXMLTreeNode * wbxml_dom_node, char **set_value)
1557 {
1558         _INNER_FUNC_ENTER;
1559
1560         retm_if((wbxml_dom_node) == NULL, "wbxml_dom_node is NULL!!");
1561
1562         WBXMLList *attr_list = wbxml_dom_node->attrs;
1563         WB_ULONG index = 0;
1564         WB_ULONG nb_attrs = wbxml_list_len(attr_list);
1565
1566         while (index < nb_attrs) {
1567                 WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attr_list, index);
1568                 if (WBXML_STRCMP("value", wbxml_attribute_get_xml_name(attr)) == 0) {
1569                         const char *value_str = 0;
1570                         value_str = (const char *)wbxml_attribute_get_xml_value(attr);
1571                         int value_len = 0;
1572                         if (value_str != NULL) {
1573                                 value_len = strlen(value_str);
1574                         }
1575                         int str_len = 0;
1576                         *set_value = (char *)calloc(value_len + 1, sizeof(char));
1577                         if (*set_value == NULL) {
1578                                 break;
1579                         }
1580
1581                         str_len = g_strlcpy(*set_value, value_str, value_len + 1);
1582                         if (str_len >= sizeof(*set_value)) {
1583                                 _DEBUG_VERBOSE("buffer overflow");
1584                                 break;
1585                         }
1586                         break;
1587                 }
1588                 index++;
1589         }
1590         _INNER_FUNC_EXIT;
1591 }