comparison gsm-fw/g23m-aci/aci/cmh_smsf.c @ 775:eedbf248bac0

gsm-fw/g23m-aci subtree: initial import from LoCosto source
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 12 Oct 2014 01:45:14 +0000
parents
children 9b2ed89a1adc
comparison
equal deleted inserted replaced
774:40a721fd9854 775:eedbf248bac0
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_SMSF
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This module defines the functions used by the command
18 | handler for the short message service.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef CMH_SMSF_C
23 #define CMH_SMSF_C
24 #endif
25
26 #include "aci_all.h"
27 /*==== INCLUDES ===================================================*/
28 #include "aci_cmh.h"
29 #include "ati_cmd.h"
30 #include "aci_cmd.h"
31
32 #ifdef FAX_AND_DATA
33 #include "aci_fd.h"
34 #endif /* of #ifdef FAX_AND_DATA */
35
36 #include "aci.h"
37 #include "aci_lst.h"
38 #include "aci_mem.h"
39 #include "psa.h"
40 #include "psa_cc.h"
41 #ifdef SIM_TOOLKIT
42 #include "psa_sat.h"
43 #endif
44 #include "psa_sms.h"
45 #include "psa_sim.h"
46 #include "psa_mmi.h"
47 #include "psa_util.h"
48 #include "phb.h"
49 #include "cmh.h"
50 #include "cmh_sms.h"
51 #include "pcm.h"
52
53 #include "aci_lst.h"
54
55 #if (defined (MFW) AND !defined (FF_MMI_RIV)) OR defined (_CONC_TESTING_)
56 #include "conc_sms.h"
57 #endif /* ##if (defined (MFW) AND !defined (FF_MMI_RIV)) OR defined (_CONC_TESTING_)*/
58
59
60 #ifdef UART
61 #include "dti_conn_mng.h"
62 #endif
63
64 #include "cmh_sim.h"
65 #ifndef _SIMULATION_
66
67 /* temporary solution to get ffs.h included without GPRS to be set ! */
68 #ifdef GPRS
69 #include "ffs/ffs.h"
70 #else
71 #include "ffs/ffs.h"
72 #undef GPRS
73 #endif /* GPRS */
74
75 #include "ffs_coat.h"
76
77 #endif /* !_SIMULATION_ */
78
79 #ifdef FF_CPHS
80 #include "cphs.h"
81 #endif /* FF_CPHS */
82
83 /*==== CONSTANTS ==================================================*/
84 #define CMMS_MODE_TIMER_VAL (5000)
85 #define SMS_CMH_YEAR_MAX (99) /* maximum value for year in */
86 /* absolute validity period */
87 #define SMS_CMH_YEAR_MIN (0) /* minimum value for year in */
88 /* absolute validity period */
89 #define SMS_CMH_MONTH_MAX (12) /* maximum value for month in */
90 /* absolute validity period */
91 #define SMS_CMH_MONTH_MIN (1) /* minimum value for month in */
92 /* absolute validity period */
93 #define SMS_CMH_DAY_MAX (31) /* maximum value for day in */
94 /* absolute validity period */
95 #define SMS_CMH_DAY_MIN (1) /* minimum value for day in */
96 /* absolute validity period */
97 #define SMS_CMH_HOUR_MAX (23) /* maximum value for hour in */
98 /* absolute validity period */
99 #define SMS_CMH_HOUR_MIN (0) /* minimum value for hour in */
100 /* absolute validity period */
101 #define SMS_CMH_MINUTE_MAX (59) /* maximum value for minute in */
102 /* absolute validity period */
103 #define SMS_CMH_MINUTE_MIN (0) /* minimum value for minute in */
104 /* absolute validity period */
105 #define SMS_CMH_SECOND_MAX (59) /* maximum value for second in */
106 /* absolute validity period */
107 #define SMS_CMH_SECOND_MIN (0) /* minimum value for second in */
108 /* absolute validity period */
109
110 #define SMS_CMH_TZ_MAX (47) /* maximum value for a time */
111 /* zone in absolute validity */
112 /* period */
113 #define SMS_CMH_TZ_MIN (-47) /* minimum value for a time */
114 /* zone in absolute validity */
115 /* period */
116
117
118 /* macro for converting a two digit BCD into an UBYTE */
119 #define BCD2UBYTE(bcd) (UBYTE)(10 * bcd[0] + bcd[1])
120
121 /* macro for testing whether any digit of a two digit */
122 /* BCD lies outside of a predefined value range */
123 #define NOTBCD(bcd) (bcd[0] > 9 OR\
124 bcd[1] > 9 )
125
126
127 #define L_MAX_UD 140
128 #define L_MAX_UD_CONC 134
129
130 #ifdef FF_CPHS_REL4
131 typedef enum
132 {
133 MSG_WAITING_TYPE_INVALID = -1,
134 MSG_WAITING_TYPE_VOICE,
135 MSG_WAITING_TYPE_FAX,
136 MSG_WAITING_TYPE_EMAIL,
137 MSG_WAITING_TYPE_OTHER
138 } T_MSG_WAITING_TYPE;
139 #endif
140
141 /*==== TYPES ======================================================*/
142
143 /*==== EXPORT =====================================================*/
144 EXTERN T_ACI_LIST *set_prm_list;
145
146 /*==== PROTOTYPES==================================================*/
147 /* Implements Measure # 73 */
148 LOCAL BOOL cmhSMS_findMessageIds (USHORT lower_mid, USHORT upper_mid);
149 /* Implements Measure # 126 */
150 LOCAL void cmhSMS_processOrigDestAddr (T_ACI_CMGL_SM *sm,
151 T_rp_addr *rp_addr,
152 T_tp_da *tp_addr );
153 /* Implements Measure # 9 */
154 LOCAL void cmhSMS_clearCbmPrm (void);
155
156
157 /*==== VARIABLES ==================================================*/
158
159 const char * const ffs_smsprfl_fname[] = { FFS_SMSPRFL_FNAME01,
160 FFS_SMSPRFL_FNAME02,
161 FFS_SMSPRFL_FNAME03,
162 FFS_SMSPRFL_FNAME04 };
163
164 /*==== FUNCTIONS ==================================================*/
165
166 /*
167 +--------------------------------------------------------------------+
168 | PROJECT : GSM-F&D (8411) MODULE : ACI_CMD |
169 | STATE : code ROUTINE : aci_encodeVpenh |
170 +--------------------------------------------------------------------+
171
172 PURPOSE : This function encodes a given T_ACI_VP_ENH type to a
173 string.
174 */
175 GLOBAL void aci_encodeVpenh ( CHAR* vpenh_str,
176 T_ACI_VP_ENH* vpenh )
177 {
178 UBYTE pos;
179
180 /* functionality indicator */
181 utl_binToHex (&vpenh->func_ind, 1, vpenh_str);
182 pos = 2;
183
184 /* extension octet */
185 if (vpenh->func_ind & TP_VPF_ENH_EXT_BIT_MASK)
186 {
187 utl_binToHex (&vpenh->ext_oct, 1, vpenh_str+pos);
188 pos += 2;
189 }
190
191 /* process validity period values */
192 if ((vpenh->func_ind & TP_VPF_ENH_FORMAT_MASK) EQ TP_VPF_ENH_REL)
193 {
194 utl_binToHex (&vpenh->val.vpenh_relative, 1, vpenh_str+pos );
195 pos += 2;
196 }
197 else if ((vpenh->func_ind & TP_VPF_ENH_FORMAT_MASK) EQ TP_VPF_ENH_SEC)
198 {
199 utl_binToHex (&vpenh->val.vpenh_seconds, 1, vpenh_str+pos );
200 pos += 2;
201 }
202 else if ((vpenh->func_ind & TP_VPF_ENH_FORMAT_MASK) EQ TP_VPF_ENH_HRS)
203 {
204 vpenh_str[pos++] = vpenh->val.vpenh_hours.hour[1] + '0';
205 vpenh_str[pos++] = vpenh->val.vpenh_hours.hour[0] + '0';
206
207 vpenh_str[pos++] = vpenh->val.vpenh_hours.minute[1] + '0';
208 vpenh_str[pos++] = vpenh->val.vpenh_hours.minute[0] + '0';
209
210 vpenh_str[pos++] = vpenh->val.vpenh_hours.second[1] + '0';
211 vpenh_str[pos++] = vpenh->val.vpenh_hours.second[0] + '0';
212 }
213
214 /* fill the rest with zeros */
215 while (pos < 14)
216 {
217 vpenh_str[pos++] = '0';
218 }
219
220 /* string terminator */
221 vpenh_str[pos] = '\0';
222 }
223
224 /*
225 +-------------------------------------------------------------------+
226 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
227 | STATE : code ROUTINE : cmhSMS_getNType |
228 +-------------------------------------------------------------------+
229
230 PURPOSE : This function calculates the 'numbering type' out of the
231 current 'type of numbering'.
232 */
233 GLOBAL UBYTE cmhSMS_getNType ( T_ACI_TOA_TON ton )
234 {
235 switch( ton )
236 {
237 case( TON_International ):
238 case( TON_National ):
239 case( TON_NetSpecific ):
240 case( TON_DedAccess ):
241 case( TON_Alphanumeric ):
242 case( TON_Abbreviated ): return (UBYTE)ton;
243 default: return SMS_TON_UNKNOWN;
244 }
245 }
246
247
248 GLOBAL BOOL cmhSMS_findPrflId ( UBYTE critrerium, void* elem )
249 {
250 T_SMS_SET_PRM *compared = (T_SMS_SET_PRM*)elem;
251 if ( compared->prflId == critrerium )
252 return TRUE;
253 else
254 return FALSE;
255 }
256
257 /*
258 +-------------------------------------------------------------------+
259 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
260 | STATE : code ROUTINE : cmhSMS_getTon |
261 +-------------------------------------------------------------------+
262
263 PURPOSE : This function calculates the 'type of numbering' out of
264 the current 'numbering type'.
265 */
266 GLOBAL T_ACI_TOA_TON cmhSMS_getTon ( UBYTE ntype )
267 {
268 switch( ntype )
269 {
270 case( SMS_TON_UNKNOWN ):
271 case( SMS_TON_INTERNATIONAL ):
272 case( SMS_TON_NATIONAL ):
273 case( SMS_TON_NETWORK_SPEC ):
274 case( SMS_TON_SUBSCRIBER ):
275 case( SMS_TON_ALPHANUMERIC ):
276 case( SMS_TON_ABBREVIATED ): return (T_ACI_TOA_TON)ntype;
277 default: return TON_NotPresent;
278 }
279 }
280
281 /*
282 +-------------------------------------------------------------------+
283 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
284 | STATE : code ROUTINE : cmhSMS_getNPlan |
285 +-------------------------------------------------------------------+
286
287 PURPOSE : This function calculates the 'numbering plan' out of the
288 current 'numbering plan identification'.
289 */
290 GLOBAL UBYTE cmhSMS_getNPlan ( T_ACI_TOA_NPI npi )
291 {
292 switch( npi )
293 {
294 case( NPI_IsdnTelephony ):
295 case( NPI_Data ):
296 case( NPI_Telex ):
297 case( NPI_National ):
298 case( NPI_Private ): return (UBYTE)npi;
299 default: return NPI_Unknown;
300 }
301 }
302
303 /*
304 +-------------------------------------------------------------------+
305 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
306 | STATE : code ROUTINE : cmhSMS_getNpi |
307 +-------------------------------------------------------------------+
308
309 PURPOSE : This function calculates the 'numbering plan
310 identification' out of the current 'numbering plan'.
311 */
312 GLOBAL T_ACI_TOA_NPI cmhSMS_getNpi ( UBYTE nplan )
313 {
314 switch( nplan )
315 {
316 case( SMS_TON_UNKNOWN ):
317 case( SMS_NPI_ISDN ):
318 case( SMS_NPI_X121 ):
319 case( SMS_NPI_F69 ):
320 case( SMS_NPI_NATIONAL ):
321 case( SMS_NPI_PRIVATE ): return (T_ACI_TOA_NPI)nplan;
322 default: return NPI_NotPresent;
323 }
324 }
325
326 /*
327 +-------------------------------------------------------------------+
328 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
329 | STATE : code ROUTINE : cmhSMS_getStatCmh |
330 +-------------------------------------------------------------------+
331
332 PURPOSE : This function converts the message status from
333 PSA type to CMH type.
334 */
335 GLOBAL void cmhSMS_getStatCmh ( UBYTE inStat,
336 T_ACI_SMS_STAT* outStat )
337 {
338 switch( inStat & STAT_MASK )
339 {
340 case( REC_UNREAD ): *outStat = SMS_STAT_RecUnread; break;
341 case( REC_READ ): *outStat = SMS_STAT_RecRead; break;
342 case( STO_UNSENT ): *outStat = SMS_STAT_StoUnsent; break;
343 case( STO_SENT ): *outStat = SMS_STAT_StoSent; break;
344 default: *outStat = SMS_STAT_NotPresent;
345 }
346 }
347
348 /*
349 +-------------------------------------------------------------------+
350 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
351 | STATE : code ROUTINE : cmhSMS_getStatPsa |
352 +-------------------------------------------------------------------+
353
354 PURPOSE : This function converts the message status from
355 CMH type to PSA type.
356 */
357 GLOBAL BOOL cmhSMS_getStatPsa ( T_ACI_SMS_STAT inStat,
358 UBYTE* outStat )
359 {
360 switch( inStat )
361 {
362 case( SMS_STAT_RecUnread ): *outStat = REC_UNREAD; break;
363 case( SMS_STAT_RecRead ): *outStat = REC_READ; break;
364 case( SMS_STAT_StoUnsent ): *outStat = STO_UNSENT; break;
365 case( SMS_STAT_StoSent ): *outStat = STO_SENT; break;
366 default : return (FALSE);
367 }
368
369 return ( TRUE );
370 }
371
372 /*
373 +-------------------------------------------------------------------+
374 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
375 | STATE : code ROUTINE : cmhSMS_isVpabsVld |
376 +-------------------------------------------------------------------+
377
378 PURPOSE : This function is used to process whether the given
379 absolute validity period is valid.
380
381 Note: This function checks whether every individual
382 time value is within a valid range. It does not
383 check whether the whole expression is valid.
384 */
385 GLOBAL BOOL cmhSMS_isVpabsVld ( T_ACI_VP_ABS* vpabs )
386 {
387 if ( BCD2UBYTE ( vpabs -> year ) > SMS_CMH_YEAR_MAX OR
388 BCD2UBYTE ( vpabs -> month ) < SMS_CMH_MONTH_MIN OR
389 BCD2UBYTE ( vpabs -> month ) > SMS_CMH_MONTH_MAX OR
390 BCD2UBYTE ( vpabs -> day ) < SMS_CMH_DAY_MIN OR
391 BCD2UBYTE ( vpabs -> day ) > SMS_CMH_DAY_MAX OR
392 BCD2UBYTE ( vpabs -> hour ) > SMS_CMH_HOUR_MAX OR
393 BCD2UBYTE ( vpabs -> minute ) > SMS_CMH_MINUTE_MAX OR
394 BCD2UBYTE ( vpabs -> second ) > SMS_CMH_SECOND_MAX OR
395 vpabs -> timezone < SMS_CMH_TZ_MIN OR
396 vpabs -> timezone > SMS_CMH_TZ_MAX OR
397 NOTBCD ( vpabs -> year ) OR
398 NOTBCD ( vpabs -> month ) OR
399 NOTBCD ( vpabs -> day ) OR
400 NOTBCD ( vpabs -> hour ) OR
401 NOTBCD ( vpabs -> minute ) OR
402 NOTBCD ( vpabs -> second ) )
403
404 return ( FALSE );
405
406 return ( TRUE );
407 }
408
409 /*
410 +-------------------------------------------------------------------+
411 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
412 | STATE : code ROUTINE : cmhSMS_isVpenhVld |
413 +-------------------------------------------------------------------+
414
415 PURPOSE : This function is used to process whether the given
416 enhanced validity period is valid.
417
418 Note: This function checks whether every individual
419 time value is within a valid range. It does not
420 check whether the whole expression is valid.
421 */
422 GLOBAL BOOL cmhSMS_isVpenhVld ( T_ACI_VP_ENH* vpenh )
423 {
424 if ((vpenh->func_ind & TP_VPF_ENH_FORMAT_MASK) > TP_VPF_ENH_HRS)
425 {
426 return FALSE;
427 }
428
429 if ((vpenh->func_ind & TP_VPF_ENH_FORMAT_MASK) EQ TP_VPF_ENH_HRS)
430 {
431 if ( BCD2UBYTE ( vpenh->val.vpenh_hours.minute ) > SMS_CMH_MINUTE_MAX OR
432 BCD2UBYTE ( vpenh->val.vpenh_hours.second ) > SMS_CMH_SECOND_MAX OR
433 NOTBCD ( vpenh->val.vpenh_hours.hour ) OR
434 NOTBCD ( vpenh->val.vpenh_hours.minute ) OR
435 NOTBCD ( vpenh->val.vpenh_hours.second ) )
436 {
437 return ( FALSE );
438 }
439 }
440
441 return ( TRUE );
442 }
443
444 /*
445 +-------------------------------------------------------------------+
446 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
447 | STATE : code ROUTINE : cmhSMS_setVpabsPsa |
448 +-------------------------------------------------------------------+
449
450 PURPOSE : This function is used to copy the elements of the
451 absolute validity period structure of the ACI to the
452 corresponding structure of the PSA.
453
454 Note: Copying of the structure elements might be
455 dangerous when array size of time elements differ
456 from MAX_VP_ABS_DIGIT due to changes in PSA
457 declaration.
458 */
459 GLOBAL void cmhSMS_setVpabsPsa ( T_tp_vp_abs* psaVp,
460 T_ACI_VP_ABS* cmhVp )
461 {
462 USHORT i; /* used for counting */
463
464 BOOL isNegative = ( cmhVp->timezone & 0x8000 );
465 SHORT tz = ( UBYTE ) cmhVp->timezone;
466
467 for (i = 0; i < MAX_VP_ABS_DIGITS; i++)
468 {
469 psaVp -> year [i] = cmhVp -> year [i];
470 psaVp -> month [i] = cmhVp -> month [i];
471 psaVp -> day [i] = cmhVp -> day [i];
472 psaVp -> hour [i] = cmhVp -> hour [i];
473 psaVp -> minute[i] = cmhVp -> minute[i];
474 psaVp -> second[i] = cmhVp -> second[i];
475 }
476
477 if ( isNegative )
478 {
479 tz = -tz;
480 psaVp -> tz_sign = 1;
481 }
482 else
483 {
484 psaVp -> tz_sign = 0;
485 }
486
487 psaVp -> tz_lsb = tz & 0x000F;
488 psaVp -> tz_msb = tz & 0x00F0;
489 }
490
491 /*
492 +-------------------------------------------------------------------+
493 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
494 | STATE : code ROUTINE : cmhSMS_setVpenhPsa |
495 +-------------------------------------------------------------------+
496
497 PURPOSE : This function is used to copy the elements of the
498 enhanced validity period structure of the ACI to the
499 corresponding structure of the PSA.
500 */
501 GLOBAL void cmhSMS_setVpenhPsa ( T_tp_vp_enh* psaVp,
502 T_ACI_VP_ENH* cmhVp )
503 {
504 memset(psaVp, 0, sizeof(T_tp_vp_enh));
505
506 if (cmhVp->func_ind & TP_VPF_ENH_EXT_BIT_MASK)
507 {
508 psaVp->tp_ext = SMS_EXT_INCLUDED;
509 psaVp->v_tp_rsrvd = 1;
510 psaVp->tp_rsrvd = cmhVp->ext_oct;
511 }
512
513 if (cmhVp->func_ind & TP_VPF_ENH_SINGLE_SHOT_MASK)
514 {
515 psaVp->tp_ss = SMS_SS_SET;
516 }
517
518 if ((cmhVp->func_ind & TP_VPF_ENH_FORMAT_MASK) EQ TP_VPF_ENH_NOT_PRESENT)
519 {
520 psaVp->tvpf = SMS_TVPF_NOT_PRESENT;
521 }
522 else if ((cmhVp->func_ind & TP_VPF_ENH_FORMAT_MASK) EQ TP_VPF_ENH_REL)
523 {
524 psaVp->tvpf = SMS_TVPF_RELATIVE;
525 psaVp->v_tp_vp_rel = 1;
526 psaVp->tp_vp_rel = cmhVp->val.vpenh_relative;
527 }
528 else if ((cmhVp->func_ind & TP_VPF_ENH_FORMAT_MASK) EQ TP_VPF_ENH_SEC)
529 {
530 psaVp->tvpf = SMS_TVPF_SECONDS;
531 psaVp->v_tp_vp_sec = 1;
532 psaVp->tp_vp_sec = cmhVp->val.vpenh_seconds;
533 }
534 else if ((cmhVp->func_ind & TP_VPF_ENH_FORMAT_MASK) EQ TP_VPF_ENH_HRS)
535 {
536 psaVp->tvpf = SMS_TVPF_HOURS;
537 psaVp->v_hour = 1;
538 psaVp->hour[0] = cmhVp->val.vpenh_hours.hour[0];
539 psaVp->hour[1] = cmhVp->val.vpenh_hours.hour[1];
540 psaVp->v_minute = 1;
541 psaVp->minute[0] = cmhVp->val.vpenh_hours.minute[0];
542 psaVp->minute[1] = cmhVp->val.vpenh_hours.minute[1];
543 psaVp->v_second = 1;
544 psaVp->second[0] = cmhVp->val.vpenh_hours.second[0];
545 psaVp->second[1] = cmhVp->val.vpenh_hours.second[1];
546 }
547 else
548 {
549 TRACE_EVENT("[ERR] cmhSMS_setVpenhPsa: wrong type of validity period format");
550 }
551 }
552
553 /*
554 +-------------------------------------------------------------------+
555 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
556 | STATE : code ROUTINE : cmhSMS_setVpabsCmh |
557 +-------------------------------------------------------------------+
558
559 PURPOSE : This function is used to copy the elements of the
560 absolute validity period structure of the PSA to the
561 corresponding structure of the ACI.
562
563 Note: Copying of the structure elements might be
564 dangerous when array size of time elements differ
565 from MAX_VP_ABS_DIGIT due to changes in PSA
566 declaration.
567 */
568 GLOBAL void cmhSMS_setVpabsCmh ( T_ACI_VP_ABS* cmhVp,
569 T_tp_vp_abs* psaVp )
570 {
571 USHORT i; /* used for counting */
572 SHORT tz;
573
574 for (i = 0; i < MAX_VP_ABS_DIGITS; i++)
575 {
576 cmhVp -> year [i] = psaVp -> year [i];
577 cmhVp -> month [i] = psaVp -> month [i];
578 cmhVp -> day [i] = psaVp -> day [i];
579 cmhVp -> hour [i] = psaVp -> hour [i];
580 cmhVp -> minute[i] = psaVp -> minute[i];
581 cmhVp -> second[i] = psaVp -> second[i];
582 }
583
584 tz = ((psaVp->tz_msb & 0x07) * 10) + psaVp->tz_lsb; /* BCD */
585
586 if (psaVp->tz_sign)
587 cmhVp -> timezone = -tz;
588 else
589 cmhVp -> timezone = tz;
590 }
591
592 /*
593 +-------------------------------------------------------------------+
594 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
595 | STATE : code ROUTINE : cmhSMS_setVpenhCmh |
596 +-------------------------------------------------------------------+
597
598 PURPOSE : This function is used to copy the elements of the
599 enhanced validity period structure of the PSA to the
600 corresponding structure of the ACI.
601
602 */
603 GLOBAL void cmhSMS_setVpenhCmh ( T_ACI_VP_ENH* cmhVp,
604 T_tp_vp_enh* psaVp )
605 {
606 memset(cmhVp, 0, sizeof(T_ACI_VP_ENH));
607
608 cmhVp->func_ind = psaVp->tvpf;
609
610 if ((psaVp->tp_ext EQ SMS_EXT_INCLUDED) AND (psaVp->v_tp_rsrvd))
611 {
612 cmhVp->func_ind |= TP_VPF_ENH_EXT_BIT_MASK;
613 cmhVp->ext_oct = psaVp->tp_rsrvd;
614 }
615
616 if (psaVp->tp_ss EQ SMS_SS_SET)
617 {
618 cmhVp->func_ind |= TP_VPF_ENH_SINGLE_SHOT_MASK;
619 }
620
621 if (psaVp->tvpf EQ SMS_TVPF_NOT_PRESENT)
622 {
623 /* do nothing */
624 }
625 else if ((psaVp->tvpf EQ SMS_TVPF_RELATIVE) AND (psaVp->v_tp_vp_rel))
626 {
627 cmhVp->val.vpenh_relative = psaVp->tp_vp_rel;
628 }
629 else if ((psaVp->tvpf EQ SMS_TVPF_SECONDS) AND (psaVp->v_tp_vp_sec))
630 {
631 cmhVp->val.vpenh_seconds = psaVp->tp_vp_sec;
632 }
633 else if (psaVp->tvpf EQ SMS_TVPF_HOURS)
634 {
635 if (psaVp->v_hour)
636 {
637 cmhVp->val.vpenh_hours.hour[0] = psaVp->hour[0];
638 cmhVp->val.vpenh_hours.hour[1] = psaVp->hour[1];
639 }
640 if (psaVp->v_minute)
641 {
642 cmhVp->val.vpenh_hours.minute[0] = psaVp->minute[0];
643 cmhVp->val.vpenh_hours.minute[1] = psaVp->minute[1];
644 }
645 if (psaVp->v_second)
646 {
647 cmhVp->val.vpenh_hours.second[0] = psaVp->second[0];
648 cmhVp->val.vpenh_hours.second[1] = psaVp->second[1];
649 }
650 }
651 else
652 {
653 TRACE_EVENT("[ERR] cmhSMS_setVpenhCmh: wrong type of validity period format");
654 }
655 }
656
657 /*
658 +--------------------------------------------------------------------+
659 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
660 | STATE : code ROUTINE : cmhSMS_getAdrStr |
661 +--------------------------------------------------------------------+
662
663 PURPOSE : This function is used to convert the service center
664 address in BCD to the service center address as a string.
665 */
666 GLOBAL UBYTE cmhSMS_getAdrStr ( CHAR* pStr,
667 UBYTE maxIdx,
668 UBYTE* pBcd,
669 UBYTE numDigits )
670 {
671 UBYTE bcdIdx;
672 UBYTE strIdx = 0;
673
674 memset(pStr, 0x00, maxIdx);
675
676 for(bcdIdx = 0; bcdIdx < numDigits AND strIdx < maxIdx; bcdIdx++)
677 {
678 switch (pBcd[bcdIdx])
679 {
680 case 0:
681 case 1:
682 case 2:
683 case 3:
684 case 4:
685 case 5:
686 case 6:
687 case 7:
688 case 8:
689 case 9:
690 pStr[strIdx++] = pBcd[bcdIdx] + '0';
691 break;
692
693 case BCD_ASTSK:
694 pStr[strIdx++] = '*';
695 break;
696
697 case BCD_PND:
698 pStr[strIdx++] = '#';
699 break;
700
701 case BCD_A:
702 pStr[strIdx++] = 'A';
703 break;
704
705 case BCD_B:
706 pStr[strIdx++] = 'B';
707 break;
708
709 case BCD_C:
710 pStr[strIdx++] = 'C';
711 break;
712 }
713 }
714
715 pStr[strIdx] = '\0';
716
717 return ( strIdx );
718 }
719
720 /*
721 +--------------------------------------------------------------------+
722 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
723 | STATE : code ROUTINE : cmhSMS_getAdrBcd |
724 +--------------------------------------------------------------------+
725
726 PURPOSE : This function is used to convert the service center
727 address as a string to the service center address in BCD.
728 */
729 GLOBAL void cmhSMS_getAdrBcd ( UBYTE* pBcd,
730 UBYTE* pNumDigits,
731 UBYTE maxDigits,
732 CHAR* pStr )
733 {
734 UBYTE bcdIdx = 0;
735 UBYTE strIdx;
736
737 for(strIdx = 0; bcdIdx < maxDigits AND pStr[strIdx] NEQ '\0'; strIdx++)
738 {
739 switch (pStr[strIdx])
740 {
741 case '0':
742 case '1':
743 case '2':
744 case '3':
745 case '4':
746 case '5':
747 case '6':
748 case '7':
749 case '8':
750 case '9':
751 pBcd[bcdIdx++] = pStr[strIdx] - '0';
752 break;
753
754 case '*':
755 pBcd[bcdIdx++] = BCD_ASTSK;
756 break;
757
758 case '#':
759 pBcd[bcdIdx++] = BCD_PND;
760 break;
761
762 case 'A':
763 pBcd[bcdIdx++] = BCD_A;
764 break;
765
766 case 'B':
767 pBcd[bcdIdx++] = BCD_B;
768 break;
769
770 case 'C':
771 pBcd[bcdIdx++] = BCD_C;
772 break;
773 }
774 }
775
776 *pNumDigits = bcdIdx;
777 }
778
779 /*
780 +--------------------------------------------------------------------+
781 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
782 | STATE : code ROUTINE : cmhSMS_getAdrAlphaNum |
783 +--------------------------------------------------------------------+
784
785 PURPOSE : This function is used to pack the Alphanumeric
786 Destination Adress according to 23.038
787 */
788 GLOBAL T_ACI_RETURN cmhSMS_packAlphaNumAddr( CHAR* da,
789 T_tp_da* da_addr)
790 {
791 UBYTE dest[((MAX_SMS_ADDR_DIG/2) * 8) / 7];
792 UBYTE dest_len;
793 USHORT dalen;
794
795 if( (da NEQ NULL) AND (da_addr NEQ NULL) )
796 {
797 dalen = strlen(da);
798
799 dest_len = utl_cvt8To7( (UBYTE*)da, (UBYTE)dalen, dest, 0);
800
801 if( dest_len > (MAX_SMS_ADDR_DIG/2) )
802 {
803 TRACE_EVENT("DA length is greater then the supported length");
804 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_UnknownErr );
805 return(AT_FAIL);
806 }
807 if( ((dalen + 3) %7) <= 3 )
808 {
809 da_addr->c_num = (dest_len*2) - 1; /* odd number of usefull nibbles */
810 }
811 else
812 {
813 da_addr->c_num = dest_len*2; /* even number of usefull nibbles */
814 }
815
816 cmh_unpackBCD(da_addr->num, dest, dest_len );
817 da_addr->digits = da_addr->c_num;
818 }
819
820 return(AT_CMPL);
821 }
822
823 /*
824 +-------------------------------------------------------------------+
825 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
826 | STATE : code ROUTINE : cmhSMS_getMemCmh |
827 +-------------------------------------------------------------------+
828
829 PURPOSE : This function converts the preferred memory from
830 PSA type to CMH type.
831 */
832 GLOBAL void cmhSMS_getMemCmh ( UBYTE inMem, T_ACI_SMS_STOR* outMem )
833 {
834 switch( inMem )
835 {
836 case( MEM_ME ): *outMem = SMS_STOR_Me; break;
837 case( MEM_SM ): *outMem = SMS_STOR_Sm; break;
838 }
839 }
840
841 /*
842 +-------------------------------------------------------------------+
843 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
844 | STATE : code ROUTINE : cmhSMS_getMemPsa |
845 +-------------------------------------------------------------------+
846
847 PURPOSE : This function converts the preferred memory from
848 CMH type to PSA type.
849
850 returns: TRUE if conversion was successfull,
851 otherwise FALSE
852 */
853 GLOBAL BOOL cmhSMS_getMemPsa ( T_ACI_SMS_STOR inMem, UBYTE* outMem )
854 {
855 switch( inMem )
856 {
857 case( SMS_STOR_Me ): *outMem = MEM_ME; break;
858 case( SMS_STOR_Sm ): *outMem = MEM_SM; break;
859 default : return ( FALSE );
860 }
861
862 return ( TRUE );
863 }
864
865 /*
866 +--------------------------------------------------------------------+
867 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
868 | STATE : code ROUTINE : cmhSMS_getAlphabetPp |
869 +--------------------------------------------------------------------+
870
871 PURPOSE : This function is used to extract the used alphabet out
872 of the data coding scheme for point-to-point SMS.
873 */
874 GLOBAL UBYTE cmhSMS_getAlphabetPp ( UBYTE dcs )
875 {
876 UBYTE alphabet = 0; /* means 7 bit default alphabet */
877
878 switch (dcs & 0xF0)
879 {
880 case( 0x30 ):
881 case( 0x20 ):
882 alphabet = 0x01; /* compressed, counts as 8 bit data */
883 break;
884 case( 0x10 ):
885 case( 0x00 ):
886 alphabet = (dcs & 0x0C) >> 2;
887 if (alphabet EQ 3)
888 alphabet = 0; /* reserved coding */
889 break;
890 case( 0xE0 ):
891 alphabet = 0x02; /* UCS2 */
892 break;
893 case( 0xF0 ):
894 alphabet = (dcs & 0x04) >> 2;
895 break;
896 }
897
898 return alphabet;
899 }
900
901 /*
902 +-------------------------------------------------------------------+
903 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
904 | STATE : code ROUTINE : cmhSMS_expdSmsPp |
905 +-------------------------------------------------------------------+
906
907 PURPOSE : This function expands a point-to-point SMS from
908 7 to 8 bit.
909 */
910 GLOBAL void cmhSMS_expdSmsPp ( UBYTE byte_offset,
911 UBYTE dcs,
912 UBYTE* source,
913 UBYTE source_len,
914 UBYTE* dest,
915 UBYTE* dest_len )
916 {
917 UBYTE alphabet;
918 UBYTE bit_offset = 0;
919
920 TRACE_FUNCTION ("cmhSMS_expdSmsPp ()");
921
922
923 alphabet = cmhSMS_getAlphabetPp ( dcs );
924
925 switch (alphabet)
926 {
927 case( 0 ): /* 7 bit alphabet */
928
929 if ( byte_offset % 7 NEQ 0 )
930 {
931 bit_offset = 7 - ((byte_offset*8) % 7);
932 }
933
934 *dest_len = source_len - ((byte_offset*8+6)/7); /* adjust byte_offset to septets */
935
936 /* In 7-Bit mode we get number of septets but we need octets */
937 source_len = (source_len*7+7)/8; /* round up to next octet*/
938 source_len -= byte_offset;
939
940 utl_cvt7To8 ( source, source_len, dest, bit_offset);
941
942
943 break;
944
945 default: /* 8 bit alphabet, UCS2, reserved */
946
947 *dest_len = source_len-byte_offset;
948 memcpy ( (CHAR*) dest, (CHAR*)source, *dest_len );
949 break;
950 }
951 }
952
953 /*
954 +-------------------------------------------------------------------+
955 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
956 | STATE : code ROUTINE : cmhSMS_rdcSmsPp |
957 +-------------------------------------------------------------------+
958
959 PURPOSE : This function reduces a point-to-point SMS from
960 8 to 7 bit.
961 */
962 GLOBAL void cmhSMS_rdcSmsPp ( UBYTE byte_offset,
963 UBYTE dcs,
964 UBYTE* source,
965 UBYTE source_len,
966 UBYTE* dest,
967 UBYTE* dest_len )
968 {
969 UBYTE data_len;
970 UBYTE alphabet;
971 UBYTE bit_offset = 0;
972
973 TRACE_FUNCTION ("cmhSMS_rdcSmsPp ()");
974
975 if (source_len EQ 0)
976 {
977 *dest_len = source_len;
978 return;
979 }
980
981 alphabet = cmhSMS_getAlphabetPp ( dcs );
982
983 switch (alphabet)
984 {
985 case( 0 ): /* 7 bit alphabet */
986
987 if ( byte_offset % 7 NEQ 0 )
988 {
989 bit_offset = 7 - ((byte_offset*8) % 7);
990 }
991
992 data_len = MINIMUM (source_len, (SMS_MSG_LEN * 8) / 7);
993
994 data_len = utl_cvt8To7 ( source, data_len, dest, bit_offset );
995 break;
996
997 default: /* 8 bit alphabet, UCS2, reserved */
998 data_len = MINIMUM ( source_len, SMS_MSG_LEN );
999
1000 memcpy ( ( CHAR * ) dest, ( CHAR * ) source, data_len );
1001 break;
1002 }
1003
1004 *dest_len = data_len;
1005 }
1006 /* Implements Measure 25. This function is replaced by cmh_getAlphabetCb*/
1007 /*
1008 +--------------------------------------------------------------------+
1009 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1010 | STATE : code ROUTINE : cmhSMS_expdSmsCb |
1011 +--------------------------------------------------------------------+
1012
1013 PURPOSE : This function expands a cell broadcast SMS from
1014 7 to 8 bit.
1015 */
1016 GLOBAL void cmhSMS_expdSmsCb ( UBYTE dcs,
1017 UBYTE *source,
1018 UBYTE source_len,
1019 UBYTE *dest,
1020 UBYTE *dest_len )
1021 {
1022 UBYTE alphabet;
1023
1024 TRACE_FUNCTION ("cmhSMS_expdSmsCb()");
1025 alphabet = cmh_getAlphabetCb ( dcs );
1026
1027 switch (alphabet)
1028 {
1029 case( 0 ): /* 7 bit alphabet */
1030 /* PATCH Add bit_offset parameter to function cvt7To8 */
1031 /* utl_cvt7To8 ( source, source_len, dest ); */
1032 utl_cvt7To8 ( source, source_len, dest, 0);
1033 /* PATCH END */
1034
1035 *dest_len = ( source_len * 8 ) / 7;
1036 break;
1037
1038 default: /* 8 bit alphabet, UCS2, reserved */
1039 memcpy ( ( CHAR * ) dest, ( CHAR * ) source, source_len );
1040
1041 *dest_len = source_len;
1042 break;
1043 }
1044 }
1045
1046 /*
1047 +--------------------------------------------------------------------+
1048 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1049 | STATE : code ROUTINE : cmhSMS_setToaDef |
1050 +--------------------------------------------------------------------+
1051
1052 PURPOSE : This function sets the type of address to default values
1053 (when the first character of address is '+' or the first
1054 two characters are '0' default is 145 otherwise default
1055 is 129)
1056 */
1057 GLOBAL CHAR* cmhSMS_setToaDef ( CHAR* number,
1058 UBYTE* ntype,
1059 UBYTE* nplan )
1060 {
1061 *nplan = SMS_NPI_ISDN;
1062
1063 if ( *number EQ '+' )
1064 {
1065 *ntype = SMS_TON_INTERNATIONAL;
1066 return number+1;
1067 }
1068 else
1069 {
1070 *ntype = SMS_TON_UNKNOWN;
1071 return number;
1072 }
1073 }
1074
1075 /*
1076 +--------------------------------------------------------------------+
1077 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1078 | STATE : code ROUTINE : cmhSMS_setTimezone |
1079 +--------------------------------------------------------------------+
1080
1081 PURPOSE : Codes the timezone format used in entity SMS.
1082
1083 */
1084 GLOBAL UBYTE cmhSMS_setTimezone (SHORT timezone)
1085 {
1086 UBYTE local_tz = ( UBYTE ) timezone;
1087 BOOL isNegative = ( local_tz & 0x80 );
1088
1089 if ( isNegative )
1090 local_tz = ~local_tz + 1;
1091
1092 local_tz = ( local_tz / 10 ) + ( ( local_tz % 10 ) << 4 );
1093
1094 return ( ( isNegative ) ? local_tz | 0x08 : local_tz );
1095 }
1096
1097 /*
1098 +--------------------------------------------------------------------+
1099 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1100 | STATE : code ROUTINE : cmhSMS_getTimezone |
1101 +--------------------------------------------------------------------+
1102
1103 PURPOSE : Decodes the timezone format used in entity SMS.
1104
1105 */
1106 GLOBAL SHORT cmhSMS_getTimezone (UBYTE timezone)
1107 {
1108 signed char local_tz;
1109
1110 local_tz = ( timezone & 0x07 ) * 10 + ( ( timezone & 0xF0 ) >> 4 );
1111
1112 return ( SHORT ) (( timezone & 0x08 ) ? -local_tz : local_tz );
1113 }
1114
1115 /*
1116 +--------------------------------------------------------------------+
1117 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1118 | STATE : code ROUTINE : cmhSMS_setStorOcc |
1119 +--------------------------------------------------------------------+
1120
1121 PURPOSE : Fills the T_ACI_SMS_STOR_OCC structure with data from the
1122 shared parameter buffer.
1123
1124 */
1125 GLOBAL void cmhSMS_setStorOcc ( T_ACI_SMS_STOR_OCC* outMem,
1126 UBYTE inMem )
1127 {
1128 cmhSMS_getMemCmh ( inMem, &outMem -> mem );
1129
1130 if ( outMem -> mem EQ SMS_STOR_Sm )
1131 {
1132 outMem -> used = smsShrdPrm.aci_sms_parameter.simUsed;
1133 outMem -> total = smsShrdPrm.aci_sms_parameter.simTotal;
1134 }
1135 else
1136 {
1137 outMem -> used = smsShrdPrm.aci_sms_parameter.meUsed;
1138 outMem -> total = smsShrdPrm.aci_sms_parameter.meTotal;
1139 }
1140 }
1141
1142 /*
1143 +-------------------------------------------------------------------+
1144 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1145 | ROUTINE : cmhSMS_GetCmsFromSim |
1146 +-------------------------------------------------------------------+
1147
1148 PURPOSE : Mapping of SIM error code to ACI error code.
1149
1150 */
1151 GLOBAL T_ACI_CMS_ERR cmhSMS_GetCmsFromSim ( USHORT errCode )
1152 {
1153 switch ( errCode )
1154 {
1155 case SIM_NO_ERROR:
1156 return CMS_ERR_NotPresent;
1157
1158 case SIM_CAUSE_PIN1_EXPECT:
1159 return CMS_ERR_SimPinReq;
1160
1161 case SIM_CAUSE_PIN2_EXPECT:
1162 return CMS_ERR_SimPin2Req;
1163
1164 case SIM_CAUSE_PUK1_EXPECT:
1165 case SIM_CAUSE_PIN1_BLOCKED:
1166 return CMS_ERR_SimPukReq;
1167
1168 case SIM_CAUSE_PUK2_EXPECT:
1169 case SIM_CAUSE_PIN2_BLOCKED:
1170 return CMS_ERR_SimPuk2Req;
1171
1172 case SIM_CAUSE_PUK1_BLOCKED:
1173 case SIM_CAUSE_PUK2_BLOCKED:
1174 return CMS_ERR_SimWrong;
1175
1176 case SIM_CAUSE_UNKN_FILE_ID:
1177 case SIM_CAUSE_DNL_ERROR:
1178 return CMS_ERR_UnknownErr;
1179
1180 case SIM_CAUSE_EF_INVALID:
1181 return CMS_ERR_OpNotSup;
1182
1183 case SIM_CAUSE_ADDR_WRONG:
1184 return CMS_ERR_InValMemIdx;
1185
1186 case SIM_CAUSE_CMD_INCONSIST:
1187 case SIM_CAUSE_MAX_INCREASE:
1188 case SIM_CAUSE_CHV_NOTSET:
1189 case SIM_CAUSE_CHV_VALIDATED:
1190 case SIM_CAUSE_ACCESS_PROHIBIT:
1191 return CMS_ERR_OpNotAllowed;
1192
1193 case SIM_CAUSE_CARD_REMOVED:
1194 case SIM_CAUSE_DRV_NOCARD:
1195 return CMS_ERR_SimNotIns;
1196
1197 case SIM_CAUSE_NO_SELECT:
1198 case SIM_CAUSE_CLA_WRONG:
1199 case SIM_CAUSE_INS_WRONG:
1200 case SIM_CAUSE_P1P2_WRONG:
1201 case SIM_CAUSE_P3_WRONG:
1202 case SIM_CAUSE_PARAM_WRONG:
1203 return CMS_ERR_MeFail;
1204
1205 case SIM_CAUSE_SAT_BUSY:
1206 return CMS_ERR_SimBsy;
1207
1208 case SIM_CAUSE_DRV_TEMPFAIL:
1209 return CMS_ERR_SimFail;
1210
1211 default:
1212 if (GET_CAUSE_DEFBY(errCode) EQ DEFBY_CONDAT AND
1213 GET_CAUSE_ORIGSIDE(errCode) EQ ORIGSIDE_MS)
1214 {
1215 return CMS_ERR_UnknownErr;
1216 }
1217 return CMS_ERR_UnknownErr;
1218 }
1219 }
1220
1221
1222
1223 /*
1224 +-------------------------------------------------------------------+
1225 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1226 | ROUTINE : cmhSMS_GetCmsFromSms |
1227 +-------------------------------------------------------------------+
1228
1229 PURPOSE : Mapping of SMS causes (MNSMS.doc) to ACI error code.
1230
1231 */
1232 GLOBAL T_ACI_CMS_ERR cmhSMS_GetCmsFromSms ( USHORT errCode )
1233 {
1234 switch ( errCode )
1235 {
1236 case SMS_NO_ERROR: /* No error */
1237 return CMS_ERR_NotPresent;
1238
1239 case SMS_CAUSE_PARAM_WRONG: /* Wrong parameter in primitive */
1240
1241 case SMS_CAUSE_ENTITY_BUSY: /* Entity is busy */
1242 return CMS_ERR_SimBsy;
1243
1244 case SMS_CAUSE_OPER_NOT_ALLW: /* Operation not allowed */
1245 return CMS_ERR_OpNotAllowed;
1246
1247 case SMS_CAUSE_OPER_NOT_SUPP: /* Operation not supported */
1248 return CMS_ERR_OpNotSup;
1249
1250 case SMS_CAUSE_SIM_BUSY: /* SIM busy */
1251 return CMS_ERR_SimBsy;
1252 default:
1253 break;
1254 }
1255
1256 /*
1257 * The switch must be splitted because of a compiler bug
1258 * - asm files can not compiled
1259 *
1260 * TMS470 ANSI C Compiler Version 1.22e
1261 *
1262 * brz, 2004.02.14
1263 */
1264
1265 switch(errCode) {
1266 case SMS_CAUSE_MEM_FAIL: /* Memory failure */
1267 return CMS_ERR_MemFail;
1268
1269 case SMS_CAUSE_INV_INDEX: /* Invalid memory index */
1270 return CMS_ERR_InValMemIdx;
1271
1272 case SMS_CAUSE_MEM_FULL: /* Memory full */
1273 return CMS_ERR_MemFull;
1274
1275 case SMS_CAUSE_NO_SERVICE: /* No network service */
1276 return CMS_ERR_NoNetServ;
1277
1278 case SMS_CAUSE_NET_TIMEOUT: /* Network timeout */
1279 return CMS_ERR_NetTimeOut;
1280
1281 case SMS_CAUSE_UNEXP_CNMA: /* No +CNMA acknowledgement expected */
1282 return CMS_ERR_NoCnmaAckExpect;
1283
1284 case SMS_CAUSE_OTHER_ERROR: /* Any other error */
1285 return CMS_ERR_UnknownErr;
1286
1287 default:
1288 return ((T_ACI_CMS_ERR) errCode); /* cmdCmsError(errCode) will figure out other error values from the first byte of the error code */
1289 }
1290 }
1291
1292
1293
1294
1295
1296
1297 /*
1298 +-------------------------------------------------------------------+
1299 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1300 | STATE : code ROUTINE : cmhSMS_ready |
1301 +-------------------------------------------------------------------+
1302
1303 PURPOSE : This function notifies SMS_READY to all sources.
1304 */
1305 GLOBAL void cmhSMS_ready ( void )
1306 {
1307 int idx;
1308 T_opl_field * ptr_opl;
1309
1310 TRACE_FUNCTION ("cmhSMS_ready()");
1311
1312 {
1313 PALLOC (sim_sync_req, SIM_SYNC_REQ);
1314 sim_sync_req -> synccs = SYNC_MMI_FINISHED_READING;
1315 simShrdPrm.synCs = SYNC_MMI_FINISHED_READING;
1316 PSENDX (SIM, sim_sync_req);
1317 }
1318
1319 smsShrdPrm.accessEnabled = TRUE;
1320 ptr_opl = cmhSIM_GetOPL();
1321 ptr_opl->opl_status = FALSE;
1322
1323 cmhSIM_UpdateOperatorName(NOT_PRESENT_16BIT); /* start EF_PNN and EF_OPL reading */
1324
1325 pb_start_build(FALSE); /* start phonebook reading, no guarantees */
1326
1327 percentCSTAT_indication(STATE_MSG_SMS, ENTITY_STATUS_Ready);
1328
1329 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
1330 {
1331 R_AT( RAT_SMS_READY, (T_ACI_CMD_SRC)idx )();
1332 }
1333
1334 }
1335
1336
1337 /*
1338 +-------------------------------------------------------------------+
1339 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1340 | STATE : code ROUTINE : cmhSMS_disableAccess |
1341 +-------------------------------------------------------------------+
1342
1343 PURPOSE : This function disables access to all SMS functions.
1344 */
1345 GLOBAL void cmhSMS_disableAccess (void)
1346 {
1347 smsShrdPrm.accessEnabled = FALSE;
1348 }
1349
1350 /*
1351 +-------------------------------------------------------------------+
1352 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1353 | STATE : code ROUTINE : cmhSMS_checkSIM |
1354 +-------------------------------------------------------------------+
1355
1356 PURPOSE : This function checks if SMS is initialized. If not, the
1357 SIM state is checked. AN error code dependent of the
1358 SIM state is stored.
1359 */
1360 GLOBAL BOOL cmhSMS_checkSIM (void)
1361 {
1362 if (smsShrdPrm.accessEnabled)
1363 return TRUE; /* SMS is accessible*/
1364 /*
1365 *-----------------------------------------------------------------
1366 * check SIM status
1367 *-----------------------------------------------------------------
1368 */
1369
1370 switch (simShrdPrm.SIMStat)
1371 {
1372 case NO_VLD_SS:
1373 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_SimNotIns );
1374 break;
1375 case SS_INV:
1376 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_SimFail );
1377 break;
1378 /* case SS_BLKD:
1379 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_SimPukReq );
1380 break; */
1381 case SS_URCHB:
1382 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_SimWrong );
1383 break;
1384 case SS_OK:
1385 switch (simShrdPrm.PINStat)
1386 {
1387 case PS_PIN1:
1388 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_SimPinReq);
1389 break;
1390
1391 case PS_PIN2:
1392 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_SimPin2Req);
1393 break;
1394
1395 case PS_PUK1:
1396 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_SimPukReq);
1397 break;
1398
1399 case PS_PUK2:
1400 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_SimPuk2Req);
1401 break;
1402
1403 default:
1404 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_SimBsy );
1405 break;
1406 }
1407 break;
1408 default:
1409 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_SimBsy );
1410 break;
1411 }
1412 return FALSE;
1413 }
1414 /*
1415 +-------------------------------------------------------------------+
1416 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1417 | STATE : code ROUTINE : cmhSMS_checkAccess |
1418 +-------------------------------------------------------------------+
1419
1420 PURPOSE : This function checks if SMS is accessible. If an error
1421 condition is found, then *ret is set to either AT_FAIL or
1422 AT_BUSY, otherwise it remains unaffected. The error code
1423 is stored.
1424 */
1425 GLOBAL BOOL cmhSMS_checkAccess (T_ACI_CMD_SRC srcId,
1426 T_ACI_RETURN *ret)
1427 {
1428 /*
1429 *-----------------------------------------------------------------
1430 * check command source
1431 *-----------------------------------------------------------------
1432 */
1433 if(srcId NEQ (T_ACI_CMD_SRC)OWN_SRC_SAT)
1434 {
1435 if(!cmh_IsVldCmdSrc (srcId))
1436 {
1437 TRACE_ERROR ("[cmhSMS_checkAccess]: Cmd Src not valid");
1438 *ret = AT_FAIL;
1439 return FALSE;
1440 }
1441 }
1442 /*
1443 *-----------------------------------------------------------------
1444 * check entity status
1445 *-----------------------------------------------------------------
1446 */
1447 if( smsShrdPrm.smsEntStat.curCmd NEQ AT_CMD_NONE )
1448 {
1449 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
1450 TRACE_ERROR ("[cmhSMS_checkAccess]: Entity is busy");
1451 *ret = AT_BUSY;
1452 return FALSE;
1453 }
1454
1455 /*
1456 *-----------------------------------------------------------------
1457 * check SMS access status
1458 *-----------------------------------------------------------------
1459 */
1460 if (cmhSMS_checkSIM ())
1461 return TRUE;
1462
1463 TRACE_ERROR ("[cmhSMS_checkAccess]: Wrong SIM status");
1464
1465 *ret = AT_FAIL;
1466 return FALSE;
1467 }
1468
1469 /*
1470 +-------------------------------------------------------------------+
1471 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1472 | STATE : code ROUTINE : cmhSMS_getPrfRge |
1473 +-------------------------------------------------------------------+
1474
1475 PURPOSE : This function gets the number of available profiles for
1476 SMS related parameters. First, the SIM is checked. If
1477 there is no space, then PCM ist checked.
1478 */
1479 GLOBAL SHORT cmhSMS_getPrfRge ( void )
1480 {
1481 /* TEMPORARY, ONLY FOR TEST PURPOSES: Pretend that the SIM has no SMSP !!! */
1482 /* smsShrdPrm.aci_sms_parameter.smsParamMaxRec = 0;*/
1483
1484 if (smsShrdPrm.aci_sms_parameter.smsParamMaxRec > 0)
1485 {
1486 return (SHORT)smsShrdPrm.aci_sms_parameter.smsParamMaxRec;
1487 }
1488 else
1489 {
1490 return (MAX_FFS_SMSPRFLS);
1491 }
1492 }
1493
1494 /*
1495 +-------------------------------------------------------------------+
1496 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1497 | STATE : code ROUTINE : cmhSMS_ReadPrmFFS |
1498 +-------------------------------------------------------------------+
1499
1500 PURPOSE : This function reads one record of EF_SMSPRFL_ID from FFS.
1501 The processed parameters are controlled by bits in
1502 'access'.
1503 */
1504 static T_ACI_RETURN cmhSMS_ReadPrmFFS (T_ACI_CMD_SRC srcId,
1505 SHORT recNr,
1506 int access)
1507 {
1508 T_SMS_SET_PRM *pSMSSetPrm; /* points to SMS parameter set */
1509 int i;
1510 T_SMS_SET_PRM *elem;
1511 T_ACI_FFS_SMSPRFL smsPrfl;
1512 #ifndef _SIMULATION_
1513 T_FFS_SIZE ffs_size;
1514 #endif
1515
1516 TRACE_FUNCTION ("cmhSMS_ReadPrmFFS()");
1517
1518 #ifdef _SIMULATION_
1519 smsPrfl.vldFlag = FFS_SMSPRFL_INVLD; /* trigger a failure since nothing can be read in simulation */
1520 #else
1521 ffs_size = FFS_fread(ffs_smsprfl_fname[recNr-1], (void*)&smsPrfl, SIZE_FSS_SMSPRFL);
1522 /*
1523 Don't check FFS return for only specif ERRORS, as ACI will not know what
1524 ERROR FFS may send. So, it's walyws better to check for ERROR OK
1525 i.e EFFS_OK Considering this in mind the below condition is changes to
1526 do the same.
1527 */
1528 if ( ffs_size < EFFS_OK )
1529 {
1530 TRACE_EVENT_P1("error when reading FFS object \"%s\"", ffs_smsprfl_fname[recNr-1]);
1531 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_MemFail );
1532 return AT_FAIL;
1533 }
1534 #endif
1535
1536 if ( smsPrfl.vldFlag EQ FFS_SMSPRFL_INVLD )
1537 {
1538 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_OpNotAllowed );
1539 return AT_FAIL;
1540 }
1541
1542 if (access & ACI_PCM_ACCESS_SMSP)
1543 {
1544 if (srcId >= CMD_SRC_MAX)
1545 {
1546 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_UnknownErr );
1547 return AT_FAIL;
1548 }
1549 else
1550 {
1551 if (set_prm_list EQ NULL)
1552 {
1553 set_prm_list = new_list();
1554 }
1555
1556 elem = find_element(set_prm_list, (UBYTE)recNr, cmhSMS_findPrflId);
1557 if (elem EQ NULL)
1558 {
1559 ACI_MALLOC(elem, sizeof(T_SMS_SET_PRM));
1560 memset(elem, 0, sizeof(T_SMS_SET_PRM));
1561 insert_list(set_prm_list, elem);
1562 }
1563 if (srcId <= CMD_SRC_NONE)
1564 {
1565 elem->numOfRefs = OWN_SRC_MAX;
1566 for (i=0; i < OWN_SRC_MAX; i++)
1567 {
1568 smsShrdPrm.pSetPrm[i] = (T_SMS_SET_PRM*) elem;
1569 }
1570 }
1571 else
1572 {
1573 smsShrdPrm.pSetPrm[srcId] = (T_SMS_SET_PRM*) elem;
1574 (smsShrdPrm.pSetPrm[srcId])->numOfRefs++;
1575 }
1576 }
1577
1578 pSMSSetPrm = (T_SMS_SET_PRM*) elem;
1579 pSMSSetPrm->prflId = (UBYTE)recNr;
1580
1581 #ifndef _SIMULATION_
1582 /*
1583 *-------------------------------------------------------------
1584 * restore the service center address
1585 *-------------------------------------------------------------
1586 */
1587 pSMSSetPrm->sca.c_num = MINIMUM (smsPrfl.CSCAlenSca, MAX_SMS_ADDR_DIG);
1588 memcpy ( pSMSSetPrm->sca.num, smsPrfl.CSCAsca, pSMSSetPrm->sca.c_num);
1589 pSMSSetPrm->sca.ton = smsPrfl.CSCAton;
1590 pSMSSetPrm->sca.npi = smsPrfl.CSCAnpi;
1591 pSMSSetPrm->sca.v_ton = TRUE;
1592 pSMSSetPrm->sca.v_npi = TRUE;
1593
1594 /*
1595 *-------------------------------------------------------------
1596 * restore the text mode parameters
1597 *-------------------------------------------------------------
1598 */
1599 pSMSSetPrm->vpRel = smsPrfl.CSMPvprel;
1600 memcpy ( &pSMSSetPrm->vpAbs, smsPrfl.CSMPvpabs, SIZE_FFS_SMSPRFL_VPABS );
1601 memcpy ( &pSMSSetPrm->vpEnh, smsPrfl.CSMPvpenh, SIZE_FFS_SMSPRFL_VPENH );
1602
1603 pSMSSetPrm->msgType = smsPrfl.CSMPfo;
1604 pSMSSetPrm->pid = smsPrfl.CSMPpid;
1605 pSMSSetPrm->dcs = smsPrfl.CSMPdcs;
1606 #endif
1607 }
1608
1609 #ifndef _SIMULATION_
1610 if (access & ACI_PCM_ACCESS_CBMP)
1611 {
1612 /*
1613 *-------------------------------------------------------------
1614 * restore the cell broadcast message types and data coding
1615 * schemes
1616 *-------------------------------------------------------------
1617 */
1618 smsShrdPrm.cbmPrm.cbmMode = smsPrfl.CSCBmode;
1619
1620 { /* default setting */
1621 memset (smsShrdPrm.cbmPrm.msgId, DEF_MID_RANGE, sizeof (smsShrdPrm.cbmPrm.msgId));
1622 memset (smsShrdPrm.cbmPrm.dcsId, DEF_DCS_RANGE, sizeof(smsShrdPrm.cbmPrm.dcsId));
1623 }
1624
1625 for ( i = 0; i < MINIMUM(MAX_IDENTS,SIZE_FFS_SMSPRFL_MIDS/2); i++ )
1626 {
1627 smsShrdPrm.cbmPrm.msgId[i] = ( USHORT )smsPrfl.CSCBmids[2*i] << 8;
1628 smsShrdPrm.cbmPrm.msgId[i] |= ( USHORT )smsPrfl.CSCBmids[2*i+1];
1629 }
1630
1631 memcpy ( smsShrdPrm.cbmPrm.dcsId, smsPrfl.CSCBdcss,
1632 MINIMUM(MAX_IDENTS,SIZE_FFS_SMSPRFL_DCSS) );
1633
1634 memcpy (smsShrdPrm.cbmPrm.IMSI, smsPrfl.IMSI, MAX_IMSI);
1635 }
1636 #endif
1637 return AT_CMPL;
1638 }
1639
1640 /*
1641 +-------------------------------------------------------------------+
1642 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1643 | STATE : code ROUTINE : cmhSMS_WritePrmFFS |
1644 +-------------------------------------------------------------------+
1645
1646 PURPOSE : This function writes one record of EF_SMSPRFL_ID to FFS.
1647 The processed parameters are controlled by bits in
1648 'access'.
1649 */
1650 static T_ACI_RETURN cmhSMS_WritePrmFFS (T_ACI_CMD_SRC srcId,
1651 SHORT recNr,
1652 int access)
1653 {
1654 T_SMS_SET_PRM *pSMSSetPrm; /* points to SMS parameter set */
1655 T_ACI_FFS_SMSPRFL smsPrfl;
1656 int i;
1657 #ifndef _SIMULATION_
1658 T_FFS_RET ffs_ret;
1659 #endif
1660
1661 TRACE_FUNCTION ("cmhSMS_WritePrmFFS()");
1662
1663 if (access & ACI_PCM_ACCESS_SMSP)
1664 {
1665 if (srcId > CMD_SRC_NONE AND srcId < CMD_SRC_MAX)
1666 {
1667 pSMSSetPrm = smsShrdPrm.pSetPrm[srcId];
1668
1669 /*
1670 *-------------------------------------------------------------
1671 * save the service center address
1672 *-------------------------------------------------------------
1673 */
1674 smsPrfl.CSCAlenSca = MINIMUM ( pSMSSetPrm->sca.c_num, SIZE_FFS_SMSPRFL_SCA );
1675 memcpy ( smsPrfl.CSCAsca, pSMSSetPrm->sca.num, smsPrfl.CSCAlenSca );
1676
1677 i = (int)smsPrfl.CSCAlenSca;
1678 while ( i < SIZE_FFS_SMSPRFL_SCA )
1679 smsPrfl.CSCAsca[i++] = 0xFF;
1680
1681 smsPrfl.CSCAton = pSMSSetPrm->sca.ton;
1682 smsPrfl.CSCAnpi = pSMSSetPrm->sca.npi;
1683
1684 /*
1685 *-------------------------------------------------------------
1686 * store the text mode parameters
1687 *-------------------------------------------------------------
1688 */
1689 smsPrfl.CSMPfo = pSMSSetPrm->msgType;
1690
1691 smsPrfl.CSMPvprel = pSMSSetPrm->vpRel;
1692 memcpy ( smsPrfl.CSMPvpabs, &pSMSSetPrm->vpAbs, SIZE_FFS_SMSPRFL_VPABS );
1693 memcpy ( smsPrfl.CSMPvpenh, &pSMSSetPrm->vpEnh, SIZE_FFS_SMSPRFL_VPENH );
1694
1695 smsPrfl.CSMPpid = pSMSSetPrm->pid;
1696 smsPrfl.CSMPdcs = pSMSSetPrm->dcs;
1697
1698 /*
1699 *-------------------------------------------------------------
1700 * set the valid flag
1701 *-------------------------------------------------------------
1702 */
1703 smsPrfl.vldFlag = FFS_SMSPRFL_VLD;
1704 }
1705 else
1706 {
1707 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_UnknownErr );
1708 return AT_FAIL;
1709 }
1710 }
1711 if (access & ACI_PCM_ACCESS_CBMP)
1712 {
1713 /*
1714 *-------------------------------------------------------------
1715 * save the cell broadcast message types
1716 *-------------------------------------------------------------
1717 */
1718 smsPrfl.CSCBmode = smsShrdPrm.cbmPrm.cbmMode;
1719
1720 { /* default setting */
1721 memset (smsPrfl.CSCBmids, 0xFF, sizeof(smsPrfl.CSCBmids));
1722 memset (smsPrfl.CSCBdcss, 0xFF, sizeof(smsPrfl.CSCBdcss));
1723 }
1724
1725 for ( i = 0; i < MINIMUM(MAX_IDENTS*2,SIZE_FFS_SMSPRFL_MIDS)-1; i += 2 )
1726 {
1727 smsPrfl.CSCBmids[i] = (UBYTE)(smsShrdPrm.cbmPrm.msgId[i/2] >> 8);
1728 smsPrfl.CSCBmids[i+1] = (UBYTE)smsShrdPrm.cbmPrm.msgId[i/2];
1729 }
1730
1731 memcpy ( smsPrfl.CSCBdcss, smsShrdPrm.cbmPrm.dcsId,
1732 MINIMUM(MAX_IDENTS,SIZE_FFS_SMSPRFL_DCSS) );
1733
1734 /*
1735 * Save IMSI also in FFS
1736 */
1737 memcpy (smsPrfl.IMSI, simShrdPrm.imsi.field, simShrdPrm.imsi.c_field);
1738 smsPrfl.vldFlag = FFS_SMSPRFL_VLD;
1739 }
1740
1741 #ifndef _SIMULATION_
1742 ffs_ret = FFS_mkdir(FFS_SMSPRFL_PATH);
1743 if (ffs_ret EQ EFFS_OK)
1744 {
1745 TRACE_EVENT_P1("FFS directory \"%s\" successfully created", FFS_SMSPRFL_PATH);
1746 }
1747 else if (ffs_ret EQ EFFS_EXISTS)
1748 {
1749 TRACE_EVENT_P1("FFS directory \"%s\" already exists", FFS_SMSPRFL_PATH);
1750 }
1751 else
1752 {
1753 TRACE_EVENT_P1("error when creating FFS directory \"%s\"", FFS_SMSPRFL_PATH);
1754 }
1755
1756 ffs_ret = FFS_fwrite(ffs_smsprfl_fname[recNr-1], (void*)&smsPrfl, SIZE_FSS_SMSPRFL);
1757 if (ffs_ret NEQ EFFS_OK)
1758 {
1759 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_MemFail );
1760 TRACE_EVENT_P1("error when writing FFS object \"%s\"", ffs_smsprfl_fname[recNr-1]);
1761 return AT_FAIL;
1762 }
1763 #endif
1764
1765 return AT_CMPL;
1766 }
1767
1768 /*
1769 +-------------------------------------------------------------------+
1770 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1771 | STATE : code ROUTINE : cmhSMS_ReadParams |
1772 +-------------------------------------------------------------------+
1773
1774 PURPOSE : This function reads parameters from SIM and/or PCM.
1775 In case of AT command +CFUN the first record is read to
1776 be informed about storage capability of SIM.
1777 */
1778 GLOBAL T_ACI_RETURN cmhSMS_ReadParams (T_ACI_CMD_SRC srcId,
1779 T_ACI_AT_CMD cmd,
1780 SHORT recNr)
1781 {
1782 T_ACI_RETURN ret = AT_CMPL;
1783 int access = 0;
1784
1785 TRACE_FUNCTION ("cmhSMS_ReadParams()");
1786
1787 smsShrdPrm.smsEntStat.curCmd = cmd;
1788 smsShrdPrm.owner = (T_OWN)srcId;
1789 smsShrdPrm.smsEntStat.entOwn = srcId;
1790
1791
1792 if (cmd EQ AT_CMD_CFUN)
1793 {
1794 /* initialization */
1795
1796 /*
1797 * Always read CSCB params from FFS so that previously stored mode and dcss
1798 * can also be restored from FFS
1799 */
1800 access |= ACI_PCM_ACCESS_CBMP;
1801 /*if (!psaSIM_ChkSIMSrvSup( SRV_SMS_Parms ))*/
1802 access |= ACI_PCM_ACCESS_SMSP;
1803
1804 ret = cmhSMS_ReadPrmFFS (CMD_SRC_NONE, 1, access);
1805
1806 if (psaSIM_ChkSIMSrvSup( SRV_SMS_Parms ))
1807 {
1808 smsShrdPrm.prmRdSeq = SMS_READ_SIM_SMSP;
1809 ret = cmhSIM_ReadRecordEF (CMD_SRC_NONE, cmd, FALSE, NULL,
1810 SIM_SMSP, 1, 255,
1811 NULL, cmhSMS_InitSMSP);
1812 }
1813 else if (psaSIM_ChkSIMSrvSup( SRV_CBMIdRnge ))
1814 {
1815 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CBMIR;
1816 ret = cmhSIM_ReadTranspEF (CMD_SRC_NONE, cmd, FALSE, NULL,
1817 SIM_CBMIR, 0, 255,
1818 NULL, cmhSMS_InitSMSP);
1819 }
1820 else if (psaSIM_ChkSIMSrvSup( SRV_CBM_Ident ))
1821 {
1822 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CBMI;
1823 ret = cmhSIM_ReadTranspEF (CMD_SRC_NONE, cmd, FALSE, NULL,
1824 SIM_CBMI, 0, 255,
1825 NULL, cmhSMS_InitSMSP);
1826 }
1827 #ifdef SIM_TOOLKIT
1828 else if ((psaSIM_ChkSIMSrvSup( SRV_DtaDownlCB )) AND
1829 smsShrdPrm.owner EQ OWN_SRC_SAT )
1830 {
1831 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CBMID;
1832 ret = cmhSIM_ReadTranspEF (CMD_SRC_NONE, cmd, FALSE, NULL,
1833 SIM_CBMID, 0, 255,
1834 NULL, cmhSMS_InitSMSP);
1835 }
1836 #endif /* of SIM_TOOLKIT */
1837 }
1838 else
1839 {
1840
1841 /* TEMPORARY, ONLY FOR TEST PURPOSES: Pretend that the SIM has no SMSP !!! */
1842 /* smsShrdPrm.aci_sms_parameter.smsParamMaxRec = 0; */
1843
1844 /*
1845 * Always read CSCB params from FFS so that previously stored mode and dcss
1846 * can also be restored from FFS
1847 */
1848 /* normal operation */
1849 access |= ACI_PCM_ACCESS_CBMP;
1850 /* if (smsShrdPrm.aci_sms_parameter.smsParamMaxRec EQ 0)*/
1851 access |= ACI_PCM_ACCESS_SMSP;
1852 ret = cmhSMS_ReadPrmFFS (srcId, recNr, access);
1853
1854 if (smsShrdPrm.aci_sms_parameter.smsParamMaxRec > 0)
1855 {
1856 if (recNr <= 0
1857 OR recNr > (SHORT)smsShrdPrm.aci_sms_parameter.smsParamMaxRec)
1858 {
1859 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_InValMemIdx );
1860 ret= AT_FAIL;
1861 }
1862 else
1863 {
1864 smsShrdPrm.prmRdSeq = SMS_READ_SIM_SMSP;
1865 return cmhSIM_ReadRecordEF (CMD_SRC_NONE, cmd, FALSE, NULL, SIM_SMSP,
1866 (UBYTE)(recNr),
1867 smsShrdPrm.aci_sms_parameter.smsParamRecLen,
1868 NULL, cmhSMS_RdCnfCRES);
1869 }
1870 }
1871 if (smsShrdPrm.cbmPrm.cbmSIMmaxIdRge > 0)
1872 {
1873 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CBMIR;
1874 return cmhSIM_ReadTranspEF (CMD_SRC_NONE, cmd, FALSE, NULL, SIM_CBMIR,
1875 0, smsShrdPrm.cbmPrm.cbmSIMmaxIdRge,
1876 NULL, cmhSMS_RdCnfCRES);
1877 }
1878 if (smsShrdPrm.cbmPrm.cbmSIMmaxId > 0)
1879 {
1880 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CBMI;
1881 return cmhSIM_ReadTranspEF (CMD_SRC_NONE, cmd, FALSE, NULL, SIM_CBMI,
1882 0, smsShrdPrm.cbmPrm.cbmSIMmaxId,
1883 NULL, cmhSMS_RdCnfCRES);
1884 }
1885 }
1886 if (ret NEQ AT_EXCT)
1887 {
1888 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1889 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
1890 smsShrdPrm.smsEntStat.entOwn =CMD_SRC_NONE;
1891
1892 smsShrdPrm.cbmPrm.cbchOwner = (T_OWN)srcId;
1893 psaMMI_Cbch();
1894 smsShrdPrm.cbmPrm.cbchOwner = (T_OWN)CMD_SRC_NONE;
1895 }
1896 return ret;
1897 }
1898
1899 /*
1900 +-------------------------------------------------------------------+
1901 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1902 | STATE : code ROUTINE : cmhSMS_WriteParams |
1903 +-------------------------------------------------------------------+
1904
1905 PURPOSE : This function reads parameters from SIM and/or PCM.
1906 In case of AT command +CFUN the first record is read to
1907 be informed about storage capability of SIM.
1908 */
1909 GLOBAL T_ACI_RETURN cmhSMS_WriteParams (T_ACI_CMD_SRC srcId,
1910 T_ACI_AT_CMD cmd,
1911 SHORT recNr)
1912 {
1913 T_ACI_RETURN ret = AT_CMPL;
1914 int access = 0;
1915 UBYTE data[MAX_SIM_CMD];
1916
1917 TRACE_FUNCTION ("cmhSMS_WriteParams()");
1918
1919 smsShrdPrm.smsEntStat.curCmd = cmd;
1920 smsShrdPrm.owner = (T_OWN)srcId;
1921 smsShrdPrm.smsEntStat.entOwn = srcId;
1922
1923 /* TEMPORARY, ONLY FOR TEST PURPOSES: Pretend that the SIM has no SMSP !!! */
1924 /* smsShrdPrm.aci_sms_parameter.smsParamMaxRec = 0; */
1925
1926 /*
1927 * Always write CSCB params to FFS so that mode and dcss
1928 * can later be restored from FFS
1929 */
1930 access |= ACI_PCM_ACCESS_CBMP;
1931 /*if (smsShrdPrm.aci_sms_parameter.smsParamMaxRec EQ 0)*/
1932 access |= ACI_PCM_ACCESS_SMSP;
1933
1934 ret = cmhSMS_WritePrmFFS (srcId, recNr, access);
1935
1936 if (smsShrdPrm.aci_sms_parameter.smsParamMaxRec > 0)
1937 {
1938 if (recNr <= 0 OR recNr > (SHORT)smsShrdPrm.aci_sms_parameter.smsParamMaxRec)
1939 {
1940 ACI_ERR_DESC( ACI_ERR_CLASS_Cms, CMS_ERR_InValMemIdx );
1941 ret= AT_FAIL;
1942 }
1943 else
1944 {
1945 smsShrdPrm.prmRdSeq = SMS_READ_SIM_SMSP;
1946 cmhSMS_PutPrmSIM (srcId, data,
1947 (int)smsShrdPrm.aci_sms_parameter.smsParamRecLen);
1948 return cmhSIM_WriteRecordEF (CMD_SRC_NONE, cmd, FALSE, NULL, SIM_SMSP,
1949 (UBYTE)(recNr),
1950 smsShrdPrm.aci_sms_parameter.smsParamRecLen,
1951 data, cmhSMS_WrCnfCSAS);
1952 }
1953 }
1954 if (smsShrdPrm.cbmPrm.cbmSIMmaxIdRge > 0)
1955 {
1956 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CBMIR;
1957 cmhSMS_PutCbmirSIM (srcId, data,
1958 (int)smsShrdPrm.cbmPrm.cbmSIMmaxIdRge * 4);
1959
1960 return cmhSIM_WriteTranspEF (CMD_SRC_NONE, cmd, FALSE, NULL, SIM_CBMIR,
1961 0, (UBYTE)(smsShrdPrm.cbmPrm.cbmSIMmaxIdRge * 4),
1962 data, cmhSMS_WrCnfCSAS);
1963 }
1964 if (smsShrdPrm.cbmPrm.cbmSIMmaxId > 0)
1965 {
1966 smsShrdPrm.prmRdSeq = SMS_READ_SIM_CBMI;
1967 cmhSMS_PutCbmiSIM (srcId, data,
1968 (int)smsShrdPrm.cbmPrm.cbmSIMmaxId * 2);
1969
1970 return cmhSIM_WriteTranspEF (CMD_SRC_NONE, cmd, FALSE, NULL, SIM_CBMI,
1971 0, (UBYTE)(smsShrdPrm.cbmPrm.cbmSIMmaxId * 2),
1972 data, cmhSMS_WrCnfCSAS);
1973 }
1974 if (ret NEQ AT_EXCT)
1975 {
1976 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1977 smsShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
1978 smsShrdPrm.smsEntStat.entOwn = CMD_SRC_NONE;
1979 }
1980 return ret;
1981 }
1982
1983 /*
1984 +-------------------------------------------------------------------+
1985 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
1986 | STATE : code ROUTINE : cmhSMS_GetPrmSIM |
1987 +-------------------------------------------------------------------+
1988
1989 PURPOSE : This function extracts the parameters of one record of
1990 EF(SMSP) read from SIM.
1991 */
1992 GLOBAL BOOL cmhSMS_GetPrmSIM (T_ACI_CMD_SRC srcId,
1993 UBYTE *data,
1994 int dataLen)
1995 {
1996 T_SMS_SET_PRM *pSMSSetPrm; /* points to SMS parameter set */
1997 T_ACI_SMS_SIM_PARAMS *smsprm;
1998
1999 TRACE_FUNCTION ("cmhSMS_GetPrmSIM ()");
2000
2001 if (data NEQ NULL)
2002 {
2003 pSMSSetPrm = smsShrdPrm.pSetPrm[srcId];
2004
2005 smsprm = (T_ACI_SMS_SIM_PARAMS *)&data[(dataLen <= MIN_SMS_PRM_LEN)?
2006 0: dataLen - MIN_SMS_PRM_LEN];
2007
2008 if (smsprm->par_ind EQ NOT_PRESENT_8BIT)
2009 {
2010
2011 /* ACI-SPR-16431: reset sca number */
2012 pSMSSetPrm->sca.c_num = 0;
2013 memset(pSMSSetPrm->sca.num, 0xFF, sizeof(pSMSSetPrm->sca.num));
2014 /* end of ACI-SPR-16431: reset sca number */
2015
2016 return TRUE; /* record is empty */
2017 }
2018
2019 if ((smsprm->par_ind & SIM_SMSP_V_SCA) EQ 0)
2020 {
2021 cmh_demergeTOA (smsprm->sca_ton_npi, &pSMSSetPrm->sca.ton,
2022 &pSMSSetPrm->sca.npi);
2023 pSMSSetPrm->sca.c_num = (UBYTE)cmh_unpackBCD (pSMSSetPrm->sca.num,
2024 smsprm->sca_addr,
2025 (USHORT)(smsprm->sca_length - 1));
2026 pSMSSetPrm->sca.v_ton = TRUE;
2027 pSMSSetPrm->sca.v_npi = TRUE;
2028
2029 }
2030 if ((smsprm->par_ind & SIM_SMSP_V_PID) EQ 0)
2031 pSMSSetPrm->pid = smsprm->pid;
2032
2033 if ((smsprm->par_ind & SIM_SMSP_V_DCS) EQ 0)
2034 pSMSSetPrm->dcs = smsprm->dcs;
2035
2036 if ((smsprm->par_ind & SIM_SMSP_V_VPREL) EQ 0)
2037 {
2038 pSMSSetPrm->vpRel = smsprm->vp_rel;
2039 pSMSSetPrm->msgType &= ~TP_VPF_MASK;
2040 pSMSSetPrm->msgType |= TP_VPF_RELATIVE;
2041 }
2042 else if ((pSMSSetPrm->msgType & TP_VPF_MASK) EQ TP_VPF_RELATIVE)
2043 pSMSSetPrm->msgType &= ~TP_VPF_MASK;
2044
2045 return TRUE;
2046 }
2047 return FALSE;
2048 }
2049
2050 /*
2051 +-------------------------------------------------------------------+
2052 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
2053 | STATE : code ROUTINE : cmhSMS_PutPrmSIM |
2054 +-------------------------------------------------------------------+
2055
2056 PURPOSE : This function conbiness the parameters for one record of
2057 EF(SMSP) to be written to SIM.
2058 */
2059 GLOBAL BOOL cmhSMS_PutPrmSIM (T_ACI_CMD_SRC srcId,
2060 UBYTE *data,
2061 int maxDataLen)
2062 {
2063 T_SMS_SET_PRM *pSMSSetPrm; /* points to SMS parameter set */
2064 T_ACI_SMS_SIM_PARAMS *smsprm;
2065 size_t datalen;
2066
2067 TRACE_FUNCTION ("cmhSMS_PutPrmSIM ()");
2068
2069 if (data NEQ NULL)
2070 {
2071 pSMSSetPrm = smsShrdPrm.pSetPrm[srcId];
2072
2073 if (maxDataLen < MIN_SMS_PRM_LEN)
2074 {
2075 datalen = MIN_SMS_PRM_LEN;
2076 smsprm = (T_ACI_SMS_SIM_PARAMS *)data;
2077 }
2078 else
2079 {
2080 datalen = (size_t)maxDataLen;
2081 smsprm = (T_ACI_SMS_SIM_PARAMS *)&data[datalen - MIN_SMS_PRM_LEN];
2082 }
2083 memset (data, NOT_PRESENT_8BIT, datalen);
2084
2085 /*
2086 *-------------------------------------------------------------
2087 * set the service center address
2088 *-------------------------------------------------------------
2089 */
2090 if (pSMSSetPrm->sca.c_num > 0)
2091 {
2092 smsprm->sca_ton_npi = cmh_mergeTOA (pSMSSetPrm->sca.ton,
2093 pSMSSetPrm->sca.npi);
2094 smsprm->sca_length = (UBYTE)cmh_packBCD (smsprm->sca_addr,
2095 pSMSSetPrm->sca.num,
2096 (USHORT)MINIMUM(pSMSSetPrm->sca.c_num,
2097 MAX_SMS_ADDR_DIG)) + 1;
2098 smsprm->par_ind &= ~SIM_SMSP_V_SCA;
2099 }
2100
2101 /*
2102 *-------------------------------------------------------------
2103 * set PID, DCS and VP-REL
2104 *-------------------------------------------------------------
2105 */
2106
2107 smsprm->pid = pSMSSetPrm->pid;
2108 smsprm->par_ind &= ~SIM_SMSP_V_PID;
2109
2110 smsprm->dcs = pSMSSetPrm->dcs;
2111 smsprm->par_ind &= ~SIM_SMSP_V_DCS;
2112
2113 if ((pSMSSetPrm->msgType & TP_VPF_MASK) EQ TP_VPF_RELATIVE)
2114 {
2115 smsprm->vp_rel = pSMSSetPrm->vpRel;
2116 smsprm->par_ind &= ~SIM_SMSP_V_VPREL;
2117 }
2118 return TRUE;
2119 }
2120 return FALSE;
2121 }
2122
2123 /*
2124 +-------------------------------------------------------------------+
2125 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
2126 | STATE : code ROUTINE : cmhSMS_GetCbmirSIM |
2127 +-------------------------------------------------------------------+
2128
2129 PURPOSE : This function extracts the parameters of EF(CBMIR)
2130 read from SIM.
2131 */
2132 GLOBAL BOOL cmhSMS_GetCbmirSIM (T_ACI_CMD_SRC srcId,
2133 UBYTE *data,
2134 int dataLen)
2135 {
2136 T_ACI_CBM_SIM_MID_RANGE *mid_range;
2137 USHORT lower_mid, upper_mid;
2138 int mid_entry;
2139
2140 TRACE_FUNCTION ("cmhSMS_GetCbmirSIM ()");
2141
2142 if (data NEQ NULL)
2143 {
2144 /* Please be aware that to keep simulation test cases as less changed as
2145 possible lets assume that IMSI and CBMs stored in the FFS and from SIM
2146 card are the same, since we cannot access FFS under SIMULATION*/
2147 #ifndef _SIMULATION_
2148 /*
2149 * The CSCB parameters read from FFS should be restored only if the same SIM
2150 * is inserted ( check IMSI to ensure the same SIM), otherwise reset the CSCB
2151 * parameters to default values
2152 */
2153 if (memcmp (smsShrdPrm.cbmPrm.IMSI, simShrdPrm.imsi.field, simShrdPrm.imsi.c_field) NEQ 0)
2154 {
2155 /* Implements Measure # 9 */
2156 cmhSMS_clearCbmPrm();
2157 return FALSE;
2158 }
2159 #endif
2160 mid_range = (T_ACI_CBM_SIM_MID_RANGE *)data;
2161 mid_entry = 0;
2162
2163 while (smsShrdPrm.cbmPrm.cbmFoundIds < MAX_IDENTS/2 AND
2164 mid_entry < dataLen)
2165 {
2166 lower_mid = (USHORT)mid_range->lowerLSB |
2167 ((USHORT)mid_range->lowerMSB << 8);
2168 upper_mid = (USHORT)mid_range->upperLSB |
2169 ((USHORT)mid_range->upperMSB << 8);
2170 mid_range++;
2171 mid_entry += 4;
2172
2173 if (lower_mid NEQ NOT_PRESENT_16BIT OR
2174 upper_mid NEQ NOT_PRESENT_16BIT)
2175 {
2176 /* Please be aware that to keep simulation test cases as less changed as
2177 possible lets assume that CBMs stored in the FFS and from SIM
2178 card are the same, since we cannot access FFS under SIMULATION*/
2179 #ifndef _SIMULATION_
2180
2181 /* Implements Measure # 73 */
2182 if (!cmhSMS_findMessageIds (lower_mid, upper_mid))
2183 {
2184 return FALSE;
2185 }
2186
2187 #else /* Just for simulation - copy data, received from SIM */
2188 smsShrdPrm.cbmPrm.msgId[smsShrdPrm.cbmPrm.cbmFoundIds * 2] = lower_mid;
2189 smsShrdPrm.cbmPrm.msgId[smsShrdPrm.cbmPrm.cbmFoundIds * 2 + 1] = upper_mid;
2190 smsShrdPrm.cbmPrm.cbmFoundIds++;
2191 #endif
2192 }
2193 }
2194 return TRUE;
2195 }
2196 return FALSE;
2197 }
2198
2199 /*
2200 +-------------------------------------------------------------------+
2201 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
2202 | STATE : code ROUTINE : cmhSMS_PutCbmirSIM |
2203 +-------------------------------------------------------------------+
2204
2205 PURPOSE : This function conbines the parameters of EF(CBMIR)
2206 to be written to SIM.
2207 */
2208 GLOBAL BOOL cmhSMS_PutCbmirSIM (T_ACI_CMD_SRC srcId,
2209 UBYTE *data,
2210 int maxDataLen)
2211 {
2212 T_ACI_CBM_SIM_MID_RANGE *mid_range;
2213 USHORT lower_mid, upper_mid;
2214 int mid_entry;
2215
2216 TRACE_FUNCTION ("cmhSMS_PutCbmirSIM ()");
2217
2218 if (data NEQ NULL)
2219 {
2220 memset (data, NOT_PRESENT_8BIT, maxDataLen);
2221
2222 mid_range = (T_ACI_CBM_SIM_MID_RANGE *)data;
2223 mid_entry = 0;
2224
2225 while (smsShrdPrm.cbmPrm.cbmFoundIds < MAX_IDENTS/2 AND
2226 mid_entry < maxDataLen)
2227 {
2228 lower_mid = smsShrdPrm.cbmPrm.msgId[smsShrdPrm.cbmPrm.cbmFoundIds * 2];
2229 upper_mid = smsShrdPrm.cbmPrm.msgId[smsShrdPrm.cbmPrm.cbmFoundIds * 2 + 1];
2230 smsShrdPrm.cbmPrm.cbmFoundIds++;
2231
2232 if (lower_mid NEQ NOT_PRESENT_16BIT OR
2233 upper_mid NEQ NOT_PRESENT_16BIT)
2234 {
2235 mid_range->lowerLSB = (UBYTE)lower_mid;
2236 mid_range->lowerMSB = (UBYTE)(lower_mid >> 8);
2237 mid_range->upperLSB = (UBYTE)upper_mid;
2238 mid_range->upperMSB = (UBYTE)(upper_mid >> 8);
2239 mid_range++;
2240 mid_entry += 4;
2241 }
2242 }
2243 return TRUE;
2244 }
2245 return FALSE;
2246 }
2247
2248 /*
2249 +-------------------------------------------------------------------+
2250 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
2251 | STATE : code ROUTINE : cmhSMS_GetCbmiSIM |
2252 +-------------------------------------------------------------------+
2253
2254 PURPOSE : This function extracts the parameters of one record of
2255 EF(SMSP) read from SIM.
2256 */
2257 GLOBAL BOOL cmhSMS_GetCbmiSIM (T_ACI_CMD_SRC srcId,
2258 UBYTE *data,
2259 int dataLen)
2260 {
2261 T_ACI_CBM_SIM_MID_LIST **mid_list;
2262 USHORT mid;
2263 int mid_entry;
2264
2265 TRACE_FUNCTION ("cmhSMS_GetCbmiSIM ()");
2266
2267 if (data NEQ NULL)
2268 {
2269
2270 /* Please be aware that to keep simulation test cases as less changed as
2271 possible lets assume that IMSI and CBMs stored in the FFS and from SIM
2272 card are the same, since we cannot access FFS under SIMULATION*/
2273 #ifndef _SIMULATION_
2274 /*
2275 * The CSCB parameters read from FFS should be restored only if the same SIM
2276 * is inserted ( check IMSI to ensure the same SIM), otherwise reset the CSCB
2277 * parameters to default values
2278 */
2279 if (memcmp (smsShrdPrm.cbmPrm.IMSI, simShrdPrm.imsi.field, simShrdPrm.imsi.c_field) NEQ 0)
2280 {
2281 /* Implements Measure # 9 */
2282 cmhSMS_clearCbmPrm();
2283 return FALSE;
2284 }
2285 #endif
2286 mid_list = (T_ACI_CBM_SIM_MID_LIST **)&data;
2287 mid_entry = 0;
2288
2289 while (smsShrdPrm.cbmPrm.cbmFoundIds < MAX_IDENTS/2 AND
2290 mid_entry < dataLen)
2291 {
2292 mid = (USHORT)(*mid_list)->LSB |
2293 ((USHORT)(*mid_list)->MSB << 8);
2294 data += 2; /* overcome TI alignment problem */
2295 mid_entry += 2;
2296
2297 if (mid NEQ NOT_PRESENT_16BIT)
2298 {
2299 /* Please be aware that to keep simulation test cases as less changed as
2300 possible lets assume that CBMs stored in the FFS and from SIM
2301 card are the same, since we cannot access FFS under SIMULATION*/
2302 #ifndef _SIMULATION_
2303
2304 /* Implements Measure # 73 */
2305 if (!cmhSMS_findMessageIds (mid, mid))
2306 {
2307 return FALSE;
2308 }
2309
2310 #else /* Just for simulation - copy data, received from SIM */
2311 smsShrdPrm.cbmPrm.msgId[smsShrdPrm.cbmPrm.cbmFoundIds * 2] =
2312 smsShrdPrm.cbmPrm.msgId[smsShrdPrm.cbmPrm.cbmFoundIds * 2 + 1] = mid;
2313 smsShrdPrm.cbmPrm.cbmFoundIds++;
2314 #endif
2315 }
2316 }
2317 return TRUE;
2318 }
2319 return FALSE;
2320 }
2321
2322 /*
2323 +-------------------------------------------------------------------+
2324 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
2325 | STATE : code ROUTINE : cmhSMS_PutCbmiSIM |
2326 +-------------------------------------------------------------------+
2327
2328 PURPOSE : This function conbines the parameters of EF(CBMI)
2329 to be written to SIM.
2330 */
2331 GLOBAL BOOL cmhSMS_PutCbmiSIM (T_ACI_CMD_SRC srcId,
2332 UBYTE *data,
2333 int maxDataLen)
2334 {
2335 T_ACI_CBM_SIM_MID_LIST **mid_list;
2336 USHORT lower_mid, upper_mid;
2337 UBYTE mid_entry;
2338
2339 TRACE_FUNCTION ("cmhSMS_PutCbmiSIM ()");
2340
2341 if (data NEQ NULL)
2342 {
2343 memset (data, NOT_PRESENT_8BIT, maxDataLen);
2344
2345 mid_list = (T_ACI_CBM_SIM_MID_LIST **)&data;
2346 mid_entry = 0;
2347
2348 while (smsShrdPrm.cbmPrm.cbmFoundIds < MAX_IDENTS/2 AND
2349 mid_entry < maxDataLen)
2350 {
2351 lower_mid = smsShrdPrm.cbmPrm.msgId[smsShrdPrm.cbmPrm.cbmFoundIds * 2];
2352 upper_mid = smsShrdPrm.cbmPrm.msgId[smsShrdPrm.cbmPrm.cbmFoundIds * 2 + 1];
2353 smsShrdPrm.cbmPrm.cbmFoundIds++;
2354
2355 if (lower_mid NEQ NOT_PRESENT_16BIT OR
2356 upper_mid NEQ NOT_PRESENT_16BIT)
2357 {
2358 while (lower_mid <= upper_mid AND mid_entry < maxDataLen)
2359 {
2360 (*mid_list)->LSB = (UBYTE)lower_mid;
2361 (*mid_list)->MSB = (UBYTE)(lower_mid >> 8);
2362 lower_mid++;
2363 data += 2; /* overcome TI alignment problem */
2364 mid_entry += 2;
2365 }
2366 }
2367 }
2368 return TRUE;
2369 }
2370 return FALSE;
2371 }
2372
2373 #ifdef SIM_TOOLKIT
2374
2375 /*
2376 +-------------------------------------------------------------------+
2377 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
2378 | STATE : code ROUTINE : cmhSMS_FileUpdate |
2379 +-------------------------------------------------------------------+
2380
2381 PURPOSE : This function processes the primitive SIM_FILE_UPDATE_IND
2382 to update the SMS parameters stored on the SIM.
2383 */
2384 GLOBAL BOOL cmhSMS_FileUpdate (int ref, T_SIM_FILE_UPDATE_IND *fu)
2385 {
2386 BOOL found = FALSE;
2387 int i;
2388
2389 TRACE_FUNCTION ("cmhSMS_FileUpdate ()");
2390
2391 for (i = 0; i < (int)fu->val_nr; i++)
2392 {
2393 if (!found AND
2394 (fu->file_info[i].v_path_info EQ TRUE AND
2395 fu->file_info[i].path_info.df_level1 EQ SIM_DF_GSM AND
2396 fu->file_info[i].path_info.v_df_level2 EQ FALSE AND
2397 (fu->file_info[i].datafield EQ SIM_CBMI OR
2398 fu->file_info[i].datafield EQ SIM_CBMIR OR
2399 fu->file_info[i].datafield EQ SIM_CBMID)) OR
2400
2401 (fu->file_info[i].v_path_info EQ TRUE AND
2402 fu->file_info[i].path_info.df_level1 EQ SIM_DF_TELECOM AND
2403 fu->file_info[i].path_info.v_df_level2 EQ FALSE AND
2404 fu->file_info[i].datafield EQ SIM_SMSP))
2405 {
2406 found = TRUE;
2407 }
2408 if (fu->file_info[i].v_path_info EQ TRUE AND
2409 fu->file_info[i].path_info.df_level1 EQ SIM_DF_TELECOM AND
2410 fu->file_info[i].path_info.v_df_level2 EQ FALSE AND
2411 fu->file_info[i].datafield EQ SIM_SMS)
2412 {
2413 smsShrdPrm.aci_sms_parameter.simTotal = 0;
2414 smsShrdPrm.aci_sms_parameter.simUsed = 0;
2415 }
2416 }
2417 if (found)
2418 {
2419 smsShrdPrm.cbmPrm.cbmFoundIds = 0; /* new CBMI(R) */
2420
2421 if (cmhSMS_ReadParams ((T_ACI_CMD_SRC)OWN_SRC_SAT, AT_CMD_CFUN, 1) EQ AT_EXCT)
2422 {
2423 smsShrdPrm.accessEnabled = FALSE;
2424
2425 simShrdPrm.fuRef = ref;
2426 return FALSE; /* reading files */
2427 }
2428 else
2429 return TRUE; /* nothing to do */
2430 }
2431 else
2432 {
2433 simShrdPrm.fuRef = -1; /* nothing to do */
2434 return TRUE;
2435 }
2436 }
2437
2438 /*
2439 +-------------------------------------------------------------------+
2440 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
2441 | STATE : code ROUTINE : cmhSMS_GetCbDtaDwnlSIM |
2442 +-------------------------------------------------------------------+
2443
2444 PURPOSE : This function extracts the parameters of CBMID record of
2445 EF(CBMID) read from SIM.
2446 */
2447 GLOBAL BOOL cmhSMS_GetCbDtaDwnlSIM (T_ACI_CMD_SRC srcId,
2448 UBYTE *data,
2449 int dataLen)
2450 {
2451 T_ACI_CBM_SIM_MID_LIST **mid_list;
2452 USHORT mid;
2453 int mid_entry;
2454
2455 TRACE_FUNCTION ("cmhSMS_GetCbDtaDwnlSIM ()");
2456
2457 if (data NEQ NULL)
2458 {
2459 smsShrdPrm.cbmPrm.CBDtaDwnlFoundIds = 0;
2460 memset (smsShrdPrm.cbmPrm.CBDtaDwnlIdent, NOT_PRESENT_8BIT,
2461 sizeof (smsShrdPrm.cbmPrm.CBDtaDwnlIdent));
2462
2463 mid_list = (T_ACI_CBM_SIM_MID_LIST **)&data;
2464 mid_entry = 0;
2465
2466 while (smsShrdPrm.cbmPrm.CBDtaDwnlFoundIds < MAX_IDENTS_SAT AND
2467 mid_entry < dataLen)
2468 {
2469 mid = (USHORT)(*mid_list)->LSB |
2470 ((USHORT)(*mid_list)->MSB << 8);
2471 data += 2; /* overcome TI alignment problem */
2472 mid_entry += 2;
2473
2474 if (mid NEQ NOT_PRESENT_16BIT)
2475 {
2476 smsShrdPrm.cbmPrm.CBDtaDwnlIdent[smsShrdPrm.cbmPrm.CBDtaDwnlFoundIds] = mid;
2477 smsShrdPrm.cbmPrm.CBDtaDwnlFoundIds++;
2478 }
2479 }
2480 return TRUE;
2481 }
2482 return FALSE;
2483 }
2484
2485 #endif /*of SIM_TOOLKIT */
2486
2487
2488
2489
2490 /*
2491 +--------------------------------------------------------------------+
2492 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
2493 | STATE : code ROUTINE : cmhSMS_decodeMsg |
2494 +--------------------------------------------------------------------+
2495
2496 PURPOSE : decodes a SM in two steps
2497
2498 */
2499 GLOBAL UBYTE* cmhSMS_decodeMsg (T_sms_sdu *sms_sdu, T_rp_addr* rp_addr,
2500 UBYTE vt_mti)
2501 {
2502 UBYTE ccdRet;
2503 UBYTE direction;
2504 UBYTE recover_from_error;
2505
2506 BUF_tpdu sim_buf; /* source for the second decoding */
2507
2508 TRACE_FUNCTION("cmhSMS_decodeMsg ()");
2509
2510 if( sms_sdu->l_buf EQ 0)
2511 {
2512 TRACE_EVENT("empty SDU: no decoding");
2513 return(NULL);
2514 }
2515
2516 CCD_START;
2517 {
2518
2519 MCAST( sim_pdu, SIM_PDU ); /* sim_pdu points to _decodedMsg */
2520 /*memset( sim_pdu, 0, sizeof (T_SIM_PDU) ); */
2521
2522 /* decoding outer layer */
2523 ccdRet = ccd_decodeMsg ( CCDENT_SMS,
2524 BOTH /* doesn't work with DOWNLINK!!! */,
2525 (T_MSGBUF *) sms_sdu,
2526 (UBYTE *) _decodedMsg, /* target */
2527 SMS_VT_SIM_PDU);
2528
2529 if ( (ccdRet NEQ ccdOK) OR (!sim_pdu->v_tpdu)
2530 OR (_decodedMsg[0] NEQ SMS_VT_SIM_PDU) )
2531 {
2532 TRACE_EVENT_P1("CCD Decoding Error: %d", ccdRet);
2533 CCD_END;
2534 return NULL;
2535 }
2536
2537 memcpy(rp_addr, &sim_pdu->rp_addr, sizeof(T_rp_addr) );
2538
2539 memcpy(&sim_buf, &sim_pdu->tpdu, sizeof(BUF_tpdu) );
2540
2541 /*memset( _decodedMsg, 0, sizeof (T_TP_SUBMIT) ); */
2542
2543 if (vt_mti EQ SMS_VT_SUBMIT)
2544 {
2545 /* for decoding of SMS-SUBMIT (in response to +CMGR, +CMGL) */
2546 direction = UPLINK;
2547 }
2548 else
2549 {
2550 direction = DOWNLINK;
2551 }
2552
2553 /* decoding inner layer */
2554 ccdRet = ccd_decodeMsg ( CCDENT_SMS,
2555 direction,
2556 (T_MSGBUF *) &sim_buf,
2557 (UBYTE *) _decodedMsg, /* target */
2558 vt_mti );
2559
2560 if (ccdRet EQ ccdWarning)
2561 recover_from_error = TRUE; /* Try to recover if a ccdWarning occoured */
2562 else
2563 recover_from_error = FALSE;
2564
2565 if ((ccdRet EQ ccdError) OR (ccdRet EQ ccdWarning))
2566 {
2567 UBYTE ccd_err;
2568 USHORT parlist [6];
2569
2570 TRACE_EVENT_P1 ("ccd_decodeMsg(): %02x", ccdRet);
2571 /*
2572 * get the first error
2573 */
2574 ccd_err = ccd_getFirstError (CCDENT_SMS, parlist);
2575
2576 /*
2577 * Error Handling
2578 */
2579 do
2580 {
2581 #ifndef NTRACE /* save some ROM */
2582 /* Implements Measure#32: Row 1080,...,1093 */
2583 if (ccdRet EQ ccdError)
2584 {
2585 TRACE_EVENT_P1 ("ERR: %u ", ccd_err);
2586 }
2587 else if (ccdRet EQ ccdWarning)
2588 {
2589 TRACE_EVENT_P1 ("WRN: %u ", ccd_err);
2590 }
2591 switch (ccd_err)
2592 {
2593 case ERR_NO_MORE_ERROR:
2594 TRACE_EVENT("the end of the error list is reached");
2595 break;
2596 case ERR_INVALID_CALC:
2597 TRACE_EVENT("calculation of the element repeat value failed");
2598 break;
2599 case ERR_PATTERN_MISMATCH:
2600 TRACE_EVENT("a bit pattern was not expected");
2601 break;
2602 case ERR_COMPREH_REQUIRED:
2603 TRACE_EVENT("check for comprehension required failed");
2604 break;
2605 case ERR_IE_NOT_EXPECTED:
2606 TRACE_EVENT("an information element was not expected");
2607 break;
2608 case ERR_IE_SEQUENCE:
2609 TRACE_EVENT("wrong sequence of information elements");
2610 break;
2611 case ERR_MAX_IE_EXCEED:
2612 TRACE_EVENT("maximum amount of repeatable information elements has exceeded");
2613 break;
2614 case ERR_MAX_REPEAT:
2615 TRACE_EVENT("a repeatable element occurs too often in the message");
2616 break;
2617 case ERR_MAND_ELEM_MISS:
2618 TRACE_EVENT("a mandatory information element is missing");
2619 break;
2620 case ERR_INVALID_MID:
2621 TRACE_EVENT("the message ID is not correct");
2622 break;
2623 case ERR_INVALID_TYPE:
2624 TRACE_EVENT("the information element is not a spare padding");
2625 break;
2626 case ERR_EOC_TAG_MISSING:
2627 TRACE_EVENT("indefinite length is specified for the ASN.1-BER but the end tag is missing");
2628 break;
2629 case ERR_INTERNAL_ERROR:
2630 TRACE_EVENT("an internal CCD error occured ");
2631 break;
2632 default:
2633 TRACE_EVENT("unknown error");
2634 break;
2635 }
2636 #endif /* NTRACE */
2637
2638 if (ccdRet EQ ccdWarning)
2639 {
2640 switch (ccd_err)
2641 {
2642 case ERR_PATTERN_MISMATCH: /* recoverable warnings */
2643 case ERR_COMPREH_REQUIRED:
2644 case ERR_INTERNAL_ERROR:
2645 break;
2646 default:
2647 recover_from_error = FALSE; /* in all other cases reset the recover flag */
2648 }
2649 }
2650
2651 ccd_err = ccd_getNextError (CCDENT_SMS, parlist);
2652 }while (ccd_err NEQ ERR_NO_MORE_ERROR);
2653 }
2654
2655 if ( (ccdRet EQ ccdError) OR
2656 ((ccdRet EQ ccdWarning) AND (recover_from_error EQ FALSE)) OR /* not possible to recover */
2657 (_decodedMsg[0] NEQ vt_mti) )
2658 {
2659 TRACE_EVENT_P1("CCD Decoding Error Stage 2: %d", ccdRet);
2660 CCD_END;
2661 return NULL;
2662 }
2663 else if ((ccdRet EQ ccdWarning) AND (recover_from_error EQ TRUE))
2664 {
2665 TRACE_EVENT ("recovered from warning");
2666 }
2667 }
2668 CCD_END;
2669
2670 return _decodedMsg;
2671 }
2672
2673
2674
2675 /*
2676 +--------------------------------------------------------------------+
2677 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
2678 | STATE : code ROUTINE : cmhSMS_codeMsg |
2679 +--------------------------------------------------------------------+
2680
2681 PURPOSE : encodes a SM in two steps
2682
2683 */
2684 GLOBAL void cmhSMS_codeMsg (T_sms_sdu *sms_sdu, UBYTE tp_vt_mti,
2685 T_rp_addr* sc_addr, UBYTE tp_mti,
2686 UBYTE* decoded_pdu )
2687 {
2688 BUF_tpdu sim_buf; /* target for first coding */
2689 UBYTE direction;
2690
2691 TRACE_FUNCTION ("cmhSMS_codeMsg()");
2692
2693
2694 CCD_START;
2695 {
2696 UBYTE ccdRet;
2697
2698 MCAST( sim_pdu, SIM_PDU );
2699
2700 /* source of outer encoding */
2701 memset( sim_pdu, 0, sizeof (T_SIM_PDU) );
2702
2703 /* target of outer encoding */
2704 /* memset( sms_sdu, 0, sizeof (T_sms_sdu) ); */
2705 sms_sdu->o_buf = 0;
2706 sms_sdu->l_buf = SIM_PDU_LEN << 3;
2707
2708 sim_pdu->tp_vt_mti = SMS_VT_SIM_PDU;
2709 sim_pdu->tp_mti = tp_mti;
2710
2711 /* service center address exists */
2712 if (sc_addr)
2713 {
2714 memcpy(&sim_pdu->rp_addr, sc_addr, sizeof(T_rp_addr));
2715 sim_pdu->rp_addr.v_ton = 1;
2716 sim_pdu->rp_addr.v_npi = 1;
2717 }
2718
2719 /* pdu data exists */
2720 if (decoded_pdu)
2721 {
2722 /* target of inner encoding */
2723 /* memset(sim_buf, 0, sizeof(BUF_tpdu)); */
2724 sim_buf.o_tpdu = 0;
2725 //TISH modified for MSIM
2726 //TISH: l_tpdu should be lenth of sim_buf.b_tpdu not BUF_tpdu.
2727 // sim_buf.l_tpdu = (sizeof(BUF_tpdu)) << 3;
2728 sim_buf.l_tpdu = (sizeof(sim_buf.b_tpdu)) << 3;
2729
2730 if (tp_vt_mti EQ SMS_VT_DELIVER)
2731 {
2732 /* for encoding of SMS-DELIVER (only in +CMGW) */
2733 direction = DOWNLINK;
2734 }
2735 else
2736 {
2737 direction = UPLINK;
2738 }
2739
2740 /* encoding inner layer */
2741 ccdRet = ccd_codeMsg (CCDENT_SMS,
2742 direction,
2743 (T_MSGBUF *) &sim_buf, /* target */
2744 (UBYTE *) decoded_pdu,
2745 tp_vt_mti);
2746
2747 if ( ccdRet NEQ ccdOK )
2748 {
2749 TRACE_EVENT_P1("CCD Coding Error: %d", ccdRet);
2750 CCD_END;
2751 return;
2752 }
2753 if (sim_buf.l_tpdu EQ 0)
2754 {
2755 TRACE_EVENT("Encoded length is zero");
2756 }
2757
2758 memcpy(&sim_pdu->tpdu, &sim_buf, sizeof(BUF_tpdu));
2759 sim_pdu->v_tpdu = 1; /* set validy flag */
2760 }
2761
2762 /* encoding outer layer */
2763 ccdRet = ccd_codeMsg (CCDENT_SMS,
2764 UPLINK,
2765 (T_MSGBUF *) sms_sdu, /* target */
2766 (UBYTE *) sim_pdu,
2767 SMS_VT_SIM_PDU);
2768
2769 if ( ccdRet NEQ ccdOK )
2770 {
2771 TRACE_EVENT_P1("CCD Coding Error: %d", ccdRet);
2772 CCD_END;
2773 return;
2774 }
2775 if (sms_sdu->l_buf EQ 0)
2776 {
2777 TRACE_EVENT("Encoded length is zero");
2778 }
2779 }
2780 CCD_END;
2781 }
2782
2783
2784
2785 /*
2786 +--------------------------------------------------------------------+
2787 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
2788 | STATE : code ROUTINE : cmhSMS_cpyDeliver |
2789 +--------------------------------------------------------------------+
2790
2791 PURPOSE : converts a SMS-DELIVER message to the T_ACI_CMGL_SM
2792 structure
2793
2794 */
2795 GLOBAL BOOL cmhSMS_cpyDeliver ( T_ACI_CMGL_SM * sm, T_sms_sdu * sms_sdu )
2796 {
2797 T_rp_addr rp_addr;
2798 UBYTE* message;
2799 T_TP_DELIVER *sms_deliver;
2800 UBYTE alphabet;
2801
2802 TRACE_FUNCTION("cmhSMS_cpyDeliver()");
2803
2804 message = cmhSMS_decodeMsg(sms_sdu, &rp_addr, SMS_VT_DELIVER);
2805
2806 if (message EQ NULL)
2807 {
2808 sm->stat = SMS_STAT_Invalid;
2809 return (FALSE);
2810 }
2811
2812 if ( message[0] NEQ SMS_VT_DELIVER)
2813 {
2814 TRACE_EVENT_P1("wrong VTI = %x", message[0]);
2815 }
2816
2817 sms_deliver = (T_TP_DELIVER*)message;
2818
2819 /*
2820 *-----------------------------------------------------------------
2821 * process originator address
2822 *-----------------------------------------------------------------
2823 */
2824 /* Implements Measure # 126 */
2825 /* Since T_tp_oa and T_tp_da are of same type, there is no problem in
2826 passing sms_deliver->tp_oa */
2827 cmhSMS_processOrigDestAddr (sm,
2828 &rp_addr,
2829 &sms_deliver->tp_oa);
2830
2831 /*
2832 *-----------------------------------------------------------------
2833 * process first octet
2834 *-----------------------------------------------------------------
2835 */
2836 sm -> fo = sms_sdu->buf[sms_sdu->buf[0] + 1];
2837
2838 /*
2839 *-----------------------------------------------------------------
2840 * process protocol identifier
2841 *-----------------------------------------------------------------
2842 */
2843 sm -> pid = sms_deliver->tp_pid;
2844
2845 /*
2846 *-----------------------------------------------------------------
2847 * process data coding scheme
2848 *-----------------------------------------------------------------
2849 */
2850 sm -> dcs = sms_deliver->tp_dcs;
2851
2852
2853 /*
2854 *-----------------------------------------------------------------
2855 * process short message data, expanding from 7 to 8 bit
2856 *-----------------------------------------------------------------
2857 */
2858
2859 if (sms_deliver->v_tp_ud)
2860 {
2861 /* user data */
2862 cmhSMS_expdSmsPp ( 0,
2863 sms_deliver->tp_dcs,
2864 sms_deliver->tp_ud.data,
2865 sms_deliver->tp_ud.length,
2866 sm -> data.data,
2867 &sm->data.len );
2868
2869 sm->udh.len = 0;
2870 }
2871 else
2872 {
2873 alphabet = cmhSMS_getAlphabetPp ( sms_deliver->tp_dcs );
2874
2875 /* user data header */
2876 memcpy (sm->udh.data, sms_deliver->tp_udh_inc.tp_udh.data,
2877 sms_deliver->tp_udh_inc.tp_udh.c_data);
2878 sm->udh.len = sms_deliver->tp_udh_inc.tp_udh.c_data;
2879
2880 /* user data (only user data can be 7bit data!!!) */
2881 cmhSMS_expdSmsPp ( (UBYTE)(sm->udh.len+1),
2882 sms_deliver->tp_dcs,
2883 sms_deliver->tp_udh_inc.data,
2884 sms_deliver->tp_udh_inc.length, /* ACI-SPR-9440 */
2885 sm->data.data,
2886 &sm->data.len );
2887
2888 /* 7-bit data */
2889 if (alphabet EQ 0x00)
2890 {
2891 sm->data.len = sms_deliver->tp_udh_inc.length - ((sm->udh.len+1)*8)/7;
2892
2893 /* minus space for the fill bits */
2894 if (((sm->udh.len+1)*8)%7 NEQ 0) sm->data.len--;
2895 }
2896 /* 8-bit data */
2897 else
2898 {
2899 sm->data.len = sms_deliver->tp_udh_inc.length-(sm->udh.len+1);
2900 }
2901 }
2902
2903 /*
2904 *-----------------------------------------------------------------
2905 * process service center time stamp
2906 *-----------------------------------------------------------------
2907 */
2908 sm -> vp_rel = 0;
2909 memset ( &sm->vp_enh, 0, sizeof(T_ACI_VP_ENH) );
2910
2911 cmhSMS_setVpabsCmh ( &sm -> scts,
2912 (T_tp_vp_abs*) &sms_deliver->tp_scts );
2913
2914 return (TRUE);
2915 }
2916
2917
2918 /*
2919 +--------------------------------------------------------------------+
2920 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
2921 | STATE : code ROUTINE : cmhSMS_cpySubmit |
2922 +--------------------------------------------------------------------+
2923
2924 PURPOSE : converts a SMS-SUBMIT message to the T_ACI_CMGL_SM
2925 structure
2926
2927 */
2928 GLOBAL BOOL cmhSMS_cpySubmit ( T_ACI_CMGL_SM * sm, T_sms_sdu * sms_sdu )
2929 {
2930 T_rp_addr rp_addr;
2931 UBYTE* message;
2932 T_TP_SUBMIT *sms_submit;
2933 UBYTE alphabet;
2934
2935 TRACE_FUNCTION("cmhSMS_cpySubmit()");
2936
2937 message = cmhSMS_decodeMsg(sms_sdu, &rp_addr, SMS_VT_SUBMIT);
2938
2939 if (message EQ NULL)
2940 {
2941 sm->stat = SMS_STAT_Invalid;
2942 return (FALSE);
2943 }
2944
2945 if ( message[0] NEQ SMS_VT_SUBMIT)
2946 {
2947 TRACE_EVENT_P1("wrong VTI = %x", message[0]);
2948 }
2949
2950 sms_submit = (T_TP_SUBMIT*)message;
2951
2952
2953 /*
2954 *-----------------------------------------------------------------
2955 * process recepient address
2956 *-----------------------------------------------------------------
2957 */
2958 /* Implements Measure # 126 */
2959 cmhSMS_processOrigDestAddr (sm,
2960 &rp_addr,
2961 &sms_submit->tp_da);
2962
2963 /*
2964 *-----------------------------------------------------------------
2965 * process first octet
2966 *-----------------------------------------------------------------
2967 */
2968 sm -> fo = sms_sdu->buf[sms_sdu->buf[0] + 1];
2969
2970 /*
2971 *-----------------------------------------------------------------
2972 * process protocol identifier
2973 *-----------------------------------------------------------------
2974 */
2975 sm -> pid = sms_submit->tp_pid;
2976
2977 /*
2978 *-----------------------------------------------------------------
2979 * process data coding scheme
2980 *-----------------------------------------------------------------
2981 */
2982 sm -> dcs = sms_submit->tp_dcs;
2983
2984 /*
2985 *-----------------------------------------------------------------
2986 * process short message data, expanding from 7 to 8 bit
2987 *-----------------------------------------------------------------
2988 */
2989
2990 if (sms_submit->v_tp_ud)
2991 {
2992 /* user data */
2993 cmhSMS_expdSmsPp ( 0,
2994 sms_submit->tp_dcs,
2995 sms_submit->tp_ud.data,
2996 sms_submit->tp_ud.length, /* ACI-SPR-9440 */
2997 sm->data.data,
2998 &sm->data.len );
2999
3000 sm->udh.len = 0;
3001 }
3002 else
3003 {
3004 alphabet = cmhSMS_getAlphabetPp ( sms_submit->tp_dcs );
3005
3006 /* user data header */
3007 memcpy (sm->udh.data, sms_submit->tp_udh_inc.tp_udh.data,
3008 sms_submit->tp_udh_inc.tp_udh.c_data);
3009 sm->udh.len = sms_submit->tp_udh_inc.tp_udh.c_data;
3010
3011 /* user data (only user data can be 7bit data!!!) */
3012 cmhSMS_expdSmsPp ( (UBYTE)(sm->udh.len+1),
3013 sms_submit->tp_dcs,
3014 sms_submit->tp_udh_inc.data,
3015 sms_submit->tp_udh_inc.length, /* ACI-SPR-9440 */
3016 sm->data.data,
3017 &sm->data.len );
3018
3019 /* 7-bit data */
3020 if (alphabet EQ 0x00)
3021 {
3022 sm->data.len = sms_submit->tp_udh_inc.length - ((sm->udh.len+1)*8)/7;
3023
3024 /* minus space for the fill bits */
3025 if (((sm->udh.len+1)*8)%7 NEQ 0) sm->data.len--;
3026 }
3027 /* 8-bit data */
3028 else
3029 {
3030 sm->data.len = sms_submit->tp_udh_inc.length-(sm->udh.len+1);
3031 }
3032 }
3033
3034 /*
3035 *-----------------------------------------------------------------
3036 * process validity period
3037 *-----------------------------------------------------------------
3038 */
3039 if (sms_submit->v_tp_vp_abs)
3040 {
3041 cmhSMS_setVpabsCmh ( &sm->scts, &sms_submit->tp_vp_abs );
3042 sm -> vp_rel = 0;
3043 memset ( &sm->vp_enh, 0, sizeof(T_ACI_VP_ENH) );
3044 }
3045 else if (sms_submit->v_tp_vp_enh)
3046 {
3047 cmhSMS_setVpenhCmh ( &sm->vp_enh, &sms_submit->tp_vp_enh );
3048 sm -> vp_rel = 0;
3049 memset ( &sm->scts, 0, sizeof(T_ACI_VP_ABS) );
3050 }
3051 else
3052 {
3053 sm -> vp_rel = sms_submit->tp_vp_rel;
3054 memset ( &sm -> scts, 0, sizeof(T_ACI_VP_ABS) );
3055 memset ( &sm -> vp_enh, 0, sizeof(T_ACI_VP_ENH) );
3056 }
3057 return (TRUE);
3058 }
3059
3060 /* Implements Measure # 110 */
3061
3062 /*
3063 +--------------------------------------------------------------------+
3064 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
3065 | STATE : code ROUTINE : cmhSMS_cpyStatInd |
3066 +--------------------------------------------------------------------+
3067
3068 PURPOSE : handles a status indication
3069
3070 */
3071 GLOBAL BOOL cmhSMS_cpyStatInd ( T_ACI_CDS_SM * sm,
3072 T_MNSMS_STATUS_IND *mnsms_status_ind )
3073 {
3074 T_rp_addr rp_addr;
3075 UBYTE* message;
3076 T_TP_STATUS *sms_status;
3077
3078 TRACE_FUNCTION("cmhSMS_cpyStatInd()");
3079
3080 message = cmhSMS_decodeMsg(&mnsms_status_ind->sms_sdu, &rp_addr, SMS_VT_STATUS);
3081
3082 if (message EQ NULL)
3083 {
3084 return (FALSE);
3085 }
3086
3087 if ( message[0] NEQ SMS_VT_STATUS)
3088 {
3089 TRACE_EVENT_P1("wrong VTI = %x", message[0]);
3090 }
3091
3092 sms_status = (T_TP_STATUS*)message;
3093
3094
3095 /*
3096 *-----------------------------------------------------------------
3097 * process message type
3098 *-----------------------------------------------------------------
3099 */
3100 sm -> fo = mnsms_status_ind->sms_sdu.buf[mnsms_status_ind->sms_sdu.buf[0]+1];
3101
3102 /*
3103 *-----------------------------------------------------------------
3104 * process message reference
3105 *-----------------------------------------------------------------
3106 */
3107 sm -> msg_ref = sms_status->tp_mr;
3108
3109 /*
3110 *-----------------------------------------------------------------
3111 * process recipient address
3112 *-----------------------------------------------------------------
3113 */
3114 cmhSMS_getAdrStr ( sm->addr,
3115 MAX_SMS_ADDR_DIG - 1,
3116 sms_status->tp_ra.num,
3117 sms_status->tp_ra.digits);
3118
3119 sm->toa.ton = cmhSMS_getTon ( sms_status->tp_ra.ton );
3120 sm->toa.npi = cmhSMS_getNpi ( sms_status->tp_ra.npi );
3121
3122 /*
3123 *-----------------------------------------------------------------
3124 * process service center time stamp
3125 *-----------------------------------------------------------------
3126 */
3127 cmhSMS_setVpabsCmh ( &sm->vpabs_scts, (T_tp_vp_abs*) &sms_status->tp_scts );
3128
3129 /*
3130 *-----------------------------------------------------------------
3131 * process discharge time
3132 *-----------------------------------------------------------------
3133 */
3134 cmhSMS_setVpabsCmh ( &sm->vpabs_dt, (T_tp_vp_abs*) &sms_status->tp_dt );
3135
3136 /*
3137 *-----------------------------------------------------------------
3138 * process status
3139 *-----------------------------------------------------------------
3140 */
3141 sm -> tp_status = sms_status->tp_st;
3142
3143 return (TRUE);
3144 }
3145
3146
3147 /*
3148 +--------------------------------------------------------------------+
3149 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
3150 | STATE : code ROUTINE : cmhSMS_getPhbEntry |
3151 +--------------------------------------------------------------------+
3152
3153 PURPOSE : gets phone book entry from coded SM
3154
3155 */
3156 GLOBAL void cmhSMS_getPhbEntry( UBYTE *buf,
3157 T_ACI_PB_TEXT *alpha,
3158 T_ACI_SMS_STAT status )
3159 {
3160 UBYTE *p_data;
3161 UBYTE sca_len;
3162 UBYTE nplan;
3163 UBYTE no_bcd;
3164 UBYTE bcd[MAX_SMS_ADDR_DIG];
3165 CHAR addr[MAX_SMS_ADDR_DIG+1]; /* for '\0' */
3166 USHORT octets;
3167
3168 alpha->len = 0;
3169
3170 p_data = &buf[0];
3171 sca_len = buf[0];
3172
3173 switch (status)
3174 {
3175 case SMS_STAT_RecUnread:
3176 case SMS_STAT_RecRead:
3177 if ((*(p_data+sca_len+1) & TP_MTI_MASK) EQ TP_MTI_SMS_STATUS_REP)
3178 {
3179 p_data++;
3180 }
3181 p_data += (sca_len+1) + 1; /* sms-deliver */
3182 break;
3183 case SMS_STAT_StoUnsent:
3184 case SMS_STAT_StoSent:
3185 p_data += (sca_len+1) + 2; /* sms-submit */
3186 break;
3187 default:
3188 return;
3189 }
3190
3191 /* process originator/destination address */
3192 no_bcd = *p_data++;
3193 no_bcd = MINIMUM(no_bcd, MAX_SMS_ADDR_DIG);
3194
3195 nplan = *p_data++ & 0x0F; /* npi */
3196
3197 octets = (no_bcd+1)/2;
3198
3199 no_bcd = (UBYTE)cmh_unpackBCD (bcd, p_data, octets);
3200
3201 if (nplan EQ 0x05) /* VO patch - if (patch) else ... */
3202 {
3203 UBYTE i,j = 0;
3204 for (i = 0 ; i < no_bcd; i=i+2)
3205 {
3206 addr[j] = (UBYTE)(bcd[i+1] << 4) + (UBYTE)(bcd[i]);
3207 j++;
3208 }
3209 addr[j] = '\0';
3210 }
3211 else
3212 {
3213 cmhSMS_getAdrStr ( addr,
3214 MAX_SMS_ADDR_DIG,
3215 bcd,
3216 no_bcd );
3217 }
3218
3219 /*
3220 *-----------------------------------------------------------------
3221 * process alphanumerical phonebook entry
3222 *-----------------------------------------------------------------
3223 */
3224 psaCC_phbMfwSrchNumPlnTxt ( addr, alpha );
3225 }
3226
3227
3228 /*
3229 +--------------------------------------------------------------------+
3230 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
3231 | STATE : code ROUTINE : cmhSMS_codeDelRep |
3232 +--------------------------------------------------------------------+
3233
3234 PURPOSE : codes RP-ACK for SMS-DELIVER-REPORT (without PID, DCS, UD)
3235
3236 */
3237 GLOBAL void cmhSMS_codeDelRep(T_sms_sdu *sms_sdu, T_rp_addr *sc_addr)
3238 {
3239 UBYTE sca_len; /* SCA len incl. length byte and toa */
3240 UBYTE sca_buf[MAX_SMS_ADDR_DIG/2 + 2];
3241
3242 sca_len = CodeRPAddress( sca_buf,
3243 sc_addr->c_num,
3244 sc_addr->ton,
3245 sc_addr->npi,
3246 sc_addr->num );
3247
3248 sms_sdu->l_buf = (sca_len+2)<<3;
3249 sms_sdu->o_buf = 0;
3250
3251 memcpy ( sms_sdu->buf, sca_buf, sca_len);
3252 memset ( sms_sdu->buf+sca_len, 0, 2);
3253 }
3254
3255
3256 /*
3257 +--------------------------------------------------------------------+
3258 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
3259 | STATE : code ROUTINE : CodeRPAddress |
3260 +--------------------------------------------------------------------+
3261
3262 PURPOSE : converts address (in BCD format) to semi-octet representation
3263 (including address-length, ton and npi),
3264 for RP addresses (e.g SCA)
3265
3266 returns number of octets including address-length,
3267 ton and npi
3268
3269 */
3270 GLOBAL UBYTE CodeRPAddress( UBYTE *buf, UBYTE numDigits, UBYTE ton,
3271 UBYTE npi, UBYTE *bcd )
3272 {
3273 UBYTE length;
3274
3275 if (numDigits EQ 0)
3276 {
3277 length = 1;
3278 *buf = 0x00;
3279 }
3280 else
3281 {
3282 *buf++ = (numDigits+1)/2 + 1;
3283 *buf++ = (ton << 4) + npi + 0x80;
3284
3285 length = (UBYTE)cmh_packBCD ( buf, bcd, numDigits );
3286
3287 /* add length of length field, ton and npi */
3288 length += 2;
3289 }
3290
3291 return length;
3292 }
3293
3294
3295 /*
3296 +--------------------------------------------------------------------+
3297 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
3298 | STATE : code ROUTINE : CodeTPAddress |
3299 +--------------------------------------------------------------------+
3300
3301 PURPOSE : converts address (in BCD format) to semi-octet representation
3302 (including address-length, ton and npi),
3303 for TP addresses (e.g OA or DA)
3304
3305 returns number of octets including including address-length,
3306 ton and npi
3307
3308 */
3309 GLOBAL UBYTE CodeTPAddress( UBYTE *buf, UBYTE numDigits, UBYTE ton,
3310 UBYTE npi, UBYTE *bcd )
3311 {
3312 UBYTE length;
3313
3314 *buf++ = numDigits;
3315 *buf++ = (ton << 4) + npi + 0x80;
3316
3317 length = (UBYTE)cmh_packBCD ( buf, bcd, numDigits );
3318
3319 /* add length of length field, to and npi */
3320 length += 2;
3321
3322 return length;
3323 }
3324
3325
3326 /*
3327 +--------------------------------------------------------------------+
3328 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
3329 | STATE : code ROUTINE : DecodeRPAddress |
3330 +--------------------------------------------------------------------+
3331
3332 PURPOSE : converts RP address (SC address) from semi-octet
3333 representation to address in BCD format (including
3334 address-length, ton and npi)
3335
3336 returns number of processed octets in buf
3337
3338 */
3339 GLOBAL UBYTE DecodeRPAddress(UBYTE *c_num, UBYTE *ton,
3340 UBYTE *npi, UBYTE *bcd, UBYTE *buf)
3341 {
3342 UBYTE sca_length; /* sca length is lenth in bytes plus TOA-octet */
3343 UBYTE processed_octets;
3344
3345 sca_length = *buf++;
3346 *ton = (*buf & 0x70)>>4;
3347 *npi = *buf++ & 0x0F;
3348
3349 *c_num = (UBYTE)cmh_unpackBCD (bcd, buf, (USHORT)(sca_length-1));
3350
3351 processed_octets = (*c_num+1)/2 + 2;
3352
3353 return processed_octets;
3354 }
3355
3356 /*
3357 +--------------------------------------------------------------------+
3358 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
3359 | STATE : code ROUTINE : DecodeTPAddress |
3360 +--------------------------------------------------------------------+
3361
3362 PURPOSE : converts TP address (DA, OA)from semi-octet
3363 representation to address in BCD format (including
3364 address-length, ton and npi)
3365
3366 returns number of processed octets in buf
3367
3368 */
3369 GLOBAL UBYTE DecodeTPAddress(UBYTE *c_num, UBYTE *ton,
3370 UBYTE *npi, UBYTE *bcd, UBYTE *buf)
3371 {
3372 UBYTE digits;
3373 UBYTE processed_octets;
3374
3375 digits = *buf++;
3376 *ton = (*buf & 0x70)>>4;
3377 *npi = *buf++ & 0x0F;
3378
3379 *c_num = (UBYTE)cmh_unpackBCD (bcd, buf, (USHORT)((digits+1)/2));
3380
3381 processed_octets = (*c_num+1)/2 + 2;
3382
3383 return processed_octets;
3384 }
3385
3386
3387
3388
3389 /*
3390 +--------------------------------------------------------------------+
3391 | PROJECT : MODULE : CMH_SMSF |
3392 | STATE : code ROUTINE : cmhSMS_fillTpSubmit |
3393 +--------------------------------------------------------------------+
3394
3395 PURPOSE : fills a T_TP_SUBMIT
3396
3397 */
3398 GLOBAL void cmhSMS_fillTpSubmit (T_TP_SUBMIT* tp_submit,
3399 T_ACI_CMD_SRC srcId,
3400 UBYTE msgType,
3401 UBYTE mr,
3402 T_tp_da* da_addr,
3403 T_ACI_SM_DATA* data,
3404 UBYTE septets,
3405 T_ACI_UDH_DATA* udh )
3406 {
3407 T_SMS_SET_PRM * pSMSSetPrm; /* points to SMS parameter set */
3408 UBYTE alphabet;
3409
3410 TRACE_FUNCTION ("cmhSMS_fillTpSubmit()");
3411
3412 pSMSSetPrm = smsShrdPrm.pSetPrm[srcId];
3413
3414 memset(tp_submit, 0, sizeof(T_TP_SUBMIT));
3415
3416 tp_submit->tp_vt_mti = SMS_VT_SUBMIT;
3417 tp_submit->tp_rp = (msgType & TP_RP_MASK) ? 1 : 0;
3418 tp_submit->tp_mti = SMS_SUBMIT;
3419 tp_submit->tp_mr = mr;
3420 tp_submit->tp_srr = (msgType & TP_SRR_MASK) ? 1 : 0;
3421
3422 if (da_addr->digits NEQ 0x00)
3423 memcpy(&tp_submit->tp_da, da_addr, sizeof(T_tp_da));
3424
3425 tp_submit->tp_pid = pSMSSetPrm -> pid;
3426 tp_submit->tp_dcs = pSMSSetPrm -> dcs;
3427
3428 switch (msgType & VPF_MASK)
3429 {
3430
3431 case VPF_RELATIVE: /* validity period relative */
3432 tp_submit->v_tp_vp_rel = 1;
3433 tp_submit->tp_vpf = SMS_VPF_RELATIVE;
3434 tp_submit->tp_vp_rel = pSMSSetPrm -> vpRel;
3435 break;
3436
3437 case VPF_ABSOLUTE: /* validity period absolute */
3438 tp_submit->v_tp_vp_abs = 1;
3439 tp_submit->tp_vpf = SMS_VPF_ABSOLUTE;
3440 memcpy(&tp_submit->tp_vp_abs, &pSMSSetPrm -> vpAbs, sizeof(T_tp_vp_abs));
3441 break;
3442
3443 case VPF_ENHANCED: /* validity period enhanced */
3444 tp_submit->v_tp_vp_enh = 1;
3445 tp_submit->tp_vpf = SMS_VPF_ENHANCED;
3446 memcpy(&tp_submit->tp_vp_enh, &pSMSSetPrm -> vpEnh, sizeof(T_tp_vp_enh));
3447 break;
3448
3449 default: /* validity period not present */
3450 break;
3451 }
3452
3453
3454 alphabet = cmhSMS_getAlphabetPp ( pSMSSetPrm -> dcs );
3455
3456 if ((udh) AND (udh->len))
3457 {
3458 tp_submit->tp_udhi = 1;
3459 tp_submit->v_tp_udh_inc = 1;
3460 tp_submit->tp_udh_inc.tp_udh.c_data = udh->len;
3461 memcpy(tp_submit->tp_udh_inc.tp_udh.data, udh->data, udh->len);
3462
3463 /* copy user data */
3464 if ((data) AND (data->len))
3465 {
3466 tp_submit->tp_udh_inc.c_data = data->len;
3467 memcpy(tp_submit->tp_udh_inc.data, data->data, data->len);
3468 }
3469
3470 /* 7-bit data */
3471 if (alphabet EQ 0x00)
3472 {
3473 tp_submit->tp_udh_inc.length = septets + (((udh->len+1)*8)/7);
3474
3475 /* space for the fill bits */
3476 if (((udh->len+1)*8)%7 NEQ 0)
3477 {
3478 tp_submit->tp_udh_inc.length++;
3479 if ((data EQ NULL) OR (data->len EQ 0))
3480 {
3481 tp_submit->tp_udh_inc.c_data = 1;
3482 tp_submit->tp_udh_inc.data[0] = 0; /* redundant */
3483 }
3484 }
3485 }
3486 /* 8-bit data */
3487 else
3488 {
3489 tp_submit->tp_udh_inc.length = tp_submit->tp_udh_inc.c_data+udh->len+1; /* UDH length should be also added */
3490 }
3491 }
3492 else
3493 {
3494 /* validity flag set for both normal SMS and empty SMS */
3495 tp_submit->v_tp_ud = 1;
3496
3497 if ((data) AND (data->len))
3498 {
3499 tp_submit->tp_ud.length = septets;
3500 tp_submit->tp_ud.c_data = data->len;
3501 memcpy(tp_submit->tp_ud.data, data->data, data->len);
3502 }
3503 else
3504 {
3505 /* enters when zero character SMS to be sent */
3506 }
3507 }
3508 }
3509
3510
3511
3512 /*
3513 +--------------------------------------------------------------------+
3514 | PROJECT : MODULE : CMH_SMSF |
3515 | STATE : code ROUTINE : cmhSMS_fillTpDeliver |
3516 +--------------------------------------------------------------------+
3517
3518 PURPOSE : fills a T_TP_DELIVER (only used by +CMGW)
3519
3520 */
3521 GLOBAL void cmhSMS_fillTpDeliver (T_TP_DELIVER* tp_deliver,
3522 T_ACI_CMD_SRC srcId,
3523 UBYTE msgType,
3524 T_tp_oa* oa_addr,
3525 T_ACI_SM_DATA* data,
3526 UBYTE septets,
3527 T_ACI_UDH_DATA* udh )
3528 {
3529 T_SMS_SET_PRM * pSMSSetPrm; /* points to SMS parameter set */
3530 UBYTE alphabet;
3531
3532 TRACE_FUNCTION ("cmhSMS_fillTpDeliver()");
3533
3534 pSMSSetPrm = smsShrdPrm.pSetPrm[srcId];
3535
3536 memset(tp_deliver, 0, sizeof(T_TP_DELIVER));
3537
3538 tp_deliver->tp_vt_mti = SMS_VT_DELIVER;
3539 tp_deliver->tp_rp = (msgType & TP_RP_MASK) ? 1 : 0;
3540 tp_deliver->tp_mti = SMS_DELIVER;
3541
3542 if (oa_addr->digits NEQ 0x00)
3543 memcpy(&tp_deliver->tp_oa, oa_addr, sizeof(T_tp_oa));
3544
3545 tp_deliver->tp_pid = pSMSSetPrm -> pid;
3546 tp_deliver->tp_dcs = pSMSSetPrm -> dcs;
3547
3548 memcpy(&tp_deliver->tp_scts, &pSMSSetPrm -> vpAbs, sizeof(T_tp_scts));
3549
3550 if ((data) AND (data->len))
3551 {
3552 alphabet = cmhSMS_getAlphabetPp ( pSMSSetPrm -> dcs );
3553
3554 if ((udh) AND (udh->len))
3555 {
3556 tp_deliver->tp_udhi = 1;
3557 tp_deliver->v_tp_udh_inc = 1;
3558 tp_deliver->tp_udh_inc.tp_udh.c_data = udh->len;
3559 memcpy(tp_deliver->tp_udh_inc.tp_udh.data, udh->data, udh->len);
3560
3561 /* copy user data */
3562 tp_deliver->tp_udh_inc.c_data = data->len;
3563 memcpy(tp_deliver->tp_udh_inc.data, data->data, data->len);
3564
3565 /* 7-bit data */
3566 if (alphabet EQ 0x00)
3567 {
3568 tp_deliver->tp_udh_inc.length = septets + (((udh->len+1)*8)/7);
3569
3570 /* space for the fill bits */
3571 if (((udh->len+1)*8)%7 NEQ 0) tp_deliver->tp_udh_inc.length++;
3572 }
3573 /* 8-bit data */
3574 else
3575 {
3576 tp_deliver->tp_udh_inc.length = tp_deliver->tp_udh_inc.c_data;
3577 }
3578 }
3579 else
3580 {
3581 tp_deliver->v_tp_ud = 1;
3582 tp_deliver->tp_ud.length = septets;
3583 tp_deliver->tp_ud.c_data = data->len;
3584 memcpy(tp_deliver->tp_ud.data, data->data, data->len);
3585 }
3586 }
3587 else /* if ((data) AND (data->len)) */
3588 {
3589 tp_deliver->v_tp_ud = 1;
3590 tp_deliver->tp_ud.length = 0;
3591 }
3592 }
3593
3594
3595 /*
3596 +--------------------------------------------------------------------+
3597 | PROJECT : MODULE : CMH_SMSF |
3598 | STATE : code ROUTINE : cmhSMS_fillTpCommand |
3599 +--------------------------------------------------------------------+
3600
3601 PURPOSE : fills a T_TP_COMMAND
3602
3603 */
3604 GLOBAL void cmhSMS_fillTpCommand ( T_TP_COMMAND* tp_command,
3605 UBYTE fo,
3606 UBYTE ct,
3607 UBYTE mr,
3608 UBYTE pid,
3609 UBYTE mn,
3610 T_tp_da* da_addr,
3611 T_ACI_CMD_DATA* data,
3612 T_ACI_UDH_DATA* udh)
3613
3614 {
3615 TRACE_FUNCTION ("cmhSMS_fillTpCommand()");
3616
3617 memset(tp_command, 0, sizeof(T_TP_COMMAND));
3618
3619 tp_command->tp_vt_mti = SMS_VT_COMMAND;
3620 tp_command->tp_srr = (fo & TP_SRR_MASK) ? 1 : 0;
3621 tp_command->tp_mti = SMS_COMMAND;
3622 tp_command->tp_mr = mr;
3623 tp_command->tp_pid = pid;
3624 tp_command->tp_ct = ct;
3625 tp_command->tp_mn = mn;
3626
3627 if (da_addr->digits NEQ 0x00)
3628 memcpy(&tp_command->tp_da, da_addr, sizeof(T_tp_da));
3629
3630 if ((data) AND (data->len))
3631 {
3632 if ((udh) AND (udh->len))
3633 {
3634 tp_command->tp_udhi = 1;
3635 tp_command->v_tp_cdh_inc = 1;
3636 tp_command->tp_cdh_inc.tp_udh.c_data = udh->len;
3637 memcpy(tp_command->tp_cdh_inc.tp_udh.data, udh->data, udh->len);
3638 tp_command->tp_cdh_inc.c_data = data->len;
3639 memcpy(tp_command->tp_cdh_inc.data, data->data, data->len);
3640 }
3641 else
3642 {
3643 tp_command->v_tp_cd = 1;
3644 tp_command->tp_cd.c_data = data->len;
3645 memcpy(tp_command->tp_cd.data, data->data, data->len);
3646 }
3647 }
3648 else
3649 {
3650 /* command length field must be present */
3651 tp_command->v_tp_cd = 1;
3652 tp_command->tp_cd.c_data = 0;
3653 }
3654
3655 }
3656 #ifdef FF_CPHS
3657
3658 /*
3659 +----------------------------------------------------------------------+
3660 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
3661 | ROUTINE : cmhSMS_check_voice_mail_ind|
3662 +----------------------------------------------------------------------+
3663
3664 PURPOSE :
3665 */
3666
3667 LOCAL BOOL cmhSMS_check_voice_mail_ind( T_TP_DELIVER *sms_deliver )
3668 {
3669 TRACE_FUNCTION("cmhSMS_check_voice_mail_ind()");
3670
3671 if ( sms_deliver->tp_oa.digits NEQ 4 OR
3672 sms_deliver->tp_oa.ton NEQ SMS_TON_ALPHANUMERIC )
3673 {
3674 TRACE_EVENT_P2("no vmi -> oa... digits:%d ton:%d",
3675 sms_deliver->tp_oa.digits, sms_deliver->tp_oa.ton);
3676 return FALSE;
3677 }
3678
3679 switch (sms_deliver->tp_dcs & 0xF0)
3680 {
3681 case SMS_DCS_GRP_DEF:
3682 case SMS_DCS_GRP_CLASS:
3683 if ( (sms_deliver->tp_dcs & 0xF) EQ 0 OR
3684 (sms_deliver->tp_dcs & 0xF) EQ 0xC )
3685 {
3686 break; /* GSM Default Alphabet */
3687 }
3688 /* no break, if FALSE */
3689 /*lint -fallthrough*/
3690 case SMS_DCS_GRP_COMPR:
3691 case SMS_DCS_GRP_CLASS_COMPR:
3692 case SMS_DCS_GRP_MW_STORE_UCS2:
3693 TRACE_EVENT_P1("no vmi -> dcs: %d", sms_deliver->tp_dcs);
3694 return FALSE; /* no GSM Default Alphabet */
3695 case SMS_DCS_DATA_CLASS:
3696 if (sms_deliver->tp_dcs & 0x4)
3697 {
3698 TRACE_EVENT_P1("no vmi -> dcs: %d", sms_deliver->tp_dcs);
3699 return FALSE; /* no GSM Default Alphabet */
3700 }
3701 }
3702
3703 if (!sms_deliver->v_tp_ud)
3704 {
3705 TRACE_EVENT("no vmi -> no ud");
3706 return FALSE; /* not only text present */
3707 }
3708 if ( ( sms_deliver->tp_ud.length NEQ 1 ) OR
3709 ( (sms_deliver->tp_ud.data[0] & 0x7F) NEQ ' ') )
3710 {
3711 TRACE_EVENT_P2("no vmi -> ud... length:%d data[0]:%d",
3712 sms_deliver->tp_ud.length, sms_deliver->tp_ud.data[0]);
3713 return FALSE; /* no single space */
3714 }
3715
3716 TRACE_FUNCTION ("CPHS VWI: send to cphs module");
3717
3718 return TRUE;
3719 }
3720
3721
3722 /*
3723 +-------------------------------------------------------------------------+
3724 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
3725 | ROUTINE : cmhSMS_voice_mail_ind_get_line|
3726 +-------------------------------------------------------------------------+
3727
3728 PURPOSE :
3729 */
3730 LOCAL void cmhSMS_voice_mail_ind_get_data( T_TP_DELIVER *sms_deliver,
3731 UBYTE *flag_set,
3732 T_CPHS_LINES *line )
3733 {
3734 TRACE_FUNCTION("cmhSMS_voice_mail_ind_get_line()");
3735
3736 /* get flag set, which is send in the first bit of the first
3737 byte of the originating address number. Due to the decoding
3738 each byte of the originating address number is now splitted
3739 into 2 bytes, so that the first 4 bits of the former first
3740 byte can be found in byte 1 */
3741 *flag_set = sms_deliver->tp_oa.num[0] & 0x1;
3742
3743 /* line is coded in character 1 bit 1 of second byte of GSM originating
3744 address based on 7bit default alphabet. In the message indication we
3745 get the data in the last bit of the first byte of the orginating address.
3746 Due to the decoding each byte of the originating address number is now
3747 splitted into 2 bytes, so that the last 4 bits of the former first
3748 byte can be found in byte 2 */
3749
3750 if (sms_deliver->tp_oa.num[1] & 0x8)
3751
3752 {
3753 *line = CPHS_LINE2;
3754 }
3755 else
3756 {
3757 *line = CPHS_LINE1;
3758 }
3759 }
3760
3761
3762 /*
3763 +----------------------------------------------------------------------+
3764 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
3765 | ROUTINE : cmhSMS_voice_mail_ind |
3766 +----------------------------------------------------------------------+
3767
3768 PURPOSE :
3769 */
3770
3771 GLOBAL BOOL cmhSMS_voice_mail_ind( T_sms_sdu *sms_sdu)
3772 {
3773 T_TP_DELIVER *sms_deliver;
3774 T_rp_addr rp_addr;
3775 T_CPHS_LINES line;
3776 UBYTE flag_set;
3777 UBYTE *message;
3778
3779 TRACE_FUNCTION("cmhSMS_voice_mail_ind()");
3780
3781 /* check if cphs is active */
3782
3783
3784 /* check if indication is voice mail indication */
3785 if ( sms_sdu )
3786 {
3787 message = cmhSMS_decodeMsg(sms_sdu, &rp_addr, SMS_VT_DELIVER);
3788
3789 if (message EQ NULL)
3790 return FALSE;
3791
3792 if ( message[0] NEQ SMS_VT_DELIVER)
3793 {
3794 TRACE_EVENT_P1("wrong VTI = %x", message[0]);
3795 }
3796
3797 sms_deliver = (T_TP_DELIVER*)message;
3798
3799 if ( cphs_check_status() EQ CPHS_OK )
3800 {
3801 if ( cmhSMS_check_voice_mail_ind(sms_deliver) )
3802 {
3803 cmhSMS_voice_mail_ind_get_data(sms_deliver, &flag_set, &line);
3804
3805 cphs_voice_mail_ind(flag_set, line);
3806
3807 return TRUE;
3808 }
3809 }
3810 }
3811 return FALSE;
3812 }
3813
3814 #endif /* FF_CPHS*/
3815
3816
3817 /*
3818 +----------------------------------------------------------------------+
3819 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
3820 | ROUTINE : cmhSMS_resetMtDsCnmiParam |
3821 +----------------------------------------------------------------------+
3822 PURPOSE : this function resets the <mt> and <ds> parameter for the
3823 SMS acknowledge in Phase2+ mode (+CNMA).
3824 */
3825 GLOBAL void cmhSMS_resetMtDsCnmiParam(void)
3826 {
3827 smsShrdPrm.mtHndl = 0; /* reset <mt> and <ds> param in error case */
3828 smsShrdPrm.srHndl = 0;
3829
3830 smsShrdPrm.CNMImt = CNMI_MT_NoSmsDeliverInd;
3831 smsShrdPrm.CNMIds = CNMI_DS_NoSmsStatRpt;
3832 /* Implements measure 149 */
3833 cmhSMS_sendConfigureReq (FALSE);
3834 }
3835
3836 /*
3837 +-------------------------------------------------------------------+
3838 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSS |
3839 | STATE : code ROUTINE : sAT_PlusCMGWPdu |
3840 +-------------------------------------------------------------------+
3841
3842 PURPOSE : This is the internal function which is responsible for
3843 storing messages into the mobile station or SIM card.
3844 AT command which is responsible for writing a short
3845 message to memory in PDU mode.
3846 */
3847 GLOBAL BOOL cmhSMS_storePduToSim( T_ACI_CMD_SRC srcId,
3848 UBYTE stat,
3849 T_ACI_SM_DATA *pdu )
3850 {
3851 T_ACI_RETURN ret;
3852
3853 TRACE_FUNCTION ("cmhSMS_storePduToSim()");
3854
3855 /* check if command executable */
3856 if(!cmhSMS_checkAccess (srcId, &ret))
3857 {
3858 return FALSE;
3859 }
3860
3861 {
3862 PALLOC (mnsms_store_req, MNSMS_STORE_REQ);
3863
3864 mnsms_store_req -> mem_type = smsShrdPrm.mem2;
3865 mnsms_store_req -> rec_num = CMGW_IDX_FREE_ENTRY;
3866 mnsms_store_req -> condx = SMS_CONDX_OVR_NON;
3867 mnsms_store_req -> status = stat;
3868
3869 if ( (pdu->len > 0) AND (pdu->len <= SIM_PDU_LEN) )
3870 {
3871 mnsms_store_req->sms_sdu.l_buf = pdu->len * 8;
3872 mnsms_store_req->sms_sdu.o_buf = 0;
3873 memcpy (mnsms_store_req->sms_sdu.buf, pdu->data, pdu->len);
3874 }
3875 else
3876 {
3877 TRACE_FUNCTION ("cmhSMS_storePduToSim() : wrong PDU len");
3878 PFREE (mnsms_store_req);
3879 return FALSE;
3880 }
3881
3882 PSENDX (SMS, mnsms_store_req);
3883 }
3884
3885 smsShrdPrm.smsEntStat.curCmd = AT_CMD_CMGW;
3886 smsShrdPrm.owner = (T_OWN)srcId;
3887 smsShrdPrm.smsEntStat.entOwn = srcId;
3888 smsShrdPrm.uiInternalSmsStorage = srcId;
3889
3890 return TRUE;
3891 }
3892
3893 /*
3894 +--------------------------------------------------------------------+
3895 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
3896 | STATE : code ROUTINE : cmhSMS_removeStatusRFUBits |
3897 +--------------------------------------------------------------------+
3898
3899 PURPOSE : ACI-SPR-17004: Method for removing of SMS RFU status
3900 bits as defined by GSM 11.11 section 9.3
3901
3902 */
3903 GLOBAL void cmhSMS_removeStatusRFUBits ( UBYTE* status )
3904 {
3905 TRACE_FUNCTION("cmhSMS_removeStatusRFUBits()");
3906
3907 /* See GSM 11.11 section 10.5.3 for position of RFU bits in status */
3908
3909 /* test the pattern of the three lowest bits, match for "101" */
3910 if ((*status & 0x07) EQ 0x05)
3911 {
3912 /* set the highest three bits to 0 */
3913 *status &= 0x1F;
3914 }
3915 else
3916 {
3917 /* set the highest five bits to 0 */
3918 *status &= 0x07;
3919 }
3920
3921 }
3922
3923 /*
3924 +-------------------------------------------------------------------------+
3925 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
3926 | STATE : code ROUTINE : cmhSMS_convertDeliverStatusToACI|
3927 +-------------------------------------------------------------------------+
3928
3929 PURPOSE : converts the SMS delivery status to ACI CPRSM status.
3930
3931 */
3932 GLOBAL T_ACI_CPRSM_MOD cmhSMS_convertDeliverStatusToACI ( UBYTE status )
3933 {
3934 T_ACI_CPRSM_MOD mode;
3935
3936 TRACE_FUNCTION("cmhSMS_convertDeliverStatusToACI()");
3937
3938 switch (status)
3939 {
3940 case SMS_DELIVER_STATUS_PAUSE:
3941 mode = CPRSM_MOD_Pause;
3942 break;
3943 case SMS_DELIVER_STATUS_RESUME:
3944 mode = CPRSM_MOD_Resume;
3945 break;
3946 default:
3947 mode = CPRSM_MOD_NotPresent;
3948 }
3949 return mode;
3950 }
3951
3952 #ifdef FF_CPHS_REL4
3953 /*
3954 +-------------------------------------------------------------------------+
3955 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
3956 | STATE : code ROUTINE : cmhSMS_chk_WtngInd |
3957 +-------------------------------------------------------------------------+
3958
3959 PURPOSE : This function expect an already decoded SMS in the T_TP_DELIVER
3960 format and checks if it is a "special SMS" (refer to TS 23.040,
3961 chpt. 9.2.3.24.2).
3962
3963 */
3964 LOCAL BOOL cmhSMS_chk_WtngInd( T_TP_DELIVER *pSms )
3965 {
3966
3967 TRACE_FUNCTION("cmhSMS_chk_WtngInd");
3968 return ( (pSms->tp_udhi) AND /* it is an UDH message */
3969 (pSms->v_tp_udh_inc) AND /* UDH successfuly decoded */
3970 (pSms->tp_udh_inc.tp_udh.c_data >= 4) AND /* min len of special SMS */
3971 (pSms->tp_udh_inc.tp_udh.data[0] EQ 0x01)
3972 );
3973 }
3974
3975
3976 /*
3977 +-------------------------------------------------------------------------+
3978 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
3979 | STATE : code ROUTINE : cmhSMS_chk_SpclMsg |
3980 +-------------------------------------------------------------------------+
3981
3982 PURPOSE : This function checks if the received SMS is a special sms which
3983 indicates the message waiting status.If so,the message will be processed
3984 and TRUE will be returned,indicating that the message was already handled.
3985 If it is no special message , the function will returns FALSE causing the
3986 SMS to be treated in the common way.
3987
3988 */
3989
3990 GLOBAL BOOL cmhSMS_chk_SpclMsg( T_MNSMS_MESSAGE_IND *mnsms_message_ind )
3991 {
3992 BOOL res = FALSE ;
3993 T_MSG_WAITING_TYPE msgType = MSG_WAITING_TYPE_INVALID;
3994 U8 *ptr;
3995 T_TP_DELIVER *smDlvr;
3996
3997 TRACE_FUNCTION( "cmhSMS_chk_SpclMsg()" );
3998
3999 if(!psaSIM_ChkSIMSrvSup( SRV_No_54 ))
4000 {
4001 return res;
4002 }
4003
4004 if (&mnsms_message_ind->sms_sdu)
4005 {
4006 T_rp_addr rpAddr;
4007 UBYTE *pMsg;
4008
4009 pMsg = cmhSMS_decodeMsg( &mnsms_message_ind->sms_sdu, &rpAddr, SMS_VT_DELIVER );
4010 smDlvr = (T_TP_DELIVER *)pMsg;
4011
4012 if (pMsg)
4013 {
4014 if (pMsg[0] NEQ SMS_VT_DELIVER)
4015 {
4016 TRACE_EVENT_P1( "wrong VTI = %x", (int)pMsg[0] );
4017 }
4018
4019 /* Check the reqired fields in the SMS to qaulify for Special Message */
4020
4021 if (cmhSMS_chk_WtngInd( smDlvr ))
4022 {
4023
4024 /* For Loop: Decode the SMS properly as ,more than one type of message
4025 can be indicated within one SMS message. A varible for
4026 tp_udh_inc.tp_udh.data has been avoided , therefore For loop
4027 seems to be lengthy,
4028 */
4029 for( ptr = smDlvr->tp_udh_inc.tp_udh.data ;
4030 ptr < &smDlvr->tp_udh_inc.tp_udh.data[smDlvr->tp_udh_inc.tp_udh.c_data ];
4031 ptr +=(ptr[1] + 2 ))
4032 {
4033 /* Filling the Message Type */
4034
4035 msgType = (ptr[2] & 0x03); /* see TS 23.040 */
4036
4037 /* Update Status field in EF-MWIS according to the values already
4038 present in the SIM and the current values in the recieved SMS.
4039 Also if the count for any type of Special SMS is ZERO then
4040 also update the status.
4041 */
4042 if( (!(smsShrdPrm.MWISdata.mwiStat >> msgType & 1U)) OR (ptr[3] EQ 0) )
4043 {
4044 smsShrdPrm.MWISdata.mwiStat ^= 1U << msgType;
4045 }
4046
4047 /* Filling the count for specfic type of SMS */
4048
4049 switch ( msgType )
4050 {
4051 case MSG_WAITING_TYPE_VOICE :
4052 smsShrdPrm.MWISdata.mwis_count_voice = ptr[3];
4053 break;
4054 case MSG_WAITING_TYPE_FAX :
4055 smsShrdPrm.MWISdata.mwis_count_fax = ptr[3];
4056 break;
4057 case MSG_WAITING_TYPE_EMAIL :
4058 smsShrdPrm.MWISdata.mwis_count_email = ptr[3];
4059 break;
4060 case MSG_WAITING_TYPE_OTHER :
4061 smsShrdPrm.MWISdata.mwis_count_other = ptr[3];
4062 break;
4063 default:
4064 TRACE_EVENT("INVALID MESSAGE TYPE");
4065 return FALSE;
4066 }
4067 }
4068
4069 /* Writing decoded data to EF-MWIS */
4070
4071 if(cmhSIM_WrMwis(CMD_SRC_NONE,MWIS_MOD_Write,1,
4072 &smsShrdPrm.MWISdata) NEQ AT_EXCT )
4073 {
4074 TRACE_EVENT(" Error in Sending the Sim Update Request ");
4075 }
4076
4077 /* If message was stored we need to indicate this, too */
4078
4079 if (mnsms_message_ind->rec_num NEQ SMS_RECORD_NOT_EXIST)
4080 {
4081 cmhSMS_SMSMemory( mnsms_message_ind );
4082 }
4083 res = TRUE; /* message processed, nothing left to do */
4084 }
4085 }
4086 }
4087 return res;
4088 }
4089 #endif
4090 /* Implements Measure # 73 */
4091
4092 /*
4093 +-------------------------------------------------------------------+
4094 | PROJECT : GSM-PS (6147) MODULE : CMH_SMSF |
4095 | ROUTINE : cmhSMS_findMessageIds |
4096 +-------------------------------------------------------------------+
4097 PARAMETERS : lower_mid - lower message id
4098 upper_mid - upper message id
4099 RETURN : TRUE if message has been found, else FALSE
4100
4101 PURPOSE : Find message ids based on the mids given as parameters and
4102 update smsShrdPrm.cbmPrm.cbmFoundIds based on the same.
4103
4104 */
4105 LOCAL BOOL cmhSMS_findMessageIds (USHORT lower_mid, USHORT upper_mid)
4106 {
4107 TRACE_FUNCTION("cmhSMS_findMessageIds()");
4108 /*
4109 * If the msg ids are same that in FFS and SIM, then restore else reset
4110 * to default values
4111 */
4112 if (smsShrdPrm.cbmPrm.msgId[smsShrdPrm.cbmPrm.cbmFoundIds * 2] EQ lower_mid
4113 AND smsShrdPrm.cbmPrm.msgId[smsShrdPrm.cbmPrm.cbmFoundIds * 2 + 1] EQ upper_mid)
4114 {
4115 smsShrdPrm.cbmPrm.cbmFoundIds++;
4116 }
4117 else
4118 {
4119 cmhSMS_clearCbmPrm();
4120 return FALSE;
4121 }
4122 return TRUE;
4123 }
4124
4125 /* Implements Measure # 126 */
4126 /*
4127 +---------------------------------------------------------------------------+
4128 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
4129 | STATE : code ROUTINE : cmhSMS_processOrigDestAddr|
4130 +---------------------------------------------------------------------------+
4131 PARAMETERS : sm - Structure into which the data is filled.
4132 rp_addr - RP Address used for filling sm
4133 tp_addr - destination or origination address that has to be
4134 filled in sm
4135 RETURN : None
4136
4137 PURPOSE : Processes originator address and converts it into 8 bit or string
4138 format as requried
4139
4140 */
4141 LOCAL void cmhSMS_processOrigDestAddr (T_ACI_CMGL_SM *sm,
4142 T_rp_addr *rp_addr,
4143 T_tp_da *tp_addr)
4144 {
4145 TRACE_FUNCTION("cmhSMS_processOrigDestAddr()");
4146 /*
4147 *-----------------------------------------------------------------
4148 * process address
4149 *-----------------------------------------------------------------
4150 */
4151 if (tp_addr->ton EQ SMS_TON_ALPHANUMERIC)
4152 {
4153 UBYTE i,j = 0;
4154 UBYTE dest_len;
4155 CHAR address_buf[MAX_SMS_ADDR_DIG/2];
4156
4157 for (i = 0 ; i < tp_addr->digits ; i=i+2)
4158 {
4159 address_buf[j] = (UBYTE)(tp_addr->num[i+1] << 4) + (UBYTE)(tp_addr->num[i]);
4160 j++;
4161 }
4162
4163 if( tp_addr->digits % 2 )
4164 {
4165 address_buf[j-1] = address_buf[j-1] & 0x0f;
4166 }
4167
4168 dest_len = utl_cvt7To8 ( (UBYTE*)address_buf, j, (UBYTE*)sm->adress, 0);
4169 sm -> adress[dest_len] = '\0';
4170
4171 if( (tp_addr->digits % 2) AND (dest_len + 3) % 8 >= 4 )
4172 sm -> adress[dest_len--] = '\0';
4173 else
4174 sm -> adress[dest_len] = '\0';
4175
4176 }
4177 else
4178 {
4179 cmhSMS_getAdrStr ( sm -> adress,
4180 MAX_SMS_NUM_LEN - 1,
4181 tp_addr->num,
4182 tp_addr->digits );
4183 }
4184 sm -> toa.ton = cmhSMS_getTon ( tp_addr->ton );
4185 sm -> toa.npi = cmhSMS_getNpi ( tp_addr->npi );
4186 /*
4187 *-----------------------------------------------------------------
4188 * process service center address
4189 *-----------------------------------------------------------------
4190 */
4191 cmhSMS_getAdrStr ( sm -> sca,
4192 MAX_SMS_NUM_LEN - 1,
4193 rp_addr->num,
4194 rp_addr->c_num);
4195
4196 sm -> tosca.ton = cmhSMS_getTon ( rp_addr->ton );
4197 sm -> tosca.npi = cmhSMS_getNpi ( rp_addr->npi );
4198
4199 /*
4200 *-----------------------------------------------------------------
4201 * process alphanumerical phonebook entry
4202 *-----------------------------------------------------------------
4203 */
4204 psaCC_phbMfwSrchNumPlnTxt ( sm -> adress, &sm -> alpha );
4205 }
4206
4207 /* Implements Measure # 149 */
4208 /*
4209 +---------------------------------------------------------------------------+
4210 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
4211 | STATE : code ROUTINE : cmhSMS_sendConfigureReq |
4212 +---------------------------------------------------------------------------+
4213 PARAMETERS : v_cmms_val - Set to TRUE if cmms_mode and tmms_val has to be
4214 filled.
4215 RETURN : None
4216
4217 PURPOSE : Sends mnsms_configure_req to inform the SMS entity
4218 about the parameter changes. v_cmms_val is TRUE if cmms_mode and
4219 tmms_val has to be filled.
4220
4221 */
4222 GLOBAL void cmhSMS_sendConfigureReq (BOOL v_cmms_val)
4223 {
4224 TRACE_FUNCTION("cmhSMS_sendConfigureReq()");
4225 { /* inform the SMS entity about the parameter changes */
4226 PALLOC (mnsms_configure_req, MNSMS_CONFIGURE_REQ);
4227
4228 /* fill in primitive parameter: command request */
4229 mnsms_configure_req -> pref_mem_3 = smsShrdPrm.mem3;
4230 mnsms_configure_req -> mt = smsShrdPrm.mtHndl;
4231 mnsms_configure_req -> ds = smsShrdPrm.srHndl;
4232 mnsms_configure_req -> mhc = (smsShrdPrm.CSMSservice NEQ CSMS_SERV_GsmPh2Plus)
4233 ? SMS_MHC_PH2 : SMS_MHC_PH2PLUS;
4234 mnsms_configure_req->v_cmms_mode = mnsms_configure_req->v_tmms_val =
4235 v_cmms_val;
4236 if(v_cmms_val)
4237 {
4238 mnsms_configure_req -> cmms_mode = smsShrdPrm.CMMSmode;
4239 mnsms_configure_req->tmms_val = CMMS_MODE_TIMER_VAL;
4240 }
4241
4242 PSENDX (SMS, mnsms_configure_req);
4243 }
4244 }
4245
4246 /* Implements Measure # 110 */
4247 /*
4248 +---------------------------------------------------------------------------+
4249 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
4250 | STATE : code ROUTINE : cmhSMS_cpyMsgIndReadCnf |
4251 +---------------------------------------------------------------------------+
4252 PARAMETERS : sm - Structure into which the data is filled.
4253 status - SMS record status
4254 sms_sdu - SMS SDU from which data has to be filled in sm
4255 rec_num - Record number of the SMS
4256 RETURN : BOOL value indicating the status returned by cmhSMS_cpyDeliver
4257 or cmhSMS_cpySubmit
4258
4259 PURPOSE : handles a message indication or a read cnf
4260
4261 */
4262 GLOBAL BOOL cmhSMS_cpyMsgIndReadCnf (T_ACI_CMGL_SM * sm,
4263 UBYTE *status,
4264 T_sms_sdu *sms_sdu,
4265 UBYTE rec_num)
4266 {
4267 BOOL ret = FALSE;
4268 TRACE_FUNCTION("cmhSMS_cpyMsgIndReadCnf()");
4269
4270 /*
4271 *-----------------------------------------------------------------
4272 * decode SMS-DELIVER or SMS-SUBMIT
4273 *-----------------------------------------------------------------
4274 */
4275
4276 /*
4277 * ACI-SPR-17004: set RFU bits of status to 0 if present since these
4278 * should be ignored in a GSM session (GSM 11.11 section 9.3)
4279 */
4280 cmhSMS_removeStatusRFUBits( status );
4281
4282 switch (*status)
4283 {
4284 case SMS_RECORD_REC_UNREAD:
4285 case SMS_RECORD_REC_READ:
4286 ret = cmhSMS_cpyDeliver ( sm, sms_sdu );
4287 break;
4288 case SMS_RECORD_STO_UNSENT:
4289 case SMS_RECORD_STO_SENT:
4290 /* ACI-SPR-17003: Handle unsupported statuses */
4291 case SMS_RECORD_STAT_UNRCVD:
4292 case SMS_RECORD_STAT_UNSTRD:
4293 case SMS_RECORD_STAT_STRD:
4294 ret = cmhSMS_cpySubmit ( sm, sms_sdu );
4295 break;
4296 /* 21.Mar.2003 currently not used by SMS entity */
4297 /*
4298 * case SMS_RECORD_INVALID:
4299 * ret = FALSE;
4300 * break;
4301 */
4302 default:
4303 TRACE_EVENT("incorrect status");
4304 }
4305
4306 /*
4307 *-----------------------------------------------------------------
4308 * process status (convert from PSA type to CMH type)
4309 *-----------------------------------------------------------------
4310 */
4311 if (sm->stat NEQ SMS_STAT_Invalid)
4312 {
4313 cmhSMS_getStatCmh ( *status, &sm -> stat );
4314 }
4315
4316 /*
4317 *-----------------------------------------------------------------
4318 * process message reference
4319 *-----------------------------------------------------------------
4320 */
4321 sm -> msg_ref = rec_num;
4322
4323 /*
4324 *-----------------------------------------------------------------
4325 * process tp_status
4326 *-----------------------------------------------------------------
4327 */
4328 sm ->tp_status = (UBYTE) -1;
4329
4330 return (ret);
4331 }
4332
4333 /* Implements Measure # 9 */
4334 /*
4335 +---------------------------------------------------------------------------+
4336 | PROJECT : GSM-F&D (8411) MODULE : CMH_SMSF |
4337 | STATE : code ROUTINE : cmhSMS_clearCbmPrm |
4338 +---------------------------------------------------------------------------+
4339 PARAMETERS : None
4340 RETURN : None
4341
4342 PURPOSE : Resets smsShrdPrm.cbmPrm to default values
4343
4344 */
4345 LOCAL void cmhSMS_clearCbmPrm (void)
4346 {
4347 TRACE_FUNCTION("cmhSMS_clearCbmPrm()");
4348
4349 smsShrdPrm.cbmPrm.cbmMode = CBCH_ACCEPT;
4350 memset (smsShrdPrm.cbmPrm.msgId, DEF_MID_RANGE,
4351 sizeof (smsShrdPrm.cbmPrm.msgId));
4352 memset (smsShrdPrm.cbmPrm.dcsId, DEF_DCS_RANGE,
4353 sizeof(smsShrdPrm.cbmPrm.dcsId));
4354 }
4355 /*==== EOF ========================================================*/