comparison src/g23m-fad/t30/t30_kerp.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 : t30_kerp
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 processing
18 | of incomming primitives for the component T30
19 | of the mobile station
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef T30_KERP_C
24 #define T30_KERP_C
25 #endif
26
27 #define ENTITY_T30
28
29 /*==== INCLUDES ===================================================*/
30
31 #include <string.h>
32 #include <stdlib.h>
33 #include <stddef.h>
34 #include "typedefs.h"
35 #include "pcm.h"
36 #include "vsi.h"
37 #include "macdef.h"
38 #include "pconst.cdg"
39 #include "mconst.cdg"
40 #include "message.h"
41 #include "ccdapi.h"
42 #include "custom.h"
43 #include "gsm.h"
44 #include "prim.h"
45 #include "cnf_t30.h"
46 #include "mon_t30.h"
47 #include "pei.h"
48 #include "tok.h"
49 #include "dti.h" /* functionality of the dti library */
50 #include "t30.h"
51
52 /*==== CONST =======================================================*/
53 /*==== TYPES =======================================================*/
54 /*==== VAR EXPORT ==================================================*/
55 /*==== VAR LOCAL ===================================================*/
56 /*==== FUNCTIONS ===================================================*/
57
58 /*
59
60 uplink
61 --------
62 DTI_DATA_TEST_REQ (SDU)
63 |
64 v
65 DTI_DATA_REQ (DescList)
66 |
67 v compress TDC
68 FAD_DATA_REQ (SDU)
69
70 downlink
71 --------
72 DTI_DATA_TEST_IND (SDU)
73 ^
74 |
75 DTI_DATA_IND (DescList)
76 ^ expand TDC
77 |
78 FAD_DATA_IND (SDU)
79 */
80
81 LOCAL void cleanup_dti_data_req_desc(T_desc2 **desc)
82 {
83 if (*desc AND (*desc)->len)
84 {
85 MFREE_DESC2(*desc);
86 }
87 *desc = NULL;
88 }
89
90 LOCAL UBYTE prepare_fad_data_req(void)
91 {
92 if (t30_data->fad_data_req EQ NULL)
93 {
94 PALLOC_SDU (fad_data_req, FAD_DATA_REQ, (USHORT)(t30_data->frames_per_prim << 3));
95 fad_data_req->sdu.l_buf = 0;
96 fad_data_req->final = FALSE;
97 fad_data_req->trans_rate = t30_data->trans_rate;
98 t30_data->fad_data_req = fad_data_req;
99 }
100 return TDCcompress(t30_data->dti_data_req_desc, &t30_data->fad_data_req->sdu);
101 }
102
103 /*-----------------------------------------------------------------------------
104 | Function : sig_dti_ker_data_received_ind
105 +------------------------------------------------------------------------------
106 | Description : Process reason DTI_REASON_DATA_RECEIVED
107 | received from dtilib callback function.
108 |
109 | Parameters : dti_data_req
110 |
111 | Return : -
112 +------------------------------------------------------------------------------
113 */
114 GLOBAL void sig_dti_ker_data_received_ind (T_DTI2_DATA_REQ *dti_data_req)
115 {
116 BOOL ready;
117
118 TRACE_FUNCTION ("sig_dti_ker_data_received_ind()");
119
120 if (dti_data_req) /* got a new DTI_DATA_REQ */
121 {
122 t30_data->dti_data_req_desc = (T_desc2*)dti_data_req->desc_list2.first;
123 PFREE (dti_data_req);
124 t30_data->dti_data_req_ptr = NULL;
125
126 switch (GET_STATE (KER))
127 {
128 case T30_SND_RDY:
129 ready = prepare_fad_data_req();
130
131 if (ready & READY_UPLI_PAGE)
132 {
133 t30_data->fad_data_req->final = TRUE;
134 sig_ker_msg_mdat_req(t30_data->fad_data_req);
135 SET_STATE (KER, T30_SND_DATF);
136 }
137 else if (ready & READY_UPLI_SDU)
138 {
139 sig_ker_msg_mdat_req(t30_data->fad_data_req);
140 SET_STATE (KER, T30_SND_DAT);
141 }
142 else
143 {
144 snd_dti_ready_ind();
145 }
146 break;
147
148 default:
149 cleanup_dti_data_req_desc(&t30_data->dti_data_req_desc);
150 break;
151 }
152 }
153 else /* more DTI data to process */
154 {
155 switch (GET_STATE (KER))
156 {
157 case T30_SND_DAT:
158 {
159 ready = prepare_fad_data_req();
160 if (ready & READY_UPLI_PAGE)
161 {
162 t30_data->fad_data_req->final = TRUE;
163 SET_STATE (KER, T30_SND_DATF);
164 sig_ker_msg_mdat_req(t30_data->fad_data_req);
165 }
166 else if (ready & READY_UPLI_SDU)
167 {
168 sig_ker_msg_mdat_req(t30_data->fad_data_req);
169 }
170 else
171 {
172 SET_STATE (KER, T30_SND_RDY);
173 snd_dti_ready_ind();
174 }
175 break;
176 }
177 default:
178 break;
179 }
180 }
181 }
182
183 /*
184 +------------------------------------------------------------------------------
185 | Function : sig_dti_ker_tx_buffer_ready_ind
186 +------------------------------------------------------------------------------
187 | Description : Process reason DTI_REASON_TX_BUFFER_READY received from
188 | dti library callback function.
189 |
190 | Parameters : -
191 |
192 | Return : -
193 +------------------------------------------------------------------------------
194 */
195 GLOBAL void sig_dti_ker_tx_buffer_ready_ind()
196 {
197 TRACE_FUNCTION ("sig_dti_ker_tx_buffer_ready_ind()");
198
199 if(t30_data->dti_data_ind_empty) /* send flow control primitive if available */
200 {
201 snd_dti_data_ind(&t30_data->dti_data_ind_empty);
202 }
203 else /* send regular data primitive */
204 {
205 switch (GET_STATE (KER))
206 {
207 case T30_RCV_MSG:
208 if (t30_data->dti_data_ind)
209 {
210 snd_dti_data_ind(&t30_data->dti_data_ind);
211 if (t30_data->dti_data_ind_final)
212 {
213 SET_STATE (KER, T30_RCV_RDYF);
214 }
215 else
216 {
217 SET_STATE (KER, T30_RCV_RDY);
218 }
219 }
220 else
221 SET_STATE (KER, T30_RCV_DATW);
222 break;
223
224 case T30_RCV_RDY:
225 if (t30_data->dti_data_ind)
226 {
227 snd_dti_data_ind(&t30_data->dti_data_ind);
228 if (t30_data->dti_data_ind_final)
229 {
230 SET_STATE (KER, T30_RCV_RDYF);
231 }
232 else
233 {
234 SET_STATE (KER, T30_RCV_RDY);
235 }
236 }
237 else
238 SET_STATE (KER, T30_RCV_DAT);
239 break;
240
241 case T30_RCV_RDYF:
242 SET_STATE (KER, T30_RCV_PSTW);
243 snd_t30_phase_ind(BCS_PHASE);
244 break;
245
246 case T30_SND_RDYW:
247 SET_STATE (KER, T30_SND_RDY);
248 break;
249
250 default:
251 TRACE_EVENT("ERROR: DTI_REASON_TX_BUFFER_READY in wrong KER state");
252 break;
253 }
254 }
255 }
256
257 LOCAL void snd_eol_ind(void)
258 {
259 PALLOC (t30_eol_ind, T30_EOL_IND);
260 t30_eol_ind->eol = t30_data->eol;
261 t30_data->eol = 0;
262 PSENDX (MMI, t30_eol_ind);
263 }
264
265 /*
266 +--------------------------------------------------------------------+
267 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
268 | STATE : code ROUTINE : ker_t30_dti_req |
269 +--------------------------------------------------------------------+
270
271 PURPOSE : Process primitive T30_DTI_REQ received from MMI
272 and confirms with T30_DTI_CNF.
273 */
274
275 GLOBAL void ker_t30_dti_req (T_T30_DTI_REQ *t30_dti_req)
276 {
277 TRACE_FUNCTION ("ker_t30_dti_req()");
278
279 PACCESS (t30_dti_req);
280
281 switch (GET_STATE (KER))
282 {
283 case T30_RCV_MSGW:
284 {
285 ker_check_rtc(NULL);
286 if (t30_dti_req->dti_conn NEQ T30_CONNECT_DTI)
287 {
288 TRACE_EVENT("ERROR: DTI not connected");
289 }
290 else
291 {
292 SET_STATE (KER, T30_RCV_MSG);
293 dti_connect_setup(t30_dti_req);
294 }
295 break;
296 }
297 case T30_RCV_PSTW:
298 {
299 if (t30_dti_req->dti_conn NEQ T30_DISCONNECT_DTI)
300 {
301 TRACE_EVENT("ERROR: DTI not disconnected");
302 }
303 else
304 {
305 SET_STATE (KER, T30_RCV_PST);
306 dti_disconnect();
307 snd_t30_dti_cnf(T30_DISCONNECT_DTI);
308 snd_eol_ind();
309 }
310 break;
311 }
312 case T30_SND_MSG:
313 {
314 if (t30_dti_req->dti_conn NEQ T30_CONNECT_DTI)
315 {
316 TRACE_EVENT("ERROR: DTI not connected");
317 }
318 else
319 {
320 SET_STATE (KER, T30_SND_RDYW);
321 dti_connect_setup(t30_dti_req);
322 }
323 break;
324 }
325 case T30_SND_PSTW:
326 {
327 if (t30_dti_req->dti_conn NEQ T30_DISCONNECT_DTI)
328 {
329 TRACE_EVENT("ERROR: DTI not disconnected");
330 }
331 else
332 {
333 SET_STATE(KER, T30_SND_PST);
334 dti_disconnect();
335 snd_t30_dti_cnf(T30_DISCONNECT_DTI);
336 SET_STATE (KER, T30_SND_PST);
337 t30_data->mux.mode = MUX_BCS;
338 sig_ker_mux_mux_req ();
339 snd_t30_sgn_ind(t30_data->sgn_ind);
340 }
341 break;
342 }
343 default:
344 if (t30_dti_req->dti_conn EQ T30_DISCONNECT_DTI)
345 {
346 dti_disconnect();
347 snd_t30_dti_cnf(T30_DISCONNECT_DTI);
348 switch (GET_STATE (KER))
349 {
350 case T30_RCV_DAT:
351 case T30_RCV_DATW:
352 case T30_RCV_MSG:
353 case T30_RCV_MSGW:
354 case T30_RCV_RDY:
355 case T30_RCV_RDYF:
356 case T30_RCV_RDYW:
357 snd_error_ind(ERR_PH_C_RCV_UNSPEC);
358 break;
359
360 case T30_SND_DAT:
361 case T30_SND_DATF:
362 case T30_SND_MSG:
363 case T30_SND_RDY:
364 case T30_SND_RDYW:
365 snd_error_ind(ERR_PH_C_SND_UNSPEC);
366 break;
367 }
368 SET_STATE (KER, T30_IDLE);
369 }
370 else
371 TRACE_EVENT("ERROR: T30_DTI_REQ in wrong KER state");
372 break;
373 }
374 PFREE (t30_dti_req);
375 }
376
377 /*
378 +------------------------------------------------------------------------+
379 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
380 | STATE : code ROUTINE : sig_dti_ker_connection_opened_ind |
381 +------------------------------------------------------------------------+
382
383 PURPOSE : Process reason DTI_REASON_CONNECTION_OPENED
384 received from dtilib callback function
385 */
386
387 GLOBAL void sig_dti_ker_connection_opened_ind ()
388 {
389 TRACE_FUNCTION ("sig_dti_ker_connection_opened_ind()");
390
391 switch (GET_STATE (KER))
392 {
393 case T30_RCV_MSG:
394 case T30_SND_RDYW:
395 {
396 dti_connect_open();
397 break;
398 }
399 default:
400 TRACE_EVENT("ERROR: DTI_REASON_CONNECTION_OPENED in wrong KER state");
401 break;
402 }
403 }
404
405 /*
406 +------------------------------------------------------------------------+
407 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
408 | STATE : code ROUTINE : sig_dti_ker_connection_closed_ind |
409 +------------------------------------------------------------------------+
410
411 PURPOSE : Process reason DTI_REASON_CONNECTION_CLOSED
412 received from dtilib callback function
413 */
414
415 GLOBAL void sig_dti_ker_connection_closed_ind ()
416 {
417 TRACE_FUNCTION ("sig_dti_ker_connection_closed_ind()");
418
419 switch (GET_STATE (KER))
420 {
421 case T30_RCV_PSTW:
422 SET_STATE (KER, T30_RCV_PST);
423 dti_connect_close();
424 snd_eol_ind();
425 break;
426
427 case T30_SND_PSTW:
428 SET_STATE(KER, T30_SND_PST);
429 dti_connect_close();
430 SET_STATE (KER, T30_SND_PST);
431 t30_data->mux.mode = MUX_BCS;
432 sig_ker_mux_mux_req ();
433 snd_t30_sgn_ind(t30_data->sgn_ind);
434 break;
435
436 default:
437 dti_connect_close();
438 switch (GET_STATE (KER))
439 {
440 case T30_RCV_DAT:
441 case T30_RCV_DATW:
442 case T30_RCV_MSG:
443 case T30_RCV_MSGW:
444 case T30_RCV_RDY:
445 case T30_RCV_RDYF:
446 case T30_RCV_RDYW:
447 snd_error_ind(ERR_PH_C_RCV_UNSPEC);
448 break;
449
450 case T30_SND_DAT:
451 case T30_SND_DATF:
452 case T30_SND_MSG:
453 case T30_SND_RDY:
454 case T30_SND_RDYW:
455 snd_error_ind(ERR_PH_C_SND_UNSPEC);
456 break;
457 }
458 SET_STATE (KER, T30_IDLE);
459 break;
460 }
461 }
462
463 /*
464 +--------------------------------------------------------------------+
465 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
466 | STATE : code ROUTINE : ker_fad_activate_cnf|
467 +--------------------------------------------------------------------+
468
469 PURPOSE : Process primitive FAD_ACTIVATE_CNF received from FAD.
470 FAD informs T30 that FAD is activated.
471 T30 informs MMI that activation has been completed.
472 */
473 GLOBAL void ker_fad_activate_cnf (T_FAD_ACTIVATE_CNF *fad_activate_cnf)
474 {
475 TRACE_FUNCTION ("ker_fad_activate_cnf()");
476 PACCESS (fad_activate_cnf);
477
478 switch (GET_STATE (KER))
479 {
480 case T30_ACTIVATE:
481 {
482 PPASS (fad_activate_cnf, t30_activate_cnf, T30_ACTIVATE_CNF);
483
484 #ifdef _TARGET_
485 /*
486 * sleep for 2 seconds because we should not send DIS to early
487 * on a real network
488 */
489 vsi_t_sleep (VSI_CALLER FRAMES_400);
490 #endif
491 /*
492 * we pass also the buffer size parameters to MMI
493 */
494 SET_STATE (KER, T30_IDLE);
495 PSENDX (MMI, t30_activate_cnf);
496 break;
497 }
498 default:
499 PFREE (fad_activate_cnf);
500 break;
501 }
502 }
503
504 /*
505 +--------------------------------------------------------------------+
506 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
507 | STATE : code ROUTINE : ker_fad_data_cnf |
508 +--------------------------------------------------------------------+
509
510 PURPOSE : Process primitive FAD_DATA_CNF received from FAD.
511 This primitive is received after a command or response
512 has been sent successfully by FAD.
513 */
514
515 GLOBAL void ker_fad_data_cnf (T_FAD_DATA_CNF *fad_data_cnf)
516 {
517 TRACE_FUNCTION ("ker_fad_data_cnf()");
518 PACCESS (fad_data_cnf);
519 t30_data->data_cnf = TRUE;
520
521 switch (GET_STATE (KER))
522 {
523 case T30_DCN:
524 snd_complete_ind(CMPL_DCN);
525 break;
526
527 case T30_RCV_CFR:
528 TIMERSTART (T2_INDEX, MSG_VALUE);
529 SET_STATE (KER, T30_RCV_MSGW);
530 snd_t30_phase_ind(MSG_PHASE);
531 break;
532
533 case T30_RCV_DIS:
534 TIMERSTART (T4_INDEX, T4_VALUE);
535 SET_STATE (KER, T30_RCV_DCS);
536 break;
537
538 case T30_RCV_MCF:
539 TIMERSTART (T2_INDEX, T2_VALUE);
540 switch (t30_data->res)
541 {
542 case BCS_EOM:
543 SET_STATE (KER, T30_RCV_T2);
544 break;
545
546 case BCS_EOP:
547 SET_STATE (KER, T30_RCV_DCN);
548 break;
549
550 case BCS_MPS:
551 t30_data->prev = BCS_MCF;
552 SET_STATE (KER, T30_RCV_MSGW);
553 snd_t30_phase_ind(MSG_PHASE);
554 break;
555 }
556 break;
557
558 case T30_RCV_PI:
559 switch (t30_data->res)
560 {
561 case SGN_PRI_EOM:
562 case SGN_PRI_EOP:
563 case SGN_PRI_MPS:
564 snd_complete_ind(CMPL_PI);
565 break;
566
567 default:
568 SET_STATE (KER, T30_RCV_PST);
569 break;
570 }
571 break;
572
573 case T30_RCV_RT:
574 SET_STATE (KER, T30_RCV_DCS);
575 break;
576
577 case T30_RCV_RT2:
578 SET_STATE (KER, T30_RCV_DCS);
579 break;
580
581 case T30_SND_DCN:
582 TIMERSTART (T4_INDEX, DCN_VALUE);
583 break;
584
585 case T30_SND_DCN1:
586 snd_complete_ind(CMPL_DCN);
587 break;
588
589 case T30_SND_DCS:
590 {
591 PALLOC (fad_snd_tcf_req, FAD_SND_TCF_REQ);
592 fad_snd_tcf_req->trans_rate = t30_data->trans_rate;
593 PSENDX (FAD, fad_snd_tcf_req);
594 SET_STATE (KER, T30_SND_TCF);
595 }
596 break;
597
598 case T30_SND_DTC:
599 TIMERSTOP (T1_INDEX);
600 SET_STATE (KER, T30_RCV_DCS);
601 break;
602
603 case T30_SND_DATF:
604 TIMERSTOP (T4_INDEX);
605 SET_STATE (KER, T30_SND_PSTW);
606 cleanup_dti_data_req_desc(&t30_data->dti_data_req_desc);
607 snd_t30_phase_ind(BCS_PHASE);
608 break;
609
610 case T30_SND_PRI:
611 snd_complete_ind(CMPL_PI);
612 break;
613
614 case T30_SND_SGN:
615 TIMERSTART (T4_INDEX, T4_VALUE);
616 SET_STATE (KER, T30_SND_MCF);
617 break;
618 }
619 PFREE (fad_data_cnf);
620 }
621
622 /*
623 +--------------------------------------------------------------------+
624 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
625 | STATE : code ROUTINE : ker_fad_deactivate_cnf|
626 +--------------------------------------------------------------------+
627
628 PURPOSE : Process primitive FAD_DEACTIVATE_CNF received from FAD.
629 FAD informs T30 that FAD is deactivated.
630 T30 informs MMI that deactivation has been completed.
631 */
632
633 GLOBAL void ker_fad_deactivate_cnf (T_FAD_DEACTIVATE_CNF
634 *fad_deactivate_cnf)
635 {
636 TRACE_FUNCTION ("ker_fad_deactivate_cnf()");
637 PACCESS (fad_deactivate_cnf);
638 PFREE (fad_deactivate_cnf);
639
640 if (GET_STATE (KER) EQ T30_DEACTIVATE)
641 {
642 PALLOC (t30_deactivate_cnf, T30_DEACTIVATE_CNF);
643 SET_STATE (KER, T30_NULL);
644 PSENDX (MMI, t30_deactivate_cnf);
645 }
646 }
647
648 /*
649 +--------------------------------------------------------------------+
650 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
651 | STATE : code ROUTINE : ker_fad_error_ind |
652 +--------------------------------------------------------------------+
653
654 PURPOSE : Process primitive FAD_ERROR_IND received from FAD.
655 All running timers are stopped and the error message is
656 passed to MMI.
657 */
658
659 GLOBAL void ker_fad_error_ind (T_FAD_ERROR_IND *fad_error_ind)
660 {
661 TRACE_FUNCTION ("ker_fad_error_ind()");
662 PACCESS (fad_error_ind);
663 {
664 PPASS (fad_error_ind, t30_error_ind, T30_ERROR_IND);
665 PSENDX (MMI, t30_error_ind);
666 }
667 TIMERSTOP (T1_INDEX);
668 TIMERSTOP (T2_INDEX);
669 TIMERSTOP (T4_INDEX);
670 SET_STATE (KER, T30_IDLE);
671 }
672
673 /*
674 +--------------------------------------------------------------------+
675 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
676 | STATE : code ROUTINE : ker_fad_rcv_tcf_cnf |
677 +--------------------------------------------------------------------+
678
679 PURPOSE : Process primitive FAD_RCV_TCF_CNF received from FAD.
680 FAD sends the ratio of the received TCF.
681 If the ratio is OK a CFR is sent as response otherwise an FTT.
682 */
683
684 GLOBAL void ker_fad_rcv_tcf_cnf (T_FAD_RCV_TCF_CNF
685 *fad_rcv_tcf_cnf)
686 {
687 TRACE_FUNCTION ("ker_fad_rcv_tcf_cnf()");
688 PACCESS (fad_rcv_tcf_cnf);
689
690 switch (GET_STATE (KER))
691 {
692 case T30_RCV_TCF:
693 {
694 TIMERSTOP (T2_INDEX);
695 t30_data->rate_modified = FALSE;
696
697 if (fad_rcv_tcf_cnf->ratio >= t30_data->threshold)
698 {
699 _decodedMsg[0] = BCS_CFR;
700
701 SET_STATE (KER, T30_RCV_CFR);
702
703 sig_ker_bcs_bdat_req (FINAL_YES);
704 }
705 else
706 {
707 _decodedMsg[0] = BCS_FTT;
708
709 SET_STATE (KER, T30_RCV_DIS);
710
711 sig_ker_bcs_bdat_req (FINAL_YES);
712 }
713
714 break;
715 }
716
717 default:
718 break;
719 }
720
721 PFREE (fad_rcv_tcf_cnf);
722 }
723
724 /*
725 +--------------------------------------------------------------------+
726 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
727 | STATE : code ROUTINE : ker_fad_ready_ind |
728 +--------------------------------------------------------------------+
729
730 PURPOSE : Process primitive FAD_READY_IND received from FAD.
731 FAD informs T30 that next fax data block can be sent.
732 T30 passes this information to MMI.
733 */
734
735 GLOBAL void ker_fad_ready_ind (T_FAD_READY_IND *fad_ready_ind)
736 {
737 TRACE_FUNCTION ("ker_fad_ready_ind()");
738 PACCESS (fad_ready_ind);
739
740 switch (GET_STATE (KER))
741 {
742 case T30_SND_DAT:
743 {
744 if (t30_data->dti_data_req_ptr) /* pending data in DTI_DATA_REQ */
745 {
746 sig_dti_ker_data_received_ind (NULL);
747 }
748 else
749 {
750 SET_STATE (KER, T30_SND_RDY);
751 snd_dti_ready_ind();
752 }
753 break;
754 }
755 default:
756 break;
757 }
758 PFREE (fad_ready_ind);
759 }
760
761 /*
762 +--------------------------------------------------------------------+
763 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
764 | STATE : code ROUTINE : sig_dti_ker_tx_buffer_full_ind |
765 +--------------------------------------------------------------------+
766
767 PURPOSE : Process signal DTI_REASON_TX_BUFFER_FULL received from
768 dti library callback function.
769 The buffer function of DTILIB is not used.
770 So there is nothing to be done here yet..
771
772 */
773 GLOBAL void sig_dti_ker_tx_buffer_full_ind()
774 {
775 TRACE_FUNCTION ("sig_dti_ker_tx_buffer_full_ind()");
776 }
777
778 /*
779 +--------------------------------------------------------------------+
780 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
781 | STATE : code ROUTINE : ker_fad_snd_tcf_cnf |
782 +--------------------------------------------------------------------+
783
784 PURPOSE : Process primitive FAD_SND_TCF_CNF received from FAD.
785 FAD informs T30 that the TCF has been sent.
786 */
787
788 GLOBAL void ker_fad_snd_tcf_cnf (T_FAD_SND_TCF_CNF *fad_snd_tcf_cnf)
789 {
790 TRACE_FUNCTION ("ker_fad_snd_tcf_cnf()");
791 PACCESS (fad_snd_tcf_cnf);
792
793 PFREE (fad_snd_tcf_cnf);
794
795 switch (GET_STATE (KER))
796 {
797 case T30_SND_TCF:
798 {
799 SET_STATE (KER, T30_SND_CFR);
800 TIMERSTART (T4_INDEX, T4_VALUE);
801 break;
802 }
803 default:
804 break;
805 }
806 }
807
808 /*
809 +--------------------------------------------------------------------+
810 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
811 | STATE : code ROUTINE : Initialize_Shared_Fax_Data_Memory|
812 +--------------------------------------------------------------------+
813
814 PURPOSE :
815 */
816
817 LOCAL void Initialize_Shared_Fax_Data_Memory(void)
818 {
819 ker_init (&t30_data_base[0]);
820 bcs_init (&t30_data_base[0]);
821
822 SET_STATE (MUX, T30_MUX_OFF);
823
824 t30_data_magic_num = T30_DATA_MAGIC_NUM; /* memory is initialized */
825 }
826
827 /*
828 +--------------------------------------------------------------------+
829 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
830 | STATE : code ROUTINE : ker_t30_activate_req|
831 +--------------------------------------------------------------------+
832
833 PURPOSE : Process primitive T30_ACTIVATE_REQ received from MMI.
834 MMI activates T30. T30 then activates FAD.
835 The BCS multiplexer is switched on.
836 */
837
838 GLOBAL void ker_t30_activate_req (T_T30_ACTIVATE_REQ *t30_activate_req)
839 {
840 TRACE_FUNCTION ("ker_t30_activate_req()");
841 PACCESS (t30_activate_req);
842
843 Initialize_Shared_Fax_Data_Memory();
844
845 switch (GET_STATE (KER))
846 {
847 case T30_NULL:
848 {
849 PALLOC (fad_activate_req, FAD_ACTIVATE_REQ);
850
851 memset (t30_data, 0, sizeof(T_T30_DATA));
852
853 t30_data->threshold = t30_activate_req->threshold;
854 t30_data->preamble_ind = TRUE;
855 t30_data->trans_rate = t30_activate_req->trans_rate;
856 t30_data->bitorder = t30_activate_req->bitorder;
857 t30_data->rate_modified = FALSE;
858
859 t30_data->TDC_doli_pending = FALSE;
860 t30_data->TDC_upli_pending = FALSE;
861
862 t30_data->frames_per_prim = MSG_SIZE_BITS >> 3; /* traditionally */
863
864 fad_activate_req->trans_rate = t30_activate_req->trans_rate;
865 fad_activate_req->frames_per_prim = t30_activate_req->frames_per_prim;
866
867 SET_STATE (KER, T30_ACTIVATE);
868 PSENDX (FAD, fad_activate_req);
869
870 t30_data->mux.mode = MUX_BCS;
871 sig_ker_mux_mux_req ();
872
873 TIMERSTART (T1_INDEX, T1_VALUE);
874 break;
875 }
876 default:
877 break;
878 }
879 PFREE (t30_activate_req);
880 }
881
882 /*
883 +--------------------------------------------------------------------+
884 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
885 | STATE : code ROUTINE : ker_t30_cap_req |
886 +--------------------------------------------------------------------+
887
888 PURPOSE : Process primitive T30_CAP_REQ received from MMI.
889 The DIS parameters are prepared for sending to remote site.
890 */
891
892 GLOBAL void ker_t30_cap_req (T_T30_CAP_REQ *t30_cap_req)
893 {
894 TRACE_FUNCTION ("ker_t30_cap_req()");
895 PACCESS (t30_cap_req);
896
897 switch (GET_STATE (KER))
898 {
899 case T30_IDLE:
900 if (t30_cap_req->hdlc_info.v_dis)
901 {
902 TIMERSTOP (T1_INDEX);
903 TIMERSTART (T1_INDEX, T1_VALUE);
904 t30_data->mux.mode = MUX_BCS;
905 t30_data->fmod = FMOD_RCV;
906 t30_data->dir = 0;
907 sig_ker_mux_mux_req ();
908 memcpy (&t30_data->hdlc_snd, &t30_cap_req->hdlc_info, sizeof (T_hdlc_info));
909 memset (&t30_data->hdlc_rcv, 0, sizeof (T_hdlc_info));
910 SET_STATE (KER, T30_RCV_DIS);
911 ker_send_dis ();
912 }
913 break;
914
915 case T30_SND_CAP:
916 if (t30_cap_req->hdlc_info.v_dcs)
917 {
918 SET_STATE (KER, T30_SND_DCS);
919 t30_data->fmod = FMOD_SND;
920 ker_send_dcs (t30_cap_req);
921 }
922 else if (t30_cap_req->hdlc_info.v_dtc)
923 {
924 SET_STATE (KER, T30_SND_DTC);
925 t30_data->fmod = FMOD_POLL;
926 ker_send_dtc (t30_cap_req);
927 }
928 break;
929
930 default:
931 break;
932 }
933
934 PFREE (t30_cap_req);
935 }
936
937 /*
938 +--------------------------------------------------------------------+
939 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
940 | STATE : code ROUTINE : ker_t30_config_req |
941 +--------------------------------------------------------------------+
942
943 PURPOSE : Process primitive T30_CONFIG_REQ received from MMI.
944 MMI sends configuration parameters to control the behaviour of T30.
945 The parameter test_mode is for internal use only.
946 */
947
948 GLOBAL void ker_t30_config_req (T_T30_CONFIG_REQ *t30_config_req)
949 {
950 TRACE_FUNCTION ("ker_t30_config_req()");
951 PACCESS (t30_config_req);
952
953 if (t30_config_req->test_mode & TST_BCS)
954 Initialize_Shared_Fax_Data_Memory();
955
956 t30_data->hdlc_report = t30_config_req->hdlc_report;
957
958 #ifdef _SIMULATION_ /* test_mode */
959 t30_data->test_mode = t30_config_req->test_mode;
960 #endif
961
962 PFREE (t30_config_req);
963
964 #ifdef _SIMULATION_ /* test_mode */
965 if (t30_data->test_mode)
966 {
967 TRACE_EVENT(" ");
968 TRACE_EVENT ("!!!! T E S T - M O D E !!!!");
969 TRACE_EVENT(" ");
970 if (t30_data->test_mode & TST_BCS)
971 TRACE_EVENT(">>> test-mode: BCS test only");
972 if (t30_data->test_mode & TST_STUFF)
973 TRACE_EVENT(">>> test-mode: stuffing / destuffing off");
974 if (t30_data->test_mode & TST_FCS)
975 TRACE_EVENT(">>> test-mode: FCS generating / checking off");
976 if (t30_data->test_mode & TST_CTRL)
977 TRACE_EVENT(">>> test-mode: HDLC control checking off");
978 if (t30_data->test_mode & TST_RTC)
979 TRACE_EVENT(">>> test-mode: RTC checking off");
980 if (t30_data->test_mode & TST_BUF)
981 TRACE_EVENT(">>> test-mode: show contents of some buffers");
982 TRACE_EVENT(" ");
983 }
984 else
985 {
986 TRACE_EVENT(" ");
987 TRACE_EVENT(">>> NORMAL MODE <<<");
988 TRACE_EVENT(" ");
989 }
990 #endif
991 }
992
993 /*
994 +--------------------------------------------------------------------+
995 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
996 | STATE : code ROUTINE : ker_t30_deactivate_req|
997 +--------------------------------------------------------------------+
998
999 PURPOSE : Process primitive T30_DEACTIVATE_REQ received from MMI.
1000 MMI deactivates T30. T30 then deactivates FAD.
1001 */
1002
1003 GLOBAL void ker_t30_deactivate_req (T_T30_DEACTIVATE_REQ *t30_deactivate_req)
1004 {
1005 TRACE_FUNCTION ("ker_t30_deactivate_req()");
1006 PACCESS (t30_deactivate_req);
1007 {
1008 PPASS (t30_deactivate_req, fad_deactivate_req, FAD_DEACTIVATE_REQ);
1009 PSENDX (FAD, fad_deactivate_req);
1010 SET_STATE (KER, T30_DEACTIVATE);
1011 }
1012 TIMERSTOP (T1_INDEX);
1013 TIMERSTOP (T2_INDEX);
1014 TIMERSTOP (T4_INDEX);
1015 t30_data->mux.mode = MUX_OFF;
1016 sig_ker_mux_mux_req();
1017 cleanup_dti_data_req_desc(&t30_data->dti_data_req_desc);
1018 }
1019
1020 /*
1021 +--------------------------------------------------------------------+
1022 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
1023 | STATE : code ROUTINE : ker_t30_modify_req |
1024 +--------------------------------------------------------------------+
1025
1026 PURPOSE : Process primitive T30_MODIFY_REQ received from MMI.
1027 MMI sends new parameter values to T30.
1028 T30 passes some of this parameters to FAD.
1029 */
1030
1031 GLOBAL void ker_t30_modify_req (T_T30_MODIFY_REQ *t30_modify_req)
1032 {
1033 TRACE_FUNCTION ("ker_t30_modify_req()");
1034 PACCESS (t30_modify_req);
1035
1036 t30_data->trans_rate = t30_modify_req->trans_rate;
1037 {
1038 PPASS (t30_modify_req, fad_modify_req, FAD_MODIFY_REQ);
1039 PSENDX (FAD, fad_modify_req);
1040 }
1041 switch (GET_STATE (KER))
1042 {
1043 case T30_SND_TCF:
1044 {
1045 if (!t30_data->rate_modified)
1046 {
1047 /*
1048 * rate is modified or confirmed (t30_modify_req) by ACI; send TCF in FAD
1049 */
1050 PALLOC (fad_snd_tcf_req, FAD_SND_TCF_REQ);
1051 fad_snd_tcf_req->trans_rate = t30_data->trans_rate;
1052 PSENDX (FAD, fad_snd_tcf_req);
1053 t30_data->rate_modified = TRUE;
1054 }
1055 }
1056 break;
1057
1058 case T30_SND_DCS:
1059 case T30_RCV_DCS:
1060 case T30_RCV_TCF:
1061 {
1062 t30_data->rate_modified = TRUE;
1063 }
1064 break;
1065 }
1066 }
1067
1068 /*
1069 +--------------------------------------------------------------------+
1070 | PROJECT : GSM-F&D (8411) MODULE : T30_KERP |
1071 | STATE : code ROUTINE : ker_t30_sgn_req |
1072 +--------------------------------------------------------------------+
1073
1074 PURPOSE : Process primitive T30_SGN_REQ received from MMI.
1075 MMI informs T30 which response should be send.
1076 T30 prepares an appropriate message
1077 and requests FAD to send this message.
1078 */
1079
1080 GLOBAL void ker_t30_sgn_req (T_T30_SGN_REQ *t30_sgn_req)
1081 {
1082 TRACE_FUNCTION ("ker_t30_sgn_req()");
1083 PACCESS (t30_sgn_req);
1084
1085 switch (GET_STATE (KER))
1086 {
1087 case T30_IDLE:
1088 {
1089 switch (t30_sgn_req->sgn)
1090 {
1091 case SGN_DCN:
1092 {
1093 _decodedMsg[0] = BCS_DCN;
1094
1095 SET_STATE (KER, T30_SND_DCN1);
1096
1097 sig_ker_bcs_bdat_req (FINAL_YES);
1098
1099 break;
1100 }
1101
1102 default:
1103 {
1104 ker_send_err (ERR_SGN_NOT_ALLOWED);
1105
1106 break;
1107 }
1108 }
1109
1110 break;
1111 }
1112
1113 case T30_RCV_PST:
1114 {
1115 switch (t30_sgn_req->sgn)
1116 {
1117 case SGN_MCF:
1118 {
1119 _decodedMsg[0] = BCS_MCF;
1120
1121 SET_STATE (KER, T30_RCV_MCF);
1122
1123 sig_ker_bcs_bdat_req (FINAL_YES);
1124
1125 break;
1126 }
1127
1128 case SGN_PIN:
1129 {
1130 _decodedMsg[0] = BCS_PIN;
1131
1132 SET_STATE (KER, T30_RCV_PI);
1133
1134 sig_ker_bcs_bdat_req (FINAL_YES);
1135
1136 break;
1137 }
1138
1139 case SGN_PIP:
1140 {
1141 _decodedMsg[0] = BCS_PIP;
1142
1143 SET_STATE (KER, T30_RCV_PI);
1144
1145 sig_ker_bcs_bdat_req (FINAL_YES);
1146
1147 break;
1148 }
1149
1150 case SGN_RTN:
1151 {
1152 _decodedMsg[0] = BCS_RTN;
1153
1154 t30_data->prev = BCS_RTN;
1155
1156 SET_STATE (KER, T30_RCV_RT);
1157
1158 sig_ker_bcs_bdat_req (FINAL_YES);
1159
1160 break;
1161 }
1162
1163 case SGN_RTP:
1164 {
1165 _decodedMsg[0] = BCS_RTP;
1166
1167 t30_data->prev = BCS_RTP;
1168
1169 SET_STATE (KER, T30_RCV_RT);
1170
1171 sig_ker_bcs_bdat_req (FINAL_YES);
1172
1173 break;
1174 }
1175
1176 default:
1177 {
1178 ker_send_err (ERR_SGN_NOT_ALLOWED);
1179
1180 break;
1181 }
1182 }
1183
1184 break;
1185 }
1186
1187 /*-------------------------------------------------------------*/
1188
1189 case T30_SND_CAP:
1190 {
1191 switch (t30_sgn_req->sgn)
1192 {
1193 case SGN_DCN:
1194 {
1195 _decodedMsg[0] = BCS_DCN;
1196
1197 SET_STATE (KER, T30_DCN);
1198
1199 t30_data->fmod = FMOD_IDLE;
1200
1201 sig_ker_bcs_bdat_req (FINAL_YES);
1202
1203 break;
1204 }
1205
1206 default:
1207 {
1208 ker_send_err (ERR_SGN_NOT_ALLOWED);
1209
1210 break;
1211 }
1212 }
1213
1214 break;
1215 }
1216
1217 /*-------------------------------------------------------------*/
1218
1219 case T30_SND_PI:
1220 {
1221 switch (t30_data->sgn_req)
1222 {
1223 case SGN_EOM:
1224 case SGN_EOP:
1225 case SGN_MPS:
1226 case SGN_PRI_EOM:
1227 case SGN_PRI_EOP:
1228 case SGN_PRI_MPS:
1229 {
1230 switch (t30_sgn_req->sgn)
1231 {
1232 case SGN_PRI_EOM:
1233 {
1234 _decodedMsg[0] = BCS_PRI_EOM;
1235
1236 SET_STATE (KER, T30_SND_PRI);
1237
1238 sig_ker_bcs_bdat_req (FINAL_YES);
1239
1240 break;
1241 }
1242
1243 case SGN_PRI_EOP:
1244 {
1245 _decodedMsg[0] = BCS_PRI_EOP;
1246
1247 SET_STATE (KER, T30_SND_PRI);
1248
1249 sig_ker_bcs_bdat_req (FINAL_YES);
1250
1251 break;
1252 }
1253
1254 case SGN_PRI_MPS:
1255 {
1256 _decodedMsg[0] = BCS_PRI_MPS;
1257
1258 SET_STATE (KER, T30_SND_PRI);
1259
1260 sig_ker_bcs_bdat_req (FINAL_YES);
1261
1262 break;
1263 }
1264 }
1265
1266 break;
1267 }
1268
1269 case SGN_CONT:
1270 {
1271 SET_STATE (KER, T30_IDLE);
1272
1273 break;
1274 }
1275
1276 default:
1277 {
1278 ker_send_err (ERR_SGN_NOT_ALLOWED);
1279
1280 break;
1281 }
1282 }
1283
1284 break;
1285 }
1286
1287 /*-------------------------------------------------------------*/
1288
1289 case T30_SND_PST:
1290 {
1291 t30_data->repeat = 1;
1292
1293 switch (t30_sgn_req->sgn)
1294 {
1295 case SGN_DCN:
1296 {
1297 _decodedMsg[0] = BCS_DCN;
1298
1299 SET_STATE (KER, T30_DCN);
1300
1301 sig_ker_bcs_bdat_req (FINAL_YES);
1302
1303 break;
1304 }
1305
1306 case SGN_EOM:
1307 {
1308 t30_data->sgn_req = BCS_EOM;
1309 _decodedMsg[0] = BCS_EOM;
1310
1311 SET_STATE (KER, T30_SND_SGN);
1312
1313 sig_ker_bcs_bdat_req (FINAL_YES);
1314
1315 break;
1316 }
1317
1318 case SGN_EOP:
1319 {
1320 t30_data->sgn_req = BCS_EOP;
1321 _decodedMsg[0] = BCS_EOP;
1322
1323 SET_STATE (KER, T30_SND_SGN);
1324
1325 sig_ker_bcs_bdat_req (FINAL_YES);
1326
1327 break;
1328 }
1329
1330 case SGN_MPS:
1331 {
1332 t30_data->sgn_req = BCS_MPS;
1333 _decodedMsg[0] = BCS_MPS;
1334
1335 SET_STATE (KER, T30_SND_SGN);
1336
1337 sig_ker_bcs_bdat_req (FINAL_YES);
1338
1339 break;
1340 }
1341
1342 case SGN_PRI_EOM:
1343 {
1344 t30_data->sgn_req = BCS_PRI_EOM;
1345 _decodedMsg[0] = BCS_PRI_EOM;
1346
1347 SET_STATE (KER, T30_SND_SGN);
1348
1349 sig_ker_bcs_bdat_req (FINAL_YES);
1350
1351 break;
1352 }
1353
1354 case SGN_PRI_EOP:
1355 {
1356 t30_data->sgn_req = BCS_PRI_EOP;
1357 _decodedMsg[0] = BCS_PRI_EOP;
1358
1359 SET_STATE (KER, T30_SND_SGN);
1360
1361 sig_ker_bcs_bdat_req (FINAL_YES);
1362
1363 break;
1364 }
1365
1366 case SGN_PRI_MPS:
1367 {
1368 t30_data->sgn_req = BCS_PRI_MPS;
1369 _decodedMsg[0] = BCS_PRI_MPS;
1370
1371 SET_STATE (KER, T30_SND_SGN);
1372
1373 sig_ker_bcs_bdat_req (FINAL_YES);
1374
1375 break;
1376 }
1377
1378 case SGN_CONT:
1379 {
1380 SET_STATE (KER, T30_IDLE);
1381
1382 break;
1383 }
1384
1385 default:
1386 {
1387 ker_send_err (ERR_SGN_NOT_ALLOWED);
1388
1389 break;
1390 }
1391 }
1392
1393 break;
1394 }
1395
1396 default:
1397 break;
1398 }
1399
1400 PFREE (t30_sgn_req);
1401 }