comparison src/aci2/aci/cmh_satr.c @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_SATR
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 which are responsible
18 | for the responses of the protocol stack adapter for
19 | the SIM application toolkit.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifdef SIM_TOOLKIT
24
25 #ifndef CMH_SATR_C
26 #define CMH_SATR_C
27 #endif
28
29 #include "aci_all.h"
30 /*==== INCLUDES ===================================================*/
31 #include "aci_cmh.h"
32 #include "aci_mem.h"
33
34 #ifdef FAX_AND_DATA
35 #include "aci_fd.h"
36 #endif /* of #ifdef FAX_AND_DATA */
37
38 #include "aci.h"
39 #include "psa.h"
40 #include "psa_cc.h"
41 #include "psa_ss.h"
42 #include "psa_sat.h"
43 #include "psa_sim.h" /* for simShrdPrm declaration */
44 #include "psa_sms.h"
45 #include "psa_util.h"
46 #include "cmh.h"
47 #include "cmh_cc.h"
48 #include "cmh_sat.h"
49 #include "cmh_sms.h"
50 #include "aoc.h"
51
52 #include "phb.h"
53 #include "cmh_phb.h"
54 #include "l4_tim.h"
55 /*==== CONSTANTS ==================================================*/
56
57
58 /*==== TYPES ======================================================*/
59
60
61 /*==== EXPORT =====================================================*/
62
63
64 /*==== VARIABLES ==================================================*/
65
66
67 /*==== FUNCTIONS ==================================================*/
68
69 /*
70 +--------------------------------------------------------------------+
71 | PROJECT : MODULE : CMH_SATR |
72 | STATE : code ROUTINE : cmhSAT_ModifyScaPdu |
73 +--------------------------------------------------------------------+
74
75 PURPOSE : modifies the SCA in a SUBMIT PDU
76
77 */
78 LOCAL void cmhSAT_ModifyScaPdu( T_sms_sdu *sms_sdu,
79 UBYTE *sca_buf,
80 UBYTE sca_len )
81 {
82 UBYTE old_sca_len;
83 UBYTE *rest;
84 USHORT rest_len;
85 UBYTE *old_sdu;
86 UBYTE old_sdu_len;
87
88 ACI_MALLOC(old_sdu, SIM_PDU_LEN);
89 old_sdu_len = sms_sdu->l_buf/8;
90 memcpy ( old_sdu, sms_sdu->buf, old_sdu_len );
91
92 old_sca_len = *old_sdu+1;
93 rest = old_sdu + old_sca_len;
94 rest_len = old_sdu_len - old_sca_len;
95
96 /* copy new SCA */
97 memcpy(sms_sdu->buf, sca_buf, sca_len);
98
99 /* copy the rest of the PDU */
100 memcpy(sms_sdu->buf+sca_len, rest, rest_len);
101
102 /* set the length */
103 sms_sdu->l_buf = (sca_len+rest_len) * 8;
104
105 ACI_MFREE(old_sdu);
106 }
107
108
109 /*
110 +--------------------------------------------------------------------+
111 | PROJECT : MODULE : CMH_SATR |
112 | STATE : code ROUTINE : cmhSAT_ModifyDaPdu |
113 +--------------------------------------------------------------------+
114
115 PURPOSE : modifies the destination address in a SUBMIT PDU
116
117 */
118 LOCAL void cmhSAT_ModifyDaPdu( T_sms_sdu *sms_sdu,
119 UBYTE *da_buf,
120 UBYTE da_len )
121 {
122 UBYTE old_sca_len;
123 UBYTE old_da_len;
124 UBYTE *rest;
125 USHORT rest_len;
126 UBYTE *old_sdu;
127 UBYTE *new_sdu;
128 UBYTE old_sdu_len;
129
130 ACI_MALLOC(old_sdu, SIM_PDU_LEN);
131 old_sdu_len = sms_sdu->l_buf/8;
132 memcpy ( old_sdu, sms_sdu->buf, old_sdu_len );
133
134 new_sdu = sms_sdu->buf;
135
136 old_sca_len = *old_sdu+1;
137 old_da_len = (*(old_sdu + old_sca_len + 2)+1)/2 + 2;
138 rest = old_sdu + old_sca_len + 2 + old_da_len;
139 rest_len = old_sdu_len - old_sca_len - 2 - old_da_len;
140
141 /* copy old sca, fo, mr */
142 memcpy(new_sdu, old_sdu, old_sca_len+2);
143 new_sdu += old_sca_len+2;
144
145 /* copy the new DA */
146 memcpy(new_sdu, da_buf, da_len);
147 new_sdu += da_len;
148
149 /* copy the rest of the PDU */
150 memcpy(new_sdu, rest, rest_len);
151
152 /* set the length */
153 sms_sdu->l_buf = (old_sca_len+2+da_len+rest_len) * 8;
154
155 ACI_MFREE(old_sdu);
156 }
157
158
159 /*
160 +-------------------------------------------------------------------+
161 | PROJECT : GSM-PS (6147) MODULE : CMH_SATR |
162 | ROUTINE : cmhSAT_STKCmdCnf |
163 +-------------------------------------------------------------------+
164
165 PURPOSE : STK command confirmation
166
167 */
168
169 GLOBAL SHORT cmhSAT_STKCmdCnf ( void )
170 {
171
172 TRACE_FUNCTION ("cmhSAT_STKCmdCnf()");
173
174 /*
175 *-------------------------------------------------------------------
176 * check for command context
177 *-------------------------------------------------------------------
178 */
179 switch( satEntStat.curCmd )
180 {
181 case( AT_CMD_SATE ):
182 /*
183 *----------------------------------------------------------------
184 * process event for %SATE command
185 *----------------------------------------------------------------
186 */
187 satEntStat.curCmd = AT_CMD_NONE;
188
189 TRACE_EVENT_P1("SAT reponse with SIM cause: %d", satShrdPrm.stkError);
190
191 switch (satShrdPrm.stkError)
192 {
193 case SIM_NO_ERROR:
194 R_AT( RAT_SATE, satEntStat.entOwn )
195 ( satShrdPrm.stkCmdLen>>3, satShrdPrm.stkCmd );
196
197 R_AT( RAT_OK, satEntStat.entOwn )
198 ( AT_CMD_SATE );
199 break;
200
201 case SIM_CAUSE_SAT_BUSY:
202 R_AT( RAT_CME, satEntStat.entOwn )
203 ( AT_CMD_SATE, CME_ERR_SimSatBusy );
204 break;
205
206 case SIM_CAUSE_PUK1_BLOCKED:
207 R_AT( RAT_CME, satEntStat.entOwn )
208 ( AT_CMD_SATE, CME_ERR_SimFail );
209 break;
210
211 default:
212 R_AT( RAT_CME, satEntStat.entOwn )
213 ( AT_CMD_SATE, CME_ERR_Unknown );
214 break;
215 }
216 break;
217 }
218
219 return 0;
220 }
221
222 /*
223 +-------------------------------------------------------------------+
224 | PROJECT : GSM-PS (6147) MODULE : CMH_SATR |
225 | ROUTINE : cmhSAT_STKCmdInd |
226 +-------------------------------------------------------------------+
227
228 PURPOSE : STK command indication
229
230 */
231
232 GLOBAL SHORT cmhSAT_STKCmdInd ( void )
233 {
234 SHORT idx; /* holds list index */
235
236 TRACE_FUNCTION ("cmhSAT_STKCmdInd()");
237
238 /*
239 *----------------------------------------------------------------
240 * send unsolicited result
241 *----------------------------------------------------------------
242 */
243
244 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
245 {
246 R_AT( RAT_SATI, idx )
247 ( satShrdPrm.stkCmdLen>>3, satShrdPrm.stkCmd );
248 }
249 return 0;
250 }
251
252 /*
253 +-------------------------------------------------------------------+
254 | PROJECT : GSM-PS (6147) MODULE : CMH_SATR |
255 | ROUTINE : cmhSAT_Cust1StkCmdInd |
256 +-------------------------------------------------------------------+
257
258 PURPOSE : Used for Sending the Origianl STK command indication to a Cust1 MMI,
259 when performing Setup Call, Send SS, Send USSD or Send SMS
260 */
261
262 GLOBAL SHORT cmhSAT_Cust1StkCmdInd ( void )
263 {
264 SHORT idx; /* holds list index */
265
266 TRACE_FUNCTION ("cmhSAT_Cust1StkCmdInd()");
267
268 if (satShrdPrm.cust1StkCmd != (void *)0)
269 {
270 /*
271 *----------------------------------------------------------------
272 * send %SATI the MMI with the Stk Cmd
273 *----------------------------------------------------------------
274 */
275
276 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
277 {
278 R_AT( RAT_SATI, idx )
279 ( satShrdPrm.cust1StkCmdLen >>3, satShrdPrm.cust1StkCmd);
280 }
281
282 ACI_MFREE(satShrdPrm.cust1StkCmd);
283
284 satShrdPrm.cust1StkCmd = (void *)0;
285 satShrdPrm.cust1StkCmdLen = 0;
286 }
287
288 return 0;
289 }
290
291 /*
292 +-------------------------------------------------------------------+
293 | PROJECT : GSM-PS (6147) MODULE : CMH_SATR |
294 | ROUTINE : cmhSAT_STKUsrNtfy |
295 +-------------------------------------------------------------------+
296
297 PURPOSE : STK user notification
298
299 */
300
301 GLOBAL SHORT cmhSAT_STKUsrNtfy ( void )
302 {
303 SHORT idx; /* holds list index */
304
305 T_ACI_SATN_CNTRL_TYPE cntrl_type = SATN_CNTRL_BY_SIM_Not_Present;
306
307 TRACE_FUNCTION ("cmhSAT_STKUsrNtfy()");
308
309 /*
310 *----------------------------------------------------------------
311 * determine user notification
312 *----------------------------------------------------------------
313 */
314 switch( satShrdPrm.ntfy )
315 {
316 case( USR_NTF_CC_SIM ):
317
318 if (simShrdPrm.overall_cust_mode EQ CUST_MODE_BEHAVIOUR_1)
319 {
320 switch (satShrdPrm.SIMCCParm.ccAct)
321 {
322 case CC_ACT_CAL:
323 cntrl_type = SATN_CNTRL_BY_SIM_CALL;
324 break ;
325
326 case CC_ACT_SS:
327 cntrl_type = SATN_CNTRL_BY_SIM_SS;
328 break ;
329
330 case CC_ACT_USSD:
331 cntrl_type = SATN_CNTRL_BY_SIM_USSD;
332 break ;
333
334 case SMC_ACT_MO:
335 cntrl_type = SATN_CNTRL_BY_SIM_SMS;
336 break ;
337
338 default:
339 cntrl_type = SATN_CNTRL_BY_SIM_Not_Present;
340 }
341 }
342
343 if(psa_IsVldOwnId(satShrdPrm.owner) AND
344 satShrdPrm.owner NEQ NO_VLD_OWN )
345 {
346 R_AT( RAT_SATN, satShrdPrm.owner )
347 ( satShrdPrm.stkCmdLen>>3, satShrdPrm.stkCmd, cntrl_type );
348 break;
349 }
350 /* otherwise continue, no break */
351 /*lint -fallthrough*/
352 default:
353
354 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
355 {
356 if( idx NEQ satShrdPrm.run_at_id )
357 {
358 /* don't notify SAT itself over run at channel */
359 R_AT( RAT_SATN, idx )
360 ( satShrdPrm.stkCmdLen>>3, satShrdPrm.stkCmd, cntrl_type );
361 }
362 }
363 }
364
365 return 0;
366 }
367
368 LOCAL void send_error_to_user( BOOL ownNotSAT,
369 UBYTE command,
370 UBYTE result,
371 UBYTE additional_result,
372 UBYTE *resId,
373 BOOL satopc )
374 {
375 T_ACI_SAT_TERM_RESP resp_data;
376
377 psaSAT_InitTrmResp( &resp_data );
378
379 if( ownNotSAT )
380 {
381 /* setup initiated by user */
382 R_AT( RAT_CME, satShrdPrm.SIMCCParm.owner )
383 ( command, CME_ERR_NotPresent );
384 /* log result */
385 cmh_logRslt ( satShrdPrm.SIMCCParm.owner, RAT_CME, command,
386 -1, -1, CME_ERR_NotPresent );
387 return;
388 }
389
390 /* setup initiated by SAT */
391 /* send SAT response */
392 resp_data.add_content = additional_result;
393
394 /* if source was open channel command */
395 #ifdef FF_SAT_E
396 if(satopc)
397 {
398 if( satShrdPrm.opchStat EQ OPCH_CCSIM_REQ )
399 {
400 cmhSAT_OpChnFailed( result, &resp_data );
401 return;
402 }
403 }
404 #endif /* FF_SAT_E */
405
406 if( resId NEQ NULL )
407 {
408 resp_data.resCC = resId;
409 }
410 psaSAT_SendTrmResp( result, &resp_data );
411 }
412
413 /* return TRUE if key sequence accepted, FALSE otherwise */
414 LOCAL BOOL sim_control_send_ss( T_CLPTY_PRM *ss_clpty,
415 UBYTE command,
416 BOOL ownNotSAT,
417 UBYTE *resCC )
418 {
419 T_ACI_RETURN retVal; /* holds return value */
420 T_ACI_D_CLIR_OVRD dummy2; /* dummy value */
421 T_ACI_D_TOC dummy1; /* dummy value */
422
423 /* check for busy SS condition */
424 if( psaSS_stbFindActSrv( NO_ENTRY ) NEQ NO_ENTRY )
425 {
426 /* NOTE: shouldn't that be:
427 send_error_to_user( ownNotSAT, RSLT_CC_SIM_PRM, ADD_ME_SS_BUSY, resCC, FALSE);
428 or send_error_to_user( ownNotSAT, RSLT_CC_SIM_PRM, RSLT_ME_CAP, resCC, FALSE);
429 ??*/
430 send_error_to_user( ownNotSAT, command, RSLT_ME_UNAB_PROC, ADD_ME_SS_BUSY, resCC, FALSE);
431 return FALSE;
432 }
433
434 /* send SS control string */
435 retVal = cmhCC_chkKeySeq ( satShrdPrm.SIMCCParm.owner,
436 ss_clpty,
437 &dummy1,
438 &dummy2,
439 CC_SIM_NO );
440 if( retVal NEQ AT_EXCT )
441 {
442 /* string is not SS: terminate with error */
443 send_error_to_user( ownNotSAT, command, RSLT_CC_SIM_PRM, RSLT_ME_CAP, resCC, FALSE);
444 return(FALSE);
445 }
446 else
447 {
448 #ifdef FF_SAT_E
449 if(!ownNotSAT AND satShrdPrm.opchStat EQ OPCH_CCSIM_REQ )
450 {
451 return( FALSE );
452 }
453 #endif /* FF_SAT_E */
454 return(TRUE);
455 }
456 }
457
458 /*
459 +-------------------------------------------------------------------+
460 | PROJECT : GSM-PS (6147) MODULE : CMH_SATR |
461 | ROUTINE : cmhSAT_ResCalCntrlBySIM |
462 +-------------------------------------------------------------------+
463
464 PURPOSE : Handle SIM call control result. Return TRUE if primitive
465 is needed for building a terminal response.
466
467 */
468 LOCAL BOOL cmhSAT_result_sim_cc_ss( SHORT cId,
469 UBYTE *resId,
470 T_ccr_allw *ccr )
471 {
472 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
473 T_ACI_SAT_TERM_RESP resp_data;
474 BOOL ownNotSAT = (satShrdPrm.SIMCCParm.owner NEQ OWN_SAT); /* flags that the owner is not SAT */
475 UBYTE cmdBuf; /* buffer command */
476
477 TRACE_FUNCTION("cmhSAT_result_sim_cc_ss()");
478
479 psaSAT_InitTrmResp( &resp_data );
480
481 #ifdef FF_SAT_E
482 /* check for a pending OPEN CHANNEL command */
483 if (ctb->calStat EQ CS_SAT_CSD_REQ)
484 {
485 /* free ctb entry */
486 psaCC_FreeCtbNtry (cId);
487
488 /* respond with "error, Interaction with CC by SIM, perm problem" */
489 resp_data.add_content = ADD_CC_REQ_CHNG;
490 resp_data.chnStat = TRUE;
491
492 cmhSAT_OpChnFailed( RSLT_CC_SIM_PRM, &resp_data );
493
494 return( FALSE );
495 }
496 #endif /* FF_SAT_E */
497
498 cmdBuf = ctb->curCmd;
499 psaCC_FreeCtbNtry (cId);
500
501 cmhCC_init_cldPty( &satPndSetup.clpty );
502
503 utl_BCD2DialStr( ccr->ss_string.ss_ctrl_string,
504 satPndSetup.clpty.num,
505 (UBYTE)MINIMUM(ccr->ss_string.c_ss_ctrl_string,
506 MAX_DIAL_LEN-1));
507
508 satPndSetup.clpty.ton = ccr->ss_string.noa;
509 satPndSetup.clpty.npi = ccr->ss_string.npi;
510
511 if( sim_control_send_ss( &satPndSetup.clpty, cmdBuf, ownNotSAT, resId ) )
512 return( !ownNotSAT );
513 return( FALSE ); /* primitive not needed anymore */
514 }
515
516 LOCAL void cmhSAT_result_sim_cc_address( SHORT cId, T_ccr_allw *ccr )
517 {
518 TRACE_FUNCTION("cmhSAT_result_sim_cc_address()");
519
520 /* adjust called address */
521 cmhSAT_fillSetupPrm ( cId,
522 &ccr->addr,
523 ((ccr->v_subaddr)?&ccr->subaddr:NULL));
524 #ifdef FF_SAT_E
525 if( psaCC_ctb(cId)->calStat NEQ CS_SAT_CSD_REQ )
526 #endif /* FF_SAT_E */
527 {
528 /* new call table entry set default bearer capabilities */
529 cmhSAT_fillSetupBC ( cId, BEARER_SERV_SPEECH, BEARER_SERV_NOT_PRES );
530 }
531
532 /* adjust bearer capabilities */
533 if( ccr->v_cap_cnf_parms )
534 {
535 /* CCP not supported yet */
536 /*
537 satShrdPrm.ntfy = USR_NTF_SETUP_CAL;
538 satShrdPrm.capParm.cId = cId;
539 satShrdPrm.capParm.cntxt = CTX_SAT_SETUP;
540 satShrdPrm.capParm.CCres = *resId;
541
542 if( psaCC_BCapDecode( BCRI_SAT, ccr->cap_cnf_parms.l_cap_cnf_parms>>3,
543 ccr->cap_cnf_parms.b_cap_cnf_parms ) < 0 )
544 {
545 psaSAT_SendTrmResp( RSLT_ME_CAP, 0, NULL, NULL, NULL );
546 psaCC_FreeCtbNtry (cId);
547 return( FALSE );
548 }
549 else
550 {
551 return( *resId EQ CCR_ALLW_WITH_MDFY );
552 }
553 */
554 }
555 }
556
557 LOCAL BOOL cmhSAT_result_sim_cc_ussd( SHORT cId,
558 UBYTE *resId,
559 T_ccr_allw *ccr )
560 {
561 T_ACI_SAT_TERM_RESP resp_data;
562 BOOL ownNotSAT = (satShrdPrm.SIMCCParm.owner NEQ OWN_SAT); /* flags that the owner is not SAT */
563 UBYTE cmdBuf; /* buffer command */
564 UBYTE len = 0;
565 T_ACI_RETURN retVal;
566 T_ACI_D_TOC dummy1;
567 T_ACI_D_CLIR_OVRD dummy2;
568
569 TRACE_FUNCTION("cmhSAT_result_sim_cc_ussd()");
570
571 psaSAT_InitTrmResp( &resp_data );
572
573 /* check for busy SS condition */
574 if( psaSS_stbFindActSrv( NO_ENTRY ) NEQ NO_ENTRY )
575 {
576 /* respond with "error, ME currently unable to process command" */
577 resp_data.add_content = ADD_ME_SS_BUSY;
578 resp_data.resCC = resId;
579 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
580 return( FALSE );
581 }
582
583 /* call adr to be modified with USSD string*/
584 cmdBuf = psaCC_ctb(cId)->curCmd;
585 psaCC_FreeCtbNtry (cId);
586
587 if( utl_getAlphabetCb( (UBYTE) ccr->ussd_string.dcs) EQ 0 ) /* 7bit alphabet */
588 {
589 len=utl_cvt7To8( ccr->ussd_string.ussd_str,
590 ccr->ussd_string.c_ussd_str,
591 (UBYTE*)&satPndSetup.clpty.num, 0);
592 satPndSetup.clpty.num[len]=0x00;
593 }
594 else
595 {
596 memcpy( satPndSetup.clpty.num, ccr->ussd_string.ussd_str,
597 ccr->ussd_string.c_ussd_str );
598 satPndSetup.clpty.num[ccr->ussd_string.c_ussd_str]=0x00;
599 }
600
601 retVal = cmhCC_chkKeySeq ( satShrdPrm.SIMCCParm.owner,
602 &satPndSetup.clpty,
603 &dummy1, &dummy2,
604 CC_SIM_NO );
605
606 if( retVal EQ AT_EXCT )
607 {
608 return( !ownNotSAT );
609 }
610
611 if( ownNotSAT )
612 {
613 R_AT( RAT_CME, satShrdPrm.SIMCCParm.owner )
614 ( cmdBuf, CME_ERR_NotPresent );
615
616 /* log result */
617 cmh_logRslt ( satShrdPrm.SIMCCParm.owner, RAT_CME, cmdBuf,
618 -1, -1, CME_ERR_NotPresent );
619 }
620 /* setup initiated by SAT */
621 else
622 {
623 /* send SAT response */
624 resp_data.resCC = resId;
625 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
626 }
627
628 return( FALSE ); /* primitive not needed anymore */
629 }
630
631
632 GLOBAL BOOL cmhSAT_ResCalCntrlBySIM( UBYTE* resId, void *ccRes )
633 {
634 UBYTE cmdBuf; /* buffer command */
635 SHORT cId = satShrdPrm.SIMCCParm.cId; /* holds setup call id */
636 SHORT actId; /* holds active call id */
637 T_ccr_allw * ccr; /* points to CC result */
638 BOOL ownNotSAT; /* flags that the owner is not SAT */
639 UBYTE idx; /* holds index */
640 T_ACI_SAT_TERM_RESP resp_data;
641
642 #if defined SMI OR defined MFW
643 T_ACI_CLOG cmdLog; /* holds logging info */
644 CHAR cmdlog_num_buf[MAX_CC_CALLED_NUMBER]; /* buffer where number is written for cmdLog */
645 USHORT length; /* length of number */
646 #endif
647
648 TRACE_FUNCTION("cmhSAT_ResCalCntrlBySIM()");
649
650 psaSAT_InitTrmResp( &resp_data );
651
652 ccr = (T_ccr_allw*)ccRes;
653
654 /* check if queued event download */
655 if (satShrdPrm.event.c_queued)
656 {
657 cmhSAT_EventDwn( -1, -1, -1);
658 }
659
660 satShrdPrm.SIMCCParm.busy = FALSE;
661
662 if (!psaCC_ctbIsValid (cId))
663 {
664 TRACE_ERROR ("Call table entry disappeared");
665 return FALSE;
666 }
667
668 ownNotSAT = satShrdPrm.SIMCCParm.owner NEQ OWN_SAT;
669
670 /*
671 ** If this is a Cust1 MMI and The originator was a STK Cmd
672 */
673 if ((simShrdPrm.overall_cust_mode EQ (UBYTE)CUST_MODE_BEHAVIOUR_1) AND
674 (ownNotSAT == FALSE))
675 {
676 /*
677 ** Customised behaviour for the Cust1 MMI
678 */
679 if (*resId == CCR_NOT_ALLW)
680 {
681 /* Call Setup not allowed */
682 send_error_to_user( ownNotSAT, psaCC_ctb(cId)->curCmd,
683 RSLT_CC_SIM_PRM, ADD_CC_NOT_ALLWD,
684 NULL, TRUE);
685 }
686 else
687 {
688 /*
689 ** This was a SAT initiated call. For the Cust1 the ACI does not yet have any
690 ** actions to perform, other than the CC By SIM which has been done. So :
691 ** Send the Original STK Cmd to the MMI in a %SATI for the MMI to process.
692 **
693 ** The second action will cause the MMI to request the approriate Call Setup, SS
694 ** or USSD Request and the required Call Table entry will then be re-created.
695 */
696 cmhSAT_Cust1StkCmdInd();
697 }
698
699 /* Free the Call Table Entry
700 ** The SATI indication (if sent) will cause the MMI to request the approriate Call Setup, SS
701 ** or USSD Request and the required Call Table entry will then be re-created.
702 */
703 psaCC_FreeCtbNtry (cId);
704
705 return( FALSE ); /* primitive not needed anymore */
706 }
707
708 /* determine result id */
709 switch( *resId )
710 {
711 case( CCR_NOT_ALLW ):
712 /* call setup not allowed */
713 send_error_to_user( ownNotSAT, psaCC_ctb(cId)->curCmd,
714 RSLT_CC_SIM_PRM, ADD_CC_NOT_ALLWD,
715 NULL, TRUE);
716
717 /* memory for number has also been allocated in case of SAT setup call !! */
718 psaCC_FreeCtbNtry (cId);
719 return( FALSE ); /* primitive not needed anymore */
720
721 case( CCR_ALLW_WITH_MDFY ):
722 /* call setup allowed with modification */
723 if( ccr->v_ss_string )
724 {
725 /* if setup was converted into a SS control string */
726 return(cmhSAT_result_sim_cc_ss( cId, resId, ccr ));
727 }
728 else if( ccr->v_addr )
729 {
730 /* Replace call parameters for this cId with the ones provided by SIM */
731 cmhSAT_result_sim_cc_address( cId, ccr );
732 }
733 else if (ccr->v_ussd_string)
734 {
735 /* if setup was converted into a USSD control string */
736 return(cmhSAT_result_sim_cc_ussd( cId, resId, ccr ));
737 }
738 else
739 {} /* do not change cId parameters */
740 break;
741
742 case( CCR_ALLW_NO_MDFY ):
743 /* call setup allowed no modification */
744 /* use parameters already linked to cId */
745 break;
746 }
747
748 /* perform call setup initiated by user */
749 if( ownNotSAT )
750 {
751 /* check for an active call */
752 actId = psaCC_ctbFindCall( NO_VLD_OWN, CS_ACT, NO_VLD_CT );
753
754 if( actId NEQ NO_ENTRY )
755 {
756 /* put active on hold if possible */
757 if( psaCC_ctb(actId)->prio EQ PRIO_NORM_CALL AND
758 cmhCC_getcalltype(actId) EQ VOICE_CALL )
759 {
760 cmhCC_HoldCall(actId, psaCC_ctb(cId)->curSrc, AT_CMD_D);
761 }
762 /* reject call setup: already data or emergency call on going */
763 else
764 {
765 cmdBuf = psaCC_ctb(cId)->curCmd;
766 psaCC_FreeCtbNtry (cId);
767
768 R_AT( RAT_CME, satShrdPrm.SIMCCParm.owner )
769 ( cmdBuf, CME_ERR_NotPresent );
770
771 /* log result */
772 cmh_logRslt ( satShrdPrm.SIMCCParm.owner, RAT_CME, cmdBuf,
773 -1, -1, CME_ERR_NotPresent );
774
775 return( FALSE ); /* primitive not needed anymore */
776 }
777 }
778
779 /* finally set up call */
780 cmhCC_flagCall( cId,
781 &(cmhPrm[psaCC_ctb(cId)->calOwn].ccCmdPrm.mltyCncFlg));
782
783 psaCC_NewCall (cId);
784
785
786 #if defined SMI OR defined MFW
787 /* log command */
788 cmdLog.atCmd = AT_CMD_D;
789 cmdLog.cmdType = CLOG_TYPE_Set;
790 cmdLog.retCode = AT_EXCT;
791 cmdLog.cId = cId+1;
792 cmdLog.sId = ACI_NumParmNotPresent;
793 cmdLog.cmdPrm.sD.srcId = psaCC_ctb(cId)->curSrc;
794
795 cmdLog.cmdPrm.sD.number = cmdlog_num_buf;
796
797 /*
798 * For this block wrong code is generated by target compiler 1.22e
799 * Use psaCC_ctb() to simplify pointer expression.
800 */
801 #if 0
802 if(ccShrdPrm.ctb[cId]->cldPty.c_called_num < MAX_CC_CALLED_NUMBER)
803 {
804 length = ccShrdPrm.ctb[cId]->cldPty.c_called_num;
805 }
806 else
807 length = MAX_CC_CALLED_NUMBER;
808
809 utl_BCD2String( cmdLog.cmdPrm.sD.number,
810 (UBYTE *) ccShrdPrm.ctb[cId]->cldPty.called_num,
811 length);
812 #else
813 if(psaCC_ctb(cId)->cldPty.c_called_num < MAX_CC_CALLED_NUMBER)
814 {
815 length = psaCC_ctb(cId)->cldPty.c_called_num;
816 }
817 else
818 length = MAX_CC_CALLED_NUMBER;
819
820 utl_BCD2String (cmdLog.cmdPrm.sD.number,
821 psaCC_ctb(cId)->cldPty.called_num,
822 length);
823 #endif /* else, #if 0 */
824
825 cmdLog.cmdPrm.sD.clirOvrd = D_CLIR_OVRD_Default; /* ??? */
826 cmdLog.cmdPrm.sD.cugCtrl = D_CUG_CTRL_NotPresent; /* ??? */
827 cmdLog.cmdPrm.sD.callType = psaCC_ctb(cId)->calType;
828 #ifdef SIM_TOOLKIT
829 cmdLog.cmdPrm.sD.simCallCtrl= D_SIMCC_ACTIVE;
830 #endif /* SIM tOOLKIT */
831 rAT_PercentCLOG( &cmdLog );
832 #endif /* SMI or MFW */
833 return( FALSE );
834 }
835 /* perform call setup initiated by SAT */
836 else /* Must be normal behaviour, otherwise it would have been trapped earlier in the function */
837 {
838
839 #ifdef FF_SAT_E
840 /* if source was open channel command */
841 if( satShrdPrm.opchStat EQ OPCH_CCSIM_REQ )
842 {
843 if(*resId EQ CCR_ALLW_WITH_MDFY)
844 satShrdPrm.opchCCMdfy = TRUE;
845
846 cmhSAT_OpChnAlert( cId );
847 return( FALSE );
848 }
849 #endif /* FF_SAT_E */
850
851 /* alert user if command details are supported */
852 if( cmhSAT_ChckCmdDet() )
853 {
854 /* check aoc condition */
855 if ((psaCC_ctb(cId)->prio EQ PRIO_NORM_CALL) AND
856 (aoc_check_moc() EQ FALSE))
857 /*
858 * check ACM exceeds ACMmax
859 * for non-emergency calls
860 */
861 {
862 resp_data.add_content = ADD_NO_CAUSE;
863 resp_data.resCC = (*resId EQ CCR_ALLW_WITH_MDFY)? resId: NULL;
864
865
866 psaSAT_SendTrmResp(RSLT_ME_UNAB_PROC, &resp_data);
867 psaCC_FreeCtbNtry (cId);
868 return( FALSE );
869 }
870
871 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
872 {
873
874 #ifdef FF_SAT_E
875 T_ACI_SATA_ADD addPrm;
876
877 addPrm.chnType = SATA_CT_VOICE;
878 addPrm.chnEst = SATA_EST_IM;
879
880 R_AT( RAT_SATA, idx )( cId+1, satShrdPrm.dur, &addPrm );
881 #else
882 R_AT( RAT_SATA, idx )( cId+1, satShrdPrm.dur );
883 #endif /* FF_SAT_E */
884 }
885
886 satShrdPrm.ntfy = USR_NTF_SETUP_CAL;
887 }
888 return( FALSE );
889 }
890 }
891
892 LOCAL BOOL sim_control_setup_call( T_ccr_allw *ccr, BOOL ownNotSAT )
893 {
894 SHORT cId = satShrdPrm.SIMCCParm.cId; /* holds setup call id */
895 UBYTE idx; /* holds index */
896 #ifdef FF_SAT_E
897 T_ACI_SATA_ADD addPrm;
898 #endif /* FF_SAT_E */
899 cId = psaCC_ctbNewEntry();
900
901 if( cId EQ NO_ENTRY )
902 {
903 send_error_to_user( ownNotSAT, AT_CMD_D, RSLT_ME_UNAB_PROC, ADD_NO_CAUSE, NULL, FALSE);
904 return( FALSE ); /* primitive not needed anymore */
905 }
906
907 /* fill in setup parameter for called address */
908 cmhSAT_fillSetupPrm ( cId,
909 ((ccr->v_addr)?&ccr->addr:NULL),
910 ((ccr->v_subaddr)?&ccr->subaddr:NULL));
911 /* new call table entry set default bearer capabilities */
912 cmhSAT_fillSetupBC ( cId, BEARER_SERV_SPEECH, BEARER_SERV_NOT_PRES );
913
914 /* check aoc condition */
915 if ((psaCC_ctb(cId)->prio EQ PRIO_NORM_CALL) AND
916 (aoc_check_moc() EQ FALSE))
917 /* check ACM exceeds ACMmax for non-emergency calls */
918 {
919 send_error_to_user( ownNotSAT, AT_CMD_D, RSLT_ME_UNAB_PROC, ADD_NO_CAUSE, NULL, FALSE);
920 psaCC_FreeCtbNtry (cId);
921 return( FALSE );
922 }
923
924 if( ccr->v_cap_cnf_parms )
925 {
926 /* check bearer caps, ctb not allocated */
927 }
928
929 /* declare call table entry as used and the owner and status
930 of the call */
931 psaCC_ctb(cId)->calOwn = satShrdPrm.SIMCCParm.owner;
932 psaCC_ctb(cId)->calStat = CS_SAT_REQ;
933 psaCC_ctb(cId)->curCmd = AT_CMD_D;
934 psaCC_ctb(cId)->curSrc = satShrdPrm.SIMCCParm.owner;
935
936 if( !ownNotSAT ) psaCC_ctb(cId)->SATinv = TRUE;
937
938 /* alert user */
939 if( ownNotSAT )
940 {
941 #ifdef FF_SAT_E
942 addPrm.chnType = SATA_CT_VOICE;
943 addPrm.chnEst = SATA_EST_IM;
944
945 R_AT( RAT_SATA, satShrdPrm.SIMCCParm.owner )
946 ( cId+1, satShrdPrm.dur, &addPrm );
947 #else
948 R_AT( RAT_SATA, satShrdPrm.SIMCCParm.owner )
949 ( cId+1, satShrdPrm.dur);
950 #endif /* FF_SAT_E */
951
952 R_AT( RAT_OK, satShrdPrm.SIMCCParm.owner )
953 ( AT_CMD_D );
954 /* log result */
955 cmh_logRslt ( satShrdPrm.SIMCCParm.owner,
956 RAT_OK, AT_CMD_D, -1, -1, -1 );
957 }
958 /* setup initiated by SAT */
959 else
960 {
961 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
962 {
963 #ifdef FF_SAT_E
964 addPrm.chnType = SATA_CT_VOICE;
965 addPrm.chnEst = SATA_EST_IM;
966 R_AT( RAT_SATA, idx )
967 ( cId+1, satShrdPrm.dur, &addPrm );
968 #else
969 R_AT( RAT_SATA, idx )
970 ( cId+1, satShrdPrm.dur);
971 #endif /* FF_SAT_E */
972 }
973 }
974 return( !ownNotSAT );
975 }
976
977
978 /*
979 +-------------------------------------------------------------------+
980 | PROJECT : GSM-PS (6147) MODULE : CMH_SATR |
981 | ROUTINE : cmhSAT_ResSSCntrlBySIM |
982 +-------------------------------------------------------------------+
983
984 PURPOSE : Handle SIM SS control result. Return TRUE if primitive
985 is needed for building a terminal response.
986
987 */
988
989 GLOBAL BOOL cmhSAT_ResSSCntrlBySIM( UBYTE* resId, void *ccRes )
990 {
991 SHORT cId = satShrdPrm.SIMCCParm.cId; /* holds setup call id */
992 T_ccr_allw * ccr; /* points to CC result */
993 BOOL ownNotSAT; /* flags that the owner is not SAT */
994
995 TRACE_FUNCTION("cmhSAT_ResSSCntrlBySIM()");
996
997 ccr = (T_ccr_allw*)ccRes;
998
999 /* check if queued event download */
1000 if (satShrdPrm.event.c_queued)
1001 {
1002 cmhSAT_EventDwn( -1, -1, -1);
1003 }
1004
1005 satShrdPrm.SIMCCParm.busy = FALSE;
1006
1007 ownNotSAT = satShrdPrm.SIMCCParm.owner NEQ OWN_SAT;
1008
1009 /*
1010 ** If this is a Cust1 MMI and The originator was a STK Cmd
1011 */
1012 if ((simShrdPrm.overall_cust_mode EQ (UBYTE)CUST_MODE_BEHAVIOUR_1) AND
1013 (ownNotSAT == FALSE))
1014 {
1015 /*
1016 ** Customised behaviour for the Cust1 MMI
1017 */
1018 if (*resId == CCR_NOT_ALLW)
1019 {
1020 send_error_to_user( ownNotSAT,
1021 AT_CMD_D,
1022 RSLT_CC_SIM_PRM,
1023 ADD_CC_NOT_ALLWD,
1024 NULL, FALSE);
1025 }
1026 else
1027 {
1028 /*
1029 ** This was a SAT initiated Request. For the Cust1 the ACI does not yet have any
1030 ** actions to perform, other than the CC By SIM which has been done. So :
1031 ** Send the Original STK Cmd to the MMI in a %SATI for the MMI to process.
1032 **
1033 ** The second action will cause the MMI to request the approriate Call Setup, SS
1034 ** or USSD Request and the required Call Table entry will then be re-created.
1035 */
1036 cmhSAT_Cust1StkCmdInd();
1037 }
1038
1039 /* Free the Call Table Entry
1040 ** The SATI indication (if sent) will cause the MMI to request the approriate Call Setup, SS
1041 ** or USSD Request and the required Call Table entry will then be re-created.
1042 */
1043 if (psaCC_ctbIsValid (cId))
1044 {
1045 psaCC_retMOCTi(psaCC_ctb(cId)->ti);
1046 psaCC_chngCalTypCnt(cId, -1);
1047 psaCC_FreeCtbNtry (cId);
1048 }
1049 return( FALSE ); /* primitive not needed anymore */
1050 }
1051
1052
1053 /* determine result id */
1054 switch( *resId )
1055 {
1056 case( CCR_NOT_ALLW ): /* SS not allowed */
1057 {
1058 send_error_to_user( ownNotSAT, AT_CMD_D, RSLT_CC_SIM_PRM, ADD_CC_NOT_ALLWD, NULL, FALSE);
1059 if (ownNotSAT EQ FALSE)
1060 {
1061 /* clear call ID */
1062 if (psaCC_ctbIsValid (cId))
1063 {
1064 psaCC_retMOCTi(psaCC_ctb(cId)->ti);
1065 psaCC_chngCalTypCnt(cId, -1);
1066 psaCC_FreeCtbNtry (cId);
1067 }
1068 }
1069 return( FALSE ); /* primitive not needed anymore */
1070 }
1071 case( CCR_ALLW_WITH_MDFY ): /* SS allowed with modification */
1072 {
1073 if( ccr->v_addr )
1074 {
1075 /* if SS control string was converted into a call setup */
1076 return(sim_control_setup_call( ccr, ownNotSAT ));
1077 }
1078 else if( ccr->v_ss_string )
1079 {
1080 /* if SS control string was changed by sim control */
1081
1082 /* adjust SS control string */
1083 cmhCC_init_cldPty( &satPndSetup.clpty ); /* erase previous ss string */
1084
1085 utl_BCD2DialStr( ccr->ss_string.ss_ctrl_string,
1086 satPndSetup.clpty.num,
1087 (UBYTE)MINIMUM(ccr->ss_string.c_ss_ctrl_string,
1088 MAX_DIAL_LEN-1));
1089 satPndSetup.clpty.ton = ccr->ss_string.noa;
1090 satPndSetup.clpty.npi = ccr->ss_string.npi;
1091
1092 sim_control_send_ss( &satPndSetup.clpty, AT_CMD_D, ownNotSAT, NULL );
1093 return(FALSE);
1094 }
1095 else /* if no optionnal field, then assume no modification see 11.14 ?9.1.6 */
1096 sim_control_send_ss( &satPndSetup.clpty, AT_CMD_D, ownNotSAT, NULL );
1097 return(FALSE);
1098 }
1099 /* SS allowed no modification */
1100 default:
1101 TRACE_ERROR ("Unknown resID in cmhSAT_ResSSCntrlBySIM!");
1102 /*lint -fallthrough*/
1103 case( CCR_ALLW_NO_MDFY ):
1104 sim_control_send_ss( &satPndSetup.clpty, AT_CMD_D, ownNotSAT, NULL );
1105 return( FALSE ); /* primitive not needed anymore */
1106 }
1107 }
1108
1109 /*
1110 +-------------------------------------------------------------------+
1111 | PROJECT : GSM-PS (6147) MODULE : CMH_SATR |
1112 | ROUTINE : cmhSAT_ResUSSDCntrlBySIM |
1113 +-------------------------------------------------------------------+
1114
1115 PURPOSE : Handle SIM USSD control result. Return TRUE if primitive
1116 is needed for building a terminal response.
1117
1118 */
1119
1120 GLOBAL BOOL cmhSAT_ResUSSDCntrlBySIM( UBYTE* resId, void *ccRes )
1121 {
1122 T_ACI_RETURN retVal; /* holds return value */
1123 T_ccr_allw * ccr; /* points to CC result */
1124 UBYTE idx; /* holds index */
1125 BOOL ownNotSAT; /* flags that the owner is not SAT */
1126 SHORT sId;
1127 T_ACI_SAT_TERM_RESP resp_data;
1128 #ifdef FF_SAT_E
1129 T_ACI_SATA_ADD addPrm;
1130 #endif
1131 UBYTE *ussdString;
1132 UBYTE ussdLen;
1133 UBYTE src_len;
1134
1135
1136
1137 TRACE_FUNCTION ("cmhSAT_ResUSSDCntrlBySIM()");
1138
1139 psaSAT_InitTrmResp( &resp_data );
1140
1141 ccr = (T_ccr_allw*)ccRes;
1142
1143 /* check if queued event download */
1144 if (satShrdPrm.event.c_queued)
1145 {
1146 cmhSAT_EventDwn( -1, -1, -1);
1147 }
1148
1149 satShrdPrm.SIMCCParm.busy = FALSE;
1150
1151 ownNotSAT = satShrdPrm.SIMCCParm.owner NEQ OWN_SAT;
1152
1153 /*
1154 ** If this is a Cust1 MMI and The originator was a STK Cmd
1155 */
1156 if ((simShrdPrm.overall_cust_mode EQ (UBYTE)CUST_MODE_BEHAVIOUR_1) AND
1157 (ownNotSAT == FALSE))
1158 {
1159 /*
1160 ** Customised behaviour for the Cust1 MMI
1161 */
1162 if (*resId == CCR_NOT_ALLW)
1163 {
1164 /* send SAT response */
1165 resp_data.add_content = ADD_CC_NOT_ALLWD;
1166 psaSAT_SendTrmResp( RSLT_CC_SIM_PRM, &resp_data );
1167 }
1168 else
1169 {
1170 /*
1171 ** This was a SAT initiated Request. For the Cust1 the ACI does not yet have any
1172 ** actions to perform, other than the CC By SIM which has been done. So :
1173 ** Send the Original STK Cmd to the MMI in a %SATI for the MMI to process.
1174 */
1175 cmhSAT_Cust1StkCmdInd();
1176 }
1177
1178 return( FALSE ); /* primitive not needed anymore */
1179 }
1180
1181 /*
1182 *----------------------------------------------------------------
1183 * determine result id
1184 *----------------------------------------------------------------
1185 */
1186 switch( *resId )
1187 {
1188 /*
1189 *------------------------------------------------------------
1190 * SS not allowed
1191 *------------------------------------------------------------
1192 */
1193 case( CCR_NOT_ALLW ):
1194
1195 /* setup initiated by user */
1196 if( ownNotSAT )
1197 {
1198 R_AT( RAT_CME, satShrdPrm.SIMCCParm.owner )
1199 ( AT_CMD_D, CME_ERR_NotPresent );
1200 /* log result */
1201 cmh_logRslt ( satShrdPrm.SIMCCParm.owner, RAT_CME, AT_CMD_D,
1202 -1, -1, CME_ERR_NotPresent );
1203 }
1204 /* setup initiated by SAT */
1205 else
1206 {
1207 /* send SAT response */
1208 resp_data.add_content = ADD_CC_NOT_ALLWD;
1209 psaSAT_SendTrmResp( RSLT_CC_SIM_PRM, &resp_data );
1210 }
1211 return( FALSE ); /* primitive not needed anymore */
1212
1213 /*
1214 *------------------------------------------------------------
1215 * USSD allowed with modification
1216 *------------------------------------------------------------
1217 */
1218 case( CCR_ALLW_WITH_MDFY ):
1219
1220 /* if USSD control string was converted into a call setup */
1221 if( ccr->v_addr )
1222 {
1223 SHORT cId = psaCC_ctbNewEntry();
1224
1225 if( cId EQ NO_ENTRY )
1226 {
1227 /*
1228 * We got no free slot in the call table
1229 */
1230 if( ownNotSAT )
1231 {
1232 R_AT( RAT_CME, satShrdPrm.SIMCCParm.owner )
1233 ( AT_CMD_D, CME_ERR_NotPresent );
1234 /* log result */
1235 cmh_logRslt ( satShrdPrm.SIMCCParm.owner, RAT_CME, AT_CMD_D,
1236 -1, -1, CME_ERR_NotPresent );
1237 }
1238 /* setup initiated by SAT */
1239 else
1240 {
1241 /* send SAT response */
1242 resp_data.add_content = ADD_NO_CAUSE;
1243 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1244 }
1245 return( FALSE ); /* primitive not needed anymore */
1246 }
1247
1248 /*
1249 * We have successfully allocated a slot in the call table
1250 */
1251
1252 /* fill in setup parameter for called address */
1253 cmhSAT_fillSetupPrm ( cId,
1254 ((ccr->v_addr)?&ccr->addr:NULL),
1255 ((ccr->v_subaddr)?&ccr->subaddr:NULL));
1256 /* new call table entry set default bearer capabilities */
1257 cmhSAT_fillSetupBC ( cId, BEARER_SERV_SPEECH, BEARER_SERV_NOT_PRES );
1258
1259 /* check aoc condition */
1260 if ((psaCC_ctb(cId)->prio EQ PRIO_NORM_CALL) AND
1261 (aoc_check_moc() EQ FALSE))
1262 /*
1263 * check ACM exceeds ACMmax
1264 * for non-emergency calls
1265 */
1266 {
1267 if( ownNotSAT )
1268 {
1269 R_AT( RAT_CME, satShrdPrm.SIMCCParm.owner )
1270 ( AT_CMD_D, CME_ERR_NotPresent );
1271 /* log result */
1272 cmh_logRslt ( satShrdPrm.SIMCCParm.owner, RAT_CME, AT_CMD_D,
1273 -1, -1, CME_ERR_NotPresent );
1274 }
1275 /* setup initiated by SAT */
1276 else
1277 {
1278 resp_data.add_content = ADD_NO_CAUSE;
1279 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1280 }
1281 psaCC_FreeCtbNtry (cId);
1282 return( FALSE );
1283 }
1284
1285 if( ccr->v_cap_cnf_parms )
1286 {
1287 /* check bearer caps, ctb not allocated */
1288 }
1289
1290
1291 /* declare call table entry as used and the owner and status
1292 of the call */
1293 psaCC_ctb(cId)->calOwn = satShrdPrm.SIMCCParm.owner;
1294 psaCC_ctb(cId)->calStat = CS_SAT_REQ;
1295 psaCC_ctb(cId)->curCmd = AT_CMD_D;
1296 psaCC_ctb(cId)->curSrc = satShrdPrm.SIMCCParm.owner;
1297
1298 if( !ownNotSAT )
1299 psaCC_ctb(cId)->SATinv = TRUE;
1300
1301 /* alert user */
1302 if( ownNotSAT )
1303 {
1304
1305 #ifdef FF_SAT_E
1306 addPrm.chnType = SATA_CT_VOICE;
1307 addPrm.chnEst = SATA_EST_IM;
1308
1309 R_AT( RAT_SATA, satShrdPrm.SIMCCParm.owner )
1310 ( cId+1, satShrdPrm.dur, &addPrm );
1311 #else
1312 R_AT( RAT_SATA, satShrdPrm.SIMCCParm.owner )
1313 ( cId+1, satShrdPrm.dur);
1314 #endif /* FF_SAT_E */
1315
1316 R_AT( RAT_OK, satShrdPrm.SIMCCParm.owner )
1317 ( AT_CMD_D );
1318 /* log result */
1319 cmh_logRslt ( satShrdPrm.SIMCCParm.owner,
1320 RAT_OK, AT_CMD_D, -1, -1, -1 );
1321 }
1322 /* setup initiated by SAT */
1323 else
1324 {
1325 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
1326 {
1327 #ifdef FF_SAT_E
1328 addPrm.chnType = SATA_CT_VOICE;
1329 addPrm.chnEst = SATA_EST_IM;
1330
1331 R_AT( RAT_SATA, idx )
1332 ( cId+1, satShrdPrm.dur, &addPrm );
1333 #else
1334 R_AT( RAT_SATA, idx )
1335 ( cId+1, satShrdPrm.dur);
1336 #endif
1337 }
1338 }
1339
1340 return( !ownNotSAT );
1341 }
1342
1343 /* --- no break, continue with next case --- */
1344 /*lint -fallthrough*/
1345
1346 /*
1347 *------------------------------------------------------------
1348 * USSD allowed no modification
1349 *------------------------------------------------------------
1350 */
1351 default:
1352 TRACE_ERROR ("unknown resID in cmhSAT_ResUSSDCntrlBySIM");
1353 /*lint -fallthrough*/
1354 case( CCR_ALLW_NO_MDFY ):
1355
1356 /* check for busy SS condition */
1357 if( psaSS_stbFindActSrv( NO_ENTRY ) NEQ NO_ENTRY )
1358 {
1359 /* respond with "error, ME currently unable to process command" */
1360 resp_data.add_content = ADD_ME_USSD_BUSY;
1361 psaSAT_SendTrmResp( RSLT_ME_UNAB_PROC, &resp_data );
1362 return( FALSE );
1363 }
1364
1365 /* adjust SS control string */
1366 if( ccr->v_ussd_string )
1367 {
1368 memcpy( &(satPndSetup.ussd_str),
1369 &ccr->ussd_string,
1370 sizeof(T_ussd_string));
1371 }
1372
1373 /********************************************************************************/
1374 /*
1375 *-------------------------------------------------------------------
1376 * check if there is a USSD request pending
1377 *-------------------------------------------------------------------
1378 */
1379 sId = psaSS_stbFindUssdReq();
1380
1381 if( sId EQ NO_ENTRY )
1382 {
1383 /* check if there is another service in progress */
1384 if( psaSS_stbFindActSrv( sId ) NEQ NO_ENTRY )
1385 {
1386 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_ParallelUSSD );
1387 return( AT_FAIL );
1388 }
1389
1390 /* get new service table entry */
1391 sId = psaSS_stbNewEntry();
1392 if( sId EQ NO_ENTRY )
1393 {
1394 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_SrvTabFull );
1395 return( AT_FAIL );
1396 }
1397
1398 CCD_START;
1399
1400 MALLOC(ussdString, MAX_USSD_STRING);
1401
1402 /* set data coding scheme */
1403 /* patch !!!!! CLB 11/12/01 */
1404 if( (UBYTE)satPndSetup.ussd_str.dcs EQ 0x40 )
1405 {
1406 /* 0x40 means basically default alphabet...
1407 yet some asian networks dont seem to accept it (although using it
1408 in their own STK !!!) */
1409 satPndSetup.ussd_str.dcs = 0x0F;
1410 }
1411 /*********************************/
1412 if( utl_getAlphabetCb( (UBYTE)satPndSetup.ussd_str.dcs ) EQ 0 ) /* 7bit alphabet */
1413 {
1414 src_len = (UBYTE)MINIMUM( MAX_USSD_STRING, satPndSetup.ussd_str.c_ussd_str);
1415 ussdLen = utl_cvt8To7( satPndSetup.ussd_str.ussd_str,
1416 src_len,
1417 ussdString, 0 );
1418 /* According to spec 23.038 section 6.1.2.3 for USSD packing, for bytes end with
1419 * (8*n)-1 i.e where n is 1,2,3....i.e byte 7, 15, 23 ... to be padded
1420 * with carriage return <CR>(0xD)
1421 */
1422 if ((src_len+1)%8 EQ 0)
1423 {
1424 ussdString[ussdLen-1] |= (0xD << 1);
1425 }
1426 }
1427 else
1428 {
1429 ussdLen = satPndSetup.ussd_str.c_ussd_str;
1430 memcpy(ussdString, satPndSetup.ussd_str.ussd_str, MAX_USSD_STRING);
1431 }
1432 psaSS_asmProcUSSDReq( (UBYTE)satPndSetup.ussd_str.dcs /*dcs*/,
1433 ussdString,
1434 ussdLen);
1435 MFREE(ussdString);
1436
1437 /* start new transaction */
1438 ssShrdPrm.stb[sId].ntryUsdFlg = TRUE;
1439
1440 if (ownNotSAT)
1441 {
1442 ssShrdPrm.stb[sId].curCmd = AT_CMD_CUSD;
1443 ssShrdPrm.stb[sId].srvOwn = satShrdPrm.SIMCCParm.owner;
1444 }
1445 else
1446 {
1447 ssShrdPrm.stb[sId].curCmd = AT_CMD_NONE;
1448 ssShrdPrm.stb[sId].srvOwn = OWN_SAT;
1449 satShrdPrm.SentUSSDid = sId;
1450 }
1451 psaSS_NewTrns(sId);
1452
1453 if (ownNotSAT)
1454 {
1455 R_AT( RAT_OK, satShrdPrm.SIMCCParm.owner )
1456 ( AT_CMD_CUSD);
1457
1458 cmh_logRslt ( satShrdPrm.SIMCCParm.owner,
1459 RAT_OK, AT_CMD_CUSD, -1, -1, -1 );
1460 }
1461
1462 CCD_END;
1463
1464 retVal = AT_EXCT;
1465 }
1466 else
1467 {
1468 CCD_START;
1469
1470 psaSS_asmCnfUSSDReq( (UBYTE)satPndSetup.ussd_str.dcs,
1471 satPndSetup.ussd_str.ussd_str,
1472 satPndSetup.ussd_str.c_ussd_str );
1473
1474 ssShrdPrm.stb[sId].ussdReqFlg = FALSE;
1475
1476 /* continue existing transaction */
1477 psaSS_CntTrns(sId);
1478
1479 CCD_END;
1480
1481 retVal = AT_CMPL;
1482 }
1483 /**********************************************************************************/
1484
1485 if( retVal EQ AT_EXCT )
1486 return( FALSE ); /* primitive not needed anymore */
1487
1488 if( ownNotSAT )
1489 {
1490 R_AT( RAT_CME, satShrdPrm.SIMCCParm.owner )
1491 ( AT_CMD_D, CME_ERR_NotPresent );
1492 /* log result */
1493 cmh_logRslt ( satShrdPrm.SIMCCParm.owner, RAT_CME, AT_CMD_D,
1494 -1, -1, CME_ERR_NotPresent );
1495 }
1496 /* setup initiated by SAT */
1497 else
1498 {
1499 /* send SAT response */
1500 resp_data.resCC = resId;
1501 psaSAT_SendTrmResp( RSLT_ME_CAP, &resp_data );
1502 }
1503
1504 return( FALSE ); /* primitive not needed anymore */
1505 }
1506 }
1507
1508 /*
1509 +-------------------------------------------------------------------+
1510 | PROJECT : GSM-PS (6147) MODULE : CMH_SATR |
1511 | ROUTINE : cmhSAT_ResSMCntrlBySIM |
1512 +-------------------------------------------------------------------+
1513
1514 PURPOSE : Handle SIM SM control result. Return TRUE if primitive
1515 is needed for building a terminal response.
1516
1517 */
1518
1519 GLOBAL BOOL cmhSAT_ResSMCntrlBySIM( UBYTE* resId, void *smcRes )
1520 {
1521 BOOL ownNotSAT; /* flags that the owner is not SAT */
1522 T_smcr_allw *smcr; /* points to SM result */
1523 T_ACI_CMGF_MOD mode;
1524 UBYTE sca_buf[MAX_SMS_ADDR_DIG/2 + 2];
1525 UBYTE da_buf[MAX_SMS_ADDR_DIG/2 + 2];
1526 UBYTE sca_len = 0;
1527 UBYTE da_len = 0;
1528 T_ACI_SAT_TERM_RESP resp_data;
1529 UBYTE srcId = smsShrdPrm.smsEntStat.entOwn;
1530
1531 TRACE_FUNCTION ("cmhSAT_ResSMCntrlBySIM()");
1532
1533
1534 psaSAT_InitTrmResp( &resp_data );
1535
1536 smcr = (T_smcr_allw*)smcRes;
1537
1538 /* check if queued event download */
1539 if (satShrdPrm.event.c_queued)
1540 {
1541 cmhSAT_EventDwn( -1, -1, -1);
1542 }
1543
1544 satShrdPrm.SIMCCParm.busy = FALSE;
1545
1546 ownNotSAT = satShrdPrm.SIMCCParm.owner NEQ OWN_SAT;
1547
1548 /*
1549 ** If this is a Cust1 MMI and The originator was a STK Cmd
1550 */
1551 if ((simShrdPrm.overall_cust_mode EQ (UBYTE)CUST_MODE_BEHAVIOUR_1) AND
1552 (ownNotSAT == FALSE))
1553 {
1554 /*
1555 ** Customised behaviour for the Cust1 MMI
1556 */
1557 if (*resId == CCR_NOT_ALLW)
1558 {
1559 /* send SAT response */
1560 resp_data.add_content = ADD_CC_NOT_ALLWD;
1561 psaSAT_SendTrmResp( RSLT_CC_SIM_PRM, &resp_data );
1562 }
1563 else
1564 {
1565 /*
1566 ** This was a SAT initiated Request. For the Cust1 the ACI does not yet have any
1567 ** actions to perform, other than the CC By SIM which has been done. So :
1568 ** Send the Original STK Cmd to the MMI in a %SATI for the MMI to process.
1569 **
1570 ** The second action will cause the MMI to request the approriate Call Setup, SS
1571 ** or USSD Request and the required Call Table entry will then be re-created.
1572 */
1573 cmhSAT_Cust1StkCmdInd();
1574 }
1575
1576 if ( (sat_mnsms_submit_req->rec_num EQ SMS_RECORD_NOT_EXIST) OR
1577 (sat_mnsms_submit_req->modify NEQ SMS_MODIFY_NON) )
1578 {
1579 if (smsShrdPrm.tpdu.tp_submit NEQ NULL)
1580 {
1581 ACI_MFREE(smsShrdPrm.tpdu.tp_submit);
1582 smsShrdPrm.tpdu.tp_submit = NULL;
1583 }
1584 }
1585 PFREE( sat_mnsms_submit_req );
1586
1587 /*
1588 ** Ensure that the SMS parameters are reset, so that the SMS Entity is freed to
1589 ** process the command later.
1590 */
1591 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1592 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = CMD_SRC_NONE;
1593
1594 return( FALSE ); /* primitive not needed anymore */
1595 }
1596
1597 if (smsShrdPrm.smsEntStat.curCmd EQ AT_CMD_CMSS)
1598 {
1599 mode = CMGF_MOD_Txt;
1600 }
1601 #if defined MFW OR defined FF_MMI_RIV OR defined _CONC_TESTING_
1602 else if (smsShrdPrm.smsEntStat.entOwn EQ CMD_SRC_LCL)
1603 {
1604 mode = CMGF_MOD_Txt; /* since text mode (AT+CMGF=1) is never set in MMI */
1605 }
1606 #endif
1607 else if (ownNotSAT EQ FALSE)
1608 {
1609 mode = CMGF_MOD_Pdu;
1610 }
1611 else
1612 {
1613 /*
1614 * request current mode
1615 */
1616 qAT_PlusCMGF(srcId, &mode);
1617 }
1618
1619 /*
1620 *----------------------------------------------------------------
1621 * determine result id
1622 *----------------------------------------------------------------
1623 */
1624 switch( *resId )
1625 {
1626 /*
1627 *------------------------------------------------------------
1628 * send message not allowed
1629 *------------------------------------------------------------
1630 */
1631 case( CCR_NOT_ALLW ):
1632 /* setup initiated by user */
1633 if( ownNotSAT )
1634 {
1635 R_AT( RAT_CME, satShrdPrm.SIMCCParm.owner )
1636 ( smsShrdPrm.smsEntStat.curCmd, CME_ERR_NotPresent );
1637 /* log result */
1638 cmh_logRslt ( satShrdPrm.SIMCCParm.owner, RAT_CME, smsShrdPrm.smsEntStat.curCmd,
1639 -1, -1, CME_ERR_NotPresent );
1640
1641 smsShrdPrm.smsEntStat.curCmd = AT_CMD_NONE;
1642 smsShrdPrm.smsEntStat.entOwn = smsShrdPrm.owner = OWN_NONE;
1643 }
1644 /* setup initiated by SAT */
1645 else
1646 {
1647 /* send SAT response */
1648 resp_data.add_content = ADD_CC_NOT_ALLWD;
1649 psaSAT_SendTrmResp( RSLT_CC_SIM_PRM, &resp_data );
1650 }
1651
1652 if ( (sat_mnsms_submit_req->rec_num EQ SMS_RECORD_NOT_EXIST) OR
1653 (sat_mnsms_submit_req->modify NEQ SMS_MODIFY_NON) )
1654 {
1655 if (smsShrdPrm.tpdu.tp_submit NEQ NULL)
1656 {
1657 ACI_MFREE(smsShrdPrm.tpdu.tp_submit);
1658 smsShrdPrm.tpdu.tp_submit = NULL;
1659 }
1660 }
1661 PFREE( sat_mnsms_submit_req );
1662 return( FALSE ); /* primitive not needed anymore */
1663
1664
1665 case( CCR_ALLW_WITH_MDFY ):
1666 if ( smcr->v_sm_addr )
1667 {
1668 /*
1669 * RP Service Center Address
1670 */
1671
1672 sat_mnsms_submit_req->modify |= SMS_MODIFY_SCA;
1673
1674 if (mode EQ CMGF_MOD_Pdu)
1675 {
1676 /* PDU mode */
1677 sca_len = CodeRPAddress( sca_buf,
1678 smcr->sm_addr.c_bcdDigit,
1679 smcr->sm_addr.noa,
1680 smcr->sm_addr.npi,
1681 smcr->sm_addr.bcdDigit );
1682
1683 cmhSAT_ModifyScaPdu( &sat_mnsms_submit_req->sms_sdu,
1684 sca_buf,
1685 sca_len );
1686 }
1687 else
1688 {
1689 /* Text mode */
1690 smsShrdPrm.tpdu.sc_addr.v_ton = 1;
1691 smsShrdPrm.tpdu.sc_addr.ton = smcr->sm_addr.noa;
1692 smsShrdPrm.tpdu.sc_addr.v_npi = 1;
1693 smsShrdPrm.tpdu.sc_addr.npi = smcr->sm_addr.npi;
1694 smsShrdPrm.tpdu.sc_addr.c_num = smcr->sm_addr.c_bcdDigit;
1695 memcpy(smsShrdPrm.tpdu.sc_addr.num, smcr->sm_addr.bcdDigit,
1696 smcr->sm_addr.c_bcdDigit);
1697 }
1698 }
1699
1700 if ( smcr->v_sm_addr_2)
1701 {
1702 /*
1703 * TP Destination Address
1704 */
1705
1706 sat_mnsms_submit_req->modify |= SMS_MODIFY_TPOA;
1707
1708 if (mode EQ CMGF_MOD_Pdu)
1709 {
1710 /* PDU mode */
1711 da_len = CodeTPAddress( da_buf,
1712 smcr->sm_addr_2.c_bcdDigit,
1713 smcr->sm_addr_2.noa,
1714 smcr->sm_addr_2.npi,
1715 smcr->sm_addr_2.bcdDigit );
1716
1717 cmhSAT_ModifyDaPdu( &sat_mnsms_submit_req->sms_sdu,
1718 da_buf,
1719 da_len );
1720 }
1721 else
1722 {
1723 /* Text mode */
1724 smsShrdPrm.tpdu.tp_submit->tp_da.ton = smcr->sm_addr_2.noa;
1725 smsShrdPrm.tpdu.tp_submit->tp_da.npi = smcr->sm_addr_2.npi;
1726 smsShrdPrm.tpdu.tp_submit->tp_da.c_num = smcr->sm_addr_2.c_bcdDigit;
1727 smsShrdPrm.tpdu.tp_submit->tp_da.digits = smcr->sm_addr_2.c_bcdDigit;
1728 memcpy(smsShrdPrm.tpdu.tp_submit->tp_da.num, smcr->sm_addr_2.bcdDigit,
1729 smcr->sm_addr_2.c_bcdDigit);
1730 }
1731 }
1732 /* no break needed !!!! */
1733 /*lint -fallthrough*/
1734 case( CCR_ALLW_NO_MDFY ):
1735 if( sat_mnsms_submit_req )
1736 {
1737 if (mode EQ CMGF_MOD_Txt) /* Text mode */
1738 {
1739 /* code sm here */
1740 cmhSMS_codeMsg (&sat_mnsms_submit_req->sms_sdu,
1741 SMS_VT_SUBMIT,
1742 &smsShrdPrm.tpdu.sc_addr,
1743 SMS_SUBMIT,
1744 (UBYTE*)smsShrdPrm.tpdu.tp_submit);
1745
1746 if (smsShrdPrm.tpdu.tp_submit NEQ NULL)
1747 {
1748 ACI_MFREE(smsShrdPrm.tpdu.tp_submit);
1749 smsShrdPrm.tpdu.tp_submit = NULL;
1750 }
1751 }
1752
1753 PSENDX (SMS, sat_mnsms_submit_req);
1754 }
1755 else
1756 TRACE_EVENT("error provoked by SAT");
1757 break;
1758
1759 default:
1760 if ( (sat_mnsms_submit_req->rec_num EQ SMS_RECORD_NOT_EXIST) OR
1761 (sat_mnsms_submit_req->modify NEQ SMS_MODIFY_NON) )
1762 {
1763 if (smsShrdPrm.tpdu.tp_submit NEQ NULL)
1764 {
1765 ACI_MFREE(smsShrdPrm.tpdu.tp_submit);
1766 smsShrdPrm.tpdu.tp_submit = NULL;
1767 }
1768 }
1769 TRACE_EVENT("wrong type of result received from SIM");
1770 PFREE( sat_mnsms_submit_req );
1771 return( FALSE ); /* primitive not needed anymore */
1772 }
1773
1774 return FALSE;
1775 }
1776
1777 /*
1778 +-------------------------------------------------------------------+
1779 | PROJECT : GSM-PS (6147) MODULE : CMH |
1780 | ROUTINE : cmhCC_SatDTMFsent |
1781 +-------------------------------------------------------------------+
1782
1783 PURPOSE : confirmation for sent SAT DTMF
1784 */
1785 GLOBAL void cmhCC_SatDTMFsent ( SHORT cId )
1786 {
1787 T_CC_CALL_TBL *ctb = ccShrdPrm.ctb[cId];
1788 T_ACI_SAT_TERM_RESP resp_data;
1789 static UBYTE dtmf_separator_count = 0;
1790
1791 TRACE_FUNCTION ("cmhCC_SatDTMFsent()");
1792
1793 psaSAT_InitTrmResp( &resp_data );
1794
1795 /*
1796 * Use ctb here because TI compiler 1.22e may have a problem otherwise here.
1797 * See cmhCC_SndDiscRsn() for the details.
1798 */
1799 if (GET_CAUSE_VALUE(ctb->nrmCs) NEQ NOT_PRESENT_8BIT AND
1800 ctb->nrmCs NEQ MNCC_CAUSE_DTMF_START_SUCCESS)
1801 {
1802 TRACE_EVENT_P1("network reported error when sending DTMF: %d", ctb->nrmCs);
1803
1804 psaSAT_SendTrmResp( RSLT_NTW_UNAB_PROC, &resp_data );
1805 dtmf_separator_count = 0;
1806 return;
1807 }
1808
1809 if(is_digit_dtmf_separator(ccShrdPrm.dtmf.dig[ccShrdPrm.dtmf.cur]))
1810 {
1811 if (dtmf_separator_count EQ 0)
1812 {
1813 dtmf_separator_count = 1;
1814 if(ctb->dtmfCmd NEQ AT_CMD_VTS) /* this is only valid within a number to dial */
1815 {
1816 /* p within a number string: this is a 3 seconds pause */
1817 TRACE_EVENT("DTMF pause requested: 3 seconds");
1818 #if defined (NEW_FRAME)
1819 TIMERSTART( TDTMF_VALUE, ACI_TDTMF );
1820 #else
1821 TIMERSTART( TDTMF_VALUE, t_dtmf_handle );
1822 #endif
1823 ccShrdPrm.dtmf.cur++; /* skip the DTMF seperator */
1824
1825 return;
1826 }
1827 ccShrdPrm.dtmf.cur++; /* skip the DTMF seperator */
1828 }
1829 }
1830 else
1831 {
1832 dtmf_separator_count = 0;
1833 }
1834
1835 if (ccShrdPrm.dtmf.cur < ccShrdPrm.dtmf.cnt)
1836 {
1837 cmhSAT_sendDTMF ( NULL );
1838 }
1839 else /* whole DTMF string has been sent */
1840 {
1841 ccShrdPrm.dtmf.cId = NO_ENTRY; /* Reset cId after sending the whole DTMF string */
1842 ctb->dtmfCmd = AT_CMD_NONE;
1843 ctb->dtmfSrc = CMD_SRC_NONE;
1844 psaSAT_SendTrmResp( RSLT_PERF_SUCCESS, &resp_data );
1845 dtmf_separator_count = 0;
1846 }
1847 }
1848
1849 #endif /* #ifdef SIM_TOOLKIT */
1850 /*==== EOF ========================================================*/