comparison g23m-aci/aci/cmh_sims.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_SIMS
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 the subscriber identity
19 | module.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef CMH_SIMS_C
24 #define CMH_SIMS_C
25 #endif
26
27 #include "config.h"
28 #include "fixedconf.h"
29 #include "condat-features.h"
30 #include "aci_conf.h"
31
32 #include "aci_all.h"
33 /*==== INCLUDES ===================================================*/
34 #include "aci_cmh.h"
35
36 #ifdef UART
37 #include "dti.h" /* functionality of the dti library */
38 #include "dti.h"
39 #include "dti_conn_mng.h"
40 #endif
41
42 #include "ati_cmd.h"
43
44 #ifdef FF_ATI
45 #include "aci_io.h"
46 #endif /* of #ifdef FF_ATI */
47
48 #ifdef FAX_AND_DATA
49 #include "aci_fd.h"
50 #endif /* of #ifdef FAX_AND_DATA */
51
52 #include "psa.h"
53 #include "psa_sim.h"
54 #include "psa_mm.h"
55 #include "cmh.h"
56 #include "cmh_sim.h"
57 #include "cmh_mm.h"
58
59 #ifdef GPRS
60 #include "dti_cntrl_mng.h"
61 #include "gaci.h"
62 #include "gaci_cmh.h"
63 #include "psa_gmm.h"
64 #include "cmh_gmm.h"
65 #endif
66
67 #include "aci.h"
68
69 /* #include "m_fac.h" */
70 #include "aoc.h"
71 #include "ati_cmd.h"
72 #include "aci_cmd.h"
73 #include "phb.h"
74
75 #include "aci_ext_pers.h"
76 #include "aci_slock.h"
77
78 #include "cl_imei.h"
79
80
81 #ifdef SIM_PERS
82 #include "general.h" // included for compilation error UNIT8 in sec_drv.h
83 #include "sec_drv.h"
84 #include "cmh.h"
85 #include "aci_cmh.h"
86
87 EXTERN T_SIM_MMI_INSERT_IND *last_sim_mmi_insert_ind;
88 EXTERN T_SEC_DRV_CATEGORY *personalisation_nw;
89 EXTERN T_SEC_DRV_CATEGORY *personalisation_ns;
90 EXTERN T_SEC_DRV_CATEGORY *personalisation_sp;
91 EXTERN T_SEC_DRV_CATEGORY *personalisation_cp;
92 EXTERN T_SEC_DRV_CATEGORY *personalisation_sim;
93 EXTERN T_SEC_DRV_CONFIGURATION *cfg_data ;
94 #endif
95
96 /*==== CONSTANTS ==================================================*/
97
98 /*==== EXPORT =====================================================*/
99
100 /*==== VARIABLES ==================================================*/
101
102 /*==== FUNCTIONS ==================================================*/
103 LOCAL T_ACI_RETURN cmhSIM_analyze_SIMLOCK_STATUS( T_SIMLOCK_STATUS status );
104 LOCAL T_ACI_RETURN sAT_Plus_CAMM_CACM ( T_ACI_AT_CMD at_cmd_id,
105 T_ACI_CMD_SRC srcId,
106 UBYTE value_type,
107 void *value,
108 UBYTE *pwd );
109 /*
110 +--------------------------------------------------------------------+
111 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
112 | STATE : code ROUTINE : sAT_PlusCFUN |
113 +--------------------------------------------------------------------+
114
115 PURPOSE : This is the functional counterpart to the +CFUN AT command
116 which is responsible to set the phone functionality.
117
118 <fun>: defines the level of functionality to switch to.
119 <rst>: reset mode
120 */
121
122 GLOBAL T_ACI_RETURN sAT_PlusCFUN ( T_ACI_CMD_SRC srcId,
123 T_ACI_CFUN_FUN fun,
124 T_ACI_CFUN_RST rst )
125 {
126 T_SIM_SET_PRM * pSIMSetPrm; /* points to MM parameter set */
127 T_ACI_RETURN retCd; /* holds return code */
128 UBYTE idx; /* holds index value */
129
130 /* variables for IMEI control mechanism */
131 #ifndef _SIMULATION_
132 BYTE retVal; /* holds return value */
133 UBYTE dummyIMEIBuf[CL_IMEI_SIZE]; /* dummy IMEI buffer */
134 #endif /* if NOT defined windows simulation */
135
136 TRACE_FUNCTION ("sAT_PlusCFUN()");
137
138 #ifndef _SIMULATION_
139 /*
140 *-------------------------------------------------------------------
141 * check IMEI
142 *-------------------------------------------------------------------
143 */
144
145 retVal = cl_get_imeisv(CL_IMEI_SIZE, dummyIMEIBuf, CL_IMEI_CONTROL_IMEI);
146
147 if( retVal NEQ CL_IMEI_OK )
148 {
149 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_IMEICheck );
150 TRACE_EVENT("IMEI not valid");
151 simShrdPrm.imei_blocked = TRUE;
152 /*return( AT_FAIL ); We dont return here to enable the stack to go to the state of "Limited Service' to enable emergency calls. */
153 }
154 #endif /* if NOT defined windows simulation */
155
156 /*
157 *-------------------------------------------------------------------
158 * check command source
159 *-------------------------------------------------------------------
160 */
161 if(!cmh_IsVldCmdSrc (srcId))
162 {
163 return( AT_FAIL );
164 }
165
166 pSIMSetPrm = &simShrdPrm.setPrm[srcId];
167
168 /*
169 *-------------------------------------------------------------------
170 * check entity status
171 *-------------------------------------------------------------------
172 */
173 if( simEntStat.curCmd NEQ AT_CMD_NONE )
174 {
175 TRACE_EVENT("Entity SIM is busy: cannot proceed command...");
176 return( AT_BUSY );
177 }
178
179 /*
180 *-------------------------------------------------------------------
181 * process the <rst> parameter
182 *-------------------------------------------------------------------
183 */
184 switch( rst )
185 {
186 case( CFUN_RST_NotPresent ): /* default value */
187 case( CFUN_RST_NoReset ):
188
189 break;
190
191 default: /* unexpected parameter */
192 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
193 return( AT_FAIL );
194 }
195
196 /*
197 *-------------------------------------------------------------------
198 * process the <fun> parameter
199 *-------------------------------------------------------------------
200 */
201 if( fun EQ CFUN_FUN_NotPresent ) fun = CFUNfun;
202
203 switch( fun )
204 {
205 case( CFUN_FUN_Minimum ): /* set ME to minimum functionality */
206 CFUNfun = fun;
207 simEntStat.curCmd = AT_CMD_CFUN;
208 simShrdPrm.owner = (T_OWN)srcId;
209 simEntStat.entOwn = srcId;
210
211 /* Turn off all possible ringing */
212 #ifdef FF_ATI
213 io_setRngInd ( IO_RING_OFF, CRING_SERV_TYP_NotPresent, CRING_SERV_TYP_NotPresent ); /* V.24 Ring Indicator Line */
214 #endif
215 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
216 {
217 R_AT( RAT_CRING_OFF, (T_ACI_CMD_SRC)idx )( 0 ); /* Turn of all ringing */
218 }
219
220
221 /* We have to wait for both entities to finish in CFUN. So both EntStat are set to AT_CMD_CFUN and
222 when a certain entity finished it also emits AT_OK if the other entity has already finished */
223
224 simEntStat.curCmd = AT_CMD_CFUN;
225 simShrdPrm.owner = (T_OWN)srcId;
226 simEntStat.entOwn = srcId;
227
228 mmEntStat.curCmd = AT_CMD_CFUN;
229 mmShrdPrm.owner = (T_OWN)srcId;
230 mmEntStat.entOwn = srcId;
231
232 pb_exit();
233
234 /* simShrdPrm.synCs = SYNC_DEACTIVATE; */ /* This is moved to pb_exit */
235 /* psaSIM_SyncSIM(); */
236
237 /* Reset ONSDesc */
238 cmhMM_Reset_ONSDesc();
239
240
241 #if defined (GPRS) AND defined (DTI)
242 mmShrdPrm.nrgCs = GMMREG_DT_POWER_OFF;
243 if( psaG_MM_CMD_DEREG ( mmShrdPrm.nrgCs ) < 0 ) /* deregister from network */
244 #else
245 mmShrdPrm.nrgCs = CS_POW_OFF;
246 if( psaMM_DeRegistrate () < 0 ) /* deregister from network */
247 #endif
248 {
249 TRACE_EVENT( "FATAL RETURN psaMM_DeRegistrate in +COPS" );
250 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
251 return( AT_FAIL );
252 }
253
254 percentCSTAT_indication(STATE_MSG_SMS, ENTITY_STATUS_NotReady);
255
256 retCd = AT_EXCT;
257 break;
258
259 case( CFUN_FUN_Full ): /* set ME to full functionality */
260 if ( (CFUNfun EQ CFUN_FUN_Minimum) OR (simShrdPrm.PINStat NEQ PS_RDY) )
261 {
262 CFUNfun = fun;
263 pSIMSetPrm -> actProc = SIM_INITIALISATION;
264
265 simEntStat.curCmd = AT_CMD_CFUN;
266 simShrdPrm.owner = (T_OWN)srcId;
267 simEntStat.entOwn = srcId;
268
269 if( psaSIM_ActivateSIM() < 0 ) /* activate SIM card */
270 {
271 TRACE_EVENT( "FATAL RETURN psaSIM in +CFUN" );
272 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
273 return( AT_FAIL );
274 }
275
276 retCd = AT_EXCT;
277 #ifdef GPRS
278 {
279 PALLOC (gmmreg_attach_req, GMMREG_ATTACH_REQ);
280
281 /* This is just a dummy req to trigger lower layer
282 for power scanning. It will be done based on bootup_act.*/
283 gmmreg_attach_req->bootup_act = QUICK_REG;
284
285 PSEND (hCommGMM,gmmreg_attach_req);
286 }
287 #else
288 {
289 PALLOC (mmr_reg_req, MMR_REG_REQ);
290
291 /* This is just a dummy req to trigger lower layer
292 for power scanning. It will be done based on bootup_act.
293 Other parameters is filled for the simulation test cases to pass */
294 mmr_reg_req->bootup_act = QUICK_REG;
295
296 PSENDX (MM, mmr_reg_req);
297 }
298 #endif
299 }
300 #ifdef SIM_PERS
301 else if (CFUNfun EQ CFUN_FUN_Full )
302 {
303 TRACE_EVENT("This is for if MMI calls sAT_PlusCFUN repetedly for verification of LOCKS");
304 CFUNfun = fun;
305 pSIMSetPrm -> actProc = SIM_INITIALISATION;
306
307 simEntStat.curCmd = AT_CMD_CFUN;
308 simShrdPrm.owner = (T_OWN)srcId;
309 simEntStat.entOwn = srcId;
310
311 if( psaSIM_ActivateSIM() < 0 ) /* activate SIM card */
312 {
313 TRACE_EVENT( "FATAL RETURN psaSIM in +CFUN" );
314 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
315 return( AT_FAIL );
316 }
317
318 retCd = AT_EXCT;
319 }
320 #endif
321 else
322 {
323 TRACE_EVENT("Switch mobile back on after radio low (CFUN=4)");
324 CFUNfun = fun;
325 retCd = AT_CMPL;
326 }
327 break;
328
329 case (CFUN_FUN_Disable_TX_RX_RF):
330 if (CFUNfun EQ CFUN_FUN_Minimum)
331 {
332 /* User directly goes to flight mode from power off. Only initialise
333 the SIM data */
334 CFUNfun = fun;
335 pSIMSetPrm -> actProc = SIM_INITIALISATION;
336
337 simEntStat.curCmd = AT_CMD_CFUN;
338 simShrdPrm.owner = (T_OWN)srcId;
339 simEntStat.entOwn = srcId;
340
341 if( psaSIM_ActivateSIM() < 0 ) /* activate SIM card */
342 {
343 TRACE_EVENT( "FATAL RETURN psaSIM in +CFUN" );
344 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
345 return( AT_FAIL );
346 }
347
348 retCd = AT_EXCT;
349 break;
350 }
351 CFUNfun = fun;
352
353 /* Turn off all possible ringing */
354 #ifdef FF_ATI
355 io_setRngInd ( IO_RING_OFF, CRING_SERV_TYP_NotPresent, CRING_SERV_TYP_NotPresent ); /* V.24 Ring Indicator Line */
356 #endif
357 for( idx = 0; idx < CMD_SRC_MAX; idx++ )
358 {
359 R_AT( RAT_CRING_OFF, (T_ACI_CMD_SRC)idx )( 0 ); /* Turn of all ringing */
360 }
361
362 if( mmEntStat.curCmd NEQ AT_CMD_BAND )
363 {
364 /* If sAT_PlusCFUN has been called by sAT_PercentBAND !!! */
365 mmEntStat.curCmd = AT_CMD_CFUN;
366 }
367 mmShrdPrm.owner = (T_OWN)srcId;
368 mmEntStat.entOwn = srcId;
369
370 #if defined (GPRS) AND defined (DTI)
371 mmShrdPrm.nrgCs = GMMREG_DT_SOFT_OFF;
372 if( psaG_MM_CMD_DEREG ( mmShrdPrm.nrgCs ) < 0 ) /* deregister from network */
373 #else
374 mmShrdPrm.nrgCs = CS_SOFT_OFF;
375 if( psaMM_DeRegistrate () < 0 ) /* deregister from network */
376 #endif
377 {
378 TRACE_EVENT( "FATAL RETURN psaMM_DeRegistrate in +COPS" );
379 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
380 return( AT_FAIL );
381 }
382
383 retCd = AT_EXCT;
384 break;
385
386 default: /* unexpected parameter */
387
388 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
389 return( AT_FAIL );
390 }
391
392 /*
393 *-------------------------------------------------------------------
394 * log command execution
395 *-------------------------------------------------------------------
396 */
397 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
398 if( mmEntStat.curCmd NEQ AT_CMD_BAND
399 AND simEntStat.curCmd NEQ AT_CMD_BAND )
400 {
401 T_ACI_CLOG cmdLog; /* holds logging info */
402
403 cmdLog.atCmd = AT_CMD_CFUN;
404 cmdLog.cmdType = CLOG_TYPE_Set;
405 cmdLog.retCode = retCd;
406 cmdLog.cId = ACI_NumParmNotPresent;
407 cmdLog.sId = ACI_NumParmNotPresent;
408 cmdLog.cmdPrm.sCFUN.srcId = srcId;
409 cmdLog.cmdPrm.sCFUN.fun = fun;
410 cmdLog.cmdPrm.sCFUN.rst = rst;
411
412 rAT_PercentCLOG( &cmdLog );
413 }
414 #endif
415
416 return( retCd );
417
418 }
419
420 #ifdef TI_PS_FF_AT_P_CMD_SECP
421 /*
422 +--------------------------------------------------------------------+
423 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
424 | STATE : code ROUTINE : sAT_PercentSECP |
425 +--------------------------------------------------------------------+
426
427 PURPOSE : This is the functional counterpart to the %SEC AT command
428 which is responsible to enter a PIN.
429
430 <pin>: string of PIN chars.
431 <newpin>: string of PIN chars required if requested PIN is
432 SIM PUK
433 */
434
435 GLOBAL T_ACI_RETURN sAT_PercentSECP ( T_ACI_CMD_SRC srcId,
436 CHAR * pin,
437 CHAR * newpin )
438 {
439 T_SIMLOCK_STATUS result;
440
441 TRACE_FUNCTION ("sAT_PercentSECP()");
442
443 /*
444 *-------------------------------------------------------------------
445 * check command source
446 *-------------------------------------------------------------------
447 */
448 if(!cmh_IsVldCmdSrc (srcId))
449 {
450 return( AT_FAIL );
451 }
452
453 /* Check validity of pin str*/
454 if( pin EQ NULL)
455 {
456 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
457 return( AT_FAIL );
458 }
459
460 /* Try to set new pin */
461 result = aci_ext_personalisation_CS_change_password( pin, newpin );
462
463 /* Implements Measure 50 */
464 return ( cmhSIM_analyze_SIMLOCK_STATUS ( result ) );
465
466 }
467 #endif /* TI_PS_FF_AT_P_CMD_SECP */
468
469 #ifdef TI_PS_FF_AT_P_CMD_SECS
470 /*
471 +--------------------------------------------------------------------+
472 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
473 | STATE : code ROUTINE : sAT_PercentSECS |
474 +--------------------------------------------------------------------+
475
476 PURPOSE : This is the functional counterpart to the %SECS? AT command
477 which is responsible to set the status of the Security Code.
478
479 <securityStatus>: Status of the security code.
480 <code>: Security code required to change the status.
481 */
482
483
484 GLOBAL T_ACI_RETURN sAT_PercentSECS ( T_ACI_CMD_SRC srcId,
485 T_ACI_SECS_STA securityState,
486 CHAR * code )
487 {
488
489 T_SIMLOCK_STATUS result;
490
491 TRACE_FUNCTION ("sAT_PercentSECS()");
492
493
494 /*
495 *-------------------------------------------------------------------
496 * check command source
497 *-------------------------------------------------------------------
498 */
499 if(!cmh_IsVldCmdSrc (srcId))
500 {
501 return( AT_FAIL );
502 }
503
504 /*
505 *-------------------------------------------------------------------
506 * check status value
507 *-------------------------------------------------------------------
508 */
509 switch (securityState)
510 {
511 case( SECS_STA_Enable ):
512 result = aci_ext_personalisation_CS_set_status(SIMLOCK_ENABLED, code);
513 break;
514 case( SECS_STA_Disable ):
515 result = aci_ext_personalisation_CS_set_status(SIMLOCK_DISABLED, code);
516 break;
517 default:
518 return( AT_FAIL );
519 }
520
521 /*
522 *-------------------------------------------------------------------
523 * analyze answer
524 *-------------------------------------------------------------------
525 */
526 /* Implements Measure 50 */
527 return ( cmhSIM_analyze_SIMLOCK_STATUS ( result ) );
528 }
529 #endif /* TI_PS_FF_AT_P_CMD_SECS */
530
531
532
533
534
535 /*
536 +--------------------------------------------------------------------+
537 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
538 | STATE : code ROUTINE : sAT_PlusCPIN |
539 +--------------------------------------------------------------------+
540
541 PURPOSE : This is the functional counterpart to the +CPIN AT command
542 which is responsible to enter a PIN.
543
544 <pin>: string of PIN chars.
545 <newpin>: string of PIN chars required if requested PIN is
546 SIM PUK
547 */
548
549 GLOBAL T_ACI_RETURN sAT_PlusCPIN ( T_ACI_CMD_SRC srcId,
550 CHAR * pin,
551 CHAR * newpin )
552 {
553 T_SIM_SET_PRM * pSIMSetPrm; /* points to SIM parameter set */
554 T_ACI_RETURN retCd; /* holds return code */
555 T_SIMLOCK_STATUS retSlStatus; /* holds return code */
556
557 TRACE_FUNCTION ("sAT_PlusCPIN()");
558
559 /*
560 *-------------------------------------------------------------------
561 * check command source
562 *-------------------------------------------------------------------
563 */
564 if(!cmh_IsVldCmdSrc (srcId))
565 {
566 return( AT_FAIL );
567 }
568
569 pSIMSetPrm = &simShrdPrm.setPrm[srcId];
570
571 /*
572 *-------------------------------------------------------------------
573 * check entity status
574 *-------------------------------------------------------------------
575 */
576 if( simEntStat.curCmd NEQ AT_CMD_NONE )
577
578 return( AT_BUSY );
579
580 /*
581 *-------------------------------------------------------------------
582 * check for PIN status
583 *-------------------------------------------------------------------
584 */
585 switch( simShrdPrm.PINStat )
586 {
587 case( PS_RDY ):
588 /*
589 *---------------------------------------------------------------
590 * Not a SIM PIN State, but a ME personalisation PIN
591 *---------------------------------------------------------------
592 */
593 #ifdef SIM_PERS
594 if (AciSLockShrd.blocked)
595 {
596 retSlStatus = aci_slock_authenticate(AciSLockShrd.current_lock, pin);
597 if ( retSlStatus NEQ SIMLOCK_DISABLED)
598 {
599 TRACE_EVENT( "Wrong PIN given for SIM lock." );
600 if (retSlStatus EQ SIMLOCK_BLOCKED)
601 {
602 if(!aci_slock_set_CFG())
603 {
604 ACI_ERR_DESC( ACI_ERR_CLASS_Ext,EXT_ERR_NoMEPD);
605 return( AT_FAIL );
606 }
607 aci_set_cme_error(AciSLockShrd.current_lock);
608 MFREE(cfg_data);
609 }
610 else
611 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_WrongPasswd );
612 return( AT_FAIL );
613 }
614 else
615 {
616 simEntStat.curCmd = AT_CMD_CPIN;
617 if(!aci_slock_set_CFG())
618 {
619 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_NoMEPD);
620 return( AT_FAIL );
621 }
622 aci_slock_init();
623
624 retSlStatus = SIMLOCK_ENABLED;
625 if(AciSLockShrd.current_lock < SIMLOCK_SIM)
626 {
627 AciSLockShrd.current_lock=(T_SIMLOCK_TYPE)(AciSLockShrd.current_lock +SIMLOCK_NETWORK_SUBSET);
628 AciSLockShrd.check_lock = SIMLOCK_CHECK_PERS;
629 retSlStatus = aci_slock_checkpersonalisation(AciSLockShrd.current_lock);
630 }
631 switch(retSlStatus)
632 {
633 case SIMLOCK_ENABLED :
634 return( AT_CMPL);
635 case SIMLOCK_BLOCKED :
636 return( AT_FAIL);
637 case SIMLOCK_WAIT :
638 return (AT_EXCT);
639
640 }
641 }
642
643 }
644
645 #endif
646 /*
647 *---------------------------------------------------------------
648 * no PIN input is required
649 *---------------------------------------------------------------
650 */
651 retCd = AT_FAIL;
652 break;
653
654 case( NO_VLD_PS ):
655 /*
656 *---------------------------------------------------------------
657 * PIN Status is unknown
658 *---------------------------------------------------------------
659 */
660
661 /* invoke SIM activate and enter PIN if needed ???? */
662 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
663 return( AT_FAIL );
664
665 case( PS_PIN1 ):
666 /*
667 *---------------------------------------------------------------
668 * PIN 1 input is required
669 *---------------------------------------------------------------
670 */
671 if( pin EQ NULL OR
672 strlen( pin ) < MIN_PIN_LEN OR
673 strlen( pin ) > PIN_LEN )
674 {
675 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
676 return( AT_FAIL );
677 }
678
679 cmhSIM_FillInPIN ( pin, pSIMSetPrm -> curPIN, PIN_LEN );
680 pSIMSetPrm -> PINType = PHASE_2_PIN_1;
681 simEntStat.curCmd = AT_CMD_CPIN;
682 simShrdPrm.owner = (T_OWN)srcId;
683 simEntStat.entOwn = srcId;
684
685 if( psaSIM_VerifyPIN() < 0 ) /* verify PIN */
686 {
687 TRACE_EVENT( "FATAL RETURN psaSIM in +CPIN" );
688 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
689 return( AT_FAIL );
690 }
691
692 retCd = AT_EXCT;
693 break;
694
695 case( PS_PIN2 ):
696 /*
697 *---------------------------------------------------------------
698 * PIN 2 input is required
699 *---------------------------------------------------------------
700 */
701 if( pin EQ NULL OR
702 strlen( pin ) < MIN_PIN_LEN OR
703 strlen( pin ) > PIN_LEN )
704 {
705 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
706 return( AT_FAIL );
707 }
708
709 cmhSIM_FillInPIN ( pin, pSIMSetPrm -> curPIN, PIN_LEN );
710 pSIMSetPrm -> PINType = PHASE_2_PIN_2;
711 simEntStat.curCmd = AT_CMD_CPIN;
712 simShrdPrm.owner = (T_OWN)srcId;
713 simEntStat.entOwn = srcId;
714
715 if( psaSIM_VerifyPIN() < 0 ) /* verify PIN */
716 {
717 TRACE_EVENT( "FATAL RETURN psaSIM in +CPIN" );
718 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
719 return( AT_FAIL );
720 }
721
722 retCd = AT_EXCT;
723 break;
724
725 case( PS_PUK1 ):
726 /*
727 *---------------------------------------------------------------
728 * PUK 1 input is required
729 *---------------------------------------------------------------
730 */
731 if( newpin EQ NULL OR
732 strlen( newpin ) EQ 0)
733 {
734 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_SimPukReq ); /* inform about needed PUK */
735 return( AT_FAIL );
736 }
737 if( pin EQ NULL OR
738 newpin EQ NULL OR
739 strlen( pin ) NEQ PUK_LEN OR
740 strlen( newpin ) < MIN_PIN_LEN OR
741 strlen( newpin ) > PIN_LEN )
742 {
743 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
744 return( AT_FAIL );
745 }
746
747 cmhSIM_FillInPIN ( pin, pSIMSetPrm -> unblkKey, PUK_LEN );
748 cmhSIM_FillInPIN ( newpin, pSIMSetPrm -> curPIN, PIN_LEN );
749 pSIMSetPrm -> PINType = PHASE_2_PUK_1;
750 simEntStat.curCmd = AT_CMD_CPIN;
751 simShrdPrm.owner = (T_OWN)srcId;
752 simEntStat.entOwn = srcId;
753
754 if( psaSIM_UnblockCard( ) < 0 ) /* verify PIN */
755 {
756 TRACE_EVENT( "FATAL RETURN psaSIM in +CPIN" );
757 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
758 return( AT_FAIL );
759 }
760
761 retCd = AT_EXCT;
762 break;
763
764 case( PS_PUK2 ):
765 /*
766 *---------------------------------------------------------------
767 * PUK 2 input is required
768 *---------------------------------------------------------------
769 */
770 if( newpin EQ NULL OR
771 strlen( newpin ) EQ 0)
772 {
773 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_SimPuk2Req ); /* inform about needed PUK2 */
774 return( AT_FAIL );
775 }
776 if( pin EQ NULL OR
777 newpin EQ NULL OR
778 strlen( pin ) NEQ PUK_LEN OR
779 strlen( newpin ) < MIN_PIN_LEN OR
780 strlen( newpin ) > PIN_LEN )
781 {
782 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
783 return( AT_FAIL );
784 }
785
786 cmhSIM_FillInPIN ( pin, pSIMSetPrm -> unblkKey, PUK_LEN );
787 cmhSIM_FillInPIN ( newpin, pSIMSetPrm -> curPIN, PIN_LEN );
788 pSIMSetPrm -> PINType = PHASE_2_PUK_2;
789 simEntStat.curCmd = AT_CMD_CPIN;
790 simShrdPrm.owner = (T_OWN)srcId;
791 simEntStat.entOwn = srcId;
792
793 if( psaSIM_UnblockCard( ) < 0 ) /* verify PIN */
794 {
795 TRACE_EVENT( "FATAL RETURN psaSIM in +CPIN" );
796 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
797 return( AT_FAIL );
798 }
799
800 retCd = AT_EXCT;
801 break;
802
803 default:
804 /*
805 *---------------------------------------------------------------
806 * unexpected PIN state
807 *---------------------------------------------------------------
808 */
809 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_DataCorrupt );
810 return( AT_FAIL );
811 }
812
813 /*
814 *-------------------------------------------------------------------
815 * log command execution
816 *-------------------------------------------------------------------
817 */
818 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
819 {
820 T_ACI_CLOG cmdLog; /* holds logging info */
821
822 cmdLog.atCmd = AT_CMD_CPIN;
823 cmdLog.cmdType = CLOG_TYPE_Set;
824 cmdLog.retCode = retCd;
825 cmdLog.cId = ACI_NumParmNotPresent;
826 cmdLog.sId = ACI_NumParmNotPresent;
827 cmdLog.cmdPrm.sCPIN.srcId = srcId;
828 cmdLog.cmdPrm.sCPIN.pin = pin;
829 cmdLog.cmdPrm.sCPIN.newpin = newpin;
830
831 rAT_PercentCLOG( &cmdLog );
832 }
833 #endif
834
835 return( retCd );
836 }
837
838 /*
839 +--------------------------------------------------------------------+
840 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
841 | STATE : code ROUTINE : sAT_PlusCAMM |
842 +--------------------------------------------------------------------+
843
844 PURPOSE : This is the functional counterpart to the +CAMM AT command
845 which is responsible to set the ACMMax.
846 */
847
848 GLOBAL T_ACI_RETURN sAT_PlusCAMM ( T_ACI_CMD_SRC srcId,
849 LONG acmmax,
850 CHAR * pwd)
851 {
852 /* Implements Measure 40 */
853 return ( sAT_Plus_CAMM_CACM( AT_CMD_CAMM, srcId, AOC_ACMMAX,
854 (void *) acmmax, (UBYTE *) pwd ));
855 }
856
857 /*
858 +--------------------------------------------------------------------+
859 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
860 | STATE : code ROUTINE : sAT_PlusCPUC |
861 +--------------------------------------------------------------------+
862
863 PURPOSE : This is the functional counterpart to the +CPUC AT command
864 which is responsible to set the PUCT values.
865 */
866
867 GLOBAL T_ACI_RETURN sAT_PlusCPUC ( T_ACI_CMD_SRC srcId,
868 CHAR * currency,
869 CHAR * ppu,
870 CHAR * pwd)
871 {
872 T_puct puct;
873 T_ACI_RETURN ret = AT_FAIL;
874
875 TRACE_FUNCTION ("sAT_PlusCPUC()");
876 /*
877 *-------------------------------------------------------------------
878 * check command source
879 *-------------------------------------------------------------------
880 */
881 if(!cmh_IsVldCmdSrc (srcId))
882 {
883 return( AT_FAIL );
884 }
885
886 /*
887 *-------------------------------------------------------------------
888 * send parameters to advice of charge module.
889 *-------------------------------------------------------------------
890 */
891 strcpy ((char *) puct.currency, currency);
892 strcpy ((char *) puct.value, ppu);
893 simEntStat.curCmd = AT_CMD_CPUC;
894 simShrdPrm.owner = (T_OWN)srcId;
895 simEntStat.entOwn = srcId;
896 ret = aoc_set_values (srcId,
897 AOC_PUCT,
898 (void *)&puct,
899 (UBYTE *) pwd);
900
901 /*
902 *-------------------------------------------------------------------
903 * Check return value of aoc_set_values() equal to AT_FAIL,
904 * resets simEntStat.curcmd and simEntStat.entown.
905 *-------------------------------------------------------------------
906 */
907
908 if( ret EQ AT_FAIL )
909 {
910 simEntStat.curCmd = AT_CMD_NONE;
911 simShrdPrm.owner = (T_OWN)CMD_SRC_NONE;
912 simEntStat.entOwn = CMD_SRC_NONE;
913 }
914
915 return( ret );
916 }
917
918 /*
919 +--------------------------------------------------------------------+
920 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
921 | STATE : code ROUTINE : sAT_PlusCACM |
922 +--------------------------------------------------------------------+
923
924 PURPOSE : This is the functional counterpart to the +CACM AT command
925 which is responsible to reset the ACM value.
926 */
927
928 GLOBAL T_ACI_RETURN sAT_PlusCACM ( T_ACI_CMD_SRC srcId,
929 CHAR * pwd)
930 {
931 /* Implements Measure 40 */
932 return ( sAT_Plus_CAMM_CACM( AT_CMD_CACM, srcId, AOC_ACM,
933 (void *) NULL, (UBYTE *) pwd ));
934 }
935
936 /*
937 +--------------------------------------------------------------------+
938 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
939 | STATE : code ROUTINE : sAT_PlusCPOL |
940 +--------------------------------------------------------------------+
941
942 PURPOSE : This is the functional counterpart to the +CPOL AT command
943 which is responsible to access the preferred PLMN list.
944
945 <index>: PLMN list index
946 <format>: PLMN format
947 <oper>: PLMN name
948 <index2>: second PLMN list index for exchange operation
949 <mode>: supplemental mode information
950 */
951
952 GLOBAL T_ACI_RETURN sAT_PlusCPOL ( T_ACI_CMD_SRC srcId,
953 SHORT index,
954 T_ACI_CPOL_FRMT format,
955 CHAR * oper,
956 SHORT index2,
957 T_ACI_CPOL_MOD mode )
958 {
959 T_SIM_CMD_PRM * pSIMCmdPrm; /* points to SIM command parameters */
960 UBYTE plmn[ACI_LEN_PLMN_SEL_NTRY];/* holds coded plmn id */
961
962 TRACE_FUNCTION ("sAT_PlusCPOL()");
963
964 /*
965 *-------------------------------------------------------------------
966 * check command source
967 *-------------------------------------------------------------------
968 */
969 if(!cmh_IsVldCmdSrc (srcId))
970 {
971 return( AT_FAIL );
972 }
973 pSIMCmdPrm = &cmhPrm[srcId].simCmdPrm;
974
975 /*
976 *-------------------------------------------------------------------
977 * check mode parameter
978 *-------------------------------------------------------------------
979 */
980 switch( mode )
981 {
982 case( CPOL_MOD_CompactList ):
983 case( CPOL_MOD_Insert ):
984 case( CPOL_MOD_NotPresent ):
985 break;
986
987 default:
988 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
989 return( AT_FAIL );
990 }
991
992 /*
993 *-------------------------------------------------------------------
994 * check format parameter
995 *-------------------------------------------------------------------
996 */
997 switch( format )
998 {
999 case( CPOL_FRMT_Long ):
1000 case( CPOL_FRMT_Short ):
1001 case( CPOL_FRMT_Numeric ):
1002
1003 if( index EQ ACI_NumParmNotPresent AND !oper )
1004 {
1005 pSIMCmdPrm->CPOLfrmt = format;
1006 return( AT_CMPL );
1007 }
1008 break;
1009
1010 case( CPOL_FRMT_NotPresent ):
1011
1012 format = pSIMCmdPrm->CPOLfrmt;
1013 break;
1014
1015 default:
1016 {
1017 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1018 return( AT_FAIL );
1019 }
1020 }
1021
1022 /*
1023 *-------------------------------------------------------------------
1024 * check for write entry
1025 *-------------------------------------------------------------------
1026 */
1027 if( oper )
1028 {
1029 /* code plmn id */
1030 if( ! cmhSIM_GetCodedPLMN( oper, format, plmn ))
1031 {
1032 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1033 return( AT_FAIL );
1034 }
1035
1036 /* if EF is already read */
1037 if( EfPLMNselStat EQ EF_STAT_READ )
1038 {
1039 if( mode EQ CPOL_MOD_CompactList )
1040 {
1041 cmhSIM_CmpctPlmnSel( CPOLSimEfDataLen, CPOLSimEfData );
1042 }
1043
1044 if( index NEQ ACI_NumParmNotPresent )
1045 {
1046 if( index > (CPOLSimEfDataLen / ACI_LEN_PLMN_SEL_NTRY))
1047 {
1048 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_InvIdx );
1049 return( AT_FAIL );
1050 }
1051
1052 return cmhSIM_UpdPlmnSel( srcId, index, plmn, mode );
1053 }
1054 else
1055
1056 return cmhSIM_FndEmptyPlmnSel( srcId, plmn );
1057 }
1058 else
1059 {
1060 if( simEntStat.curCmd NEQ AT_CMD_NONE )
1061
1062 return( AT_BUSY );
1063
1064 pSIMCmdPrm->CPOLidx = (UBYTE)(index EQ ACI_NumParmNotPresent)?
1065 NOT_PRESENT_8BIT:index;
1066 pSIMCmdPrm->CPOLmode = mode;
1067 pSIMCmdPrm->CPOLact = CPOL_ACT_Write;
1068 memcpy( pSIMCmdPrm->CPOLplmn, plmn, ACI_LEN_PLMN_SEL_NTRY );
1069
1070 simEntStat.curCmd = AT_CMD_CPOL;
1071 simEntStat.entOwn = srcId;
1072
1073 /* Implements Measure 150 and 159 */
1074 return cmhSIM_Req_or_Write_PlmnSel( srcId, ACT_RD_DAT );
1075 }
1076 }
1077
1078 /*
1079 *-------------------------------------------------------------------
1080 * check for delete entry
1081 *-------------------------------------------------------------------
1082 */
1083 else
1084 {
1085 /* check presence of index */
1086 if( index EQ ACI_NumParmNotPresent )
1087 {
1088 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_InvIdx );
1089 return( AT_FAIL );
1090 }
1091
1092 /* if EF is already read */
1093 if( EfPLMNselStat EQ EF_STAT_READ )
1094 {
1095 if( mode EQ CPOL_MOD_CompactList )
1096 {
1097 cmhSIM_CmpctPlmnSel( CPOLSimEfDataLen, CPOLSimEfData );
1098 }
1099
1100 if( index > (CPOLSimEfDataLen / ACI_LEN_PLMN_SEL_NTRY) OR
1101 (index2 > (CPOLSimEfDataLen / ACI_LEN_PLMN_SEL_NTRY) AND
1102 index2 NEQ ACI_NumParmNotPresent))
1103 {
1104 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_InvIdx );
1105 return( AT_FAIL );
1106 }
1107
1108 if( index2 EQ ACI_NumParmNotPresent )
1109
1110 return cmhSIM_DelPlmnSel( srcId, index, mode );
1111
1112 else
1113
1114 return cmhSIM_ChgPlmnSel( srcId, index, index2 );
1115 }
1116 else
1117 {
1118 if( simEntStat.curCmd NEQ AT_CMD_NONE )
1119
1120 return( AT_BUSY );
1121
1122 pSIMCmdPrm->CPOLidx = (UBYTE)index;
1123 pSIMCmdPrm->CPOLidx2 = (index2 NEQ ACI_NumParmNotPresent)?
1124 (UBYTE)index2:NOT_PRESENT_8BIT;
1125 pSIMCmdPrm->CPOLmode = mode;
1126 pSIMCmdPrm->CPOLact = CPOL_ACT_Delete;
1127
1128 simEntStat.curCmd = AT_CMD_CPOL;
1129 simEntStat.entOwn = srcId;
1130
1131 /* Implements Measure 150 and 159 */
1132 return cmhSIM_Req_or_Write_PlmnSel( srcId, ACT_RD_DAT );
1133 }
1134 }
1135 }
1136
1137 /*
1138 +--------------------------------------------------------------------+
1139 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
1140 | STATE : code ROUTINE : sAT_PlusCRSM |
1141 +--------------------------------------------------------------------+
1142
1143 PURPOSE : This is the functional counterpart to the +CRSM AT command
1144 which is responsible for restricted SIM access.
1145
1146 <cmd>: access command.
1147 <fileId>: file identifier
1148 <p1>: parameter 1
1149 <p2>: parameter 2
1150 <p3>: parameter 3
1151 <dataLen>: length of data
1152 <data>: pointer to data
1153 */
1154
1155 T_ACI_RETURN sAT_PlusCRSM ( T_ACI_CMD_SRC srcId,
1156 T_ACI_CRSM_CMD cmd,
1157 SHORT fileId,
1158 SHORT p1,
1159 SHORT p2,
1160 SHORT p3,
1161 SHORT dataLen,
1162 UBYTE *data )
1163 {
1164 T_SIM_TRNS_ACC_PRM prm; /* holds access parameter */
1165
1166 TRACE_FUNCTION ("sAT_PlusCRSM()");
1167
1168 /*
1169 *-------------------------------------------------------------------
1170 * check command source
1171 *-------------------------------------------------------------------
1172 */
1173 if(!cmh_IsVldCmdSrc (srcId))
1174 {
1175 return( AT_FAIL );
1176 }
1177
1178 /*
1179 *-------------------------------------------------------------------
1180 * check entity status
1181 *-------------------------------------------------------------------
1182 */
1183 if( simEntStat.curCmd NEQ AT_CMD_NONE )
1184
1185 return( AT_BUSY );
1186
1187 /*
1188 *-------------------------------------------------------------------
1189 * check command, data, p1, p2 and p3 parameters
1190 *-------------------------------------------------------------------
1191 */
1192 switch( cmd )
1193 {
1194 case( CRSM_CMD_UpdBin ):
1195 case( CRSM_CMD_UpdRec ):
1196
1197 if( !data OR !dataLen )
1198 {
1199 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1200 return( AT_FAIL );
1201 }
1202 /*lint -fallthrough*/
1203
1204 case( CRSM_CMD_ReadBin ):
1205 case( CRSM_CMD_ReadRec ):
1206
1207 if( p1 EQ ACI_NumParmNotPresent OR
1208 p2 EQ ACI_NumParmNotPresent OR
1209 p3 EQ ACI_NumParmNotPresent )
1210 {
1211 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1212 return( AT_FAIL );
1213 }
1214 break;
1215
1216 case( CRSM_CMD_GetResp ):
1217 case( CRSM_CMD_Status ):
1218
1219 if( p3 EQ ACI_NumParmNotPresent )
1220 p3 = 0;
1221 break;
1222
1223 case( CRSM_CMD_NotPresent ):
1224 default:
1225 {
1226 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1227 return( AT_FAIL );
1228 }
1229 }
1230
1231 /*
1232 *-------------------------------------------------------------------
1233 * check fileId parameter
1234 *-------------------------------------------------------------------
1235 */
1236 if( fileId EQ ACI_NumParmNotPresent AND cmd NEQ CRSM_CMD_Status )
1237 {
1238 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1239 return( AT_FAIL );
1240 }
1241
1242 /*
1243 *-------------------------------------------------------------------
1244 * convert command
1245 *-------------------------------------------------------------------
1246 */
1247 switch( cmd )
1248 {
1249 case( CRSM_CMD_UpdBin ): prm.cmd = SIM_UPDATE_BINARY;break;
1250 case( CRSM_CMD_UpdRec ): prm.cmd = SIM_UPDATE_RECORD;break;
1251 case( CRSM_CMD_ReadBin ): prm.cmd = SIM_READ_BINARY;break;
1252 case( CRSM_CMD_ReadRec ): prm.cmd = SIM_READ_RECORD;break;
1253 case( CRSM_CMD_GetResp ): prm.cmd = SIM_GET_RESPONSE;break;
1254 case( CRSM_CMD_Status ): prm.cmd = SIM_STATUS;break;
1255 }
1256
1257 /*
1258 *-------------------------------------------------------------------
1259 * access SIM
1260 *-------------------------------------------------------------------
1261 */
1262 simEntStat.curCmd = AT_CMD_CRSM;
1263 simEntStat.entOwn = srcId;
1264
1265 prm.reqDataFld = (USHORT)fileId;
1266 prm.p1 = (UBYTE)p1;
1267 prm.p2 = (UBYTE)p2;
1268 prm.p3 = (UBYTE)p3;
1269 prm.dataLen = (UBYTE)dataLen;
1270 prm.transData = data;
1271
1272 psaSIM_TrnsSIMAccess( &prm );
1273
1274 return( AT_EXCT );
1275 }
1276
1277 /*
1278 +--------------------------------------------------------------------+
1279 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
1280 | STATE : code ROUTINE : sAT_PlusCSIM |
1281 +--------------------------------------------------------------------+
1282
1283 PURPOSE : This is the functional counterpart to the +CSIM AT command
1284 which is responsible for generic SIM access.
1285
1286 */
1287
1288 T_ACI_RETURN sAT_PlusCSIM ( T_ACI_CMD_SRC srcId,
1289 USHORT dataLen,
1290 UBYTE *data )
1291 {
1292 T_SIM_TRNS_ACC_PRM prm; /* holds access parameter */
1293
1294 TRACE_FUNCTION ("sAT_PlusCSIM()");
1295
1296 /*
1297 *-------------------------------------------------------------------
1298 * check command source
1299 *-------------------------------------------------------------------
1300 */
1301 if(!cmh_IsVldCmdSrc (srcId))
1302 {
1303 return( AT_FAIL );
1304 }
1305
1306 /*
1307 *-------------------------------------------------------------------
1308 * check entity status
1309 *-------------------------------------------------------------------
1310 */
1311 if( simEntStat.curCmd NEQ AT_CMD_NONE )
1312 {
1313 return( AT_BUSY );
1314 }
1315
1316 if (data[0] EQ GSM_CLASS)
1317 {
1318 /* GSM instruction class is not allowed */
1319 TRACE_EVENT("GSM instruction class is not allowed");
1320 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
1321 return( AT_FAIL );
1322 }
1323 #if 0 /* do we really need the check for the ATP source ? */
1324 #ifdef _TARGET_
1325 if (ati_is_src_type((UBYTE)srcId, ATI_SRC_TYPE_RIV) EQ FALSE)
1326 {
1327 /* don't allow other source type than RIV */
1328 TRACE_EVENT("other src type than RIV is not allowed");
1329 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
1330 return( AT_FAIL );
1331 }
1332 #endif /*_TARGET_*/
1333 #endif /* */
1334 if (dataLen > MAX_SIM_TRANSP)
1335 {
1336 /* wrong length value */
1337 TRACE_EVENT("wrong length value");
1338 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1339 return( AT_FAIL );
1340 }
1341
1342 /*
1343 *-------------------------------------------------------------------
1344 * access SIM
1345 *-------------------------------------------------------------------
1346 */
1347 simEntStat.curCmd = AT_CMD_CSIM;
1348 simEntStat.entOwn = srcId;
1349
1350 prm.cmd = SIM_TRANSP_CMD;
1351 prm.dataLen = dataLen;
1352 prm.transData = data;
1353
1354 psaSIM_TrnsSIMAccess( &prm );
1355
1356 return( AT_EXCT );
1357
1358 }
1359
1360 /*
1361 +--------------------------------------------------------------------+
1362 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
1363 | STATE : code ROUTINE : sAT_PercentPVRF |
1364 +--------------------------------------------------------------------+
1365
1366 PURPOSE : This is the functional counterpart to the %PVRF AT command
1367 which is responsible to verify a specific PIN.
1368
1369 <pin>: string of PIN chars.
1370 <newpin>: string of PIN chars required if requested PIN is
1371 SIM PUK
1372 */
1373
1374 GLOBAL T_ACI_RETURN sAT_PercentPVRF( T_ACI_CMD_SRC srcId,
1375 T_ACI_PVRF_TYPE type,
1376 CHAR * pin,
1377 CHAR * newpin )
1378 {
1379 T_SIM_SET_PRM * pSIMSetPrm; /* points to SIM parameter set */
1380 T_ACI_RETURN retCd; /* holds return code */
1381
1382 TRACE_FUNCTION ("sAT_PercentPVRF()");
1383
1384 /*
1385 *-------------------------------------------------------------------
1386 * check command source
1387 *-------------------------------------------------------------------
1388 */
1389 if(!cmh_IsVldCmdSrc (srcId))
1390 {
1391 return( AT_FAIL );
1392 }
1393
1394 pSIMSetPrm = &simShrdPrm.setPrm[srcId];
1395
1396 /*
1397 *-------------------------------------------------------------------
1398 * check entity status
1399 *-------------------------------------------------------------------
1400 */
1401 if( simEntStat.curCmd NEQ AT_CMD_NONE )
1402
1403 return( AT_BUSY );
1404
1405 /*
1406 *-------------------------------------------------------------------
1407 * check for PIN type
1408 *-------------------------------------------------------------------
1409 */
1410 switch( type )
1411 {
1412 case( PVRF_TYPE_Pin1 ):
1413 case( PVRF_TYPE_Pin2 ):
1414 /*
1415 *---------------------------------------------------------------
1416 * PIN 1/2 verify is required
1417 *---------------------------------------------------------------
1418 */
1419 if( pin EQ NULL OR
1420 strlen( pin ) < MIN_PIN_LEN OR
1421 strlen( pin ) > PIN_LEN )
1422 {
1423 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1424 return( AT_FAIL );
1425 }
1426
1427 cmhSIM_FillInPIN ( pin, pSIMSetPrm -> curPIN, PIN_LEN );
1428 pSIMSetPrm -> PINType = (type EQ PVRF_TYPE_Pin1)?
1429 PHASE_2_PIN_1:PHASE_2_PIN_2;
1430 simEntStat.curCmd = AT_CMD_PVRF;
1431 simShrdPrm.owner = (T_OWN)srcId;
1432 simEntStat.entOwn = srcId;
1433
1434 if( psaSIM_VerifyPIN() < 0 ) /* verify PIN */
1435 {
1436 TRACE_EVENT( "FATAL RETURN psaSIM in %%PVRF" );
1437 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
1438 return( AT_FAIL );
1439 }
1440
1441 retCd = AT_EXCT;
1442 break;
1443
1444 case( PVRF_TYPE_Puk1 ):
1445 case( PVRF_TYPE_Puk2 ):
1446 /*
1447 *---------------------------------------------------------------
1448 * PUK 1/2 verify is required
1449 *---------------------------------------------------------------
1450 */
1451 if( pin EQ NULL OR
1452 newpin EQ NULL OR
1453 strlen( pin ) NEQ PUK_LEN OR
1454 strlen( newpin ) < MIN_PIN_LEN OR
1455 strlen( newpin ) > PIN_LEN )
1456 {
1457 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1458 return( AT_FAIL );
1459 }
1460
1461 cmhSIM_FillInPIN ( pin, pSIMSetPrm -> unblkKey, PUK_LEN );
1462 cmhSIM_FillInPIN ( newpin, pSIMSetPrm -> curPIN, PIN_LEN );
1463 pSIMSetPrm -> PINType = (type EQ PVRF_TYPE_Puk1)?
1464 PHASE_2_PUK_1:PHASE_2_PUK_2;
1465 simEntStat.curCmd = AT_CMD_PVRF;
1466 simShrdPrm.owner = (T_OWN)srcId;
1467 simEntStat.entOwn = srcId;
1468
1469 if( psaSIM_UnblockCard( ) < 0 ) /* verify PIN */
1470 {
1471 TRACE_EVENT( "FATAL RETURN psaSIM in %%PVRF" );
1472 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
1473 return( AT_FAIL );
1474 }
1475
1476 retCd = AT_EXCT;
1477 break;
1478
1479 default:
1480 /*
1481 *---------------------------------------------------------------
1482 * unexpected PIN state
1483 *---------------------------------------------------------------
1484 */
1485 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_DataCorrupt );
1486 return( AT_FAIL );
1487 }
1488
1489 /*
1490 *-------------------------------------------------------------------
1491 * log command execution
1492 *-------------------------------------------------------------------
1493 */
1494 #if defined SMI OR defined MFW OR defined FF_MMI_RIV
1495 {
1496 T_ACI_CLOG cmdLog; /* holds logging info */
1497
1498 cmdLog.atCmd = AT_CMD_PVRF;
1499 cmdLog.cmdType = CLOG_TYPE_Set;
1500 cmdLog.retCode = retCd;
1501 cmdLog.cId = ACI_NumParmNotPresent;
1502 cmdLog.sId = ACI_NumParmNotPresent;
1503 cmdLog.cmdPrm.sPVRF.srcId = srcId;
1504 cmdLog.cmdPrm.sPVRF.type = type;
1505 cmdLog.cmdPrm.sPVRF.pin = pin;
1506 cmdLog.cmdPrm.sPVRF.newpin = newpin;
1507
1508 rAT_PercentCLOG( &cmdLog );
1509 }
1510 #endif
1511
1512 return( retCd );
1513 }
1514
1515
1516 /*
1517 +-------------------------------------------------------------------+
1518 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
1519 | ROUTINE : sAT_PercentCPRI |
1520 +-------------------------------------------------------------------+
1521
1522 PURPOSE : set the CPRI mode for displaying/not displaying
1523 ciphering indications
1524 */
1525
1526 GLOBAL T_ACI_RETURN sAT_PercentCPRI( T_ACI_CMD_SRC srcId,
1527 UBYTE mode )
1528 {
1529 TRACE_FUNCTION ("sAT_PercentCPRI()");
1530
1531 if( !cmh_IsVldCmdSrc( srcId ) )
1532 {
1533 return( AT_FAIL );
1534 }
1535
1536 if (simShrdPrm.ciSIMEnabled NEQ FALSE) /* Since this function is used by MMI,it just returns AT_CMPL */
1537 {
1538 return( AT_CMPL ); /* If CPRI is enabled in the SIM,it just returns AT_CMPL */
1539 }
1540
1541 else
1542 {
1543 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
1544 return( AT_FAIL );
1545 }
1546 }
1547
1548 #ifdef FF_DUAL_SIM
1549 /*
1550 +-------------------------------------------------------------------+
1551 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
1552 | ROUTINE : sAT_PercentSIM |
1553 +-------------------------------------------------------------------+
1554
1555 PURPOSE : Select the SIM to be powered on
1556 */
1557
1558 GLOBAL T_ACI_RETURN sAT_PercentSIM( T_ACI_CMD_SRC srcId,
1559 UBYTE sim_num )
1560 {
1561 T_SIM_SET_PRM * pSIMSetPrm; /* points to SIM parameter set */
1562
1563 TRACE_FUNCTION ("sAT_PercentSIM()");
1564
1565 if( !cmh_IsVldCmdSrc( srcId ) )
1566 {
1567 return( AT_FAIL );
1568 }
1569
1570 pSIMSetPrm = &simShrdPrm.setPrm[srcId];
1571
1572 if( simEntStat.curCmd NEQ AT_CMD_NONE )
1573 {
1574 TRACE_EVENT("Entity SIM is busy: cannot proceed command...");
1575 return( AT_BUSY );
1576 }
1577
1578 if(CFUNfun EQ CFUN_FUN_Full)
1579 {
1580 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
1581 return( AT_FAIL );
1582 }
1583
1584 if(sim_num < SIM_NUM_0 OR sim_num > SIM_NUM_2)
1585 {
1586 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotAllow );
1587 return( AT_FAIL );
1588 }
1589
1590 pSIMSetPrm->SIM_Selected = sim_num;
1591
1592 simEntStat.curCmd = AT_CMD_SIM;
1593 simShrdPrm.owner = (T_OWN)srcId;
1594 simEntStat.entOwn = srcId;
1595
1596 if( psaSIM_SelectSIM() < 0 ) /* select SIM card */
1597 {
1598 TRACE_EVENT( "FATAL RETURN psaSIM in %SIM" );
1599 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal );
1600 return( AT_FAIL );
1601 }
1602 return(AT_EXCT);
1603 }
1604 #endif /*FF_DUAL_SIM*/
1605
1606 #ifdef FF_CPHS_REL4
1607 /*
1608 +-------------------------------------------------------------------+
1609 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
1610 | ROUTINE : sAT_PercentCFIS |
1611 +-------------------------------------------------------------------+
1612
1613 PURPOSE : Set/Read the CFU staus in EF-CFIS file present in SIM
1614 */
1615
1616 GLOBAL T_ACI_RETURN sAT_PercentCFIS( T_ACI_CMD_SRC srcId,
1617 T_ACI_CFIS_MOD mode,
1618 UBYTE index,
1619 UBYTE mspId,
1620 UBYTE cfuStat,
1621 CHAR* number,
1622 T_ACI_TOA* type,
1623 UBYTE cc2_id)
1624 {
1625
1626 TRACE_FUNCTION ("sAT_PercentCFIS()");
1627
1628 /*
1629 *-------------------------------------------------------------------
1630 * check command source
1631 *-------------------------------------------------------------------
1632 */
1633 if(!cmh_IsVldCmdSrc (srcId))
1634 {
1635 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1636 return( AT_FAIL );
1637 }
1638
1639 /*
1640 *-------------------------------------------------------------------
1641 * check entity status
1642 *-------------------------------------------------------------------
1643 */
1644 if( simEntStat.curCmd NEQ AT_CMD_NONE )
1645 return( AT_BUSY );
1646
1647 /*
1648 *-------------------------------------------------------------------
1649 * process parameter <mode>
1650 *-------------------------------------------------------------------
1651 */
1652 switch( mode )
1653 {
1654 case ( CFIS_MOD_Write ):
1655 case ( CFIS_MOD_Delete ):
1656 return cmhSIM_WrCfis (srcId,mode,index,mspId,cfuStat,number,
1657 type,cc2_id);
1658 default:
1659 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1660 return( AT_FAIL );
1661 }
1662 }
1663 /*
1664 +-------------------------------------------------------------------+
1665 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
1666 | ROUTINE : sAT_PercentMWIS |
1667 +-------------------------------------------------------------------+
1668
1669 PURPOSE :Set the Message Waiting status in EF-MWIS file in SIM
1670 */
1671
1672 GLOBAL T_ACI_RETURN sAT_PercentMWIS( T_ACI_CMD_SRC srcId,
1673 T_ACI_MWIS_MOD mode,
1674 UBYTE mspId,
1675 T_ACI_MWIS_MWI *mwis)
1676 {
1677
1678 TRACE_FUNCTION ("sAT_PercentMWIS()");
1679
1680 /*
1681 *-------------------------------------------------------------------
1682 * check command source
1683 *-------------------------------------------------------------------
1684 */
1685 if(!cmh_IsVldCmdSrc (srcId))
1686 {
1687 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1688 return( AT_FAIL );
1689 }
1690
1691 /*
1692 *-------------------------------------------------------------------
1693 * check entity status
1694 *-------------------------------------------------------------------
1695 */
1696 if( simEntStat.curCmd NEQ AT_CMD_NONE )
1697 return( AT_BUSY );
1698
1699 /*
1700 *-------------------------------------------------------------------
1701 * process parameter <mode>
1702 *-------------------------------------------------------------------
1703 */
1704 switch( mode )
1705 {
1706 case ( MWIS_MOD_Write ):
1707 case ( MWIS_MOD_Delete ):
1708 return cmhSIM_WrMwis (srcId,mode,mspId,mwis);
1709 break;
1710 default:
1711 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1712 return( AT_FAIL );
1713 }
1714 }
1715 /*
1716 +-------------------------------------------------------------------+
1717 | PROJECT : GSM-PS (6147) MODULE : CMH_SIMS |
1718 | ROUTINE : sAT_PercentMBDN |
1719 +-------------------------------------------------------------------+
1720
1721 PURPOSE : Set/Read the Mailbox Numbers in EF-MBDN file present in SIM
1722 */
1723
1724 GLOBAL T_ACI_RETURN sAT_PercentMBDN( T_ACI_CMD_SRC srcId,
1725 T_ACI_MBN_MODE mode,
1726 UBYTE index,
1727 CHAR* number,
1728 T_ACI_TOA* type,
1729 UBYTE cc2_id,
1730 T_ACI_PB_TEXT *text)
1731 {
1732
1733 TRACE_FUNCTION ("sAT_PercentMBDN()");
1734
1735 #ifndef NO_ASCIIZ
1736 /* convert Text */
1737 if ( text NEQ NULL )
1738 {
1739 UBYTE tmpBuf[MAX_ALPHA_LEN];
1740 USHORT len;
1741 text->cs = CS_Sim;
1742 cmh_cvtToDefGsm ( (CHAR*)text->data, (CHAR*)tmpBuf, &len );
1743 text->len = (UBYTE)len;
1744 memcpy ( text->data, tmpBuf, text->len );
1745 }
1746 #endif /* #ifndef NO_ASCIIZ */
1747 /*
1748 *-------------------------------------------------------------------
1749 * check command source
1750 *-------------------------------------------------------------------
1751 */
1752 if(!cmh_IsVldCmdSrc (srcId))
1753 {
1754 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1755 return( AT_FAIL );
1756 }
1757
1758 /*
1759 *-------------------------------------------------------------------
1760 * check entity status
1761 *-------------------------------------------------------------------
1762 */
1763 if( simEntStat.curCmd NEQ AT_CMD_NONE )
1764 return( AT_BUSY );
1765
1766 /*
1767 *-------------------------------------------------------------------
1768 * process parameter <mode>
1769 *-------------------------------------------------------------------
1770 */
1771 switch( mode )
1772 {
1773 case ( MBN_Mode_Write ):
1774 if (number EQ NULL)
1775 {
1776 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1777 return (AT_FAIL);
1778 }
1779 /* lint-fallthrough */
1780 case ( MBN_Mode_Delete ):
1781 return cmhSIM_WrMbdn (srcId, mode, index, number,
1782 type, cc2_id, text);
1783 default:
1784 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1785 return( AT_FAIL );
1786 }
1787 }
1788 #endif /* FF_CPHS_REL4 */
1789
1790
1791 /* Implements Measure 50 */
1792 /*
1793 +------------------------------------------------------------------------------
1794 | Function : cmhSIM_analyze_SIMLOCK_STATUS
1795 +------------------------------------------------------------------------------
1796 | Description : This Function will analyze the SIMLOCK STATUS, passed as an
1797 | argument to this function and accordingly returns AT_CMPL
1798 | AT_FAIL
1799 |
1800 | Parameters : status - SIMLOCK STATUS that needs to be analyzed
1801 |
1802 | Return : ACI Return Codes (Either AT_CMPL or AT_FAIL)
1803 +------------------------------------------------------------------------------
1804 */
1805
1806 LOCAL T_ACI_RETURN cmhSIM_analyze_SIMLOCK_STATUS( T_SIMLOCK_STATUS status )
1807 {
1808 TRACE_FUNCTION ( "cmhSIM_analyze_SIMLOCK_STATUS()" );
1809
1810 switch ( status )
1811 {
1812 case SIMLOCK_ENABLED:
1813 case SIMLOCK_DISABLED:
1814 /* success */
1815 return AT_CMPL;
1816
1817 case SIMLOCK_BLOCKED: /* password tried too many times, phone blocked */
1818 ACI_ERR_DESC(ACI_ERR_CLASS_Cme, CME_ERR_PhoneFail);
1819 return AT_FAIL;
1820
1821 case SIMLOCK_LOCKED: /* password wrong */
1822 ACI_ERR_DESC(ACI_ERR_CLASS_Cme, CME_ERR_WrongPasswd);
1823 return AT_FAIL;
1824
1825 default: /* other error */
1826 ACI_ERR_DESC(ACI_ERR_CLASS_Cme, CME_ERR_Unknown);
1827 return AT_FAIL;
1828 }
1829 }
1830
1831 /* Implements Measure 40 */
1832 /*
1833 +------------------------------------------------------------------------------
1834 | Function : sAT_Plus_CAMM_CACM
1835 +------------------------------------------------------------------------------
1836 | Description : This is the functional counterpart to the +CACM or +CAMM
1837 | AT commands.
1838 |
1839 | Parameters : at_cmd_id - AT command identifier
1840 | srcId - AT command source identifier
1841 | value_type - AOC_ACM or AOC_ACMMAX
1842 | value - NULL in case of +CACM
1843 | acmmax in case of +CAMM
1844 | pwd - password
1845 |
1846 | Return : ACI functional return codes
1847 +------------------------------------------------------------------------------
1848 */
1849
1850 LOCAL T_ACI_RETURN sAT_Plus_CAMM_CACM ( T_ACI_AT_CMD at_cmd_id,
1851 T_ACI_CMD_SRC srcId,
1852 UBYTE value_type,
1853 void *value,
1854 UBYTE *pwd )
1855 {
1856 T_ACI_RETURN ret = AT_FAIL;
1857
1858 TRACE_FUNCTION ( "sAT_Plus_CAMM_CACM()" );
1859 /*
1860 *-------------------------------------------------------------------
1861 * check command source
1862 *-------------------------------------------------------------------
1863 */
1864 if(!cmh_IsVldCmdSrc (srcId))
1865 {
1866 return( AT_FAIL );
1867 }
1868
1869 /*
1870 *-------------------------------------------------------------------
1871 * send parameters to advice of charge module.
1872 *-------------------------------------------------------------------
1873 */
1874 simEntStat.curCmd = at_cmd_id;
1875 simShrdPrm.owner = (T_OWN)srcId;
1876 simEntStat.entOwn = srcId;
1877 ret = aoc_set_values ( srcId,
1878 value_type,
1879 value,
1880 pwd );
1881
1882 /*
1883 *-------------------------------------------------------------------
1884 * Check return value of aoc_set_values() equal to AT_FAIL,
1885 * resets simEntStat.curcmd and simEntStat.entown.
1886 *-------------------------------------------------------------------
1887 */
1888
1889 if( ret EQ AT_FAIL )
1890 {
1891 simEntStat.curCmd = AT_CMD_NONE;
1892 simShrdPrm.owner = (T_OWN)srcId;
1893 simEntStat.entOwn = srcId;
1894 }
1895
1896 return( ret );
1897
1898 }
1899
1900
1901
1902
1903 /*==== EOF ========================================================*/