comparison src/g23m-aci/aci/cmh_sims.c @ 1:fa8dc04885d8

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