comparison src/g23m-aci/aci/psa_ccf.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 : PSA_CCF
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 module defines the functions for the protocol
18 | stack adapter for call control.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef PSA_CCF_C
23 #define PSA_CCF_C
24 #endif
25
26 #include "aci_all.h"
27
28 #undef TRACING
29
30 /*==== INCLUDES ===================================================*/
31
32 #include "l4_tim.h"
33 #include "ccdapi.h"
34
35 #include "aci_cmh.h"
36 #include "ati_cmd.h"
37 #include "aci_cmd.h"
38 #include "phb.h"
39
40 #ifdef FAX_AND_DATA
41 #include "aci_fd.h"
42 #endif /* of #ifdef FAX_AND_DATA */
43
44 #include "aci.h"
45 #include "psa.h"
46 #include "psa_cc.h"
47 #include "psa_mmi.h"
48 #include "psa_ss.h"
49 #include "cmh.h"
50 #include "cmh_cc.h"
51 #include "psa_util.h"
52 #include "cmh_phb.h"
53 #include "psa_sim.h"
54 #include "aci_mem.h"
55 #include "hl_audio_drv.h"
56
57 #include "gdi.h"
58 #include "rtcdrv.h"
59 #include "audio.h"
60 #include "aoc.h"
61
62 #ifdef SIM_TOOLKIT
63 #include "psa_sat.h"
64 #include "cmh_sat.h"
65 #endif /* SIM_TOOLKIT */
66
67 /*==== CONSTANTS ==================================================*/
68 #define MAX_MOCTI_NR (7) /* max number of ti's for MOC */
69 #define SA_DEL ('-') /* subaddress delimiter */
70
71 #define MAX_ITM (5) /* max number of items per line */
72 #define ITM_WDT (14) /* item width in chars */
73 #define HDR_WDT (10) /* header width in chars */
74
75 /*modify by dongfeng for ASTec28850, ASTec27950*/
76 #define EMRGNCY_NUM {"112","911",""}
77 /* default emergency numbers */
78
79 #define EMRGNCY_NUM_NS {"118","119","000","08","110","999",""} /* additional default emergency */
80 /* numbers for use without SIM */
81
82
83 /*==== TYPES ======================================================*/
84
85
86 /*==== EXPORT =====================================================*/
87
88
89 /*==== VARIABLES ==================================================*/
90 LOCAL UBYTE tiPool = 0xFF; /* holds pool of transaction identifiers */
91
92 LOCAL const CHAR * const ec_string[] = EMRGNCY_NUM;
93 LOCAL const CHAR * const ec_string_ns[] = EMRGNCY_NUM_NS;
94
95 EXTERN T_ACI_CUSCFG_PARAMS cuscfgParams;
96 EXTERN SHORT Ext_USSD_Res_Pending_sId;
97
98 /* Implements Measure#32: Row 1245, 1277 & 1312 */
99 const char * const format_2X_str="%02X";
100
101 /*
102 * Phonebook search list
103 *
104 * Description : this is the list of phonebooks, which will be searched
105 * for known entries. This is done during phonebook
106 * dialling and the indication of incoming calls. It is
107 * important to leave the EOL indicator at the end of
108 * the list to terminate the list.
109 * Available phonebooks:
110 *
111 * ECC Emergency call numbers
112 * ADN Abbreviated dialing number
113 * FDN Fixed dialing number
114 * BDN Barred dialing number
115 * LDN Last dialing number
116 * LRN Last received number
117 * SDN Service dialing number
118 */
119
120 const SHORT phbSrchLst[] =
121 {
122 ADN,
123 SDN,
124 FDN,
125 /*--- EOL -------------------------------------------------------*/
126 -1
127 };
128
129 /*==== FUNCTIONS ==================================================*/
130
131 LOCAL UBYTE psaCC_handleInternatPlus( char *number );
132
133 LOCAL CHAR *psaCC_ctbAdr2Num ( CHAR *pNumBuf, UBYTE maxSize, UBYTE *num,
134 UBYTE c_num, UBYTE ton);
135
136 /*
137 +-------------------------------------------------------------------+
138 | PROJECT : GSM-PS (6147) MODULE : PSA_CCS |
139 | ROUTINE : psaCC_send_satevent |
140 +-------------------------------------------------------------------+
141
142 PURPOSE : Tries to send an event to SAT.
143
144 */
145 GLOBAL void psaCC_send_satevent( UBYTE event,
146 SHORT callId ,
147 T_CC_INITIATER actionSrc,
148 BOOL check_SatDiscEvent )
149 {
150 /* DOES NOTHING IF SIM TOOLKIT IS NOT HERE */
151 #ifdef SIM_TOOLKIT /* monitoring for SAT */
152 T_CC_CALL_TBL * pCtbNtry; /* holds pointer to call table entry */
153
154 pCtbNtry = ccShrdPrm.ctb[callId];
155
156 if( check_SatDiscEvent EQ TRUE ) /* not sure whether this is needed */
157 {
158 if ( !pCtbNtry -> SatDiscEvent )
159 {
160 pCtbNtry -> SatDiscEvent = TRUE;
161 if ( psaSAT_ChkEventList(event) )
162 {
163 cmhSAT_EventDwn( event, callId, actionSrc );
164 }
165 }
166 }
167 else
168 {
169 if ( psaSAT_ChkEventList(event) )
170 {
171 cmhSAT_EventDwn( event, callId, actionSrc );
172 }
173 }
174 #endif /* SIM_TOOLKIT */
175 }
176
177 /*
178 +-------------------------------------------------------------------+
179 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
180 | ROUTINE : psaCC_ctbNewEntry |
181 +-------------------------------------------------------------------+
182
183 PURPOSE : returns the call table index for a free entry to be used,
184 otherwise the function return -1 to indicate that no
185 entry is free.
186
187 NOTE: Having the condition to consider a call table
188 entry as be available to be reused not only
189 if ntryUsdFlg equals FALSE, but also if
190 calStat equals CS_IDL seems to be undesirable.
191
192 */
193
194 GLOBAL SHORT psaCC_ctbNewEntry ( void )
195 {
196 SHORT ctbIdx; /* holds call table index */
197
198 for (ctbIdx = 0; ctbIdx < MAX_CALL_NR; ctbIdx++)
199 {
200 if (ccShrdPrm.ctb[ctbIdx] EQ NULL)
201 {
202 psaCC_InitCtbNtry( ctbIdx );
203 return( ctbIdx );
204 }
205 }
206 return( -1 );
207 }
208
209
210
211 /*
212 +-------------------------------------------------------------------+
213 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
214 | ROUTINE : psaCC_ctbFindTi |
215 +-------------------------------------------------------------------+
216
217 PURPOSE : returns the call table index for the entry that holds
218 call parameters for the passed transaction identifier.
219 Returning -1 indicates that the passed ti was not found.
220 */
221
222 GLOBAL SHORT psaCC_ctbFindTi ( UBYTE ti2Find )
223 {
224 SHORT ctbIdx; /* holds call table index */
225
226 for( ctbIdx = 0; ctbIdx < MAX_CALL_NR; ctbIdx++ )
227 {
228 T_CC_CALL_TBL *ctbx = ccShrdPrm.ctb[ctbIdx];
229
230 if (ctbx NEQ NULL AND
231 ctbx->ti EQ ti2Find )
232
233 return( ctbIdx );
234 }
235
236 return( -1 );
237 }
238
239 /*
240 +-------------------------------------------------------------------+
241 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
242 | ROUTINE : psaCC_ctbFindCall |
243 +-------------------------------------------------------------------+
244
245 PURPOSE : returns the call table index for the entry that holds
246 call parameters for the call with the searched call owner,
247 call status and call type.
248 Returning -1 indicates that no such call was found.
249 */
250
251 GLOBAL SHORT psaCC_ctbFindCall ( T_OWN calOwn,
252 T_CC_CLST calStat,
253 T_CC_CLTP calType )
254 {
255 SHORT ctbIdx; /* holds call table index */
256
257 for( ctbIdx = 0; ctbIdx < MAX_CALL_NR; ctbIdx++ )
258 {
259 T_CC_CALL_TBL *ctbx = ccShrdPrm.ctb[ctbIdx];
260
261 if (ctbx NEQ NULL AND
262 ctbx->calStat EQ calStat)
263 {
264 if( calOwn EQ OWN_SRC_INV OR
265 ctbx->calOwn EQ calOwn )
266 {
267 if( calType EQ NO_VLD_CT OR
268 ctbx->calType EQ calType )
269
270 return( ctbIdx );
271 }
272 }
273 }
274
275 return( -1 );
276 }
277
278 /*
279 +-------------------------------------------------------------------+
280 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
281 | ROUTINE : psaCC_ctbCallInUse |
282 +-------------------------------------------------------------------+
283
284 PURPOSE : checks the call table if there is a call in use by a
285 owner, or if the call table is idle. The function returns
286 TRUE or FALSE.
287 */
288
289 GLOBAL BOOL psaCC_ctbCallInUse ( void )
290 {
291 SHORT ctbIdx; /* holds call table index */
292
293 for( ctbIdx = 0; ctbIdx < MAX_CALL_NR; ctbIdx++ )
294 {
295 T_CC_CALL_TBL *ctbx = ccShrdPrm.ctb[ctbIdx];
296
297 if (ctbx NEQ NULL)
298 {
299 switch( ctbx->calStat )
300 {
301 case( CS_ACT ):
302 case( CS_ACT_REQ ):
303 case( CS_HLD_REQ ):
304 case( CS_HLD ):
305 case( CS_DSC_REQ ):
306 case( CS_CPL_REQ ):
307 case( CS_MDF_REQ ):
308 if( ctbx->calOwn NEQ (T_OWN)CMD_SRC_NONE )
309 return( TRUE );
310 }
311 }
312 }
313
314 return( FALSE );
315 }
316
317 //TISH, patch for OMAPS00110151/OMAPS00130693
318 //start
319 GLOBAL SHORT psaCC_ctbCountActiveCall ( void )
320 {
321 SHORT ctbIdx; /* holds call table index */
322 SHORT activeCallNum=0;
323 for( ctbIdx = 0; ctbIdx < MAX_CALL_NR; ctbIdx++ )
324 {
325 T_CC_CALL_TBL *ctbx = ccShrdPrm.ctb[ctbIdx];
326
327 if (ctbx NEQ NULL && ctbx->calStat EQ CS_ACT)
328 activeCallNum++;
329 }
330 return activeCallNum;
331 }
332 //end
333
334 /*
335 +-------------------------------------------------------------------+
336 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
337 | ROUTINE : psaCC_ctbAnyCallInUse |
338 +-------------------------------------------------------------------+
339
340 PURPOSE : checks the call table if there is a any call in use,
341 or if the call table is idle. The function returns
342 TRUE or FALSE.
343 */
344
345 GLOBAL BOOL psaCC_ctbAnyCallInUse ( void )
346 {
347 SHORT ctbIdx; /* holds call table index */
348
349 for( ctbIdx = 0; ctbIdx < MAX_CALL_NR; ctbIdx++ )
350 {
351 T_CC_CALL_TBL *ctbx = ccShrdPrm.ctb[ctbIdx];
352
353 if (ctbx NEQ NULL)
354 {
355 switch( ctbx->calStat )
356 {
357 case( CS_ACT ):
358 case( CS_ACT_REQ ):
359 case( CS_HLD_REQ ):
360 case( CS_HLD ):
361 case( CS_DSC_REQ ):
362 case( CS_CPL_REQ ):
363 case( CS_MDF_REQ ):
364 return( TRUE );
365 }
366 }
367 }
368
369 return( FALSE );
370 }
371
372
373
374
375
376 /*
377 +-------------------------------------------------------------------+
378 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
379 | ROUTINE : psaCC_ctbDialNr2CldAdr |
380 +-------------------------------------------------------------------+
381
382 PURPOSE : this function converts a dial string into the settings
383 for the called address parameters for the passed call id.
384 The function returns -1 if an error occurs.
385 */
386
387 GLOBAL SHORT psaCC_ctbDialNr2CldAdr ( SHORT cId, char * pDialStr )
388 {
389 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
390 char * pSubAdr; /* points to subaddress */
391
392 /*
393 *-------------------------------------------------------------------
394 * seach for subaddress
395 *-------------------------------------------------------------------
396 */
397 pSubAdr = strchr( pDialStr, SA_DEL );
398
399 if ( pSubAdr ) /* subaddress found */
400 {
401 /*
402 * cutoff the subaddr from the dialnumber
403 */
404 *pSubAdr = 0x0;
405 pSubAdr++;
406
407 /*
408 * fill in subaddress information
409 */
410 ctb->cldPtySub.tos = MNCC_TOS_NSAP;
411
412 ctb->cldPtySub.c_subaddr =
413 (UBYTE)utl_dialStr2BCD (pSubAdr, ctb->cldPtySub.subaddr, MNCC_SUB_LENGTH);
414
415 ctb->cldPtySub.odd_even =
416 (ctb->cldPtySub.c_subaddr & 1) ? MNCC_OE_ODD : MNCC_OE_EVEN;
417 }
418 else /* subaddress not found */
419 {
420 ctb->cldPtySub.tos = MNCC_TOS_NOT_PRES;
421 ctb->cldPtySub.odd_even = MNCC_OE_EVEN;
422 ctb->cldPtySub.c_subaddr = 0;
423 }
424
425 /*
426 *-------------------------------------------------------------------
427 * fill in address information
428 *-------------------------------------------------------------------
429 */
430 ctb->cldPty.npi = MNCC_NPI_ISDN_TEL_NUMB_PLAN;
431
432 ctb->cldPty.ton = ((pDialStr[0] EQ '+') ? MNCC_TON_INT_NUMB : MNCC_TON_UNKNOWN);
433
434 /*
435 * 00 is not an indication for an international number
436 if( pDialStr[0] EQ '0' AND pDialStr[1] EQ '0' )
437 {
438 pDialStr += 2;
439 ctb->cldPty.ton = TON_INT_NUMB;
440 }
441 */
442
443 if (ctb->cldPty.called_num NEQ NULL)
444 {
445 ACI_MFREE (ctb->cldPty.called_num);
446 ctb->cldPty.called_num = NULL;
447 }
448 ctb->cldPty.c_called_num =
449 (UBYTE)utl_dialStr2BCD (pDialStr, NULL, MNCC_MAX_CC_CALLED_NUMBER);
450 if (ctb->cldPty.c_called_num NEQ 0)
451 {
452 ACI_MALLOC (ctb->cldPty.called_num,
453 ctb->cldPty.c_called_num);
454 (void)utl_dialStr2BCD (pDialStr,
455 ctb->cldPty.called_num,
456 ctb->cldPty.c_called_num);
457 }
458
459 return( 0 );
460 }
461
462 /*
463 +-------------------------------------------------------------------+
464 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
465 | ROUTINE : psaCC_ctbClrAdr2Num |
466 +-------------------------------------------------------------------+
467
468 PURPOSE : this function converts the parameters of the calling
469 address for the passed call id into a dial number. The
470 string is copied into the passed buffer. In case the
471 buffer size is not sufficient to hold the called number,
472 the number is cut to maxSize. The function returns a pointer
473 to the buffer or NULL if an error occurs.
474 */
475
476 GLOBAL CHAR *psaCC_ctbClrAdr2Num ( SHORT cId, CHAR *pNumBuf, UBYTE maxSize )
477 {
478 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
479
480 TRACE_FUNCTION ("psaCC_ctbClrAdr2Num()");
481
482 /* Implements Measure# 188 */
483 return (psaCC_ctbAdr2Num ( pNumBuf, maxSize , ctb->clgPty.num,
484 ctb->clgPty.c_num, ctb->clgPty.ton));
485 }
486
487 /*
488 +-------------------------------------------------------------------+
489 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
490 | ROUTINE : psaCC_ctbClrAdr2Sub |
491 +-------------------------------------------------------------------+
492
493 PURPOSE : this function converts the parameters of the calling
494 subaddress for the passed call id into a dial subnumber.
495 The string is copied into the passed buffer. The function
496 returns a pointer to the buffer or 0 if an error occurs.
497 */
498
499 GLOBAL CHAR *psaCC_ctbClrAdr2Sub ( SHORT cId, CHAR * pSubBuf )
500 {
501 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
502
503 /*
504 *-------------------------------------------------------------------
505 * convert BCD subaddress
506 *-------------------------------------------------------------------
507 */
508 if (ctb->clgPtySub.c_subaddr EQ 0 )
509 {
510 *pSubBuf = '\0'; /* empty string */
511 return( NULL );
512 }
513 utl_BCD2DialStr (ctb->clgPtySub.subaddr, pSubBuf,
514 ctb->clgPtySub.c_subaddr);
515
516 return( pSubBuf );
517 }
518
519 /*
520 +-------------------------------------------------------------------+
521 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
522 | ROUTINE : psaCC_ctbCldAdr2Num |
523 +-------------------------------------------------------------------+
524
525 PURPOSE : this function converts the parameters of the called
526 address for the passed call id into a dial number. The
527 string is copied into the passed buffer. In case the
528 buffer size is not sufficient to hold the called number,
529 the number is cut to maxSize. This is currently necessary
530 to protect the protocol stack from memory overwriting, as
531 the called party address for CC may have a size of up to
532 80 digits, but there may not be this room foreseen in some
533 phonebook entries. The function returns a pointer
534 to the buffer or NULL if an error occurs.
535 */
536
537 GLOBAL CHAR *psaCC_ctbCldAdr2Num ( SHORT cId, CHAR *pNumBuf, UBYTE maxSize )
538 {
539 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
540
541 /* Implements Measure# 188 */
542 return (psaCC_ctbAdr2Num ( pNumBuf, maxSize ,ctb->cldPty.called_num,
543 ctb->cldPty.c_called_num, ctb->cldPty.ton));
544 }
545
546 /*
547 +-------------------------------------------------------------------+
548 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
549 | ROUTINE : psaCC_ctbCldAdr2Sub |
550 +-------------------------------------------------------------------+
551
552 PURPOSE : this function converts the parameters of the called
553 subaddress for the passed call id into a dial subnumber.
554 The string is copied into the passed buffer. The function
555 returns a pointer to the buffer or 0 if an error occurs.
556 */
557
558 GLOBAL CHAR *psaCC_ctbCldAdr2Sub ( SHORT cId, CHAR * pSubBuf )
559 {
560 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
561
562 /*
563 *-------------------------------------------------------------------
564 * convert BCD subaddress
565 *-------------------------------------------------------------------
566 */
567 if (ctb->cldPtySub.c_subaddr EQ 0 )
568 {
569 *pSubBuf = '\0'; /* empty string */
570 return( NULL );
571 }
572 utl_BCD2DialStr (ctb->cldPtySub.subaddr, pSubBuf,
573 ctb->cldPtySub.c_subaddr);
574
575 return( pSubBuf );
576 }
577
578 /*
579 +-------------------------------------------------------------------+
580 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
581 | ROUTINE : psaCC_ctbRdrAdr2Num |
582 +-------------------------------------------------------------------+
583
584 PURPOSE : this function converts the parameters of the redirecting
585 address for the passed call id into a dial number. The
586 string is copied into the passed buffer. In case the
587 buffer size is not sufficient to hold the called number,
588 the number is cut to maxSize. The function returns a pointer
589 to the buffer or NULL if an error occurs.
590 */
591
592 GLOBAL CHAR *psaCC_ctbRdrAdr2Num ( SHORT cId, CHAR *pNumBuf, UBYTE maxSize )
593 {
594 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
595
596 /* Implements Measure# 189 */
597 return (psaCC_ctbAdr2Num ( pNumBuf, maxSize ,ctb->rdrPty.redir_num,
598 ctb->rdrPty.c_redir_num, ctb->rdrPty.ton));
599 }
600
601 /*
602 +-------------------------------------------------------------------+
603 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
604 | ROUTINE : psaCC_ctbRdrAdr2Sub |
605 +-------------------------------------------------------------------+
606
607 PURPOSE : this function converts the parameters of the redirecting
608 subaddress for the passed call id into a dial subnumber.
609 The string is copied into the passed buffer. The function
610 returns a pointer to the buffer or 0 if an error occurs.
611 */
612
613 GLOBAL CHAR *psaCC_ctbRdrAdr2Sub ( SHORT cId, CHAR * pSubBuf )
614 {
615 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
616
617 /*
618 *-------------------------------------------------------------------
619 * convert BCD subaddress
620 *-------------------------------------------------------------------
621 */
622 if (ctb->rdrPtySub.c_subaddr EQ 0 )
623 {
624 *pSubBuf = '\0'; /* empty string */
625 return( NULL );
626 }
627 utl_BCD2DialStr (ctb->rdrPtySub.subaddr, pSubBuf,
628 ctb->rdrPtySub.c_subaddr);
629
630 return( pSubBuf );
631 }
632
633 /*
634 +-------------------------------------------------------------------+
635 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
636 | ROUTINE : psaCC_ctbGetAplha |
637 +-------------------------------------------------------------------+
638
639 PURPOSE : this function returns the pointer of the aplha identifier
640 in the call table for the specified call. If no alpha
641 identifier is available a NULL pointer will be returned.
642 */
643
644 GLOBAL T_ACI_PB_TEXT *psaCC_ctbGetAlpha ( SHORT cId )
645 {
646 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
647
648 if( ctb->alphIdUni.len EQ 0 )
649
650 return( NULL );
651
652 else
653
654 return( &ctb->alphIdUni );
655 }
656
657 /*
658 +-------------------------------------------------------------------+
659 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
660 | ROUTINE : psaCC_chgCalTypCnt |
661 +-------------------------------------------------------------------+
662
663 PURPOSE : this function modifies the call type counter (MOC/MTC)
664 defined by the passed call id by the passed delta value.
665
666 NOTE: The purpose of this function is to be able to set
667 ccShrdPrm.TCHasg to FALSE if all calls are gone.
668 Nice try, but this could achieved more easily by
669 having a clean call table management.
670 Misconcepted code.
671
672 */
673
674 GLOBAL void psaCC_chngCalTypCnt ( SHORT cId, SHORT dlt )
675 {
676 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
677
678 TRACE_EVENT_P3 ("MOC = %d, MTC = %d, cId = %d",
679 (int)ccShrdPrm.nrOfMOC, (int)ccShrdPrm.nrOfMTC, (int)cId);
680
681 switch( ctb->calType )
682 {
683 case( CT_MOC ):
684
685 ccShrdPrm.nrOfMOC += dlt;
686
687 if( ccShrdPrm.nrOfMOC < 0 ) ccShrdPrm.nrOfMOC = 0;
688
689 break;
690
691 case( CT_MTC ):
692
693 ccShrdPrm.nrOfMTC += dlt;
694
695 if( ccShrdPrm.nrOfMTC < 0 ) ccShrdPrm.nrOfMTC = 0;
696
697 break;
698
699 case( CT_MOC_RDL):
700
701 break;
702
703 default:
704
705 TRACE_EVENT( "UNEXP CALL TYPE IN CTB" );
706 }
707
708 if (ctb->calType NEQ CT_MOC_RDL)
709 {
710 if (ccShrdPrm.nrOfMTC EQ 0 AND /* update state of TCH assignment */
711 ccShrdPrm.nrOfMOC EQ 0)
712 {
713 /* If there is any call in CS_ACT_REQ state then do not disable vocoder */
714 if(psaCC_ctbFindCall( (T_OWN)CMD_SRC_NONE, CS_ACT_REQ, CT_MTC ) < 0)
715 {
716 ccShrdPrm.TCHasg = FALSE;
717 }
718 cmhCC_TTY_Control (cId, TTY_STOP);
719 }
720 }
721
722 }
723
724
725 /*
726 +-------------------------------------------------------------------+
727 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
728 | ROUTINE : psaCC_chkPrgDesc |
729 +-------------------------------------------------------------------+
730
731 PURPOSE : this function checks for a valid progress description.
732 if valid, it updates the shared parameters and notifies
733 ACI.
734 */
735
736 GLOBAL void psaCC_chkPrgDesc ( SHORT cId, UBYTE prgDesc, UBYTE msgType )
737 {
738 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
739
740 TRACE_FUNCTION("psaCC_chkPrgDesc( )");
741
742 /* check in-band tones anouncement during call establishment
743 GSM 04.08/5.5.1 */
744
745 ccShrdPrm.msgType = msgType;
746 ctb->prgDesc = prgDesc;
747
748 if( msgType EQ MT_SETUP OR
749 msgType EQ MT_ALRT OR
750 msgType EQ MT_PROC OR
751 msgType EQ MT_SYNC OR
752 msgType EQ MT_PROGR OR
753 msgType EQ MT_CONN )
754 {
755
756 if( prgDesc EQ MNCC_PROG_INBAND_AVAIL OR
757 prgDesc EQ MNCC_PROG_NO_END_TO_END_PLMN OR
758 prgDesc EQ MNCC_PROG_DEST_NON_PLMN OR
759 prgDesc EQ MNCC_PROG_ORIGIN_NON_PLMN OR
760 (prgDesc >= 6 AND prgDesc <= 20) )
761 {
762 /* if( ccShrdPrm.TCHasg EQ TRUE ) */
763 {
764 TRACE_EVENT("Call with In-band tones");
765 if (msgType NEQ MT_SETUP) //mars for AMR can not play with mobile MT call
766 ctb->inBndTns = TRUE; /* implicit connect to In-band tones */
767 }
768 }
769 else if ( msgType EQ MT_ALRT )
770 {
771 cmhCC_CallAlerted(cId);
772 }
773 }
774
775 /* check in-band tones anouncement during call disconnection
776 GSM 04.08/5.4.4.1.1/5.4.4.1.2 */
777 else if( msgType EQ MT_DISC )
778 {
779 if( prgDesc EQ MNCC_PROG_INBAND_AVAIL )
780 {
781 TRACE_EVENT("Call with In-band tones");
782 if (msgType NEQ MT_SETUP) //mars for AMR can not play with mobile MT call
783 ctb->inBndTns = TRUE;
784 }
785 else
786 ctb->inBndTns = FALSE;
787 }
788
789 /*
790 * In the case of MT_DISC (mncc_disconnect_ind) cmhCC_CallDisconnected()
791 * called the CPI macro
792 */
793 if(MT_DISC NEQ msgType)
794 {
795 cmhCC_CallProceeding (cId);
796 }
797
798 /* Attach/Detach user connection as required */
799 psaCC_setSpeechMode ();
800 }
801
802 /*
803 +-------------------------------------------------------------------+
804 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
805 | ROUTINE : psaCC_getMOCTi |
806 +-------------------------------------------------------------------+
807
808 PURPOSE : this function selects a ti out of a pool of valid ti's
809 and inserts it into the passed call table entry if the
810 table index is valid. if no ti is available the function
811 returns -1 otherwise it returns the selected ti.
812 a bit of the pool stands for a valid ti.
813 0 indicates a used ti, 1 indicates a free ti.
814 */
815 GLOBAL SHORT psaCC_getMOCTi( SHORT cId )
816 {
817 UBYTE idx; /* holds pool idx */
818
819 for( idx = 0; idx < MAX_MOCTI_NR; idx++ )
820 {
821 if( tiPool & (1u << idx) )
822 {
823 tiPool &= ~(1u << idx);
824
825 if( cId >= 0 )
826 psaCC_ctb(cId)->ti = idx;
827 return( idx );
828 }
829 }
830 return( -1 );
831 }
832 /*
833 +-------------------------------------------------------------------+
834 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
835 | ROUTINE : psaCC_retMOCTi |
836 +-------------------------------------------------------------------+
837
838 PURPOSE : this function returns a used ti to the ti pool if the
839 call was a MOC. the ti is free for the next MOC
840 afterwards.
841 a bit of the pool stands for a valid ti.
842 0 indicates a used ti, 1 indicates a free ti.
843 */
844
845 GLOBAL void psaCC_retMOCTi( UBYTE ti )
846 {
847 if( ti < MAX_MOCTI_NR )
848
849 tiPool |= (0x01 << ti);
850 }
851
852
853 /*
854 +-------------------------------------------------------------------+
855 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
856 | ROUTINE : psaCC_setSpeechMode |
857 +-------------------------------------------------------------------+
858
859 PURPOSE : this function attachs or detachs the user connection.
860
861 */
862
863 GLOBAL void psaCC_setSpeechMode (void)
864 {
865 SHORT ctbIdx; /* holds call table index */
866 BOOL user_attach; /* Attach/Detach user connection */
867
868 TRACE_FUNCTION ("psaCC_setSpeechMode()");
869
870 user_attach = FALSE;
871
872 if (((ccShrdPrm.chMod EQ MNCC_CHM_SPEECH) OR
873 (ccShrdPrm.chMod EQ MNCC_CHM_SPEECH_V2) OR
874 (ccShrdPrm.chMod EQ MNCC_CHM_SPEECH_V3)) AND (ccShrdPrm.syncCs NEQ MNCC_CAUSE_REEST_STARTED))
875 {
876 /*
877 * The channel mode is appropriate for speech.
878 * Find any non-IDLE speech call where inband tones are available
879 * or the active state has been reached. If there is such a call,
880 * attach the user connection, otherwise detach it.
881 */
882 for (ctbIdx = 0; ctbIdx < MAX_CALL_NR; ctbIdx++)
883 {
884 T_CC_CALL_TBL *ctbx = ccShrdPrm.ctb[ctbIdx];
885
886 if ((ctbx NEQ NULL) AND
887 (ctbx->calStat NEQ NO_VLD_CS) AND
888 (ctbx->calStat NEQ CS_IDL) AND
889 (ctbx->calStat NEQ CS_HLD))
890 {
891 /*
892 * The call is non-Idle and non-Hold. Check for inband tones,
893 * active or call modification requested state.
894 */
895 if ( ctbx->inBndTns OR
896 (ctbx->calStat EQ CS_ACT) OR
897 (ctbx->calStat EQ CS_CPL_REQ) OR
898 (ctbx->calStat EQ CS_MDF_REQ))
899 {
900 //TISH: open vocoder if there is active call
901 if (ctbx->calStat EQ CS_ACT)
902 {
903 user_attach = TRUE;
904 break;
905 }
906 if (ccShrdPrm.TCHasg NEQ TRUE)
907
908 {
909 /* CCBS: 4.08/5.4.4.2ff do not connect to the in-band tone/announcement
910 */
911 }
912 else
913 {
914 user_attach = TRUE;
915 break;
916 }
917 }
918
919 }
920 }
921 }
922
923 hl_drv_set_vocoder_state(user_attach);
924
925 /* Implements Measure#32: Row 1237 & 1238 */
926 if(user_attach)
927 {
928 TRACE_EVENT("User state: attach user");
929 }
930 else
931 {
932 TRACE_EVENT("User state: detach user");
933 }
934 }
935
936 /*
937 +-------------------------------------------------------------------+
938 | PROJECT : GSM-PS (6147) MODULE : CMH_CC |
939 | ROUTINE : psaCC_phbSrchNum |
940 +-------------------------------------------------------------------+
941
942 PURPOSE : phonebook search for number
943
944 */
945
946 GLOBAL void psaCC_phbSrchNum ( SHORT cId, T_CC_CLTP call_type)
947 {
948 UBYTE maxLen = MAX_ALPHA; /* maximum length of entry */
949 CHAR numBuf[MAX_PHB_NUM_LEN]; /* buffers number 'number\0' */
950
951 TRACE_FUNCTION("psaCC_phbSrchNum");
952
953 switch(call_type)
954 {
955 case CT_MOC:
956 case CT_MOC_RDL:
957 case CT_NI_MOC:
958 if(!psaCC_ctbCldAdr2Num(cId, numBuf, MAX_PHB_NUM_LEN))
959 return;
960 break;
961 case CT_MTC:
962 if(!psaCC_ctbClrAdr2Num (cId, numBuf, MAX_PHB_NUM_LEN))
963 return;
964 break;
965 default:
966 return;
967 }
968
969
970 psaCC_phbSrchNumPlnTxt( numBuf, &maxLen, &psaCC_ctb(cId)->alphIdUni );
971
972 return;
973 }
974
975 /*
976 +-------------------------------------------------------------------+
977 | PROJECT : GSM-PS (6147) MODULE : CMH_CC |
978 | ROUTINE : psaCC_phbSrchNumPlnTxt |
979 +-------------------------------------------------------------------+
980
981 PURPOSE : phonebook search for number. Returns TRUE if at least
982 any matching number is found.
983
984 */
985
986 GLOBAL BOOL psaCC_phbSrchNumPlnTxt ( CHAR * inNum,
987 UBYTE * inoutMaxLen,
988 T_ACI_PB_TEXT * outTxt )
989 {
990 #ifdef TI_PS_FFS_PHB
991 SHORT order_num; /* Order number of entry by number */
992 #else
993 SHORT mtch = 0; /* holds number of matches */
994 SHORT fstIdx; /* holds first index */
995 #endif
996 UBYTE lstIdx; /* holds phonebook list index */
997 T_PHB_RECORD ntry; /* found entry */
998
999 outTxt->cs = CS_NotPresent;
1000 outTxt->len = 0;
1001
1002 for ( lstIdx = 0; phbSrchLst[lstIdx] NEQ -1; lstIdx++ )
1003 {
1004 #ifdef TI_PS_FFS_PHB
1005 order_num = 0;
1006 if (pb_search_number ((T_PHB_TYPE)phbSrchLst[lstIdx],
1007 (const UBYTE*)inNum,
1008 &order_num) EQ PHB_OK)
1009 {
1010 /* Implements Measure #30 */
1011 if (pb_sim_read_alpha_num_record ((T_PHB_TYPE)phbSrchLst[lstIdx],
1012 order_num, &ntry,
1013 NUMBER_IDX) EQ PHB_OK)
1014 #else
1015 pb_search_number ( (UBYTE)phbSrchLst[lstIdx],
1016 (UBYTE*)inNum,
1017 PHB_NEW_SEARCH,
1018 &fstIdx, &mtch, &ntry );
1019
1020 {
1021 if ( mtch NEQ 0 )
1022 #endif
1023 {
1024 *inoutMaxLen = ( UBYTE ) MINIMUM ( ntry.tag_len, MAX_ALPHA );
1025
1026 while ( ( outTxt->len < *inoutMaxLen ) AND
1027 ( ntry.tag[outTxt->len] NEQ 0xFF ) )
1028 {
1029 outTxt->data[outTxt->len] = ntry.tag[outTxt->len];
1030 outTxt->len++;
1031 }
1032 outTxt->cs = CS_Sim;
1033
1034 return TRUE;
1035 }
1036 }
1037 }
1038
1039 return FALSE;
1040 }
1041
1042 /*
1043 +-------------------------------------------------------------------+
1044 | PROJECT : GSM-PS (6147) MODULE : CMH_CC |
1045 | ROUTINE : psaCC_phbMfwSrchNumPlnTxt |
1046 +-------------------------------------------------------------------+
1047
1048 PURPOSE : phonebook search for number. Returns TRUE if at least
1049 any matching number is found.
1050
1051 */
1052
1053 GLOBAL BOOL psaCC_phbMfwSrchNumPlnTxt ( CHAR * inNum,
1054 T_ACI_PB_TEXT * outTxt )
1055 {
1056 #ifdef TI_PS_FFS_PHB
1057 SHORT order_num; /* Order number of entry by number */
1058 #else
1059 SHORT mtch = 0; /* holds number of matches */
1060 SHORT fstIdx; /* holds first index */
1061 #endif
1062 UBYTE maxLen; /* holds max alpha length */
1063 UBYTE lstIdx; /* holds phonebook list index */
1064 T_PHB_RECORD ntry; /* found entry */
1065
1066 TRACE_FUNCTION("psaCC_phbMfwSrchNumPlnTxt()");
1067
1068 outTxt->len = 0;
1069
1070 for ( lstIdx = 0; phbSrchLst[lstIdx] NEQ -1; lstIdx++ )
1071 {
1072 #ifdef TI_PS_FFS_PHB
1073 order_num = 0;
1074 if (pb_search_number ((T_PHB_TYPE)phbSrchLst[lstIdx],
1075 (const UBYTE*)inNum,
1076 &order_num) EQ PHB_OK)
1077 {
1078 /* Implements Measure #30 */
1079 if (pb_sim_read_alpha_num_record ((T_PHB_TYPE)phbSrchLst[lstIdx],
1080 order_num, &ntry,
1081 NUMBER_IDX) EQ PHB_OK)
1082 #else
1083 pb_search_number ( (UBYTE)phbSrchLst[lstIdx],
1084 (UBYTE*)inNum,
1085 PHB_NEW_SEARCH,
1086 &fstIdx, &mtch, &ntry );
1087
1088 {
1089 if ( mtch NEQ 0 )
1090 #endif
1091 {
1092 maxLen = ( UBYTE ) MINIMUM ( ntry.tag_len, MAX_ALPHA );
1093
1094 outTxt -> len = 0;
1095
1096 while ( outTxt -> len < maxLen AND ntry.tag[outTxt -> len] NEQ 0xFF )
1097 {
1098 outTxt -> data[outTxt -> len] = ntry.tag[outTxt -> len];
1099 outTxt -> len++;
1100 }
1101
1102 return TRUE;
1103 }
1104 }
1105 }
1106
1107 return FALSE;
1108 }
1109
1110 /*
1111 +-------------------------------------------------------------------+
1112 | PROJECT : GSM-PS (6147) MODULE : CMH_CC |
1113 | ROUTINE : psaCC_phbSrchName |
1114 +-------------------------------------------------------------------+
1115
1116 PURPOSE : phonebook search for name
1117
1118 */
1119
1120 GLOBAL BOOL psaCC_phbSrchName ( T_ACI_CMD_SRC srcId,
1121 T_ACI_PB_TEXT *srchName,
1122 T_CLPTY_PRM *calPrm )
1123 {
1124 #ifdef TI_PS_FFS_PHB
1125 T_PHB_MATCH match_criteria; /* matching criteria */
1126 SHORT order_num; /* Order number of entry by number */
1127 #else
1128 SHORT fstIdx; /* holds first index */
1129 SHORT srchRslt = 0; /* holds search result */
1130 #endif
1131 UBYTE lstIdx; /* holds phonebook list index */
1132 T_PHB_RECORD phbNtry; /* holds phonebook entry */
1133
1134 memset( calPrm, 0x0, sizeof(T_CLPTY_PRM));
1135
1136 /*
1137 *-------------------------------------------------------------------
1138 * check for name search
1139 *-------------------------------------------------------------------
1140 */
1141 for( lstIdx = 0; phbSrchLst[lstIdx] NEQ -1; lstIdx++ )
1142 {
1143 #ifdef TI_PS_FFS_PHB
1144 if (srcId EQ CMD_SRC_LCL)
1145 match_criteria = PHB_MATCH_GE;
1146 else
1147 match_criteria = PHB_MATCH_PARTIAL;
1148
1149 order_num = 0;
1150 if (pb_search_name ((T_PHB_TYPE)phbSrchLst[lstIdx],
1151 match_criteria,
1152 srchName,
1153 &order_num) EQ PHB_OK)
1154 {
1155 /* Implements Measure #30 */
1156 if ( pb_sim_read_alpha_num_record ((T_PHB_TYPE)phbSrchLst[lstIdx],
1157 order_num, &phbNtry, NAME_IDX)
1158 EQ PHB_OK)
1159 #else
1160 pb_search_name ( srcId,
1161 (UBYTE)phbSrchLst[lstIdx], srchName, PHB_NEW_SEARCH,
1162 &fstIdx, &srchRslt, &phbNtry );
1163 {
1164 if( srchRslt NEQ 0 )
1165 #endif
1166 {
1167 cmhPHB_getAdrStr( calPrm->num, MAX_PHB_NUM_LEN-1,
1168 phbNtry.number, phbNtry.len );
1169
1170 cmh_demergeTOA ( phbNtry.ton_npi, &calPrm->ton, &calPrm->npi );
1171
1172 return( TRUE );
1173 }
1174 }
1175 }
1176
1177 return( FALSE );
1178 }
1179
1180 /*
1181 +-------------------------------------------------------------------+
1182 | PROJECT : GSM-PS (6147) MODULE : CMH_CC |
1183 | ROUTINE : psaCC_phbSrchECC |
1184 +-------------------------------------------------------------------+
1185
1186 PURPOSE : phonebook search for emergency number
1187
1188 */
1189
1190 GLOBAL UBYTE psaCC_phbSrchECC ( CHAR* dialStr, BOOL srchECC )
1191 {
1192
1193 #ifdef TI_PS_FFS_PHB
1194 SHORT order_num; /* Order number of entry by number */
1195 UBYTE dummy_num_len;
1196 UBYTE tag_len;
1197 UBYTE idx;
1198 SHORT max_rcd, used_rcd;
1199 #else
1200 SHORT mtch; /* holds number of matches */
1201 SHORT fstIdx; /* holds first index */
1202 T_PHB_RECORD ntry; /* found entry */
1203 UBYTE service, tag_len;
1204 UBYTE idx;
1205 SHORT max_rcd, ecc_on_sim_count, avail_rcd;
1206 #endif
1207 SHORT dummy_max_ext, dummy_used_ext;
1208
1209 TRACE_FUNCTION("psaCC_phbSrchECC");
1210
1211 if (dialStr EQ NULL)
1212 return( MNCC_PRIO_NORM_CALL );
1213
1214 /* remove any CLIR suppression/invocation prior checking for ECC */
1215 /* Implements Measure#32: Row 89, 90, 116, 117, 1241 & 1242 */
1216 if (!strncmp( dialStr, ksd_supp_clir_str, 4) OR
1217 !strncmp( dialStr, ksd_inv_clir_str, 4))
1218 dialStr+=4; /* skip CLIR supression/invocation digits */
1219
1220 if ( *dialStr EQ '\0' )
1221 return( MNCC_PRIO_NORM_CALL ); /* empty dialStr passed? */
1222
1223 /*
1224 * if emergency call numbers from SIM are available, only use
1225 * the emergency call numbers from the SIM
1226 */
1227 #ifdef TI_PS_FFS_PHB
1228 if (pb_read_sizes (ECC, &max_rcd, &used_rcd, &dummy_num_len, &tag_len,
1229 &dummy_max_ext, &dummy_used_ext) EQ PHB_OK)
1230 {
1231 if ( used_rcd )
1232 {
1233 /* SIM emergency numbers in SIM phonebook available */
1234 order_num = 0;
1235 if (pb_search_number (ECC, (const UBYTE*)dialStr, &order_num) EQ PHB_OK)
1236 {
1237 TRACE_EVENT("EMERGENCY_CALL (PHONEBOOK)!");
1238 return( MNCC_PRIO_EMERG_CALL );
1239 }
1240
1241 /* Implements Measure#32: Row 1239 */
1242 if (!strcmp(num_911_str,dialStr) OR !strcmp(num_112_str,dialStr))
1243 {
1244 TRACE_EVENT("EMERGENCY_CALL (!PHONEBOOK) 911 or 112");
1245 return( MNCC_PRIO_EMERG_CALL );
1246 }
1247 /* no valid emergency number */
1248 return( MNCC_PRIO_NORM_CALL );
1249 }
1250 }
1251 #else
1252 if (pb_read_status( ECC, &service, &max_rcd, &ecc_on_sim_count, &tag_len, &avail_rcd,
1253 &dummy_max_ext, &dummy_used_ext) EQ PHB_OK)
1254 {
1255 if ( ecc_on_sim_count )
1256 {
1257 /* SIM emergency numbers have been read and stored in phonebook */
1258 if (pb_search_number( ECC, (UBYTE*)dialStr, PHB_NEW_SEARCH, &fstIdx, &mtch, &ntry ) EQ PHB_OK)
1259 {
1260 if( mtch )
1261 {
1262 TRACE_EVENT("EMERGENCY_CALL (PHONEBOOK)!");
1263 return( MNCC_PRIO_EMERG_CALL );
1264 }
1265 /* Implements Measure#32: Row 1239 */
1266 if(!strcmp(num_911_str,dialStr) OR !strcmp(num_112_str,dialStr))
1267 {
1268 TRACE_EVENT("EMERGENCY_CALL (!PHONEBOOK) 911 or 112");
1269 return( MNCC_PRIO_EMERG_CALL );
1270 }
1271 /* no valid emergency number */
1272 return( MNCC_PRIO_NORM_CALL );
1273 }
1274 }
1275 }
1276 #endif
1277
1278 /* check the default emergency numbers */
1279 for (idx=0; *ec_string[idx] NEQ '\0'; idx++)
1280 {
1281 if ( !strcmp(ec_string[idx], dialStr) )
1282 {
1283 /* if dialStr is a service number, then no emergency call */
1284 #ifdef TI_PS_FFS_PHB
1285 //TISH, patch for OMAPS00137002
1286 //start
1287 #if 0
1288 order_num = 0;
1289 if (pb_search_number (SDN, (const UBYTE*)dialStr, &order_num) EQ PHB_OK)
1290 {
1291 break;
1292 }
1293 #endif
1294 //end
1295 TRACE_EVENT("EMERGENCY_CALL! (DEFAULT)");
1296 return( MNCC_PRIO_EMERG_CALL );
1297 }
1298 }
1299 #else
1300 //TISH, patch for OMAPS00137002
1301 //start
1302 #if 0
1303 if (pb_search_number( SDN, (UBYTE*)dialStr, PHB_NEW_SEARCH, &fstIdx, &mtch, &ntry ) EQ PHB_OK)
1304 {
1305 if( mtch )
1306 {
1307 break;
1308 }
1309 }
1310 #endif
1311 //end
1312 TRACE_EVENT("EMERGENCY_CALL! (DEFAULT)");
1313 return( MNCC_PRIO_EMERG_CALL );
1314 }
1315 }
1316 #endif
1317
1318 /*if no valid SIM is inserted check the additional default emergency numbers */
1319 if ((simShrdPrm.SIMStat NEQ SS_OK) AND
1320 (simShrdPrm.SIMStat NEQ SS_BLKD))
1321 {
1322 /* compare each additional default emergency call number */
1323 for (idx=0; *ec_string_ns[idx] NEQ '\0'; idx++)
1324 {
1325 if ( !strcmp(ec_string_ns[idx], dialStr) )
1326 {
1327 TRACE_EVENT("EMERGENCY_CALL! (DEFAULT WITHOUT SIM)");
1328 return ( MNCC_PRIO_EMERG_CALL );
1329 }
1330 }
1331 }
1332
1333 /* search for emergency call numbers in the phonebook */
1334 if( srchECC )
1335 #ifdef TI_PS_FFS_PHB
1336 {
1337 order_num = 0;
1338 if (pb_search_number (ECC, (const UBYTE*)dialStr, &order_num) EQ PHB_OK)
1339 {
1340 TRACE_EVENT("EMERGENCY_CALL!");
1341 return( MNCC_PRIO_EMERG_CALL );
1342 }
1343 }
1344 #else
1345 {
1346 if (pb_search_number( ECC, (UBYTE*)dialStr, PHB_NEW_SEARCH, &fstIdx, &mtch, &ntry ) EQ PHB_OK)
1347 {
1348 if( mtch )
1349 {
1350 TRACE_EVENT("EMERGENCY_CALL!");
1351 return( MNCC_PRIO_EMERG_CALL );
1352 }
1353 }
1354 }
1355 #endif
1356
1357 #ifdef TI_PS_FF_AT_CMD_P_ECC
1358 /*
1359 *--------------------------------------------------------------------
1360 * compare the dialed number with the ECC numbers already stored
1361 *--------------------------------------------------------------------
1362 */
1363 if(cmhCC_isNrInAdditionalECC(dialStr))
1364 {
1365 TRACE_EVENT("EMERGENCY_CALL! (additional ECC number)");
1366 return (MNCC_PRIO_EMERG_CALL);
1367 }
1368 #endif /* TI_PS_FF_AT_CMD_P_ECC */
1369 /* no valid emergency number */
1370 return( MNCC_PRIO_NORM_CALL );
1371 }
1372
1373 /*
1374 +-------------------------------------------------------------------+
1375 | PROJECT : GSM-PS (6147) MODULE : CMH_CC |
1376 | ROUTINE : psaCC_phbNtryFnd |
1377 +-------------------------------------------------------------------+
1378
1379 PURPOSE : phonebook search if entry exist
1380
1381 */
1382
1383 GLOBAL BOOL psaCC_phbNtryFnd ( UBYTE phb, T_CLPTY_PRM* calPrm )
1384 {
1385 #ifndef TI_PS_FFS_PHB
1386 SHORT mtchDmy = 0; /* holds number of matches */
1387 SHORT fstIdxDmy; /* holds first index */
1388 #endif
1389 T_PHB_RECORD ntry; /* holds phonebook entry */
1390 SHORT order_num; /* Order number of entry by number */
1391 UBYTE toa; /* Type Of Address */
1392
1393 TRACE_FUNCTION("psaCC_phbNtryFnd()");
1394
1395 /* Problem for GSM string in FDN: if the call number includes an
1396 international '+', the number will not be found, because the
1397 FDN entry will not have a '+' for international calls, but ton
1398 is set to TON_International.
1399 Solution: copy the call parameter. If ton is not set to international,
1400 then check if '+' is embeded in the call number. If it has a '+',
1401 then remove it from the copied call number, set ton of the copy
1402 to international and use the copy for the FDN search.
1403 */
1404
1405 /* search number */
1406 toa = cmh_mergeTOA ( calPrm -> ton, calPrm -> npi );
1407
1408 if( phb EQ FDN )
1409 {
1410 T_CLPTY_PRM *calPrmCopy;
1411
1412 ACI_MALLOC (calPrmCopy, sizeof (T_CLPTY_PRM));
1413
1414 *calPrmCopy = *calPrm; /* Struct assignment */
1415
1416 /* check if '+' is within the string and remove it if it is */
1417 if (psaCC_handleInternatPlus(calPrmCopy->num))
1418 {
1419 /* set calling parameter for international */
1420 calPrmCopy->ton = TON_International;
1421 toa = cmh_mergeTOA( calPrmCopy->ton, calPrmCopy->npi );
1422 }
1423 if (calPrm->ton EQ MNCC_TON_UNKNOWN)
1424 {
1425 toa = 0;
1426 }
1427 ACI_MFREE (calPrmCopy);
1428 return (pb_check_fdn(toa, (const UBYTE*)calPrm->num) EQ PHB_OK);
1429 }
1430 else
1431 #ifdef TI_PS_FFS_PHB
1432 {
1433 order_num = 0;
1434 if (pb_search_number ((T_PHB_TYPE)phb, (const UBYTE*)calPrm->num, &order_num) NEQ PHB_OK)
1435 return FALSE;
1436
1437 /* Implements Measure #30 */
1438 if (pb_sim_read_alpha_num_record ((T_PHB_TYPE)phb, order_num, &ntry, NUMBER_IDX)
1439 NEQ PHB_OK)
1440 return FALSE;
1441 }
1442
1443 return ((toa EQ ntry.ton_npi) OR (ntry.ton_npi EQ 0xFF));
1444 #else
1445 {
1446 pb_search_number( phb, (UBYTE*)calPrm->num, PHB_NEW_SEARCH,
1447 &fstIdxDmy,&mtchDmy,&ntry );
1448 }
1449
1450 if( mtchDmy NEQ 0 AND ((toa EQ ntry.ton_npi) OR (ntry.ton_npi EQ 0xFF) OR (toa EQ 0)) ) /* VO patch 02.03.01 */
1451 {
1452 return( TRUE );
1453 }
1454 else
1455 {
1456 return( FALSE );
1457 }
1458 #endif
1459 }
1460
1461 /*
1462 +-------------------------------------------------------------------+
1463 | PROJECT : GSM-PS (6147) MODULE : CMH_CC |
1464 | ROUTINE : psaCC_handleInternatPlus|
1465 +-------------------------------------------------------------------+
1466
1467 PURPOSE : check if '+' is embeded in the call number. If it
1468 has a '+', then remove it from the call number
1469
1470 RETURNS : TRUE, if '+' has been found
1471 FALSE, if '+' has not been found
1472 */
1473 LOCAL UBYTE psaCC_handleInternatPlus( char *number )
1474 {
1475 UBYTE i;
1476 UBYTE str_len = strlen((char*)number);
1477
1478 TRACE_FUNCTION("psaCC_handleInternatPlus()");
1479
1480 /* Specific pos to check are number[4], number[5] and number[6] */
1481 if ( str_len > 4 )
1482 {
1483 for (i=4; (number[i] != 0) && (i<=6); i++)
1484 {
1485 if ( number[i] EQ '+' )
1486 {
1487 /* '+' for international number found */
1488
1489 /* move all digits to right of '+' 1 position to the left to
1490 remove the '+' from the call number */
1491 memmove( (&number[i]), (&number[i+1]), str_len - (i+1) );
1492 number[str_len-1] = '\0';
1493
1494 return TRUE;
1495 }
1496 }
1497 }
1498 /* no '+' for international number found */
1499 return FALSE;
1500 }
1501
1502
1503 /*
1504 +-------------------------------------------------------------------+
1505 | PROJECT : GSM-PS (6147) MODULE : CMH_CC |
1506 | ROUTINE : psaCC_phbAddNtry |
1507 +-------------------------------------------------------------------+
1508
1509 PURPOSE : add call table setting to specified phonebook
1510
1511 NOTE: This function can be called with a cId EQ NO_ENTRY.
1512 Not nice.
1513
1514 */
1515
1516 GLOBAL void psaCC_phbAddNtry ( UBYTE phb, SHORT cId, UBYTE clTp, T_CLPTY_PRM *cldPty )
1517 {
1518 #ifndef TI_PS_FFS_PHB
1519 SHORT mtch; /* holds number of matches */
1520 SHORT fstIdx; /* holds first index */
1521 #endif
1522 T_PHB_RECORD ntry; /* holds phonebook entry */
1523 SHORT order_num; /* holds first index */
1524 CHAR numBuf[MAX_PHB_NUM_LEN]; /* buffers number 'number\0' */
1525 rtc_time_type rtc_time; /* creation time for LDN,LRN,.. entry */
1526
1527 TRACE_FUNCTION ("psaCC_phbAddNtry()");
1528
1529 if( phb EQ LDN AND PBCFldn EQ PBCF_LDN_Disable ) return;
1530 if( phb EQ LRN AND PBCFlrn EQ PBCF_LRN_Disable ) return;
1531 if( phb EQ LMN AND PBCFlmn EQ PBCF_LMN_Disable ) return;
1532
1533 if (cldPty NEQ NULL) /* Explicit number passed? */
1534 {
1535 strncpy(numBuf, cldPty->num, MAX_PHB_NUM_LEN-1);
1536 numBuf[MAX_PHB_NUM_LEN-1]='\0';
1537 }
1538 else /* otherwise read number from CTB and add DTMF */
1539 {
1540 switch (clTp)
1541 {
1542 case CT_MTC:
1543 /* Save time stamp of MT Call even if number is not known */
1544 psaCC_ctbClrAdr2Num( cId, numBuf, MAX_PHB_NUM_LEN );
1545 break;
1546 case CT_MOC:
1547 case CT_NI_MOC: /* Maybe also for CCBS */
1548 if (!psaCC_ctbCldAdr2Num( cId, numBuf, MAX_PHB_NUM_LEN ))
1549 return;
1550 break;
1551 default: /* invalid or no call */
1552 return;
1553 }
1554
1555 if (strlen(numBuf) < MAX_PHB_NUM_LEN-1) /* is there still room for DTMF digits? */
1556 {
1557 strncat(numBuf,
1558 (char *)ccShrdPrm.dtmf.dig,
1559 (MAX_PHB_NUM_LEN-1) - strlen(numBuf) ); /* remember the previos cut off DTMF digits */
1560 }
1561 }
1562
1563 if ((phb NEQ LDN) AND (phb NEQ LRN) AND (phb NEQ LMN))
1564 #ifdef TI_PS_FFS_PHB
1565 {
1566 order_num = 0;
1567 if (pb_search_number ((T_PHB_TYPE)phb, (const UBYTE*)numBuf, &order_num) EQ PHB_OK)
1568 return; /* entry already exist */
1569 }
1570
1571 memset (&ntry, 0, sizeof (T_PHB_RECORD));
1572
1573 ntry.phy_recno = 0; /* Search for a free record */
1574 memset((char *)ntry.tag, 0xFF, PHB_MAX_TAG_LEN);
1575 memset((char *)ntry.subaddr, 0xFF, PHB_PACKED_SUB_LEN);
1576 #else
1577 {
1578 pb_search_number( phb, (UBYTE*)numBuf, PHB_NEW_SEARCH,
1579 &fstIdx,&mtch,&ntry );
1580
1581 if( mtch NEQ 0 ) return; /* entry already exist */
1582 }
1583
1584 ntry.index = 0;
1585 memset((char *)ntry.tag, 0xFF, PHB_MAX_TAG_LEN);
1586 memset((char *)ntry.subaddr, 0xFF, PHB_PACKED_NUM_LEN);
1587 #endif
1588
1589 if (cldPty NEQ NULL) /* Explicit number passed? */
1590 {
1591 T_ACI_PB_TEXT tag;
1592 ntry.tag_len = PHB_MAX_TAG_LEN;
1593
1594 if (psaCC_phbSrchNumPlnTxt ( numBuf, &ntry.tag_len, &tag ))
1595 memcpy(ntry.tag, tag.data, ntry.tag_len);
1596 else
1597 ntry.tag_len = 0;
1598
1599 ntry.ton_npi=((cldPty->ton & 0x07) << 4 ) +
1600 (cldPty->npi & 0x0F) + 0x80;
1601 }
1602 else
1603 {
1604 /*
1605 * Probably it is important to use this pointer variable here!
1606 */
1607 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
1608
1609 if ( ctb->alphIdUni.cs EQ CS_Sim )
1610 {
1611 cmhPHB_getTagSim( &ctb->alphIdUni, ntry.tag, PHB_MAX_TAG_LEN );
1612 ntry.tag_len = MINIMUM ( ctb->alphIdUni.len, PHB_MAX_TAG_LEN );
1613 }
1614 else
1615 ntry.tag_len = 0;
1616
1617 if( clTp EQ CT_MOC )
1618 ntry.ton_npi = ((ctb->cldPty.ton & 0x07) << 4 ) +
1619 (ctb->cldPty.npi & 0x0F) + 0x80;
1620
1621 else if ( clTp EQ CT_MTC )
1622 ntry.ton_npi = ((ctb->clgPty.ton & 0x07) << 4 ) +
1623 (ctb->clgPty.npi & 0x0F) + 0x80;
1624 }
1625
1626 cmhPHB_getAdrBcd ( ntry.number, &ntry.len,
1627 PHB_PACKED_NUM_LEN, numBuf );
1628
1629 ntry.cc_id = 0xFF;
1630 #ifdef TI_PS_FFS_PHB
1631 ntry.v_time = FALSE;
1632 ntry.v_line = FALSE;
1633 #endif
1634
1635 if ( ( phb EQ LDN ) OR ( phb EQ LRN ) OR ( phb EQ LMN ) )
1636 {
1637 if ( rtc_read_time ( &rtc_time ) EQ TRUE )
1638 {
1639 #ifdef TI_PS_FFS_PHB
1640 ntry.v_time = TRUE;
1641 ntry.time.year = rtc_time.year;
1642 ntry.time.month = rtc_time.month;
1643 ntry.time.day = rtc_time.day;
1644 ntry.time.hour = rtc_time.hour;
1645 ntry.time.minute = rtc_time.minute;
1646 ntry.time.second = rtc_time.second;
1647 #else
1648 ntry.year = rtc_time.year;
1649 ntry.month = rtc_time.month;
1650 ntry.day = rtc_time.day;
1651 ntry.hour = rtc_time.hour;
1652 ntry.minute = rtc_time.minute;
1653 ntry.second = rtc_time.second;
1654 #endif
1655
1656
1657
1658
1659
1660
1661 }
1662
1663 #ifdef TI_PS_FFS_PHB
1664 ntry.v_line = TRUE;
1665 #endif
1666
1667 if (cId NEQ NO_ENTRY AND
1668 psaCC_ctb(cId)->BC[0].bearer_serv EQ MNCC_BEARER_SERV_AUX_SPEECH)
1669 {
1670 ntry.line = 2;
1671 }
1672 else
1673 {
1674 ntry.line = 1;
1675 }
1676 }
1677 /* ACI-SPR-16301: result might also be PHB_EXCT */
1678 #ifdef TI_PS_FFS_PHB
1679 if( pb_add_record ( (T_PHB_TYPE)phb, ntry.phy_recno, &ntry ) EQ PHB_FAIL )
1680 #else
1681 if( pb_add_record ( phb, ntry.index, &ntry ) EQ PHB_FAIL )
1682 #endif
1683 {
1684 TRACE_EVENT( "PHONEBOOK ADDING FAILED" );
1685 }
1686 }
1687
1688 /*
1689 +-------------------------------------------------------------------+
1690 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
1691 | ROUTINE : psaCC_asmBuildMPTY |
1692 +-------------------------------------------------------------------+
1693
1694 PURPOSE : assemble the build multiparty SS facility
1695 information element. return invoke id.
1696 */
1697
1698 GLOBAL void psaCC_asmBuildMPTY ( void )
1699 {
1700 TRACE_FUNCTION("psaCC_asmBuildMPTY");
1701
1702 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf ));
1703
1704 ssFIECodeBuf.l_buf = 8;
1705 ssFIECodeBuf.o_buf = 0;
1706 ssFIECodeBuf.buf[0] = OPC_BUILD_MPTY;
1707
1708 ccShrdPrm.cmpType = CT_INV;
1709 }
1710
1711 /* Implements Measure #86 */
1712
1713 /*
1714 +-------------------------------------------------------------------+
1715 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
1716 | ROUTINE : psaCC_asmSplitMPTY |
1717 +-------------------------------------------------------------------+
1718
1719 PURPOSE : assemble the split multiparty SS facility
1720 information element. return invoke id.
1721 */
1722
1723 GLOBAL void psaCC_asmSplitMPTY ( void )
1724 {
1725 TRACE_FUNCTION("psaCC_asmSplitMPTY");
1726
1727 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf ));
1728
1729 ssFIECodeBuf.l_buf = 8;
1730 ssFIECodeBuf.o_buf = 0;
1731 ssFIECodeBuf.buf[0] = OPC_SPLIT_MPTY;
1732
1733 ccShrdPrm.cmpType = CT_INV;
1734 }
1735
1736 /*
1737 +-------------------------------------------------------------------+
1738 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
1739 | ROUTINE : psaCC_asmECT |
1740 +-------------------------------------------------------------------+
1741
1742 PURPOSE : assemble the explicit call transfer SS facility
1743 information element. return invoke id.
1744 */
1745
1746 GLOBAL void psaCC_asmECT ( void )
1747 {
1748 TRACE_FUNCTION("psaCC_asmECT");
1749
1750 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf ));
1751
1752 ssFIECodeBuf.l_buf = 8;
1753 ssFIECodeBuf.o_buf = 0;
1754 ssFIECodeBuf.buf[0] = OPC_EXPLICIT_CT;
1755
1756 ccShrdPrm.cmpType = CT_INV;
1757 }
1758
1759 /*
1760 +-------------------------------------------------------------------+
1761 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
1762 | ROUTINE : psaCC_asmCUGInfo |
1763 +-------------------------------------------------------------------+
1764
1765 PURPOSE : assemble the forward CUG info SS facility
1766 information element.
1767 */
1768
1769 GLOBAL void psaCC_asmCUGInfo ( SHORT cId )
1770 {
1771 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
1772 MCAST( CUGinf, FWD_CUG_INFO_INV );
1773
1774 TRACE_FUNCTION("psaCC_asmCUGInfo");
1775
1776 memset( CUGinf, 0, sizeof( T_FWD_CUG_INFO_INV ));
1777
1778 /* set basic settings */
1779 CUGinf->msg_type = FWD_CUG_INFO_INV;
1780 CUGinf->v_forwardCUGInfoArg = TRUE;
1781
1782 /* set CUG info */
1783 if( ctb->CUGidx NEQ NOT_PRESENT_8BIT )
1784 {
1785 CUGinf->forwardCUGInfoArg.v_cugIndex = TRUE;
1786 CUGinf->forwardCUGInfoArg.cugIndex = ctb->CUGidx;
1787 }
1788 CUGinf->forwardCUGInfoArg.v_suppressPrefCUG = ctb->CUGprf;
1789 CUGinf->forwardCUGInfoArg.v_suppressOA = ctb->OAsup;
1790
1791 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf ));
1792 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3;
1793 ccd_codeMsg (CCDENT_FAC, UPLINK,
1794 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg,
1795 NOT_PRESENT_8BIT);
1796
1797 ccShrdPrm.cmpType = CT_INV;
1798 }
1799
1800
1801 /*
1802 +-------------------------------------------------------------------+
1803 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
1804 | ROUTINE : psaCC_asmCDReq |
1805 +-------------------------------------------------------------------+
1806
1807 PURPOSE : Assemble the Invoke component for CallDeflection.
1808 On calling this function, it is assumed the semaphore
1809 for the shared CCD buffer is already set.
1810
1811 */
1812
1813 GLOBAL void psaCC_asmCDReq ( const CHAR *number,
1814 const T_ACI_TOA *type,
1815 const CHAR *subaddr,
1816 const T_ACI_TOS *satype)
1817 {
1818 MCAST ( invokeCD, CALL_DEFLECTION_INV );
1819 UBYTE ton, tos; /* holds type of number/subaddress */
1820 UBYTE npi, oe; /* holds numbering plan/odd.even indicator */
1821 UBYTE ccdRet;
1822
1823 TRACE_FUNCTION ("psaCC_asmCDReq()");
1824
1825 memset( invokeCD, 0, sizeof( T_CALL_DEFLECTION_INV ));
1826
1827 /* set basic settings */
1828 invokeCD->msg_type = CALL_DEFLECTION_INV;
1829 invokeCD->v_callDeflectionArg = TRUE;
1830
1831 /* Process T_deflectedToNumber (mandatory element) */
1832 if ((type EQ NULL) OR
1833 (type->npi EQ NPI_NotPresent) OR
1834 (type->ton EQ TON_NotPresent))
1835 {
1836 /* Use defaults */
1837 ton = (number[0] EQ '+') ? NOA_INTER_NUM : NOA_UNKNOWN;
1838 npi = NPI_ISDN;
1839 }
1840 else
1841 {
1842 /* Use given values */
1843 ton = type->ton;
1844 npi = type->npi;
1845 }
1846 invokeCD->callDeflectionArg.v_deflectedToNumber = TRUE;
1847 invokeCD->callDeflectionArg.deflectedToNumber.v_noa = TRUE;
1848 invokeCD->callDeflectionArg.deflectedToNumber.noa = ton;
1849 invokeCD->callDeflectionArg.deflectedToNumber.v_npi = TRUE;
1850 invokeCD->callDeflectionArg.deflectedToNumber.npi = npi;
1851 invokeCD->callDeflectionArg.deflectedToNumber.c_bcdDigit =
1852 (UBYTE)utl_dialStr2BCD (number,
1853 invokeCD->callDeflectionArg.deflectedToNumber.bcdDigit,
1854 MAX_PARTY_NUM);
1855
1856 /* Process T_deflectedToSubaddress (optional element) */
1857 if (subaddr NEQ NULL)
1858 {
1859 if ((satype EQ NULL) OR
1860 (satype->tos EQ TOS_NotPresent) OR
1861 (satype->oe EQ OE_NotPresent))
1862 {
1863 /* Use defaults */
1864 tos = TOS_X213;
1865 oe = OEI_EVEN;
1866 }
1867 else
1868 {
1869 /* Use given values */
1870 tos = satype->tos;
1871 oe = satype->oe;
1872 }
1873 invokeCD->callDeflectionArg.v_deflectedToSubaddress = TRUE;
1874 invokeCD->callDeflectionArg.deflectedToSubaddress.v_tos = TRUE;
1875 invokeCD->callDeflectionArg.deflectedToSubaddress.tos = tos;
1876 invokeCD->callDeflectionArg.deflectedToSubaddress.v_oei = TRUE;
1877 invokeCD->callDeflectionArg.deflectedToSubaddress.oei = oe;
1878 invokeCD->callDeflectionArg.deflectedToSubaddress.c_subadr_str =
1879 (UBYTE)utl_dialStr2BCD(subaddr,
1880 invokeCD->callDeflectionArg.deflectedToSubaddress.subadr_str,
1881 MAX_SUBADDR_NUM);
1882 }
1883
1884 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf ));
1885 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3;
1886
1887 ccdRet = ccd_codeMsg (CCDENT_FAC, UPLINK,
1888 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg,
1889 NOT_PRESENT_8BIT);
1890
1891 switch (ccdRet)
1892 {
1893 case ccdOK:
1894 break;
1895 case ccdWarning:
1896 TRACE_EVENT ("ccdWarning");
1897 break;
1898 default:
1899 TRACE_ERROR ("ccdError/other problem");
1900 break;
1901 }
1902
1903 ccShrdPrm.cmpType = CT_INV; /* Component Type = Invoke */
1904 }
1905
1906
1907 /*
1908 +-------------------------------------------------------------------+
1909 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
1910 | ROUTINE : psaCC_asmComponent |
1911 +-------------------------------------------------------------------+
1912
1913 PURPOSE : Build the componenet. The content of the component is
1914 expected in ssFIECodeBuf, the ready built component will
1915 be returned in ssFIECodeBuf.
1916
1917 */
1918
1919 GLOBAL void psaCC_asmComponent ( SHORT cId )
1920 {
1921 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
1922 MCAST (comp, COMPONENT);
1923 UBYTE ccdRet;
1924
1925 TRACE_FUNCTION ("psaCC_asmComponent()");
1926
1927 memset (comp, 0, sizeof (T_COMPONENT));
1928
1929 comp->v_inv_comp = TRUE;
1930 comp->inv_comp.v_inv_id = TRUE;
1931 comp->inv_comp.inv_id = ctb->iId = ccShrdPrm.iIdNxt++;
1932 comp->inv_comp.v_op_code = TRUE;
1933 comp->inv_comp.op_code = ctb->opCode = ssFIECodeBuf.buf[0];
1934 comp->inv_comp.v_params = TRUE;
1935 comp->inv_comp.params.l_params = ssFIECodeBuf.l_buf - 8;
1936 comp->inv_comp.params.o_params = 8;
1937
1938 memcpy (comp->inv_comp.params.b_params,
1939 ssFIECodeBuf.buf + (ssFIECodeBuf.o_buf >> 3),
1940 ssFIECodeBuf.l_buf >> 3);
1941
1942 ccdRet = ccd_codeMsg (CCDENT_FAC,
1943 UPLINK,
1944 (T_MSGBUF *)&ssFIECodeBuf,
1945 _decodedMsg,
1946 COMPONENT);
1947
1948 if (ccdRet NEQ ccdOK)
1949 {
1950 TRACE_EVENT_P1 ("ccdRet=%d NEQ ccdOK", ccdRet);
1951 }
1952 }
1953
1954
1955 /*
1956 +-------------------------------------------------------------------+
1957 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
1958 | ROUTINE : psaCC_asmCCBSReq |
1959 +-------------------------------------------------------------------+
1960
1961 PURPOSE : assemble the access register CC entry SS facility
1962 information element.
1963 */
1964
1965 GLOBAL void psaCC_asmCCBSReq ( SHORT cId )
1966 {
1967 MCAST( CCBSreq, ACC_REGISTER_CC_ENTRY_INV );
1968
1969 TRACE_FUNCTION("psaCC_asmCCBSReq");
1970
1971 memset( CCBSreq, 0, sizeof( T_ACC_REGISTER_CC_ENTRY_INV ));
1972
1973 /* set basic settings */
1974 CCBSreq->msg_type = ACC_REGISTER_CC_ENTRY_INV;
1975 CCBSreq->v_accRegisterCCEntryArg = TRUE;
1976 CCBSreq->accRegisterCCEntryArg.l_accRegisterCCEntryArg = 0;
1977
1978 memset( &ssFIECodeBuf, 0, sizeof( ssFIECodeBuf ));
1979 ssFIECodeBuf.l_buf = MAX_FIE_CODE_BUF_LEN<<3;
1980 ccd_codeMsg (CCDENT_FAC, UPLINK,
1981 (T_MSGBUF *)&ssFIECodeBuf, _decodedMsg,
1982 NOT_PRESENT_8BIT);
1983
1984 ccShrdPrm.cmpType = CT_INV;
1985 }
1986
1987 /*
1988 +-------------------------------------------------------------------+
1989 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
1990 | ROUTINE : psaCC_dasmInvokeCmp |
1991 +-------------------------------------------------------------------+
1992
1993 PURPOSE : disassemble the result component.
1994 */
1995
1996 GLOBAL void psaCC_dasmInvokeCmp ( SHORT cId, T_inv_comp *invCmp )
1997 {
1998 USHORT ivId; /* holds invoke Id */
1999 UBYTE opCode; /* holds operation code */
2000
2001 TRACE_FUNCTION("psaCC_dasmInvokeCmp");
2002
2003 if( invCmp -> v_inv_id )
2004 ivId = invCmp -> inv_id;
2005 else
2006 ivId = NOT_PRESENT_16BIT;
2007
2008 if( invCmp -> v_op_code )
2009 opCode = invCmp -> op_code;
2010 else
2011 opCode = NOT_PRESENT_8BIT;
2012
2013 if( invCmp -> params.l_params )
2014 {
2015 UBYTE ccdRet;
2016
2017 memcpy( &ssFIECodeBuf, &invCmp -> params, sizeof(ssFIECodeBuf));
2018
2019 ccdRet = ccd_decodeMsg (CCDENT_FAC,
2020 DOWNLINK,
2021 (T_MSGBUF *) &ssFIECodeBuf,
2022 (UBYTE *) _decodedMsg,
2023 opCode);
2024
2025 if( ccdRet NEQ ccdOK )
2026 {
2027 TRACE_EVENT_P1( "CCD Decoding Error: %d",ccdRet );
2028 psaCC_ctb(cId)->failType = SSF_CCD_DEC;
2029 cmhCC_SSTransFail(cId);
2030 }
2031 }
2032
2033 /* determine to which operation the invoke belongs to */
2034 switch( opCode )
2035 {
2036 /*
2037 * Advice of Charge Information received
2038 */
2039 case OPC_FWD_CHARGE_ADVICE:
2040 {
2041 MCAST( aoc_para, FWD_CHG_ADVICE_INV);
2042
2043 aoc_parameter (cId, aoc_para);
2044
2045 if (aoc_info (cId, AOC_START_AOC))
2046 {
2047 /*
2048 * build return result to infrastructure
2049 * directly without using CCD (it´s too simple)
2050 */
2051 PALLOC (facility_req, MNCC_FACILITY_REQ);
2052
2053 facility_req->fac_inf.l_fac = 5*8;
2054 facility_req->fac_inf.o_fac = 0;
2055 facility_req->fac_inf.fac [0] = 0xA2; /* component type tag */
2056 facility_req->fac_inf.fac [1] = 3; /* component type length */
2057 facility_req->fac_inf.fac [2] = 2; /* invoke id tag */
2058 facility_req->fac_inf.fac [3] = 1; /* invoke id length */
2059 facility_req->fac_inf.fac [4] = (UBYTE)ivId; /* invoke id */
2060
2061 facility_req->ti = psaCC_ctb(cId)->ti;
2062 facility_req->ss_version = NOT_PRESENT_8BIT;
2063
2064 PSENDX (CC, facility_req);
2065 }
2066 }
2067 break;
2068
2069 case( OPC_NOTIFY_SS ):
2070 {
2071 MCAST( ntfySS, NOTIFY_SS_INV );
2072
2073 cmhCC_NotifySS( cId, ntfySS );
2074 }
2075 break;
2076
2077 case( OPC_FWD_CHECK_SS_IND ):
2078 {
2079 cmhCC_CheckSS( cId);
2080 }
2081 break;
2082 }
2083 }
2084
2085 /*
2086 +-------------------------------------------------------------------+
2087 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
2088 | ROUTINE : psaCC_dasmResultCmp |
2089 +-------------------------------------------------------------------+
2090
2091 PURPOSE : disassemble the result component.
2092 */
2093
2094 GLOBAL void psaCC_dasmResultCmp ( SHORT cId, T_res_comp *resCmp )
2095 {
2096 UBYTE opCode; /* holds operation code */
2097
2098 TRACE_FUNCTION("psaCC_dasmResultCmp");
2099
2100 /* get operation code of the result */
2101 if( resCmp -> v_sequence AND resCmp -> sequence.v_op_code )
2102 opCode = resCmp -> sequence.op_code;
2103 else
2104 opCode = psaCC_ctb(cId)->opCode;
2105
2106 /* decode additional parameters of result */
2107 if( resCmp -> v_sequence AND resCmp -> sequence.params.l_params )
2108 {
2109 UBYTE ccdRet;
2110
2111 memcpy( &ssFIECodeBuf, &resCmp -> sequence.params, sizeof(ssFIECodeBuf));
2112
2113 ccdRet = ccd_decodeMsg (CCDENT_FAC,
2114 DOWNLINK,
2115 (T_MSGBUF *) &ssFIECodeBuf,
2116 (UBYTE *) _decodedMsg,
2117 opCode);
2118
2119 if( ccdRet NEQ ccdOK )
2120 {
2121 TRACE_EVENT_P1( "CCD Decoding Error: %d",ccdRet );
2122 return;
2123 }
2124 }
2125
2126 /* determine to which operation the result belongs to */
2127 switch( opCode )
2128 {
2129 case( OPC_BUILD_MPTY ):
2130 {
2131 MCAST( bldMPTY, BUILD_MPTY_RES );
2132
2133 cmhCC_MPTYBuild( cId, bldMPTY );
2134 }
2135 break;
2136
2137 case( OPC_EXPLICIT_CT ):
2138 {
2139 TIMERSTOP( ACI_TECT );
2140 }
2141 break;
2142
2143 case( OPC_SPLIT_MPTY ):
2144 {
2145 MCAST( splMPTY, SPLIT_MPTY_RES );
2146
2147 cmhCC_MPTYSplit( cId, splMPTY );
2148 }
2149 break;
2150
2151 case( OPC_HOLD_MPTY ):
2152 {
2153 MCAST( hldMPTY, HOLD_MPTY_RES );
2154
2155 cmhCC_MPTYHeld( cId, hldMPTY );
2156 }
2157 break;
2158
2159 case( OPC_RETRIEVE_MPTY ):
2160 {
2161 MCAST( rtvMPTY, RETRIEVE_MPTY_RES );
2162
2163 cmhCC_MPTYRetrieved( cId, rtvMPTY );
2164 }
2165 break;
2166
2167 case( OPC_ACC_REGISTER_CC_ENTRY ):
2168 {
2169 MCAST( ccbs, ACC_REGISTER_CC_ENTRY_RES );
2170
2171 cmhCC_CCBSRegistered( cId, ccbs );
2172 }
2173 break;
2174
2175 case( OPC_CALL_DEFLECTION ):
2176 {
2177 cmhCC_CDRegistered ( cId );
2178 }
2179 break;
2180
2181 }
2182 }
2183
2184 /*
2185 +-------------------------------------------------------------------+
2186 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
2187 | ROUTINE : psaCC_dasmErrorCmp |
2188 +-------------------------------------------------------------------+
2189
2190 PURPOSE : disassemble the error component.
2191 */
2192
2193 GLOBAL void psaCC_dasmErrorCmp ( SHORT cId, T_err_comp *errCmp )
2194 {
2195 TRACE_FUNCTION("psaCC_dasmErrorCmp");
2196
2197 if( errCmp -> v_err_code )
2198 {
2199 psaCC_ctb(cId)->failType = SSF_ERR_PRB;
2200 psaCC_ctb(cId)->errCd = errCmp -> err_code;
2201 }
2202
2203 cmhCC_SSTransFail (cId);
2204 }
2205
2206 /*
2207 +-------------------------------------------------------------------+
2208 | PROJECT : GSM-PS (6147) MODULE : PSA_SSF |
2209 | ROUTINE : psaCC_dasmRejectCmp |
2210 +-------------------------------------------------------------------+
2211
2212 PURPOSE : disassemble the error component.
2213 */
2214
2215 GLOBAL void psaCC_dasmRejectCmp ( SHORT cId, T_rej_comp *rejCmp )
2216 {
2217 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
2218
2219 TRACE_FUNCTION("psaCC_dasmRejectCmp");
2220
2221 if( rejCmp -> v_gen_problem )
2222 {
2223 ctb->failType = SSF_GEN_PRB;
2224 ctb->rejPrb = rejCmp -> gen_problem;
2225 }
2226
2227 else if( rejCmp -> v_inv_problem )
2228 {
2229 ctb->failType = SSF_INV_PRB;
2230 ctb->rejPrb = rejCmp -> inv_problem;
2231 }
2232
2233 else if( rejCmp -> v_res_problem )
2234 {
2235 ctb->failType = SSF_RSL_PRB;
2236 ctb->rejPrb = rejCmp -> res_problem;
2237 }
2238
2239 else if( rejCmp -> v_err_problem )
2240 {
2241 ctb->failType = SSF_ERR_PRB;
2242 ctb->rejPrb = rejCmp -> err_problem;
2243 }
2244
2245 cmhCC_SSTransFail(cId);
2246 }
2247
2248 /*
2249 +-------------------------------------------------------------------+
2250 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
2251 | ROUTINE : psaCC_DTMFSent |
2252 +-------------------------------------------------------------------+
2253
2254 PURPOSE : previous DTMF digit was sent
2255
2256 */
2257 GLOBAL void psaCC_DTMFSent ( SHORT cId )
2258 {
2259 TRACE_FUNCTION( "psaCC_DTMFSent()" );
2260
2261
2262 /*-------------------------------------------------------------------
2263 * check current command
2264 *-------------------------------------------------------------------
2265 */
2266 if (!psaCC_ctbIsValid (cId))
2267 return;
2268
2269
2270 #ifdef SIM_TOOLKIT
2271 if ( psaCC_ctb(cId)->dtmfSrc EQ OWN_SRC_SAT ) /* confirm to SAT send DTMF cmd */
2272 {
2273 cmhCC_SatDTMFsent ( cId );
2274 return;
2275 }
2276 else
2277 #endif /* SIM_TOOLKIT */
2278 {
2279 cmhCC_DTMFsent ( cId );
2280 }
2281 }
2282
2283 /*
2284 +-------------------------------------------------------------------+
2285 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
2286 | ROUTINE : psaCC_StopDTMF |
2287 +-------------------------------------------------------------------+
2288
2289 PURPOSE : stop further DTMF generation for that call
2290
2291 */
2292
2293 GLOBAL void psaCC_StopDTMF ( SHORT cId )
2294 {
2295 #ifdef SIM_TOOLKIT
2296 T_ACI_SAT_TERM_RESP resp_data;
2297 #endif /* SIM_TOOLKIT */
2298
2299 TRACE_FUNCTION( "psaCC_StopDTMF()" );
2300
2301 if( cId EQ ccShrdPrm.dtmf.cId )
2302 {
2303 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
2304
2305 TIMERSTOP( ACI_TDTMF);
2306
2307 #ifdef SIM_TOOLKIT
2308 psaSAT_InitTrmResp( &resp_data );
2309
2310 /* if other dtmf were to be sent in send DTMF SAT cmd*/
2311 if ( ctb->dtmfSrc EQ OWN_SRC_SAT AND
2312 ccShrdPrm.dtmf.cnt NEQ 0 )
2313 {
2314 resp_data.add_content = ADD_ME_NO_SPCH_CALL; /* tell SIM that it failed */
2315 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
2316 }
2317 else /*Stop DTMF generation before calling cmhCC_DTMFstopped */
2318 #endif /* SIM_TOOLKIT */
2319 {
2320 cmhCC_DTMFstopped ( cId );
2321 }
2322 ctb->dtmfSrc = OWN_SRC_INV;
2323 ctb->dtmfCmd = AT_CMD_NONE;
2324 ccShrdPrm.dtmf.cId = NO_ENTRY;
2325 ccShrdPrm.dtmf.cnt = 0;
2326 ccShrdPrm.dtmf.cur = 0;
2327 }
2328 }
2329
2330 /*
2331 +-------------------------------------------------------------------+
2332 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
2333 | ROUTINE : psaCC_DTMFTimeout |
2334 +-------------------------------------------------------------------+
2335
2336 PURPOSE : handle DTMF timeout
2337
2338 */
2339
2340 GLOBAL void psaCC_DTMFTimeout ( void )
2341 {
2342 TRACE_FUNCTION( "psaCC_DTMFTimeout()" );
2343
2344 psaCC_DTMFSent( ccShrdPrm.dtmf.cId );
2345 }
2346
2347 /*
2348 +-------------------------------------------------------------------+
2349 | PROJECT : GSM-PS (6147) MODULE : PSA_CC |
2350 | ROUTINE : psaCC_InitCtbNtry |
2351 +-------------------------------------------------------------------+
2352
2353 PURPOSE : allocate and initialize the indexed call table entry.
2354
2355 */
2356
2357 GLOBAL void psaCC_InitCtbNtry ( SHORT idx )
2358 {
2359 T_CC_CALL_TBL *ctb;
2360
2361 /*
2362 *-------------------------------------------------------------------
2363 * initialize call table entry
2364 *-------------------------------------------------------------------
2365 */
2366 TRACE_FUNCTION ("psaCC_InitCtbNtry()");
2367
2368 if (ccShrdPrm.ctb[idx] NEQ NULL)
2369 {
2370 TRACE_EVENT ("Suspicious: ccShrdPrm.ctb[idx] was not freed");
2371 ACI_MFREE (ccShrdPrm.ctb[idx]); /* Make sure we get no leak */
2372 }
2373 ACI_MALLOC (ccShrdPrm.ctb[idx], sizeof (T_CC_CALL_TBL));
2374
2375 ctb = ccShrdPrm.ctb[idx];
2376
2377 ctb->ti = 0xFF;
2378 ctb->calStat = NO_VLD_CS;
2379 ctb->calType = NO_VLD_CT;
2380 ctb->alrtStat = AS_IDL;
2381 ctb->inBndTns = FALSE;
2382 ctb->prgDesc = MNCC_PROG_NOT_PRES;
2383 ctb->BC[0].rate = DEF_BC1_UR;
2384 ctb->BC[0].bearer_serv = DEF_BC1_BS;
2385 ctb->BC[0].conn_elem = DEF_BC1_CE;
2386 ctb->BC[0].stop_bits = DEF_BC1_SB;
2387 ctb->BC[0].data_bits = DEF_BC1_DB;
2388 ctb->BC[0].parity = DEF_BC1_PR;
2389 ctb->BC[0].flow_control = DEF_BC1_FC;
2390 ctb->BC[0].modem_type = DEF_BC1_MT;
2391 ctb->BC[0].transfer_cap = DEF_BC1_TC;
2392 ctb->BC[0].rate_adaption= DEF_BC1_RA;
2393 ctb->BC[1].rate = DEF_BC2_UR;
2394 ctb->BC[1].bearer_serv = DEF_BC2_BS;
2395 ctb->BC[1].conn_elem = DEF_BC2_CE;
2396 ctb->BC[1].stop_bits = DEF_BC2_SB;
2397 ctb->BC[1].data_bits = DEF_BC2_DB;
2398 ctb->BC[1].parity = DEF_BC2_PR;
2399 ctb->BC[1].flow_control = DEF_BC2_FC;
2400 ctb->BC[1].modem_type = DEF_BC2_MT;
2401 ctb->curBC = 0;
2402 ctb->rptInd = DEF_RPT_IND;
2403 ctb->sigInf = MNCC_SIG_NOT_PRES;
2404 ctb->prio = 0xFF;
2405 ctb->CLIRsup = DEF_CLIR_SUP;
2406 ctb->mptyStat = CS_IDL;
2407 ctb->iId = 0;
2408 ctb->srvStat = SSS_IDL;
2409 ctb->srvType = NO_VLD_ST;
2410 ctb->SSver = DEF_SS_VER;
2411 ctb->CUGidx = NOT_PRESENT_8BIT;
2412 ctb->CUGprf = FALSE;
2413 ctb->OAsup = FALSE;
2414 ctb->opCode = NOT_PRESENT_8BIT;
2415 ctb->rslt = CAUSE_MAKE (DEFBY_CONDAT,
2416 ORIGSIDE_MS,
2417 MNCC_CC_ORIGINATING_ENTITY,
2418 NOT_PRESENT_8BIT);
2419 ctb->nrmCs = CAUSE_MAKE (DEFBY_CONDAT,
2420 ORIGSIDE_MS,
2421 MNCC_CC_ORIGINATING_ENTITY,
2422 NOT_PRESENT_8BIT);
2423 ctb->rejCs = CAUSE_MAKE (DEFBY_CONDAT,
2424 ORIGSIDE_MS,
2425 MNCC_CC_ORIGINATING_ENTITY,
2426 NOT_PRESENT_8BIT);
2427 ctb->failType = NO_VLD_SSF;
2428 ctb->rejPrb = NOT_PRESENT_8BIT;
2429 ctb->errCd = NOT_PRESENT_8BIT;
2430 ctb->ssDiag = MNCC_SS_DIAG_NOT_PROVIDED;
2431 ctb->SATinv = FALSE;
2432 ctb->CCBSstat = NO_VLD_CCBSS;
2433 ctb->CDStat = NO_VLD_CD;
2434 ctb->curCmd = AT_CMD_NONE;
2435 ctb->curSrc = CMD_SRC_NONE;
2436 ctb->dtmfCmd = AT_CMD_NONE;
2437 ctb->dtmfSrc = (T_OWN)CMD_SRC_NONE;
2438 ctb->calOwn = (T_OWN)CMD_SRC_NONE;
2439 ctb->alphIdUni.cs = CS_NotPresent;
2440 ctb->alphIdUni.len = 0;
2441
2442 memset (&ctb->cldPty, 0, sizeof(T_dyn_called_party));
2443 memset (&ctb->cldPtySub, 0, sizeof(T_MNCC_called_party_sub));
2444 memset (&ctb->clgPty, 0, sizeof(T_MNCC_calling_party));
2445 memset (&ctb->clgPtySub, 0, sizeof(T_MNCC_calling_party_sub));
2446 memset (&ctb->rdrPty, 0, sizeof(T_dyn_redir_party));
2447 memset (&ctb->rdrPtySub, 0, sizeof(T_dyn_redir_party_sub));
2448 ctb->rdlCnt = 0;
2449 ctb->rdlTimIndex = RDL_TIM_INDEX_NOT_PRESENT;
2450 ctb->curCs = MNCC_CAUSE_NO_MS_CAUSE;
2451 ccShrdPrm.ccCs[idx] = CAUSE_MAKE (DEFBY_STD,
2452 ORIGSIDE_MS,
2453 MNCC_ACI_ORIGINATING_ENTITY,
2454 NOT_PRESENT_8BIT);
2455 ccShrdPrm.callType[idx] = (S8)NO_VLD_CC_CALL_TYPE;
2456 ctb->numRawCauseBytes = 0;
2457 ctb->rawCauseBytes = NULL;
2458 #ifdef SIM_TOOLKIT
2459 /*
2460 *-----------------------------------------------------------------
2461 * SAT settings
2462 *-----------------------------------------------------------------
2463 */
2464 ctb->SatDiscEvent = FALSE;
2465 #endif
2466 }
2467
2468 /*
2469 +-------------------------------------------------------------------+
2470 | PROJECT : GSM-PS (6147) MODULE : PSA_CC |
2471 | ROUTINE : psaCC_FreeRdrPty |
2472 +-------------------------------------------------------------------+
2473
2474 PURPOSE : free (re-initialize) the redirecting party number and
2475 the redirecting party subaddress of the indexed call
2476 table entry.
2477
2478 */
2479
2480 GLOBAL void psaCC_FreeRdrPty ( SHORT idx )
2481 {
2482 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[idx];
2483
2484 TRACE_FUNCTION ("psaCC_FreeRdrPty()");
2485
2486 if (ctb->rdrPty.redir_num NEQ NULL)
2487 {
2488 ACI_MFREE (ctb->rdrPty.redir_num);
2489 memset (&ctb->rdrPty, 0, sizeof(T_dyn_redir_party));
2490 }
2491 if (ctb->rdrPtySub.subaddr NEQ NULL)
2492 {
2493 ACI_MFREE (ctb->rdrPtySub.subaddr);
2494 memset (&ctb->rdrPtySub, 0, sizeof(T_dyn_redir_party_sub));
2495 }
2496 }
2497
2498
2499 /*
2500 +-------------------------------------------------------------------+
2501 | PROJECT : GSM-PS (6147) MODULE : PSA_CC |
2502 | ROUTINE : psaCC_FreeCtbNtry |
2503 +-------------------------------------------------------------------+
2504
2505 PURPOSE : free (re-initialize) the indexed call table entry.
2506
2507 */
2508
2509 GLOBAL void psaCC_FreeCtbNtry ( SHORT idx )
2510 {
2511 T_CC_CALL_TBL *ctb;
2512 USHORT listcounter;
2513 T_ACI_LIST *msg2send;
2514
2515 TRACE_FUNCTION ("psaCC_FreeCtbNtry()");
2516
2517 if (!psaCC_ctbIsValid (idx))
2518 {
2519 TRACE_ERROR ("Try to clear an invalid entry!");
2520 return;
2521 }
2522
2523 /*
2524 * Probably it is important to use this pointer variable here!
2525 */
2526 ctb = ccShrdPrm.ctb[idx];
2527
2528 /*
2529 * Save the last cause, if any, for later query with qAT_PlusCEER()
2530 */
2531 if (GET_CAUSE_VALUE(ctb->rejCs) NEQ NOT_PRESENT_8BIT)
2532 {
2533 ccShrdPrm.ccCs[idx] = ctb->rejCs;
2534 }
2535 else if (GET_CAUSE_VALUE(ctb->nrmCs) NEQ NOT_PRESENT_8BIT)
2536 {
2537 ccShrdPrm.ccCs[idx] = ctb->nrmCs;
2538 }
2539 else if (GET_CAUSE_VALUE(ctb->rslt) NEQ NOT_PRESENT_8BIT)
2540 {
2541 ccShrdPrm.ccCs[idx] = ctb->rslt;
2542 }
2543 else
2544 {
2545 /* in case network has sent no extended report */
2546 ccShrdPrm.ccCs[idx] = CAUSE_MAKE (DEFBY_STD,
2547 ORIGSIDE_MS,
2548 MNCC_ACI_ORIGINATING_ENTITY,
2549 NOT_PRESENT_8BIT);
2550 }
2551
2552 /*
2553 * Save the call type. Fax/Data needs this information.
2554 */
2555 ccShrdPrm.callType[idx] = (T_CC_CALL_TYPE)cmhCC_getcalltype(idx);
2556
2557 /* Deleting linked list of Facility primitives */
2558 if ((listcounter = get_list_count(ccShrdPrm.facility_list)) > 0)
2559 {
2560 for (;listcounter > 0 ; listcounter --)
2561 {
2562 msg2send = get_next_element( ccShrdPrm.facility_list, NULL);
2563 remove_first_element(ccShrdPrm.facility_list);
2564 PFREE(msg2send);
2565 }
2566 }
2567 ccShrdPrm.facility_list= NULL;
2568 ccShrdPrm.aocRsmpPend = 0;
2569
2570 if (ctb->cldPty.called_num NEQ NULL)
2571 {
2572 ACI_MFREE (ctb->cldPty.called_num);
2573 ctb->cldPty.called_num = NULL;
2574 }
2575
2576 psaCC_FreeRdrPty (idx);
2577
2578 ACI_MFREE (ccShrdPrm.ctb[idx]);
2579 ccShrdPrm.ctb[idx] = NULL;
2580 }
2581
2582 /*
2583 +-------------------------------------------------------------------+
2584 | PROJECT : GSM-PS (6147) MODULE : CMH |
2585 | ROUTINE : psaCC_ctbIsValid |
2586 +-------------------------------------------------------------------+
2587
2588 PURPOSE : This function returns whether a given call table entry
2589 is valid (means non-NULL).
2590 Caution with TRACE_EVENTs etc., it could be used in
2591 a signal handler.
2592
2593 */
2594
2595 GLOBAL BOOL psaCC_ctbIsValid (SHORT cId)
2596 {
2597 return ((cId >= 0) AND
2598 (cId < MAX_CALL_NR) AND
2599 (ccShrdPrm.ctb[cId] NEQ NULL));
2600 }
2601
2602
2603 /*
2604 +-------------------------------------------------------------------+
2605 | PROJECT : GSM-PS (6147) MODULE : CMH |
2606 | ROUTINE : psaCC_ctb |
2607 +-------------------------------------------------------------------+
2608
2609 PURPOSE : This function returns a pointer to the call table
2610 described by the cId. It is assumed that cId is valid,
2611 no return of NULL pointer expected here.
2612 What's the sense of this function? There were problems
2613 encountered with the target compiler having a too
2614 complicated pointer expression.
2615
2616 */
2617
2618 GLOBAL T_CC_CALL_TBL * psaCC_ctb (SHORT cId)
2619 {
2620 return (ccShrdPrm.ctb[cId]);
2621 }
2622
2623
2624 /*
2625 +-------------------------------------------------------------------+
2626 | PROJECT : GSM-PS (6147) MODULE : PSA_CC |
2627 | ROUTINE : psaCC_Init |
2628 +-------------------------------------------------------------------+
2629
2630 PURPOSE : initialize the protocol stack adapter for CC.
2631
2632 */
2633
2634 /* initialize CC parametrs for MTC bearer capabilities */
2635 GLOBAL void psaCC_init_mtcbearer ( void )
2636 {
2637 /* wasn't really used apparently
2638 ccShrdPrm.mtcBC.rate = DEF_BC1_UR;
2639 ccShrdPrm.mtcBC.bearer_serv = DEF_BC1_BS;
2640 ccShrdPrm.mtcBC.conn_elem = DEF_BC1_CE;
2641 ccShrdPrm.mtcBC.stop_bits = DEF_BC1_SB;
2642 ccShrdPrm.mtcBC.data_bits = DEF_BC1_DB;
2643 ccShrdPrm.mtcBC.parity = DEF_BC1_PR;
2644 ccShrdPrm.mtcBC.flow_control = DEF_BC1_FC;
2645 ccShrdPrm.mtcBC.modem_type = DEF_BC1_MT;*/
2646
2647 /* initialize CC for MTC calls */
2648 #ifdef FAX_AND_DATA
2649 ccShrdPrm.CBSTspeed = BS_SPEED_9600_V32;
2650 ccShrdPrm.CBSTname = CBST_NAM_Asynch;
2651 ccShrdPrm.CBSTce = CBST_CE_NonTransparent;
2652 #endif /* FAX_AND_DATA */
2653 ccShrdPrm.snsMode = MNCC_SNS_MODE_VOICE;
2654 #ifdef FF_TTY
2655 ccShrdPrm.ctmReq = MNCC_CTM_DISABLED;
2656 ccShrdPrm.ctmState = TTY_STATE_NONE;
2657 ccShrdPrm.ttyCmd = (UBYTE)TTY_OFF;
2658 ccShrdPrm.ctmOvwr = FALSE;
2659 #endif /* FF_TTY */
2660 psaCC_Config( );
2661 }
2662
2663 GLOBAL void psaCC_Init ( void )
2664 {
2665 UBYTE ctbIdx; /* holds index to call table */
2666
2667 /* initialize call table */
2668 for( ctbIdx = 0; ctbIdx < MAX_CALL_NR; ctbIdx++ )
2669 {
2670 ccShrdPrm.ctb[ctbIdx] = NULL;
2671 }
2672
2673 /* initialize shared parameter */
2674 ccShrdPrm.cIdFail = -1;
2675 ccShrdPrm.nrOfMOC = 0;
2676 ccShrdPrm.nrOfMTC = 0;
2677 ccShrdPrm.chMod = NOT_PRESENT_8BIT;
2678 ccShrdPrm.chType = NOT_PRESENT_8BIT;
2679 ccShrdPrm.syncCs = CAUSE_MAKE(DEFBY_CONDAT, ORIGSIDE_MS, MNCC_CC_ORIGINATING_ENTITY, NOT_PRESENT_8BIT);
2680 ccShrdPrm.TCHasg = FALSE;
2681 ccShrdPrm.datStat = DS_IDL;
2682 ccShrdPrm.CMODmode = CMOD_MOD_Single;
2683 ccShrdPrm.msgType = NO_VLD_MT;
2684 ccShrdPrm.dtmf.cId = NO_ENTRY;
2685 ccShrdPrm.dtmf.cnt = 0;
2686 ccShrdPrm.dtmf.cur = 0;
2687 ccShrdPrm.facility_list = NULL;
2688 ccShrdPrm.cvhu = CVHU_DropDTR_IGNORED;
2689 #if defined (FF_WAP) || defined (FF_SAT_E)
2690 ccShrdPrm.wapStat = CC_WAP_STACK_DOWN;
2691 #endif
2692 cuscfgParams.MO_SM_Control_SIM = CUSCFG_STAT_Disabled;
2693 cuscfgParams.MO_Call_Control_SIM = CUSCFG_STAT_Disabled;
2694 cuscfgParams.MO_SS_Control_SIM = CUSCFG_STAT_Disabled;
2695 cuscfgParams.MO_USSD_Control_SIM = CUSCFG_STAT_Disabled;
2696 cuscfgParams.Two_digit_MO_Call = CUSCFG_STAT_Disabled;
2697 cuscfgParams.Ext_USSD_Response = CUSCFG_STAT_Disabled;
2698 cuscfgParams.USSD_As_MO_Call = CUSCFG_STAT_Disabled;
2699
2700 Ext_USSD_Res_Pending_sId = NOT_PRESENT_8BIT;
2701
2702 psaCC_init_mtcbearer( );
2703 #ifdef TI_PS_FF_AT_CMD_P_ECC
2704 /* Initialize additional ECC numbers */
2705 cmhCC_additional_ecc_numbers_initialize();
2706 #endif /* TI_PS_FF_AT_CMD_P_ECC */
2707 }
2708
2709 /*
2710 +-------------------------------------------------------------------------+
2711 | PROJECT : GSM-PS (6147) MODULE : PSA_CCP |
2712 | ROUTINE : psaCC_ProcessCmp |
2713 +-------------------------------------------------------------------------+
2714
2715 PURPOSE : processes the each component sent by the function
2716 psa_mncc_facility_ind().
2717
2718 */
2719
2720
2721 GLOBAL void psaCC_ProcessCmp ( T_MNCC_FACILITY_IND *mncc_facility_ind )
2722 {
2723 SHORT cId; /* holds call id */
2724 BOOL facility_stored = FALSE;
2725
2726 TRACE_FUNCTION ("psaCC_ProcessCmp()");
2727
2728 /*
2729 *-------------------------------------------------------------------
2730 * find call in call table
2731 *-------------------------------------------------------------------
2732 */
2733 cId = psaCC_ctbFindTi( mncc_facility_ind -> ti );
2734
2735 if( cId < 0 )
2736 {
2737 /*
2738 * ignore primitive, due to not found transaction identifier.
2739 */
2740 TRACE_EVENT ("primitive rejected due to unused ti");
2741 PFREE(mncc_facility_ind);
2742 return;
2743 }
2744
2745 psaCC_DumpFIE (&mncc_facility_ind -> fac_inf );
2746 cmhCC_sendFie( CSCN_FACILITY_DIRECTION_IN,
2747 cId,
2748 &mncc_facility_ind -> fac_inf );
2749
2750 /* decode component type */
2751 CCD_START;
2752 {
2753 UBYTE ccdRet;
2754
2755 MCAST( com, COMPONENT );
2756 memset( com, 0, sizeof( T_COMPONENT ));
2757
2758 ccdRet = ccd_decodeMsg (CCDENT_FAC,
2759 DOWNLINK,
2760 (T_MSGBUF *) &mncc_facility_ind -> fac_inf,
2761 (UBYTE *) _decodedMsg,
2762 COMPONENT);
2763
2764 if( ccdRet NEQ ccdOK )
2765 {
2766 TRACE_EVENT_P1("CCD Decoding Error: %d",ccdRet );
2767 psaCC_ctb(cId)->failType = SSF_CCD_DEC;
2768 cmhCC_SSTransFail(cId);
2769 }
2770 else
2771 {
2772 /* Buffer MNCC_FACILITY_IND primitive
2773 if the Call direction is MTC
2774 and no TCHasg Flag
2775 and RING is not sent yet
2776 and no signal information
2777
2778 */
2779 if (psaCC_ctb(cId)->calType EQ CT_MTC AND !ccShrdPrm.TCHasg AND
2780 psaCC_ctb(cId)->calStat EQ CS_ACT_REQ AND psaCC_ctb(cId)->sigInf EQ MNCC_SIG_NOT_PRES)
2781 {
2782 if ( ccShrdPrm.facility_list EQ NULL)
2783 {
2784 ccShrdPrm.facility_list = new_list ();
2785 insert_list(ccShrdPrm.facility_list, mncc_facility_ind);
2786 }
2787 else
2788 {
2789 insert_list(ccShrdPrm.facility_list, mncc_facility_ind);
2790 }
2791 facility_stored = TRUE;
2792 }
2793 else
2794 {
2795 if( com->v_inv_comp )
2796 {
2797 psaCC_dasmInvokeCmp( cId, &com->inv_comp );
2798 }
2799 else if( com->v_res_comp )
2800 {
2801 psaCC_dasmResultCmp( cId, &com->res_comp );
2802 }
2803 else if( com->v_err_comp )
2804 {
2805 #ifdef SIM_TOOLKIT
2806 if( psaCC_ctb(cId)->SATinv )
2807 {
2808 psaCC_ctb(cId)->SATinv = FALSE;
2809 psaSAT_SSErrComp((T_fac_inf *) &mncc_facility_ind -> fac_inf, FALSE );
2810 }
2811 #endif
2812 psaCC_dasmErrorCmp( cId, &com->err_comp );
2813 }
2814 else if( com->v_rej_comp )
2815 {
2816 #ifdef SIM_TOOLKIT
2817 if( psaCC_ctb(cId)->SATinv )
2818 {
2819 psaCC_ctb(cId)->SATinv = FALSE;
2820 psaSAT_SSRejComp( RSLT_NTW_UNAB_PROC );
2821 }
2822 #endif
2823 psaCC_dasmRejectCmp( cId, &com->rej_comp );
2824 }
2825 else
2826 {
2827 TRACE_EVENT( "WRONG COMPONENT TYPE RECEIVED" );
2828 cmhCC_SSTransFail (cId);
2829 }
2830 }
2831 }
2832 }
2833 CCD_END;
2834
2835 /*
2836 *-------------------------------------------------------------------
2837 * free the primitive buffer if not stored
2838 *-------------------------------------------------------------------
2839 */
2840 if (!facility_stored)
2841 {
2842 PFREE (mncc_facility_ind);
2843 }
2844
2845 }
2846
2847 /*
2848 +-------------------------------------------------------------------+
2849 | PROJECT : GSM-PS (6147) MODULE : PSA_CC |
2850 | ROUTINE : psaCC_DumpFIE |
2851 +-------------------------------------------------------------------+
2852
2853 PURPOSE : Dump facility information element to debug output.
2854
2855 */
2856
2857 GLOBAL void psaCC_DumpFIE ( T_MNCC_fac_inf * fie )
2858 {
2859 CHAR strBuf[40+1]; /* holds string buffer */
2860 UBYTE idx, cnt,mcnt; /* buffer index */
2861 CHAR *pDest; /* points to destination */
2862
2863 TRACE_EVENT( "FIE SENT/RECEIVED:" );
2864
2865 mcnt = fie->l_fac >> 3;
2866 /* G23 uses ever offset 0 !!! */
2867
2868 /* format FIE */
2869 for( cnt = 0; cnt < mcnt; cnt+=idx )
2870 {
2871 pDest = strBuf;
2872
2873 for( idx = 0; idx < 20 AND idx+cnt < mcnt; idx++ )
2874 {
2875 /* Implements Measure#32: Row 1245 */
2876 pDest += sprintf( pDest, format_2X_str, (UBYTE)fie->fac[idx+cnt] );
2877 }
2878
2879 *pDest = 0x0;
2880
2881 TRACE_EVENT_P1("%s", strBuf );
2882 }
2883 }
2884
2885 /*
2886 +-------------------------------------------------------------------+
2887 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
2888 | ROUTINE : psaCC_ctbDump |
2889 +-------------------------------------------------------------------+
2890
2891 PURPOSE : this function dumps the call table to the debug output.
2892 */
2893
2894 #ifdef TRACING
2895 // What you are searching for has been removed by Conquest issue
2896 // ACI-ENH-30932 for the Locosto project in the assumption noone
2897 // is using it anymore. If I was wrong get the function back from
2898 // the version control system and let me know.
2899 // HM, 4-May-2005
2900 #endif /* of #ifdef TRACING */
2901
2902 /*
2903 +-------------------------------------------------------------------+
2904 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
2905 | ROUTINE : psaCC_ctbDumpBC |
2906 +-------------------------------------------------------------------+
2907
2908 PURPOSE : this function dumps the BC to the debug output.
2909 */
2910
2911 #ifdef TRACING
2912 // What you are searching for has been removed by Conquest issue
2913 // ACI-ENH-30932 for the Locosto project in the assumption noone
2914 // is using it anymore. If I was wrong get the function back from
2915 // the version control system and let me know.
2916 // HM, 4-May-2005
2917 #endif /* of #ifdef TRACING */
2918
2919 /* Implements Measure# 188 & 189*/
2920 /*
2921 +-------------------------------------------------------------------+
2922 | PROJECT : GSM-PS (6147) MODULE : PSA_CCF |
2923 | ROUTINE : psaCC_ctbClrAdr2Num |
2924 +-------------------------------------------------------------------+
2925
2926 PURPOSE : this function converts the parameters of the calling
2927 address for the passed call id into a dial number. The
2928 string is copied into the passed buffer. In case the
2929 buffer size is not sufficient to hold the called number,
2930 the number is cut to maxSize. The function returns a pointer
2931 to the buffer or NULL if an error occurs.
2932 */
2933
2934 LOCAL CHAR *psaCC_ctbAdr2Num ( CHAR *pNumBuf, UBYTE maxSize, UBYTE *num,
2935 UBYTE c_num, UBYTE ton)
2936 {
2937 TRACE_FUNCTION ("psaCC_ctbAdr2Num()");
2938 /*
2939 *-------------------------------------------------------------------
2940 * convert BCD address
2941 *-------------------------------------------------------------------
2942 */
2943 if (c_num EQ 0)
2944 {
2945 *pNumBuf = '\0'; /* empty string */
2946 return( NULL );
2947 }
2948
2949 maxSize -= 1; /* for trailing '\0' */
2950
2951 /*
2952 * International call add + at the beginning
2953 */
2954 if (ton EQ MNCC_TON_INT_NUMB)
2955 {
2956 *pNumBuf = '+';
2957 utl_BCD2DialStr (num, pNumBuf+1,
2958 (UBYTE)MINIMUM(maxSize-1, c_num));
2959 }
2960 else
2961 {
2962 utl_BCD2DialStr (num, pNumBuf,
2963 (UBYTE)MINIMUM(maxSize, c_num));
2964 }
2965 return( pNumBuf );
2966 }
2967
2968 /*==== EOF ========================================================*/
2969