Tizen 2.0 Release
[framework/system/oma-dm-agent.git] / src / agent / serviceadapter / sa_elements.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 /*sync-agent*/
19 #include <sync_agent.h>
20
21 /*dm-agent*/
22 #include "common/dm_common.h"
23 #include "common/util/util.h"
24 #include "serviceadapter/protocolbinder/syncml_def.h"
25 #include "serviceadapter/sa_elements.h"
26 #include "serviceadapter/sa_elements_internal.h"
27 #include "serviceadapter/sa_session_internal.h"
28 #include "serviceadapter/sa_command.h"
29 #include "mo-handler/dm_mo_common.h"
30
31 #ifndef OMADM_AGENT_LOG
32 #undef LOG_TAG
33 #define LOG_TAG "OMA_DM_SA"
34 #endif
35
36 DM_ERROR create_hmac(char *auth_name, char *auth_type, char *mac, Session ** session)
37 {
38         _EXTERN_FUNC_ENTER;
39
40         DM_ERROR ret = DM_OK;
41
42         retvm_if((auth_name) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "auth_name is NULL!!");
43         retvm_if((auth_type) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "auth_type is NULL!!");
44         retvm_if((mac) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "mac is NULL!!");
45
46         if ((*session)->reqhmacinfo == NULL) {
47                 (*session)->reqhmacinfo = (Hmac *) calloc(1, sizeof(Hmac));
48                 if ((*session)->reqhmacinfo == NULL) {
49                         ret = COMMON_ERR_ALLOC;
50                         goto error;
51                 }
52         }
53
54         if ((*session)->reqhmacinfo->username != NULL) {
55                 str_free(&(*session)->reqhmacinfo->username);
56         }
57         if ((*session)->reqhmacinfo->authtype != NULL) {
58                 str_free(&(*session)->reqhmacinfo->authtype);
59         }
60         if ((*session)->reqhmacinfo->mac != NULL) {
61                 str_free(&(*session)->reqhmacinfo->mac);
62         }
63
64         (*session)->reqhmacinfo->username = strdup(auth_name);
65         (*session)->reqhmacinfo->authtype = strdup(auth_type);
66         (*session)->reqhmacinfo->mac = strdup(mac);
67
68         _DEBUG_INFO("user name : %s", auth_name);
69         _DEBUG_INFO("auth type : %s", auth_type);
70         _DEBUG_INFO("mac : %s", mac);
71
72         _DEBUG_INFO(" end : %d", ret);
73         _EXTERN_FUNC_EXIT;
74         return ret;
75  error:
76         _DEBUG_INFO(" end error : %d", ret);
77         _EXTERN_FUNC_EXIT;
78         return ret;
79 }
80
81 DM_ERROR create_location(const char *locURI, const char *locName, Location ** pLocation)
82 {
83         _EXTERN_FUNC_ENTER;
84
85         DM_ERROR ret = DM_OK;
86
87         retvm_if((locURI) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "locURI is NULL!!");
88         _DEBUG_INFO("start with locURI = %s, locName = %s\n", locURI, locName);
89
90         *pLocation = (Location *) calloc(1, sizeof(Location) + 1);
91         if (*pLocation == NULL) {
92                 ret = COMMON_ERR_ALLOC;
93                 goto error;
94         }
95         (*pLocation)->locURI = g_strdup(locURI);
96
97         if (locName != NULL) {
98                 (*pLocation)->locName = g_strdup(locName);
99         }
100
101         _DEBUG_INFO("end");
102         _EXTERN_FUNC_EXIT;
103         return ret;
104
105  error:
106         _DEBUG_INFO(" error : %d\n", ret);
107         _EXTERN_FUNC_EXIT;
108         return ret;
109 }
110
111 Location *dup_location(Location * pLocation)
112 {
113         _EXTERN_FUNC_ENTER;
114
115         DM_ERROR ret = DM_OK;
116
117         retvm_if((pLocation) == NULL, NULL, "pLocation is NULL!!");
118
119         Location *location = NULL;
120         ret = create_location(pLocation->locURI, pLocation->locName, &location);
121         if (ret != DM_OK)
122                 goto error;
123
124         _EXTERN_FUNC_EXIT;
125         return location;
126
127  error:
128         _DEBUG_INFO(" error : %d\n", ret);
129         _EXTERN_FUNC_EXIT;
130         return NULL;
131
132 }
133
134 char *get_location_locname(Location * location)
135 {
136         _EXTERN_FUNC_ENTER;
137
138         retvm_if((location) == NULL, NULL, "location is NULL!!");
139
140         _EXTERN_FUNC_EXIT;
141
142         return location->locName;
143 }
144
145 char *get_location_locuri(Location * location)
146 {
147         _EXTERN_FUNC_ENTER;
148
149         retvm_if((location) == NULL, NULL, "location is NULL!!");
150
151         _EXTERN_FUNC_EXIT;
152
153         return location->locURI;
154 }
155
156 void free_location(Location * loc)
157 {
158         _EXTERN_FUNC_ENTER;
159
160         retm_if((loc) == NULL, "loc is NULL!!");
161
162         if (loc->locURI != NULL) {
163                 _DEBUG_INFO(" loc->locURI = %s\n", loc->locURI);
164                 free(loc->locURI);
165                 loc->locURI = NULL;
166         }
167
168         if (loc->locName != NULL) {
169                 _DEBUG_INFO(" loc->locName = %s\n", loc->locName);
170                 free(loc->locName);
171                 loc->locName = NULL;
172         }
173         if (loc != NULL) {
174                 free(loc);
175                 loc = NULL;
176         }
177         _EXTERN_FUNC_EXIT;
178 }
179
180 void free_cred(Cred * cred)
181 {
182         _EXTERN_FUNC_ENTER;
183
184         if (cred == NULL)
185                 return;
186
187         if (cred->data != NULL) {
188                 free(cred->data);
189                 cred->data = NULL;
190         }
191
192         if (cred->username != NULL) {
193                 free(cred->username);
194                 cred->username = NULL;
195         }
196
197         if (cred->password != NULL) {
198                 free(cred->password);
199                 cred->password = NULL;
200         }
201         if (cred != NULL) {
202                 free(cred);
203                 cred = NULL;
204         }
205
206         _EXTERN_FUNC_EXIT;
207 }
208
209 DM_ERROR create_auth_cred(char *userName, char *pwd, AuthType authType, FormatType formatType, char *data, Cred ** cred)
210 {
211
212         _EXTERN_FUNC_ENTER;
213
214         DM_ERROR ret = DM_OK;
215
216         retvm_if((userName) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "userName is NULL!!");
217         retvm_if((pwd) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "pwd is NULL!!");
218
219         _DEBUG_INFO(" user : %s , pwd : %s, authtype : %d,. formattype : %d, cred : %s\n", userName, pwd, authType, formatType, data);
220
221         if (strlen(userName) == 0 || strlen(pwd) == 0) {
222                 ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
223                 goto error;
224         }
225
226         if (data != NULL) {
227                 *cred = (Cred *) calloc(1, sizeof(Cred));
228                 if (*cred == NULL) {
229                         ret = COMMON_ERR_ALLOC;
230                         goto error;
231                 }
232
233                 (*cred)->type = authType;
234                 (*cred)->format = formatType;
235                 (*cred)->username = strdup(userName);
236                 (*cred)->password = strdup(pwd);
237
238                 (*cred)->data = strdup(data);
239         } else if (data == NULL && authType == AUTH_TYPE_HMAC) {
240                 /* hmac  */
241         } else {
242                 /*error */
243                 ret = COMMON_ERR_IS_NULL;
244         }
245
246         _EXTERN_FUNC_EXIT;
247         return ret;
248  error:
249         _DEBUG_INFO(" error : %d\n", ret);
250         _EXTERN_FUNC_EXIT;
251         return ret;
252
253 }
254
255 Cred *create_credwithdata(AuthType authType, char *data)
256 {
257         _EXTERN_FUNC_ENTER;
258
259         DM_ERROR ret = DM_OK;
260
261         retvm_if((data) == NULL, NULL, "data is NULL!!");
262
263         Cred *cred = (Cred *) calloc(1, sizeof(Cred));
264         if (cred == NULL) {
265                 ret = COMMON_ERR_ALLOC;
266                 goto error;
267         }
268
269         cred->type = authType;
270         cred->data = strdup(data);
271
272         _EXTERN_FUNC_EXIT;
273         return cred;
274  error:
275         _DEBUG_INFO(" error : %d\n", ret);
276         _EXTERN_FUNC_EXIT;
277         return NULL;
278
279 }
280
281 void set_credformattype(Cred * cred, FormatType formatType)
282 {
283         _EXTERN_FUNC_ENTER;
284
285         retm_if((cred) == NULL, "cred is NULL!!");
286
287         cred->format = formatType;
288
289         _EXTERN_FUNC_EXIT;
290 }
291
292 DM_ERROR check_server_cred(Cred * hdrCred, Session * session)   //Cred *sessionCred)
293 {
294         _EXTERN_FUNC_ENTER;
295
296         DM_ERROR ret = DM_OK;
297
298         retvm_if((hdrCred) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "hdrCred is NULL!!");
299         retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "session is NULL!!");
300
301         char *server_id;
302         char *server_pwd;
303         char *sourceUrl;
304         char *targetUrl;
305         int isBase64;
306         char *nextNonce;
307         char *authType;
308
309         ret = get_server_dmacc(session->pServer_id, &server_id, &server_pwd, &sourceUrl, &targetUrl, &isBase64, &nextNonce, &authType);
310         if (ret != DM_OK)
311                 goto error;
312         _DEBUG_INFO("packet server pw data : %s", hdrCred->data);
313         _DEBUG_INFO("server pw : %s", server_pwd);
314         if (hdrCred->data != NULL) {
315                 if (strcmp(hdrCred->data, server_pwd) == 0) {
316                         ret = DM_OK;
317                 } else {
318                         ret = DM_ERR_UNAUTHORIZED;
319                 }
320         } else {
321                 //do nothing
322         }
323         str_free(&server_id);
324         str_free(&server_pwd);
325         str_free(&sourceUrl);
326         str_free(&targetUrl);
327         str_free(&nextNonce);
328         str_free(&authType);
329
330         _EXTERN_FUNC_EXIT;
331         return ret;
332  error:
333         _DEBUG_INFO(" end error : %d", ret);
334         _EXTERN_FUNC_EXIT;
335         return ret;
336 }
337
338 DM_ERROR create_chal(FormatType format, AuthType type, char *nextnonce, Chal ** pChal)
339 {
340         _EXTERN_FUNC_ENTER;
341
342         retvm_if((nextnonce) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "nextnonce is NULL!!");
343         _DEBUG_INFO("start with format = %d, type = %d Nextnonce =  %s\n", format, type, nextnonce);
344
345         DM_ERROR ret = DM_OK;
346
347         *pChal = (Chal *) calloc(1, sizeof(Chal));
348         if (*pChal == NULL) {
349                 ret = COMMON_ERR_ALLOC;
350                 goto error;
351         }
352
353         (*pChal)->format = format;
354         (*pChal)->type = type;
355         if (type == AUTH_TYPE_MD5 || type == AUTH_TYPE_HMAC) {
356                 (*pChal)->nonce_plain = g_strdup(nextnonce);
357         }
358
359         _EXTERN_FUNC_EXIT;
360         return ret;
361
362  error:
363         _DEBUG_INFO(" error : %d\n", ret);
364         _EXTERN_FUNC_EXIT;
365         return ret;
366 }
367
368 void free_chal(Chal * pChal)
369 {
370         _EXTERN_FUNC_ENTER;
371         if (pChal == NULL) {
372                 _EXTERN_FUNC_EXIT;
373                 return;
374         }
375
376         pChal->format = 0;
377         pChal->type = 0;
378         pChal->nonce_length = 0;
379
380         if (pChal->nonce_plain != NULL) {
381                 free(pChal->nonce_plain);
382                 pChal->nonce_plain = NULL;
383         }
384
385         if (pChal->nonce_b64 != NULL) {
386                 free(pChal->nonce_b64);
387                 pChal->nonce_b64 = NULL;
388         }
389
390         if (pChal != NULL) {
391                 free(pChal);
392                 pChal = NULL;
393         }
394
395         _EXTERN_FUNC_EXIT;
396 }
397
398 Chal *dup_chal(Chal * pChal)
399 {
400         _EXTERN_FUNC_ENTER;
401
402         retvm_if((pChal) == NULL, NULL, "pChal is NULL!!");
403
404         Chal *temp = (Chal *) calloc(1, sizeof(Chal));
405         if (temp == NULL) {
406                 _EXTERN_FUNC_EXIT;
407                 return 0;
408         }
409
410         temp->type = pChal->type;
411         temp->format = pChal->format;
412
413         if (pChal->nonce_b64 != NULL)
414                 temp->nonce_b64 = strdup(pChal->nonce_b64);
415
416         if (pChal->nonce_length != 0)
417                 temp->nonce_length = pChal->nonce_length;
418
419         if (pChal->nonce_plain != NULL)
420                 temp->nonce_plain = strdup(pChal->nonce_plain);
421
422         _EXTERN_FUNC_EXIT;
423         return temp;
424 }
425
426 void free_hmac(Hmac * hmac)
427 {
428         _EXTERN_FUNC_ENTER;
429
430         if (hmac != NULL) {
431                 str_free(&(hmac->authtype));
432                 str_free(&(hmac->username));
433                 str_free(&(hmac->mac));
434
435                 free(hmac);
436                 hmac = NULL;
437         }
438
439         _EXTERN_FUNC_EXIT;
440 }
441
442 AuthType converttoauthtype(char *authType)
443 {
444         _EXTERN_FUNC_ENTER;
445
446         retvm_if((authType) == NULL, AUTH_TYPE_UNKNOWN, "authType is NULL!!");
447
448         if (strcmp(authType, ELEMENT_AUTH_BASIC) == 0) {
449                 _EXTERN_FUNC_EXIT;
450                 return AUTH_TYPE_BASIC;
451         } else if (strcmp(authType, ELEMENT_AUTH_MD5) == 0) {
452                 _EXTERN_FUNC_EXIT;
453                 return AUTH_TYPE_MD5;
454         } else if (strcmp(authType, ELEMENT_AUTH_HMAC) == 0) {
455                 _EXTERN_FUNC_EXIT;
456                 return AUTH_TYPE_HMAC;
457         }
458
459         _EXTERN_FUNC_EXIT;
460         return AUTH_TYPE_UNKNOWN;
461 }
462
463 FormatType converttoformattype(char *formatType)
464 {
465         _EXTERN_FUNC_ENTER;
466
467         retvm_if((formatType) == NULL, FORMAT_TYPE_UNKNOWN, "formatType is NULL!!");
468
469         if (strcmp(formatType, ELEMENT_FORMAT_BASE64) == 0) {
470                 _EXTERN_FUNC_EXIT;
471                 return FORMAT_TYPE_BASE64;
472         }
473
474         _EXTERN_FUNC_EXIT;
475         return FORMAT_TYPE_UNKNOWN;
476 }
477
478 DM_ERROR construct_Item(char *sourceUrl, const char *format, const char *contenttype, const char *data, unsigned int size, int moreData, Item ** pItem)
479 {
480         _EXTERN_FUNC_ENTER;
481
482         DM_ERROR ret = DM_OK;
483
484         retvm_if((sourceUrl) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "sourceUrl is NULL!!");
485
486         Location *pLocation = NULL;
487
488         ret = create_item_data((char *)data, size, pItem);
489         if (ret != DM_OK)
490                 goto error;
491
492         if (contenttype != NULL)
493                 (*pItem)->contenttype = g_strdup(contenttype);
494
495         if (format != NULL)
496                 (*pItem)->format = g_strdup(format);
497
498         (*pItem)->moreData = moreData;
499
500         ret = create_location(sourceUrl, NULL, &pLocation);
501         if (ret != DM_OK)
502                 goto error;
503
504         set_itemsource((*pItem), pLocation);
505
506         _EXTERN_FUNC_EXIT;
507         return ret;
508
509  error:
510         _DEBUG_INFO(" error : %d\n", ret);
511         _EXTERN_FUNC_EXIT;
512         return ret;
513 }
514
515 Item *create_Item()
516 {
517         _EXTERN_FUNC_ENTER;
518
519         DM_ERROR ret = DM_OK;
520
521         Item *item = (Item *) calloc(1, sizeof(Item));
522         if (item == NULL) {
523                 ret = COMMON_ERR_ALLOC;
524                 goto error;
525         }
526
527         item->dataType = ITEM_UNKNOWN;
528
529         _EXTERN_FUNC_EXIT;
530         return item;
531
532  error:
533         _DEBUG_INFO(" error : %d\n", ret);
534         _EXTERN_FUNC_EXIT;
535         return NULL;
536 }
537
538 DM_ERROR create_item_data(char *data, unsigned int size, Item ** pItem)
539 {
540         _EXTERN_FUNC_ENTER;
541
542         DM_ERROR ret = DM_OK;
543
544         (*pItem) = create_Item();
545         if ((*pItem) == NULL) {
546                 ret = COMMON_ERR_INTERNAL_NO_MEMORY;
547                 goto error;
548         }
549
550         if (data != NULL) {
551                 (*pItem)->private.data = strdup(data);
552         }
553
554         (*pItem)->dataType = ITEM_DATA;
555         (*pItem)->size = size;
556
557         _EXTERN_FUNC_EXIT;
558         return ret;
559  error:
560         _DEBUG_INFO(" error : %d\n", ret);
561         _EXTERN_FUNC_EXIT;
562         return ret;
563 }
564
565 void set_itemtarget(Item * item, Location * target)
566 {
567         _EXTERN_FUNC_ENTER;
568
569         retm_if((item) == NULL, "item is NULL!!");
570
571         item->target = target;
572
573         _EXTERN_FUNC_EXIT;
574 }
575
576 void set_itemsource(Item * item, Location * source)
577 {
578         _EXTERN_FUNC_ENTER;
579
580         retm_if((item) == NULL, "item is NULL!!");
581
582         item->source = source;
583
584         _EXTERN_FUNC_EXIT;
585 }
586
587 void free_Item(Item * item)
588 {
589         _EXTERN_FUNC_ENTER;
590
591         retm_if((item) == NULL, "item is NULL!!");
592
593         if (item->source != NULL) {
594                 free_location(item->source);
595                 item->source = NULL;
596         }
597
598         if (item->target != NULL) {
599                 free_location(item->target);
600                 item->target = NULL;
601         }
602
603         switch (item->dataType) {
604         case ITEM_DATA:
605                 if (item->private.data != NULL) {
606                         free(item->private.data);
607                         item->private.data = NULL;
608                 }
609                 break;
610         case ITEM_UNKNOWN:
611                 //noting to free
612                 break;
613         }
614
615         if (item->contenttype != NULL) {
616                 free(item->contenttype);
617                 item->contenttype = NULL;
618         }
619
620         if (item->format != NULL) {
621                 free(item->format);
622                 item->format = NULL;
623         }
624
625         free(item);
626         item = NULL;
627
628         _EXTERN_FUNC_EXIT;
629 }
630
631 DM_ERROR create_syncml(SyncHdr * syncHdr, GList * status, GList * commands, int isFinal, SyncML ** pSyncML)
632 {
633         _EXTERN_FUNC_ENTER;
634
635         DM_ERROR ret = DM_OK;
636
637         retvm_if((syncHdr) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "syncHdr is NULL!!");
638
639         *pSyncML = (SyncML *) calloc(1, sizeof(SyncML));
640         if (*pSyncML == NULL) {
641                 ret = COMMON_ERR_ALLOC;
642                 goto error;
643         }
644
645         (*pSyncML)->hdr = syncHdr;
646         (*pSyncML)->status = status;
647         (*pSyncML)->commands = commands;
648         (*pSyncML)->final = isFinal;
649
650         _EXTERN_FUNC_EXIT;
651         return ret;
652  error:
653         _DEBUG_INFO(" error : %d", ret);
654         _EXTERN_FUNC_EXIT;
655         return ret;
656
657 }
658
659 void free_syncml(SyncML * syncML)
660 {
661         _EXTERN_FUNC_ENTER;
662
663         retm_if((syncML) == NULL, "syncML is NULL!!");
664
665         free_synchdr(syncML->hdr);
666         syncML->hdr = NULL;
667
668         free_statuses(syncML->status);
669         syncML->status = NULL;
670
671         free_commands(syncML->commands);
672         syncML->commands = NULL;
673
674         if (syncML != NULL) {
675                 free(syncML);
676                 syncML = NULL;
677         }
678
679         _EXTERN_FUNC_EXIT;
680 }
681
682 DM_ERROR create_syncml_hdr(Session * session, SyncHdr ** pSyncHdr)
683 {
684         _EXTERN_FUNC_ENTER;
685
686         DM_ERROR ret = DM_OK;
687
688         retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
689
690         if (session->protocolVersion == VERSION_UNKNOWN) {
691                 ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
692                 goto error;
693         }
694
695         if (session->protocolType != PROTOCOL_TYPE_DM) {
696                 ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
697                 goto error;
698         }
699
700         if (session->source == NULL) {
701                 ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
702                 goto error;
703         }
704
705         if (session->target == NULL) {
706                 ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
707                 goto error;
708         }
709
710         *pSyncHdr = (SyncHdr *) calloc(1, sizeof(SyncHdr));
711
712         if (*pSyncHdr == NULL) {
713                 ret = COMMON_ERR_ALLOC;
714                 goto error;
715         }
716
717         (*pSyncHdr)->version = session->protocolVersion;
718         (*pSyncHdr)->protocol = session->protocolType;
719         (*pSyncHdr)->target = session->target;  //don't free    free in session free section
720         (*pSyncHdr)->source = session->source;  //don't free    free in session free section
721
722         if (session->cred != NULL)
723                 (*pSyncHdr)->cred = session->cred;      //don't free    free in session free section
724
725         (*pSyncHdr)->sessionID = strdup(session->sessionID);    //free
726         (*pSyncHdr)->messageID = ++session->msgID;
727
728         (*pSyncHdr)->maxmsgsize = session->sourceMaxMsgSize;
729         (*pSyncHdr)->maxobjsize = session->sourceMaxObjSize;
730
731         _EXTERN_FUNC_EXIT;
732         return ret;
733
734  error:
735         _DEBUG_INFO(" error : %d\n", ret);
736         _EXTERN_FUNC_EXIT;
737         return ret;
738 }
739
740 void free_synchdr(SyncHdr * syncHdr)
741 {
742         _EXTERN_FUNC_ENTER;
743
744         retm_if((syncHdr) == NULL, "syncHdr is NULL!!");
745
746         if (syncHdr->sessionID != NULL) {
747                 free(syncHdr->sessionID);
748                 syncHdr->sessionID = NULL;
749         }
750
751         if (syncHdr->responseURI != NULL) {
752                 free(syncHdr->responseURI);
753                 syncHdr->responseURI = NULL;
754         }
755
756         syncHdr->source = NULL;
757         syncHdr->target = NULL;
758         syncHdr->cred = NULL;
759
760         if (syncHdr != NULL) {
761                 free(syncHdr);
762                 syncHdr = NULL;
763         }
764
765         _EXTERN_FUNC_EXIT;
766 }