comparison g23m-gsm/sms/sms_tls.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-F&D (8411)
4 | Modul : SMS_TLP
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 Modul defines the functions for the transfer layer
18 | capability of the module Short Message Service.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef SMS_TLS_C
23 #define SMS_TLS_C
24
25 #include "config.h"
26 #include "fixedconf.h"
27 #include "condat-features.h"
28
29 #define ENTITY_SMS
30
31 /*==== INCLUDES ===================================================*/
32
33 #include <string.h>
34 #include <stdlib.h>
35 #include <stddef.h>
36 #include "typedefs.h"
37 #include "pcm.h"
38 #include "vsi.h"
39 #include "custom.h"
40 #include "gsm.h"
41 #include "message.h"
42 #include "ccdapi.h"
43 #include "prim.h"
44 #include "cus_sms.h"
45 #include "cnf_sms.h"
46 #include "mon_sms.h"
47 #include "pei.h"
48 #include "tok.h"
49 #include "sms.h"
50 #include "gdi.h"
51 #include "sms_em.h"
52
53 /*==== EXPORT ======================================================*/
54
55 /*==== PRIVAT ======================================================*/
56
57 /*==== VARIABLES ===================================================*/
58
59 /*==== FUNCTIONS ===================================================*/
60
61 LOCAL BOOL tl_modify_is_all (UBYTE modify)
62 {
63 switch (modify)
64 {
65 case SMS_MODIFY_NON:
66 case SMS_MODIFY_SCA:
67 case SMS_MODIFY_TPOA:
68 case SMS_MODIFY_TPOA_SCA:
69 return FALSE;
70 default:
71 break;
72 }
73 return TRUE; /* MODIFY_ALL: complete message is given */
74 }
75
76 LOCAL void tl_send_failure(USHORT cause)
77 {
78 GET_INSTANCE_DATA;
79
80 /*
81 * release connection
82 */
83 rl_release_req(SMS_INST.ti);
84
85 /*
86 * Send MNSMS_REPORT_IND indicating the cmms_mode value to ACI
87 * if CMMS_MODE is equal to 1or 2.
88 */
89 if(CMMS_ACTIVE)
90 {
91 tl_cmms_end();
92 }
93 /*
94 * SUBMIT_CNF
95 */
96 tl_mnsms_submit_cnf (SMS_SEL_MEM(sms_data),
97 SMS_SEL_REC(sms_data),
98 NOT_PRESENT_8BIT,
99 cause,
100 NULL);
101 }
102
103 /*---- SIGNALS -----------------------------------------------------*/
104
105 /*
106 +--------------------------------------------------------------------+
107 | PROJECT : GSM-PS (8410) MODULE : SMS_TLS |
108 | STATE : code ROUTINE : tl_establish_cnf |
109 +--------------------------------------------------------------------+
110
111 PURPOSE : Process the signal TL_ESTABLISH_CNF.
112
113 */
114
115 GLOBAL void tl_establish_cnf (
116 BOOL success)
117 {
118 GET_INSTANCE_DATA;
119
120 TRACE_FUNCTION ("tl_establish_cnf()");
121
122 #ifdef GPRS
123 if (success EQ FALSE)
124 {
125 /*
126 * Establishment Failed.
127 */
128 if (SMS_INST.downlink EQ SMS_DOWNLINK_LL_CHECK)
129 {
130 if (sms_data->mo_dst_pref EQ GPRS_SMS_GPRS_PREF)
131 {
132 /*
133 * using the preferred downlink LL failed, use CSD
134 */
135 TRACE_EVENT("Establishment failed on LL link, try gsm path instead");
136 /*
137 * set downlink type MMSMS
138 */
139 TRACE_EVENT("downlink = SMS_DOWNLINK_MMSMS");
140 SMS_INST.downlink = SMS_DOWNLINK_MMSMS;
141 /*
142 * try again
143 */
144 rl_establish_req(SMS_INST.ti);
145 return;
146 }
147 else
148 {
149 /*
150 * unsing the preferred downlink LL failed
151 */
152 TRACE_EVENT("Establishment failed on LL link, stop working");
153 /*
154 * handle event in report ind
155 */
156 tl_report_ind(NULL,SMS_CAUSE_NO_SERVICE);
157 return;
158 }
159 }
160
161 else if (SMS_INST.downlink EQ SMS_DOWNLINK_MMSMS)
162 {
163 if(sms_data->mo_dst_pref EQ GPRS_SMS_CCT_PREF)
164 {
165 /*
166 * using the preferred downlink MM failed, use PS
167 */
168 TRACE_EVENT("Establishment failed on MM link, try gprs path instead");
169
170 /*
171 * set downlink type LL
172 */
173 TRACE_EVENT("downlink = SMS_DOWNLINK_LL");
174 SMS_INST.downlink = SMS_DOWNLINK_LL_CHECK;
175 /*
176 * If CMMS_ACTIVE then send the MNSMS_REPORT_IND to ACI informing about
177 * the current cmms_mode value as GSM connection is failed.
178 */
179 if(CMMS_ACTIVE)
180 {
181 tl_cmms_end();
182 }
183
184 /*
185 * try again
186 */
187 rl_establish_req(SMS_INST.ti);
188 return;
189 }
190 /*
191 * else
192 * <<PS PREF failed CS fallback also failed>> case covered in cp layer.
193 */
194 }
195 }
196 #endif /* #ifdef GPRS */
197
198 switch (SMS_INST_GET_STATE (STATE_TL))
199 {
200 case TL_ESTABLISH:
201 switch (GET_STATE (STATE_EST))
202 {
203 case EST_SEND:
204
205 tl_establish_cnf_send();
206 break;
207
208 case EST_RTX:
209
210 tl_establish_cnf_rtx();
211 break;
212
213 case EST_CMD:
214
215 tl_establish_cnf_cmd();
216 break;
217
218 case EST_SMMA:
219
220 /*
221 * TL state transition: TL_OTHER
222 */
223 SMS_INST_SET_STATE (STATE_TL, TL_OTHER);
224 if (!rl_mem_avail_req ())
225 {
226 TRACE_EVENT("could not send SMMA");
227 /*
228 * TL state transition TL_OTHER
229 */
230 SMS_INST_SET_STATE (STATE_TL, TL_OTHER);
231 /*
232 * handle event in report ind
233 */
234 tl_report_ind(NULL,SMS_CAUSE_ENTITY_BUSY);
235 }
236
237 break;
238 }
239 break;
240
241 default:
242 TRACE_ERROR("TL_ESTABLISH_CNF in wrong state received");
243 }
244 }
245
246 /*
247 +--------------------------------------------------------------------+
248 | PROJECT : GSM-PS (8410) MODULE : SMS_TLS |
249 | STATE : code ROUTINE : tl_establish_cnf_send |
250 +--------------------------------------------------------------------+
251
252 PURPOSE : Process the signal TL_ESTABLISH_CNF
253 in state TL_SEND_ESTABLISH.
254
255 */
256
257 GLOBAL void tl_establish_cnf_send (void)
258 {
259 GET_INSTANCE_DATA;
260 drv_Return_Type pcm_result;
261 T_SIM_PDU *sim_pdu;
262
263 TRACE_FUNCTION ("tl_establish_cnf_send()");
264
265 if ( (SMS_SEL_REC(sms_data) NEQ SMS_RECORD_NOT_EXIST) AND
266 (!tl_modify_is_all (SMS_MODIFY(sms_data))) )
267 {
268 /*
269 * SEND - MODIFY
270 */
271 switch (SMS_SEL_MEM(sms_data))
272 {
273 case MEM_SM:
274
275 if (SMS_SEL_REC(sms_data) <= SMS_SIM_PROP(sms_data).max_record)
276 {
277 tl_set_access_fifo (ACCESS_BY_MMI);
278 /*
279 * TL state transition: TL_SEND
280 */
281 SET_STATE (STATE_MMI, MMI_READ);
282 SMS_INST_SET_STATE (STATE_TL, TL_SEND);
283 tl_sim_read_record_req (SMS_SEL_REC(sms_data));
284 }
285 else
286 {
287 tl_send_failure(SMS_CAUSE_INV_INDEX);
288 /*
289 * TL state transition: TL_IDLE
290 */
291 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
292 }
293 break;
294
295 case MEM_ME:
296
297 if (SMS_SEL_REC(sms_data) <= SMS_ME_PROP(sms_data).max_record)
298 {
299 USHORT max_record;
300 UBYTE misc;
301 UBYTE sim_msg[SIZE_EF_SMS];
302 MCAST (cp_data, U_CP_DATA);
303
304 /* Implements Measure#32: Row 109 */
305 pcm_result = pcm_ReadRecord ((UBYTE *)ef_sms_id,
306 (USHORT)SMS_SEL_REC(sms_data),
307 SIZE_EF_SMS,
308 sim_msg, &misc, &max_record);
309 if (pcm_result NEQ PCM_OK)
310 {
311 SMS_ME_PROP(sms_data).max_record = 0;
312 /*
313 * stop sending
314 */
315 tl_send_failure(SMS_CAUSE_MEM_FAIL);
316 /*
317 * TL state transition: TL_IDLE
318 */
319 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
320 break;
321 }
322 MALLOC (sim_pdu, sizeof(T_SIM_PDU));
323 CCD_START;
324 /*
325 * modify, prepare submit
326 */
327 if (tl_modify_submit (sim_pdu, SMS_MODIFY(sms_data),
328 SMS_SDU(sms_data), sim_msg) AND
329 tl_prepare_submit (sim_pdu, cp_data))
330 {
331 /*
332 * RL_DATA_REQ
333 */
334 if (!rl_data_req (SMS_INST.tp_mr, cp_data))
335 {
336 /*
337 * stop sending
338 */
339 tl_send_failure(SMS_CAUSE_ENTITY_BUSY);
340 /*
341 * TL state transition: TL_IDLE
342 */
343 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
344 }
345 else
346 {
347 SMS_EM_MO_SHORT_MESSAGE;
348 /*
349 * TL state transition: TL_SEND
350 */
351 SMS_INST_SET_STATE (STATE_TL, TL_SEND);
352 }
353 }
354 else
355 {
356 /*
357 * stop sending
358 */
359 tl_send_failure(SMS_CAUSE_PARAM_WRONG);
360 /*
361 * TL state transition: TL_IDLE
362 */
363 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
364 }
365 CCD_END;
366 MFREE (sim_pdu);
367 }
368 else
369 {
370 /*
371 * stop sending
372 */
373 tl_send_failure(SMS_CAUSE_INV_INDEX);
374 /*
375 * TL state transition: TL_IDLE
376 */
377 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
378 }
379 break;
380
381 default:
382 /*
383 * stop sending
384 */
385 tl_send_failure(SMS_CAUSE_PARAM_WRONG);
386 /*
387 * TL state transition: TL_IDLE
388 */
389 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
390 }
391 }
392 else /* no record given, or no previous mem read */
393 {
394 /*
395 * SEND - STRAIGHT
396 */
397 USHORT cause = SMS_NO_ERROR;
398
399 switch (SMS_SEL_MEM(sms_data))
400 {
401 case MEM_SM:
402 if (SMS_SEL_REC(sms_data) > SMS_SIM_PROP(sms_data).max_record)
403 {
404 cause = SMS_CAUSE_INV_INDEX;
405 }
406 break;
407
408 case MEM_ME:
409 if (SMS_SEL_REC(sms_data) > SMS_ME_PROP(sms_data).max_record)
410 {
411 cause = SMS_CAUSE_INV_INDEX;
412 }
413 break;
414
415 default:
416 if (SMS_SEL_REC(sms_data) NEQ SMS_RECORD_NOT_EXIST)
417 {
418 cause = SMS_CAUSE_PARAM_WRONG;
419 }
420 break;
421 }
422
423 if (cause EQ SMS_NO_ERROR)
424 {
425 /* Do some additional tests on the SMS SDU */
426 if (SMS_SDU(sms_data)->l_buf EQ 0)
427 {
428 TRACE_ERROR ("MNSMS_SUBMIT_REQ: sms_sdu empty");
429 cause = SMS_CAUSE_PARAM_WRONG;
430 }
431 if ((SMS_SDU(sms_data)->l_buf >> 3) +
432 (SMS_SDU(sms_data)->o_buf >> 3) > SIM_PDU_LEN)
433 {
434 TRACE_ERROR ("MNSMS_SUBMIT_REQ: sms_sdu out of range");
435 cause = SMS_CAUSE_PARAM_WRONG;
436 }
437 }
438
439 if (cause EQ SMS_NO_ERROR) /* error on previous parameter check? */
440 {
441 MCAST (cp_data, U_CP_DATA);
442 MALLOC (sim_pdu, sizeof(T_SIM_PDU));
443
444 CCD_START;
445 ccd_decodeMsg (CCDENT_SMS, BOTH,
446 (T_MSGBUF *)SMS_SDU(sms_data),
447 (UBYTE *)sim_pdu, SMS_VT_SIM_PDU);
448 /*
449 * prepare submit
450 */
451 if (tl_prepare_submit (sim_pdu, cp_data))
452 {
453 /*
454 * RL_DATA_REQ
455 */
456 if (!rl_data_req (SMS_INST.tp_mr, cp_data))
457 {
458 cause = SMS_CAUSE_ENTITY_BUSY;
459 }
460 else
461 {
462 SMS_EM_MO_SHORT_MESSAGE;
463 /*
464 * TL state transition
465 */
466 SMS_INST_SET_STATE (STATE_TL, TL_SEND);
467 }
468 }
469 else
470 {
471 cause = SMS_CAUSE_PARAM_WRONG;
472 }
473
474 MFREE (sim_pdu);
475 CCD_END;
476 }
477 if (cause NEQ SMS_NO_ERROR)
478 {
479 /*
480 * stop sending
481 */
482 tl_send_failure(cause);
483 /*
484 * TL state transition: TL_IDLE
485 */
486 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
487 }
488 }
489 }
490
491 /*
492 +--------------------------------------------------------------------+
493 | PROJECT : GSM-PS (8410) MODULE : SMS_TLS |
494 | STATE : code ROUTINE : tl_establish_cnf_rtx |
495 +--------------------------------------------------------------------+
496
497 PURPOSE : Process the signal TL_ESTABLISH_CNF
498 in state TL_RTX_ESTABLISH.
499
500 */
501 GLOBAL void tl_establish_cnf_rtx (void)
502 {
503 GET_INSTANCE_DATA;
504
505 TRACE_FUNCTION ("tl_establish_cnf_rtx()");
506
507 {
508 MCAST (cp_data, U_CP_DATA); /* T_U_CP_DATA */
509 BUF_tpdu *tpdu = &cp_data->cp_user_data_ul.rp_data_ul.rp_user_data.tpdu;
510 /*
511 * check whether data req still exists
512 */
513 if (SMS_DATA_REQ(sms_data) EQ NULL)
514 {
515 TRACE_ERROR("Horror: cannot retransmit DATA REQ: buffer gone");
516 return;
517 }
518 /*
519 * Inform ACI that MO transmission attempt is still going on
520 */
521 /* tl_mnsms_send_prog_ind(sms_data); */ /* TCS 4.x and above */
522
523 CCD_START;
524
525 /*
526 * Revert addition of PD and TI
527 */
528 SMS_DATA_REQ(sms_data)->sdu.o_buf += BSIZE_TI_PD;
529 SMS_DATA_REQ(sms_data)->sdu.l_buf -= BSIZE_TI_PD;
530
531 ccd_decodeMsg (CCDENT_SMS,
532 UPLINK,
533 (T_MSGBUF *)&SMS_DATA_REQ(sms_data)->sdu,
534 (UBYTE *)cp_data,
535 NOT_PRESENT_8BIT);
536
537 /*
538 * Set the TP-RD bit in the SMS-SUBMIT.
539 * No usage of CCD here, this would be inefficient.
540 */
541 tpdu->b_tpdu[tpdu->o_tpdu >> 3] |= 0x04;
542 /*
543 * TL state transition: TL_SEND
544 */
545 SMS_INST_SET_STATE (STATE_TL, TL_SEND);
546 /*
547 * RL_DATA_REQ
548 */
549 rl_data_req (SMS_INST.tp_mr, cp_data);
550
551 CCD_END;
552 }
553 }
554
555 /*
556 +--------------------------------------------------------------------+
557 | PROJECT : GSM-PS (8410) MODULE : SMS_TLS |
558 | STATE : code ROUTINE : tl_establish_cnf_cmd |
559 +--------------------------------------------------------------------+
560
561 PURPOSE : Process the signal TL_ESTABLISH_CNF
562 in state TL_CMD_ESTABLISH.
563
564 */
565
566 GLOBAL void tl_establish_cnf_cmd(void)
567 {
568 GET_INSTANCE_DATA;
569 T_SIM_PDU *sim_pdu;
570
571 TRACE_FUNCTION ("tl_establish_cnf_cmd()");
572
573 CCD_START;
574
575 MALLOC (sim_pdu, sizeof(T_SIM_PDU));
576 memset (sim_pdu, 0, sizeof(T_SIM_PDU));
577
578 ccd_decodeMsg (CCDENT_SMS, BOTH,
579 (T_MSGBUF *)SMS_SDU(sms_data),
580 (UBYTE *)sim_pdu, SMS_VT_SIM_PDU);
581
582 if (sim_pdu->tp_mti EQ SMS_COMMAND AND sim_pdu->v_tpdu)
583 {
584 MCAST (cp_data, U_CP_DATA);
585
586 /* ++SMS_INST.tp_mr; */
587 sim_pdu->tpdu.b_tpdu[1] = SMS_INST.tp_mr;
588 SMS_TP_REF_RET(sms_data) = SMS_INST.tp_mr;
589
590 SMS_INST_SET_STATE (STATE_TL, TL_COMMAND);
591
592 SMS_EM_MO_SHORT_MESSAGE_COMMAND;
593
594 cp_data->cp_user_data_ul.v_rp_error = FALSE;
595 cp_data->cp_user_data_ul.v_rp_ack = FALSE;
596 memset (&cp_data->cp_user_data_ul.rp_data_ul, 0,
597 sizeof (T_rp_data_ul));
598
599 memcpy (&cp_data->cp_user_data_ul.rp_data_ul.rp_addr,
600 &sim_pdu->rp_addr, sizeof (T_rp_addr));
601 cp_data->cp_user_data_ul.rp_data_ul.rp_user_data.tp_mti
602 = sim_pdu->tp_mti;
603 memcpy (&cp_data->cp_user_data_ul.rp_data_ul.rp_user_data.tpdu,
604 &sim_pdu->tpdu, sizeof (BUF_tpdu));
605 cp_data->cp_user_data_ul.rp_data_ul.rp_user_data.v_tpdu
606 = TRUE;
607 cp_data->cp_user_data_ul.v_rp_data_ul = TRUE;
608
609
610 /*
611 * RL_DATA_REQ
612 */
613 if (!rl_data_req (SMS_INST.tp_mr, cp_data))
614 {
615 tl_mnsms_command_cnf (NOT_PRESENT_8BIT, SMS_CAUSE_ENTITY_BUSY, NULL);
616 }
617 }
618 else
619 {
620 tl_mnsms_command_cnf (NOT_PRESENT_8BIT, SMS_CAUSE_PARAM_WRONG, NULL);
621 }
622
623 MFREE (sim_pdu);
624 CCD_END;
625 }
626 /*
627 +--------------------------------------------------------------------+
628 | PROJECT : GSM-PS (8410) MODULE : SMS_TLS |
629 | STATE : code ROUTINE : tl_data_ind |
630 +--------------------------------------------------------------------+
631
632 PURPOSE : Process the signal DATA_IND.
633
634 */
635
636 GLOBAL void tl_data_ind (
637 T_rp_data_dl *rp_data_dl)
638 {
639 GET_INSTANCE_DATA;
640 TRACE_FUNCTION ("tl_data_ind()");
641
642 /* Valid tp-user data will not be set to TRUE unless futher decoding is done
643 * so removed check rp_data_dl->rp_addr.v_tpdu
644 */
645 if (rp_data_dl EQ NULL OR !rp_data_dl->rp_addr.v_ton)
646 {
647 /*
648 * RP_ERROR =>
649 */
650 rl_report_req_error (SMS_RP_CS_INV_MAND_INFO, NULL);
651 /*
652 * RL_RELEASE_REQ ==>
653 */
654 rl_release_req(SMS_INST.ti);
655 return;
656 }
657 switch (rp_data_dl->rp_user_data.tp_mti)
658 {
659 case SMS_DELIVER:
660 {
661 MCAST (sms_deliver, TP_DELIVER);
662
663 TRACE_EVENT ("SMS DELIVER");
664
665 if (SMS_RP_RCVD(sms_data) EQ NULL)
666 {
667 MALLOC (SMS_RP_RCVD(sms_data), sizeof(T_rp_data_dl));
668 }
669 memcpy (SMS_RP_RCVD(sms_data), rp_data_dl,
670 sizeof(T_rp_data_dl));
671
672 /*
673 *If Valid TP user Data is missing in RP Message, send RP ERROR
674 * This is done by checking v_tp_ud field
675 */
676 if ( ccd_decodeMsg (CCDENT_SMS,
677 DOWNLINK,
678 (T_MSGBUF *)&SMS_RP_RCVD(sms_data)->rp_user_data.tpdu,
679 (UBYTE *)sms_deliver,
680 SMS_VT_DELIVER) EQ ccdError )
681 {
682 /*
683 * RP_ERROR =>
684 */
685 rl_report_req_error (SMS_RP_CS_INV_MAND_INFO, NULL);
686 /*
687 * RL_RELEASE_REQ ==>
688 */
689 rl_release_req(SMS_INST.ti);
690 break;
691 }
692
693 SMS_INST_SET_STATE (STATE_TL, TL_RECEIVE);
694
695 SMS_DCS(sms_data) = sms_deliver->tp_dcs;
696 SMS_PID(sms_data) = sms_deliver->tp_pid;
697 #ifdef FF_SMS_23430
698 if (tl_handle_23430 (sms_deliver))
699 return;
700 #endif
701 switch (sms_deliver->tp_pid)
702 {
703 case SMS_PID_SM_TYPE_0:
704 /*
705 * "A short message type 0 indicates that the ME must acknowledge
706 * receipt of the short message but shall discard its contents."
707 * [3GPP 23.040 subclause 9.2.3.9]
708 */
709 rl_report_req_ack (NULL);
710 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
711
712 MFREE (SMS_RP_RCVD(sms_data));
713 SMS_RP_RCVD(sms_data) = NULL;
714 break;
715
716 case SMS_PID_REP_SM_TYPE_1:
717 case SMS_PID_REP_SM_TYPE_2:
718 case SMS_PID_REP_SM_TYPE_3:
719 case SMS_PID_REP_SM_TYPE_4:
720 case SMS_PID_REP_SM_TYPE_5:
721 case SMS_PID_REP_SM_TYPE_6:
722 case SMS_PID_REP_SM_TYPE_7:
723 case SMS_PID_RET_CALL_MSG:
724 /*
725 * replace short messages
726 */
727 tl_replace_message (sms_deliver);
728 break;
729 case SMS_PID_SIM_DOWNLOAD:
730 /*
731 * SIM data download
732 */
733 #ifdef SIM_TOOLKIT
734 if (sms_data->download_sms AND
735 tl_check_class_2 (sms_deliver->tp_dcs))
736 {
737 tl_build_envelope_sms_download (SMS_RP_RCVD(sms_data));
738 }
739 else
740 #endif
741 tl_handle_message (sms_deliver);
742 break;
743
744 #ifdef REL99
745 /* Currently EGPRS over TIA/EIA-136 is not supported and hence it
746 * is treated as below. If TIA/EIA-136 is supported, the message
747 * should be passed to ME for routing to the application handling
748 * ANSI-136 data
749 */
750 case SMS_PID_ANSI_136_R_DATA:
751 if( tl_check_class_2 (sms_deliver->tp_dcs) )
752 {
753 #ifdef SIM_TOOLKIT
754 /* Download it to SIM only if both SAT is supported and data download
755 * service is enabled
756 */
757 if (sms_data->download_sms)
758 {
759 tl_build_envelope_sms_download (SMS_RP_RCVD(sms_data));
760 }
761 else
762 {
763 /* 11.14 8.d.0 Sec 7.1.1 mentions about storing the message when
764 * If the service "data download via SMS-PP" is not allocated
765 * and activated only for protocol identifier = SIM data download.
766 * Hence discard the message and send NACK indicating inability
767 * to handle the message*/
768 T_rp_user_data *rp_ud;
769 MALLOC (rp_ud, sizeof(T_rp_user_data));
770 rp_ud->tpdu.o_tpdu = 0;
771 rp_ud->tp_mti = rp_ud->tpdu.b_tpdu[0] = SMS_DELIVER_REPORT;
772 rp_ud->tpdu.b_tpdu[1] = SMS_FCS_TP_PID_UNSPEC; /* TP-FCS */
773 rp_ud->tpdu.b_tpdu[2] = 0; /* TP-PI */
774 rp_ud->tpdu.l_tpdu = 24; /* 3 bytes */
775 rp_ud->v_tpdu = TRUE;
776 rl_report_req_error (SMS_RP_CS_PROTOCOL_ERROR, rp_ud);
777 /*
778 * RL_RELEASE_REQ ==>
779 */
780 rl_release_req( SMS_INST.ti);
781 MFREE (rp_ud);
782
783 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
784 MFREE (SMS_RP_RCVD(sms_data));
785 SMS_RP_RCVD(sms_data) = NULL;
786 }
787 #else
788 /*
789 * Discard the message and send NACK
790 */
791 T_rp_user_data *rp_ud;
792 MALLOC (rp_ud, sizeof(T_rp_user_data));
793 rp_ud->tpdu.o_tpdu = 0;
794 rp_ud->tp_mti = rp_ud->tpdu.b_tpdu[0] = SMS_DELIVER_REPORT;
795 rp_ud->tpdu.b_tpdu[1] = SMS_FCS_TP_PID_UNSPEC; /* TP-FCS */
796 rp_ud->tpdu.b_tpdu[2] = 0; /* TP-PI */
797 rp_ud->tpdu.l_tpdu = 24; /* 3 bytes */
798 rp_ud->v_tpdu = TRUE;
799 rl_report_req_error (SMS_RP_CS_PROTOCOL_ERROR, rp_ud);
800 /*
801 * RL_RELEASE_REQ ==>
802 */
803 rl_release_req(SMS_INST.ti);
804 MFREE (rp_ud);
805
806 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
807 MFREE (SMS_RP_RCVD(sms_data));
808 SMS_RP_RCVD(sms_data) = NULL;
809 #endif
810 }
811 else
812 {
813 tl_handle_message (sms_deliver);
814 }
815 break;
816 #endif /* REL99 */
817
818 case SMS_PID_ME_DEPERSON:
819 /*
820 * ME de-personalization short message
821 */
822 #ifdef SIM_PERS_OTA
823 {
824 PALLOC (mnsms_OTA_message_ind, MNSMS_OTA_MESSAGE_IND);
825 memcpy (&mnsms_OTA_message_ind->tp_ud, &sms_deliver->tp_ud, sizeof(T_tp_ud));
826 mnsms_OTA_message_ind->tp_dcs = sms_deliver->tp_dcs ;
827 mnsms_OTA_message_ind->tp_pid = sms_deliver->tp_pid;
828 #ifdef TI_PS_HCOMM_CHANGE
829 PSEND (_hCommMMI, mnsms_OTA_message_ind);
830 #else
831 PSEND (hCommMMI, mnsms_OTA_message_ind);
832 #endif
833 break;
834 }
835 #else
836 break;
837 #endif
838 case SMS_PID_ME_DOWNLOAD:
839 /*
840 * ME download short message
841 */
842 default:
843 tl_handle_message (sms_deliver);
844 break;
845 }
846 break;
847 }
848
849 case SMS_STATUS_REPORT:
850 TRACE_EVENT ("SMS STATUS REPORT");
851
852 if (sms_data->ds EQ DS1)
853 {
854 /*
855 * only if requested by MMI
856 */
857 PALLOC (status_ind, MNSMS_STATUS_IND);
858
859 SMS_EM_SMS_STATUS_MESSAGE;
860
861 tl_build_status_rep (rp_data_dl, status_ind);
862 PSENDX (MMI, status_ind);
863
864 if (SMS_MT_ACK_MODE(sms_data) EQ SMS_MHC_PH2PLUS)
865 {
866 SMS_INST_SET_STATE (STATE_TL, TL_RECEIVE);
867 break;
868 }
869 }
870 rl_report_req_ack (NULL);
871 break;
872
873 default:
874 /*
875 * RP_ERROR =>
876 */
877 rl_report_req_error (SMS_RP_CS_SEM_INC_MSG, NULL);
878 /*
879 * RL_RELEASE_REQ ==>
880 */
881 rl_release_req(SMS_INST.ti);
882 break;
883 }
884 }
885
886 /*
887 +--------------------------------------------------------------------+
888 | PROJECT : GSM-PS (8410) MODULE : SMS_TLS |
889 | STATE : code ROUTINE : tl_timeout_ind |
890 +--------------------------------------------------------------------+
891
892 PURPOSE : Process the signal TL_TIMEOUT_IND.
893
894 */
895 GLOBAL void tl_timeout_ind ( USHORT timer_id)
896 {
897 GET_INSTANCE_DATA;
898
899 TRACE_FUNCTION ("tl_timeout_ind()");
900
901 switch (SMS_INST_GET_STATE (STATE_TL))
902 {
903 /* -------------------------------------- */
904 case TL_ESTABLISH:
905 /* -------------------------------------- */
906
907 switch (GET_STATE(STATE_EST))
908 {
909 case EST_SEND:
910 /*
911 * Connection establishment for the SUBMIT has failed
912 */
913 TRACE_EVENT("Connection establishment for SUBMIT request failed");
914
915 TRACE_EVENT_P1 ("TL retrans #%d", SMS_INST.tl_retx);
916
917 if (SMS_INST.tl_retx < TL_MAX_RETANS)
918 {
919 /*
920 * Maximum number of TL retransmissions not exceeded.
921 * Retry establishment.
922 */
923 SMS_INST.tl_retx++;
924 /*
925 * establish connection
926 */
927 #ifdef REL99
928 tl_mnsms_send_prog_ind();
929 #endif /* REL99 */
930 tl_establish_connection(FALSE);
931 }
932 else
933 {
934 /*
935 * clean up instance
936 */
937 if (SMS_SDU(sms_data) NEQ NULL)
938 {
939 MFREE (SMS_SDU(sms_data));
940 SMS_SDU(sms_data) = NULL;
941 }
942 SMS_SEL_REC(sms_data) = SMS_RECORD_NOT_EXIST;
943 /*
944 * TL state transition TL_IDLE
945 */
946 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
947 /*
948 * SUBMIT_CNF
949 */
950 tl_mnsms_submit_cnf (SMS_SEL_MEM(sms_data),
951 SMS_RECORD_NOT_EXIST,
952 SMS_TP_REF_RET(sms_data),
953 SMS_CAUSE_NET_TIMEOUT,
954 SMS_SDU(sms_data));
955 /*
956 * End the cmms session
957 */
958 if(CMMS_ACTIVE)
959 {
960 tl_cmms_end();
961 }
962
963 }
964 break;
965
966 case EST_CMD:
967 /*
968 * Connection establishment for the COMMAND has failed
969 */
970 TRACE_EVENT("Connection establishment for COMMAND request failed");
971
972 TRACE_EVENT_P1 ("TL retrans #%d", SMS_INST.tl_retx);
973
974 if (SMS_INST.tl_retx < TL_MAX_RETANS)
975 {
976 /*
977 * Maximum number of TL retransmissions not exceeded.
978 * Retry establishment.
979 */
980 SMS_INST.tl_retx++;
981 /*
982 * establish connection
983 */
984 #ifdef REL99
985 tl_mnsms_send_prog_ind();
986 #endif
987 tl_establish_connection(FALSE);
988 }
989 else
990 {
991 /*
992 * clean up instance
993 */
994 if (SMS_SDU(sms_data) NEQ NULL)
995 {
996 MFREE (SMS_SDU(sms_data));
997 SMS_SDU(sms_data) = NULL;
998 }
999 SMS_SEL_REC(sms_data) = SMS_RECORD_NOT_EXIST;
1000 /*
1001 * TL state transition
1002 */
1003 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
1004 /*
1005 * COMMAND_CNF
1006 */
1007 tl_mnsms_command_cnf (SMS_TP_REF_RET(sms_data),
1008 SMS_CAUSE_NET_TIMEOUT,
1009 SMS_SDU(sms_data));
1010 }
1011 break;
1012
1013 case EST_RTX:
1014 TRACE_EVENT("timeout establishment for retransmission ignored");
1015 break;
1016
1017 case EST_SMMA:
1018 /*
1019 * Connection establishment for the SMMA has failed
1020 */
1021 TRACE_EVENT("Connection establishment for SMMA request failed");
1022
1023 TRACE_EVENT_P1 ("TL retrans #%d", SMS_INST.tl_retx);
1024
1025 if (SMS_INST.tl_retx < TL_MAX_RETANS)
1026 {
1027 /*
1028 * Maximum number of TL retransmissions not exceeded.
1029 * Retry establishment.
1030 */
1031 SMS_INST.tl_retx++;
1032 /*
1033 * try again
1034 */
1035 SMS_INST.retrans = TRUE;
1036 /*
1037 * establish connection
1038 */
1039
1040 tl_establish_connection(FALSE);
1041
1042 }
1043 else
1044 {
1045 /*
1046 * TL state transition TL_OTHER
1047 */
1048 SMS_INST_SET_STATE (STATE_TL, TL_OTHER);
1049 /*
1050 * handle event in report ind
1051 */
1052 tl_report_ind(NULL,SMS_CAUSE_NET_TIMEOUT);
1053 }
1054 break;
1055 }
1056 break;
1057
1058 /* -------------------------------------- */
1059 case TL_SEND:
1060 /* -------------------------------------- */
1061 /*
1062 * sending of the SUBMIT has failed
1063 */
1064 TRACE_EVENT("Transmission for SUBMIT request failed");
1065
1066 TRACE_EVENT_P1 ("TL retrans #%d", SMS_INST.tl_retx);
1067
1068 if (SMS_INST.tl_retx < TL_MAX_RETANS)
1069 {
1070 /*
1071 * Maximum number of TL retransmissions not exceeded.
1072 * Retry establishment.
1073 */
1074 SMS_INST.tl_retx++;
1075 #ifdef REL99
1076 tl_mnsms_send_prog_ind();
1077 #endif /* REl99 */
1078
1079 /*
1080 * TL state transition TL_ESTABLISH
1081 * EST state transition EST_RTX
1082 */
1083 SMS_INST_SET_STATE (STATE_TL, TL_ESTABLISH);
1084 SET_STATE(STATE_EST,EST_RTX);
1085 /*
1086 * establish connection
1087 */
1088 tl_establish_connection(FALSE);
1089 }
1090 else
1091 {
1092 /*
1093 * clean up instance
1094 */
1095 if (SMS_SDU(sms_data) NEQ NULL)
1096 {
1097 MFREE (SMS_SDU(sms_data));
1098 SMS_SDU(sms_data) = NULL;
1099 }
1100 SMS_SEL_REC(sms_data) = SMS_RECORD_NOT_EXIST;
1101 /*
1102 * TL state transition TL_IDLE
1103 */
1104 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
1105 /*
1106 * SUBMIT_CNF
1107 */
1108 tl_mnsms_submit_cnf (SMS_SEL_MEM(sms_data),
1109 SMS_RECORD_NOT_EXIST,
1110 SMS_TP_REF_RET(sms_data),
1111 SMS_CAUSE_NET_TIMEOUT,
1112 SMS_SDU(sms_data));
1113 /*
1114 * End the cmms session
1115 */
1116 if(CMMS_ACTIVE)
1117 {
1118 tl_cmms_end();
1119 }
1120 }
1121 break;
1122
1123 /* -------------------------------------- */
1124 case TL_COMMAND:
1125 /* -------------------------------------- */
1126 /*
1127 * sending of the COMMAND has failed
1128 */
1129 TRACE_EVENT("Transmission for COMMAND request failed");
1130
1131 TRACE_EVENT_P1 ("TL retrans #%d", SMS_INST.tl_retx);
1132
1133 if (SMS_INST.tl_retx < TL_MAX_RETANS)
1134 {
1135 /*
1136 * Maximum number of TL retransmissions not exceeded.
1137 * Retry establishment.
1138 */
1139 SMS_INST.tl_retx++;
1140 #ifdef REL99
1141 tl_mnsms_send_prog_ind();
1142 #endif /* REl99 */
1143 /*
1144 * TL state transition TL_ESTABLISH
1145 * EST state transition EST_CMD
1146 */
1147 SMS_INST_SET_STATE (STATE_TL, TL_ESTABLISH);
1148 SET_STATE(STATE_EST,EST_CMD);
1149 /*
1150 * establish connection
1151 */
1152 tl_establish_connection(FALSE);
1153 }
1154 else
1155 {
1156 /*
1157 * clean up instance
1158 */
1159 if (SMS_SDU(sms_data) NEQ NULL)
1160 {
1161 MFREE (SMS_SDU(sms_data));
1162 SMS_SDU(sms_data) = NULL;
1163 }
1164 SMS_SEL_REC(sms_data) = SMS_RECORD_NOT_EXIST;
1165 /*
1166 * TL state transition TL_IDLE
1167 */
1168 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
1169 /*
1170 * COMMAND_CNF
1171 */
1172 tl_mnsms_command_cnf (SMS_TP_REF_RET(sms_data),
1173 SMS_CAUSE_NET_TIMEOUT,
1174 SMS_SDU(sms_data));
1175 }
1176 break;
1177
1178 /* -------------------------------------- */
1179 default:
1180 /* -------------------------------------- */
1181
1182 // TRACE_EVENT("TL_TIMEOUT_IND ignored");
1183 if (timer_id EQ TRAM)
1184 {
1185 /*
1186 * sending of the SMMA has failed
1187 */
1188 TRACE_EVENT("Transmission for SMMA failed");
1189 /*
1190 * ??? !!! ???
1191 */
1192 --SMS_RP_REF(sms_data);
1193 /*
1194 * TL state transition TL_ESTABLISH
1195 * EST state transition EST_SMMA
1196 */
1197 SMS_INST_SET_STATE (STATE_TL, TL_ESTABLISH);
1198 SET_STATE(STATE_EST,EST_SMMA);
1199 /*
1200 * try again
1201 */
1202 SMS_INST.retrans = TRUE;
1203 /*
1204 * establish connection
1205 */
1206 tl_establish_connection(FALSE);
1207 }
1208 else
1209 {
1210 tl_report_ind(NULL,SMS_CAUSE_NET_TIMEOUT);
1211 }
1212 break;
1213 }
1214 }
1215 /*
1216 +--------------------------------------------------------------------+
1217 | PROJECT : GSM-PS (8410) MODULE : SMS_TLS |
1218 | STATE : code ROUTINE : tl_report_ind |
1219 +--------------------------------------------------------------------+
1220
1221 PURPOSE : Process the signal TL_REPORT_IND.
1222
1223 */
1224
1225 LOCAL UBYTE tl_check_condx_send (T_BACKUP *prop,
1226 UBYTE mem_type,
1227 UBYTE condx,
1228 UBYTE rec_num)
1229 {
1230 if (condx EQ SMS_CONDX_OVR_NON)
1231 {
1232 if ((rec_num = tl_get_free_space (mem_type)) NEQ 0)
1233 return rec_num;
1234 else
1235 return SMS_RECORD_NOT_EXIST;
1236 }
1237 else if (condx EQ SMS_CONDX_OVR_MO)
1238 {
1239 switch (tl_get_status (prop, rec_num - 1))
1240 {
1241 case SMS_RECORD_REC_UNREAD:
1242 case SMS_RECORD_REC_READ:
1243 if ((rec_num = tl_get_free_space (mem_type)) NEQ 0)
1244 return rec_num;
1245 return SMS_RECORD_NOT_EXIST;
1246
1247 default:
1248 break;
1249 }
1250 }
1251 return rec_num;
1252 }
1253
1254 GLOBAL void tl_report_ind (T_rp_user_data *rp_user_data,
1255 USHORT cause)
1256 {
1257 GET_INSTANCE_DATA;
1258 T_SIM_PDU *sim_pdu;
1259 UBYTE rec_num, next_rec_num = 0;
1260
1261 TRACE_FUNCTION ("tl_report_ind()");
1262
1263 #ifdef REL99
1264 if (cause NEQ SMS_NO_ERROR)
1265 {
1266 SMS_INST.failed_msg_rec_num = SMS_SEL_REC(sms_data);
1267 SMS_INST.failed_msg_mem = SMS_SEL_MEM(sms_data);
1268 }
1269 #endif
1270
1271 if (sms_data)
1272 {
1273 if (SMS_SDU(sms_data) NEQ NULL)
1274 {
1275 MFREE (SMS_SDU(sms_data));
1276 SMS_SDU(sms_data) = NULL;
1277 }
1278
1279 /*
1280 * An SMS DELIVER REPORT TPDU is carried as a RP User Data element within
1281 * an RP ERROR PDU and is part of the negative acknowledgement to an SMS
1282 * DELIVER or SMS STATUS REPORT.
1283 *
1284 * An SMS DELIVER REPORT TPDU is also carried as a RP User Data element
1285 * within an RP ACK PDU and is part of a positive acknowledgement to a
1286 * SMS DELIVER or SMS STATUS REPORT.
1287 * [3gpp 23.040 clause 9.2.2.1a]
1288 *
1289 * The cause value (invalid / non-invalid) is used to distinguish whether
1290 * the RP user data (SMS DELIVER REPORT) came with RP-ACK / RP-ERROR.
1291 */
1292
1293 if (IS_CAUSE_INVALID(cause) AND
1294 (rp_user_data NEQ NULL AND rp_user_data->v_tpdu))
1295 {
1296 MALLOC (sim_pdu, sizeof(T_SIM_PDU));
1297 MALLOC (SMS_SDU(sms_data), sizeof(T_sms_sdu));
1298
1299 memset (&sim_pdu->rp_addr, 0, sizeof(T_rp_addr));
1300 sim_pdu->tp_mti = rp_user_data->tp_mti;
1301 sim_pdu->tpdu = rp_user_data->tpdu;
1302 sim_pdu->v_tpdu = TRUE;
1303 sim_pdu->tp_vt_mti = SMS_VT_SIM_PDU;
1304
1305 SMS_SDU(sms_data)->o_buf = 0;
1306 SMS_SDU(sms_data)->l_buf = SIM_PDU_LEN<<3;
1307 if (ccd_codeMsg (CCDENT_SMS, BOTH,
1308 (T_MSGBUF *)SMS_SDU(sms_data),
1309 (UBYTE *)sim_pdu, SMS_VT_SIM_PDU) NEQ ccdOK)
1310 {
1311 MFREE (SMS_SDU(sms_data));
1312 SMS_SDU(sms_data) = NULL;
1313 }
1314 MFREE (sim_pdu);
1315 }
1316 switch (SMS_INST_GET_STATE (STATE_TL))
1317 {
1318 /* -------------------------------------- */
1319 case TL_ESTABLISH:
1320 /* -------------------------------------- */
1321
1322 switch (GET_STATE(STATE_EST))
1323 {
1324 case EST_SEND:
1325 case EST_RTX:
1326 /*
1327 * TL state transition TL_SEND
1328 */
1329 SMS_INST_SET_STATE (STATE_TL, TL_SEND);
1330 break;
1331 case EST_CMD:
1332 /*
1333 * TL state transition TL_COMMAND
1334 */
1335 SMS_INST_SET_STATE (STATE_TL, TL_COMMAND);
1336 break;
1337 case EST_SMMA:
1338 if (SMS_INST.retrans)
1339 {
1340 SMS_INST.retrans = FALSE;
1341 /*
1342 * TL state transition TL_OTHER
1343 */
1344 SMS_INST_SET_STATE (STATE_TL, TL_OTHER);
1345 }
1346 else
1347 {
1348 /*
1349 * RL_START_TRAM_REQ
1350 */
1351 rl_start_tram_req();
1352 return;
1353 }
1354 break;
1355 default:
1356 TRACE_ERROR("Invalid EST state!");
1357 /*
1358 * TL state transition TL_IDLE
1359 */
1360 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
1361 break;
1362 }
1363 /*
1364 * TL_REPORT_IND recursive
1365 */
1366 tl_report_ind(rp_user_data,cause);
1367 return;
1368
1369 /* -------------------------------------- */
1370 case TL_SEND:
1371 /* -------------------------------------- */
1372
1373 if (!IS_CAUSE_INVALID(cause) AND
1374 (rp_user_data NEQ NULL) AND (SMS_INST.tl_retx > 0))
1375 {
1376 /*
1377 * Retransmission case as of 23.040 subclause 9.2.3.6
1378 * and RP ERROR with RP USER DATA received. Check whether
1379 * the RP USER DATA contains a SMS SUBMIT REPORT with TP-FCS set to
1380 * "SM Rejected - Duplicate SM".
1381 * If so the transmission has been a success and not a failure.
1382 */
1383 MCAST (tp_sbmt_rep_err, TP_SBMT_REP_ERR); /* T_TP_SBMT_REP_ERR */
1384 BUF_tpdu *tpdu = &rp_user_data->tpdu;
1385 BYTE ccd_result;
1386
1387 switch (tpdu->b_tpdu[tpdu->o_tpdu >> 3] & 0x3)
1388 {
1389 case SMS_SUBMIT_REPORT:
1390 /* Copy tpdu from rp_user_data, it's part of decoded msg buffer */
1391 MALLOC (tpdu, sizeof(BUF_tpdu));
1392 memcpy (tpdu, &rp_user_data->tpdu, sizeof (BUF_tpdu));
1393
1394 CCD_START;
1395 ccd_result = ccd_decodeMsg (CCDENT_SMS, DOWNLINK,
1396 (T_MSGBUF *)tpdu,
1397 (UBYTE *)tp_sbmt_rep_err,
1398 SMS_VT_SBMT_REP_ERR);
1399 if (ccd_result NEQ ccdOK)
1400 {
1401 /* Could error handling be elaborated here? */
1402 TRACE_ERROR ("ccd decoding problem");
1403 }
1404
1405 if (tp_sbmt_rep_err->tp_fcs EQ SMS_FCS_REJ_DUPL_SM)
1406 {
1407 TRACE_EVENT ("SC had SMS");
1408 cause = SMS_NO_ERROR; /* Enter "no error" handling below */
1409 /* Since the transmission was successful, the data stored for
1410 retransmission can be freed */
1411 if (SMS_DATA_REQ(sms_data) NEQ NULL)
1412 {
1413 PFREE (SMS_DATA_REQ(sms_data));
1414 SMS_DATA_REQ(sms_data) = NULL;
1415 }
1416 }
1417 CCD_END;
1418
1419 MFREE (tpdu);
1420 break;
1421
1422 default:
1423 break; /* Do nothing, it is an error */
1424 }
1425 }
1426
1427 if (IS_CAUSE_INVALID(cause) AND SMS_SEL_REC(sms_data) > 0)
1428 {
1429 if (SMS_SEL_MEM(sms_data) EQ MEM_SM AND
1430 SMS_SEL_REC(sms_data) <= SMS_SIM_PROP(sms_data).max_record)
1431 {
1432 if ((rec_num = tl_check_condx_send (&SMS_SIM_PROP(sms_data),
1433 MEM_SM,
1434 SMS_CONDX(sms_data),
1435 SMS_SEL_REC(sms_data)))
1436 NEQ SMS_RECORD_NOT_EXIST)
1437 SMS_SEL_REC(sms_data) = rec_num;
1438 else
1439 {
1440 #ifdef REL99
1441 if(SMS_INST.failed_msg_retx EQ FALSE)
1442 {
1443 #endif
1444 tl_mnsms_submit_cnf (MEM_SM, SMS_RECORD_NOT_EXIST,
1445 SMS_TP_REF_RET(sms_data),
1446 SMS_CAUSE_MEM_FULL, SMS_SDU(sms_data));
1447 #ifdef REL99
1448 }
1449 else
1450 {
1451 tl_mnsms_retrans_cnf (MEM_SM, SMS_RECORD_NOT_EXIST,
1452 SMS_TP_REF_RET(sms_data),
1453 SMS_CAUSE_MEM_FULL, SMS_SDU(sms_data));
1454 }
1455 #endif
1456
1457 break;
1458 }
1459 {
1460 UBYTE sim_acc_ix;
1461 T_SMS_SIM_ACCESS_INFO *sms_sim_access_info_ptr;
1462 if (tl_sms_reserve_req_id(&sim_acc_ix))
1463 {
1464 PALLOC (update_req, SIM_UPDATE_RECORD_REQ);
1465 sms_sim_access_info_ptr = &sms_data->sms_sim_access_info[sim_acc_ix];
1466 update_req->source = SRC_SMS;
1467 update_req->req_id = sim_acc_ix;
1468 update_req->v_path_info = FALSE;
1469 update_req->datafield = sms_sim_access_info_ptr->datafield
1470 = SIM_SMS;
1471 update_req->record = sms_sim_access_info_ptr->rec_num
1472 = SMS_SEL_REC(sms_data);
1473 update_req->length = SIM_LENGTH_SMS_RECORD;
1474
1475 tl_convert_mo_to_mem (SMS_DATA_REQ(sms_data),
1476 update_req->linear_data);
1477
1478 PSENDX (SIM, update_req);
1479 }
1480 }
1481 tl_store_status (&SMS_SIM_PROP(sms_data), rec_num-1, SIM_SMS_PENDING);
1482 tl_set_access_fifo (ACCESS_BY_MMI);
1483 SET_STATE (STATE_MMI, MMI_REPLACE);
1484 /*
1485 * concat control
1486 */
1487 if (sms_data->concat_cntrl.concatenation NEQ TRUE)
1488 {
1489 /*
1490 * RL_RELEASE_REQ ==>
1491 */
1492 rl_release_req(SMS_INST.ti);
1493 }
1494 return;
1495 }
1496 if (SMS_SEL_MEM(sms_data) EQ MEM_ME AND
1497 SMS_SEL_REC(sms_data) <= SMS_ME_PROP(sms_data).max_record)
1498 {
1499 UBYTE data[SIZE_EF_SMS];
1500
1501 if ((rec_num = tl_check_condx_send (&SMS_ME_PROP(sms_data),
1502 MEM_ME,
1503 SMS_CONDX(sms_data),
1504 SMS_SEL_REC(sms_data)))
1505 NEQ SMS_RECORD_NOT_EXIST)
1506 SMS_SEL_REC(sms_data) = rec_num;
1507 else
1508 {
1509 #ifdef REL99
1510 if(SMS_INST.failed_msg_retx EQ FALSE)
1511 {
1512 #endif
1513 tl_mnsms_submit_cnf (MEM_ME, SMS_RECORD_NOT_EXIST,
1514 SMS_TP_REF_RET(sms_data),
1515 SMS_CAUSE_MEM_FULL, SMS_SDU(sms_data));
1516 #ifdef REL99
1517 }
1518 else
1519 {
1520 tl_mnsms_retrans_cnf (MEM_ME, SMS_RECORD_NOT_EXIST,
1521 SMS_TP_REF_RET(sms_data),
1522 SMS_CAUSE_MEM_FULL, SMS_SDU(sms_data));
1523 }
1524 #endif
1525 break;
1526 }
1527 tl_convert_mo_to_mem (SMS_DATA_REQ(sms_data), data);
1528 /* Implements Measure#32: Row 113 */
1529 if (pcm_WriteRecord ((UBYTE *)ef_sms_id, SMS_SEL_REC(sms_data),
1530 SIZE_EF_SMS, data) NEQ DRV_OK)
1531 {
1532 cause = SMS_CAUSE_MEM_FAIL;
1533 }
1534 }
1535 }
1536 /*
1537 * MNSMS_SUBMIT_CNF =>
1538 */
1539 #ifdef REL99
1540 if(SMS_INST.failed_msg_retx EQ FALSE)
1541 {
1542 #endif
1543 tl_mnsms_submit_cnf (SMS_SEL_MEM(sms_data), SMS_RECORD_NOT_EXIST,
1544 SMS_TP_REF_RET(sms_data), cause, SMS_SDU(sms_data));
1545 #ifdef REL99
1546 }
1547 else
1548 {
1549 tl_mnsms_retrans_cnf (SMS_SEL_MEM(sms_data), SMS_RECORD_NOT_EXIST,
1550 SMS_TP_REF_RET(sms_data), cause, SMS_SDU(sms_data));
1551 }
1552 #endif
1553 /*
1554 * concat control
1555 */
1556 if ((sms_data->concat_cntrl.concatenation EQ TRUE) AND !CMMS_ACTIVE)
1557 {
1558 if (cause EQ SMS_NO_ERROR)
1559 {
1560 /*
1561 * start timer TLCT for next submit req supervision
1562 */
1563 sms_timer_start(TLCT);
1564 /*
1565 * TL State Transition TL_SEND_CONTD
1566 */
1567 SMS_INST_SET_STATE (STATE_TL, TL_SEND_CONTD);
1568 /*
1569 * do not release connection now
1570 */
1571 sms_data->concat_cntrl.release_pending = TRUE;
1572 return;
1573 }
1574 else
1575 {
1576 /*
1577 * error case: end concatenation series
1578 */
1579 sms_data->concat_cntrl.concatenation = FALSE;
1580 }
1581 }
1582 else
1583 {
1584 /*
1585 * cmms control
1586 */
1587 if(CMMS_ACTIVE AND (sms_data->cmms_release_pending EQ TRUE))
1588 {
1589 tl_cmms_start();
1590 SMS_INST_SET_STATE (STATE_TL, TL_SEND_CONTD);
1591
1592 if (sms_data->concat_cntrl.concatenation EQ TRUE)
1593 {
1594 if (cause EQ SMS_NO_ERROR)
1595 {
1596 sms_data->concat_cntrl.release_pending = TRUE;
1597 }
1598 else
1599 {
1600 /*
1601 * error case: end concatenation series
1602 */
1603 sms_data->concat_cntrl.concatenation = FALSE;
1604 }
1605 }
1606 return;
1607 }
1608 else
1609 if(CMMS_ACTIVE)
1610 {
1611 tl_cmms_end();
1612 }
1613 }
1614 break;
1615
1616 /* -------------------------------------- */
1617 case TL_COMMAND:
1618 /* -------------------------------------- */
1619
1620 #ifdef REL99
1621 if(SMS_INST.failed_msg_retx EQ FALSE)
1622 {
1623 #endif
1624
1625 tl_mnsms_command_cnf (SMS_TP_REF_RET(sms_data), cause, SMS_SDU(sms_data));
1626 #ifdef REL99
1627 }
1628 else
1629 {
1630 tl_mnsms_retrans_cnf (NOT_PRESENT_8BIT, SMS_RECORD_NOT_EXIST,
1631 SMS_TP_REF_RET(sms_data), cause, SMS_SDU(sms_data));
1632 }
1633 #endif
1634
1635 break;
1636
1637 /* -------------------------------------- */
1638 case TL_RECEIVE:
1639 /* -------------------------------------- */
1640
1641 if (!IS_CAUSE_INVALID(cause))
1642 {
1643 switch (GET_STATE (STATE_NET))
1644 {
1645 case NET_WRITE:
1646 case NET_READ:
1647 break;
1648 default:
1649 if (SMS_MT_ACK_MODE(sms_data) EQ SMS_MHC_PH2PLUS)
1650 tl_mnsms_error_ind ((USHORT)((GET_CAUSE_DEFBY(cause) EQ DEFBY_CONDAT)?
1651 cause: SMS_CAUSE_NET_TIMEOUT));
1652 break;
1653 }
1654 SET_STATE (STATE_NET, NET_IDLE);
1655 }
1656
1657 /* -------------------------------------- */
1658 case TL_OTHER:
1659 /* -------------------------------------- */
1660
1661 if (GET_STATE (STATE_MMI) EQ MMI_DELETE)
1662 {
1663 if (!tl_sms_memo_exceeded (TRUE))
1664 {
1665 if(SMS_REC_STATUS(sms_data) NEQ CMGD_DEL_INDEX)
1666 {
1667 if(SMS_SEL_MEM(sms_data) EQ MEM_SM)
1668 {
1669 /* Status value is given. Find the next record satisfying this status value */
1670 next_rec_num = tl_search_record_for_delete (&SMS_SIM_PROP(sms_data),
1671 SMS_SEL_REC(sms_data),
1672 SMS_REC_STATUS(sms_data));
1673 }
1674 else if(SMS_SEL_MEM(sms_data) EQ MEM_ME)
1675 {
1676 /* Status value is given. Find the next record satisfying this status value */
1677 next_rec_num = tl_search_record_for_delete (&SMS_ME_PROP(sms_data),
1678 SMS_SEL_REC(sms_data),
1679 SMS_REC_STATUS(sms_data));
1680 }
1681 }
1682 tl_mnsms_delete_cnf (SMS_SEL_MEM(sms_data), SMS_SEL_REC(sms_data), next_rec_num,
1683 SIM_NO_ERROR);
1684 SET_STATE (STATE_MMI, MMI_IDLE);
1685 #ifdef SIM_TOOLKIT
1686 if (sms_data->file_update_ind NEQ NULL)
1687 {
1688 T_SIM_FILE_UPDATE_IND *file_update_ind = sms_data->file_update_ind;
1689 sms_data->file_update_ind = NULL;
1690 tl_sim_file_update_ind (file_update_ind);
1691 }
1692 #endif
1693 break;
1694 }
1695 else
1696 {
1697 /*
1698 * RL_RELEASE_REQ ==>
1699 */
1700 rl_release_req(SMS_INST.ti);
1701 return;
1702 }
1703 }
1704 else if (GET_STATE (STATE_MMI) EQ MMI_RESUME)
1705 {
1706 /*
1707 * <<acknowledgment>> of SMMA message for
1708 * user initiated RESUME
1709 * we expect here that the given tl_report_ind signal
1710 * is generated in the following cases:
1711 * - success (positive ack for smma)
1712 * - error (negative ack for smma)
1713 * - repeated timeout (waiting for ack exceeded limit)
1714 */
1715 /*
1716 * Unset memory full condition in any case
1717 */
1718 sms_data->pr_cntrl.delivery_state = SMS_DELIVER_STATUS_RESUME;
1719 /*
1720 * save cause
1721 */
1722 if (IS_CAUSE_INVALID(cause))
1723 {
1724 sms_data->pr_cntrl.save_cause = SMS_NO_ERROR;
1725 }
1726 else
1727 {
1728 sms_data->pr_cntrl.save_cause = cause;
1729 }
1730 /*
1731 * Unset notification flag on sim
1732 */
1733 tl_sms_memo_resume();
1734 break;
1735 }
1736 else if (GET_STATE (STATE_MMI) NEQ MMI_IDLE)
1737 {
1738 SET_STATE (STATE_MMI, MMI_IDLE);
1739 #ifdef SIM_TOOLKIT
1740 if (sms_data->file_update_ind NEQ NULL)
1741 {
1742 T_SIM_FILE_UPDATE_IND *file_update_ind = sms_data->file_update_ind;
1743 sms_data->file_update_ind = NULL;
1744 tl_sim_file_update_ind (file_update_ind);
1745 }
1746 #endif
1747 break;
1748 }
1749 /*FALLTHROUGH*/ /*lint -fallthrough*/
1750
1751 /* -------------------------------------- */
1752 case TL_IDLE:
1753 /* -------------------------------------- */
1754
1755 if (SMS_ENT_STATE(sms_data) EQ SMS_STATE_INITIALISING)
1756 {
1757 if (!tl_sms_memo_exceeded (TRUE))
1758 {
1759 tl_mnsms_report_ind (SMS_ENT_STATE(sms_data) = SMS_STATE_READY);
1760 break;
1761 }
1762 else
1763 {
1764 /*
1765 * RL_RELEASE_REQ ==>
1766 */
1767 rl_release_req(SMS_INST.ti);
1768 return;
1769 }
1770 }
1771 break;
1772
1773 /* -------------------------------------- */
1774 default:
1775 /* -------------------------------------- */
1776
1777 TRACE_EVENT("TL_REPORT_IND ignored");
1778 break;
1779 }
1780
1781 if (SMS_SDU(sms_data) NEQ NULL)
1782 {
1783 MFREE (SMS_SDU(sms_data));
1784 SMS_SDU(sms_data) = NULL;
1785 }
1786 SMS_SEL_REC(sms_data) = SMS_RECORD_NOT_EXIST;
1787 /*
1788 * TL State Transition TL_IDLE
1789 */
1790 SMS_INST_SET_STATE (STATE_TL, TL_IDLE);
1791 /*
1792 * RL_RELEASE_REQ ==>
1793 */
1794 rl_release_req(SMS_INST.ti);
1795 }
1796 }
1797
1798 /*
1799 +--------------------------------------------------------------------+
1800 | PROJECT : GSM-PS (8410) MODULE : SMS_TLF |
1801 | STATE : code ROUTINE : tl_cmms_end |
1802 +--------------------------------------------------------------------+
1803
1804 PURPOSE : Function used for ending the CMMS Session
1805
1806 */
1807
1808 GLOBAL void tl_cmms_end(void)
1809 {
1810 GET_INSTANCE_DATA;
1811 TRACE_FUNCTION ("tl_cmms_end()");
1812
1813 sms_data->cmms_release_pending = FALSE;
1814 sms_timer_stop(TMMS);
1815 tl_mnsms_cmms_end_ind();
1816 }
1817
1818 #endif /* #ifndef SMS_TLS_C */