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