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

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