svace issues fixed
[platform/core/messaging/msg-service.git] / plugin / sms_plugin / SmsPluginTpduCodec.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16
17 #include <stdio.h>
18 #include <string.h>
19
20 #include "MsgDebug.h"
21 #include "MsgCppTypes.h"
22 #include "MsgException.h"
23 #include "MsgGconfWrapper.h"
24
25 #include "SmsPluginTpduCodec.h"
26 #include "SmsPluginParamCodec.h"
27 #include "SmsPluginUDCodec.h"
28
29
30 /*==================================================================================================
31                                      IMPLEMENTATION OF SmsPluginTpduCodec - Member Functions
32 ==================================================================================================*/
33 SmsPluginTpduCodec::SmsPluginTpduCodec()
34 {
35 }
36
37
38 SmsPluginTpduCodec::~SmsPluginTpduCodec()
39 {
40 }
41
42
43 int SmsPluginTpduCodec::encodeTpdu(const SMS_TPDU_S *pSmsTpdu, char *pTpdu)
44 {
45         int tpduLen = 0;
46
47         switch (pSmsTpdu->tpduType) {
48         case SMS_TPDU_SUBMIT:
49                 tpduLen = encodeSubmit(&(pSmsTpdu->data.submit), pTpdu);
50                 break;
51
52         case SMS_TPDU_DELIVER:
53                 tpduLen = encodeDeliver(&(pSmsTpdu->data.deliver), pTpdu);
54                 break;
55
56         case SMS_TPDU_DELIVER_REP:
57                 tpduLen = encodeDeliverReport(&(pSmsTpdu->data.deliverRep), pTpdu);
58                 break;
59
60         case SMS_TPDU_STATUS_REP:
61                 tpduLen = encodeStatusReport(&(pSmsTpdu->data.statusRep), pTpdu);
62                 break;
63         }
64
65         return tpduLen;
66 }
67
68
69 int SmsPluginTpduCodec::decodeTpdu(const unsigned char *pTpdu, int TpduLen, SMS_TPDU_S *pSmsTpdu)
70 {
71         int decodeLen = 0;
72
73         char mti = pTpdu[0] & 0x03;
74
75         switch (mti) {
76         case 0x00:
77                 pSmsTpdu->tpduType = SMS_TPDU_DELIVER;
78                 decodeLen = decodeDeliver(pTpdu, TpduLen, &(pSmsTpdu->data.deliver));
79                 break;
80
81         case 0x01:
82                 pSmsTpdu->tpduType = SMS_TPDU_SUBMIT;
83                 decodeLen = decodeSubmit(pTpdu, TpduLen, &(pSmsTpdu->data.submit));
84                 break;
85
86         case 0x02:
87                 pSmsTpdu->tpduType = SMS_TPDU_STATUS_REP;
88                 decodeLen = decodeStatusReport(pTpdu, TpduLen, &(pSmsTpdu->data.statusRep));
89                 break;
90         }
91
92         return decodeLen;
93 }
94
95
96 int SmsPluginTpduCodec::encodeSubmit(const SMS_SUBMIT_S *pSubmit, char *pTpdu)
97 {
98         int offset = 0, length = 0, encodeSize = 0;
99
100         char* address = NULL;
101         unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter);
102
103         char* dcs = NULL;
104         unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter);
105
106         char* vpTime = NULL;
107         unique_ptr<char*, void(*)(char**)> vpBuf(&vpTime, unique_ptr_deleter);
108
109         /* TP-MTI */
110         pTpdu[offset] = 0x01;
111
112         /* TP-RD */
113         if (pSubmit->bRejectDup == true)
114                 pTpdu[offset] |= 0x04;
115
116         /* TP-VPF */
117         switch (pSubmit->vpf) {
118         case SMS_VPF_NOT_PRESENT:
119                 break;
120         case SMS_VPF_ENHANCED:
121                 pTpdu[offset] |= 0x08;
122                 break;
123         case SMS_VPF_RELATIVE:
124                 pTpdu[offset] |= 0x10;
125                 break;
126         case SMS_VPF_ABSOLUTE:
127                 pTpdu[offset] |= 0x18;
128                 break;
129         default:
130                 break;
131         }
132
133         /* TP-SRR */
134         if (pSubmit->bStatusReport == true)
135                 pTpdu[offset] |= 0x20;
136
137         MSG_DEBUG("TP-SRR pSubmit->bStatusReport : %d.", pSubmit->bStatusReport);
138
139         /* TP-UDHI */
140         if (pSubmit->bHeaderInd == true)
141                 pTpdu[offset] |= 0x40;
142
143         /* TP-RP */
144         if (pSubmit->bReplyPath == true)
145                 pTpdu[offset] |= 0x80;
146
147         offset++;
148
149         /* TP-MR */
150         pTpdu[offset++] = pSubmit->msgRef;
151
152         MSG_DEBUG("TP-MR pSubmit->msgRef : %d.", pSubmit->msgRef);
153
154         /* TP-DA */
155         length = SmsPluginParamCodec::encodeAddress(&pSubmit->destAddress, &address);
156         memcpy(&(pTpdu[offset]), address, length);
157         offset += length;
158
159         MSG_DEBUG("TP-DA length : %d.", length);
160
161         /* TP-PID */
162         pTpdu[offset++] = pSubmit->pid;
163
164         MSG_DEBUG("TP-PID pSubmit->pid : %d.", pSubmit->pid);
165
166         /* TP-DCS */
167         length = SmsPluginParamCodec::encodeDCS(&pSubmit->dcs, &dcs);
168         memcpy(&(pTpdu[offset]), dcs, length);
169         offset += length;
170
171         MSG_DEBUG("TP-DCS length : %d.", length);
172
173         /* TP-VP */
174         if (pSubmit->vpf != SMS_VPF_NOT_PRESENT) {
175                 length = SmsPluginParamCodec::encodeTime(&pSubmit->validityPeriod, &vpTime);
176
177                 if (length > 0) {
178                         memcpy(&(pTpdu[offset]), vpTime, length);
179                         offset += length;
180                 }
181         }
182
183         encodeSize = SmsPluginUDCodec::encodeUserData(&(pSubmit->userData), pSubmit->dcs.codingScheme, &(pTpdu[offset]));
184
185         MSG_DEBUG("encodeSize : %d", encodeSize);
186
187         offset += encodeSize;
188
189 #if 0
190         printf("\n\n[encodeSubmit] pTpdu data.\n");
191         for (int i = 0; i < offset; i++) {
192                 printf(" [%02x]", pTpdu[i]);
193         }
194         printf("\n\n");
195 #endif
196
197         return offset;
198 }
199
200
201 int SmsPluginTpduCodec::encodeDeliver(const SMS_DELIVER_S *pDeliver, char *pTpdu)
202 {
203         int offset = 0, length = 0, encodeSize = 0;
204
205         char* address = NULL;
206         unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter);
207
208         char* dcs = NULL;
209         unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter);
210
211         char* scts = NULL;
212         unique_ptr<char*, void(*)(char**)> timeBuf(&scts, unique_ptr_deleter);
213
214         /* TP-MTI : 00 */
215         pTpdu[offset] = 0x00;
216
217         /* TP-MMS */
218         if (pDeliver->bMoreMsg == false)
219                 pTpdu[offset] |= 0x04;
220
221         /* TP-SRI */
222         if (pDeliver->bStatusReport == true)
223                 pTpdu[offset] |= 0x20;
224
225         /* TP-UDHI */
226         if (pDeliver->bHeaderInd == true)
227                 pTpdu[offset] |= 0x40;
228
229         /* TP-RP */
230         if (pDeliver->bReplyPath == true)
231                 pTpdu[offset] |= 0x80;
232
233         offset++;
234
235         /* TP-OA */
236         length = SmsPluginParamCodec::encodeAddress(&pDeliver->originAddress, &address);
237         memcpy(&(pTpdu[offset]), address, length);
238         offset += length;
239
240         /* TP-PID */
241         pTpdu[offset++] = pDeliver->pid;
242
243         /* TP-DCS */
244         length = SmsPluginParamCodec::encodeDCS(&pDeliver->dcs, &dcs);
245         memcpy(&(pTpdu[offset]), dcs, length);
246         offset += length;
247
248         /* TP-SCTS */
249         length = SmsPluginParamCodec::encodeTime(&pDeliver->timeStamp, &scts);
250         memcpy(&(pTpdu[offset]), scts, length);
251         offset += length;
252
253         /* TP-UDL & TP-UD */
254         encodeSize = SmsPluginUDCodec::encodeUserData(&(pDeliver->userData), pDeliver->dcs.codingScheme, &(pTpdu[offset]));
255
256         MSG_DEBUG("encodeSize : %d", encodeSize);
257
258         offset += encodeSize;
259
260         return offset;
261 }
262
263
264 int SmsPluginTpduCodec::encodeDeliverReport(const SMS_DELIVER_REPORT_S *pDeliverRep, char *pTpdu)
265 {
266         int offset = 0;
267
268         /* TP-MTI : 00 */
269         pTpdu[offset] = 0x00;
270
271         /* TP-UDHI */
272         if (pDeliverRep->bHeaderInd == true)
273                 pTpdu[offset] |= 0x40;
274
275         offset++;
276
277         /* TP-FCS */
278         if (pDeliverRep->reportType == SMS_REPORT_NEGATIVE) {
279                 pTpdu[offset++] = pDeliverRep->failCause;
280                 MSG_DEBUG("Delivery report : fail cause = [%02x]", pDeliverRep->failCause);
281         }
282
283         /* TP-PI */
284         pTpdu[offset++] = pDeliverRep->paramInd;
285
286         /* TP-PID */
287         if (pDeliverRep->paramInd & 0x01)
288                 pTpdu[offset++] = pDeliverRep->pid;
289
290         /* TP-DCS */
291         if (pDeliverRep->paramInd & 0x02) {
292                 int length = 0;
293
294                 char* dcs = NULL;
295                 unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter);
296
297                 length = SmsPluginParamCodec::encodeDCS(&pDeliverRep->dcs, &dcs);
298                 memcpy(&(pTpdu[offset]), dcs, length);
299
300                 offset += length;
301         }
302
303         /* TP-UDL & TP-UD */
304         if (pDeliverRep->paramInd & 0x04) {
305                 int encodeSize = 0;
306
307                 encodeSize = SmsPluginUDCodec::encodeUserData(&(pDeliverRep->userData), pDeliverRep->dcs.codingScheme, &(pTpdu[offset]));
308
309                 MSG_DEBUG("encodeSize : %d", encodeSize);
310
311                 offset += encodeSize;
312         }
313
314         pTpdu[offset] = '\0';
315
316         return offset;
317 }
318
319
320 int SmsPluginTpduCodec::encodeStatusReport(const SMS_STATUS_REPORT_S *pStatusRep, char *pTpdu)
321 {
322         int offset = 0, length = 0;
323
324         char* address = NULL;
325         unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter);
326
327         char* scts = NULL;
328         unique_ptr<char*, void(*)(char**)> sctsBuf(&scts, unique_ptr_deleter);
329
330         char* dt = NULL;
331         unique_ptr<char*, void(*)(char**)> dtBuf(&dt, unique_ptr_deleter);
332
333         /* TP-MTI : 10 */
334         pTpdu[offset] = 0x02;
335
336         /* TP-MMS */
337         if (pStatusRep->bMoreMsg == true)
338                 pTpdu[offset] |= 0x04;
339
340         /* TP-SRQ */
341         if (pStatusRep->bStatusReport == true)
342                 pTpdu[offset] |= 0x20;
343
344         /* TP-UDHI */
345         if (pStatusRep->bHeaderInd == true)
346                 pTpdu[offset] |= 0x40;
347
348         offset++;
349
350         /* TP-MR */
351         pTpdu[offset++] = pStatusRep->msgRef;
352
353         /* TP-RA */
354         length = SmsPluginParamCodec::encodeAddress(&pStatusRep->recipAddress, &address);
355         memcpy(&(pTpdu[offset]), address, length);
356         offset += length;
357
358         /* TP-SCTS */
359         length = SmsPluginParamCodec::encodeTime(&pStatusRep->timeStamp, &scts);
360         memcpy(&(pTpdu[offset]), scts, length);
361         offset += length;
362
363         /* TP-DT */
364         length = SmsPluginParamCodec::encodeTime(&pStatusRep->dischargeTime, &dt);
365         memcpy(&(pTpdu[offset]), dt, length);
366         offset += length;
367
368         /* TP-Status */
369         pTpdu[offset++] = pStatusRep->status;
370
371         /* TP-PI */
372         pTpdu[offset++] = pStatusRep->paramInd;
373
374         /* TP-PID */
375         if (pStatusRep->paramInd & 0x01)
376                 pTpdu[offset++] = pStatusRep->pid;
377
378         /* TP-DCS */
379         if (pStatusRep->paramInd & 0x02) {
380                 int length = 0;
381
382                 char* dcs = NULL;
383                 unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter);
384
385                 length = SmsPluginParamCodec::encodeDCS(&pStatusRep->dcs, &dcs);
386                 memcpy(&(pTpdu[offset]), dcs, length);
387
388                 offset += length;
389         }
390
391         /* TP-UDL & TP-UD */
392         if (pStatusRep->paramInd & 0x04) {
393                 int encodeSize = 0;
394
395                 encodeSize = SmsPluginUDCodec::encodeUserData(&(pStatusRep->userData), pStatusRep->dcs.codingScheme, &(pTpdu[offset]));
396
397                 MSG_DEBUG("encodeSize : %d", encodeSize);
398
399                 offset += encodeSize;
400         }
401
402         pTpdu[offset] = '\0';
403
404         return offset;
405 }
406
407
408 int SmsPluginTpduCodec::decodeSubmit(const unsigned char *pTpdu, int TpduLen, SMS_SUBMIT_S *pSubmit)
409 {
410         int offset = 0, udLen = 0;
411
412         char tpduTmp[(TpduLen*2)+1];
413         memset(tpduTmp, 0x00, sizeof(tpduTmp));
414         for (int i = 0; i < TpduLen; i++) {
415                 snprintf(tpduTmp+(i*2), sizeof(tpduTmp)-(i*2), "%02X", pTpdu[i]);
416         }
417         MSG_DEBUG("Sumbit TPDU.");
418         MSG_INFO("[%s]", tpduTmp);
419
420         /* TP-RD */
421         if (pTpdu[offset] & 0x04)
422                 pSubmit->bRejectDup = false;
423         else
424                 pSubmit->bRejectDup = true;
425
426         /* TP-VPF */
427         pSubmit->vpf = (SMS_VPF_T)(pTpdu[offset] & 0x18);
428
429         /* TP-SRR */
430         if (pTpdu[offset] & 0x20)
431                 pSubmit->bStatusReport = true;
432         else
433                 pSubmit->bStatusReport = false;
434
435         /* TP-UDHI */
436         if (pTpdu[offset] & 0x40)
437                 pSubmit->bHeaderInd = true;
438         else
439                 pSubmit->bHeaderInd = false;
440
441         /* TP-RP */
442         if (pTpdu[offset] & 0x80)
443                 pSubmit->bReplyPath = true;
444         else
445                 pSubmit->bReplyPath = false;
446
447         offset++;
448
449         /* TP-MR */
450         pSubmit->msgRef = pTpdu[offset++];
451
452         /* TP-DA */
453         offset += SmsPluginParamCodec::decodeAddress(pTpdu+offset, &(pSubmit->destAddress));
454
455         /* TP-PID */
456         pSubmit->pid = pTpdu[offset++];
457
458         /* TP-DCS */
459         offset += SmsPluginParamCodec::decodeDCS(pTpdu+offset, &(pSubmit->dcs));
460
461         /* TP-VP */
462         if (pSubmit->vpf != SMS_VPF_NOT_PRESENT) {
463                 /* Decode VP */
464         }
465
466         /* TP-UDL & TP-UD */
467         udLen = SmsPluginUDCodec::decodeUserData(pTpdu+offset, TpduLen, pSubmit->bHeaderInd, pSubmit->dcs.codingScheme, &(pSubmit->userData));
468
469         return udLen;
470 }
471
472
473 int SmsPluginTpduCodec::decodeDeliver(const unsigned char *pTpdu, int TpduLen, SMS_DELIVER_S *pDeliver)
474 {
475         int offset = 0, udLen = 0, tmpOffset = 0;
476
477
478         char tpduTmp[(TpduLen*2)+1];
479         memset(tpduTmp, 0x00, sizeof(tpduTmp));
480         for (int i = 0; i < TpduLen; i++) {
481                 snprintf(tpduTmp+(i*2), sizeof(tpduTmp)-(i*2), "%02X", pTpdu[i]);
482         }
483         MSG_DEBUG("Deliver TPDU.");
484         MSG_INFO("[%s]", tpduTmp);
485
486
487         /* TP-MMS */
488         if (pTpdu[offset] & 0x04)
489                 pDeliver->bMoreMsg = false;
490         else
491                 pDeliver->bMoreMsg = true;
492
493         /* TP-SRI */
494         if (pTpdu[offset] & 0x20)
495                 pDeliver->bStatusReport = true;
496         else
497                 pDeliver->bStatusReport = false;
498
499         /* TP-UDHI */
500         if (pTpdu[offset] & 0x40)
501                 pDeliver->bHeaderInd = true;
502         else
503                 pDeliver->bHeaderInd = false;
504
505         /* TP-RP */
506         if (pTpdu[offset] & 0x80)
507                 pDeliver->bReplyPath = true;
508         else
509                 pDeliver->bReplyPath = false;
510
511         offset++;
512
513         tmpOffset = offset;
514 #if 1
515         /* TP-OA */
516         offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pDeliver->originAddress));
517
518         /* TP-PID */
519         pDeliver->pid = pTpdu[offset++];
520
521         /* TP-DCS */
522         offset += SmsPluginParamCodec::decodeDCS(&pTpdu[offset], &(pDeliver->dcs));
523
524         /* Support KSC5601 :: Coding group bits == 0x84 */
525         if (pTpdu[offset-1] == 0x84) {
526                 pDeliver->dcs.codingScheme = SMS_CHARSET_EUCKR;
527         }
528
529 #else
530         /* For alphanumeric address test */
531
532         offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pDeliver->originAddress));
533
534         char* address = new char[15];
535         address[0] = 0x04;
536         address[1] = 0xd0;
537         address[2] = 0x11;
538         address[3] = 0x00;
539         address[4] = 0x20;
540         address[5] = 0xF2;
541         address[6] = 0x01;
542         address[7] = 0x01;
543         address[8] = 0x11;
544         address[9] = 0x61;
545         address[10] = 0x40;
546         address[11] = 0x82;
547         address[12] = 0x2b;
548         address[13] = 0x01;
549         address[14] = 0x20;
550
551         SmsPluginParamCodec::decodeAddress((unsigned char*)address, &(pDeliver->originAddress));
552
553         pDeliver->pid = 0x20;
554         offset++;
555         offset += SmsPluginParamCodec::decodeDCS((unsigned char*)address, &(pDeliver->dcs));
556         /* end test */
557 #endif
558
559         if (pDeliver->pid == 0x20 && pDeliver->originAddress.ton == SMS_TON_ALPHANUMERIC) {
560                 int setType = -1;
561                 int indType = -1;
562
563                 bool bVmi = SmsPluginParamCodec::checkCphsVmiMsg(&pTpdu[tmpOffset], &setType, &indType);
564
565                 MSG_DEBUG("bVmi = [%d], setType=[%d], indType=[%d]", bVmi, setType, indType);
566
567                 if (bVmi) {
568                         pDeliver->dcs.bMWI = true;
569
570                         if (setType == 0) {
571                                 pDeliver->dcs.bIndActive = false;
572                         } else {
573                                 pDeliver->dcs.bIndActive = true;
574                         }
575
576                         if (indType == 0)
577                                 pDeliver->dcs.indType = SMS_VOICE_INDICATOR;
578                         else if (indType == 1)
579                                 pDeliver->dcs.indType = SMS_VOICE2_INDICATOR;
580                 }
581         }
582
583         /* TP-SCTS */
584         offset += SmsPluginParamCodec::decodeTime(&pTpdu[offset], &(pDeliver->timeStamp));
585
586         /* TP-UD */
587         udLen = SmsPluginUDCodec::decodeUserData(&pTpdu[offset], TpduLen, pDeliver->bHeaderInd, pDeliver->dcs.codingScheme, &(pDeliver->userData), &(pDeliver->udData));
588
589         return udLen;
590 }
591
592
593 int SmsPluginTpduCodec::decodeStatusReport(const unsigned char *pTpdu, int TpduLen, SMS_STATUS_REPORT_S *pStatusRep)
594 {
595 #ifdef LOG_ENABLE
596         printf("\n\n[decodeStatusReport] pTpdu data - Length [%d]\n", TpduLen);
597
598         for (int i = 0; i < TpduLen; i++) {
599                 printf(" [%02x]", pTpdu[i]);
600         }
601         printf("\n\n");
602 #endif
603
604         int offset = 0, udLen = 0;
605
606         char* address = NULL;
607         unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter);
608
609         char* scts = NULL;
610         unique_ptr<char*, void(*)(char**)> sctsBuf(&scts, unique_ptr_deleter);
611
612         char* dt = NULL;
613         unique_ptr<char*, void(*)(char**)> dtBuf(&dt, unique_ptr_deleter);
614
615         /* TP-MMS */
616         if (pTpdu[offset] & 0x04)
617                 pStatusRep->bMoreMsg = false;
618         else
619                 pStatusRep->bMoreMsg = true;
620
621         /* TP-SRQ */
622         if (pTpdu[offset] & 0x20)
623                 pStatusRep->bStatusReport = true;
624         else
625                 pStatusRep->bStatusReport = false;
626
627         /* TP-UDHI */
628         if (pTpdu[offset] & 0x40)
629                 pStatusRep->bHeaderInd = true;
630         else
631                 pStatusRep->bHeaderInd = false;
632
633         offset++;
634
635         /* TP-MR */
636         pStatusRep->msgRef = pTpdu[offset++];
637
638         /* TP-RA */
639         offset += SmsPluginParamCodec::decodeAddress(&pTpdu[offset], &(pStatusRep->recipAddress));
640
641         /* TP-SCTS */
642         /* Decode timestamp */
643         offset += SmsPluginParamCodec::decodeTime(&pTpdu[offset], &(pStatusRep->timeStamp));
644
645         /* TP-DT */
646         /* Decode timestamp */
647         offset += SmsPluginParamCodec::decodeTime(&pTpdu[offset], &(pStatusRep->dischargeTime));
648
649         /* TP-Status */
650         pStatusRep->status = pTpdu[offset++];
651
652         /* TP-PI */
653         pStatusRep->paramInd = pTpdu[offset++];
654
655         /* No Parameters */
656         if (pStatusRep->paramInd == 0) {
657                 pStatusRep->pid = SMS_PID_NORMAL;
658
659                 pStatusRep->dcs.bCompressed = false;
660                 pStatusRep->dcs.bMWI = false;
661                 pStatusRep->dcs.bIndActive = false;
662
663                 pStatusRep->dcs.msgClass = MSG_CLASS_NONE;
664                 pStatusRep->dcs.codingScheme = SMS_CHARSET_7BIT;
665                 pStatusRep->dcs.codingGroup = SMS_GROUP_GENERAL;
666                 pStatusRep->dcs.indType = SMS_OTHER_INDICATOR;
667
668                 pStatusRep->userData.headerCnt = 0;
669                 pStatusRep->userData.length = 0;
670                 memset(pStatusRep->userData.data, 0x00, MAX_USER_DATA_LEN+1);
671         }
672
673         /* TP-PID */
674         if (pStatusRep->paramInd & 0x01)
675                 pStatusRep->pid = pTpdu[offset++];
676
677         /* TP-DCS */
678         if (pStatusRep->paramInd & 0x02)
679                 offset += SmsPluginParamCodec::decodeDCS(&pTpdu[offset], &(pStatusRep->dcs));
680
681         /* TP-UDL & TP-UD */
682         if (pStatusRep->paramInd & 0x04)
683                 /* Decode User Data */
684                 udLen = SmsPluginUDCodec::decodeUserData(&pTpdu[offset], TpduLen, pStatusRep->bHeaderInd, pStatusRep->dcs.codingScheme, &(pStatusRep->userData));
685
686         return udLen;
687 }