comparison g23m-gsm/sms/sms_rl.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_RL
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 relay layer
18 | of the component SMS.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef SMS_RL_C
23 #define SMS_RL_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 #define SAP_RR /* get RR causes until all causes are in one document */
34 #define SAP_MMCM /* same reason */
35
36 #include <string.h>
37 #include <stdlib.h>
38 #include <stddef.h>
39 #include "typedefs.h"
40 #include "pcm.h"
41 #include "vsi.h"
42 #include "custom.h"
43 #include "gsm.h"
44 #include "message.h"
45 #include "ccdapi.h"
46 #include "prim.h"
47 #include "cus_sms.h"
48 #include "cnf_sms.h"
49 #include "mon_sms.h"
50 #include "pei.h"
51 #include "tok.h"
52 #include "sms.h"
53 #include "sms_em.h"
54
55 /*==== EXPORT ======================================================*/
56
57 /*==== PRIVAT ======================================================*/
58
59 /*==== VARIABLES ===================================================*/
60
61 /*==== FUNCTIONS ===================================================*/
62
63 /*
64 +--------------------------------------------------------------------+
65 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
66 | STATE : code ROUTINE : rl_init |
67 +--------------------------------------------------------------------+
68
69 PURPOSE : Initialize the relay layer.
70
71 */
72
73 GLOBAL void rl_init (void)
74 {
75 GET_INSTANCE_DATA;
76
77 TRACE_FUNCTION ("rl_init()");
78
79 sms_data->data[0].state[STATE_RL] = RL_IDLE;
80 sms_data->data[1].state[STATE_RL] = RL_IDLE;
81 }
82
83 /*---- SIGNALS -----------------------------------------------------*/
84
85 #ifdef GPRS
86 GLOBAL void rl_proceed (void)
87 {
88 GET_INSTANCE_DATA;
89 TRACE_FUNCTION ("rl_proceed()");
90
91 if (SMS_INST_GET_STATE (STATE_RL) EQ RL_WAIT_FOR_SEND_ERROR)
92 {
93 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
94
95 tl_report_ind (NULL, CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS,
96 SMSRP_ORIGINATING_ENTITY, SMS_RP_CS_PROTOCOL_ERROR));
97 }
98 }
99 #endif
100
101 /*
102 +--------------------------------------------------------------------+
103 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
104 | STATE : code ROUTINE : rl_data_ind |
105 +--------------------------------------------------------------------+
106
107 PURPOSE : Processing the signal RL_DATA_IND.
108
109 */
110
111 GLOBAL void rl_data_ind (T_cp_user_data_dl *cp_user_data_dl)
112 {
113 GET_INSTANCE_DATA;
114 TRACE_FUNCTION ("rl_data_ind()");
115
116 if (sms_data)
117 {
118 if (cp_user_data_dl->rp_mti EQ RP_ERROR_DL)
119 TRACE_EVENT_P1 ("RP_ERROR.CAUSE rcvd: 0x%2.2X",
120 (int)cp_user_data_dl->rp_error.rp_cause.rp_cause_value);
121
122 switch (SMS_INST_GET_STATE (STATE_RL))
123 {
124 /* ------------------------------------- */
125 case RL_ESTABLISHED:
126 /* ------------------------------------- */
127 case RL_IDLE:
128 /* ------------------------------------- */
129 {
130 SMS_RP_REF(sms_data) = cp_user_data_dl->reference;
131 if (cp_user_data_dl->rp_mti EQ RP_DATA_DL)
132 {
133 /*
134 * RL state transition RL_WAIT_FOR_SEND_ACK
135 */
136 SMS_INST_SET_STATE (STATE_RL, RL_WAIT_FOR_SEND_ACK);
137 /*
138 * start timer TR2M
139 */
140 sms_timer_start(TR2M);
141
142 SMS_EM_RECEIVE_RP_DATA;
143 /*
144 * TL_DATA_IND =>
145 */
146 tl_data_ind (&cp_user_data_dl->rp_data_dl);
147 }
148 else
149 {
150 MCAST (cp_data, U_CP_DATA);
151 /*
152 * If Message Id is unknwon then send RP-ERROR with cause #97
153 */
154 if(cp_user_data_dl->rp_mti > 0x06)
155 {
156 rl_build_rp_error (cp_user_data_dl->reference,
157 SMS_RP_CS_MSG_NON_EXIST,
158 cp_data, NULL);
159 }
160 else
161 {
162 rl_build_rp_error (cp_user_data_dl->reference,
163 SMS_RP_CS_MSG_NOT_COMP,
164 cp_data, NULL);
165 }
166
167 SMS_EM_SEND_RP_ERROR;
168
169 cp_data_req (cp_data);
170 /*
171 * CP_RELEASE_REQ =>
172 */
173 TRACE_EVENT("CP_RELEASE_REQ_1");
174
175 cp_release_req (SMS_INST.ti);
176 /*
177 * free instance
178 */
179 FREE_SMS_INSTANCE (SMS_INST.ti);
180 }
181 break;
182 }
183
184 /* ------------------------------------- */
185 case RL_WAIT_FOR_ACK:
186 /* ------------------------------------- */
187
188 TRACE_FUNCTION ("rl_data_ind(): RP_WAIT_FOR_ACK");
189
190 switch (cp_user_data_dl->rp_mti)
191 {
192 case RP_ACK_DL:
193 TRACE_FUNCTION ("rl_data_ind(): RP_ACK_DL");
194 /*
195 * stop timer TR1M
196 */
197 sms_timer_stop(TR1M);
198 /*
199 * RL state transition RL_IDLE
200 */
201 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
202
203 /*
204 * if CMMS mode is 1 or 2 then only make cmm_release_pending TRUE
205 */
206 if(CMMS_ACTIVE)
207 {
208 sms_data->cmms_release_pending = TRUE;
209 }
210
211 /*
212 * TL_REPORT_IND =>
213 */
214 tl_report_ind (((cp_user_data_dl->rp_ack.v_rp_user_data)?
215 &cp_user_data_dl->rp_ack.rp_user_data:
216 NULL), SMS_NO_ERROR);
217
218 /* Since the transmission is successful, the data stored for
219 retransmission can be freed */
220 if (SMS_DATA_REQ(sms_data) NEQ NULL)
221 {
222 PFREE (SMS_DATA_REQ(sms_data));
223 SMS_DATA_REQ(sms_data) = NULL;
224 }
225
226 SMS_EM_RECEIVE_RP_AKNOWLEDGE;
227
228 break;
229
230 case RP_ERROR_DL:
231 /* When an RP-error with appropriate case value is
232 * is received, Retransmission of SMS is started
233 */
234 {
235 #ifdef REL99
236 BOOL retrans_flag = FALSE;
237 #endif
238 TRACE_FUNCTION ("rl_data_ind(): RP_ERROR_DL");
239 /*
240 * stop timer TR1M
241 */
242 sms_timer_stop(TR1M);
243 /*
244 * if CMMS mode is 1 or 2 then only make cmm_release_pending TRUE
245 */
246 if(CMMS_ACTIVE)
247 {
248 sms_data->cmms_release_pending = TRUE;
249 }
250 #ifdef REL99
251 /*
252 * This is done for Retransmission for the causes
253 * listed in the table 8.4/3gPP TS 24.011(Part 1)
254 */
255 if (SMS_INST.tl_retx < TL_MAX_RETANS)
256 {
257 /* Check whether the cause value satisfies the one for retransmission
258 * listed in the table 8.4/3gPP TS 24.011(Part 1)
259 */
260 switch(cp_user_data_dl->rp_error.rp_cause.rp_cause_value)
261 {
262 case SMS_RP_CS_UNASSIGNED_NUMBER:
263 case SMS_RP_CS_OPERATOR_DET_BARRED:
264 case SMS_RP_CS_CALL_BARRED:
265 case SMS_RP_CS_SM_TRANSFER_REJECTED:
266 case SMS_RP_CS_MEM_CAP_EXCEEDED:
267 case SMS_RP_CS_UNIDENT_SUBSCRIBER:
268 case SMS_RP_CS_FACILITY_REJECTED:
269 case SMS_RP_CS_UNKNOWN_SUBSCRIBER:
270 case SMS_RP_CS_NET_OUT_OF_ORDER:
271 case SMS_RP_CS_NO_RESOURCES:
272 case SMS_RP_CS_FAC_NOT_SUBSCRIBED:
273 case SMS_RP_CS_FAC_NOT_IMPL:
274 case SMS_RP_CS_INV_SM_TR_REF_VAL:
275 case SMS_RP_CS_SEM_INC_MSG:
276 case SMS_RP_CS_INV_MAND_INFO:
277 case SMS_RP_CS_MSG_NON_EXIST:
278 case SMS_RP_CS_INFO_NON_EXIST:
279 case SMS_RP_CS_PROTOCOL_ERROR:
280 case SMS_RP_CS_INTERWORKING:
281 retrans_flag = FALSE;
282 break;
283 /* All values other than the ones above are treated as temporary
284 failures. This includes SMS_RP_CS_DEST_OUT_OF_ORDER,
285 SMS_RP_CS_TEMP_FAILURE, SMS_RP_CS_CONGESTION,
286 SMS_RP_CS_MSG_NOT_COMP and others non-standard values
287 are taken as temporary error */
288 default:
289 retrans_flag = TRUE;
290 break;
291 }
292 }
293 if(retrans_flag EQ TRUE)
294 {
295 TRACE_EVENT ("Retransmission cause received");
296 cp_release_req(SMS_INST.ti);
297 TIMERSTART (SMS_INST_TR1M, 20000);
298 TRACE_EVENT ("Delay expiry TR1M, retransmit");
299 }
300 else
301 #endif
302 {
303 /*
304 * RL state transition RL_IDLE
305 */
306 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
307 tl_report_ind (((cp_user_data_dl->rp_error.v_rp_user_data)?
308 &cp_user_data_dl->rp_error.rp_user_data: NULL),
309 CAUSE_MAKE(DEFBY_STD, ORIGSIDE_NET, SMSRP_ORIGINATING_ENTITY,
310 cp_user_data_dl->rp_error.rp_cause.rp_cause_value));
311 SMS_EM_RECEIVE_RP_ERROR;
312 }
313 }
314 break;
315
316 default:
317 TRACE_FUNCTION ("rl_data_ind(): default");
318
319 /*
320 * stop timer TR1M
321 */
322 sms_timer_stop(TR1M);
323
324 {
325 MCAST (cp_data_ul, U_CP_DATA);
326 /*
327 * If Message Id is unknwon then send RP-ERROR with cause #97
328 */
329 if(cp_user_data_dl->rp_mti > 0x06)
330 {
331 rl_build_rp_error (cp_user_data_dl->reference,
332 SMS_RP_CS_MSG_NON_EXIST,
333 cp_data_ul, NULL);
334 }
335 else
336 {
337 rl_build_rp_error (cp_user_data_dl->reference,
338 SMS_RP_CS_PROTOCOL_ERROR,
339 cp_data_ul, NULL);
340 }
341
342 cp_data_req (cp_data_ul);
343 }
344 #ifdef GPRS /* interworking from flow control */
345 if (SMS_LLC_FLOW(sms_data) NEQ SMS_LLC_BUSY_WAITING)
346 #endif
347 {
348 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
349
350 /*
351 * if CMMS mode is 1 or 2 and current link used is GSM then only
352 * make cmm_release_pending TRUE
353 */
354 #ifdef GPRS
355 if(CMMS_ACTIVE AND (SMS_INST.downlink EQ SMS_DOWNLINK_MMSMS))
356 {
357 sms_data->cmms_release_pending = TRUE;
358 }
359 #endif
360 /*
361 * TL_REPORT_IND =>
362 */
363 /*
364 * If Message Id is unknwon then send TL REPORT IND with cause #97
365 */
366 if(cp_user_data_dl->rp_mti > 0x06)
367 {
368 tl_report_ind (NULL, CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS,
369 SMSRP_ORIGINATING_ENTITY, SMS_RP_CS_MSG_NON_EXIST));
370 }
371 else
372 {
373 tl_report_ind (NULL, CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS,
374 SMSRP_ORIGINATING_ENTITY, SMS_RP_CS_PROTOCOL_ERROR));
375 }
376
377 }
378 #ifdef GPRS
379 else
380 {
381 SMS_INST_SET_STATE (STATE_RL, RL_WAIT_FOR_SEND_ERROR);
382 }
383 #endif
384
385 SMS_EM_RECEIVE_UNKNOWN_2;
386
387 break;
388 }
389
390 break;
391
392 case RL_WAIT_FOR_SEND_ACK:
393 TRACE_FUNCTION ("rl_data_ind(): RP_WAIT_FOR_SEND_ACK");
394 {
395 MCAST (cp_data_ul, U_CP_DATA);
396 /*
397 * If Message Id is unknwon then send RP-ERROR with cause #97
398 */
399 if(cp_user_data_dl->rp_mti > 0x06)
400 {
401 rl_build_rp_error (cp_user_data_dl->reference,
402 SMS_RP_CS_MSG_NON_EXIST,
403 cp_data_ul, NULL);
404 }
405 else
406 {
407 rl_build_rp_error (cp_user_data_dl->reference,
408 SMS_RP_CS_PROTOCOL_ERROR,
409 cp_data_ul, NULL);
410 }
411 cp_data_req (cp_data_ul);
412
413 }
414 break;
415
416 /* ------------------------------------- */
417 case RL_WAIT_FOR_SMMA_ACK:
418 /* ------------------------------------- */
419
420 TRACE_FUNCTION ("rl_data_ind(): RP_WAIT_FOR_SMMA_ACK");
421
422 switch (cp_user_data_dl->rp_mti)
423 {
424 case RP_ACK_DL:
425 TRACE_FUNCTION ("rl_data_ind(): RP_ACK_DL");
426 /*
427 * stop timer TR1M
428 */
429 sms_timer_stop(TR1M);
430
431 SMS_INST.retrans = FALSE;
432 /*
433 * RL state transition RL_IDLE
434 */
435 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
436 /*
437 * TL_REPORT_IND =>
438 */
439 tl_report_ind (NULL, SMS_NO_ERROR);
440 break;
441
442 case RP_ERROR_DL:
443 TRACE_FUNCTION ("rl_data_ind(): RP_ERROR_DL");
444
445 if (rl_temp_failure (cp_user_data_dl->rp_error.
446 rp_cause.rp_cause_value))
447 {
448 if (SMS_INST.retrans)
449 {
450 /*
451 * RL state transition RL_IDLE
452 */
453 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
454 SMS_INST.retrans = FALSE;
455
456 /*
457 * TL_REPORT_IND =>
458 */
459 tl_report_ind (NULL,
460 CAUSE_MAKE(DEFBY_STD, ORIGSIDE_NET, SMSRP_ORIGINATING_ENTITY,
461 cp_user_data_dl->rp_error.rp_cause.rp_cause_value));
462 sms_timer_stop(TR1M);
463
464 tl_sms_memo_exceeded (TRUE);
465 /*
466 * stop timer TR1M
467 */
468 }
469 else
470 {
471 SMS_INST.retrans = TRUE;
472 /*
473 * RL state transition RL_WAIT_FOR_RETRANS_TIMER
474 */
475 SMS_INST_SET_STATE (STATE_RL, RL_WAIT_FOR_RETRANS_TIMER);
476 /*
477 * stop timer TR1M
478 */
479 sms_timer_stop(TR1M);
480 /*
481 * start timer TRAM
482 */
483 sms_timer_start(TRAM);
484 /*
485 * CP_RELEASE_REQ =>
486 */
487 TRACE_EVENT("CP_RELEASE_REQ_11");
488 cp_release_req (SMS_INST.ti);
489
490 }
491 }
492 else
493 {
494 /*
495 * stop timer TR1M
496 */
497
498 sms_timer_stop(TR1M);
499 SMS_INST.retrans = FALSE;
500 /*
501 * RL state transition RL_IDLE
502 */
503 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
504 /*
505 * TL_REPORT_IND =>
506 */
507
508 tl_report_ind (NULL,
509 CAUSE_MAKE(DEFBY_STD, ORIGSIDE_NET, SMSRP_ORIGINATING_ENTITY,
510 cp_user_data_dl->rp_error.rp_cause.rp_cause_value));
511
512 tl_sms_memo_exceeded (TRUE);
513
514 }
515 break;
516
517 default:
518 TRACE_FUNCTION ("rl_data_ind(): default");
519 /*
520 * stop timer TR1M
521 */
522 sms_timer_stop(TR1M);
523
524 SMS_INST.retrans = FALSE;
525 /*
526 * RL state transition RL_IDLE
527 */
528 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
529 /*
530 * If Message Id is unknwon then send RP-ERROR with cause #97
531 */
532 if(cp_user_data_dl->rp_mti > 0x06)
533 {
534 MCAST (cp_data, U_CP_DATA);
535 rl_build_rp_error (cp_user_data_dl->reference,
536 SMS_RP_CS_MSG_NON_EXIST,
537 cp_data, NULL);
538 SMS_EM_SEND_RP_ERROR;
539 cp_data_req (cp_data);
540 tl_report_ind (NULL, CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS,
541 SMSRP_ORIGINATING_ENTITY, SMS_RP_CS_MSG_NON_EXIST));
542 }
543 break;
544 }
545 break;
546 }
547 }
548 }
549
550 /*
551 +--------------------------------------------------------------------+
552 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
553 | STATE : code ROUTINE : rl_establish_req |
554 +--------------------------------------------------------------------+
555
556 PURPOSE : Processing the signal RL_ESTABLISH_REQ.
557
558 */
559
560 GLOBAL void rl_establish_req (UBYTE ti)
561 {
562 GET_INSTANCE_DATA;
563 TRACE_FUNCTION_P1 ("rl_establish_req(TI=%u)", ti);
564 switch (SMS_INST_GET_STATE (STATE_RL))
565 {
566 case RL_IDLE:
567 /*
568 * RL state transition RL_ESTABLISH
569 */
570 SMS_INST_SET_STATE (STATE_RL, RL_ESTABLISH);
571 /*
572 * CP_ESTABLISH_REQ =>
573 */
574 cp_establish_req(ti);
575 /*
576 * start timer TR1M
577 */
578 sms_data->timer_ti = ti;
579 sms_timer_start(TR1M);
580 break;
581 default:
582 TRACE_ERROR("RL_ESTABLISH_REQ in wrong state received!");
583 }
584 }
585
586 /*
587 +--------------------------------------------------------------------+
588 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
589 | STATE : code ROUTINE : rl_establish_cnf |
590 +--------------------------------------------------------------------+
591
592 PURPOSE : Processing the signal RL_ESTABLISH_CNF.
593
594 */
595
596 GLOBAL void rl_establish_cnf (BOOL success)
597 {
598 GET_INSTANCE_DATA;
599 TRACE_FUNCTION ("rl_establish_cnf()");
600 switch (SMS_INST_GET_STATE (STATE_RL))
601 {
602 case RL_ESTABLISH:
603 /*
604 * stop timer TR1M
605 */
606 sms_timer_stop(TR1M);
607 if (success EQ TRUE)
608 {
609 /*
610 * RL state transition RL_ESTABLISHED
611 */
612 SMS_INST_SET_STATE (STATE_RL, RL_ESTABLISHED);
613 }
614 else
615 {
616 /*
617 * RL state transition RL_IDLE
618 */
619 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
620 }
621 /*
622 * TL_ESTABLISH_CNF =>
623 */
624 tl_establish_cnf(success);
625 break;
626 default:
627 TRACE_ERROR("RL_ESTABLISH_CNF in wrong state received!");
628 }
629 }
630
631 /*
632 +--------------------------------------------------------------------+
633 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
634 | STATE : code ROUTINE : rl_release_req |
635 +--------------------------------------------------------------------+
636
637 PURPOSE : Processing the signal RL_RELEASE_REQ.
638
639 */
640
641 GLOBAL void rl_release_req ( UBYTE ti)
642 {
643 TRACE_FUNCTION_P1 ("rl_release_req(TI=%u)", ti);
644 /*
645 * CP_RELEASE_REQ =>
646 */
647 TRACE_EVENT("CP_RELEASE_REQ_13");
648 cp_release_req(ti);
649 }
650
651 /*
652 +--------------------------------------------------------------------+
653 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
654 | STATE : code ROUTINE : rl_data_req |
655 +--------------------------------------------------------------------+
656
657 PURPOSE : Processing the signal RL_DATA_REQ.
658
659 */
660 GLOBAL BOOL rl_data_req (UBYTE msg_ref,
661 T_U_CP_DATA *cp_data)
662 {
663 GET_INSTANCE_DATA;
664 TRACE_FUNCTION ("rl_data_req()");
665
666 if (sms_data)
667 {
668 switch (SMS_INST_GET_STATE (STATE_RL))
669 {
670 case RL_ESTABLISHED:
671 {
672 SMS_INST.msg_ref = msg_ref;
673 /*
674 * RL state transtion RL_WAIT_FOR_ACK
675 */
676 SMS_INST_SET_STATE (STATE_RL, RL_WAIT_FOR_ACK);
677
678 SMS_EM_SEND_RP_DATA;
679
680 cp_data->cp_user_data_ul.rp_mti = RP_DATA_UL;
681 cp_data->cp_user_data_ul.reference = msg_ref;
682 /*
683 * CP_DATA_REQ =>
684 */
685 cp_data_req (cp_data);
686 /*
687 * start timer TR1M
688 */
689 sms_timer_start(TR1M);
690
691 return TRUE;
692 }
693 default:
694 TRACE_ERROR("RL_DATA_REQ in wrong state received!");
695 break;
696 }
697 }
698 return FALSE;
699 }
700
701 /*
702 +--------------------------------------------------------------------+
703 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
704 | STATE : code ROUTINE : rl_error_ind |
705 +--------------------------------------------------------------------+
706
707 PURPOSE : Processing the signal RL_ERROR_IND.
708
709 */
710
711 GLOBAL void rl_error_ind (USHORT cause)
712 {
713 GET_INSTANCE_DATA;
714 TRACE_FUNCTION ("rl_error_ind()");
715
716 if (sms_data)
717 {
718 switch (SMS_INST_GET_STATE (STATE_RL))
719 {
720 /* --------------------------------- */
721 case RL_ESTABLISH:
722 /* --------------------------------- */
723
724 if ( SMS_INST.tl_retx < TL_MAX_RETANS )
725 {
726 switch ( cause )
727 {
728 case MMCM_MMCS_MESSAGE_INCOMPAT:
729 case RRCS_NORM:
730 /*
731 * start timer TR1M with value
732 */
733 TIMERSTART ( SMS_INST_TR1M, 20000 );
734 TRACE_EVENT ( "Delay expiry TR1M, retransmit" );
735 return;
736
737 default: /* No retransmission */
738 break;
739 }
740 }
741
742 /*
743 * stop timer TR1M
744 */
745 sms_timer_stop(TR1M);
746 /*FALLTHROUGH*/ /*lint -fallthrough*/
747 /* --------------------------------- */
748 case RL_ESTABLISHED:
749 /* --------------------------------- */
750 /*
751 * RL state transition RL_IDLE
752 */
753 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
754 /*
755 * free instance
756 */
757 FREE_SMS_INSTANCE (SMS_INST.ti);
758 /*
759 * TL_REPORT_IND
760 */
761 tl_report_ind (NULL, cause);
762 break;
763
764 /* --------------------------------- */
765 case RL_WAIT_FOR_ACK:
766 /* --------------------------------- */
767 TRACE_FUNCTION ("rl_error_ind(): RL_WAIT_FOR_ACK");
768 /*
769 * The following code is to implement a subset of
770 * 3GPP 23.040 Release 1999 subclause 9.2.3.6.
771 * For certain errors the SMS SUBMIT / SMS COMMAND is repeated
772 * after timeout of TR1M.
773 */
774 TRACE_EVENT_P2 ("TL retrans #%d, error_cs %04x",
775 SMS_INST.tl_retx,
776 cause);
777
778 if (SMS_INST.tl_retx < TL_MAX_RETANS)
779 {
780 switch (cause)
781 {
782 case SMS_CAUSE_NET_TIMEOUT:
783 /* 11.10 test case 34.2.2 step 68 */
784 /*
785 * start timer TR1M with value
786 */
787 TIMERSTART (SMS_INST_TR1M, 20000);
788 TRACE_EVENT ("Delay expiry TR1M, retransmit");
789 return;
790
791 case RRCS_NORM:
792 case MMCM_MMCS_MESSAGE_INCOMPAT: /* Make cingular happy, #19189 */
793 TRACE_EVENT ("Retransmission after TR1M");
794 return;
795
796 default: /* No retransmission */
797 break;
798 }
799 }
800 /*
801 * stop timer TR1M
802 */
803 sms_timer_stop(TR1M);
804 /*
805 * RL state transition RL_IDLE
806 */
807 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
808 /*
809 * free instance
810 */
811 FREE_SMS_INSTANCE (SMS_INST.ti);
812 /*
813 * TL_REPORT_IND =>
814 */
815 tl_report_ind (NULL, cause);
816 break;
817
818 /* --------------------------------- */
819 case RL_WAIT_FOR_SEND_ACK:
820 /* --------------------------------- */
821
822 TRACE_FUNCTION ("rl_error_ind(): RL_WAIT_FOR_SEND_ACK");
823 /*
824 * free instance
825 */
826 FREE_SMS_INSTANCE (SMS_INST.ti);
827 /*
828 * stop timer TR2M
829 */
830 sms_timer_stop(TR2M);
831 /*
832 * RL state transition RL_IDLE
833 */
834 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
835 /*
836 * TL_REPORT_IND =>
837 */
838 tl_report_ind (NULL, cause);
839 break;
840
841 /* --------------------------------- */
842 case RL_WAIT_FOR_SMMA_ACK:
843 /* --------------------------------- */
844
845 TRACE_FUNCTION ("rl_error_ind(): RL_WAIT_FOR_SMMA_ACK");
846
847 // FREE_SMS_INSTANCE (SMS_INST.ti);
848
849 if (SMS_INST.retrans)
850 {
851 /*
852 * RL state transition RL_IDLE
853 */
854 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
855 SMS_INST.retrans = FALSE;
856 /*
857 * TL_REPORT_IND =>
858 */
859 tl_report_ind (NULL, SMS_CAUSE_NET_TIMEOUT);
860 /*
861 * stop timer TR1M
862 */
863 sms_timer_stop(TR1M);
864 tl_sms_memo_exceeded (TRUE);
865
866 }
867 else
868 {
869 SMS_INST.retrans = TRUE;
870 /*
871 * RL state transition RL_WAIT_FOR_RETRANS_TIMER
872 */
873 SMS_INST_SET_STATE (STATE_RL, RL_WAIT_FOR_RETRANS_TIMER);
874 /*
875 * stop timer TR1M
876 */
877 sms_timer_stop(TR1M);
878 /*
879 * start timer TRAM
880 */
881 sms_timer_start(TRAM);
882 /*
883 * CP_RELEASE_REQ =>
884 */
885 TRACE_EVENT("CP_RELEASE_REQ_15");
886 cp_release_req (SMS_INST.ti);
887
888 /*
889 * free instance
890 */
891 FREE_SMS_INSTANCE (SMS_INST.ti);
892 }
893
894 break;
895
896
897 default:
898
899 if(CMMS_ACTIVE)
900 {
901 tl_cmms_end();
902 }
903 /*
904 * free instance
905 */
906 FREE_SMS_INSTANCE (SMS_INST.ti);
907 /*
908 * RL state transition RL_IDLE
909 */
910
911 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
912 break;
913 }
914 }
915 }
916
917 /*
918 +--------------------------------------------------------------------+
919 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
920 | STATE : code ROUTINE : rl_mem_avail_req |
921 +--------------------------------------------------------------------+
922
923 PURPOSE : Processing the signal RL_MEM_AVAIL_REQ.
924
925 */
926
927 GLOBAL BOOL rl_mem_avail_req (void)
928 {
929 GET_INSTANCE_DATA;
930 TRACE_FUNCTION ("rl_mem_avail_req()");
931
932 if (sms_data)
933 {
934 switch (SMS_INST_GET_STATE (STATE_RL))
935 {
936 case RL_ESTABLISHED:
937 {
938 CCD_START;
939 {
940 MCAST (cp_data, U_CP_DATA);
941 /*
942 * RL state transition RL_WAIT_FOR_SMMA_ACK
943 */
944 SMS_INST_SET_STATE (STATE_RL, RL_WAIT_FOR_SMMA_ACK);
945 SMS_RP_REF(sms_data) = SMS_INST.tp_mr;
946
947 rl_build_rp_smma (SMS_RP_REF(sms_data), cp_data);
948
949 CCD_END;
950 /*
951 * CP_DATA_REQ =>
952 */
953 cp_data_req (cp_data);
954 }
955 /*
956 * start timer TR1M
957 */
958 sms_timer_start(TR1M);
959 return TRUE;
960
961 default:
962 TRACE_ERROR("RL_MEM_AVAIL_REQ in wrong state received!");
963 break;
964 }
965 }
966 }
967 return FALSE;
968 }
969
970 /*
971 +--------------------------------------------------------------------+
972 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
973 | STATE : code ROUTINE : rl_start_tram_req |
974 +--------------------------------------------------------------------+
975
976 PURPOSE : Processing the signal RL_START_TRAM_REQ.
977
978 */
979
980 GLOBAL void rl_start_tram_req (void)
981 {
982 GET_INSTANCE_DATA;
983 TRACE_FUNCTION ("rl_start_tram_req()");
984
985 SMS_INST.retrans = TRUE;
986 /*
987 * RL state transition RL_WAIT_FOR_RETRANS_TIMER
988 */
989 SMS_INST_SET_STATE (STATE_RL, RL_WAIT_FOR_RETRANS_TIMER);
990 /*
991 * start timer TRAM
992 */
993 sms_timer_start(TRAM);
994 }
995
996 /*
997 +--------------------------------------------------------------------+
998 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
999 | STATE : code ROUTINE : rl_build_rp_ack |
1000 +--------------------------------------------------------------------+
1001
1002 PURPOSE : Processing the function RL_BUILD_RP_ACK.
1003
1004 */
1005
1006 LOCAL void rl_build_rp_ack (UBYTE msg_ref,
1007 T_U_CP_DATA *cp_data,
1008 T_rp_user_data *rp_user_data)
1009 {
1010 TRACE_FUNCTION ("rl_build_rp_ack()");
1011
1012 memset (&cp_data->cp_user_data_ul.rp_ack, 0, sizeof (T_rp_ack));
1013
1014 cp_data->msg_type = U_CP_DATA;
1015 cp_data->cp_user_data_ul.rp_mti = RP_ACK_UL;
1016 cp_data->cp_user_data_ul.reference = msg_ref;
1017
1018 cp_data->cp_user_data_ul.v_rp_data_ul = FALSE;
1019 cp_data->cp_user_data_ul.v_rp_error = FALSE;
1020 cp_data->cp_user_data_ul.v_rp_ack = TRUE;
1021
1022 if (rp_user_data NEQ NULL AND rp_user_data->v_tpdu)
1023 {
1024 memcpy (&cp_data->cp_user_data_ul.rp_ack.rp_user_data,
1025 rp_user_data, sizeof (T_rp_user_data));
1026 cp_data->cp_user_data_ul.rp_ack.v_rp_user_data = TRUE;
1027 }
1028 }
1029
1030 /*
1031 +--------------------------------------------------------------------+
1032 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
1033 | STATE : code ROUTINE : rl_report_req_ack |
1034 +--------------------------------------------------------------------+
1035
1036 PURPOSE : Processing the signal RL_REPORT_REQ_ACK.
1037
1038 */
1039
1040 GLOBAL void rl_report_req_ack (T_rp_user_data *rp_user_data)
1041 {
1042 GET_INSTANCE_DATA;
1043 TRACE_FUNCTION ("rl_report_req_ack()");
1044
1045 if (sms_data)
1046 {
1047 switch (SMS_INST_GET_STATE (STATE_RL))
1048 {
1049 case RL_WAIT_FOR_SEND_ACK:
1050 {
1051 MCAST (cp_data, U_CP_DATA);
1052 /*
1053 * stop timer TR2M
1054 */
1055 sms_timer_stop(TR2M);
1056
1057 rl_build_rp_ack (SMS_RP_REF(sms_data), cp_data, rp_user_data);
1058 /*
1059 * RL state transition RL_IDLE
1060 */
1061 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
1062 /*
1063 * CP_DATA / RP_ACK ==>
1064 */
1065 cp_data_req (cp_data);
1066 /*
1067 * CP_RELEASE_REQ =>
1068 */
1069 TRACE_EVENT("CP_RELEASE_REQ_16");
1070 cp_release_req (SMS_INST.ti);
1071 break;
1072 }
1073 default:
1074 break;
1075 }
1076 }
1077 }
1078
1079 /*
1080 +--------------------------------------------------------------------+
1081 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
1082 | STATE : code ROUTINE : rl_build_rp_error |
1083 +--------------------------------------------------------------------+
1084
1085 PURPOSE : Processing the function RL_BUILD_RP_ERROR.
1086
1087 */
1088
1089 GLOBAL void rl_build_rp_error (UBYTE msg_ref,
1090 USHORT error,
1091 T_U_CP_DATA *cp_data,
1092 T_rp_user_data *rp_user_data)
1093 {
1094 TRACE_FUNCTION ("rl_build_rp_error()");
1095 TRACE_EVENT_P1 ("RP_ERROR.CAUSE sent: 0x%2.2X", (int)error);
1096
1097 memset (&cp_data->cp_user_data_ul.rp_error, 0, sizeof (T_rp_error));
1098
1099 cp_data->msg_type = U_CP_DATA;
1100 cp_data->cp_user_data_ul.rp_mti = RP_ERROR_UL;
1101 cp_data->cp_user_data_ul.reference = msg_ref;
1102
1103 cp_data->cp_user_data_ul.v_rp_data_ul = FALSE;
1104 cp_data->cp_user_data_ul.v_rp_ack = FALSE;
1105 cp_data->cp_user_data_ul.v_rp_error = TRUE;
1106
1107 cp_data->cp_user_data_ul.rp_error.
1108 rp_cause.v_rp_cause_value = TRUE;
1109 if (error < 128) /* GSM 04.11 cause */
1110 {
1111 cp_data->cp_user_data_ul.rp_error.
1112 rp_cause.rp_cause_value = (UBYTE)error;
1113 }
1114 else
1115 {
1116 cp_data->cp_user_data_ul.rp_error.
1117 rp_cause.rp_cause_value = SMS_RP_CS_PROTOCOL_ERROR;
1118 cp_data->cp_user_data_ul.rp_error.
1119 v_rp_user_data = TRUE;
1120 }
1121 if (rp_user_data NEQ NULL AND rp_user_data->v_tpdu)
1122 {
1123 memcpy (&cp_data->cp_user_data_ul.rp_error.rp_user_data,
1124 rp_user_data, sizeof (T_rp_user_data));
1125 cp_data->cp_user_data_ul.rp_error.v_rp_user_data = TRUE;
1126 }
1127 }
1128
1129 /*
1130 +--------------------------------------------------------------------+
1131 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
1132 | STATE : code ROUTINE : rl_report_req_error |
1133 +--------------------------------------------------------------------+
1134
1135 PURPOSE : Processing the signal RL_REPORT_REQ_ERROR.
1136
1137 */
1138
1139 GLOBAL void rl_report_req_error (USHORT cause,
1140 T_rp_user_data *rp_user_data)
1141 {
1142 GET_INSTANCE_DATA;
1143 TRACE_FUNCTION ("rl_report_req_error()");
1144
1145 if (sms_data)
1146 {
1147 switch (SMS_INST_GET_STATE (STATE_RL))
1148 {
1149 case RL_WAIT_FOR_SEND_ACK:
1150 {
1151 MCAST (cp_data, U_CP_DATA);
1152 /*
1153 * stop timer TR2M
1154 */
1155 sms_timer_stop(TR2M);
1156
1157 rl_build_rp_error (SMS_RP_REF(sms_data), cause,
1158 cp_data, rp_user_data);
1159 /*
1160 * RL state transition RL_IDLE
1161 */
1162 SMS_INST_SET_STATE (STATE_RL, RL_IDLE);
1163 /*
1164 * CP_DATA / RP_ERROR ==>
1165 */
1166 cp_data_req (cp_data);
1167 break;
1168 }
1169 default:
1170 break;
1171 }
1172 }
1173 }
1174
1175 #if defined (GPRS)
1176 /*
1177 +--------------------------------------------------------------------+
1178 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
1179 | STATE : code ROUTINE : rl_build_rp_error_gprs |
1180 +--------------------------------------------------------------------+
1181
1182 PURPOSE : Processing the function RL_BUILD_RP_ERROR for GSMS.
1183
1184 */
1185
1186 GLOBAL void rl_build_rp_error_gprs (UBYTE ti,
1187 T_LL_UNITDATA_REQ *data_req,
1188 USHORT error,
1189 UBYTE msg_ref,
1190 T_U_CP_DATA *cp_data,
1191 T_stk_cmd *stk_cmd)
1192 {
1193 TRACE_FUNCTION ("rl_build_rp_error_gprs()");
1194 TRACE_EVENT_P1 ("RP_ERROR.CAUSE sent: 0x%4.2X", (int)error);
1195
1196 data_req->sdu.o_buf = ENCODE_OFFSET;
1197
1198 cp_data->msg_type = U_CP_DATA;
1199 cp_data->cp_user_data_ul.rp_mti = RP_ERROR_UL;
1200 cp_data->cp_user_data_ul.reference = msg_ref;
1201
1202 cp_data->cp_user_data_ul.v_rp_data_ul = FALSE;
1203 cp_data->cp_user_data_ul.v_rp_error = TRUE;
1204
1205 memset (&cp_data->cp_user_data_ul.rp_error.rp_cause, 0,
1206 sizeof (T_rp_cause));
1207
1208 cp_data->cp_user_data_ul.rp_error.
1209 rp_cause.v_rp_cause_value = TRUE;
1210 if (error < 128) /* GSM 04.11 cause */
1211 {
1212 cp_data->cp_user_data_ul.rp_error.
1213 rp_cause.rp_cause_value = (UBYTE)error;
1214 cp_data->cp_user_data_ul.rp_error.
1215 v_rp_user_data = FALSE;
1216 }
1217 else
1218 {
1219 cp_data->cp_user_data_ul.rp_error.
1220 rp_cause.rp_cause_value = SMS_RP_CS_PROTOCOL_ERROR;
1221 cp_data->cp_user_data_ul.rp_error.
1222 v_rp_user_data = TRUE;
1223 memset (&cp_data->cp_user_data_ul.rp_error.rp_user_data,
1224 0, sizeof (T_rp_user_data));
1225 if (error >= 256) /* no GSM 03.40 cause */
1226 error = SMS_FCS_UNSPECIFIED;
1227 cp_data->cp_user_data_ul.rp_error.rp_user_data.
1228 v_tpdu = TRUE;
1229 /*
1230 cp_data->cp_user_data_ul.rp_error.rp_user_data.
1231 sms_deliver_rep_err.tp_fcs = (UBYTE)error;
1232 */
1233 }
1234
1235 ccd_codeMsg (CCDENT_SMS,
1236 UPLINK,
1237 (T_MSGBUF *) &data_req->sdu,
1238 (UBYTE *) cp_data,
1239 NOT_PRESENT_8BIT);
1240 /*lint -e415 -e416 Likely creation/access of out-of-bounds pointer */
1241 data_req->sdu.buf[3] = (ti << 4) + PD_SMS;
1242 data_req->sdu.o_buf = ENCODE_OFFSET - BSIZE_TI_PD;
1243 data_req->sdu.l_buf += BSIZE_TI_PD;
1244
1245 if (stk_cmd NEQ NULL)
1246 {
1247 /*
1248 * response from a SIM Toolkit command
1249 */
1250 if (stk_cmd->l_cmd NEQ 0)
1251 {
1252 /*
1253 * response TPDU available
1254 */
1255 /* change length of rp-error */
1256 data_req->sdu.buf[5] += ((stk_cmd->l_cmd >> 3) + 2);
1257 /* add IEI for rp user data */
1258 data_req->sdu.buf[10] = 0x41;
1259 /* add length for rp user data */
1260 data_req->sdu.buf [11] = stk_cmd->l_cmd >> 3;
1261 /* add TPDU */
1262 memcpy (&data_req->sdu.buf [12],
1263 &stk_cmd->cmd[stk_cmd->o_cmd>>3],
1264 stk_cmd->l_cmd>>3);
1265 /* modify length of CP Data */
1266 data_req->sdu.l_buf += (stk_cmd->l_cmd + 16);
1267 }
1268 }
1269 /*lint +e415 +e416 Likely creation/access of out-of-bounds pointer */
1270 }
1271 #endif /* GPRS */
1272
1273 /*
1274 +--------------------------------------------------------------------+
1275 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
1276 | STATE : code ROUTINE : rl_build_rp_smma |
1277 +--------------------------------------------------------------------+
1278
1279 PURPOSE : Processing the function RL_BUILD_RP_SMMA.
1280
1281 */
1282
1283 GLOBAL void rl_build_rp_smma (UBYTE msg_ref,
1284 T_U_CP_DATA *cp_data)
1285 {
1286 TRACE_FUNCTION ("rl_build_rp_smma()");
1287
1288 cp_data->cp_user_data_ul.rp_mti = RP_SMMA_UL;
1289 cp_data->cp_user_data_ul.reference = msg_ref;
1290
1291 cp_data->cp_user_data_ul.v_rp_data_ul = FALSE;
1292 cp_data->cp_user_data_ul.v_rp_error = FALSE;
1293 cp_data->cp_user_data_ul.v_rp_ack = FALSE;
1294 }
1295
1296 /*
1297 +--------------------------------------------------------------------+
1298 | PROJECT : GSM-PS (8410) MODULE : SMS_RL |
1299 | STATE : code ROUTINE : rl_temp_failure |
1300 +--------------------------------------------------------------------+
1301
1302 PURPOSE : Processing the function RL_TEMP_FAILURE.
1303 This is valid for memory available notification attempt.
1304 [04.11 Table 8.4 part 3]
1305 */
1306
1307 GLOBAL UBYTE rl_temp_failure (UBYTE cause)
1308 {
1309 TRACE_FUNCTION ("rl_temp_failure()");
1310
1311 switch (cause)
1312 {
1313 case SMS_RP_CS_UNKNOWN_SUBSCRIBER:
1314 case SMS_RP_CS_FAC_NOT_IMPL:
1315 case SMS_RP_CS_SEM_INC_MSG:
1316 case SMS_RP_CS_INV_MAND_INFO:
1317 case SMS_RP_CS_MSG_NON_EXIST:
1318 case SMS_RP_CS_MSG_NOT_COMP:
1319 case SMS_RP_CS_INFO_NON_EXIST:
1320 case SMS_RP_CS_PROTOCOL_ERROR:
1321 case SMS_RP_CS_INTERWORKING:
1322 return FALSE; /* Non-temporary */
1323
1324 default:
1325 return TRUE; /* Temporary */
1326 }
1327 }
1328
1329 #endif /* #ifndef SMS_RL_C */