comparison src/g23m-gsm/sms/sms_tls.c @ 1:fa8dc04885d8

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