comparison src/g23m-gsm/cc/cc_time.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-PS (6147)
4 | Modul : CC_TIME
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 timer handling functions
18 | for the component CC of the mobile station
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef CC_TIM_C
23 #define CC_TIM_C
24
25 #define ENTITY_CC
26 /*==== INCLUDES ===================================================*/
27
28 #include <string.h>
29 #include "typedefs.h"
30 #include "pcm.h"
31 #include "vsi.h"
32 #include "custom.h"
33 #include "gsm.h"
34 #include "message.h"
35 #include "ccdapi.h"
36 #include "prim.h"
37 #include "cnf_cc.h"
38 #include "mon_cc.h"
39 #include "pei.h"
40 #include "tok.h"
41 #include "cc.h"
42 #include "cc_em.h"
43
44 /*==== EXPORT =====================================================*/
45 /*==== PRIVAT =====================================================*/
46 /*==== PROTOTYPES =====================================================*/
47 /* Implements Measure# 30, 31 */
48 LOCAL void tim_mncc_rel_ind (void);
49 /*==== VARIABLES ==================================================*/
50
51 /*==== FUNCTIONS ==================================================*/
52
53 /*
54 +--------------------------------------------------------------------+
55 | PROJECT : GSM-PS (6147) MODULE : CC_TIM |
56 | STATE : code ROUTINE : tim_exec_timeout |
57 +--------------------------------------------------------------------+
58
59 PURPOSE : execute timeout
60
61 */
62
63 GLOBAL void tim_exec_timeout (USHORT index)
64 {
65 GET_INSTANCE_DATA;
66
67 TRACE_FUNCTION ("tim_exec_timeout()");
68
69 /*
70 * Processing of Timeout Function
71 */
72 if (index < MAX_CC_CALLS)
73 {
74 /*
75 * Not DTMF (T336, T337), any other CC timer
76 */
77 cc_data->ti = cc_data->stored_ti_values[index];
78 cc_data->index_ti = (UBYTE)index;
79
80 switch (cc_data->state[cc_data->index_ti])
81 {
82 case M_CC_CS_01:
83 tim_t303_u0_1 ();
84 break;
85 case M_CC_CS_03:
86 tim_t332_u0_3 ();
87 break;
88 case M_CC_CS_05:
89 tim_t335_u0_5 ();
90 break;
91 case M_CC_CS_1:
92 tim_t303_u1 ();
93 break;
94 case M_CC_CS_3:
95 tim_t310_u3 ();
96 break;
97 case M_CC_CS_8:
98 tim_t313_u8 ();
99 break;
100 case M_CC_CS_11:
101 tim_t305_u11 ();
102 break;
103 case M_CC_CS_19:
104 tim_t308_u19 ();
105 break;
106 case M_CC_CS_26:
107 tim_t323_u26 ();
108 break;
109 }
110 }
111 else
112 {
113 /*
114 * DTMF timer, either T336 or T337
115 */
116 T_DTMF * p_dtmf;
117
118 cc_data->index_ti = (UBYTE)(index - MAX_CC_CALLS);
119 cc_data->ti = cc_data->stored_ti_values[cc_data->index_ti];
120 p_dtmf = &cc_data->dtmf[cc_data->index_ti];
121
122 switch (p_dtmf->state)
123 {
124 case DTMF_SEND_REQUEST:
125 tim_t336 ();
126 break;
127 case DTMF_STOP_REQUEST:
128 tim_t337 ();
129 break;
130 default: /* Not expected */
131 break;
132 }
133 }
134 }
135 /*
136 +--------------------------------------------------------------------+
137 | PROJECT : GSM-PS (6147) MODULE : CC_TIM |
138 | STATE : code ROUTINE : tim_t303_u0_1 |
139 +--------------------------------------------------------------------+
140
141 PURPOSE : Timeout of timer T303 in state U0.1
142
143 */
144
145 GLOBAL void tim_t303_u0_1 ()
146 {
147 PALLOC (rej_ind, MNCC_REJECT_IND);
148
149 GET_INSTANCE_DATA;
150
151 TRACE_FUNCTION ("tim_t303_u0_1()");
152
153 EM_CC_TIMEOUT_T303;
154
155 rej_ind->ti = cc_data->ti;
156 rej_ind->cause = CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS, MNCC_CC_ORIGINATING_ENTITY, M_CC_CAUSE_TIMER);
157 PSENDX (MMI, rej_ind);
158 for_rel_req ();
159 cc_set_state (M_CC_CS_0);
160 }
161
162 /*
163 +--------------------------------------------------------------------+
164 | PROJECT : GSM-PS (6147) MODULE : CC_TIM |
165 | STATE : code ROUTINE : tim_t303_u1 |
166 +--------------------------------------------------------------------+
167
168 PURPOSE : Timeout of timer T303 in state U1
169
170 */
171
172 GLOBAL void tim_t303_u1 ()
173 {
174 GET_INSTANCE_DATA;
175
176 TRACE_FUNCTION ("tim_t303_u1()");
177
178 EM_CC_TIMEOUT_T303;
179
180 cc_data->timer [cc_data->index_ti] = T303;
181 cc_disconnect_after_timeout ();
182 cc_set_state (M_CC_CS_11);
183 }
184
185 /*
186 +--------------------------------------------------------------------+
187 | PROJECT : GSM-PS (6147) MODULE : CC_TIM |
188 | STATE : code ROUTINE : tim_t305_u11 |
189 +--------------------------------------------------------------------+
190
191 PURPOSE : Timeout of timer T305 in state U11
192
193 */
194
195 GLOBAL void tim_t305_u11 ()
196 {
197 PALLOC (disc_ind, MNCC_DISCONNECT_IND);
198
199 GET_INSTANCE_DATA;
200
201 TRACE_FUNCTION ("tim_t305_u11()");
202
203 cc_data->timer [cc_data->index_ti] = T305;
204 CCD_START;
205 {
206 MCAST (release, U_RELEASE);
207
208 cc_build_release (release,
209 cc_data->cc_cause[cc_data->index_ti],
210 NULL, MNCC_SS_VER_NOT_PRES);
211 for_release (release);
212 }
213 CCD_END;
214
215 disc_ind->ti = cc_data->ti;
216 disc_ind->cause = cc_data->cc_cause [cc_data->index_ti];
217 /* Setting raw_cause to empty as this is a local release
218 * of MM connection,CC is not receiving any cause value
219 * from Network
220 */
221 disc_ind->c_raw_cause = 0;
222 disc_ind->diagnostic = NOT_PRESENT_8BIT;
223 disc_ind->progress_desc = MNCC_PROG_NOT_PRES;
224 PSENDX (MMI, disc_ind);
225
226 TIMERSTART (T308, T308_VALUE);
227 cc_set_state (M_CC_CS_19);
228 }
229
230 /*
231 +--------------------------------------------------------------------+
232 | PROJECT : GSM-PS (6147) MODULE : CC_TIM |
233 | STATE : code ROUTINE : tim_t308_u19 |
234 +--------------------------------------------------------------------+
235
236 PURPOSE : Timeout of timer T308 in state U19
237
238 */
239
240 GLOBAL void tim_t308_u19 ()
241 {
242 GET_INSTANCE_DATA;
243
244 TRACE_FUNCTION ("tim_t308_u19()");
245
246 cc_data->timer [cc_data->index_ti] = T308;
247
248 if (cc_data->t308_counter [cc_data->index_ti] EQ 0)
249 {
250 CCD_START;
251 {
252 MCAST (release, U_RELEASE);
253
254 cc_data->t308_counter[cc_data->index_ti]++;
255 cc_build_release (release,
256 cc_data->cc_cause [cc_data->index_ti],
257 NULL, MNCC_SS_VER_NOT_PRES);
258 for_release (release);
259 }
260 CCD_END;
261 TIMERSTART (T308, T308_VALUE);
262 }
263 else
264 {
265 cc_reset_dtmf ();
266
267 {
268 PALLOC (rel_cnf, MNCC_RELEASE_CNF);
269 rel_cnf->ti = cc_data->ti;
270 rel_cnf->cause = CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS, MNCC_CC_ORIGINATING_ENTITY, M_CC_CAUSE_TIMER);
271 rel_cnf->c_raw_cause = 0;
272 PSENDX (MMI, rel_cnf);
273 }
274
275 for_rel_req ();
276 cc_set_state (M_CC_CS_0);
277 }
278 }
279
280 /*
281 +--------------------------------------------------------------------+
282 | PROJECT : GSM-PS (6147) MODULE : CC_TIM |
283 | STATE : code ROUTINE : tim_t310_u3 |
284 +--------------------------------------------------------------------+
285
286 PURPOSE : Timeout of timer T310 in state U3
287
288 */
289
290 GLOBAL void tim_t310_u3 ()
291 {
292 GET_INSTANCE_DATA;
293
294 TRACE_FUNCTION ("tim_t310_u3()");
295
296 cc_data->timer [cc_data->index_ti] = T310;
297 cc_disconnect_after_timeout ();
298 cc_set_state (M_CC_CS_11);
299 }
300
301 /*
302 +--------------------------------------------------------------------+
303 | PROJECT : GSM-PS (6147) MODULE : CC_TIM |
304 | STATE : code ROUTINE : tim_t313_u8 |
305 +--------------------------------------------------------------------+
306
307 PURPOSE : Timeout of timer T313 in state U8
308
309 */
310
311 GLOBAL void tim_t313_u8 ()
312 {
313 GET_INSTANCE_DATA;
314
315 PALLOC (setup_comp, MNCC_SETUP_COMPL_IND);
316
317 TRACE_FUNCTION ("tim_t313_u8()");
318
319
320 EM_CC_DISCONNECT_SENT;
321
322 cc_data->timer [cc_data->index_ti] = T313;
323 CCD_START;
324 {
325 MCAST (disconnect, U_DISCONNECT);
326
327 cc_build_disconnect (disconnect,
328 CAUSE_MAKE(DEFBY_STD,
329 ORIGSIDE_MS,
330 MNCC_CC_ORIGINATING_ENTITY,
331 M_CC_CAUSE_TIMER),
332 NULL, MNCC_SS_VER_NOT_PRES);
333 for_disconnect (disconnect);
334 }
335 CCD_END;
336
337 setup_comp->ti = cc_data->ti;
338 setup_comp->cause = CAUSE_MAKE(DEFBY_STD,
339 ORIGSIDE_MS,
340 MNCC_CC_ORIGINATING_ENTITY,
341 M_CC_CAUSE_TIMER);
342 PSENDX (MMI, setup_comp);
343 TIMERSTART (T305, T305_VALUE);
344 cc_set_state (M_CC_CS_11);
345 }
346
347 /*
348 +--------------------------------------------------------------------+
349 | PROJECT : GSM-PS (6147) MODULE : CC_TIM |
350 | STATE : code ROUTINE : tim_t323_u26 |
351 +--------------------------------------------------------------------+
352
353 PURPOSE : Timeout of timer T323 in state U26
354
355 */
356
357 GLOBAL void tim_t323_u26 ()
358 {
359 GET_INSTANCE_DATA;
360
361 PALLOC (modify_cnf, MNCC_MODIFY_CNF);
362
363 TRACE_FUNCTION ("tim_t323_u26()");
364
365
366
367 cc_data->timer [cc_data->index_ti] = T323;
368
369 CCD_START;
370 {
371 MCAST (disconnect, U_DISCONNECT);
372
373 cc_build_disconnect (disconnect,
374 CAUSE_MAKE(DEFBY_STD,
375 ORIGSIDE_MS,
376 MNCC_CC_ORIGINATING_ENTITY,
377 M_CC_CAUSE_TIMER),
378 NULL, MNCC_SS_VER_NOT_PRES);
379 for_disconnect (disconnect);
380 }
381 CCD_END;
382
383 modify_cnf->ti = cc_data->ti;
384 modify_cnf->cause = CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS, MNCC_CC_ORIGINATING_ENTITY, M_CC_CAUSE_TIMER);
385 /* Setting raw_cause to empty as we are not sending any cause from network*/
386 modify_cnf->c_raw_cause = 0;
387
388 PSENDX (MMI, modify_cnf);
389
390 TIMERSTART (T305, T305_VALUE);
391 cc_set_state (M_CC_CS_11);
392 }
393
394 /*
395 +--------------------------------------------------------------------+
396 | PROJECT : GSM-PS (6147) MODULE : CC_TIM |
397 | STATE : code ROUTINE : tim_t332_u0_3 |
398 +--------------------------------------------------------------------+
399
400 PURPOSE : Timeout of timer T332 in state U0.3
401
402 */
403
404 GLOBAL void tim_t332_u0_3 ()
405 {
406 GET_INSTANCE_DATA;
407
408 TRACE_FUNCTION ("tim_t332_u0_3()");
409
410
411 cc_data->timer [cc_data->index_ti] = T332;
412
413 /* Inform MMI */
414 /* Implements Measure# 30, 31 */
415 tim_mncc_rel_ind ();
416
417 /* Send RELEASE COMPLETE to network */
418 CCD_START;
419 {
420 MCAST (rel_com, U_RELEASE_COMP);
421 cc_build_release_complete (rel_com, CAUSE_MAKE(DEFBY_STD,
422 ORIGSIDE_MS,
423 MNCC_CC_ORIGINATING_ENTITY,
424 M_CC_CAUSE_TIMER));
425 for_release_complete (rel_com);
426 }
427 CCD_END;
428
429 /* Release MM connection */
430 for_rel_req ();
431
432 /* Next state is NULL */
433 cc_set_state (M_CC_CS_0);
434 }
435
436 /*
437 +--------------------------------------------------------------------+
438 | PROJECT : GSM-PS (6147) MODULE : CC_TIM |
439 | STATE : code ROUTINE : tim_t335_u0_5 |
440 +--------------------------------------------------------------------+
441
442 PURPOSE : Timeout of timer T335 in state U0.5
443
444 */
445
446 GLOBAL void tim_t335_u0_5 ()
447 {
448 GET_INSTANCE_DATA;
449 TRACE_FUNCTION ("tim_t335_u0_5()");
450
451 cc_data->timer [cc_data->index_ti] = T335;
452
453 /* Forget stored setup container */
454 PFREE (cc_data->stored_ccbs_setup);
455 cc_data->stored_ccbs_setup = NULL;
456
457 /* Inform MMI */
458 /* Implements Measure# 30, 31 */
459 tim_mncc_rel_ind ();
460
461 /* Send RELEASE COMPLETE to network */
462 CCD_START;
463 {
464 MCAST (rel_com, U_RELEASE_COMP);
465 cc_build_release_complete (rel_com, CAUSE_MAKE(DEFBY_STD,
466 ORIGSIDE_MS,
467 MNCC_CC_ORIGINATING_ENTITY,
468 M_CC_CAUSE_TIMER));
469 for_release_complete (rel_com);
470 }
471 CCD_END;
472
473 /* Release MM connection */
474 for_rel_req ();
475
476 /* Next state is NULL */
477 cc_set_state (M_CC_CS_0);
478 }
479
480 /*
481 +--------------------------------------------------------------------+
482 | PROJECT : GSM-PS (6147) MODULE : CC_TIM |
483 | STATE : code ROUTINE : tim_t336 |
484 +--------------------------------------------------------------------+
485
486 PURPOSE : Timeout of timer T336
487
488 */
489
490 GLOBAL void tim_t336 ()
491 {
492 GET_INSTANCE_DATA;
493
494 T_DTMF * p_dtmf;
495
496 TRACE_FUNCTION ("tim_t336()");
497
498 cc_data->timer [cc_data->index_ti] = T336;
499 p_dtmf = &cc_data->dtmf[cc_data->index_ti];
500
501 /*
502 * Send error indication to MMI. DTMF transmission maybe has failed.
503 * This point may be discussed, but TS 24.008 doesn't say that a
504 * positive indication as a feedback for a successful transmission
505 * should be generated.
506 */
507 {
508 PALLOC (dtmf_cnf, MNCC_START_DTMF_CNF);
509 dtmf_cnf->ti = cc_data->ti;
510 dtmf_cnf->key = p_dtmf->key;
511 dtmf_cnf->cause = CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS, MNCC_CC_ORIGINATING_ENTITY, M_CC_CAUSE_TIMER);
512 dtmf_cnf->dtmf_mod = p_dtmf->mode;
513 PSENDX (MMI, dtmf_cnf);
514 }
515
516 cc_stop_dtmf ();
517 }
518
519 /*
520 +--------------------------------------------------------------------+
521 | PROJECT : GSM-PS (6147) MODULE : CC_TIM |
522 | STATE : code ROUTINE : tim_t337 |
523 +--------------------------------------------------------------------+
524
525 PURPOSE : Timeout of timer T337
526
527 */
528
529 GLOBAL void tim_t337 ()
530 {
531 GET_INSTANCE_DATA;
532
533 TRACE_FUNCTION ("tim_t337()");
534
535 cc_data->timer [cc_data->index_ti] = T337;
536
537 cc_stop_dtmf ();
538 }
539
540
541
542 /* Implements Measure# 30, 31 */
543 /*
544 +--------------------------------------------------------------------+
545 | PROJECT : GSM-PS (6147) MODULE : CC_TIM |
546 | STATE : code ROUTINE : tim_mncc_rel_ind |
547 +--------------------------------------------------------------------+
548
549 PURPOSE : Build and send MNCC_RELEASE_IND
550
551 */
552
553 LOCAL void tim_mncc_rel_ind (void)
554 {
555 GET_INSTANCE_DATA;
556
557 TRACE_FUNCTION ("tim_mncc_rel_ind");
558 {
559 PALLOC (release, MNCC_RELEASE_IND);
560 release->ti = cc_data->ti;
561 release->cause = CAUSE_MAKE(DEFBY_STD, ORIGSIDE_MS, MNCC_CC_ORIGINATING_ENTITY, M_CC_CAUSE_TIMER);
562 release->c_raw_cause = 0;
563 PSENDX (MMI, release);
564 }
565 }
566
567 #endif /* #ifndef CC_TIM_C */