comparison g23m/condat/ms/src/aci/cmh_sss.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_SSS
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 provides the set functions related to the
18 | protocol stack adapter for SS.
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef CMH_SSS_C
23 #define CMH_SSS_C
24 #endif
25
26 #include "aci_all.h"
27 /*==== INCLUDES ===================================================*/
28 #include "aci.h"
29 #include "aci_cmh.h"
30
31 #ifdef FAX_AND_DATA
32 #include "aci_fd.h"
33 #endif /* of #ifdef FAX_AND_DATA */
34
35 #ifdef UART
36 #include "dti.h"
37 #include "dti_conn_mng.h"
38 #endif
39
40 #include "ksd.h"
41 #include "psa.h"
42 #include "psa_ss.h"
43 #include "psa_sim.h"
44 #include "psa_sms.h"
45 #include "psa_cc.h"
46 #include "cmh.h"
47 #include "cmh_ss.h"
48 #include "cmh_sim.h"
49 #include "cmh_sms.h"
50 #include "cmh_cc.h"
51
52 #ifdef SIM_TOOLKIT
53 #include "psa_cc.h"
54 #include "psa_sat.h"
55 #include "cmh_sat.h"
56 #include "ati_cmd.h"
57 #include "aci_cmd.h"
58 #include "cmh_cc.h"
59 #endif /* of SIM_TOOLKIT */
60
61 #include "psa_util.h"
62 #ifdef GPRS
63 #include "gaci_cmh.h"
64 #endif /* GPRS */
65 #include "phb.h"
66
67
68 #include "aci_ext_pers.h"
69 #include "aci_slock.h"
70
71 #ifdef SIM_PERS
72 #include "general.h" // inluded for UINT8 compilation error in sec_drv.h
73 #include "sec_drv.h"
74
75 EXTERN T_SEC_DRV_CONFIGURATION *cfg_data;
76 EXTERN T_SIM_MMI_INSERT_IND *last_sim_mmi_insert_ind;
77 #endif
78
79 /*==== CONSTANTS ==================================================*/
80 #define AT_TOA_DEF_INT (129) /* toa default for international no.*/
81 #define AT_TOA_DEF_NAT (145) /* toa default for national no.*/
82 #define AT_TOS_DEF (128) /* tos default */
83 #define AT_CFNRY_DEF_TIME (20) /* default no reply time */
84
85
86
87
88 /*==== EXPORT =====================================================*/
89
90 /*==== VARIABLES ==================================================*/
91 EXTERN T_ACI_CUSCFG_PARAMS cuscfgParams;
92 GLOBAL SHORT Ext_USSD_Res_Pending_sId;
93 GLOBAL T_CUSDR_EXT_USSD_RES Ext_USSD_Res_Pending = CUSDR_EXT_USSD_RES_Not_Pending;
94
95 /*==== FUNCTIONS ==================================================*/
96
97 /*
98 +--------------------------------------------------------------------+
99 | PROJECT : GSM-PS (6147) MODULE : CMH_SSS |
100 | STATE : code ROUTINE : sAT_PlusCCFC |
101 +--------------------------------------------------------------------+
102
103 PURPOSE : This is the functional counterpart to the +CCFC AT command
104 which is responsible to set the parameters for call
105 forwarding supplementary services.
106
107 <reason> : reason for CF.
108 <mode> : CF mode.
109 <number> : number to be forwarded to.
110 <type> : type of number.
111 <class> : class of calls.
112 <subaddr>: subaddress of number.
113 <satype> : type of subaddress.
114 <time> : no reply time.
115 */
116
117 GLOBAL T_ACI_RETURN sAT_PlusCCFC ( T_ACI_CMD_SRC srcId,
118 T_ACI_CCFC_RSN reason,
119 T_ACI_CCFC_MOD mode,
120 CHAR* number,
121 T_ACI_TOA* type,
122 T_ACI_CLASS class_type,
123 CHAR* subaddr,
124 T_ACI_TOS* satype,
125 SHORT time)
126 {
127 SHORT sId1, sId2; /* holds service id */
128 UBYTE ssCd; /* holds ss code */
129 UBYTE bst1, bst2; /* holds basic service type */
130 UBYTE bs1, bs2; /* holds basic service */
131 UBYTE ton, tos; /* holds type of number/subaddress */
132 UBYTE npi, oe; /* holds numbering plan/odd.even indicator */
133 BOOL mltyTrnFlg = FALSE; /* flags for multi transaction */
134 T_CLPTY_PRM *ccfc_cldPty;
135
136 #ifdef SIM_TOOLKIT
137 T_ACI_RETURN retVal;
138 #endif /* of SIM_TOOLKIT */
139
140 TRACE_FUNCTION ("sAT_PlusCCFC");
141
142 /*
143 *-------------------------------------------------------------------
144 * check command source
145 *-------------------------------------------------------------------
146 */
147 if(!cmh_IsVldCmdSrc (srcId))
148 {
149 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
150 return( AT_FAIL );
151 }
152
153 if( cmhPrm[srcId].ssCmdPrm.mltyTrnFlg NEQ 0 )
154 {
155 TRACE_EVENT("ssCmdPrm.mltyTrnFlg NEQ 0 !!! CCFC busy");
156 return( AT_BUSY );
157 }
158
159 /*
160 *-------------------------------------------------------------------
161 * check parameter <time>
162 *-------------------------------------------------------------------
163 */
164 if( time EQ ACI_NumParmNotPresent )
165 {
166 time = AT_CFNRY_DEF_TIME;
167 }
168 else if (time < CCFC_TIME_MIN AND time >= 1)
169 {
170 /* 07.07 allows [1...30] for time while
171 09.02 allows [5...30]. So map [1..4] to 5 */
172 time = CCFC_TIME_MIN;
173 }
174 else if( time > CCFC_TIME_MAX OR time < CCFC_TIME_MIN )
175 {
176 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
177 return( AT_FAIL );
178 }
179
180 /*
181 *-------------------------------------------------------------------
182 * check parameter <reason>
183 *-------------------------------------------------------------------
184 */
185 switch( reason )
186 {
187 case( CCFC_RSN_Uncond ): ssCd = SS_CD_CFU; break;
188 case( CCFC_RSN_Busy ): ssCd = SS_CD_CFB; break;
189 case( CCFC_RSN_NoReply ): ssCd = SS_CD_CFNRY; break;
190 case( CCFC_RSN_NotReach ): ssCd = SS_CD_CFNRC; break;
191 case( CCFC_RSN_Forward ): ssCd = SS_CD_ALL_FWSS; break;
192 case( CCFC_RSN_CondForward ): ssCd = SS_CD_ALL_CFWSS; break;
193
194 case( CCFC_RSN_NotPresent ):
195 default:
196 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
197 return( AT_FAIL );
198 }
199
200 /*
201 *-------------------------------------------------------------------
202 * check parameter <class>
203 *-------------------------------------------------------------------
204 */
205 if( !cmhSS_CheckClass( class_type, &bs1, &bst1, &bs2, &bst2, &mltyTrnFlg ))
206 {
207 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
208 return( AT_FAIL );
209 }
210
211 /* SIM TOOLKIT & FDN HANDLING */
212
213 retVal = cmhSS_CF_SAT_Handle( srcId, reason, mode, number, type, class_type, subaddr, satype, time);
214
215 if( retVal NEQ AT_CMPL )
216 return( retVal );
217
218
219
220
221
222 /*
223 *-------------------------------------------------------------------
224 * check parameter <class> against possible ALS-Lock
225 *-------------------------------------------------------------------
226 */
227 if ((ALSlock EQ ALS_MOD_SPEECH AND class_type EQ CLASS_AuxVce) OR
228 (ALSlock EQ ALS_MOD_AUX_SPEECH AND class_type NEQ CLASS_AuxVce))
229 {
230 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_AlsLock );
231 return( AT_FAIL );
232 }
233
234 /*
235 *-------------------------------------------------------------------
236 * get a new service table entry
237 *-------------------------------------------------------------------
238 */
239 sId1 = psaSS_stbNewEntry();
240
241 if( sId1 EQ NO_ENTRY )
242 {
243 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_SrvTabFull );
244 return( AT_FAIL );
245 }
246
247 sId2 = NO_ENTRY;
248
249 if( mltyTrnFlg )
250 {
251 ssShrdPrm.stb[sId1].ntryUsdFlg = TRUE;
252
253 sId2 = psaSS_stbNewEntry();
254
255 if( sId2 EQ NO_ENTRY )
256 {
257 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_SrvTabFull );
258 return( AT_FAIL );
259 }
260 }
261
262 /*
263 *-------------------------------------------------------------------
264 * check parameter <mode>
265 *-------------------------------------------------------------------
266 */
267 switch( mode )
268 {
269 /*
270 *---------------------------------------------------------------
271 * enable, disable and erase call forwarding service
272 *---------------------------------------------------------------
273 */
274 case( CCFC_MOD_Disable ):
275 case( CCFC_MOD_Enable ):
276 case( CCFC_MOD_Erasure ):
277
278 CCD_START;
279
280 if( mode EQ CCFC_MOD_Disable )
281 psaSS_asmDeactivateSS( ssCd, bst1, bs1 );
282
283 else if( mode EQ CCFC_MOD_Enable )
284 psaSS_asmActivateSS( ssCd, bst1, bs1 );
285
286 else if( mode EQ CCFC_MOD_Erasure )
287 psaSS_asmEraseSS( ssCd, bst1, bs1 );
288
289 ssShrdPrm.stb[sId1].ntryUsdFlg = TRUE;
290 ssShrdPrm.stb[sId1].ssCode = ssCd;
291 ssShrdPrm.stb[sId1].srvOwn = srcId;
292 ssShrdPrm.stb[sId1].ClassType = class_type; /* the complete classes defined by the user */
293
294 /* start first transaction */
295 ssShrdPrm.stb[sId1].curCmd = AT_CMD_CCFC;
296
297 cmhSS_flagTrn( sId1, &(cmhPrm[srcId].ssCmdPrm.mltyTrnFlg));
298 psaSS_NewTrns(sId1);
299
300 if( mltyTrnFlg )
301 {
302 if( mode EQ CCFC_MOD_Disable )
303 psaSS_asmDeactivateSS( ssCd, bst2, bs2 );
304
305 else if( mode EQ CCFC_MOD_Enable )
306 psaSS_asmActivateSS( ssCd, bst2, bs2 );
307
308 else if( mode EQ CCFC_MOD_Erasure )
309 psaSS_asmEraseSS( ssCd, bst2, bs2 );
310
311 ssShrdPrm.stb[sId2].ntryUsdFlg = TRUE;
312 ssShrdPrm.stb[sId2].ssCode = ssCd;
313 ssShrdPrm.stb[sId2].srvOwn = srcId;
314 ssShrdPrm.stb[sId2].ClassType = class_type; /* the complete classes defined by the user */
315
316 /* start second transaction */
317 ssShrdPrm.stb[sId2].curCmd = AT_CMD_CCFC;
318
319 cmhSS_flagTrn( sId2, &(ssShrdPrm.mltyTrnFlg)); /* only for the second one */
320 cmhSS_flagTrn( sId2, &(cmhPrm[srcId].ssCmdPrm.mltyTrnFlg));
321
322 psaSS_NewTrns(sId2);
323 }
324
325 CCD_END;
326 break;
327
328 /*
329 *---------------------------------------------------------------
330 * register call forwarding service
331 *---------------------------------------------------------------
332 */
333 case( CCFC_MOD_Register ):
334
335 if(number EQ NULL)
336 {
337 TRACE_EVENT("ERROR: cannot register CCFC without a number");
338 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
339 return( AT_FAIL );
340 }
341 MALLOC(ccfc_cldPty, sizeof(T_CLPTY_PRM));
342 cmhCC_init_cldPty( ccfc_cldPty );
343
344 cmh_bldCalPrms( number, ccfc_cldPty );
345
346 /* check for TOA default */
347 if(type EQ NULL)
348 {
349 ton = ccfc_cldPty->ton;
350 npi = ccfc_cldPty->npi;
351 }
352 else if(type->ton EQ TON_NotPresent OR
353 type->npi EQ NPI_NotPresent)
354 {
355 ton = ccfc_cldPty->ton;
356 npi = ccfc_cldPty->npi;
357 }
358 else
359 {
360 ton = type->ton;
361 npi = type->npi;
362 }
363
364 /* check for TOS default */
365 if(satype EQ NULL)
366 {
367 tos = TOS_X213;
368 oe = OEI_EVEN;
369 }
370 else if(satype->tos EQ TOS_NotPresent OR
371 satype->oe EQ OE_NotPresent)
372 {
373 tos = TOS_X213;
374 oe = OEI_EVEN;
375 }
376 else
377 {
378 tos = satype -> tos;
379 oe = satype -> oe;
380 }
381
382 if(subaddr EQ NULL AND
383 ccfc_cldPty->sub[0] NEQ 0) /* if not set by user AND number contained a subaddress */
384 {
385 subaddr = (CHAR *)ccfc_cldPty->sub;
386 }
387
388 CCD_START;
389
390 psaSS_asmRegisterSS( ssCd, bst1, bs1,
391 ton, npi, (UBYTE*)ccfc_cldPty->num, tos, oe, (UBYTE *)subaddr, (UBYTE)time );
392
393 ssShrdPrm.stb[sId1].ntryUsdFlg = TRUE;
394 ssShrdPrm.stb[sId1].ssCode = ssCd;
395 ssShrdPrm.stb[sId1].srvOwn = srcId;
396
397 /* start first transaction */
398 ssShrdPrm.stb[sId1].curCmd = AT_CMD_CCFC;
399 cmhSS_flagTrn( sId1, &(cmhPrm[srcId].ssCmdPrm.mltyTrnFlg));
400 psaSS_NewTrns(sId1);
401
402 if( mltyTrnFlg )
403 {
404 psaSS_asmRegisterSS( ssCd, bst2, bs2,
405 ton, npi, (UBYTE*)ccfc_cldPty->num, tos, oe, (UBYTE *)subaddr, (UBYTE)time );
406
407 ssShrdPrm.stb[sId2].ntryUsdFlg = TRUE;
408 ssShrdPrm.stb[sId2].ssCode = ssCd;
409 ssShrdPrm.stb[sId2].srvOwn = srcId;
410
411 /* start second transaction */
412 ssShrdPrm.stb[sId2].curCmd = AT_CMD_CCFC;
413 cmhSS_flagTrn( sId2, &(ssShrdPrm.mltyTrnFlg)); /* only for the second one */
414 cmhSS_flagTrn( sId2, &(cmhPrm[srcId].ssCmdPrm.mltyTrnFlg));
415 psaSS_NewTrns(sId2);
416 }
417 MFREE(ccfc_cldPty);
418 CCD_END;
419 break;
420
421 /*
422 *---------------------------------------------------------------
423 * unexpected mode
424 *---------------------------------------------------------------
425 */
426 case( CCFC_MOD_NotPresent ):
427 default:
428
429 ssShrdPrm.stb[sId1].ntryUsdFlg = FALSE;
430 if( sId2 NEQ NO_ENTRY ) ssShrdPrm.stb[sId2].ntryUsdFlg = FALSE;
431
432 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
433 return( AT_FAIL );
434 }
435
436 /*
437 *-------------------------------------------------------------------
438 * log command execution
439 *-------------------------------------------------------------------
440 */
441 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
442 {
443 T_ACI_CLOG cmdLog; /* holds logging info */
444
445 cmdLog.atCmd = AT_CMD_CCFC;
446 cmdLog.cmdType = CLOG_TYPE_Set;
447 cmdLog.retCode = AT_EXCT;
448 cmdLog.cId = ACI_NumParmNotPresent;
449 cmdLog.sId = sId1+1;
450 cmdLog.cmdPrm.sCCFC.srcId = srcId;
451 cmdLog.cmdPrm.sCCFC.reason = reason;
452 cmdLog.cmdPrm.sCCFC.mode = mode;
453 cmdLog.cmdPrm.sCCFC.number = number;
454 cmdLog.cmdPrm.sCCFC.type = type;
455 cmdLog.cmdPrm.sCCFC.class_type = class_type;
456 cmdLog.cmdPrm.sCCFC.subaddr = subaddr;
457 cmdLog.cmdPrm.sCCFC.satype = satype;
458 cmdLog.cmdPrm.sCCFC.time = time;
459
460 rAT_PercentCLOG( &cmdLog );
461 }
462 #endif
463
464 return( AT_EXCT );
465 }
466
467 /*
468 +--------------------------------------------------------------------+
469 | PROJECT : GSM-PS (6147) MODULE : CMH_SSS |
470 | STATE : code ROUTINE : sAT_PlusCLCK |
471 +--------------------------------------------------------------------+
472
473 PURPOSE : This is the functional counterpart to the +CLCK AT command
474 which is responsible to set the parameters for call
475 barring supplementary services.
476
477 <fac> : CB facility.
478 <mode> : CB mode.
479 <passwd> : password for CB facility.
480 <class_type>: class of calls.
481 */
482 LOCAL BOOL check_sat_cb_pwd_required(UBYTE ssCd, CHAR *passwd)
483 {
484 #ifdef SIM_TOOLKIT
485 SHORT ss_id = NO_ENTRY;
486 T_OWN owner;
487
488 /* Special case: there was an SS (by STK) transaction running.
489 It returned get password, handle the password for this transaction */
490
491 TRACE_FUNCTION ("check_sat_ss_pwd_required ()");
492
493 /* satShrdPrm.sId_pwd_requested will be reset by any mnss_end_ind
494 to be sure it has been reset.
495 This means: user has to give password right after error has been
496 shown. */
497 ss_id = satShrdPrm.sId_pwd_requested;
498 if( ss_id EQ NO_ENTRY)
499 {
500 return(FALSE);
501 }
502
503 if( ssShrdPrm.stb[ss_id].srvOwn NEQ OWN_SAT )
504 {
505 satShrdPrm.sId_pwd_requested = NO_ENTRY;
506 return(FALSE);
507 }
508 TRACE_EVENT("Password required during a SAT session");
509
510 if( ssShrdPrm.stb[ss_id].curCmd NEQ KSD_CMD_CB )
511 {
512 TRACE_EVENT_P1("Wrong command context: %d", ssShrdPrm.stb[ss_id].curCmd);
513 satShrdPrm.sId_pwd_requested = NO_ENTRY;
514 return(FALSE);
515 }
516 owner = ssShrdPrm.stb[ss_id].srvOwn;
517
518 if(ssShrdPrm.stb[ss_id].ssCode EQ ssCd)
519 {
520 /* store for later use (as usual)*/
521 strncpy
522 (
523 (char *) cmhPrm[owner].ssCmdPrm.CXXXpwd,
524 (char *) passwd,
525 MAX_PWD_NUM
526 );
527 cmhPrm[owner].ssCmdPrm.CXXXpwd[MAX_PWD_NUM] = '\0';
528 psaSS_asmVerifyPWD( cmhPrm[owner].ssCmdPrm.CXXXpwd);
529 psaSS_CntTrns(ss_id);
530 satShrdPrm.sId_pwd_requested = NO_ENTRY;
531 return(TRUE); /* as pwd only needed for SAT session*/
532 }
533 else
534 {
535 TRACE_EVENT_P1("Wrong Service type: %d", ssCd);
536 }
537 satShrdPrm.sId_pwd_requested = NO_ENTRY;
538 #endif /* SIM_TOOLKIT */
539 return(FALSE);
540 }
541
542 /*
543 +------------------------------------------------------------------------------
544 | Function : sAT_PlusCLCK
545 +------------------------------------------------------------------------------
546 | Description : This is the functional counterpart to the +CLCK AT command
547 | which is responsible to set the parameters for call
548 | barring supplementary services. also fo locking and unlocking ME for categories
549 | Networl lock, Network Subset lock, Service Provider Lock, Corporate Lock, SIM Lock
550 |
551 | Parameters : <fac> : CB facility.
552 | <mode> : CB mode.
553 | <passwd> : password for CB facility.
554 | <class_type>: class of calls.
555 |
556 | Return : AT_FAIL - execution of command failed
557 | AT_CMPL - execution of command completed
558 | AT_EXCT - execution of command is in progress
559 | AT_BUSY - execution of command is rejected due
560 |
561 +------------------------------------------------------------------------------
562 */
563
564 GLOBAL T_ACI_RETURN sAT_PlusCLCK ( T_ACI_CMD_SRC srcId,
565 T_ACI_CLCK_FAC fac,
566 T_ACI_CLCK_MOD mode,
567 CHAR * passwd,
568 T_ACI_CLASS class_type)
569 {
570 SHORT sId1, sId2; /* holds service id */
571 UBYTE ssCd; /* holds ss code */
572 UBYTE bst1, bst2; /* holds basic service type */
573 UBYTE bs1, bs2; /* holds basic service */
574 BOOL mltyTrnFlg = FALSE; /* flags for multi transaction */
575 #ifdef SIM_PERS
576 T_SIMLOCK_TYPE slocktype;
577 T_SIMLOCK_STATUS rlockstatus;
578 T_SIMLOCK_TYPE lock_type;
579 T_SIMLOCK_TYPE last_lock_type;
580 #endif
581 SHORT psasim_ret;
582 BOOL done = FALSE;
583 #ifdef SIM_PERS
584 T_ACI_CME_ERR err_code = CME_ERR_NotPresent; /* code holding the correct error code calculated */
585 UBYTE cmdBuf; /* buffers current command */
586 #endif
587 #ifdef SIM_PERS
588 T_OPER_RET_STATUS fcResetStat; /*holds Failure Counter Reset Return Status Introduced on 11/03/2005*/
589 T_SIMLOCK_STATUS retSlStatus; /* holds return code */
590 #endif
591 T_ACI_RETURN retVal;
592
593 TRACE_FUNCTION ("sAT_PlusCLCK ()");
594
595 /*
596 *-------------------------------------------------------------------
597 * check command source
598 *-------------------------------------------------------------------
599 */
600 if(!cmh_IsVldCmdSrc (srcId))
601 {
602 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
603 return( AT_FAIL );
604 }
605
606 /*
607 *-------------------------------------------------------------------
608 * check parameter <fac>
609 *-------------------------------------------------------------------
610 */
611 switch( fac )
612 {
613 case( CLCK_FAC_Ao ): ssCd = SS_CD_BAOC; break;
614 case( CLCK_FAC_Oi ): ssCd = SS_CD_BOIC; break;
615 case( CLCK_FAC_Ox ): ssCd = SS_CD_BOICXH; break;
616 case( CLCK_FAC_Ai ): ssCd = SS_CD_BAIC; break;
617 case( CLCK_FAC_Ir ): ssCd = SS_CD_BICRM; break;
618 case( CLCK_FAC_Ab ): ssCd = SS_CD_ALL_CBSS; break;
619 case( CLCK_FAC_Ag ): ssCd = SS_CD_BOC; break;
620 case( CLCK_FAC_Ac ): ssCd = SS_CD_BIC; break;
621
622 case( CLCK_FAC_Sc ):
623 case( CLCK_FAC_Fd ):
624 #ifdef SIM_PERS
625 case( CLCK_FAC_Pn ):
626 case( CLCK_FAC_Pu ):
627 case( CLCK_FAC_Pc ):
628 case( CLCK_FAC_Pp ):
629 case( CLCK_FAC_Pf ):
630 case( CLCK_FAC_Ps ):
631 #endif
632 case( CLCK_FAC_Al ):
633 #ifdef SIM_PERS
634 case( CLCK_FAC_Fc ):
635 case(CLCK_FAC_Fcm):
636 #endif
637 ssCd = NOT_PRESENT_8BIT; break;
638
639 case( CLCK_FAC_NotPresent ):
640 default:
641
642 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
643 return( AT_FAIL );
644 }
645
646 /*
647 *-------------------------------------------------------------------
648 * if action is related to SS
649 *-------------------------------------------------------------------
650 */
651 if( ssCd NEQ NOT_PRESENT_8BIT )
652 {
653 /*
654 *-------------------------------------------------------------------
655 * check parameter <passwd>
656 *-------------------------------------------------------------------
657 */
658 if( passwd AND strlen( passwd ) > MAX_PWD_NUM )
659 {
660 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
661 return( AT_FAIL );
662 }
663
664 /*
665 *-------------------------------------------------------------------
666 * check parameter <class>
667 *-------------------------------------------------------------------
668 */
669 if( !cmhSS_CheckCbClass( class_type, &bs1, &bst1, &bs2, &bst2, &mltyTrnFlg ))
670 {
671 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
672 return( AT_FAIL );
673 }
674
675 if( cmhPrm[srcId].ssCmdPrm.mltyTrnFlg NEQ 0 )
676 return( AT_BUSY );
677
678 /*
679 *-------------------------------------------------------------------
680 * check combination of <mode> and <fac>
681 *-------------------------------------------------------------------
682 */
683 if((fac EQ CLCK_FAC_Ab OR fac EQ CLCK_FAC_Ag OR fac EQ CLCK_FAC_Ac)
684 AND mode NEQ CLCK_MOD_Unlock )
685 {
686 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
687 return( AT_FAIL );
688 }
689
690 /*** Shangai's labs tessession fix: adapted to this version from 1.3.3 (TCS 2.0) ****/
691 /* Special case: there was an SS (by STK) transaction running.
692 It returned get password, handle the password for this transaction */
693 done = check_sat_cb_pwd_required(ssCd, passwd);
694 if(done)
695 {
696 return(AT_CMPL); /* as pwd only needed for SAT session*/
697 }
698 /* End fix */
699
700
701 /* SIM TOOLKIT & FDN HANDLING */
702 retVal = cmhSS_Call_Barr_SAT_Handle( srcId, mode, fac, passwd, class_type);
703
704 if( retVal NEQ AT_CMPL )
705 return( retVal );
706
707 /*
708 *-------------------------------------------------------------------
709 * get a new service table entry
710 *-------------------------------------------------------------------
711 */
712 sId1 = psaSS_stbNewEntry();
713
714 if( sId1 EQ NO_ENTRY )
715 {
716 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_SrvTabFull );
717 return( AT_FAIL );
718 }
719
720 sId2 = NO_ENTRY;
721
722 if( mltyTrnFlg )
723 {
724 ssShrdPrm.stb[sId1].ntryUsdFlg = TRUE;
725 sId2 = psaSS_stbNewEntry();
726
727 if( sId2 EQ NO_ENTRY )
728 {
729 ssShrdPrm.stb[sId1].ntryUsdFlg = FALSE;
730 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_SrvTabFull );
731 return( AT_FAIL );
732 }
733 }
734
735 /*
736 *-------------------------------------------------------------------
737 * check parameter <mode>
738 *-------------------------------------------------------------------
739 */
740 switch( mode )
741 {
742 /*
743 *---------------------------------------------------------------
744 * lock and unlock call barring service
745 *---------------------------------------------------------------
746 */
747 case( CLCK_MOD_Unlock ):
748 case( CLCK_MOD_Lock ):
749
750 CCD_START;
751
752 if( mode EQ CLCK_MOD_Unlock )
753 psaSS_asmDeactivateSS( ssCd, bst1, bs1 );
754
755 else if( mode EQ CLCK_MOD_Lock )
756 psaSS_asmActivateSS( ssCd, bst1, bs1 );
757
758 ssShrdPrm.stb[sId1].ntryUsdFlg = TRUE;
759 ssShrdPrm.stb[sId1].ssCode = ssCd;
760 ssShrdPrm.stb[sId1].srvOwn = srcId;
761
762 /* start first transaction */
763 ssShrdPrm.stb[sId1].curCmd = AT_CMD_CLCK;
764 cmhSS_flagTrn( sId1, &(cmhPrm[srcId].ssCmdPrm.mltyTrnFlg));
765 psaSS_NewTrns(sId1);
766
767 if( mltyTrnFlg )
768 {
769 if( mode EQ CLCK_MOD_Unlock )
770 psaSS_asmDeactivateSS( ssCd, bst2, bs2 );
771
772 else if( mode EQ CLCK_MOD_Lock )
773 psaSS_asmActivateSS( ssCd, bst2, bs2 );
774
775 ssShrdPrm.stb[sId2].ntryUsdFlg = TRUE;
776 ssShrdPrm.stb[sId2].ssCode = ssCd;
777 ssShrdPrm.stb[sId2].srvOwn = srcId;
778
779 /* start second transaction */
780 ssShrdPrm.stb[sId2].curCmd = AT_CMD_CLCK;
781 cmhSS_flagTrn( sId2, &(ssShrdPrm.mltyTrnFlg)); /* only for the second one */
782 cmhSS_flagTrn( sId2, &(cmhPrm[srcId].ssCmdPrm.mltyTrnFlg));
783 psaSS_NewTrns(sId2);
784 }
785 CCD_END;
786 break;
787
788 /*
789 *---------------------------------------------------------------
790 * unexpected mode
791 *---------------------------------------------------------------
792 */
793 case( CLCK_MOD_NotPresent ):
794 default:
795
796 ssShrdPrm.stb[sId1].ntryUsdFlg = FALSE;
797 if( sId2 NEQ NO_ENTRY ) ssShrdPrm.stb[sId2].ntryUsdFlg = FALSE;
798
799 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
800 return( AT_FAIL );
801 }
802
803 /*
804 *-------------------------------------------------------------------
805 * store password for later use
806 *-------------------------------------------------------------------
807 */
808 if( passwd )
809 {
810 strncpy
811 (
812 (char *) cmhPrm[srcId].ssCmdPrm.CXXXpwd,
813 (char *) passwd,
814 MAX_PWD_NUM
815 );
816 cmhPrm[srcId].ssCmdPrm.CXXXpwd[MAX_PWD_NUM] = '\0';
817 }
818 }
819
820 /*
821 *-------------------------------------------------------------------
822 * if action is related to SIM
823 *-------------------------------------------------------------------
824 */
825 else
826 {
827 if( simEntStat.curCmd NEQ AT_CMD_NONE )
828 return( AT_BUSY );
829
830 switch (fac)
831 {
832 /*
833 *---------------------------------------------------------------
834 * access PIN 1
835 *---------------------------------------------------------------
836 */
837 case CLCK_FAC_Sc:
838 switch( mode )
839 {
840 case( CLCK_MOD_Unlock ):
841 case( CLCK_MOD_Lock ):
842 if (simShrdPrm.PINStat EQ PS_PUK1)
843 {
844 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_SimPukReq);
845 return( AT_FAIL );
846 }
847 if (!psaSIM_ChkSIMSrvSup(SRV_CHV1_Disable))
848 {
849 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow);
850 return( AT_FAIL );
851 }
852 if( !passwd OR (strlen( passwd ) > PIN_LEN) )
853 {
854 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
855 return( AT_FAIL );
856 }
857 if( strlen( passwd ) < MIN_PIN_LEN OR
858 strlen( passwd ) > PIN_LEN )
859 {
860 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
861 return( AT_FAIL );
862 }
863 cmhSIM_FillInPIN ( passwd, simShrdPrm.setPrm[srcId].curPIN, PIN_LEN );
864 simShrdPrm.setPrm[srcId].PINType = PHASE_2_PIN_1;
865 simEntStat.curCmd = AT_CMD_CLCK;
866 simEntStat.entOwn = simShrdPrm.owner = srcId;
867
868 if( mode EQ CLCK_MOD_Lock )
869 {
870 psasim_ret = psaSIM_EnablePIN( );
871 }
872 else /* if( mode EQ CLCK_MOD_Unlock ) */
873 {
874 psasim_ret = psaSIM_DisablePIN( );
875 }
876
877 if(psasim_ret < 0)
878 {
879 TRACE_EVENT( "FATAL RETURN psaSIM in +CLCK" );
880 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
881 return( AT_FAIL );
882 }
883 break;
884
885 default:
886
887 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
888 return( AT_FAIL );
889 }
890 break;
891
892 /*
893 *---------------------------------------------------------------
894 * access fixed dialling feature
895 *---------------------------------------------------------------
896 */
897 case CLCK_FAC_Fd:
898 if (!psaSIM_ChkSIMSrvSup(SRV_FDN))
899 {
900 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow);
901 return( AT_FAIL );
902 }
903 /*
904 Check the SIM PIN States before sending any request to SIM
905 */
906 if ( simShrdPrm.PINStat EQ PS_PUK2 )
907 {
908 TRACE_EVENT("sAT_PlusCLCK_ME(): SIM PIN-2 Bolcked PUK-2 Required");
909 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_SimPuk2Req );
910 return( AT_FAIL );
911 }
912
913 /*
914 According to the standards 27.007 Sec 7.4 for facility "FDN":
915 if PIN2 authentication has not been done during the current session,
916 PIN2 is required as <passwd>; Below condition will do the
917 same to check to see whether <passwd> is required / not.
918 */
919
920 if ( simShrdPrm.pn2Stat EQ PS_PIN2 OR
921 simShrdPrm.pn2Stat EQ NO_VLD_PS )
922 {
923 if ( simShrdPrm.PINStat EQ PS_RDY OR
924 simShrdPrm.PINStat EQ PS_PIN2 )
925 {
926 simShrdPrm.PINStat = PS_PIN2;
927 }
928 else
929 {
930 TRACE_EVENT("sAT_PlusCLCK_ME(): SIM PIN State is NOT Valid");
931 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_SimFail );
932 return( AT_FAIL );
933 }
934
935 if( !passwd OR ( strlen( passwd ) > PIN_LEN OR
936 strlen( passwd ) < MIN_PIN_LEN ) )
937 {
938 TRACE_EVENT("sAT_PlusCLCK_ME(): SIM PIN-2 Password is Omitted");
939 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_SimPin2Req );
940 return( AT_FAIL );
941 }
942 }
943
944 /*
945 * test class_type whether it is supported and store it temporarily for further use
946 */
947 if( class_type EQ CLASS_NotPresent OR /* default case */
948 class_type EQ CLASS_VceDatFax ) /* case 7 */
949 {
950 simShrdPrm.classFDN = CLASS_VceDatFax;
951 }
952 else if ( class_type EQ CLASS_VceDatFaxSms ) /* case 15 */
953 {
954 simShrdPrm.classFDN = CLASS_VceDatFaxSms; /* set global class type */
955 }
956 else /* parameter not supported */
957 {
958 TRACE_EVENT( "class type not supported, +CLCK rejected" );
959 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotSupp );
960 return( AT_FAIL );
961 }
962 simShrdPrm.setPrm[srcId].actProc = (mode EQ CLCK_MOD_Lock)?
963 SIM_FDN_ENABLE:SIM_FDN_DISABLE;
964
965 simEntStat.curCmd = AT_CMD_CLCK;
966 simEntStat.entOwn = simShrdPrm.owner = srcId;
967
968 if( psaSIM_ActivateSIM() < 0 ) /* activate SIM card */
969 {
970 TRACE_EVENT( "FATAL RETURN psaSIM in +CLCK" );
971 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
972 return( AT_FAIL );
973 }
974
975 /* store PIN 2 for later use */
976 /* if( passwd ) ... already checked in the beginning! */
977 cmhSIM_FillInPIN ( passwd, simShrdPrm.setPrm[srcId].curPIN, PIN_LEN );
978
979 break;
980
981 /*
982 *---------------------------------------------------------------
983 * lock ALS setting with PIN2
984 *---------------------------------------------------------------
985 */
986 case CLCK_FAC_Al:
987
988 if( !passwd OR ( strlen( passwd ) > PIN_LEN OR
989 strlen( passwd ) < MIN_PIN_LEN ) )
990 {
991 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
992 return( AT_FAIL );
993 }
994
995 cmhSIM_FillInPIN ( passwd, simShrdPrm.setPrm[srcId].curPIN, PIN_LEN );
996
997 simShrdPrm.setPrm[srcId].actProc = (mode EQ CLCK_MOD_Lock)?
998 SIM_ALS_LOCK:SIM_ALS_UNLOCK;
999
1000 simShrdPrm.setPrm[srcId].PINType = PHASE_2_PIN_2;
1001
1002 simEntStat.curCmd = AT_CMD_CLCK;
1003 simEntStat.entOwn = simShrdPrm.owner = srcId;
1004
1005 if( psaSIM_VerifyPIN() < 0 ) /* check PIN2 card */
1006 {
1007 TRACE_EVENT( "FATAL RETURN psaSIM in +CLCK" );
1008 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
1009 return( AT_FAIL );
1010 }
1011
1012 break;
1013
1014 /*
1015 *---------------------------------------------------------------
1016 * ME Personalisation
1017 *---------------------------------------------------------------
1018 */
1019 #ifdef SIM_PERS
1020 case CLCK_FAC_Pn:
1021 case CLCK_FAC_Pu:
1022 case CLCK_FAC_Pp:
1023 case CLCK_FAC_Pc:
1024 case CLCK_FAC_Ps:
1025 case CLCK_FAC_Pf:
1026
1027 switch (fac)
1028 {
1029 case CLCK_FAC_Pn: slocktype = SIMLOCK_NETWORK; break;
1030 case CLCK_FAC_Pu: slocktype = SIMLOCK_NETWORK_SUBSET; break;
1031 case CLCK_FAC_Pp: slocktype = SIMLOCK_SERVICE_PROVIDER; break;
1032 case CLCK_FAC_Pc: slocktype = SIMLOCK_CORPORATE; break;
1033 case CLCK_FAC_Ps: slocktype = SIMLOCK_SIM; break;
1034 case CLCK_FAC_Pf: slocktype = SIMLOCK_FIRST_SIM; break;
1035 default: slocktype = SIMLOCK_NETWORK;
1036 }
1037
1038 /*
1039 * Check whether sim is inserted or not before trying to lock/Unlock
1040 */
1041
1042 if(simShrdPrm.SIMStat EQ SS_OK)
1043 {
1044 rlockstatus = (mode EQ CLCK_MOD_Lock)?
1045 aci_slock_lock(slocktype, passwd):
1046 aci_slock_unlock(slocktype, passwd);
1047 }
1048 else
1049 {
1050 /*
1051 * Sim is not present: unlocking is allowed if No_SIM_Unlock flag is OFF
1052 */
1053 aci_slock_set_CFG();
1054 if(cfg_data EQ NULL)
1055 {
1056 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown);
1057 return( AT_FAIL );
1058 }
1059 if( (mode EQ CLCK_MOD_Unlock) AND !(cfg_data->Flags & SEC_DRV_HDR_FLAG_No_SIM_Unlock))
1060 {
1061 MFREE(cfg_data);
1062 rlockstatus = aci_slock_unlock(slocktype, passwd);
1063 }
1064 else
1065 {
1066 MFREE(cfg_data);
1067 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_SimNotIns);
1068 return( AT_FAIL );
1069 }
1070 }
1071 cmdBuf = AT_CMD_CLCK ;
1072 if ( ( (mode EQ CLCK_MOD_Lock) AND (rlockstatus EQ SIMLOCK_ENABLED) ) OR
1073 ( (mode EQ CLCK_MOD_Unlock) AND (rlockstatus EQ SIMLOCK_DISABLED) ) )
1074 {
1075 return (AT_CMPL);
1076 }
1077 else
1078 {
1079 if (rlockstatus EQ SIMLOCK_BLOCKED) /* Special error description on blocked personalisation */
1080 {
1081 aci_slock_set_CFG();
1082 if(cfg_data EQ NULL)
1083 {
1084 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown);
1085 return( AT_FAIL );
1086 }
1087 aci_set_cme_error(slocktype);
1088 MFREE(cfg_data);
1089 }
1090 else if(rlockstatus EQ SIMLOCK_WAIT)
1091 {
1092 simEntStat.curCmd = AT_CMD_CLCK;
1093 simEntStat.entOwn = simShrdPrm.owner = srcId;
1094 AciSLockShrd.check_lock = SIMLOCK_CHECK_LOCK;
1095 AciSLockShrd.lock_type = slocktype;
1096 AciSLockShrd.lock_passwd = passwd;
1097
1098 return( AT_EXCT);
1099 }
1100 else
1101 {
1102 err_code =CME_ERR_WrongPasswd;
1103 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_WrongPasswd );
1104 }
1105
1106 return( AT_FAIL );
1107 }
1108
1109 /*
1110 *---------------------------------------------------------------
1111 * FC RESET Handling
1112 Added on 11/03/2005
1113 *---------------------------------------------------------------
1114 */
1115 case CLCK_FAC_Fc:
1116 fcResetStat=aci_slock_reset_fc(passwd);
1117 simEntStat.curCmd = AT_CMD_CLCK;
1118 if (fcResetStat EQ OPER_SUCCESS)
1119 {
1120 aci_slock_set_CFG();
1121 if(cfg_data EQ NULL)
1122 {
1123 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown);
1124 return( AT_FAIL );
1125 }
1126 aci_slock_init();
1127 AciSLockShrd.check_lock = SIMLOCK_CHECK_RESET_FC;
1128 retSlStatus = aci_slock_checkpersonalisation(AciSLockShrd.current_lock);
1129
1130 switch(retSlStatus)
1131 {
1132 case SIMLOCK_ENABLED :
1133 return( AT_CMPL);
1134 case SIMLOCK_BLOCKED :
1135 return( AT_FAIL);
1136 case SIMLOCK_WAIT :
1137 return (AT_EXCT);
1138
1139 }
1140
1141
1142 }
1143 else if (fcResetStat EQ OPER_FAIL)
1144 {
1145 cmdBuf = simEntStat.curCmd;
1146 simEntStat.curCmd = AT_CMD_NONE;
1147 err_code =CME_ERR_WrongPasswd;
1148 R_AT( RAT_CME, simEntStat.entOwn )
1149 ( cmdBuf, err_code );
1150 cmh_logRslt ( simEntStat.entOwn, RAT_CME, cmdBuf, -1, -1, err_code );
1151 return( AT_FAIL );
1152 }
1153
1154 case CLCK_FAC_Fcm:
1155 fcResetStat=aci_slock_reset_fc(passwd);
1156 if (fcResetStat EQ OPER_SUCCESS)
1157 {
1158 TRACE_FUNCTION(" AT_CMPL");
1159 return( AT_CMPL );
1160 }
1161 else
1162 {
1163 TRACE_FUNCTION(" AT_FAIL");
1164 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_WrongPasswd );
1165 return( AT_FAIL );
1166 }
1167 #endif //SIM_PERS
1168 /*
1169 *---------------------------------------------------------------
1170 * Error handling
1171 *---------------------------------------------------------------
1172 */
1173 default:
1174 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown );
1175 return( AT_FAIL );
1176 }
1177 }
1178
1179 /*
1180 *-------------------------------------------------------------------
1181 * log command execution
1182 *-------------------------------------------------------------------
1183 */
1184 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
1185 {
1186 T_ACI_CLOG cmdLog; /* holds logging info */
1187
1188 cmdLog.atCmd = AT_CMD_CLCK;
1189 cmdLog.cmdType = CLOG_TYPE_Set;
1190 cmdLog.retCode = AT_EXCT;
1191 cmdLog.cId = ACI_NumParmNotPresent;
1192 cmdLog.sId = (ssCd EQ NOT_PRESENT_8BIT)?
1193 ACI_NumParmNotPresent:/*lint -e(644)*/sId1+1;
1194 cmdLog.cmdPrm.sCLCK.srcId = srcId;
1195 cmdLog.cmdPrm.sCLCK.fac = fac;
1196 cmdLog.cmdPrm.sCLCK.mode = mode;
1197 cmdLog.cmdPrm.sCLCK.passwd = passwd;
1198 cmdLog.cmdPrm.sCLCK.class_type = class_type;
1199
1200 rAT_PercentCLOG( &cmdLog );
1201 }
1202 #endif
1203
1204 return( AT_EXCT );
1205 }
1206
1207 /*
1208 +--------------------------------------------------------------------+
1209 | PROJECT : GSM-PS (6147) MODULE : CMH_SSS |
1210 | STATE : code ROUTINE : sAT_PlusCPWD |
1211 +--------------------------------------------------------------------+
1212
1213 PURPOSE : This is the functional counterpart to the +CPWD AT command
1214 which is responsible to change the password for call
1215 barring supplementary services.
1216
1217 <fac> : CB facility.
1218 <oldpwd> : current password.
1219 <newpwd> : new password.
1220 */
1221
1222 GLOBAL T_ACI_RETURN sAT_PlusCPWD ( T_ACI_CMD_SRC srcId,
1223 T_ACI_CPWD_FAC fac,
1224 CHAR * oldpwd,
1225 CHAR * newpwd)
1226 {
1227 T_ACI_RETURN retCd = AT_FAIL; /* holds return code */
1228 UBYTE ssCd; /* holds ss code */
1229 SHORT sId; /* holds service id */
1230 #ifdef SIM_PERS
1231 T_SIMLOCK_TYPE slocktype;
1232 T_OPER_RET_STATUS status;
1233 #endif
1234 TRACE_FUNCTION ("sAT_PlusCPWD");
1235
1236 /*
1237 *-------------------------------------------------------------------
1238 * check password parameter
1239 *-------------------------------------------------------------------
1240 */
1241 if( !newpwd OR !oldpwd )
1242 {
1243 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1244 return( AT_FAIL );
1245 }
1246
1247 /*
1248 *-------------------------------------------------------------------
1249 * check parameter <fac>
1250 *-------------------------------------------------------------------
1251 */
1252 switch( fac )
1253 {
1254 /* All Baring Services share the same password so only SS_CD_ALL_CBSS is valid,
1255 everything else will be rejected by the network! */
1256 case( CPWD_FAC_Ao ):
1257 case( CPWD_FAC_Oi ):
1258 case( CPWD_FAC_Ox ):
1259 case( CPWD_FAC_Ai ):
1260 case( CPWD_FAC_Ir ):
1261 case( CPWD_FAC_Ab ):
1262 case( CPWD_FAC_Ag ):
1263 case( CPWD_FAC_Ac ): ssCd = SS_CD_ALL_CBSS; break;
1264
1265 case( CPWD_FAC_Sc ):
1266 case( CPWD_FAC_P2 ):
1267 #ifdef SIM_PERS
1268 case( CPWD_FAC_Pn ):
1269 case( CPWD_FAC_Pu ):
1270 case( CPWD_FAC_Pc ):
1271 case( CPWD_FAC_Pp ):
1272 case( CPWD_FAC_Pf ):
1273 case( CPWD_FAC_Ps ):
1274 #endif
1275 ssCd = NOT_PRESENT_8BIT; break;
1276
1277
1278 case( CPWD_FAC_NotPresent ):
1279 default:
1280
1281 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1282 return( AT_FAIL );
1283 }
1284
1285 /*
1286 *-------------------------------------------------------------------
1287 * if password relates to SS
1288 *-------------------------------------------------------------------
1289 */
1290 if( ssCd NEQ NOT_PRESENT_8BIT )
1291 {
1292 /*
1293 *-------------------------------------------------------------------
1294 * check parameter <oldpwd>
1295 *-------------------------------------------------------------------
1296 */
1297 if( strlen( newpwd ) > MAX_PWD_NUM OR
1298 strlen( oldpwd ) > MAX_PWD_NUM )
1299 {
1300 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1301 return( AT_FAIL );
1302 }
1303
1304 /*
1305 *-----------------------------------------------------------------
1306 * get a new service table entry to interrogate SS
1307 *-----------------------------------------------------------------
1308 */
1309 sId = psaSS_stbNewEntry();
1310
1311 if( sId EQ NO_ENTRY )
1312 {
1313 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_SrvTabFull );
1314 return( AT_FAIL );
1315 }
1316
1317 /*
1318 *-----------------------------------------------------------------
1319 * set up facility information element
1320 *-----------------------------------------------------------------
1321 */
1322 CCD_START;
1323
1324 psaSS_asmRegisterPWD( ssCd );
1325 /*
1326 *---------------------------------------------------------------
1327 * declare service table entry as used and the owner of the service
1328 *---------------------------------------------------------------
1329 */
1330 ssShrdPrm.stb[sId].ntryUsdFlg = TRUE;
1331 ssShrdPrm.stb[sId].ssCode = ssCd;
1332 ssShrdPrm.stb[sId].srvOwn = srcId;
1333
1334 /*
1335 *-----------------------------------------------------------------
1336 * start a new transaction
1337 *-----------------------------------------------------------------
1338 */
1339 ssShrdPrm.stb[sId].curCmd = AT_CMD_CPWD;
1340 psaSS_NewTrns(sId);
1341
1342 CCD_END;
1343
1344 /*
1345 *-----------------------------------------------------------------
1346 * store passwords for later use
1347 *-----------------------------------------------------------------
1348 */
1349 strncpy
1350 (
1351 (char *) cmhPrm[srcId].ssCmdPrm.CXXXpwd,
1352 (char *) oldpwd,
1353 MAX_PWD_NUM
1354 );
1355 cmhPrm[srcId].ssCmdPrm.CXXXpwd[MAX_PWD_NUM] = '\0';
1356
1357 strncpy
1358 (
1359 (char *) cmhPrm[srcId].ssCmdPrm.CXXXnewPwd,
1360 (char *) newpwd,
1361 MAX_PWD_NUM
1362 );
1363 cmhPrm[srcId].ssCmdPrm.CXXXnewPwd[MAX_PWD_NUM] = '\0';
1364
1365 strncpy
1366 (
1367 (char *) cmhPrm[srcId].ssCmdPrm.CXXXnewPwd2,
1368 (char *) newpwd,
1369 MAX_PWD_NUM
1370 );
1371 cmhPrm[srcId].ssCmdPrm.CXXXnewPwd2[MAX_PWD_NUM] = '\0';
1372 retCd = AT_EXCT;
1373 }
1374 else
1375 {
1376 /*
1377 *-------------------------------------------------------------------
1378 * if password relates to SIM
1379 *-------------------------------------------------------------------
1380 */
1381 switch (fac)
1382 {
1383 /*
1384 *---------------------------------------------------------------
1385 * change PIN 1 / PIN 2
1386 *---------------------------------------------------------------
1387 */
1388 case( CPWD_FAC_Sc ):
1389 case( CPWD_FAC_P2 ):
1390 if( simEntStat.curCmd NEQ AT_CMD_NONE )
1391 return( AT_BUSY );
1392
1393 if( strlen( newpwd ) > PIN_LEN OR
1394 strlen( newpwd ) < MIN_PIN_LEN OR
1395 strlen( oldpwd ) > PIN_LEN OR
1396 strlen( oldpwd ) < MIN_PIN_LEN )
1397 {
1398 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1399 return( AT_FAIL );
1400 }
1401
1402 if( simEntStat.curCmd NEQ AT_CMD_NONE )
1403 return( AT_BUSY );
1404
1405 cmhSIM_FillInPIN ( oldpwd, simShrdPrm.setPrm[srcId].curPIN, PIN_LEN );
1406 cmhSIM_FillInPIN ( newpwd, simShrdPrm.setPrm[srcId].newPIN, PIN_LEN );
1407
1408 simShrdPrm.setPrm[srcId].PINType = (fac EQ CPWD_FAC_Sc)?
1409 PHASE_2_PIN_1:PHASE_2_PIN_2;
1410
1411 simEntStat.curCmd = AT_CMD_CPWD;
1412 simEntStat.entOwn = simShrdPrm.owner = srcId;
1413
1414 if( psaSIM_ChangePIN() < 0 ) /* change PIN */
1415 {
1416 TRACE_EVENT( "FATAL RETURN psaSIM in +CPWD" );
1417 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
1418 return( AT_FAIL );
1419 }
1420 retCd = AT_EXCT;
1421 break;
1422
1423 #ifdef SIM_PERS
1424 case( CPWD_FAC_Pn ):
1425 case( CPWD_FAC_Pu ):
1426 case( CPWD_FAC_Pc ):
1427 case( CPWD_FAC_Pp ):
1428 case( CPWD_FAC_Pf ):
1429 case( CPWD_FAC_Ps ):
1430 {
1431 T_SIMLOCK_TYPE slocktype;
1432 T_SIMLOCK_STATUS status;
1433
1434 switch (fac)
1435 {
1436 case CLCK_FAC_Pn: slocktype = SIMLOCK_NETWORK; break;
1437 case CLCK_FAC_Pu: slocktype = SIMLOCK_NETWORK_SUBSET; break;
1438 case CLCK_FAC_Pp: slocktype = SIMLOCK_SERVICE_PROVIDER; break;
1439 case CLCK_FAC_Pc: slocktype = SIMLOCK_CORPORATE; break;
1440 case CLCK_FAC_Ps: slocktype = SIMLOCK_SIM; break;
1441 case CLCK_FAC_Pf: slocktype = SIMLOCK_FIRST_SIM; break;
1442 default: slocktype = SIMLOCK_NETWORK; break;
1443 }
1444
1445 status = aci_slock_change_password( slocktype, oldpwd, newpwd );
1446 if (status EQ OPER_SUCCESS)
1447 return(AT_CMPL);
1448 else if(status EQ OPER_FAIL )
1449 {
1450 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_WrongPasswd );
1451 return( AT_FAIL );
1452 }
1453 else if (status EQ SIMLOCK_BLOCKED)
1454 {
1455 switch (fac)
1456 {
1457 case CLCK_FAC_Pn: ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_NetworkPersPukReq ); break;
1458 case CLCK_FAC_Pu: ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_NetworkSubsetPersPukReq ); break;
1459 case CLCK_FAC_Pp: ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_ProviderPersPukReq ); break;
1460 case CLCK_FAC_Pc: ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_CorporatePersPukReq ); break;
1461 case CLCK_FAC_Ps: ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_PhoneFail ); break;
1462 case CLCK_FAC_Pf: ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_PhFSimPukReq ); break;
1463 }
1464 return( AT_FAIL );
1465 }
1466 }
1467 retCd = AT_CMPL;
1468 break;
1469 #endif
1470 }
1471 }
1472
1473 /*
1474 *-------------------------------------------------------------------
1475 * log command execution
1476 *-------------------------------------------------------------------
1477 */
1478 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
1479 {
1480 T_ACI_CLOG cmdLog; /* holds logging info */
1481
1482 cmdLog.atCmd = AT_CMD_CPWD;
1483 cmdLog.cmdType = CLOG_TYPE_Set;
1484 cmdLog.retCode = retCd;
1485 cmdLog.cId = ACI_NumParmNotPresent;
1486 cmdLog.sId = (ssCd EQ NOT_PRESENT_8BIT)?
1487 ACI_NumParmNotPresent:/*lint -e(644)*/sId+1;
1488 cmdLog.cmdPrm.sCPWD.srcId = srcId;
1489 cmdLog.cmdPrm.sCPWD.fac = fac;
1490 cmdLog.cmdPrm.sCPWD.oldpwd = oldpwd;
1491 cmdLog.cmdPrm.sCPWD.newpwd = newpwd;
1492
1493 rAT_PercentCLOG( &cmdLog );
1494 }
1495 #endif
1496
1497 return( retCd );
1498 }
1499
1500 /*
1501 +--------------------------------------------------------------------+
1502 | PROJECT : GSM-PS (6147) MODULE : CMH_SSS |
1503 | STATE : code ROUTINE : sAT_PlusCCWA |
1504 +--------------------------------------------------------------------+
1505
1506 PURPOSE : This is the functional counterpart to the +CCWA AT command
1507 which is responsible to set the parameters for call
1508 waiting supplementary services.
1509
1510 <mode> : CW mode.
1511 <class_type>: class of call.
1512 */
1513
1514 GLOBAL T_ACI_RETURN sAT_PlusCCWA ( T_ACI_CMD_SRC srcId,
1515 T_ACI_CCWA_MOD mode,
1516 T_ACI_CLASS class_type)
1517 {
1518 SHORT sId1, sId2; /* holds service id */
1519 UBYTE bst1, bst2; /* holds basic service type */
1520 UBYTE bs1, bs2; /* holds basic service */
1521 BOOL mltyTrnFlg = FALSE; /* flags for multi transaction */
1522
1523 T_ACI_RETURN retVal;
1524
1525 TRACE_FUNCTION ("sAT_PlusCCWA ()");
1526
1527 /*
1528 *-------------------------------------------------------------------
1529 * check command source
1530 *-------------------------------------------------------------------
1531 */
1532 if(!cmh_IsVldCmdSrc (srcId))
1533 {
1534 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1535 return( AT_FAIL );
1536 }
1537
1538 if( cmhPrm[srcId].ssCmdPrm.mltyTrnFlg NEQ 0 )
1539
1540 return( AT_BUSY );
1541
1542 /*
1543 *-------------------------------------------------------------------
1544 * check parameter <class>
1545 *-------------------------------------------------------------------
1546 */
1547 if( !cmhSS_CheckClass( class_type, &bs1, &bst1, &bs2, &bst2, &mltyTrnFlg ))
1548 {
1549 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1550 return( AT_FAIL );
1551 }
1552
1553 /* SIM TOOLKIT & FDN HANDLING */
1554 if (mode NEQ CCWA_MOD_NotInterrogate) /* mode should be valid */
1555 {
1556 retVal = cmhSS_CW_SAT_Handle( srcId, mode, class_type);
1557
1558 if( retVal NEQ AT_CMPL )
1559 return( retVal );
1560 }
1561
1562
1563 /*
1564 *-------------------------------------------------------------------
1565 * get a new service table entry to interrogate SS
1566 *-------------------------------------------------------------------
1567 */
1568 sId1 = psaSS_stbNewEntry();
1569
1570 if( sId1 EQ NO_ENTRY )
1571 {
1572 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_SrvTabFull );
1573 return( AT_FAIL );
1574 }
1575
1576 sId2 = NO_ENTRY;
1577
1578 if( mltyTrnFlg )
1579 {
1580 ssShrdPrm.stb[sId1].ntryUsdFlg = TRUE;
1581
1582 sId2 = psaSS_stbNewEntry();
1583
1584 if( sId2 EQ NO_ENTRY )
1585 {
1586 ssShrdPrm.stb[sId1].ntryUsdFlg = FALSE;
1587 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_SrvTabFull );
1588 return( AT_FAIL );
1589 }
1590 }
1591
1592 /*
1593 *-------------------------------------------------------------------
1594 * check parameter <mode>
1595 *-------------------------------------------------------------------
1596 */
1597 switch( mode )
1598 {
1599 /*
1600 *---------------------------------------------------------------
1601 * lock and unlock call barring service
1602 *---------------------------------------------------------------
1603 */
1604 case( CCWA_MOD_Disable ):
1605 case( CCWA_MOD_Enable ):
1606
1607 CCD_START;
1608
1609 if( mode EQ CCWA_MOD_Disable )
1610 psaSS_asmDeactivateSS( SS_CD_CW, bst1, bs1 );
1611
1612 else if( mode EQ CCWA_MOD_Enable )
1613 psaSS_asmActivateSS( SS_CD_CW, bst1, bs1 );
1614
1615 ssShrdPrm.stb[sId1].ntryUsdFlg = TRUE;
1616 ssShrdPrm.stb[sId1].ssCode = SS_CD_CW;
1617 ssShrdPrm.stb[sId1].srvOwn = srcId;
1618
1619 /* start first transaction */
1620 ssShrdPrm.stb[sId1].curCmd = AT_CMD_CCWA;
1621 cmhSS_flagTrn( sId1, &(cmhPrm[srcId].ssCmdPrm.mltyTrnFlg));
1622 psaSS_NewTrns(sId1);
1623
1624 if( mltyTrnFlg )
1625 {
1626 if( mode EQ CCWA_MOD_Disable )
1627 psaSS_asmDeactivateSS( SS_CD_CW, bst2, bs2 );
1628
1629 else if( mode EQ CCWA_MOD_Enable )
1630 psaSS_asmActivateSS( SS_CD_CW, bst2, bs2 );
1631
1632 ssShrdPrm.stb[sId2].ntryUsdFlg = TRUE;
1633 ssShrdPrm.stb[sId2].ssCode = SS_CD_CW;
1634 ssShrdPrm.stb[sId2].srvOwn = srcId;
1635
1636 /* start second transaction */
1637 ssShrdPrm.stb[sId2].curCmd = AT_CMD_CCWA;
1638 cmhSS_flagTrn( sId2, &(ssShrdPrm.mltyTrnFlg)); /* only for the second one */
1639 cmhSS_flagTrn( sId2, &(cmhPrm[srcId].ssCmdPrm.mltyTrnFlg));
1640 psaSS_NewTrns(sId2);
1641 }
1642 CCD_END;
1643 break;
1644
1645 /*
1646 *---------------------------------------------------------------
1647 * unexpected mode
1648 *---------------------------------------------------------------
1649 */
1650 case( CCWA_MOD_NotInterrogate ):
1651
1652 ssShrdPrm.stb[sId1].ntryUsdFlg = FALSE;
1653 return( AT_CMPL );
1654
1655 default:
1656
1657 ssShrdPrm.stb[sId1].ntryUsdFlg = FALSE;
1658 if( sId2 NEQ NO_ENTRY ) ssShrdPrm.stb[sId2].ntryUsdFlg = FALSE;
1659
1660 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1661 return( AT_FAIL );
1662 }
1663
1664 /*
1665 *-------------------------------------------------------------------
1666 * log command execution
1667 *-------------------------------------------------------------------
1668 */
1669 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
1670 {
1671 T_ACI_CLOG cmdLog; /* holds logging info */
1672
1673 cmdLog.atCmd = AT_CMD_CCWA;
1674 cmdLog.cmdType = CLOG_TYPE_Set;
1675 cmdLog.retCode = AT_EXCT;
1676 cmdLog.cId = ACI_NumParmNotPresent;
1677 cmdLog.sId = sId1+1;
1678 cmdLog.cmdPrm.sCCWA.srcId = srcId;
1679 cmdLog.cmdPrm.sCCWA.mode = mode;
1680 cmdLog.cmdPrm.sCCWA.class_type = class_type;
1681
1682 rAT_PercentCLOG( &cmdLog );
1683 }
1684 #endif
1685
1686 return( AT_EXCT );
1687 }
1688
1689
1690 /*
1691 +--------------------------------------------------------------------+
1692 | PROJECT : GSM-PS (6147) MODULE : CMH_SSS |
1693 | STATE : code ROUTINE : sAT_PlusCUSD |
1694 +--------------------------------------------------------------------+
1695
1696 PURPOSE : This is the functional counterpart to the +CUSD AT command
1697 which is responsible to invoke an unstructured
1698 supplementary services.
1699
1700 <str> : USSD string.
1701 <dcs> : data coding scheme.
1702 */
1703 LOCAL T_ACI_RETURN ussd_call_control_by_sim(T_ACI_CMD_SRC srcId,
1704 T_ACI_USSD_DATA *str,
1705 SHORT dcs)
1706 {
1707 T_ACI_RETURN retCd = AT_CMPL; /* holds return code */
1708
1709 #ifdef SIM_TOOLKIT
1710 T_sat_ussd SATussd; /* to hold USSD string in case of SAT Control */
1711 T_CLPTY_PRM *sat_ss_cldPty;
1712
1713 if(!psaSIM_ChkSIMSrvSup( SRV_CalCntrl )) /* call control by SAT enabled */
1714 {
1715 return(AT_CMPL);
1716 }
1717
1718 if (psaSIM_ChkSIMSrvSup(SRV_USSDsupportInCC))
1719 {
1720 SATussd.dcs = (UBYTE)dcs;
1721 SATussd.c_ussd_str = str->len;
1722 SATussd.ussd_str = str->data;
1723
1724 retCd = cmhSAT_USSDCntrlBySIM( &SATussd, (UBYTE)srcId );
1725 }
1726 else /* USSD structure not known by SAT */
1727 {
1728 MALLOC(sat_ss_cldPty, sizeof(T_CLPTY_PRM));
1729 cmhCC_init_cldPty( sat_ss_cldPty );
1730
1731 if( !utl_cvtGsmIra ( str -> data,
1732 str->len,
1733 (UBYTE *)sat_ss_cldPty->num,
1734 MAX_USSD_DATA,
1735 CSCS_DIR_IraToGsm ) )
1736 {
1737 TRACE_EVENT("utl_cvtGsmIra( ) returned FALSE");
1738 MFREE(sat_ss_cldPty);
1739 return( AT_FAIL );
1740 }
1741 retCd = cmhSAT_SSCntrlBySIM( sat_ss_cldPty, (UBYTE)srcId );
1742 MFREE(sat_ss_cldPty);
1743 }
1744 return( retCd );
1745 #else
1746 return( AT_CMPL);
1747 #endif /* of SIM_TOOLKIT */
1748 }
1749
1750 GLOBAL T_ACI_RETURN sAT_PlusCUSD ( T_ACI_CMD_SRC srcId,
1751 T_ACI_USSD_DATA *str,
1752 SHORT dcs)
1753 {
1754 SHORT sId; /* holds service id */
1755 T_ACI_RETURN retCd = AT_CMPL; /* holds return code */
1756 UBYTE ussdLen;
1757 UBYTE *ussdString;
1758 UBYTE src_len;
1759
1760 TRACE_FUNCTION ("sAT_PlusCUSD ()");
1761
1762 /*
1763 *-------------------------------------------------------------------
1764 * check command source
1765 *-------------------------------------------------------------------
1766 */
1767 if(!cmh_IsVldCmdSrc (srcId))
1768 {
1769 TRACE_EVENT_P1("Wrong source: %d", srcId);
1770 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1771 return( AT_FAIL );
1772 }
1773
1774 /*
1775 *-------------------------------------------------------------------
1776 * check parameter str
1777 *-------------------------------------------------------------------
1778 */
1779 if( !str )
1780 {
1781 TRACE_EVENT("Empty string");
1782 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1783 return( AT_FAIL );
1784 }
1785
1786 /*
1787 *-------------------------------------------------------------------
1788 * check parameter dcs
1789 *-------------------------------------------------------------------
1790 */
1791 if( dcs EQ ACI_NumParmNotPresent )
1792
1793 dcs = 0;
1794
1795 /*
1796 *-------------------------------------------------------------------
1797 * check if there is a USSD request pending
1798 *-------------------------------------------------------------------
1799 */
1800 sId = psaSS_stbFindUssdReq();
1801
1802 if( sId EQ NO_ENTRY )
1803 {
1804 /* check if there is another service in progress */
1805 if( psaSS_stbFindActSrv( sId ) NEQ NO_ENTRY )
1806 {
1807 TRACE_EVENT("Parallel USSD Transaction not allowed");
1808 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_ParallelUSSD );
1809 return( AT_FAIL );
1810 }
1811
1812 /* get new service table entry */
1813 sId = psaSS_stbNewEntry();
1814 if( sId EQ NO_ENTRY )
1815 {
1816 TRACE_EVENT("Service table is full");
1817 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_SrvTabFull );
1818 return( AT_FAIL );
1819 }
1820
1821 /* check ussd call control by sim */
1822 retCd = ussd_call_control_by_sim(srcId, str, dcs);
1823 if(retCd NEQ AT_CMPL)
1824 {
1825 TRACE_EVENT_P1("ussd_call_control_by_sim() returned with %d", retCd);
1826
1827 return( retCd );
1828 }
1829
1830 CCD_START;
1831
1832 MALLOC(ussdString, MAX_USSD_STRING);
1833
1834 if( utl_getAlphabetCb( (UBYTE)dcs ) EQ 0 ) /* 7bit alphabet */
1835 {
1836 src_len = (UBYTE)MINIMUM( MAX_USSD_STRING, str->len);
1837 ussdLen = utl_cvt8To7( str->data,
1838 src_len,
1839 ussdString, 0 );
1840 /* According to spec 23.038 section 6.1.2.3 for USSD packing, for bytes end with
1841 * (8*n)-1 i.e where n is 1,2,3....i.e byte 7, 15, 23 ... to be padded
1842 * with carriage return <CR>(0xD)
1843 */
1844 if ((src_len+1)%8 EQ 0)
1845 {
1846 ussdString[ussdLen-1] |= (0xD << 1);
1847 }
1848 }
1849 else
1850 {
1851 ussdLen = str->len;
1852 memcpy(ussdString, str->data, MAX_USSD_STRING);
1853 }
1854
1855 psaSS_asmProcUSSDReq( (UBYTE)dcs, ussdString, ussdLen );
1856
1857 MFREE(ussdString);
1858
1859 /* start new transaction */
1860 ssShrdPrm.stb[sId].ntryUsdFlg = TRUE;
1861 ssShrdPrm.stb[sId].curCmd = AT_CMD_CUSD;
1862 ssShrdPrm.stb[sId].srvOwn = srcId;
1863 psaSS_NewTrns(sId);
1864
1865 CCD_END;
1866
1867 retCd = AT_CMPL;
1868
1869
1870 }
1871 else
1872 {
1873 CCD_START;
1874
1875 psaSS_asmCnfUSSDReq( (UBYTE)dcs, str->data, str->len );
1876
1877 ssShrdPrm.stb[sId].ussdReqFlg = FALSE;
1878
1879 /* continue existing transaction */
1880 psaSS_CntTrns(sId);
1881
1882 CCD_END;
1883
1884 retCd = AT_CMPL;
1885 }
1886
1887 ssShrdPrm.ussdLen = 0;
1888
1889 /* save ussd string for possible version 1 retry */
1890 if( cmhSMS_getAlphabetCb( (UBYTE)dcs ) EQ 0 )
1891 {
1892 if( str->len <= MAX_USSD_STRING )
1893 {
1894 ssShrdPrm.ussdLen = str->len;
1895 memcpy( ssShrdPrm.ussdBuf, str->data, str->len );
1896 }
1897 }
1898
1899 /*
1900 *-------------------------------------------------------------------
1901 * log command execution
1902 *-------------------------------------------------------------------
1903 */
1904 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
1905 {
1906 T_ACI_CLOG cmdLog; /* holds logging info */
1907
1908 cmdLog.atCmd = AT_CMD_CUSD;
1909 cmdLog.cmdType = CLOG_TYPE_Set;
1910 cmdLog.retCode = retCd;
1911 cmdLog.cId = ACI_NumParmNotPresent;
1912 cmdLog.sId = sId+1;
1913 cmdLog.cmdPrm.sCUSD.srcId = srcId;
1914 cmdLog.cmdPrm.sCUSD.dcs = dcs;
1915 cmdLog.cmdPrm.sCUSD.str = str;
1916
1917 rAT_PercentCLOG( &cmdLog );
1918 }
1919 #endif
1920
1921 return( retCd );
1922 }
1923
1924 /*
1925 +--------------------------------------------------------------------+
1926 | PROJECT : GSM-PS (6147) MODULE : CMH_SSS |
1927 | STATE : code ROUTINE : sAT_PercentCCBS |
1928 +--------------------------------------------------------------------+
1929
1930 PURPOSE : This is the functional counterpart to the %CCBS AT command
1931 which is responsible to clear CCBS entries. Index value set
1932 to 0 indicates clear all entries.
1933
1934 <idx> : ccbs index
1935 */
1936
1937 GLOBAL T_ACI_RETURN sAT_PercentCCBS( T_ACI_CMD_SRC srcId,
1938 SHORT idx )
1939 {
1940 SHORT sId; /* holds service id */
1941
1942 T_ACI_RETURN retVal;
1943
1944 TRACE_FUNCTION ("sAT_PercentCCBS ()");
1945
1946 /*
1947 *-------------------------------------------------------------------
1948 * check command source
1949 *-------------------------------------------------------------------
1950 */
1951 if(!cmh_IsVldCmdSrc (srcId))
1952 {
1953 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1954 return( AT_FAIL );
1955 }
1956
1957 /*
1958 *-------------------------------------------------------------------
1959 * check parameter idx
1960 *-------------------------------------------------------------------
1961 */
1962 if( idx EQ ACI_NumParmNotPresent OR idx > 5 OR idx < 0 )
1963 {
1964 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1965 return( AT_FAIL );
1966 }
1967
1968 /* SIM TOOLKIT & FDN HANDLING */
1969 retVal = cmhSS_CCBS_SAT_Handle( srcId, CCFC_MOD_Erasure, idx);
1970
1971 if( retVal NEQ AT_CMPL )
1972 return( retVal );
1973
1974
1975 /*
1976 *-------------------------------------------------------------------
1977 * get a new service table entry to interrogate SS
1978 *-------------------------------------------------------------------
1979 */
1980 sId = psaSS_stbNewEntry();
1981
1982 if( sId EQ NO_ENTRY )
1983 {
1984 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_SrvTabFull );
1985 return( AT_FAIL );
1986 }
1987
1988 /*
1989 *-------------------------------------------------------------------
1990 * check parameter <mode>
1991 *-------------------------------------------------------------------
1992 */
1993 CCD_START;
1994
1995 if( idx EQ 0 ) idx = KSD_IDX_NONE;
1996
1997 psaSS_asmDeactivateCCBS((UBYTE)idx);
1998
1999 ssShrdPrm.stb[sId].ntryUsdFlg = TRUE;
2000 ssShrdPrm.stb[sId].ssCode = SS_CD_CCBS;
2001 ssShrdPrm.stb[sId].SSver = SS_VERSION_3;
2002
2003 ssShrdPrm.stb[sId].srvOwn = srcId;
2004
2005 ssShrdPrm.stb[sId].curCmd = AT_CMD_CCBS;
2006
2007 psaSS_NewTrns(sId);
2008
2009 CCD_END;
2010
2011 /*
2012 *-------------------------------------------------------------------
2013 * log command execution
2014 *-------------------------------------------------------------------
2015 */
2016 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
2017 {
2018 T_ACI_CLOG cmdLog; /* holds logging info */
2019
2020 cmdLog.atCmd = AT_CMD_CCBS;
2021 cmdLog.cmdType = CLOG_TYPE_Set;
2022 cmdLog.retCode = AT_EXCT;
2023 cmdLog.cId = ACI_NumParmNotPresent;
2024 cmdLog.sId = sId+1;
2025 cmdLog.cmdPrm.sCCBS.srcId = srcId;
2026 cmdLog.cmdPrm.sCCBS.idx = idx;
2027
2028 rAT_PercentCLOG( &cmdLog );
2029 }
2030 #endif
2031
2032 return( AT_EXCT );
2033 }
2034
2035
2036 /*
2037 +--------------------------------------------------------------------+
2038 | PROJECT : GSM-PS (6147) MODULE : CMH_SSS |
2039 | STATE : code ROUTINE : sAT_PercentCSCN |
2040 +--------------------------------------------------------------------+
2041
2042 PURPOSE : This is the functional counterpart to the %CSCN AT command
2043 which is responsible to set the switches for debugging
2044 mode at terminal interface.
2045 */
2046 GLOBAL T_ACI_RETURN sAT_PercentCSCN ( T_ACI_CMD_SRC srcId,
2047 T_ACI_SS_CSCN_MOD_STATE ss_switch,
2048 T_ACI_SS_CSCN_MOD_DIRECTION ss_direction,
2049 T_ACI_CC_CSCN_MOD_STATE cc_switch,
2050 T_ACI_CC_CSCN_MOD_DIRECTION cc_direction )
2051 {
2052 TRACE_FUNCTION ("sAT_PercentCSCN ()");
2053
2054 if(!cmh_IsVldCmdSrc (srcId)) /* check command source */
2055 {
2056 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
2057 return( AT_FAIL );
2058 }
2059
2060 if (ss_switch NEQ SS_CSCN_MOD_STATE_INVALID)
2061 cmhPrm[srcId].ssCmdPrm.CSCNss_mode.SsCSCNModeState = ss_switch;
2062
2063 if (ss_direction NEQ SS_CSCN_MOD_DIR_INVALID)
2064 cmhPrm[srcId].ssCmdPrm.CSCNss_mode.SsCSCNModeDirection = ss_direction;
2065
2066 if (cc_switch NEQ CC_CSCN_MOD_STATE_INVALID)
2067 cmhPrm[srcId].ccCmdPrm.CSCNcc_mode.CcCSCNModeState = cc_switch;
2068
2069 if (cc_direction NEQ CC_CSCN_MOD_DIR_INVALID)
2070 cmhPrm[srcId].ccCmdPrm.CSCNcc_mode.CcCSCNModeDirection = cc_direction;
2071
2072 return( AT_CMPL );
2073 }
2074
2075 /*
2076 +--------------------------------------------------------------------+
2077 | PROJECT : GSM-PS (6147) MODULE : CMH_SSS |
2078 | STATE : code ROUTINE : sAT_PercentCUSDR |
2079 +--------------------------------------------------------------------+
2080
2081 PURPOSE : This is the functional counterpart to the %CUSDR AT command
2082 which is responsible for extended user/MMI response to n/w
2083 initaiated USSD.
2084 */
2085 GLOBAL T_ACI_RETURN sAT_PercentCUSDR(T_ACI_CMD_SRC srcId, T_ACI_CUSDR_RES response)
2086 {
2087 TRACE_FUNCTION ("sAT_PercentCUSDR()");
2088
2089 if(!cmh_IsVldCmdSrc (srcId)) /* check command source */
2090 {
2091 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
2092 return( AT_FAIL );
2093 }
2094
2095 if(cuscfgParams.Ext_USSD_Response EQ CUSCFG_STAT_Disabled)
2096 {
2097 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
2098 return( AT_FAIL );
2099 }
2100
2101 if(Ext_USSD_Res_Pending EQ CUSDR_EXT_USSD_RES_Not_Pending OR Ext_USSD_Res_Pending_sId EQ NOT_PRESENT_16BIT)
2102 {
2103 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
2104 return( AT_FAIL );
2105 }
2106
2107 switch(response)
2108 {
2109 case CUSDR_RES_Ok:
2110 if(Ext_USSD_Res_Pending NEQ CUSDR_EXT_USSD_RES_Request)
2111 {
2112 psaSS_asmEmptyRslt();
2113 psaSS_CntTrns(Ext_USSD_Res_Pending_sId);
2114 }
2115 Ext_USSD_Res_Pending = CUSDR_EXT_USSD_RES_Not_Pending;
2116 Ext_USSD_Res_Pending_sId = NOT_PRESENT_8BIT;
2117 return(AT_CMPL);
2118
2119 case CUSDR_RES_Unknown_Alphabet:
2120 psaSS_asmErrorRslt( Ext_USSD_Res_Pending_sId, ERR_UNKNOWN_ALPHA );
2121 psaSS_CntTrns(Ext_USSD_Res_Pending_sId);
2122 ssShrdPrm.stb[Ext_USSD_Res_Pending_sId].ntryUsdFlg = FALSE;
2123 Ext_USSD_Res_Pending = CUSDR_EXT_USSD_RES_Not_Pending;
2124 Ext_USSD_Res_Pending_sId = NOT_PRESENT_8BIT;
2125 return(AT_CMPL);
2126
2127 case CUSDR_RES_Busy:
2128 psaSS_asmErrorRslt( Ext_USSD_Res_Pending_sId, ERR_USSD_BUSY );
2129 psaSS_EndTrns(Ext_USSD_Res_Pending_sId);
2130 ssShrdPrm.stb[Ext_USSD_Res_Pending_sId].ntryUsdFlg = FALSE;
2131 Ext_USSD_Res_Pending = CUSDR_EXT_USSD_RES_Not_Pending;
2132 Ext_USSD_Res_Pending_sId = NOT_PRESENT_8BIT;
2133 return(AT_CMPL);
2134
2135 default:
2136 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
2137 return( AT_FAIL );
2138
2139 }
2140
2141 }
2142
2143
2144 /*==== EOF ========================================================*/