comparison src/g23m-aci/aci/aci_slock.c @ 162:53929b40109c

src/g23m-aci: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 11 Oct 2016 02:02:43 +0000
parents
children
comparison
equal deleted inserted replaced
161:4557e2a9c18e 162:53929b40109c
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul : J:\g23m-aci\aci\aci_slock.c
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 :
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifdef SIM_PERS
22 #include "aci_all.h"
23
24 #include "aci_cmh.h"
25 #include "ati_cmd.h"
26 #include "aci_cmd.h"
27
28 #ifdef FAX_AND_DATA
29 #include "aci_fd.h"
30 #endif /* FAX_AND_DATA */
31
32 #include "aci.h"
33 #include "psa.h"
34 #include "psa_sim.h"
35 #include "psa_sms.h"
36 #include "psa_mmi.h"
37 #include "cmh.h"
38 #include "dti_conn_mng.h"
39 #include "cmh_sim.h"
40 #include "phb.h"
41 #include "aoc.h"
42
43 #include "psa_sim.h" /* simShrdPrm */
44
45 #include "aci_ext_pers.h" /* we are using personalisation extensions */
46 #include "aci_slock.h" /* in order to asure interfaces */
47 #include "l4_tim.h"
48
49 /* Remember actual stati of already checked locks */
50 GLOBAL T_ACI_SLOCK_SHARED AciSLockShrd;
51
52 GLOBAL UBYTE sim_code_present_in_me; /* used by personalisation */
53 GLOBAL T_ACI_SIM_CONFIG aci_slock_sim_config; /* SIM configuration, initialised by a T_SIM_MMI_INSERT_IND */
54
55 #include "general.h" /* inluded for UINT8 compilation error in sec_drv.h */
56 #include "sec_drv.h"
57
58 GLOBAL T_SEC_DRV_CONFIGURATION *cfg_data ;
59
60 EXTERN T_SEC_DRV_CATEGORY *personalisation_nw;
61
62 EXTERN T_SEC_DRV_CATEGORY *personalisation_ns;
63
64 EXTERN T_SEC_DRV_CATEGORY *personalisation_sp;
65
66 EXTERN T_SEC_DRV_CATEGORY *personalisation_cp;
67
68 EXTERN T_SEC_DRV_CATEGORY *personalisation_sim;
69
70 EXTERN T_SEC_DRV_CATEGORY *personalisation_bnw;
71
72
73 EXTERN T_SEC_DRV_CATEGORY *personalisation_first_sim;
74 EXTERN void psaSAT_FUConfirm ( int, USHORT );
75 void aci_slock_start_timer(void);
76 const UBYTE mnc_mcc[6] = "00101"; /* 04-08-2005 */
77
78 LOCAL UBYTE aci_slock_sim_service_table [10]; /* SIM service table */
79 LOCAL T_SIMLOCK_STATUS aci_slock_check_done(T_SIMLOCK_STATUS sl_status);
80
81 EXTERN T_SIM_MMI_INSERT_IND *last_sim_mmi_insert_ind;
82
83
84 /*
85 * Conversion Table for setting the CPIN response parameter
86 */
87 const UBYTE aci_set_cpin_response [SIMLOCK_LAST][2] = {
88 { CPIN_RSLT_PhNetPukReq , CPIN_RSLT_PhNetPinReq },
89 { CPIN_RSLT_PhNetSubPukReq , CPIN_RSLT_PhNetSubPinReq },
90 { CPIN_RSLT_PhSPPukReq , CPIN_RSLT_PhSPPinReq },
91 { CPIN_RSLT_PhCorpPukReq , CPIN_RSLT_PhCorpPinReq },
92 { CPIN_RSLT_PhSimFail , CPIN_RSLT_PhSimPinReq },
93 { CPIN_RSLT_PhFSimPukReq , CPIN_RSLT_PhFSimPinReq },
94 { CPIN_RSLT_PhBlockedNetPukReq , CPIN_RSLT_PhBlockedNetPinReq}
95 };
96
97 /*
98 * Conversion Table for setting the CME ERROR Code
99 */
100 const UBYTE set_cme_error_code [SIMLOCK_LAST][2] = {
101 { CME_ERR_NetworkPersPukReq , CME_ERR_NetworkPersPinReq },
102 { CME_ERR_NetworkSubsetPersPukReq , CME_ERR_NetworkSubsetPersPinReq },
103 { CME_ERR_ProviderPersPukReq , CME_ERR_ProviderPersPinReq },
104 { CME_ERR_CorporatePersPukReq , CME_ERR_CorporatePersPinReq },
105 { CME_ERR_PhoneFail , CME_ERR_PhSimPinReq },
106 { CME_ERR_PhFSimPukReq , CME_ERR_PhFSimPinReq },
107 { EXT_ERR_BlockedNetworkPersPukReq, EXT_ERR_BlockedNetworkPersPinReq }
108 };
109 LOCAL BOOL aci_slock_compare_codegroup_with_MEPD( UBYTE personalisation,
110 UINT16 *index,
111 UBYTE *imsi_sim,
112 UBYTE code_len,
113 UBYTE len,
114 UBYTE *pBody ,BOOL bnw_flag);
115
116 LOCAL UBYTE aci_slock_compare_NSCode ( UBYTE *me_nw_code,
117 UBYTE *me_nw_ns_code_str,
118 UBYTE *imsi_sim );
119 LOCAL UBYTE aci_slock_compare_MSINCode( UBYTE *me_nw_ns_msin_msin_code_str,
120 UBYTE *imsi_sim );
121 LOCAL int aci_slock_extractCode( UBYTE *source_str, UBYTE len );
122 LOCAL UBYTE aci_slock_check_isNSCodePresent( UBYTE *me_nw_code,
123 UBYTE *imsi_sim,
124 UINT16 *index );
125 LOCAL UBYTE aci_slock_compare_gid_str( UBYTE *imsi_me,
126 UBYTE *imsi_sim,
127 UINT16 *index,
128 T_SIM_SRV grp_lvl);
129 LOCAL UBYTE aci_slock_compare_gid( UBYTE *me_gid_str,
130 UBYTE *sim_gidl,
131 UBYTE *sim_gid_str,
132 UBYTE gid_len,
133 UBYTE *pBody,
134 UINT16 *index );
135 LOCAL UBYTE aci_slock_check_isgidPresent( UBYTE *pBody,
136 UBYTE *imsi_sim,
137 UBYTE *imsi_me,
138 T_SIM_SRV grp_lvl, UINT16 *index );
139 LOCAL void aci_slock_decode_MEPD( UBYTE *pBody,
140 UINT16 *index,
141 UBYTE code_len,
142 UBYTE *imsi_ascii );
143 LOCAL void aci_slock_set_me_personalisation_status( UBYTE personalisation,
144 UBYTE status );
145
146
147
148 /*
149 +------------------------------------------------------------------------------
150 | Function : aci_slock_init
151 +------------------------------------------------------------------------------
152 | Description : Initialising of this module. Has to be called first and *once only* before
153 | calling any other method.
154 |
155 | Parameters : None
156 |
157 | Return : void
158 |
159 +------------------------------------------------------------------------------
160 */
161
162 void aci_slock_init ( void )
163 {
164
165 TRACE_FUNCTION("aci_slock_init()");
166
167 /* Initialise the ACI Personalisation extension */
168 aci_ext_personalisation_init();
169 AciSLockShrd.blocked = FALSE;
170
171 }
172
173
174
175
176 /*
177 Temporary Unlocks the lock of the given type after verifying the given password.
178 The ACI extension for password verifying (see 2.3.9.1) will be used to
179 determine if the given password is correct or not.
180 On a successful unlock the actual status of the lock will be returned.
181 If an error occurred SIMLOCK_FAIL will be returned.
182 (Uses the ACI extension "personalisation data access".)
183 */
184 T_SIMLOCK_STATUS aci_slock_authenticate ( T_SIMLOCK_TYPE type, char *passwd )
185 {
186 T_SIMLOCK_STATUS result;
187
188 TRACE_FUNCTION("aci_slock_authenticate()");
189
190 if(!aci_slock_set_CFG())
191 {
192 return SIMLOCK_FAIL;
193 }
194 result = aci_ext_personalisation_verify_password(type, passwd);
195
196 if ( (result EQ SIMLOCK_DISABLED) AND (AciSLockShrd.blocked)) /* If lock is checked as blocked at the moment uncheck it! */
197 {
198 AciSLockShrd.blocked = !(AciSLockShrd.current_lock EQ type);
199 }
200
201 MFREE(cfg_data);
202
203 if(result EQ SIMLOCK_FAIL)
204 {
205 if(!aci_slock_set_CFG())
206 {
207 return SIMLOCK_FAIL;
208 }
209 if(cfg_data->FC_Current >= cfg_data->FC_Max)
210 {
211 MFREE(cfg_data);
212 return SIMLOCK_BLOCKED;
213 }
214 MFREE(cfg_data);
215 }
216
217 return result;
218 }
219
220
221 /*
222 ACI method for retrieving the status of a single personalisation type. This method calls extension
223 methods which in turn calls Security Drv. API and retrn the status of a personalisation category.
224 The personalisation status is stored in MEPD which is directly accessed by Security Drv.
225 Added on 11/03/2005
226 */
227 T_SIMLOCK_STATUS aci_personalisation_get_status ( T_SIMLOCK_TYPE personalisation_type )
228 {
229 TRACE_FUNCTION("aci_personalisation_get_status ()");
230 return aci_ext_personalisation_get_status(personalisation_type);
231 }
232 /* #endif */
233
234
235 /*
236 +------------------------------------------------------------------------------
237 | Function : aci_slock_unlock
238 +------------------------------------------------------------------------------
239 | Description : Unlocks the lock of the given type after verifying the given password.
240 | The ACI extension for password verifying (see 2.3.9.1) will be used to
241 | determine if the given password is correct or not.
242 | On a successful unlock the actual status of the lock will be returned.
243 | If an error occurred SIMLOCK_FAIL will be returned.
244 | (Uses the ACI extension "personalisation data access".)
245 |
246 | Parameters : type - Category Lock type
247 | passwd - lock Password
248 |
249 | Return : SIMLOCK_FAIL = -1,
250 | SIMLOCK_DISABLED, No SIM lock check has to be done
251 | SIMLOCK_PERM_DISABLED,
252 | SIMLOCK_ENABLED, A SIM lock check has to be executed
253 | SIMLOCK_BLOCKED, The SIM is blocked, i.e. because of a (or to many) wrong PIN(s)
254 | SIMLOCK_LOCKED The ME is locked because of wrong SIM
255 |
256 +------------------------------------------------------------------------------
257 */
258
259 T_SIMLOCK_STATUS aci_slock_unlock ( T_SIMLOCK_TYPE type, char *passwd )
260 {
261 T_SIMLOCK_STATUS result;
262
263 TRACE_FUNCTION("aci_slock_unlock()");
264 if(aci_slock_is_timer_support() EQ TRUE)
265 {
266 if(aci_slock_check_timer() EQ TIMER_RUNNING)
267 {
268 return SIMLOCK_BUSY;
269 }
270 }
271 if(!aci_slock_set_CFG())
272 {
273 return SIMLOCK_FAIL;
274 }
275 result = aci_ext_personalisation_set_status(type, SIMLOCK_DISABLED, passwd);
276
277 if ( (result EQ SIMLOCK_DISABLED) AND (AciSLockShrd.blocked)) /* If lock is checked as blocked at the moment uncheck it! */
278 {
279 AciSLockShrd.blocked = !(AciSLockShrd.current_lock EQ type);
280 }
281 MFREE(cfg_data);
282 if((result EQ SIMLOCK_BLOCKED) OR (result EQ SIMLOCK_FAIL))
283 {
284 aci_slock_start_timer();
285 }
286 return result;
287 }
288
289
290 /*
291 +------------------------------------------------------------------------------
292 | Function : aci_slock_lock
293 +------------------------------------------------------------------------------
294 | Description : Locks the lock of the given type. On a successful lock the actual
295 | status of the lock will be returned. If an error occurred SIMLOCK_FAIL
296 | will be returned. This method will use the ACI extension for password
297 | verifying (see 2.3.9.1) to determine if the given password is correct
298 | or not. (Uses the ACI extension "personalisation data access".)
299 |
300 | Parameters : type - Category Lock type
301 | passwd - lock Password
302 |
303 | Return : SIMLOCK_FAIL = -1,
304 | SIMLOCK_DISABLED, No SIM lock check has to be done
305 | SIMLOCK_PERM_DISABLED,
306 | SIMLOCK_ENABLED, A SIM lock check has to be executed
307 | SIMLOCK_BLOCKED, The SIM is blocked, i.e. because of a (or to many) wrong PIN(s)
308 | SIMLOCK_LOCKED The ME is locked because of wrong SIM
309 |
310 +------------------------------------------------------------------------------
311 */
312 T_SIMLOCK_STATUS aci_slock_lock ( T_SIMLOCK_TYPE type, char *passwd )
313 {
314
315 T_SIMLOCK_STATUS result;
316 T_SEC_DRV_RETURN ret;
317 UBYTE imsi_sim[MAX_IMSI_LEN+1];
318 int numUserCodeIdx;
319 BOOL lock = TRUE;
320 TRACE_FUNCTION("aci_slock_lock()");
321
322 if(aci_slock_sim_config.sim_type EQ SIM_NORMAL)
323 {
324 if(!aci_slock_set_CFG())
325 {
326 return SIMLOCK_FAIL;
327 }
328 aci_ext_personalisation_init();
329 result = aci_ext_personalisation_get_status( type );
330 if(result EQ SIMLOCK_DISABLED)
331 {
332 if(cfg_data->AddNewIMSI & ( 0x0001 << type) ) /* 1-Apr-05 Bitmap check */
333 {
334 sim_code_present_in_me = FALSE;
335 psaSIM_decodeIMSI(simShrdPrm.imsi.field, simShrdPrm.imsi.c_field, (char *)imsi_sim);
336 switch(type)
337 {
338 case SIMLOCK_NETWORK: aci_slock_check_NWlock(imsi_sim, 1);break;
339 case SIMLOCK_NETWORK_SUBSET: aci_slock_check_NSlock(imsi_sim, 1);break;
340 case SIMLOCK_SIM: aci_slock_check_SMlock(imsi_sim, 1); break;
341 /*Added cases for SP & CP below: 2nd April - 2005*/
342 case SIMLOCK_SERVICE_PROVIDER:
343 if (psaSIM_ChkSIMSrvSup(SRV_GrpLvl1) )
344 {
345 if(aci_slock_sim_config.sim_read_gid1 EQ FALSE)
346 {
347 aci_slock_sim_read_sim(SIM_GID1, NOT_PRESENT_8BIT, MAX_GID);
348 aci_ext_personalisation_free();
349 MFREE(cfg_data);
350 return SIMLOCK_WAIT;
351 }
352 }
353 else
354 {
355 aci_ext_personalisation_free();
356 MFREE(cfg_data);
357 return SIMLOCK_FAIL;
358 }
359 aci_slock_check_SPlock(imsi_sim,1);break;
360 case SIMLOCK_CORPORATE:
361 if (psaSIM_ChkSIMSrvSup(SRV_GrpLvl1))
362 {
363 if(aci_slock_sim_config.sim_read_gid1 EQ FALSE)
364 {
365 aci_slock_sim_read_sim(SIM_GID1, NOT_PRESENT_8BIT, MAX_GID);
366 aci_ext_personalisation_free();
367 MFREE(cfg_data);
368 return SIMLOCK_WAIT;
369 }
370 }
371 else
372 {
373 aci_ext_personalisation_free();
374 MFREE(cfg_data);
375 return SIMLOCK_FAIL;
376 }
377 if (psaSIM_ChkSIMSrvSup(SRV_GrpLvl2))
378 {
379 if(aci_slock_sim_config.sim_read_gid2 EQ FALSE)
380 {
381 aci_slock_sim_read_sim(SIM_GID2, NOT_PRESENT_8BIT, MAX_GID);
382 aci_ext_personalisation_free();
383 MFREE(cfg_data);
384 return SIMLOCK_WAIT;
385 }
386 }
387 else
388 {
389 aci_ext_personalisation_free();
390 MFREE(cfg_data);
391 return SIMLOCK_FAIL;
392 }
393 aci_slock_check_CPlock(imsi_sim, 1);break;
394 case SIMLOCK_BLOCKED_NETWORK: sim_code_present_in_me = TRUE;
395 break;
396 default:TRACE_ERROR ("illegal type aci_slock_lock ()");
397 return SIMLOCK_FAIL;
398 }
399 if (sim_code_present_in_me EQ FALSE)
400 {
401 /* changes for ETSI behavior date : 01-Apr-05*/
402 if (cfg_data->Flags & SEC_DRV_HDR_FLAG_ETSI_Flag)
403 {
404 ret = SEC_DRV_RET_Ok ;
405 }
406 else
407 {
408 ret = sec_cmp_KEY(type,passwd,0);
409 }
410 if(ret EQ SEC_DRV_RET_Ok)
411 {
412 aci_ext_add_code(type);
413 }
414 else
415 {
416 aci_ext_personalisation_free();
417 MFREE(cfg_data);
418 return SIMLOCK_FAIL;
419 }
420 }
421 else if(sim_code_present_in_me EQ CHECK_FAIL)
422 {
423 aci_ext_personalisation_free();
424 MFREE(cfg_data);
425 return SIMLOCK_FAIL;
426 }
427 }
428
429 /*
430 * If there are no operator-defined codes or user-defined codes in the MEPD at all, do not lock the category
431 */
432 switch(type)
433 {
434 case SIMLOCK_NETWORK :
435 numUserCodeIdx = OPCODE_LEN_INDEX + ((UBYTE *)personalisation_nw->pBody)[OPCODE_LEN_INDEX] + 1;
436 if( (((UBYTE *) personalisation_nw->pBody)[OPCODE_LEN_INDEX] EQ 0) AND
437 (((UBYTE *) personalisation_nw->pBody)[numUserCodeIdx] EQ 0) )
438 {
439 /*Do not lock the category*/
440 lock = FALSE;
441 }
442 break;
443 case SIMLOCK_NETWORK_SUBSET :
444 numUserCodeIdx = OPCODE_LEN_INDEX + ((UBYTE *)personalisation_ns->pBody)[OPCODE_LEN_INDEX] + 1;
445 if( ( ((UBYTE *)personalisation_ns->pBody)[OPCODE_LEN_INDEX] EQ 0) AND
446 ( ((UBYTE *)personalisation_ns->pBody)[numUserCodeIdx] EQ 0) )
447 {
448 /*Do not lock the category*/
449 lock = FALSE;
450 }
451 break;
452 case SIMLOCK_SIM :
453 numUserCodeIdx = OPCODE_LEN_INDEX +((UBYTE *) personalisation_sim->pBody)[OPCODE_LEN_INDEX] + 1;
454 if( (((UBYTE *) personalisation_sim->pBody)[OPCODE_LEN_INDEX] EQ 0) AND
455 (((UBYTE *) personalisation_sim->pBody)[numUserCodeIdx] EQ 0) )
456 {
457 /*Do not lock the category*/
458 lock = FALSE;
459 }
460 break;
461 case SIMLOCK_SERVICE_PROVIDER:
462 numUserCodeIdx = OPCODE_LEN_INDEX + ((UBYTE *)personalisation_sp->pBody)[OPCODE_LEN_INDEX] + 1;
463 if( ( ((UBYTE *)personalisation_sp->pBody)[OPCODE_LEN_INDEX] EQ 0) AND
464 (((UBYTE *) personalisation_sp->pBody)[numUserCodeIdx] EQ 0) )
465 {
466 /*Do not lock the category*/
467 lock = FALSE;
468 }
469 break;
470 case SIMLOCK_CORPORATE:
471 numUserCodeIdx = OPCODE_LEN_INDEX + ((UBYTE *)personalisation_cp->pBody)[OPCODE_LEN_INDEX] + 1;
472 if( ( ((UBYTE *)personalisation_cp->pBody)[OPCODE_LEN_INDEX] EQ 0) AND
473 ( ((UBYTE *)personalisation_cp->pBody)[numUserCodeIdx] EQ 0) )
474 {
475 /*Do not lock the category*/
476 lock = FALSE;
477 }
478 break;
479 case SIMLOCK_BLOCKED_NETWORK :
480 numUserCodeIdx = OPCODE_LEN_INDEX + ((UBYTE *)personalisation_bnw->pBody)[OPCODE_LEN_INDEX] + 1;
481 if( (((UBYTE *) personalisation_bnw->pBody)[OPCODE_LEN_INDEX] EQ 0) AND
482 (((UBYTE *) personalisation_bnw->pBody)[numUserCodeIdx] EQ 0) )
483 {
484 /*Do not lock the category*/
485 lock = FALSE;
486 }
487 break;
488
489 }
490 if(lock EQ TRUE)
491 {
492 result = aci_ext_personalisation_set_status(type, SIMLOCK_ENABLED, passwd);
493 }
494
495 aci_ext_personalisation_free();
496 MFREE(cfg_data);
497 return result;
498 }
499 else
500 {
501 aci_ext_personalisation_free();
502 MFREE(cfg_data);
503 return SIMLOCK_FAIL;
504 }
505 }
506 else
507 return SIMLOCK_FAIL;
508 }
509
510
511 /*
512 +------------------------------------------------------------------------------
513 | Function : aci_slock_reset_fc
514 +------------------------------------------------------------------------------
515 | Description : This function is used to reset the Failure Counter
516 |
517 | Parameters : char* fcKey - Failure Reset Key
518 |
519 | Return : OPER_FAIL
520 | OPER_SUCCESS
521 |
522 +------------------------------------------------------------------------------
523 */
524
525 T_OPER_RET_STATUS aci_slock_reset_fc ( char *fcKey )
526 {
527 T_OPER_RET_STATUS result;
528 TRACE_FUNCTION("aci_slock_reset_fc ()");
529 if(!aci_slock_set_CFG())
530 {
531 return OPER_FAIL;
532 }
533 if(cfg_data->Flags & SEC_DRV_HDR_FLAG_Unlock_Timer)
534 {
535 if(aci_slock_check_timer() EQ TIMER_RUNNING)
536 {
537 return OPER_BUSY;
538 }
539 }
540 result = aci_ext_slock_reset_fc(fcKey);
541 if(result EQ OPER_WRONG_PASSWORD)
542 {
543 aci_slock_start_timer();
544 }
545 return result ;
546 }
547
548 /*
549 +------------------------------------------------------------------------------
550 | Function : aci_slock_sup_info
551 +------------------------------------------------------------------------------
552 | Description : This function is used to get the supplementary information like FCMAX,
553 | FCATTEMPTSLEFT, FCRESETFAILMAX, FCRESETFAILATTEMPTSLEFT,
554 | FCRESETSUCCESSMAX, FCRESETSUCCESSATTEMPTSLEFT, TIMERFLAG,
555 | ETSIFLAG, AIRTELINDFLAG
556 |
557 | Parameters : sup_info - Pointer to T_SUP_INFO
558 |
559 | Return : OPER_FAIL
560 | OPER_SUCCESS
561 |
562 +------------------------------------------------------------------------------
563 */
564 T_OPER_RET_STATUS aci_slock_sup_info(T_SUP_INFO *sup_info)
565 {
566 TRACE_FUNCTION("aci_slock_sup_info()");
567 return aci_ext_slock_sup_info (sup_info);
568 }
569
570
571 /*
572 +------------------------------------------------------------------------------
573 | Function : aci_slock_change_password
574 +------------------------------------------------------------------------------
575 | Description : This function is used to change the password of a category
576 |
577 | Parameters : type - Category lock type
578 | passwd - Old Control key
579 | new_passwd - New Control key
580 |
581 | Return : SIMLOCK_FAIL = -1,
582 | SIMLOCK_DISABLED, No SIM lock check has to be done
583 | SIMLOCK_PERM_DISABLED,
584 | SIMLOCK_ENABLED, A SIM lock check has to be executed
585 | SIMLOCK_BLOCKED, The SIM is blocked, i.e. because of a (or to many) wrong PIN(s)
586 | SIMLOCK_LOCKED The ME is locked because of wrong SIM
587 |
588 +------------------------------------------------------------------------------
589 */
590
591 T_OPER_RET_STATUS aci_slock_change_password ( T_SIMLOCK_TYPE type, char *passwd, char *new_passwd )
592 {
593 TRACE_FUNCTION("aci_slock_change_password()");
594 return aci_ext_personalisation_change_password(type, passwd, new_passwd);
595 }
596
597
598 /*
599 +------------------------------------------------------------------------------
600 | Function : aci_slock_psaSIM_decodeIMSI
601 +------------------------------------------------------------------------------
602 | Description : convert imsi (packed bcd to ASCIIZ; ->11.11)
603 |
604 | Parameters : imsi_field - IMSI in BCD
605 | imsi_c_field -
606 | imsi_asciiz - ASCII IMSI
607 |
608 | Return : void
609 |
610 +------------------------------------------------------------------------------
611 */
612 GLOBAL void aci_slock_psaSIM_decodeIMSI (UBYTE* imsi_field,
613 UBYTE imsi_c_field, CHAR* imsi_asciiz)
614 {
615
616 UBYTE imsi_len;
617 UBYTE i;
618 UBYTE digit;
619
620
621 /*
622
623 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
624
625 +---+---+---+---+---+---+---+---+
626 imsi_c_field = | Length indicator |
627 imsi_field[0] = | IMSI digit 1 | p | 0 | 0 | 1 |
628 imsi_field[1] = | IMSI digit 3 | IMSI digit 2 |
629
630 imsi_c_field = length indicator:
631
632 The length indicator refers to the number of significant bytes, not including this length byte,
633 required for the IMSI.
634 p = parity
635 0: Even number of IMSI digits
636 1: Odd number of IMSI digits
637
638 If the number of IMSI digits is even then bits 5 to 8 of the last octet shall be filled with an end mark coded as 1111b
639 */
640
641 /*
642 *
643 Check length
644 */
645 if ((imsi_c_field EQ 0) OR (imsi_c_field > (MAX_IMSI-1))) /* maybe 0xFF on some testcards */
646 {
647 TRACE_EVENT_P1("[WRN] imsi_c_field = %d is not valid", imsi_c_field);
648
649 imsi_asciiz[0] = '\0'; /* return empty string in case of error */
650
651 return;
652 }
653
654 /*
655 * calculate number of digits
656 */
657 imsi_len = (imsi_c_field)*2-1; /* -1 goes off for parity nibble */
658
659
660 /*
661 * if even number of digits then last upper nibble is an end mark '1111'
662 */
663 if ((imsi_field[0] & 0x08) EQ 0)
664 {
665 imsi_len--;
666 }
667
668
669
670 if ((imsi_field[0] & 0x08) EQ 0)
671 {
672 imsi_len--;
673 }
674
675 /*
676 * extract all digits
677 */
678 for (i=0; i<imsi_len; i++)
679 {
680 if ((i & 1) EQ 0)
681 {
682 /* process IMSI digit 1,3,5,... at i=0,2,4,...*/
683 digit = (imsi_field[(i+1)/2] & 0xf0) >> 4; /* +1 is to skip parity nibble */
684 }
685 else
686 {
687 /* process IMSI digit 2,4,6,... at i=1,3,5,...*/
688 digit = (imsi_field[(i+1)/2] & 0x0f);
689 }
690
691 if (digit > 9)
692 {
693 imsi_asciiz[i] = 'F';
694 /* return; */
695 }
696 else
697 {
698 imsi_asciiz[i] = '0' + digit;
699 }
700
701 }
702 imsi_asciiz[i] = '\0';
703 return;
704 }
705
706
707 /*
708 +------------------------------------------------------------------------------
709 | Function : aci_slock_psaSIM_decodeIMSI_without_parity
710 +------------------------------------------------------------------------------
711 | Description : convert imsi (packed bcd to ASCIIZ; ->11.11)
712 |
713 | Parameters : imsi_field - IMSI in BCD
714 | imsi_c_field -
715 | imsi_asciiz - ASCII IMSI
716 |
717 | Return : void
718 |
719 +------------------------------------------------------------------------------
720 */
721
722 GLOBAL void aci_slock_psaSIM_decodeIMSI_without_parity(UBYTE* imsi_field,
723 UBYTE imsi_c_field,
724 CHAR* imsi_asciiz)
725 {
726
727 UBYTE imsi_len;
728 UBYTE i;
729 UBYTE digit;
730
731 /* TRACE_FUNCTION ("aci_slock_sim_decodeIMSI()"); */
732
733 /*
734 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
735 +---+---+---+---+---+---+---+---+
736 imsi_c_field = | Length indicator |
737 imsi_field[0] = | IMSI digit 1 | p | 0 | 0 | 1 |
738 imsi_field[1] = | IMSI digit 3 | IMSI digit 2 |
739
740
741 imsi_c_field = length indicator:
742 The length indicator refers to the number of significant bytes,
743 not including this length byte, required for the IMSI.
744 p = parity
745 0: Even number of IMSI digits
746 1: Odd number of IMSI digits
747
748 If the number of IMSI digits is even then bits 5 to 8 of the last octet
749 shall be filled with an end mark coded as 1111b
750 */
751
752 /*
753 * Check length
754 */
755 if ((imsi_c_field EQ 0) OR (imsi_c_field > (MAX_IMSI-1))) /* maybe 0xFF on some testcards */
756 {
757 TRACE_EVENT_P1("[WRN] imsi_c_field = %d is not valid", imsi_c_field);
758 imsi_asciiz[0] = '\0'; /* return empty string in case of error */
759 return;
760 }
761
762 /*
763 * calculate number of digits
764 */
765 imsi_len = (imsi_c_field)*2;
766
767
768
769 /*
770 * extract all digits
771 */
772 for (i=0; i<imsi_len; i++)
773 {
774 if ((i & 1) EQ 0)
775 {
776 /* process IMSI digit 1,3,5,... at i=0,2,4,...*/
777 digit = (imsi_field[i/2] & 0x0f);
778 }
779 else
780 {
781 /* process IMSI digit 2,4,6,... at i=1,3,5,...*/
782 digit = (imsi_field[i/2] & 0xf0) >> 4; /* +1 is to skip parity nibble */
783 }
784
785 if (digit > 9)
786 {
787
788 imsi_asciiz[i] = 'F';
789 /* return; */
790 }
791 else
792 {
793 imsi_asciiz[i] = '0' + digit;
794 }
795
796
797 }
798 imsi_asciiz[i] = '\0';
799 return;
800 }
801
802
803 /*
804 +------------------------------------------------------------------------------
805 | Function : aci_slock_check_NWlock
806 +------------------------------------------------------------------------------
807 | Description : Check IMSI against network personalisation
808 |
809 | Parameters : imsi_sim - IMSI
810 | personalisation - 0-add the lock data
811 | 1-verify the existing lock data
812 |
813 | Return : void
814 |
815 +------------------------------------------------------------------------------
816 */
817
818 void aci_slock_check_NWlock( UBYTE* imsi_sim, UBYTE personalisation )
819 {
820
821 UBYTE num_op_codes;
822 UBYTE num_user_codes;
823 UBYTE code_type;
824
825 UBYTE i;
826 UINT16 index =0;
827 UBYTE imsi_me[MAX_IMSI_LEN+1];
828 UBYTE isCodeFound;
829
830 int me_nw_code_first, me_nw_code_last, sim_nw_code;
831
832 TRACE_FUNCTION("aci_slock_check_NWlock()");
833
834 /*
835 personalisation_nw->pBody[0] -----maximum number of user codes
836 personalisation_nw->pBody[1] -----num of operator codes
837 personalisation_nw->pBody[2] -----Operator Code-group length (To be set during configuration)
838 where length = total number of bytes occupied by operator codes
839
840
841 Code type = 0x0a ( Type identifier for normal code)
842 Normal code (Including parity nibble) -- 4 bytes
843
844 Code type = 0x0b (Type identifier for range)
845 Start value (Including parity nibble) ---- 4 byte
846 End value (Including parity nibble) -----4 byte
847
848 Code type = 0x0c (Type identifier for regular expression)
849 Regular Expression -------------6 byte
850
851
852 Number of User Codes --- 1 byte
853 Current user code index --- 1 byte
854 User code1 ------------4 byte
855
856 */
857 /* TRACE_FUNCTION_P1("personalisation = %d",personalisation); */
858 if((personalisation_nw NEQ NULL) AND ((UBYTE *)personalisation_nw->pBody NEQ NULL))
859 {
860 index += MAX_NUM_USERCODE_SIZE;
861 num_op_codes = ((UBYTE *)personalisation_nw->pBody)[index];
862 index += NUM_OPCODE_SIZE;
863
864 index +=OPCODE_LEN_SIZE;
865
866 /* Implements NEW Mesaure */
867 aci_slock_set_me_personalisation_status( personalisation, FALSE );
868
869 /*
870 * check operator defined code-groups
871 */
872 for(i=0; i< num_op_codes; i++)
873 {
874 code_type =((UBYTE *) personalisation_nw->pBody)[index];
875 index +=CODE_TYPE_SIZE;
876
877 switch(code_type)
878 {
879 case NORMAL_CODE :
880 /* Checks whether the NW Code is Matching with the
881 * Network Personalisation DataBase
882 */
883 if(aci_slock_compare_codegroup_with_MEPD( personalisation,
884 &index,imsi_sim,
885 NW_CODE_LEN,
886 simShrdPrm.mnc_len+3,
887 (UBYTE*)personalisation_nw->pBody,FALSE))
888 {
889 return;
890 }
891 break;
892
893 case INTERVAL_TYPE1 :
894 /* Implements New Measure */
895 aci_slock_decode_MEPD( (UBYTE *)personalisation_nw->pBody, &index,
896 NW_CODE_LEN, imsi_me );
897 /* to remove trailing F (if any) from imsi_me string */
898 imsi_me[simShrdPrm.mnc_len+3] = '\0';
899 me_nw_code_first = atoi((const char *)imsi_me);
900
901 aci_slock_decode_MEPD( (UBYTE *)personalisation_nw->pBody, &index,
902 NW_CODE_LEN, imsi_me );
903
904 imsi_me[simShrdPrm.mnc_len+3] = '\0';
905 me_nw_code_last = atoi((const char *)imsi_me);
906
907 sim_nw_code = aci_slock_extractCode( imsi_sim, simShrdPrm.mnc_len+3 );
908
909 isCodeFound = (sim_nw_code >= me_nw_code_first ) AND
910 (sim_nw_code <= me_nw_code_last);
911
912 aci_slock_set_me_personalisation_status ( personalisation,
913 isCodeFound );
914
915 if( isCodeFound )
916 {
917 return;
918 }
919 break;
920
921 case REGULAR_EXP :
922 break;
923
924 default :
925 break;
926 }
927 }
928
929 num_user_codes = ((UBYTE *)personalisation_nw->pBody)[index];
930 index +=NUM_USER_CODE_SIZE;
931 index +=CURR_USER_CODE_INDEX_SIZE;
932
933 /*
934 * check user defined code-groups
935 */
936 for(i=0; i< num_user_codes; i++)
937 {
938
939 /*
940 * Checks whether the NW Code is Matching with the
941 * Network Personalisation DataBase
942 */
943 if(aci_slock_compare_codegroup_with_MEPD( personalisation,
944 &index,imsi_sim,
945 NW_CODE_LEN,
946 simShrdPrm.mnc_len+3,
947 (UBYTE*)personalisation_nw->pBody,FALSE))
948 {
949 return;
950 }
951 }
952 }
953 }
954
955
956 /*
957 +------------------------------------------------------------------------------
958 | Function : aci_slock_check_NSlock
959 +------------------------------------------------------------------------------
960 | Description : Check IMSI against network subset personalisation
961 |
962 | Parameters : imsi_sim - IMSI
963 | personalisation - 0-add the lock data
964 | 1-verify the existing lock data
965 |
966 | Return : void
967 |
968 +------------------------------------------------------------------------------
969 */
970 void aci_slock_check_NSlock( UBYTE* imsi_sim, UBYTE personalisation )
971 {
972 UBYTE num_op_codes;
973 UBYTE num_user_codes;
974 UBYTE code_type;
975 UBYTE cmp_result;
976 UINT16 index =0;
977 UBYTE me_nw_code[MAX_IMSI_LEN+1];
978 UBYTE me_nw_ns_ns_code_str[6+2+2+1];
979
980 int i ;
981
982 TRACE_FUNCTION("aci_slock_check_NSlock()");
983
984 /*
985 personalisation_ns->pBody[0] -----maximum number of user codes
986 personalisation_ns->pBody[1] -----num of operator codes
987 personalisation_ns->pBody[2] -----Operator Code-group length (To be set during configuration)
988 where length = total number of bytes occupied by operator codes
989
990
991 Code type = 0x0a ( Type identifier for normal code)
992 Normal code (Including parity nibble) -- 5 bytes (Nw code + NS code)
993
994 Code type = 0x0b (Type identifier for range)
995 Network code --------- 4 byte
996 Start value of NS code ---- 1 byte
997 End value of NS code -----1 byte
998
999 Code type = 0x0c (Type identifier for regular expression)
1000 Regular expression including Network + NS Code -------------8 byte
1001
1002 Code type = 0x0d
1003 (8thdigit normal code/range)
1004 Network code (Including parity nibble) ------ 4 byte
1005 No. of 8th digit values for which normal codes and/or intervals are to be stored ---- 1 byte
1006 8th digit value -- 1 byte
1007 No. of normal codes to be associated with the digit (n1) ---- 1 byte
1008 No. of intervals to be associated with the digit (n2) ----- 1 byte
1009 Normal code 1 --- 1 byte
1010 |
1011 |
1012 |
1013 Normal code n1 ---- 1 byte
1014
1015 Start value of interval 1 ---- 1 byte
1016 End value of interval 1 ---- 1 byte
1017 |
1018 |
1019 |
1020 Start value of interval n2 ------ 1 byte
1021 End value of interval n2 ------- 1 byte
1022
1023 Number of User Codes ------- 1 byt e
1024 Current user code index
1025 (for FIFO based addition/deletion of user codes)
1026 (should be set to 0xff if no user codes are present) ---- 1 byte
1027
1028 User code1 ---------- 5 byte
1029 User code 2 ---------- 5 byte
1030 |
1031 |
1032 User code n (n = Max number of user codes for NS) -- 5 byte
1033
1034
1035 */
1036
1037 /* Implements NEW Mesaure */
1038 aci_slock_set_me_personalisation_status( personalisation, FALSE );
1039 if((personalisation_ns NEQ NULL) AND ((UBYTE *)personalisation_ns->pBody NEQ NULL))
1040 {
1041 index += MAX_NUM_USERCODE_SIZE;
1042 num_op_codes =((UBYTE *) personalisation_ns->pBody)[index];
1043 index += NUM_OPCODE_SIZE;
1044
1045 index +=OPCODE_LEN_SIZE;
1046
1047 /*
1048 * check operator defined code-groups
1049 */
1050 for(i=0; i< num_op_codes; i++)
1051 {
1052 code_type = ((UBYTE *)personalisation_ns->pBody)[index];
1053 index +=CODE_TYPE_SIZE;
1054 switch(code_type)
1055 {
1056 case NORMAL_CODE :
1057 /*
1058 * Checks whether the NS Code is Matching with the
1059 * Network Subset Personalisation DataBase
1060 */
1061 if (aci_slock_compare_codegroup_with_MEPD( personalisation,
1062 &index, imsi_sim,
1063 NW_NS_CODE_LEN,
1064 simShrdPrm.mnc_len+3+2,
1065 (UBYTE*)personalisation_ns->pBody,FALSE))
1066 {
1067 return;
1068 }
1069
1070 break;
1071
1072 case INTERVAL_TYPE1 :
1073
1074 aci_slock_decode_MEPD( (UBYTE *)personalisation_ns->pBody, &index,
1075 NW_NS_NS_CODE_LEN, me_nw_ns_ns_code_str );
1076 memcpy(me_nw_code,me_nw_ns_ns_code_str,simShrdPrm.mnc_len+3);
1077 /* Compare the NS Code */
1078 cmp_result = aci_slock_compare_NSCode( me_nw_code,
1079 me_nw_ns_ns_code_str,
1080 imsi_sim );
1081
1082
1083 aci_slock_set_me_personalisation_status( personalisation,
1084 cmp_result );
1085
1086 if ( cmp_result )
1087 {
1088 /*
1089 * The Network Code and the Network subset code matches,
1090 * hence return
1091 */
1092 return;
1093 }
1094 break;
1095
1096 case INTERVAL_TYPE2 :
1097 TRACE_FUNCTION("INTERVAL_TYPE2");
1098 aci_slock_decode_MEPD( (UBYTE *)personalisation_ns->pBody, &index,
1099 NW_CODE_LEN, me_nw_code );
1100
1101 index += 1;
1102
1103 /* Implements Measure 212 */
1104 cmp_result = aci_slock_check_isNSCodePresent( me_nw_code, imsi_sim, &index );
1105
1106 aci_slock_set_me_personalisation_status( personalisation, cmp_result );
1107
1108 if ( cmp_result )
1109 {
1110 return;
1111 }
1112 break;
1113
1114 case REGULAR_EXP :
1115 break;
1116
1117 default :
1118 break;
1119 }
1120 }
1121
1122 num_user_codes = ((UBYTE *)personalisation_ns->pBody)[index];
1123 index +=NUM_USER_CODE_SIZE;
1124
1125 index +=CURR_USER_CODE_INDEX_SIZE;
1126 /*
1127 * check user defined code-groups
1128 */
1129 for(i=0; i< num_user_codes; i++)
1130 {
1131
1132 /* Checks whether the NS Code is Matching with the
1133 * Network Subset Personalisation DataBase
1134 */
1135 if(aci_slock_compare_codegroup_with_MEPD( personalisation,
1136 &index, imsi_sim,
1137 NW_NS_CODE_LEN,
1138 simShrdPrm.mnc_len+3+2,
1139 (UBYTE*)personalisation_ns->pBody,FALSE))
1140 {
1141 return;
1142 }
1143 }
1144 }
1145 }
1146
1147
1148 /*
1149 +------------------------------------------------------------------------------
1150 | Function : aci_slock_check_SPlock
1151 +------------------------------------------------------------------------------
1152 | Description : Check IMSI against service provider personalisation
1153 |
1154 | Parameters : imsi_sim - IMSI
1155 | personalisation - 0-add the lock data
1156 | 1-verify the existing lock data
1157 |
1158 | Return : void
1159 |
1160 +------------------------------------------------------------------------------
1161 */
1162 void aci_slock_check_SPlock( UBYTE* imsi_sim, UBYTE personalisation )
1163 {
1164 UBYTE num_op_codes;
1165 UBYTE num_user_codes;
1166 UBYTE code_type;
1167 UBYTE cmp_result;
1168 UINT16 index =0;
1169 UBYTE imsi_me[MAX_IMSI_LEN+1];
1170 int i;
1171
1172 TRACE_FUNCTION("aci_slock_check_SPlock()");
1173
1174 #if 0 // TISH patch for OMAPS00120012
1175 if((aci_slock_sim_config.sim_gidl1[0] EQ NOT_PRESENT_8BIT) OR (aci_slock_sim_config.gid1_len NEQ cfg_data->GID1_Len))
1176 #else
1177 if(aci_slock_sim_config.sim_gidl1[0] EQ NOT_PRESENT_8BIT)
1178 #endif
1179 {
1180
1181 TRACE_FUNCTION_P1("aci_slock_sim_config.sim_gidl1[0] %d", aci_slock_sim_config.sim_gidl1[0]);
1182 if(!personalisation)
1183 {
1184 AciSLockShrd.blocked = TRUE;
1185 }
1186 else
1187 {
1188 sim_code_present_in_me = CHECK_FAIL;
1189 }
1190 return;
1191 }
1192 else
1193 {
1194
1195
1196 /*
1197 personalisation_sp->pBody[0] -----maximum number of user codes
1198 personalisation_sp->pBody[1] -----num of operator codes
1199 personalisation_sp->pBody[2] -----Operator Code-group length (To be set during configuration)
1200 where length = total number of bytes occupied by operator codes
1201
1202
1203 Code type = 0x0a ( Type identifier for normal code)
1204 Normal code (Including parity nibble) -- 8 bytes (Network code + GID1 value)
1205
1206 Code type = 0x0b (Type identifier for range)
1207 Network code --------- 4 byte
1208 Start GID1 ---- -------4 byte
1209 End GID1 -------------4 byte
1210
1211 Code type = 0x0c (Type identifier for regular expression)
1212 Regular Expression (including NW code and GID1 value) --- 10 byte
1213
1214 Number of User Codes ------- 1 byt e
1215 Current user code index
1216 (for FIFO based addition/deletion of user codes)
1217 (should be set to 0xff if no user codes are present) ---- 1 byte
1218
1219 User code1 ---------- 8 byte
1220 User code 2 ---------- 8 byte
1221 |
1222 |
1223 User code n (n = Max number of user codes for NS) -- 8 byte
1224
1225
1226 */
1227 aci_slock_set_me_personalisation_status( personalisation, FALSE );
1228
1229 if((personalisation_sp NEQ NULL) AND ((UBYTE *)personalisation_sp->pBody NEQ NULL))
1230 {
1231 index += MAX_NUM_USERCODE_SIZE;
1232 num_op_codes = ((UBYTE *)personalisation_sp->pBody)[index];
1233 index += NUM_OPCODE_SIZE;
1234
1235 index +=OPCODE_LEN_SIZE;
1236
1237 /*
1238 * check operator defined code-groups
1239 */
1240 for(i=0; i< num_op_codes; i++)
1241 {
1242 code_type = ((UBYTE *)personalisation_sp->pBody)[index];
1243 index +=CODE_TYPE_SIZE;
1244 if( ((code_type)&0xf0)>>4)
1245 {
1246 imsi_me[0] = 0;
1247 }
1248 else
1249 {
1250 aci_slock_decode_MEPD( (UBYTE *)personalisation_sp->pBody, &index,
1251 NW_CODE_LEN, imsi_me );
1252 }
1253 switch(code_type)
1254 {
1255 case NORMAL_CODE :
1256
1257 cmp_result = aci_slock_check_isgidPresent( (UBYTE *)personalisation_sp->pBody,
1258 imsi_sim, imsi_me,
1259 SRV_GrpLvl1, &index );
1260 aci_slock_set_me_personalisation_status( personalisation,
1261 cmp_result );
1262
1263 if (cmp_result)
1264 {
1265 return;
1266 }
1267
1268 break;
1269
1270 case INTERVAL_TYPE1 :
1271 cmp_result = aci_slock_compare_gid_str ( imsi_me, imsi_sim, &index,SRV_GrpLvl1);
1272 aci_slock_set_me_personalisation_status( personalisation, cmp_result );
1273 if (cmp_result)
1274 {
1275 return;
1276 }
1277 break;
1278
1279 case REGULAR_EXP :
1280 break;
1281 default :
1282 break;
1283 }
1284 }
1285
1286 num_user_codes = ((UBYTE *)personalisation_sp->pBody)[index];
1287 index +=NUM_USER_CODE_SIZE;
1288 index +=CURR_USER_CODE_INDEX_SIZE;
1289 /*
1290 * check user defined code-groups
1291 */
1292 for(i=0; i< num_user_codes; i++)
1293 {
1294
1295 aci_slock_decode_MEPD( (UBYTE *)personalisation_sp->pBody, &index,
1296 NW_CODE_LEN, imsi_me );
1297 cmp_result = aci_slock_check_isgidPresent( (UBYTE *)personalisation_sp->pBody,
1298 imsi_sim, imsi_me, SRV_GrpLvl1,&index );
1299 aci_slock_set_me_personalisation_status( personalisation,
1300 cmp_result );
1301 if (cmp_result)
1302 {
1303 return;
1304 }
1305 }
1306 }
1307 }
1308 }
1309
1310
1311 /*
1312 +------------------------------------------------------------------------------
1313 | Function : aci_slock_check_CPlock
1314 +------------------------------------------------------------------------------
1315 | Description : Check IMSI against service corporate personalisation
1316 |
1317 | Parameters : imsi_sim - IMSI
1318 | personalisation - 0-add the lock data
1319 | 1-verify the existing lock data
1320 |
1321 | Return : void
1322 |
1323 +------------------------------------------------------------------------------
1324 */
1325 void aci_slock_check_CPlock( UBYTE* imsi_sim, UBYTE personalisation)
1326 {
1327 UBYTE num_op_codes;
1328 UBYTE num_user_codes;
1329
1330 UBYTE code_type;
1331 UBYTE cmp_result;
1332
1333 UINT16 index =0;
1334 UBYTE imsi_me[MAX_IMSI_LEN+1];
1335
1336 int i;
1337
1338 TRACE_FUNCTION("aci_slock_check_CPlock()");
1339
1340
1341
1342 #if 0 // TISH patch for OMAPS00120012
1343 if((aci_slock_sim_config.sim_gidl1[0] EQ NOT_PRESENT_8BIT) OR (aci_slock_sim_config.sim_gidl2[0] EQ NOT_PRESENT_8BIT)
1344 OR (aci_slock_sim_config.gid1_len NEQ cfg_data->GID1_Len) OR (aci_slock_sim_config.gid2_len NEQ cfg_data->GID2_Len))
1345 #else
1346 if((aci_slock_sim_config.sim_gidl1[0] EQ NOT_PRESENT_8BIT) OR (aci_slock_sim_config.sim_gidl2[0] EQ NOT_PRESENT_8BIT))
1347 #endif
1348 {
1349 if(!personalisation)
1350 {
1351 AciSLockShrd.blocked = TRUE;
1352 }
1353 else
1354 {
1355 sim_code_present_in_me = CHECK_FAIL;
1356 }
1357 return;
1358 }
1359 else
1360 {
1361
1362
1363 /*
1364 personalisation_cp->pBody[0] -----maximum number of user codes
1365 personalisation_cp->pBody[1] -----num of operator codes
1366 personalisation_cp->pBody[2] -----Operator Code-group length (To be set during configuration)
1367 where length = total number of bytes occupied by operator codes
1368
1369
1370 Code type = 0x0a ( Type identifier for normal code)
1371 Normal code (Including parity nibble) -- 12 bytes (Network code + GID1 value + GID2 value)
1372
1373 Code type = 0x0b (Type identifier for range)
1374 Network code --------- 4 byte
1375 GID1 value------------4 byte
1376 Start GID1 ---- -------4 byte
1377 End GID1 -------------4 byte
1378
1379 Code type = 0x0c (Type identifier for regular expression)
1380 Regular Expression (including NW code, GID1 value and GID2 value) --- 14 byte
1381
1382 Number of User Codes ------- 1 byt e
1383 Current user code index
1384 (for FIFO based addition/deletion of user codes)
1385 (should be set to 0xff if no user codes are present) ---- 1 byte
1386
1387 User code1 ---------- 12 byte
1388 User code 2 ---------- 12 byte
1389 |
1390 |
1391 User code n (n = Max number of user codes for NS) -- 12 byte
1392
1393
1394 */
1395
1396 /* Implements NEW Mesaure */
1397 aci_slock_set_me_personalisation_status( personalisation, FALSE );
1398
1399 if((personalisation_cp NEQ NULL) AND ((UBYTE *)personalisation_cp->pBody NEQ NULL))
1400 {
1401 index += MAX_NUM_USERCODE_SIZE;
1402 num_op_codes = ((UBYTE *)personalisation_cp->pBody)[index];
1403 index += NUM_OPCODE_SIZE;
1404
1405 index +=OPCODE_LEN_SIZE;
1406 /*
1407 * check operator defined code-groups
1408 */
1409 for(i=0; i< num_op_codes; i++)
1410 {
1411 code_type = ((UBYTE *)personalisation_cp->pBody)[index];
1412 index +=CODE_TYPE_SIZE;
1413 if( ((code_type)&0xf0)>>4)
1414 {
1415 imsi_me[0] = 0;
1416 }
1417 else
1418 {
1419 aci_slock_decode_MEPD( (UBYTE *)personalisation_sp->pBody, &index,
1420 NW_CODE_LEN, imsi_me );
1421 }
1422 switch(code_type)
1423 {
1424 case NORMAL_CODE :
1425 cmp_result = aci_slock_check_isgidPresent( (UBYTE *)personalisation_cp->pBody,
1426 imsi_sim, imsi_me,
1427 SRV_GrpLvl2, &index );
1428
1429 aci_slock_set_me_personalisation_status( personalisation,
1430 cmp_result );
1431
1432 if (cmp_result)
1433 {
1434 return;
1435 }
1436
1437 break;
1438
1439 case INTERVAL_TYPE1 :
1440 cmp_result = aci_slock_compare_gid_str ( imsi_me, imsi_sim, &index,SRV_GrpLvl2);
1441
1442 aci_slock_set_me_personalisation_status( personalisation, cmp_result );
1443
1444 if (cmp_result)
1445 {
1446 return;
1447 }
1448 break;
1449
1450 case REGULAR_EXP :
1451 break;
1452
1453 default :
1454 break;
1455 }
1456 }
1457
1458 num_user_codes = ((UBYTE *)personalisation_cp->pBody)[index];
1459 index +=NUM_USER_CODE_SIZE;
1460 index +=CURR_USER_CODE_INDEX_SIZE;
1461 /*
1462 * check user defined code-groups
1463 */
1464 for(i=0; i< num_user_codes; i++)
1465 {
1466
1467 aci_slock_decode_MEPD( (UBYTE *)personalisation_cp->pBody, &index,
1468 NW_CODE_LEN, imsi_me );
1469
1470 cmp_result = aci_slock_check_isgidPresent( (UBYTE *)personalisation_cp->pBody,
1471 imsi_sim, imsi_me,
1472 SRV_GrpLvl2,&index );
1473
1474 aci_slock_set_me_personalisation_status( personalisation,cmp_result );
1475
1476 if (cmp_result)
1477 {
1478 return;
1479 }
1480 }
1481 }
1482 }
1483
1484 }
1485
1486
1487 /*
1488 +------------------------------------------------------------------------------
1489 | Function : aci_slock_check_SMlock
1490 +------------------------------------------------------------------------------
1491 | Description : Check IMSI against SIM personalisation
1492 |
1493 | Parameters : imsi_sim - IMSI
1494 | personalisation - 0-add the lock data
1495 | 1-verify the existing lock data
1496 |
1497 | Return : void
1498 |
1499 +------------------------------------------------------------------------------
1500 */
1501 void aci_slock_check_SMlock( UBYTE* imsi_sim, UBYTE personalisation)
1502 {
1503 UBYTE num_op_codes;
1504 UBYTE num_user_codes;
1505 UBYTE cmp_result;
1506 UBYTE code_type;
1507
1508 UBYTE i;
1509 UINT16 index =0;
1510
1511 UBYTE me_nw_ns_msin_msin_code_str[6+2+8+8+1];
1512
1513
1514 TRACE_FUNCTION("aci_slock_check_SMlock()");
1515
1516 /*
1517 personalisation_sim->pBody[0] -----maximum number of user codes
1518 personalisation_sim->pBody[1] -----num of operator codes
1519 personalisation_sim->pBody[2] -----Operator Code-group length (To be set during configuration)
1520 where length = total number of bytes occupied by operator codes
1521
1522
1523 Code type = 0x0a ( Type identifier for normal code)
1524 Normal code (Including parity nibble) -- 8 bytes (Network code + NS code + MSIN)
1525
1526 Code type = 0x0b (Type identifier for range)
1527 Network code + NS code --------- 5 byte
1528 Start MSIN ---- -------4 byte
1529 End MSIN -------------4 byte
1530
1531 Code type = 0x0c (Type identifier for regular expression)
1532 Regular Expression (including NW code NS code and MSIN) --- 15 byte
1533
1534 Number of User Codes ------- 1 byt e
1535 Current user code index
1536 (for FIFO based addition/deletion of user codes)
1537 (should be set to 0xff if no user codes are present) ---- 1 byte
1538
1539 User code1 ---------- 8 byte
1540 User code 2 ---------- 8 byte
1541 |
1542 |
1543 User code n (n = Max number of user codes for NS) -- 8 byte
1544
1545
1546 */
1547
1548 aci_slock_set_me_personalisation_status( personalisation, FALSE );
1549
1550 if((personalisation_sim NEQ NULL) AND ((UBYTE *)personalisation_sim->pBody NEQ NULL))
1551 {
1552 index += MAX_NUM_USERCODE_SIZE;
1553 num_op_codes =((UBYTE *) personalisation_sim->pBody)[index];
1554 index += NUM_OPCODE_SIZE;
1555
1556 index +=OPCODE_LEN_SIZE;
1557
1558 /*
1559 * check operator defined code-groups
1560 */
1561 for(i=0; i< num_op_codes; i++)
1562 {
1563 code_type = ((UBYTE *)personalisation_sim->pBody)[index];
1564 index +=CODE_TYPE_SIZE;
1565
1566 switch(code_type)
1567 {
1568 case NORMAL_CODE :
1569 if(aci_slock_compare_codegroup_with_MEPD( personalisation,
1570 &index, imsi_sim,
1571 NW_NS_MSIN_CODE_LEN,
1572 MAX_IMSI_LEN,
1573 (UBYTE*)personalisation_sim->pBody,FALSE))
1574 {
1575 return;
1576 }
1577
1578 break;
1579
1580 case INTERVAL_TYPE1 :
1581 aci_slock_decode_MEPD( (UBYTE *)personalisation_sim->pBody, &index,
1582 NW_NS_MSIN_MSIN_CODE_LEN,
1583 me_nw_ns_msin_msin_code_str );
1584
1585 cmp_result = aci_slock_compare_MSINCode( me_nw_ns_msin_msin_code_str,
1586 imsi_sim );
1587
1588 aci_slock_set_me_personalisation_status( personalisation,cmp_result );
1589
1590 if ( cmp_result EQ TRUE )
1591 {
1592 /*
1593 * The Network subset code and MSIN code matches,
1594 * hence return
1595 */
1596 return;
1597 }
1598 break;
1599
1600 case REGULAR_EXP :
1601 break;
1602 default :
1603 break;
1604 }
1605 }
1606
1607 num_user_codes = ((UBYTE *)personalisation_sim->pBody)[index];
1608 index +=NUM_USER_CODE_SIZE;
1609
1610 index +=CURR_USER_CODE_INDEX_SIZE;
1611 /*
1612 * check user defined code-groups
1613 */
1614 for(i=0; i< num_user_codes; i++)
1615 {
1616
1617 /*
1618 * Checks whether the MSIN Code is Matching with the
1619 * SIM Personalisation DataBase
1620 */
1621 if(aci_slock_compare_codegroup_with_MEPD( personalisation,
1622 &index, imsi_sim,
1623 NW_NS_MSIN_CODE_LEN,
1624 MAX_IMSI_LEN,
1625 (UBYTE*)personalisation_sim->pBody,FALSE))
1626 {
1627 return;
1628 }
1629 }
1630 }
1631 }
1632
1633 /*
1634 +------------------------------------------------------------------------------
1635 | Function : aci_slock_check_BNWlock
1636 +------------------------------------------------------------------------------
1637 | Description : Check IMSI against blocked network personalisation
1638 |
1639 | Parameters : imsi_sim - IMSI
1640 | personalisation - 0-add the lock data
1641 | 1-verify the existing lock data
1642 |
1643 | Return : void
1644 |
1645 +------------------------------------------------------------------------------
1646 */
1647
1648 void aci_slock_check_BNWlock( UBYTE* imsi_sim, UBYTE personalisation )
1649 {
1650
1651 UBYTE num_op_codes;
1652 UBYTE num_user_codes;
1653 UBYTE code_type;
1654
1655 UBYTE i;
1656 UINT16 index =0;
1657 UBYTE imsi_me[MAX_IMSI_LEN+1];
1658 UBYTE isCodeFound;
1659
1660 int me_bnw_code_first, me_bnw_code_last, sim_bnw_code;
1661
1662 TRACE_FUNCTION("aci_slock_check_NWlock()");
1663
1664 /*
1665 personalisation_bnw->pBody[0] -----maximum number of user codes
1666 personalisation_bnw->pBody[1] -----num of operator codes
1667 personalisation_bnw->pBody[2] -----Operator Code-group length (To be set during configuration)
1668 where length = total number of bytes occupied by operator codes
1669
1670
1671 Code type = 0x0a ( Type identifier for normal code)
1672 Normal code (Including parity nibble) -- 4 bytes
1673
1674 Code type = 0x0b (Type identifier for range)
1675 Start value (Including parity nibble) ---- 4 byte
1676 End value (Including parity nibble) -----4 byte
1677
1678 Code type = 0x0c (Type identifier for regular expression)
1679 Regular Expression -------------6 byte
1680
1681
1682 Number of User Codes --- 1 byte
1683 Current user code index --- 1 byte
1684 User code1 ------------4 byte
1685
1686 */
1687 /* TRACE_FUNCTION_P1("personalisation = %d",personalisation); */
1688 if((personalisation_bnw NEQ NULL) AND ((UBYTE *)personalisation_bnw->pBody NEQ NULL))
1689 {
1690 index += MAX_NUM_USERCODE_SIZE;
1691 num_op_codes = ((UBYTE *)personalisation_bnw->pBody)[index];
1692 index += NUM_OPCODE_SIZE;
1693
1694 index +=OPCODE_LEN_SIZE;
1695
1696 /* Implements NEW Mesaure */
1697 aci_slock_set_me_personalisation_status( personalisation, TRUE );
1698
1699 /*
1700 * check operator defined code-groups
1701 */
1702 for(i=0; i< num_op_codes; i++)
1703 {
1704 code_type =((UBYTE *) personalisation_bnw->pBody)[index];
1705 index +=CODE_TYPE_SIZE;
1706
1707 switch(code_type)
1708 {
1709 case NORMAL_CODE :
1710 /* Checks whether the NW Code is Matching with the
1711 * Network Personalisation DataBase
1712 */
1713 if (aci_slock_compare_codegroup_with_MEPD( personalisation,
1714 &index, imsi_sim,
1715 NW_CODE_LEN,
1716 simShrdPrm.mnc_len+3,
1717 (UBYTE*)personalisation_bnw->pBody,TRUE))
1718 {
1719 return;
1720 }
1721 break;
1722
1723 case INTERVAL_TYPE1 :
1724 /* Implements New Measure */
1725 aci_slock_decode_MEPD( (UBYTE *)personalisation_bnw->pBody, &index,
1726 NW_CODE_LEN, imsi_me );
1727 /* to remove trailing F (if any) from imsi_me string */
1728 imsi_me[simShrdPrm.mnc_len+3] = '\0';
1729 me_bnw_code_first = atoi((const char *)imsi_me);
1730
1731 aci_slock_decode_MEPD( (UBYTE *)personalisation_bnw->pBody, &index,
1732 NW_CODE_LEN, imsi_me );
1733
1734 imsi_me[simShrdPrm.mnc_len+3] = '\0';
1735 me_bnw_code_last = atoi((const char *)imsi_me);
1736
1737 sim_bnw_code = aci_slock_extractCode( imsi_sim, simShrdPrm.mnc_len+3 );
1738
1739 isCodeFound = (sim_bnw_code >= me_bnw_code_first ) AND
1740 (sim_bnw_code <= me_bnw_code_last);
1741
1742 aci_slock_set_me_personalisation_status ( personalisation, !isCodeFound );
1743
1744 if( isCodeFound )
1745 {
1746 return;
1747 }
1748 break;
1749
1750 case REGULAR_EXP :
1751 break;
1752
1753 default :
1754 break;
1755 }
1756 }
1757
1758 num_user_codes = ((UBYTE *)personalisation_bnw->pBody)[index];
1759 index +=NUM_USER_CODE_SIZE;
1760
1761 index +=CURR_USER_CODE_INDEX_SIZE;
1762
1763 /*
1764 * check user defined code-groups
1765 */
1766 for(i=0; i< num_user_codes; i++)
1767 {
1768
1769 /*
1770 * Checks whether the NW Code is Matching with the
1771 * Network Personalisation DataBase
1772 */
1773 if(aci_slock_compare_codegroup_with_MEPD( personalisation,
1774 &index,imsi_sim,
1775 NW_CODE_LEN,
1776 simShrdPrm.mnc_len+3,
1777 (UBYTE*)personalisation_bnw->pBody,TRUE))
1778 {
1779 return;
1780 }
1781 }
1782 }
1783 }
1784
1785
1786
1787 /*
1788 +------------------------------------------------------------------------------
1789 | Function : aci_slock_checkpersonalisation
1790 +------------------------------------------------------------------------------
1791 | Description : Checks for all kinds of personalisation locks (except sp & cp : Apr 03,2005).
1792 | The given IMSI will be checked against the internal personalisation data.
1793 | Returns SIMLOCK_BLOCKED, if one lock was not matching the given IMSI.
1794 |
1795 | Parameters : None
1796 |
1797 | Return : SIMLOCK_FAIL = -1,
1798 | SIMLOCK_DISABLED, No SIM lock check has to be done
1799 | SIMLOCK_PERM_DISABLED,
1800 | SIMLOCK_ENABLED, A SIM lock check has to be executed
1801 | SIMLOCK_BLOCKED, The SIM is blocked, i.e. because of a (or to many) wrong PIN(s)
1802 | SIMLOCK_LOCKED The ME is locked because of wrong SIM
1803 |
1804 +------------------------------------------------------------------------------
1805 */
1806 T_SIMLOCK_STATUS aci_slock_checkpersonalisation(T_SIMLOCK_TYPE current_lock)
1807 {
1808 T_SIMLOCK_TYPE type;
1809
1810 UBYTE imsi_sim[MAX_IMSI_LEN+1];
1811 T_SIMLOCK_STATUS sl_status=SIMLOCK_FAIL;
1812 T_AUTOLOCK_STATUS al_status;
1813
1814 TRACE_FUNCTION("aci_slock_checkpersonalisation()");
1815
1816 psaSIM_decodeIMSI(simShrdPrm.imsi.field, simShrdPrm.imsi.c_field, (char *)imsi_sim);
1817
1818 /*
1819 * Test SIM
1820 */
1821 if(memcmp(imsi_sim,mnc_mcc,5) EQ 0)
1822 {
1823 aci_slock_set_simtype(SIM_TEST);
1824 switch(cfg_data->TestCPHS)
1825 {
1826 case ALWAYS_ACCEPTED :
1827 TRACE_FUNCTION("TEST SIM: always accepted");
1828 return( aci_slock_check_done(SIMLOCK_ENABLED));
1829 case ALWAYS_REJECTED :
1830 TRACE_FUNCTION("TEST SIM: always rejected");
1831 break;
1832 }
1833 }
1834 /*
1835 * type approval
1836 */
1837 else if(aci_slock_sim_config.sim_read_ad_first_byte & 0x80)
1838 {
1839 TRACE_FUNCTION("sim type: Classic Test SIM (Type Approval SIM)");
1840 aci_slock_set_simtype(SIM_TYPEAPPROVAL);
1841 switch(cfg_data->TypeAprovalSIM)
1842 {
1843 case ALWAYS_ACCEPTED :
1844 TRACE_FUNCTION("type approval: always accepted");
1845 return( aci_slock_check_done(SIMLOCK_ENABLED));
1846 /* break is removed ,as case is returning before break so it is not needed */
1847 case ALWAYS_REJECTED :
1848 TRACE_FUNCTION("type approval: always rejected");
1849 for (type=SIMLOCK_NETWORK; type<=SIMLOCK_SIM; type++)
1850 {
1851 if(AciSLockShrd.status[type] EQ SIMLOCK_ENABLED)
1852 {
1853 sl_status = SIMLOCK_BLOCKED;
1854 AciSLockShrd.blocked = TRUE;
1855 break;
1856 }
1857 }
1858 if(AciSLockShrd.blocked NEQ TRUE)
1859 {
1860 sl_status = SIMLOCK_ENABLED ;
1861 }
1862 return(aci_slock_check_done(sl_status));
1863 /* break is removed ,as case is returning before break so it is not needed */
1864
1865 case UNTIL_NORMAL_SIM :
1866 if(AciSLockShrd.status[SIMLOCK_FIRST_SIM] EQ SIMLOCK_ENABLED) /*11_Apr_05*/
1867 {
1868 AciSLockShrd.blocked = TRUE;
1869 return (aci_slock_check_done(SIMLOCK_BLOCKED));
1870 }
1871 break;
1872 }
1873 }
1874 /*
1875 *Normal SIM
1876 */
1877 else
1878 {
1879 TRACE_FUNCTION("sim type: NORMAL SIM");
1880 aci_slock_set_simtype(SIM_NORMAL );
1881
1882 }
1883 #if 0//OMAPS00134957 & ASTec32151
1884 if((cfg_data->FC_Current < cfg_data->FC_Max) OR (cfg_data->FC_Max EQ FC_MAX_INFINITE))
1885 {
1886
1887 if((aci_slock_sim_config.sim_type EQ SIM_NORMAL) AND (personalisation_first_sim NEQ NULL)
1888 AND (AciSLockShrd.status[SIMLOCK_FIRST_SIM] EQ SIMLOCK_DISABLED) )
1889 {
1890 TRACE_FUNCTION("personalisation_first_sim NEQ NULL");
1891 al_status = aci_ext_auto_personalise(current_lock);
1892 switch(al_status)
1893 {
1894 case AUTOLOCK_CMPL :
1895 return (aci_slock_check_done(SIMLOCK_ENABLED));
1896 case AUTOLOCK_EXCT:
1897 return SIMLOCK_WAIT; /* wait for gid1 andgid2 read cnf*/
1898 case AUTOLOCK_FAIL:
1899 default :
1900 AciSLockShrd.blocked = TRUE;
1901 return (aci_slock_check_done(SIMLOCK_BLOCKED));
1902 }
1903
1904 }
1905 else
1906 {
1907
1908 for (type=current_lock; type<SIMLOCK_LAST; type++)
1909 {
1910 AciSLockShrd.current_lock=type;
1911
1912 if (AciSLockShrd.status[type] EQ SIMLOCK_ENABLED) /* initialised in aci_slock_init */
1913 {
1914 switch (type)
1915 {
1916 case SIMLOCK_NETWORK: aci_slock_check_NWlock(imsi_sim, 0); break;
1917 case SIMLOCK_NETWORK_SUBSET: aci_slock_check_NSlock(imsi_sim, 0); break;
1918 case SIMLOCK_SERVICE_PROVIDER:
1919 if (psaSIM_ChkSIMSrvSup(SRV_GrpLvl1) )
1920 {
1921 if(aci_slock_sim_config.sim_read_gid1 EQ FALSE)
1922 {
1923 aci_slock_sim_read_sim(SIM_GID1, NOT_PRESENT_8BIT, MAX_GID);
1924 return SIMLOCK_WAIT;
1925 }
1926 }
1927 else
1928 {
1929 AciSLockShrd.blocked = TRUE;
1930 return (aci_slock_check_done(SIMLOCK_BLOCKED));
1931 }
1932
1933 aci_slock_check_SPlock(imsi_sim, 0);
1934 break;
1935 case SIMLOCK_CORPORATE:
1936 if (psaSIM_ChkSIMSrvSup(SRV_GrpLvl1))
1937 {
1938 if(aci_slock_sim_config.sim_read_gid1 EQ FALSE)
1939 {
1940 aci_slock_sim_read_sim(SIM_GID1, NOT_PRESENT_8BIT, MAX_GID);
1941 return SIMLOCK_WAIT;
1942 }
1943 }
1944 else
1945 {
1946 AciSLockShrd.blocked = TRUE;
1947 return (aci_slock_check_done(SIMLOCK_BLOCKED));
1948 }
1949 if (psaSIM_ChkSIMSrvSup(SRV_GrpLvl2))
1950 {
1951 if(aci_slock_sim_config.sim_read_gid2 EQ FALSE)
1952 {
1953 aci_slock_sim_read_sim(SIM_GID2, NOT_PRESENT_8BIT, MAX_GID);
1954 return SIMLOCK_WAIT;
1955 }
1956 }
1957 else
1958 {
1959 AciSLockShrd.blocked = TRUE;
1960 return (aci_slock_check_done(SIMLOCK_BLOCKED));
1961 }
1962 aci_slock_check_CPlock(imsi_sim, 0);
1963 break;
1964
1965 case SIMLOCK_SIM: aci_slock_check_SMlock(imsi_sim, 0); break;
1966 case SIMLOCK_FIRST_SIM: break;
1967 case SIMLOCK_BLOCKED_NETWORK: aci_slock_check_BNWlock(imsi_sim, 0); break;
1968 default: return (aci_slock_check_done(SIMLOCK_FAIL)); /* won't happen */
1969 }
1970 }
1971
1972 if (AciSLockShrd.blocked) /* if one lock isn't matching, don't try the others */
1973 return (aci_slock_check_done(SIMLOCK_BLOCKED));
1974 }
1975
1976 return (aci_slock_check_done(SIMLOCK_ENABLED));
1977
1978 }
1979 }
1980 else
1981 {
1982 AciSLockShrd.blocked = TRUE;
1983 return (aci_slock_check_done(SIMLOCK_BLOCKED));
1984 }
1985 #else
1986 {
1987 if((aci_slock_sim_config.sim_type EQ SIM_NORMAL) AND (personalisation_first_sim NEQ NULL)
1988 AND (AciSLockShrd.status[SIMLOCK_FIRST_SIM] EQ SIMLOCK_DISABLED) )
1989 {
1990 TRACE_FUNCTION("personalisation_first_sim NEQ NULL");
1991 al_status = aci_ext_auto_personalise(current_lock);
1992 switch(al_status)
1993 {
1994 case AUTOLOCK_CMPL :
1995 return(aci_slock_check_done(SIMLOCK_ENABLED));
1996 case AUTOLOCK_EXCT:
1997 return SIMLOCK_WAIT; /* wait for gid1 andgid2 read cnf*/
1998 case AUTOLOCK_FAIL:
1999 default :
2000 AciSLockShrd.blocked = TRUE;
2001 return (aci_slock_check_done(SIMLOCK_BLOCKED));
2002 }
2003 }
2004 else
2005 {
2006
2007 for (type=current_lock; type<=SIMLOCK_CORPORATE; type++)
2008 {
2009 AciSLockShrd.current_lock=type;
2010
2011 if (AciSLockShrd.status[type] EQ SIMLOCK_ENABLED) /* initialised in aci_slock_init */
2012 {
2013 switch (type)
2014 {
2015 case SIMLOCK_NETWORK: aci_slock_check_NWlock(imsi_sim, 0); break;
2016 case SIMLOCK_NETWORK_SUBSET: aci_slock_check_NSlock(imsi_sim, 0); break;
2017 case SIMLOCK_SERVICE_PROVIDER:
2018 if (psaSIM_ChkSIMSrvSup(SRV_GrpLvl1) )
2019 {
2020 if(aci_slock_sim_config.sim_read_gid1 EQ FALSE)
2021 {
2022 aci_slock_sim_read_sim(SIM_GID1, NOT_PRESENT_8BIT, MAX_GID);
2023 return SIMLOCK_WAIT;
2024 }
2025 }
2026 else
2027 {
2028 AciSLockShrd.blocked = TRUE;
2029 return (aci_slock_check_done(SIMLOCK_BLOCKED));
2030 }
2031 aci_slock_check_SPlock(imsi_sim, 0);
2032 break;
2033 case SIMLOCK_CORPORATE:
2034 if (psaSIM_ChkSIMSrvSup(SRV_GrpLvl1))
2035 {
2036 if(aci_slock_sim_config.sim_read_gid1 EQ FALSE)
2037 {
2038 aci_slock_sim_read_sim(SIM_GID1, NOT_PRESENT_8BIT, MAX_GID);
2039 return SIMLOCK_WAIT;
2040 }
2041 }
2042 else
2043 {
2044 AciSLockShrd.blocked = TRUE;
2045 return (aci_slock_check_done(SIMLOCK_BLOCKED));
2046 }
2047 if (psaSIM_ChkSIMSrvSup(SRV_GrpLvl2))
2048 {
2049 if(aci_slock_sim_config.sim_read_gid2 EQ FALSE)
2050 {
2051 aci_slock_sim_read_sim(SIM_GID2, NOT_PRESENT_8BIT, MAX_GID);
2052 return SIMLOCK_WAIT;
2053 }
2054 }
2055 else
2056 {
2057 AciSLockShrd.blocked = TRUE;
2058 return (aci_slock_check_done(SIMLOCK_BLOCKED));
2059 }
2060 aci_slock_check_CPlock(imsi_sim, 0);
2061 break;
2062 case SIMLOCK_SIM: aci_slock_check_SMlock(imsi_sim, 0); break;
2063 default: return (aci_slock_check_done(SIMLOCK_FAIL)); /* won't happen */
2064 }
2065 }
2066
2067 if (AciSLockShrd.blocked) /* if one lock isn't matching, don't try the others */
2068 return (aci_slock_check_done(SIMLOCK_BLOCKED));
2069 }
2070
2071 return (aci_slock_check_done(SIMLOCK_ENABLED));
2072
2073 }
2074 }
2075 #endif
2076 }
2077
2078
2079
2080
2081 /*
2082 +------------------------------------------------------------------------------
2083 | Function : aci_slock_sim_init
2084 +------------------------------------------------------------------------------
2085 | Description : Install information found in the primitive into configuration buffers
2086 |
2087 | Parameters : sim_mmi_insert_ind- pointer to T_SIM_MMI_INSERT_IND
2088 |
2089 | Return : void
2090 |
2091 +------------------------------------------------------------------------------
2092 */
2093 void aci_slock_sim_init ( T_SIM_MMI_INSERT_IND *sim_mmi_insert_ind )
2094 {
2095 TRACE_FUNCTION("aci_slock_sim_init()");
2096
2097 aci_slock_sim_config.oper_mode = sim_mmi_insert_ind->func;
2098 memcpy(aci_slock_sim_service_table,sim_mmi_insert_ind->sim_serv,sizeof(aci_slock_sim_service_table));
2099
2100 aci_slock_sim_config.phase = sim_mmi_insert_ind->phase;
2101 aci_slock_sim_config.access_acm = sim_mmi_insert_ind->access_acm;
2102 aci_slock_sim_config.access_acmmax = sim_mmi_insert_ind->access_acmmax;
2103 aci_slock_sim_config.access_puct = sim_mmi_insert_ind->access_puct;
2104 aci_slock_reset();
2105
2106 }
2107
2108
2109 /*
2110 +------------------------------------------------------------------------------
2111 | Function : aci_slock_sim_read_sim_cb
2112 +------------------------------------------------------------------------------
2113 | Description : Call back for SIM read.
2114 | Parameters : table_id-
2115 |
2116 | Return : void
2117 |
2118 +------------------------------------------------------------------------------
2119 */
2120 void aci_slock_sim_read_sim_cb(SHORT table_id)
2121 {
2122
2123 TRACE_FUNCTION ("aci_slock_sim_read_sim_cb()");
2124
2125 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE;
2126
2127 /* Implements Measure 84 */
2128 aci_slock_sim_gid_cnf( table_id );
2129 }
2130
2131
2132 /*
2133 +------------------------------------------------------------------------------
2134 | Function : aci_slock_sim_read_sim
2135 +------------------------------------------------------------------------------
2136 | Description : Request to read SIM card.
2137 | Parameters : data_id - data field identifier
2138 | len - actual length of data
2139 | max_length - max length of data
2140 |
2141 | Return : void
2142 |
2143 +------------------------------------------------------------------------------
2144 */
2145 void aci_slock_sim_read_sim(USHORT data_id, UBYTE len, UBYTE max_length)
2146 {
2147 SHORT table_id;
2148
2149 TRACE_FUNCTION ("aci_slock_sim_read_sim()");
2150
2151 table_id = psaSIM_atbNewEntry();
2152
2153 if(table_id NEQ NO_ENTRY)
2154 {
2155 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE;
2156 simShrdPrm.atb[table_id].accType = ACT_RD_DAT;
2157 /* Called only for GID1/GID2, standard files. Hence full path not required. */
2158 simShrdPrm.atb[table_id].v_path_info = FALSE;
2159 simShrdPrm.atb[table_id].reqDataFld = data_id;
2160 simShrdPrm.atb[table_id].dataOff = 0;
2161 simShrdPrm.atb[table_id].dataLen = len;
2162 simShrdPrm.atb[table_id].recMax = max_length;
2163 simShrdPrm.atb[table_id].exchData = NULL;
2164 simShrdPrm.atb[table_id].rplyCB = aci_slock_sim_read_sim_cb;
2165
2166 simShrdPrm.aId = table_id;
2167 if(psaSIM_AccessSIMData() < 0)
2168 {
2169 TRACE_FUNCTION("abc FATAL ERROR");
2170 }
2171 }
2172 }
2173
2174
2175
2176
2177 /*
2178 +------------------------------------------------------------------------------
2179 | Function : aci_slock_set_simtype
2180 +------------------------------------------------------------------------------
2181 | Description : Setting the sim_type value (Normal, Test SIM, Type Approval SIM
2182 | Parameters : sim_type - SIM_NORMAL =0,
2183 | SIM_TYPEAPPROVAL,
2184 | SIM_TEST
2185 |
2186 | Return : void
2187 |
2188 +------------------------------------------------------------------------------
2189 */
2190 void aci_slock_set_simtype(T_SIM_TYPE sim_type )
2191 {
2192 aci_slock_sim_config.sim_type = sim_type;
2193 }
2194
2195
2196 /*
2197 +------------------------------------------------------------------------------
2198 | Function : aci_slock_set_CFG
2199 +------------------------------------------------------------------------------
2200 | Description : To set global variable for configuration data ( part1 of Security Driver)
2201 | Parameters : none
2202 |
2203 | Return : void
2204 |
2205 +------------------------------------------------------------------------------
2206 */
2207 BOOL aci_slock_set_CFG(void)
2208 {
2209 T_SEC_DRV_RETURN status ;
2210 TRACE_FUNCTION("aci_slock_set_CFG()");
2211 status = sec_get_CFG(&cfg_data);
2212 if(status NEQ SEC_DRV_RET_Ok)
2213 {
2214 cfg_data = NULL;
2215 return FALSE;
2216 }
2217 return TRUE;
2218 }
2219
2220
2221
2222
2223
2224
2225 /*
2226 +------------------------------------------------------------------------------
2227 | Function : aci_set_cme_error
2228 +------------------------------------------------------------------------------
2229 | Description : Set the cme error using ACI_ERR_DESC
2230 | Parameters : slocktype - lock type
2231 |
2232 | Return : void
2233 |
2234 +------------------------------------------------------------------------------
2235 */
2236 void aci_set_cme_error(T_SIMLOCK_TYPE slocktype)
2237 {
2238
2239
2240 int index = (cfg_data->FC_Current < cfg_data->FC_Max)?1:0;
2241
2242 if(slocktype EQ SIMLOCK_BLOCKED_NETWORK)
2243 {
2244 ACI_ERR_DESC( ACI_ERR_CLASS_Ext,
2245 set_cme_error_code[slocktype][index] );
2246 }
2247 else
2248 {
2249
2250 if ( (slocktype >= SIMLOCK_NETWORK) AND
2251 (slocktype < SIMLOCK_LAST) )
2252 {
2253 ACI_ERR_DESC( ACI_ERR_CLASS_Cme,
2254 set_cme_error_code[slocktype][index] );
2255 }
2256 else
2257 {
2258 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_WrongPasswd );
2259 }
2260
2261 }
2262 }
2263 /*
2264 +------------------------------------------------------------------------------
2265 | Function : aci_set_cme_error_code
2266 +------------------------------------------------------------------------------
2267 | Description : Set the cme error code
2268 | Parameters : err_code - cme error code
2269 |
2270 | Return : void
2271 |
2272 +------------------------------------------------------------------------------
2273 */
2274 void aci_set_cme_error_code(T_SIMLOCK_TYPE current_lock ,T_ACI_CME_ERR *err_code)
2275 {
2276 int index = (cfg_data->FC_Current < cfg_data->FC_Max)?1:0;
2277
2278 if ( (current_lock >= SIMLOCK_NETWORK) AND
2279 (current_lock < SIMLOCK_LAST) AND (current_lock NEQ SIMLOCK_BLOCKED_NETWORK))
2280 {
2281 *err_code =
2282 (T_ACI_CME_ERR) set_cme_error_code[current_lock][index];
2283 }
2284 else
2285 {
2286 *err_code = CME_ERR_Unknown;
2287 aci_set_cme_error(current_lock);
2288 }
2289 }
2290
2291 /*
2292 +------------------------------------------------------------------------------
2293 | Function : aci_set_cpin_code
2294 +------------------------------------------------------------------------------
2295 | Description : Set the cpin request code
2296 | Parameters : code - cpin request code
2297 |
2298 | Return : void
2299 | code -Set the cpin request code
2300 |
2301 +------------------------------------------------------------------------------
2302 */
2303 void aci_set_cpin_code(T_SIMLOCK_TYPE current_lock ,T_ACI_CPIN_RSLT *code)
2304 {
2305
2306 int index = (cfg_data->FC_Current < cfg_data->FC_Max)?1:0;
2307
2308 if ( (current_lock >= SIMLOCK_NETWORK) AND
2309 (current_lock < SIMLOCK_LAST) )
2310 {
2311 *code =
2312 (T_ACI_CPIN_RSLT) aci_set_cpin_response[current_lock][index];
2313 }
2314 else
2315 {
2316 *code = CPIN_RSLT_NotPresent;
2317 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_DataCorrupt );
2318 }
2319 }
2320
2321 /*
2322 +------------------------------------------------------------------------------
2323 | Function : aci_slock_reset
2324 +------------------------------------------------------------------------------
2325 | Description : Reset the lock
2326 | Parameters : None
2327 |
2328 | Return : void
2329 |
2330 +------------------------------------------------------------------------------
2331 */
2332 void aci_slock_reset()
2333 {
2334 aci_slock_sim_config.sim_gidl1[0] = NOT_PRESENT_8BIT;
2335 aci_slock_sim_config.sim_gidl2[0] = NOT_PRESENT_8BIT;
2336 aci_slock_sim_config.sim_read_gid1= FALSE;
2337 aci_slock_sim_config.sim_read_gid2= FALSE;
2338 }
2339
2340 /*
2341 +------------------------------------------------------------------------------
2342 | Function : aci_slock_check_done
2343 +------------------------------------------------------------------------------
2344 | Description : Check for lock
2345 | Parameters : Status
2346 |
2347 | Return : SIMLOCK_FAIL = -1,
2348 | SIMLOCK_DISABLED,
2349 | SIMLOCK_PERM_DISABLED,
2350 | SIMLOCK_ENABLED,
2351 | SIMLOCK_BLOCKED,
2352 | SIMLOCK_LOCKED,
2353 | SIMLOCK_WAIT,
2354 | SIMLOCK_BUSY
2355 |
2356 +------------------------------------------------------------------------------
2357 */
2358
2359 T_SIMLOCK_STATUS aci_slock_check_done(T_SIMLOCK_STATUS sl_status)
2360 {
2361
2362 USHORT cmdBuf = simEntStat.curCmd;
2363 T_ACI_CME_ERR err_code = CME_ERR_NotPresent; /* code holding the correct error code calculated */
2364
2365 TRACE_FUNCTION_P1 ("aci_slock_check_done() %d",simEntStat.curCmd );
2366 switch(cmdBuf )
2367 {
2368 case( AT_CMD_CFUN ):
2369 case( AT_CMD_CPIN ):
2370 case( AT_CMD_PVRF ):
2371 case(AT_CMD_NRG) :
2372 case( AT_CMD_SIMRST):
2373 case( AT_CMD_NONE ):
2374 case (AT_CMD_CIMI):
2375 case( KSD_CMD_UBLK):
2376 /*
2377 * Start to build phonebook
2378 */
2379 AciSLockShrd.pb_load = TRUE;
2380
2381 #ifdef TI_PS_FFS_PHB
2382 if(last_sim_mmi_insert_ind NEQ NULL)
2383 {
2384 pb_reset();
2385 pb_inserted_sim (MAX_SRV_TBL,
2386 last_sim_mmi_insert_ind->sim_serv,
2387 &last_sim_mmi_insert_ind->imsi_field,
2388 last_sim_mmi_insert_ind->func,
2389 last_sim_mmi_insert_ind->phase);
2390 }
2391 #else
2392 if(last_sim_mmi_insert_ind NEQ NULL)
2393 {
2394 pb_reset();
2395 pb_build_req(last_sim_mmi_insert_ind);
2396 }
2397 #endif
2398
2399 /* Request the Customer Service Profile from the SIM (EF_CPHS_CSP) */
2400 cmhSIM_Get_CSP();
2401 if(last_sim_mmi_insert_ind NEQ NULL)
2402 {
2403 #ifdef SIM_TOOLKIT
2404 cmhSMS_ReadCbDtaDwnl (last_sim_mmi_insert_ind);
2405 #endif
2406 #ifdef FF_MMI_RIV
2407 rAT_PlusCFUNP (last_sim_mmi_insert_ind);
2408 #endif /* FF_MMI_RIV */
2409 PFREE (last_sim_mmi_insert_ind); /* 11_Apr_05 */
2410 last_sim_mmi_insert_ind= NULL;
2411 }
2412
2413 cmhSIM_SIMInserted();
2414 aci_ext_personalisation_free();
2415 MFREE(cfg_data);
2416 break;
2417
2418 case (AT_CMD_CLCK):
2419 if((AciSLockShrd.check_lock EQ SIMLOCK_CHECK_RESET_FC) OR (AciSLockShrd.check_lock EQ SIMLOCK_CHECK_MASTER_UNLOCK))
2420 {
2421
2422 simEntStat.curCmd = AT_CMD_NONE;
2423 if((sl_status EQ SIMLOCK_ENABLED) AND (AciSLockShrd.pb_load EQ FALSE))
2424 {
2425 /*
2426 * Start to build phonebook
2427 */
2428 AciSLockShrd.pb_load = TRUE;
2429
2430 #ifdef TI_PS_FFS_PHB
2431 if(last_sim_mmi_insert_ind NEQ NULL)
2432 {
2433 pb_reset();
2434 pb_inserted_sim (MAX_SRV_TBL,
2435 last_sim_mmi_insert_ind->sim_serv,
2436 &last_sim_mmi_insert_ind->imsi_field,
2437 last_sim_mmi_insert_ind->func,
2438 last_sim_mmi_insert_ind->phase);
2439 }
2440 #else
2441 if(last_sim_mmi_insert_ind NEQ NULL)
2442 {
2443 pb_reset();
2444 pb_build_req(last_sim_mmi_insert_ind);
2445 }
2446 #endif
2447
2448 /* Request the Customer Service Profile from the SIM (EF_CPHS_CSP) */
2449 cmhSIM_Get_CSP();
2450
2451 if(last_sim_mmi_insert_ind NEQ NULL)
2452 {
2453 #ifdef SIM_TOOLKIT
2454 cmhSMS_ReadCbDtaDwnl (last_sim_mmi_insert_ind);
2455 #endif
2456 #ifdef FF_MMI_RIV
2457 rAT_PlusCFUNP (last_sim_mmi_insert_ind);
2458 #endif /* FF_MMI_RIV */
2459 PFREE (last_sim_mmi_insert_ind); /* 11_Apr_05 */
2460 last_sim_mmi_insert_ind= NULL;
2461 }
2462 R_AT( RAT_OK, simEntStat.entOwn ) ((T_ACI_AT_CMD) cmdBuf );
2463 cmh_logRslt ( simEntStat.entOwn, RAT_OK, (T_ACI_AT_CMD)cmdBuf, -1, BS_SPEED_NotPresent, CME_ERR_NotPresent );
2464 }
2465 if ( AciSLockShrd.blocked)
2466 {
2467 aci_set_cme_error(AciSLockShrd.current_lock);
2468 /* @GBR: Alternativly CME_ERR_SimWrong might be returned, but this way is telling the MMI mor specific, what went wrong. */
2469 aci_set_cme_error_code_and_logRslt( cmdBuf );
2470 }
2471 aci_ext_personalisation_free();
2472 MFREE(cfg_data);
2473 }
2474
2475 else if(AciSLockShrd.check_lock EQ SIMLOCK_CHECK_LOCK)
2476 {
2477 switch(sl_status)
2478 {
2479 case SIMLOCK_ENABLED :
2480 simEntStat.curCmd = AT_CMD_NONE;
2481 R_AT( RAT_OK, simEntStat.entOwn ) ( (T_ACI_AT_CMD)cmdBuf );
2482 cmh_logRslt ( simEntStat.entOwn, RAT_OK, (T_ACI_AT_CMD)cmdBuf, -1, BS_SPEED_NotPresent, CME_ERR_NotPresent );
2483 break;
2484 case SIMLOCK_WAIT :
2485 break;
2486 case SIMLOCK_FAIL :
2487 simEntStat.curCmd = AT_CMD_NONE;
2488 err_code =CME_ERR_WrongPasswd;
2489 R_AT( RAT_CME, simEntStat.entOwn )
2490 ( (T_ACI_AT_CMD)cmdBuf, err_code );
2491 cmh_logRslt ( simEntStat.entOwn, RAT_CME, (T_ACI_AT_CMD)cmdBuf, -1, BS_SPEED_NotPresent, err_code );
2492 break;
2493 }
2494 }
2495 break;
2496
2497 }
2498 return sl_status;
2499 }
2500
2501 /*
2502 +------------------------------------------------------------------------------
2503 | Function : aci_slock_master_unlock
2504 +------------------------------------------------------------------------------
2505 | Description : Unlock the master key
2506 | Parameters : Masterkey password
2507 |
2508 | Return : OPER_FAIL = -1,
2509 | OPER_SUCCESS,
2510 | OPER_WRONG_PASSWORD,
2511 | OPER_BUSY,
2512 | OPER_NOT_ALLOWED
2513 |
2514 +------------------------------------------------------------------------------
2515 */
2516
2517 T_OPER_RET_STATUS aci_slock_master_unlock(char *masterkey)
2518 {
2519 T_OPER_RET_STATUS ret;
2520 ret = aci_ext_slock_master_unlock(masterkey);
2521 if(ret EQ OPER_SUCCESS)
2522 {
2523 if((aci_slock_is_timer_support() EQ TRUE) AND (aci_slock_check_timer() EQ TIMER_RUNNING)
2524 AND (masterkey NEQ NULL))
2525 {
2526 aci_slock_unlock_timer_stopped();
2527 }
2528 }
2529 return ret;
2530 }
2531
2532 /*
2533 +------------------------------------------------------------------------------
2534 | Function : aci_slock_start_timer
2535 +------------------------------------------------------------------------------
2536 | Description : Start the penalty Timer
2537 | Parameters : None
2538 |
2539 | Return : Void
2540 |
2541 +------------------------------------------------------------------------------
2542 */
2543 void aci_slock_start_timer(void)
2544 {
2545
2546 TRACE_FUNCTION("aci_slock_start_timer()");
2547 if(aci_slock_is_timer_support() EQ TRUE)
2548 {
2549 if(!aci_slock_set_CFG())
2550 {
2551 return ;
2552 }
2553 if(cfg_data->FC_Current NEQ 0xFF)
2554 {
2555 TIMERSTART((ACI_UNLOCK_TIMER*cfg_data->FC_Current),ACI_UNLOCK_TIMER_HANDLE);
2556 aci_slock_set_timer_flag(TIMER_RUNNING);
2557 }
2558 MFREE(cfg_data);
2559 }
2560 return;
2561 }
2562
2563 /*
2564 +------------------------------------------------------------------------------
2565 | Function : aci_slock_check_timer
2566 +------------------------------------------------------------------------------
2567 | Description : Check for time active or not
2568 | Parameters : None
2569 |
2570 | Return : timer status
2571 |
2572 +------------------------------------------------------------------------------
2573 */
2574
2575 GLOBAL UBYTE aci_slock_check_timer(void)
2576 {
2577 return (aci_ext_check_timer());
2578 }
2579
2580
2581 /*
2582 +------------------------------------------------------------------------------
2583 | Function : aci_slock_unlock_timer_stopped
2584 +------------------------------------------------------------------------------
2585 | Description : Check for time is stoped or not
2586 | Parameters : None
2587 |
2588 | Return : void
2589 |
2590 +------------------------------------------------------------------------------
2591 */
2592 GLOBAL void aci_slock_unlock_timer_stopped(void)
2593 {
2594 aci_slock_set_timer_flag(TIMER_STOPPED);
2595 return;
2596 }
2597
2598 /*
2599 +------------------------------------------------------------------------------
2600 | Function : aci_slock_set_timer_flag
2601 +------------------------------------------------------------------------------
2602 | Description : Set the timer flag
2603 | Parameters : Status
2604 |
2605 | Return : void
2606 |
2607 +------------------------------------------------------------------------------
2608 */
2609
2610 GLOBAL void aci_slock_set_timer_flag(UBYTE status)
2611 {
2612 aci_ext_set_timer_flag(status);
2613 }
2614
2615 /*
2616 +------------------------------------------------------------------------------
2617 | Function : aci_slock_is_timer_support
2618 +------------------------------------------------------------------------------
2619 | Description : Check the timer ,is support or not
2620 | Parameters : None
2621 |
2622 | Return : Status of timer
2623 |
2624 +------------------------------------------------------------------------------
2625 */
2626
2627 GLOBAL UBYTE aci_slock_is_timer_support()
2628 {
2629 UBYTE result;
2630 if(!aci_slock_set_CFG())
2631 {
2632 return FALSE;
2633 }
2634 result = aci_ext_is_timer_support() ;
2635 MFREE(cfg_data);
2636 return result;
2637 }
2638
2639
2640 /*
2641 +------------------------------------------------------------------------------
2642 | Function : aci_slock_send_RAT
2643 +------------------------------------------------------------------------------
2644 | Description : Send RAT_CME message to MMI
2645 | Parameters : cmdBuf - Current AT command
2646 | err_code - CME error code
2647 | Return : none
2648 |
2649 +------------------------------------------------------------------------------
2650 */
2651
2652 GLOBAL void aci_slock_send_RAT(UBYTE cmdBuf,T_ACI_CME_ERR err_code )
2653 {
2654
2655 R_AT( RAT_CME, simEntStat.entOwn )
2656 ( (T_ACI_AT_CMD)cmdBuf, err_code );
2657 cmh_logRslt ( simEntStat.entOwn, RAT_CME, (T_ACI_AT_CMD)cmdBuf, -1,
2658 BS_SPEED_NotPresent, err_code );
2659
2660 }
2661
2662
2663 /*
2664 +------------------------------------------------------------------------------
2665 |
2666 | Function : aci_slock_sim_gid_cnf
2667 +------------------------------------------------------------------------------
2668 | Description : read SIM group identifier 1 or 2 from SIM card
2669 |
2670 | Parameters : table_id -
2671 |
2672 | Return : void
2673 |
2674 +------------------------------------------------------------------------------
2675 */
2676
2677 void aci_slock_sim_gid_cnf( SHORT table_id )
2678 {
2679 T_SIMLOCK_STATUS sl_status;
2680
2681
2682 TRACE_FUNCTION( "aci_slock_sim_gid_cnf()" );
2683
2684 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR )
2685 {
2686 if(simShrdPrm.atb[table_id].reqDataFld EQ SIM_GID1)
2687 {
2688 /* The length needs to be modfied when there is no ERROR from SIM */
2689 aci_slock_sim_config.gid1_len = simShrdPrm.atb[table_id].dataLen;
2690 aci_slock_sim_config.sim_read_gid1 = TRUE;
2691 memcpy( aci_slock_sim_config.sim_gidl1,
2692 simShrdPrm.atb[table_id].exchData, MAX_GID );
2693 }
2694 else /*SIM_GID2*/
2695 {
2696 /* The length needs to be modfied when there is no ERROR from SIM */
2697 aci_slock_sim_config.gid2_len= simShrdPrm.atb[table_id].dataLen;
2698 aci_slock_sim_config.sim_read_gid2 = TRUE;
2699 memcpy( aci_slock_sim_config.sim_gidl2,
2700 simShrdPrm.atb[table_id].exchData, MAX_GID );
2701 }
2702
2703 if( simEntStat.curCmd NEQ AT_CMD_NONE )
2704 {
2705 if( AciSLockShrd.check_lock EQ SIMLOCK_CHECK_LOCK )
2706 {
2707 sl_status = aci_slock_lock( AciSLockShrd.lock_type,
2708 AciSLockShrd.lock_passwd );
2709 aci_slock_check_done( sl_status );
2710 }
2711 else
2712 {
2713 /*
2714 * Since AciSLockShrd.check_lock can have only 3 values , hence there
2715 * is no need to put
2716 * else if( (AciSLockShrd.check_lock EQ SIMLOCK_CHECK_PERS) OR
2717 (AciSLockShrd.check_lock EQ SIMLOCK_CHECK_RESET_FC) )
2718 */
2719
2720 /* check for SP and corporate personalisation.
2721 This is the first case, we can do this,
2722 as we have the gid1/gid2 file here */
2723 sl_status= aci_slock_checkpersonalisation(AciSLockShrd.current_lock);
2724 }
2725 }
2726 }
2727 }
2728
2729 /* Implements Measure 82 */
2730 /*
2731 +------------------------------------------------------------------------------
2732 | Function : aci_slock_compare_codegroup_with_MEPD
2733 +------------------------------------------------------------------------------
2734 | Description : This function compares the different code group present in SIM
2735 | with the code group present in the different category of
2736 | MEPD DataBase
2737 |
2738 | This function first extracts the code group present in the
2739 | different category of MEPD DataBase from the argument passed
2740 | as pBody and then compares with the code group present in
2741 | the SIM which is passed as an argument imsi_sim.
2742 |
2743 | If matches returns TRUE otherwise FALSE.
2744 |
2745 | Parameters : personalisation - 0- add the lock data
2746 | index - array index
2747 | num_user_codes - No. of user codes
2748 | imsi_sim - IMSI
2749 | code_len - length
2750 | pBody - Different Category of Personalisation Data.
2751 |
2752 | Return : BOOL - if the IMSI matches returns TRUE otherwise FASLE
2753 +------------------------------------------------------------------------------
2754 */
2755
2756 LOCAL BOOL aci_slock_compare_codegroup_with_MEPD( UBYTE personalisation,
2757 UINT16 *index,
2758 UBYTE *imsi_sim,
2759 UBYTE code_len,
2760 UBYTE len,
2761 UBYTE *pBody, BOOL bnw_flag )
2762 {
2763 UBYTE imsi_me[MAX_IMSI_LEN+1];
2764 BOOL isCodeFound;
2765
2766 TRACE_FUNCTION( "aci_slock_compare_codegroup_with_MEPD()" );
2767
2768 aci_slock_decode_MEPD( pBody, index, code_len, imsi_me );
2769
2770 isCodeFound = memcmp( imsi_sim, imsi_me, len ) EQ 0;
2771 if(bnw_flag)
2772 {
2773 aci_slock_set_me_personalisation_status ( personalisation, !isCodeFound );
2774 }
2775 else
2776 {
2777 aci_slock_set_me_personalisation_status ( personalisation, isCodeFound );
2778 }
2779
2780
2781 if (isCodeFound)
2782 {
2783 return TRUE;
2784 }
2785 return FALSE;
2786 }
2787
2788 /* Implements Measure 26 */
2789 /*
2790 +------------------------------------------------------------------------------
2791 | Function : aci_set_cme_error_code_and_logRslt
2792 +------------------------------------------------------------------------------
2793 | Description : Sets the cme error code and logs the result code
2794 |
2795 | Parameters : cmdBuf - Current Command
2796 |
2797 | Return : void
2798 +------------------------------------------------------------------------------
2799 */
2800
2801 GLOBAL void aci_set_cme_error_code_and_logRslt( UBYTE cmdBuf )
2802 {
2803 T_ACI_CME_ERR err_code;
2804
2805 TRACE_FUNCTION( "aci_set_cme_error_code_and_logRslt()" );
2806
2807 aci_set_cme_error_code( AciSLockShrd.current_lock, &err_code );
2808 aci_slock_send_RAT(cmdBuf, err_code );
2809
2810 }
2811
2812 /* Implements NEW Measure */
2813 /*
2814 +------------------------------------------------------------------------------
2815 | Function : aci_slock_compare_NSCode
2816 +------------------------------------------------------------------------------
2817 | Description : This function will compare the network subset code present
2818 | in SIM with the network subset code which is present in MEPD
2819 | DataBase
2820 |
2821 | IF the comparison matches the function will return TRUE,
2822 | otherwise FALSE
2823 |
2824 | Parameters : me_nw_code - Network Code from MEPD DataBase
2825 | me_nw_ns_code_str - Network Subset Code String from
2826 | MEPD DataBase.
2827 |
2828 | imsi_sim - IMSI from SIM
2829 |
2830 | Return : BOOL - Returns the Result of the comparison
2831 +------------------------------------------------------------------------------
2832 */
2833
2834 LOCAL UBYTE aci_slock_compare_NSCode ( UBYTE *me_nw_code,
2835 UBYTE *me_nw_ns_code_str,
2836 UBYTE *imsi_sim )
2837 {
2838 int me_ns_code_first, me_ns_code_last, sim_ns_code;
2839 BOOL cmp_result;
2840
2841 TRACE_FUNCTION( "aci_slock_compare_NSCode()" );
2842
2843 cmp_result = memcmp( imsi_sim, me_nw_code, simShrdPrm.mnc_len+3 ) EQ 0;
2844
2845 if ( cmp_result EQ TRUE )
2846 {
2847 me_ns_code_first = aci_slock_extractCode( me_nw_ns_code_str+7, 2 );
2848
2849 me_ns_code_last = aci_slock_extractCode( me_nw_ns_code_str+7+2, 2 );
2850
2851 sim_ns_code = aci_slock_extractCode( imsi_sim+simShrdPrm.mnc_len+3, 2 );
2852
2853 if((sim_ns_code >= me_ns_code_first ) AND (sim_ns_code <= me_ns_code_last))
2854 {
2855 return TRUE; /* Matches */
2856 }
2857 else
2858 {
2859 return FALSE;
2860 }
2861 }
2862 return ( cmp_result );
2863 }
2864
2865 /* Implements NEW Measure */
2866 /*
2867 +------------------------------------------------------------------------------
2868 | Function : aci_slock_compare_MSINCode
2869 +------------------------------------------------------------------------------
2870 | Description : This function will compare MSIN Code from MEPD DataBase
2871 | with the MSIN Code present in SIM
2872 |
2873 | IF the comparison matches the function will return TRUE,
2874 | otherwise FALSE
2875 |
2876 | Parameters : me_nw_ns_msin_msin_code_str - msin Code String from
2877 | MEPD DataBase.
2878 | imsi_sim - IMSI from SIM
2879 |
2880 | Return : BOOL - Returns the Result of the comparison
2881 +------------------------------------------------------------------------------
2882 */
2883
2884 LOCAL UBYTE aci_slock_compare_MSINCode( UBYTE *me_nw_ns_msin_msin_code_str,
2885 UBYTE *imsi_sim )
2886 {
2887 UBYTE me_nw_ns_code_str[6+2+1];
2888 BOOL cmp_result;
2889 int me_msin_code_first, me_msin_code_last, sim_msin_code;
2890
2891 TRACE_FUNCTION( "aci_slock_compare_MSINCode()" );
2892
2893 memcpy(me_nw_ns_code_str,me_nw_ns_msin_msin_code_str,simShrdPrm.mnc_len+3+2);
2894
2895 cmp_result = memcmp( imsi_sim, me_nw_ns_code_str,
2896 simShrdPrm.mnc_len+3+2 ) EQ 0;
2897
2898 if ( cmp_result EQ TRUE )
2899 {
2900 me_msin_code_first = aci_slock_extractCode( me_nw_ns_msin_msin_code_str+9,
2901 (MAX_IMSI_LEN - simShrdPrm.mnc_len+3+2) );
2902
2903 me_msin_code_last = aci_slock_extractCode( me_nw_ns_msin_msin_code_str+9+8,
2904 (MAX_IMSI_LEN - simShrdPrm.mnc_len+3+2) );
2905
2906 sim_msin_code = aci_slock_extractCode( imsi_sim+simShrdPrm.mnc_len+3+2,
2907 (MAX_IMSI_LEN - cfg_data->MNC_Len+3+2) );
2908
2909 if( (sim_msin_code >= me_msin_code_first ) AND
2910 (sim_msin_code <= me_msin_code_last) )
2911 {
2912 return TRUE; /* Matches */
2913 }
2914 else
2915 {
2916 return FALSE;
2917 }
2918 }
2919 return ( cmp_result );
2920 }
2921
2922 /*
2923 +------------------------------------------------------------------------------
2924 | Function : aci_slock_compare_NSCode
2925 +------------------------------------------------------------------------------
2926 | Description : This function will extract the code in Integer format
2927 | from the string that has been passed as a parameter source_str
2928 |
2929 | Parameters : souce_str - Source String from which the code is
2930 | extracted out.
2931 | len - Length
2932 |
2933 | Return : BOOL - Returns the Code in Integer Format
2934 +------------------------------------------------------------------------------
2935 */
2936
2937 LOCAL int aci_slock_extractCode( UBYTE *source_str, UBYTE len )
2938 {
2939 UBYTE dest_str[MAX_IMSI_LEN+1];
2940
2941 memcpy(dest_str,source_str, len);
2942 dest_str[len] = '\0';
2943 return( atoi((const char *)dest_str));
2944 }
2945
2946 /* Implements Measure 212 */
2947 /*
2948 +------------------------------------------------------------------------------
2949 | Function : aci_slock_check_isNSCodePresent
2950 +------------------------------------------------------------------------------
2951 | Description : This function is intended to compare the Network Subset Code
2952 | from the Network Subset Personalisation Database and SIM.
2953 |
2954 | First it will compare the Network Code between the
2955 | Network Subset Personalisation Database and SIM.
2956 |
2957 | IF that matches then it will compare the Network Subset Code
2958 | between the Network Subset Personalisation Database and SIM.
2959 |
2960 | If the comparison matches the function will return TRUE,
2961 | otherwise FALSE
2962 |
2963 | Parameters : me_nw_code - Network Subset Code from
2964 | Network Subset Personalisation
2965 | imsi_sim - IMSI from SIM
2966 | index -
2967 |
2968 | Return : BOOL - Returns the Result of the comparison
2969 +------------------------------------------------------------------------------
2970 */
2971
2972 LOCAL UBYTE aci_slock_check_isNSCodePresent( UBYTE *me_nw_code,
2973 UBYTE *imsi_sim,
2974 UINT16 *index )
2975 {
2976 UBYTE imsi_sim_8or9th_digit_str[1+1];
2977 UBYTE me_ns_code_bcd[NS_CODE_LEN];
2978 UBYTE me_ns_code[2 +1];
2979
2980
2981 UBYTE no_of_normal_8th_digit_ns_code;
2982 UBYTE digit_8th_value;
2983 UBYTE no_of_digit_8th_value;
2984 UBYTE no_of_interval_8th_digit_ns_code;
2985
2986 BOOL cmp_result;
2987 int me_ns_code_first,
2988 me_ns_code_last,
2989 sim_ns_code,
2990 sim_8or9th_digit_code,
2991 j,k;
2992
2993 TRACE_FUNCTION( "aci_slock_check_isNSCodePresent()" );
2994
2995 cmp_result = memcmp(imsi_sim,me_nw_code,simShrdPrm.mnc_len+3) EQ 0;
2996 no_of_digit_8th_value = ((UBYTE *)personalisation_ns->pBody)[*index] ;
2997 *index += 1;
2998 if ( cmp_result EQ TRUE )
2999 {
3000 cmp_result = FALSE;
3001
3002 imsi_sim_8or9th_digit_str[0] = imsi_sim[simShrdPrm.mnc_len+3+2];
3003 imsi_sim_8or9th_digit_str[1] ='\0';
3004 sim_8or9th_digit_code = atoi((const char *)imsi_sim_8or9th_digit_str);
3005
3006 for(j=0; j<no_of_digit_8th_value; j++ )
3007 {
3008 digit_8th_value = ((UBYTE *)personalisation_ns->pBody)[*index];
3009 *index += 1;
3010 no_of_normal_8th_digit_ns_code =
3011 ((UBYTE *)personalisation_ns->pBody)[*index];
3012 *index += 1;
3013 no_of_interval_8th_digit_ns_code =
3014 ((UBYTE *)personalisation_ns->pBody)[*index];
3015 *index += 1;
3016
3017 if( sim_8or9th_digit_code EQ digit_8th_value )
3018 {
3019 for( k =0; k < no_of_normal_8th_digit_ns_code; k++ )
3020 {
3021 memcpy( me_ns_code_bcd, &(((UBYTE *)personalisation_ns->pBody)[*index]),
3022 NS_CODE_LEN );
3023 *index += NS_CODE_LEN;
3024 aci_slock_psaSIM_decodeIMSI_without_parity( me_ns_code_bcd,
3025 NS_CODE_LEN,
3026 (char *)me_ns_code);
3027
3028 cmp_result = memcmp( imsi_sim + simShrdPrm.mnc_len+3,
3029 me_ns_code, 2 ) EQ 0;
3030
3031 if( cmp_result EQ TRUE )
3032 {
3033 return TRUE; /* Matches */
3034 }
3035 }
3036 if( cmp_result EQ FALSE )
3037 {
3038 for(k =0; k < no_of_interval_8th_digit_ns_code; k++)
3039 {
3040 memcpy( me_ns_code_bcd,
3041 &(((UBYTE *)personalisation_ns->pBody)[*index]),NS_CODE_LEN);
3042 *index += NS_CODE_LEN;
3043 aci_slock_psaSIM_decodeIMSI_without_parity( me_ns_code_bcd,
3044 NS_CODE_LEN,
3045 (char *)me_ns_code );
3046
3047 me_ns_code[2] = '\0';
3048 me_ns_code_first = atoi((const char *)me_ns_code);
3049
3050 memcpy( me_ns_code_bcd,
3051 &(((UBYTE *)personalisation_ns->pBody)[*index]),
3052 NS_CODE_LEN );
3053
3054 *index += NS_CODE_LEN;
3055 aci_slock_psaSIM_decodeIMSI_without_parity( me_ns_code_bcd,
3056 NS_CODE_LEN,
3057 (char *)me_ns_code );
3058
3059 me_ns_code[2] = '\0';
3060 me_ns_code_last = atoi((const char *)me_ns_code);
3061
3062 sim_ns_code =
3063 aci_slock_extractCode( &imsi_sim[simShrdPrm.mnc_len+3], 2 );
3064
3065 if( ( sim_ns_code >= me_ns_code_first ) AND
3066 ( sim_ns_code <= me_ns_code_last ) )
3067 {
3068 return TRUE; /* Matches */
3069 }
3070 else
3071 {
3072 return FALSE;
3073 }
3074 }
3075 }
3076 else
3077 {
3078 *index += ( NS_CODE_LEN*no_of_normal_8th_digit_ns_code +
3079 2*NS_CODE_LEN*no_of_interval_8th_digit_ns_code ) ;
3080 }
3081 }
3082 }
3083 }
3084 return FALSE;
3085 }
3086
3087 /* Implements Measure 146 */
3088 /*
3089 +------------------------------------------------------------------------------
3090 | Function : aci_slock_compare_gid_str
3091 +------------------------------------------------------------------------------
3092 | Description : This function will compare the gid str present in the SIM
3093 | and the gid str present in the MEPD Database.
3094 |
3095 | This function can compare both the gid str i.e for
3096 | Group Identifier Level 1 and Group Identifier Level 2.
3097 | depending upon the Group Identifier Level passed as an
3098 | argument grp_lvl.
3099 |
3100 |
3101 | Parameters : imsi_me - IMSI from Personalisation DataBase
3102 | imsi_sim - IMSI from SIM
3103 | index -
3104 | grp_lvl - Group Identifier Level 1 or
3105 | Group Identifier Level 2
3106 |
3107 | Return : BOOL - Returns the Result of the comparison
3108 +------------------------------------------------------------------------------
3109 */
3110
3111 LOCAL UBYTE aci_slock_compare_gid_str( UBYTE *imsi_me,
3112 UBYTE *imsi_sim,
3113 UINT16 *index,
3114 T_SIM_SRV grp_lvl)
3115 {
3116 UBYTE cmp_result = TRUE;
3117 UBYTE me_gid1_str[GID1_LEN+1];
3118 UBYTE me_gid2_str[GID2_LEN+1];
3119 UBYTE sim_gid1_str[GID1_LEN+1];
3120 UBYTE sim_gid2_str[GID2_LEN+1];
3121
3122 TRACE_FUNCTION( "aci_slock_compare_gid_str()" );
3123 if(imsi_me[0] NEQ 0)
3124 {
3125 cmp_result = memcmp( imsi_sim, imsi_me,simShrdPrm.mnc_len+3 ) EQ 0;
3126 }
3127
3128 if ( cmp_result EQ TRUE )
3129 {
3130 if ( psaSIM_ChkSIMSrvSup(SRV_GrpLvl1) )
3131 {
3132 if( grp_lvl EQ SRV_GrpLvl1 )
3133 {
3134 return ( aci_slock_compare_gid( me_gid1_str,
3135 aci_slock_sim_config.sim_gidl1,
3136 sim_gid1_str, GID1_LEN,
3137 (UBYTE *)personalisation_sp->pBody,
3138 index ) );
3139 }
3140 else
3141 {
3142 memcpy( me_gid1_str,&(((UBYTE *)personalisation_cp->pBody)[*index]),
3143 GID1_LEN);
3144 *index +=GID1_LEN;
3145
3146 cmp_result = memcmp( aci_slock_sim_config.sim_gidl1, me_gid1_str,
3147 cfg_data->GID1_Len ) EQ 0;
3148
3149 if ( cmp_result EQ TRUE )
3150 {
3151 if ( psaSIM_ChkSIMSrvSup(SRV_GrpLvl2) )
3152 {
3153 return ( aci_slock_compare_gid( me_gid2_str,
3154 aci_slock_sim_config.sim_gidl2,
3155 sim_gid2_str, GID2_LEN,
3156 (UBYTE *)personalisation_cp->pBody,
3157 index ) );
3158 }
3159 }
3160 }
3161 }
3162 }
3163 return FALSE;
3164 }
3165
3166 /*
3167 +------------------------------------------------------------------------------
3168 | Function : aci_slock_compare_gid
3169 +------------------------------------------------------------------------------
3170 | Description : This function will compare gid str of SIM and the MEPD
3171 | DataBase and returns TRUE if it matches otherwise FALSE
3172 |
3173 |
3174 | Parameters : me_gid_str -
3175 | sim_gidl - gid string from aci_slock_sim_config
3176 | sim_gid_str -
3177 | gid_len - gid length
3178 | pBody - Personalisation Data
3179 | index -
3180 |
3181 | Return : BOOL - Returns the Result of the comparison
3182 +------------------------------------------------------------------------------
3183 */
3184
3185 LOCAL UBYTE aci_slock_compare_gid( UBYTE *me_gid_str, UBYTE *sim_gidl,
3186 UBYTE *sim_gid_str, UBYTE gid_len,
3187 UBYTE *pBody, UINT16 *index )
3188 {
3189 int sim_gid, me_gid_first, me_gid_last;
3190
3191 TRACE_FUNCTION( "aci_slock_compare_gid()" );
3192
3193 me_gid_first = aci_slock_extractCode( &(pBody[*index]), gid_len );
3194 *index +=gid_len;
3195
3196 me_gid_last = aci_slock_extractCode( &(pBody[*index]), gid_len );
3197 *index +=gid_len;
3198
3199 sim_gid = aci_slock_extractCode( sim_gidl, gid_len );
3200
3201 if((sim_gid >= me_gid_first) AND (sim_gid <= me_gid_last))
3202 {
3203 return TRUE; /* Matches */
3204 }
3205 else
3206 {
3207 return FALSE;
3208 }
3209 }
3210
3211 /* Implements Measure 160 */
3212 /*
3213 +------------------------------------------------------------------------------
3214 | Function : aci_slock_check_isgidPresent
3215 +------------------------------------------------------------------------------
3216 | Description : This function will compare gid str of SIM and the MEPD
3217 | DataBase for the NORMAL CODE type
3218 | and returns TRUE if it matches otherwise FALSE
3219 |
3220 |
3221 | Parameters : pBody - Personalisation Data
3222 | imsi_sim - IMSI from SIM
3223 | imsi_me - IMSI from Personalisation DataBase
3224 | grp_lvl - Group Identifier Level 1 or
3225 | Group Identifier Level 2
3226 | index -
3227 |
3228 | Return : BOOL - Returns the Result of the comparison
3229 +------------------------------------------------------------------------------
3230 */
3231
3232 LOCAL UBYTE aci_slock_check_isgidPresent( UBYTE *pBody, UBYTE *imsi_sim,
3233 UBYTE *imsi_me, T_SIM_SRV grp_lvl, UINT16 *index )
3234 {
3235 UBYTE me_gid1_str[GID1_LEN+1];
3236 UBYTE me_gid2_str[GID2_LEN+1];
3237 UBYTE cmp_result = TRUE;
3238
3239 TRACE_FUNCTION( "aci_slock_check_isgidPresent()" );
3240 if(imsi_me[0] NEQ 0)
3241 {
3242 cmp_result = memcmp(imsi_sim,imsi_me,simShrdPrm.mnc_len+3) EQ 0;
3243 }
3244
3245 if ( cmp_result EQ TRUE )
3246 {
3247 if ( psaSIM_ChkSIMSrvSup(SRV_GrpLvl1) )
3248 {
3249 memcpy( me_gid1_str,&(pBody[*index]), GID1_LEN );
3250 *index +=GID1_LEN;
3251 cmp_result = memcmp( aci_slock_sim_config.sim_gidl1,
3252 me_gid1_str, cfg_data->GID1_Len) EQ 0;
3253
3254 if ( cmp_result EQ TRUE )
3255 {
3256 if( grp_lvl EQ SRV_GrpLvl2 )
3257 {
3258 if (psaSIM_ChkSIMSrvSup(SRV_GrpLvl2))
3259 {
3260 memcpy( me_gid2_str, &(pBody[*index]), GID2_LEN);
3261 *index +=GID2_LEN;
3262 cmp_result = memcmp( aci_slock_sim_config.sim_gidl2,
3263 me_gid2_str, cfg_data->GID2_Len ) EQ 0;
3264 if ( cmp_result EQ TRUE )
3265 {
3266 return TRUE;
3267 }
3268 }
3269 }
3270 else
3271 {
3272 return TRUE;
3273 }
3274 }
3275 }
3276 }
3277 return FALSE;
3278 }
3279
3280 /* Implements NEW Measure */
3281 /*
3282 +------------------------------------------------------------------------------
3283 | Function : aci_slock_decode_MEPD
3284 +------------------------------------------------------------------------------
3285 | Description : This function will convert IMSI of MEPD DataBase
3286 | from BCD to ASCII format.
3287 |
3288 | Parameters : pBody - Personalisation Data
3289 | index -
3290 | code_len - Code Length
3291 | imsi_ascii - IMSI in ASCII Format (OutPut parameter)
3292 |
3293 | Return : void
3294 +------------------------------------------------------------------------------
3295 */
3296
3297 LOCAL void aci_slock_decode_MEPD( UBYTE *pBody, UINT16 *index, UBYTE code_len,
3298 UBYTE *imsi_ascii )
3299 {
3300 UBYTE me_code_bcd[NW_NS_MSIN_MSIN_CODE_LEN];
3301 /*
3302 * NW_NS_MSIN_MSIN_CODE_LEN has been used because this is the biggest size
3303 * needed by the callers of the this function
3304 */
3305 TRACE_FUNCTION( "aci_slock_decode_MEPD()" );
3306
3307 memcpy( me_code_bcd, &(pBody[*index]), code_len );
3308 *index += code_len;
3309 aci_slock_psaSIM_decodeIMSI( me_code_bcd, code_len, (char *)imsi_ascii );
3310 }
3311
3312 /* Implements NEW Measure */
3313 /*
3314 +------------------------------------------------------------------------------
3315 | Function : aci_slock_set_me_personalisation_status
3316 +------------------------------------------------------------------------------
3317 | Description : This function will set the Global Flag AciSLockShrd.blocked
3318 | or sim_code_present_in_me.
3319 |
3320 | Parameters : personalisation - Personalisation
3321 | status - TRUE or FALSE
3322 |
3323 | Return : void
3324 +------------------------------------------------------------------------------
3325 */
3326
3327 LOCAL void aci_slock_set_me_personalisation_status( UBYTE personalisation,
3328 UBYTE status )
3329 {
3330 TRACE_FUNCTION( "aci_slock_set_me_personalisation_status()" );
3331
3332 if( !personalisation )
3333 {
3334 AciSLockShrd.blocked = !status;
3335 }
3336 else
3337 {
3338 sim_code_present_in_me = status;
3339 }
3340
3341 }
3342
3343 #endif