FreeCalypso > hg > fc-magnetite
comparison src/aci2/aci/cmh_simf.c @ 3:93999a60b835
src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 26 Sep 2016 00:29:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:c41a534f33c6 | 3:93999a60b835 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS (6147) | |
4 | Modul : CMH_SIMF | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This module defines the functions used by the commad | |
18 | handler for the subscriber identity module. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef CMH_SIMF_C | |
23 #define CMH_SIMF_C | |
24 #endif | |
25 | |
26 #include "aci_all.h" | |
27 /*==== INCLUDES ===================================================*/ | |
28 #include "aci_cmh.h" | |
29 #include "ati_cmd.h" | |
30 #include "aci_cmd.h" | |
31 #include "pcm.h" | |
32 | |
33 #ifdef DTI | |
34 #include "dti.h" | |
35 #include "dti_conn_mng.h" | |
36 #endif | |
37 | |
38 #ifdef FAX_AND_DATA | |
39 #include "aci_fd.h" | |
40 #endif /* of #ifdef FAX_AND_DATA */ | |
41 | |
42 #include "aci.h" | |
43 #include "psa.h" | |
44 #include "psa_sim.h" | |
45 #include "psa_cc.h" | |
46 #include "psa_sat.h" | |
47 #include "psa_mm.h" | |
48 #include "psa_util.h" | |
49 #include "cmh.h" | |
50 #include "cmh_sim.h" | |
51 #include "cmh_mm.h" | |
52 #include "phb.h" | |
53 #ifdef SIM_PERS | |
54 #include "aci_ext_pers.h" | |
55 #include "aci_slock.h" | |
56 #include "general.h" // inluded for UINT8 compilation error in sec_drv.h | |
57 #include "sec_drv.h" | |
58 | |
59 EXTERN T_ACI_SIM_CONFIG aci_slock_sim_config; | |
60 EXTERN T_SEC_DRV_CONFIGURATION *cfg_data; | |
61 #endif | |
62 | |
63 EXTERN T_SIM_MMI_INSERT_IND *last_sim_mmi_insert_ind; | |
64 /* #include "m_cc.h" */ | |
65 | |
66 /*==== CONSTANTS ==================================================*/ | |
67 | |
68 /*==== TYPES ======================================================*/ | |
69 | |
70 /*==== EXPORT =====================================================*/ | |
71 | |
72 /*==== VARIABLES ==================================================*/ | |
73 const UBYTE PLMNselEmpty[] = { 0xFF, 0xFF, 0xFF }; | |
74 #ifdef SIM_PERS_OTA | |
75 UBYTE nw_ctrl_key[9], nw_subset_ctrl_key[9], sp_ctrl_key[9], corp_ctrl_key[9]; | |
76 #define MAX_DCK_LEN 16 | |
77 #endif | |
78 | |
79 /*==== FUNCTIONS ==================================================*/ | |
80 void cmhSIM_Read_AD_cb(SHORT table_id); | |
81 void cmhSIM_Get_CSP_cb(SHORT table_id); | |
82 void cmhSIM_Read_CSP_cb(SHORT table_id); | |
83 #ifdef SIM_PERS_OTA | |
84 void cmhSIM_Read_DCK_cb(SHORT table_id); | |
85 void cmhSIM_Read_DCK_init_cb(SHORT table_id); | |
86 void cmhSIM_WriteDefaultValue_DCK_cb(SHORT table_id); | |
87 #endif | |
88 /* | |
89 +-------------------------------------------------------------------+ | |
90 | PROJECT : GSM-PS (6147) MODULE : CMH_SIM | | |
91 | ROUTINE : cmhSIM_FillInPIN | | |
92 +-------------------------------------------------------------------+ | |
93 | |
94 PURPOSE : fill in the PIN into the PIN field of size length and | |
95 stuff unused chars with 0xFF. | |
96 | |
97 */ | |
98 | |
99 GLOBAL void cmhSIM_FillInPIN ( CHAR * PINStr, CHAR * PINFld, UBYTE len ) | |
100 { | |
101 UBYTE idx; | |
102 | |
103 strncpy( PINFld, PINStr, len ); | |
104 | |
105 for( idx = strlen( PINStr ); idx < len; idx++ ) | |
106 { | |
107 PINFld[idx] = NOT_PRESENT_CHAR; | |
108 } | |
109 } | |
110 | |
111 /* | |
112 +-------------------------------------------------------------------+ | |
113 | PROJECT : GSM-PS (6147) MODULE : CMH_SIM | | |
114 | ROUTINE : cmhSIM_GetHomePLMN | | |
115 +-------------------------------------------------------------------+ | |
116 | |
117 PURPOSE : Extract home PLMN out of the IMSI. | |
118 | |
119 */ | |
120 | |
121 GLOBAL void cmhSIM_GetHomePLMN ( SHORT * mccBuf, SHORT * mncBuf ) | |
122 { | |
123 UBYTE digit; /* holds 4bit digit */ | |
124 UBYTE i; /* holds counter */ | |
125 | |
126 if( simShrdPrm.imsi.c_field EQ 0 ) | |
127 { | |
128 /* | |
129 * No SIM present | |
130 */ | |
131 *mccBuf = *mncBuf = -1; | |
132 } | |
133 else | |
134 { | |
135 /* | |
136 * SIM present | |
137 */ | |
138 *mccBuf = *mncBuf = 0; | |
139 | |
140 /* Convert MCC and MNC. */ | |
141 for (i = 0; i < SIZE_MCC + SIZE_MNC; i++) | |
142 { | |
143 digit = (i & 1) ? | |
144 (simShrdPrm.imsi.field[(i + 1)/2] & 0x0f) : | |
145 (simShrdPrm.imsi.field[(i + 1)/2] & 0xf0) >> 4; | |
146 if (i < SIZE_MCC) | |
147 *mccBuf = (*mccBuf << 4) | digit; | |
148 else | |
149 *mncBuf = (*mncBuf << 4) | digit; | |
150 } | |
151 /* The only 3 digit mnc codes that are valid are the values between 310 and 316 */ | |
152 if ((*mccBuf >= 0x310) AND (*mccBuf <= 0x316) | |
153 OR simShrdPrm.mnc_len EQ 3) | |
154 { | |
155 /* used in the US - mcc = 0x310 */ | |
156 } | |
157 /* Set the third digit of the MNC to 'F' if the SIM indicates a 2-digit MNC country */ | |
158 else /* if (simShrdPrm.mnc_len EQ 2) */ | |
159 { | |
160 /* The MS digit of the mnc is not valid, so replace the LSB it with 0xF. */ | |
161 *mncBuf |= 0x00F; | |
162 } | |
163 } | |
164 } | |
165 | |
166 /* | |
167 +-------------------------------------------------------------------+ | |
168 | PROJECT : GSM-PS (6147) MODULE : CMH_MM | | |
169 | ROUTINE : cmhSIM_plmn_equal_sim | | |
170 +-------------------------------------------------------------------+ | |
171 | |
172 PURPOSE : Return TRUE if the PLMN received equals the PLMN | |
173 stored on the SIM. | |
174 This is not exactly the algorithm as shown for HPLMN | |
175 matching as shown in 03.22 Normative Annex A, this version | |
176 here is more universal. | |
177 | |
178 */ | |
179 | |
180 GLOBAL BOOL cmhSIM_plmn_equal_sim (SHORT bcch_mcc, SHORT bcch_mnc, | |
181 SHORT sim_mcc, SHORT sim_mnc) | |
182 { | |
183 /*TRACE_FUNCTION ("cmhSIM_plmn_equal_sim()");*/ | |
184 | |
185 /* Check MCC */ | |
186 if (sim_mcc NEQ bcch_mcc) | |
187 return FALSE; | |
188 | |
189 /* Check first 2 MNC digits */ | |
190 if ((sim_mnc & 0xff0) NEQ (bcch_mnc & 0xff0)) | |
191 return FALSE; | |
192 | |
193 /* Check for full match */ | |
194 if ((sim_mnc & 0xf) EQ (bcch_mnc & 0xf)) | |
195 return TRUE; | |
196 | |
197 /* The 3rd digit of the MNC differs */ | |
198 if ((bcch_mcc >= 0x310) AND (bcch_mcc <= 0x316) | |
199 OR simShrdPrm.mnc_len EQ 3) | |
200 { | |
201 /* | |
202 * The MCC is in the range 310..316, this means North America. | |
203 * The zero suffix rule applies. | |
204 */ | |
205 return ((((sim_mnc & 0xf) EQ 0xf) AND ((bcch_mnc & 0xf) EQ 0x0)) OR | |
206 (((sim_mnc & 0xf) EQ 0x0) AND ((bcch_mnc & 0xf) EQ 0xf))); | |
207 } | |
208 return ((bcch_mnc & 0xf) EQ 0xf); | |
209 } | |
210 | |
211 /* | |
212 +-------------------------------------------------------------------+ | |
213 | PROJECT : GSM-PS (6147) MODULE : CMH_MM | | |
214 | ROUTINE : cmhSIM_plmn_is_hplmn | | |
215 +-------------------------------------------------------------------+ | |
216 | |
217 PURPOSE : Return TRUE if the PLMN received is the HPLMN, otherwise | |
218 return FALSE. | |
219 | |
220 */ | |
221 | |
222 GLOBAL BOOL cmhSIM_plmn_is_hplmn (SHORT bcch_mcc, SHORT bcch_mnc) | |
223 { | |
224 SHORT sim_mcc; /* Holds the MCC of the HPLMN from the SIM */ | |
225 SHORT sim_mnc; /* Holds the MNC of the HPLMN from the SIM */ | |
226 | |
227 TRACE_FUNCTION ("cmhSIM_plmn_is_hplmn()"); | |
228 | |
229 if(!cmhMM_GetActingHPLMN(&sim_mcc, &sim_mnc))/*Enhancement Acting HPLMN*/ | |
230 { | |
231 /* Extract the HPLMN identification out of the IMSI digits. */ | |
232 cmhSIM_GetHomePLMN (&sim_mcc, &sim_mnc); | |
233 } | |
234 | |
235 return cmhSIM_plmn_equal_sim (bcch_mcc, bcch_mnc, sim_mcc, sim_mnc); | |
236 } | |
237 | |
238 /* | |
239 +-------------------------------------------------------------------+ | |
240 | PROJECT : GSM-PS (6147) MODULE : CMH_SIM | | |
241 | ROUTINE : cmhSIM_GetCmeFromSim | | |
242 +-------------------------------------------------------------------+ | |
243 | |
244 PURPOSE : Mapping of SIM error code to ACI error code. | |
245 | |
246 */ | |
247 GLOBAL T_ACI_CME_ERR cmhSIM_GetCmeFromSim ( USHORT errCode ) | |
248 { | |
249 switch ( errCode ) | |
250 { | |
251 case SIM_NO_ERROR: | |
252 return CME_ERR_NotPresent; | |
253 | |
254 case SIM_CAUSE_PIN1_EXPECT: | |
255 return CME_ERR_SimPinReq; | |
256 | |
257 case SIM_CAUSE_PIN2_EXPECT: | |
258 return CME_ERR_SimPin2Req; | |
259 | |
260 case SIM_CAUSE_PUK1_EXPECT: | |
261 return CME_ERR_WrongPasswd; | |
262 case SIM_CAUSE_PIN1_BLOCKED: | |
263 return CME_ERR_SimPukReq; | |
264 | |
265 case SIM_CAUSE_PUK2_EXPECT: | |
266 return CME_ERR_WrongPasswd; | |
267 case SIM_CAUSE_PIN2_BLOCKED: | |
268 return CME_ERR_SimPuk2Req; | |
269 | |
270 case SIM_CAUSE_PUK1_BLOCKED: | |
271 case SIM_CAUSE_PUK2_BLOCKED: | |
272 return CME_ERR_SimWrong; | |
273 | |
274 case SIM_CAUSE_NO_SELECT: | |
275 case SIM_CAUSE_UNKN_FILE_ID: | |
276 return CME_ERR_NotFound; | |
277 | |
278 case SIM_CAUSE_EF_INVALID: | |
279 return CME_ERR_OpNotSupp; | |
280 | |
281 case SIM_CAUSE_ADDR_WRONG: | |
282 return CME_ERR_InvIdx; | |
283 | |
284 case SIM_CAUSE_CMD_INCONSIST: | |
285 case SIM_CAUSE_MAX_INCREASE: | |
286 case SIM_CAUSE_CHV_NOTSET: | |
287 case SIM_CAUSE_CHV_VALIDATED: | |
288 return CME_ERR_OpNotAllow; | |
289 | |
290 case SIM_CAUSE_ACCESS_PROHIBIT: | |
291 return CME_ERR_WrongPasswd; | |
292 | |
293 case SIM_CAUSE_CARD_REMOVED: | |
294 case SIM_CAUSE_DRV_NOCARD: | |
295 return CME_ERR_SimNotIns; | |
296 | |
297 case SIM_CAUSE_CLA_WRONG: | |
298 case SIM_CAUSE_INS_WRONG: | |
299 case SIM_CAUSE_P1P2_WRONG: | |
300 case SIM_CAUSE_P3_WRONG: | |
301 case SIM_CAUSE_PARAM_WRONG: | |
302 return CME_ERR_PhoneFail; | |
303 | |
304 case SIM_CAUSE_SAT_BUSY: | |
305 return CME_ERR_SimBusy; | |
306 | |
307 case SIM_CAUSE_DNL_ERROR: | |
308 return CME_ERR_Unknown; | |
309 | |
310 case SIM_CAUSE_DRV_TEMPFAIL: | |
311 return CME_ERR_SimFail; | |
312 | |
313 default: | |
314 if (GET_CAUSE_DEFBY(errCode) EQ DEFBY_CONDAT AND | |
315 GET_CAUSE_ORIGSIDE(errCode) EQ ORIGSIDE_MS) | |
316 { | |
317 return CME_ERR_Unknown; | |
318 } | |
319 return CME_ERR_Unknown; | |
320 } | |
321 } | |
322 | |
323 /* | |
324 +--------------------------------------------------------------------+ | |
325 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
326 | STATE : code ROUTINE : cmhSIM_getUserRate | | |
327 +--------------------------------------------------------------------+ | |
328 | |
329 PURPOSE : | |
330 */ | |
331 GLOBAL T_ACI_BS_SPEED cmhSIM_GetUserRate ( UBYTE userRate ) | |
332 { | |
333 switch( userRate ) | |
334 { | |
335 case ( UR_0_3_KBIT ): return BS_SPEED_300_V110; | |
336 case ( UR_1_2_KBIT ): return BS_SPEED_1200_V110; | |
337 case ( UR_2_4_KBIT ): return BS_SPEED_2400_V110; | |
338 case ( UR_4_8_KBIT ): return BS_SPEED_4800_V110; | |
339 case ( UR_9_6_KBIT ): return BS_SPEED_9600_V110; | |
340 case ( UR_1_2_KBIT_V23 ): return BS_SPEED_1200_75_V23; | |
341 case ( UR_12_0_KBIT_TRANS ): | |
342 default: return BS_SPEED_NotPresent; | |
343 } | |
344 } | |
345 | |
346 /* | |
347 +--------------------------------------------------------------------+ | |
348 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
349 | STATE : code ROUTINE : cmhSIM_getSrvFromSync | | |
350 +--------------------------------------------------------------------+ | |
351 | |
352 PURPOSE : | |
353 */ | |
354 GLOBAL T_ACI_CNUM_SERV cmhSIM_GetSrvFromSync ( UBYTE sync ) | |
355 { | |
356 switch( sync ) | |
357 { | |
358 case ( ASYNCHRONOUS ): return CNUM_SERV_Asynch; | |
359 case ( SYNCHRONOUS ): return CNUM_SERV_Synch; | |
360 default: return CNUM_SERV_NotPresent; | |
361 } | |
362 } | |
363 | |
364 /* | |
365 +--------------------------------------------------------------------+ | |
366 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
367 | STATE : code ROUTINE : cmhSIM_getSrvFromItc | | |
368 +--------------------------------------------------------------------+ | |
369 | |
370 PURPOSE : | |
371 */ | |
372 GLOBAL T_ACI_CNUM_SERV cmhSIM_GetSrvFromItc ( UBYTE itc ) | |
373 { | |
374 switch( itc ) | |
375 { | |
376 case ( ITC_SPEECH ): return CNUM_SERV_Voice; | |
377 case ( ITC_FAX_GROUP_3 ): return CNUM_SERV_Fax; | |
378 default: return CNUM_SERV_NotPresent; | |
379 } | |
380 } | |
381 | |
382 /* | |
383 +--------------------------------------------------------------------+ | |
384 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
385 | STATE : code ROUTINE : cmhSIM_getUserRate | | |
386 +--------------------------------------------------------------------+ | |
387 | |
388 PURPOSE : | |
389 */ | |
390 GLOBAL T_ACI_CNUM_ITC cmhSIM_GetItc ( UBYTE itc ) | |
391 { | |
392 switch( itc ) | |
393 { | |
394 case ( ITC_DIGITAL_UNRESTRICTED ): return CNUM_ITC_Udi; | |
395 case ( ITC_AUDIO ): return CNUM_ITC_3_1_kHz; | |
396 default: return CNUM_ITC_NotPresent; | |
397 } | |
398 } | |
399 | |
400 /* | |
401 +--------------------------------------------------------------------+ | |
402 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
403 | STATE : code ROUTINE : cmhSIM_getMncMccFrmPLMNsel | | |
404 +--------------------------------------------------------------------+ | |
405 | |
406 PURPOSE : get MNC and MCC out of EF PLMNsel entry | |
407 */ | |
408 | |
409 GLOBAL void cmhSIM_getMncMccFrmPLMNsel(const UBYTE *ntry, | |
410 SHORT *mcc, | |
411 SHORT *mnc ) | |
412 { | |
413 if (memcmp (ntry, PLMNselEmpty, sizeof(PLMNselEmpty)) EQ 0) | |
414 { | |
415 *mcc = *mnc = -1; | |
416 } | |
417 else | |
418 { | |
419 *mcc = ( ntry[0] & 0x0f) << 8; | |
420 *mcc |= ((ntry[0] >> 4) & 0x0f) << 4; | |
421 *mcc |= ( ntry[1] & 0x0f); | |
422 *mnc = ( ntry[2] & 0x0f) << 8; | |
423 *mnc |= ((ntry[2] >> 4) & 0x0f) << 4; | |
424 *mnc |= ((ntry[1] >> 4) & 0x0f); | |
425 } | |
426 } | |
427 | |
428 /* | |
429 +--------------------------------------------------------------------+ | |
430 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
431 | STATE : code ROUTINE : cmhSIM_GetCodedPLMN | | |
432 +--------------------------------------------------------------------+ | |
433 | |
434 PURPOSE : Code MNC and MCC according a EF PLMNsel entry | |
435 */ | |
436 | |
437 GLOBAL BOOL cmhSIM_GetCodedPLMN( const CHAR *oper, T_ACI_CPOL_FRMT format, | |
438 UBYTE *sim_plmn ) | |
439 { | |
440 T_OPER_ENTRY operDesc; /* operator description */ | |
441 BOOL found; | |
442 | |
443 /* get MNC and MCC */ | |
444 switch( format ) | |
445 { | |
446 case( CPOL_FRMT_Long ): | |
447 found = cmhMM_FindName( &operDesc, oper, COPS_FRMT_Long ); | |
448 break; | |
449 case( CPOL_FRMT_Short ): | |
450 found = cmhMM_FindName( &operDesc, oper, COPS_FRMT_Short ); | |
451 break; | |
452 case( CPOL_FRMT_Numeric ): | |
453 found = cmhMM_FindNumeric( &operDesc, oper ); | |
454 break; | |
455 default: | |
456 return( FALSE ); | |
457 } | |
458 | |
459 if( !found ) | |
460 return( FALSE ); | |
461 | |
462 /* code MCC and MNC */ | |
463 sim_plmn[0] = (operDesc.mcc & 0xf00) >> 8; | |
464 sim_plmn[0] |= (operDesc.mcc & 0x0f0) ; | |
465 sim_plmn[1] = (operDesc.mcc & 0x00f) ; | |
466 sim_plmn[1] |= (operDesc.mnc & 0x00f) << 4; | |
467 sim_plmn[2] = (operDesc.mnc & 0xf00) >> 8; | |
468 sim_plmn[2] |= (operDesc.mnc & 0x0f0) ; | |
469 | |
470 return( TRUE ); | |
471 } | |
472 | |
473 /* | |
474 +--------------------------------------------------------------------+ | |
475 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
476 | STATE : code ROUTINE : cmhSIM_FillPlmnSelList | | |
477 +--------------------------------------------------------------------+ | |
478 | |
479 PURPOSE : Fills in the CPOL list out of EF PLMNsel and returns the | |
480 last written index. | |
481 */ | |
482 GLOBAL SHORT cmhSIM_FillPlmnSelList ( UBYTE index, | |
483 T_ACI_CPOL_FRMT frmt, | |
484 T_ACI_CPOL_OPDESC* operLst, | |
485 UBYTE length, | |
486 UBYTE* pData ) | |
487 { | |
488 BOOL found; /* cmhMM_FindXXX found an entry */ | |
489 UBYTE idx; /* holds list index */ | |
490 SHORT off; /* holds PLMNsel offset */ | |
491 SHORT lastIdx; /* holds last index written to list */ | |
492 SHORT mcc; /* holds mcc value */ | |
493 SHORT mnc; /* holds mnc value */ | |
494 T_OPER_ENTRY OpDsc; /* operator description */ | |
495 | |
496 /* | |
497 *----------------------------------------------------------------- | |
498 * calculate PLMNsel offset | |
499 *----------------------------------------------------------------- | |
500 */ | |
501 off = (index-1) * ACI_LEN_PLMN_SEL_NTRY; | |
502 | |
503 /* | |
504 *----------------------------------------------------------------- | |
505 * fill the preferred operator list | |
506 *----------------------------------------------------------------- | |
507 */ | |
508 idx = 0; | |
509 lastIdx = ACI_NumParmNotPresent; | |
510 | |
511 do | |
512 { | |
513 /* get mnc and mcc out of PLMNsel field */ | |
514 cmhSIM_getMncMccFrmPLMNsel( (pData+off), &mcc, & mnc ); | |
515 | |
516 /* end of PLMNsel field */ | |
517 if( off >= length ) | |
518 { | |
519 operLst[idx].index = ACI_NumParmNotPresent; | |
520 operLst[idx].format = CPOL_FRMT_NotPresent; | |
521 operLst[idx].oper[0] = 0x0; | |
522 break; | |
523 } | |
524 | |
525 /* valid entry */ | |
526 if( !(mcc < 0 AND mnc < 0) ) | |
527 { | |
528 operLst[idx].index = index; | |
529 operLst[idx].format = frmt; | |
530 | |
531 found = cmhMM_FindPLMN( &OpDsc, mcc, mnc, NOT_PRESENT_16BIT, FALSE); | |
532 | |
533 switch( frmt ) | |
534 { | |
535 case( CPOL_FRMT_Long ): | |
536 if (OpDsc.pnn) | |
537 { | |
538 if (OpDsc.long_len) | |
539 { | |
540 switch (OpDsc.long_ext_dcs>>4 & 0x07) | |
541 { | |
542 case 0x00: | |
543 utl_cvtPnn7To8((UBYTE *)OpDsc.longName, | |
544 OpDsc.long_len, | |
545 OpDsc.long_ext_dcs, | |
546 (UBYTE *)operLst[idx].oper); | |
547 break; | |
548 case 0x01: | |
549 TRACE_ERROR ("ERROR: Unhandled UCS2"); | |
550 break; | |
551 default: | |
552 TRACE_ERROR ("ERROR: Unknown DCS"); | |
553 break; | |
554 } | |
555 } | |
556 else | |
557 { | |
558 operLst[idx].oper[0] = '\0'; | |
559 } | |
560 } | |
561 else | |
562 { | |
563 /* MAX_LONG_OPER_LEN <= MAX_ALPHA_OPER_LEN, no length check needed */ | |
564 strcpy( operLst[idx].oper, OpDsc.longName ); | |
565 } | |
566 break; | |
567 | |
568 case( CPOL_FRMT_Short ): | |
569 if (OpDsc.pnn) | |
570 { | |
571 if (OpDsc.shrt_len) | |
572 { | |
573 switch (OpDsc.shrt_ext_dcs>>4 & 0x07) | |
574 { | |
575 case 0x00: | |
576 utl_cvtPnn7To8((UBYTE *)OpDsc.shrtName, | |
577 OpDsc.shrt_len, | |
578 OpDsc.shrt_ext_dcs, | |
579 (UBYTE *)operLst[idx].oper); | |
580 break; | |
581 case 0x01: | |
582 TRACE_ERROR ("ERROR: Unhandled UCS2"); | |
583 break; | |
584 default: | |
585 TRACE_ERROR ("ERROR: Unknown DCS"); | |
586 break; | |
587 } | |
588 } | |
589 else | |
590 { | |
591 operLst[idx].oper[0] = '\0'; | |
592 } | |
593 } | |
594 else | |
595 { | |
596 /* MAX_SHRT_OPER_LEN <= MAX_ALPHA_OPER_LEN, no length check needed */ | |
597 strcpy( operLst[idx].oper, OpDsc.shrtName ); | |
598 } | |
599 break; | |
600 | |
601 case( CPOL_FRMT_Numeric ): | |
602 if ((mnc & 0x00F) EQ 0xF) | |
603 sprintf (operLst[idx].oper, "%03X%02X", mcc, (mnc & 0xff0) >> 4); | |
604 else | |
605 sprintf (operLst[idx].oper, "%03X%03X", mcc, mnc); | |
606 break; | |
607 } | |
608 idx++; | |
609 lastIdx = index; | |
610 } | |
611 | |
612 off += ACI_LEN_PLMN_SEL_NTRY; | |
613 index++; | |
614 | |
615 } while( idx < MAX_OPER ); | |
616 | |
617 return( lastIdx ); | |
618 } | |
619 | |
620 /* | |
621 +--------------------------------------------------------------------+ | |
622 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
623 | STATE : code ROUTINE : cmhSIM_UsdPlmnSelNtry | | |
624 +--------------------------------------------------------------------+ | |
625 | |
626 PURPOSE : Counts the used entries of the preferred PLMN list and | |
627 returns the number of used entries. | |
628 */ | |
629 GLOBAL SHORT cmhSIM_UsdPlmnSelNtry ( UBYTE length, | |
630 UBYTE* pData ) | |
631 { | |
632 UBYTE idx; /* holds list index */ | |
633 SHORT off; /* holds PLMNsel offset */ | |
634 UBYTE maxNtry; /* holds the maximum number of entries */ | |
635 SHORT used; /* holds number of used entries */ | |
636 SHORT mcc; /* holds mcc value */ | |
637 SHORT mnc; /* holds mnc value */ | |
638 | |
639 /* | |
640 *----------------------------------------------------------------- | |
641 * count the used entries | |
642 *----------------------------------------------------------------- | |
643 */ | |
644 maxNtry = length / ACI_LEN_PLMN_SEL_NTRY; | |
645 | |
646 for( idx = 0, used = 0, off = 0; | |
647 idx < maxNtry; | |
648 idx++, off += ACI_LEN_PLMN_SEL_NTRY ) | |
649 { | |
650 /* get mnc and mcc out of PLMNsel field */ | |
651 cmhSIM_getMncMccFrmPLMNsel( (pData+off), &mcc, & mnc ); | |
652 | |
653 /* valid entry */ | |
654 if( !(mcc < 0 AND mnc < 0) ) | |
655 { | |
656 used++; | |
657 } | |
658 } | |
659 | |
660 return( used ); | |
661 } | |
662 | |
663 /* | |
664 +--------------------------------------------------------------------+ | |
665 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
666 | STATE : code ROUTINE : cmhSIM_CmpctPlmnSel | | |
667 +--------------------------------------------------------------------+ | |
668 | |
669 PURPOSE : Shoves entries of preferred PLMN list to remove empty | |
670 entries of the list. | |
671 */ | |
672 GLOBAL void cmhSIM_CmpctPlmnSel ( UBYTE length, UBYTE* pData ) | |
673 { | |
674 UBYTE maxNtry; /* holds the maximum number of entries */ | |
675 UBYTE lstIdx; /* holds list index */ | |
676 UBYTE* dstNtry; /* points to destination entry index */ | |
677 | |
678 /* | |
679 *----------------------------------------------------------------- | |
680 * compact the list | |
681 *----------------------------------------------------------------- | |
682 */ | |
683 lstIdx = 0; | |
684 dstNtry = pData; | |
685 | |
686 maxNtry = length / ACI_LEN_PLMN_SEL_NTRY; | |
687 | |
688 while( lstIdx < maxNtry ) | |
689 { | |
690 if(memcmp( pData, PLMNselEmpty, sizeof(PLMNselEmpty))) | |
691 { | |
692 if( pData NEQ dstNtry ) | |
693 { | |
694 memcpy( dstNtry, pData, ACI_LEN_PLMN_SEL_NTRY ); | |
695 memcpy( pData, PLMNselEmpty, ACI_LEN_PLMN_SEL_NTRY); | |
696 } | |
697 dstNtry += ACI_LEN_PLMN_SEL_NTRY; | |
698 } | |
699 lstIdx++; | |
700 pData += ACI_LEN_PLMN_SEL_NTRY; | |
701 } | |
702 } | |
703 | |
704 /* | |
705 +--------------------------------------------------------------------+ | |
706 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMS | | |
707 | STATE : code ROUTINE : cmhSIM_ReqPlmnSel | | |
708 +--------------------------------------------------------------------+ | |
709 | |
710 PURPOSE : This function starts reading of EF PLMN SEL from SIM. | |
711 */ | |
712 GLOBAL T_ACI_RETURN cmhSIM_ReqPlmnSel ( T_ACI_CMD_SRC srcId ) | |
713 { | |
714 T_ACI_RETURN ret = AT_FAIL; | |
715 SHORT table_id; | |
716 | |
717 TRACE_FUNCTION ("cmhSIM_ReqPlmnSel()"); | |
718 | |
719 /* | |
720 *----------------------------------------------------------------- | |
721 * request table id for SIM SAP access | |
722 *----------------------------------------------------------------- | |
723 */ | |
724 table_id = psaSIM_atbNewEntry(); | |
725 | |
726 if(table_id NEQ NO_ENTRY) | |
727 { | |
728 simShrdPrm.atb[table_id].accType = ACT_RD_DAT; | |
729 simShrdPrm.atb[table_id].reqDataFld = SIM_PLMNSEL; | |
730 simShrdPrm.atb[table_id].dataOff = 0; | |
731 /* length is variable */ | |
732 simShrdPrm.atb[table_id].dataLen = NOT_PRESENT_8BIT; | |
733 simShrdPrm.atb[table_id].recMax = ACI_LEN_PLMN_SEL_FLD; | |
734 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE; | |
735 simShrdPrm.atb[table_id].exchData = CPOLSimEfData; | |
736 simShrdPrm.atb[table_id].rplyCB = cmhSIM_RdCnfPlmnSel; | |
737 | |
738 simShrdPrm.aId = table_id; | |
739 | |
740 simEntStat.curCmd = AT_CMD_CPOL; | |
741 simEntStat.entOwn = simShrdPrm.owner = srcId; | |
742 | |
743 if(psaSIM_AccessSIMData() < 0) | |
744 { | |
745 TRACE_EVENT("FATAL ERROR psaSIM in +CPOL"); | |
746 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal ); | |
747 } | |
748 else | |
749 { | |
750 ret = AT_EXCT; | |
751 } | |
752 } | |
753 | |
754 return ( ret ); | |
755 } | |
756 | |
757 /* | |
758 +--------------------------------------------------------------------+ | |
759 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMS | | |
760 | STATE : code ROUTINE : cmhSIM_UpdPlmnSel | | |
761 +--------------------------------------------------------------------+ | |
762 | |
763 PURPOSE : This function updates the indexed EF PLMN SEL entry and | |
764 writes the field to the SIM. | |
765 */ | |
766 GLOBAL T_ACI_RETURN cmhSIM_UpdPlmnSel ( T_ACI_CMD_SRC srcId, | |
767 SHORT index, | |
768 UBYTE *plmn, | |
769 T_ACI_CPOL_MOD mode ) | |
770 { | |
771 SHORT off; /* holds EF offset */ | |
772 SHORT cpyOff; /* holds offset for copy operation */ | |
773 UBYTE maxIdx; /* holds maximum number of index */ | |
774 | |
775 TRACE_FUNCTION ("cmhSIM_UpdPlmnSel()"); | |
776 | |
777 /* | |
778 *----------------------------------------------------------------- | |
779 * update EF PLMNsel RAM copy | |
780 *----------------------------------------------------------------- | |
781 */ | |
782 maxIdx = CPOLSimEfDataLen / ACI_LEN_PLMN_SEL_NTRY; | |
783 | |
784 off = (index-1) * ACI_LEN_PLMN_SEL_NTRY; | |
785 | |
786 if( mode EQ CPOL_MOD_Insert AND index < maxIdx ) | |
787 { | |
788 cmhSIM_CmpctPlmnSel ( CPOLSimEfDataLen, CPOLSimEfData ); | |
789 | |
790 cpyOff = (maxIdx-1) * ACI_LEN_PLMN_SEL_NTRY; | |
791 | |
792 cpyOff -= ACI_LEN_PLMN_SEL_NTRY; /* need not copy since last index will fall out of list! */ | |
793 | |
794 while( cpyOff >= off AND cpyOff >= 0 ) | |
795 { | |
796 memcpy( CPOLSimEfData+cpyOff+ACI_LEN_PLMN_SEL_NTRY, | |
797 CPOLSimEfData+cpyOff, ACI_LEN_PLMN_SEL_NTRY ); | |
798 | |
799 cpyOff -= ACI_LEN_PLMN_SEL_NTRY; | |
800 } | |
801 } | |
802 | |
803 memcpy( CPOLSimEfData+off, plmn, ACI_LEN_PLMN_SEL_NTRY ); | |
804 | |
805 return ( cmhSIM_WritePlmnSel( srcId )); | |
806 } | |
807 | |
808 /* | |
809 +--------------------------------------------------------------------+ | |
810 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMS | | |
811 | STATE : code ROUTINE : cmhSIM_FndEmptyPlmnSel | | |
812 +--------------------------------------------------------------------+ | |
813 | |
814 PURPOSE : This function searches for an empty entry in EF PLMN SEL, | |
815 fills it and writes the field to the SIM. | |
816 */ | |
817 GLOBAL T_ACI_RETURN cmhSIM_FndEmptyPlmnSel ( T_ACI_CMD_SRC srcId, | |
818 UBYTE *plmn ) | |
819 { | |
820 UBYTE maxNtry; /* holds maximum number of entries */ | |
821 SHORT off; /* holds EF offset */ | |
822 | |
823 TRACE_FUNCTION ("cmhSIM_FndEmptyPlmnSel()"); | |
824 | |
825 /* | |
826 *----------------------------------------------------------------- | |
827 * search for an empty entry, and update | |
828 *----------------------------------------------------------------- | |
829 */ | |
830 maxNtry = CPOLSimEfDataLen / ACI_LEN_PLMN_SEL_NTRY; | |
831 | |
832 for( off = 0; maxNtry > 0; off += ACI_LEN_PLMN_SEL_NTRY, maxNtry-- ) | |
833 { | |
834 if( !memcmp( CPOLSimEfData+off, PLMNselEmpty, | |
835 ACI_LEN_PLMN_SEL_NTRY )) | |
836 { | |
837 memcpy( CPOLSimEfData+off, plmn, ACI_LEN_PLMN_SEL_NTRY ); | |
838 | |
839 return ( cmhSIM_WritePlmnSel( srcId )); | |
840 } | |
841 } | |
842 | |
843 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_MemFull ); | |
844 return( AT_FAIL ); | |
845 } | |
846 | |
847 /* | |
848 +--------------------------------------------------------------------+ | |
849 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMS | | |
850 | STATE : code ROUTINE : cmhSIM_DelPlmnSel | | |
851 +--------------------------------------------------------------------+ | |
852 | |
853 PURPOSE : This function updates the indexed EF PLMN SEL entry and | |
854 writes the field to the SIM. | |
855 */ | |
856 GLOBAL T_ACI_RETURN cmhSIM_DelPlmnSel ( T_ACI_CMD_SRC srcId, | |
857 SHORT index, | |
858 T_ACI_CPOL_MOD mode ) | |
859 { | |
860 SHORT off; /* holds EF offset */ | |
861 | |
862 TRACE_FUNCTION ("cmhSIM_DelPlmnSel()"); | |
863 | |
864 /* | |
865 *----------------------------------------------------------------- | |
866 * delete entry in EF PLMNsel RAM copy | |
867 *----------------------------------------------------------------- | |
868 */ | |
869 | |
870 off = (index-1) * ACI_LEN_PLMN_SEL_NTRY; | |
871 | |
872 memcpy( CPOLSimEfData+off, PLMNselEmpty, ACI_LEN_PLMN_SEL_NTRY ); | |
873 | |
874 if( mode EQ CPOL_MOD_CompactList ) | |
875 | |
876 cmhSIM_CmpctPlmnSel ( CPOLSimEfDataLen, CPOLSimEfData ); | |
877 | |
878 return ( cmhSIM_WritePlmnSel( srcId )); | |
879 } | |
880 | |
881 /* | |
882 +--------------------------------------------------------------------+ | |
883 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMS | | |
884 | STATE : code ROUTINE : cmhSIM_ChgPlmnSel | | |
885 +--------------------------------------------------------------------+ | |
886 | |
887 PURPOSE : This function exchanges the indexed EF PLMN SEL entries and | |
888 writes the field to the SIM. | |
889 */ | |
890 GLOBAL T_ACI_RETURN cmhSIM_ChgPlmnSel ( T_ACI_CMD_SRC srcId, | |
891 SHORT index, | |
892 SHORT index2 ) | |
893 { | |
894 SHORT off1, off2; /* holds EF offset */ | |
895 UBYTE plmn1[ACI_LEN_PLMN_SEL_NTRY]; /* buffers PLMN 1 */ | |
896 UBYTE plmn2[ACI_LEN_PLMN_SEL_NTRY]; /* buffers PLMN 2 */ | |
897 | |
898 TRACE_FUNCTION ("cmhSIM_ChgPlmnSel()"); | |
899 | |
900 /* | |
901 *----------------------------------------------------------------- | |
902 * change entries in EF PLMNsel RAM copy | |
903 *----------------------------------------------------------------- | |
904 */ | |
905 | |
906 off1 = (index-1) * ACI_LEN_PLMN_SEL_NTRY; | |
907 off2 = (index2-1) * ACI_LEN_PLMN_SEL_NTRY; | |
908 | |
909 memcpy( plmn1, CPOLSimEfData+off1, ACI_LEN_PLMN_SEL_NTRY ); | |
910 memcpy( plmn2, CPOLSimEfData+off2, ACI_LEN_PLMN_SEL_NTRY ); | |
911 | |
912 memcpy( CPOLSimEfData+off1, plmn2, ACI_LEN_PLMN_SEL_NTRY ); | |
913 memcpy( CPOLSimEfData+off2, plmn1, ACI_LEN_PLMN_SEL_NTRY ); | |
914 | |
915 return ( cmhSIM_WritePlmnSel( srcId )); | |
916 } | |
917 | |
918 /* | |
919 +--------------------------------------------------------------------+ | |
920 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
921 | STATE : code ROUTINE : cmhSIM_WritePlmnSel| | |
922 +--------------------------------------------------------------------+ | |
923 | |
924 PURPOSE : This function starts writing of EF PLMN SEL to SIM. | |
925 */ | |
926 GLOBAL T_ACI_RETURN cmhSIM_WritePlmnSel ( T_ACI_CMD_SRC srcId ) | |
927 { | |
928 T_ACI_RETURN ret = AT_FAIL; | |
929 SHORT table_id; | |
930 | |
931 TRACE_FUNCTION ("cmhSIM_WritePlmnSel()"); | |
932 | |
933 /* | |
934 *----------------------------------------------------------------- | |
935 * request table id for SIM SAP access | |
936 *----------------------------------------------------------------- | |
937 */ | |
938 table_id = psaSIM_atbNewEntry(); | |
939 | |
940 if(table_id NEQ NO_ENTRY) | |
941 { | |
942 simShrdPrm.atb[table_id].accType = ACT_WR_DAT; | |
943 simShrdPrm.atb[table_id].reqDataFld = SIM_PLMNSEL; | |
944 simShrdPrm.atb[table_id].dataOff = 0; | |
945 /* length is variable */ | |
946 simShrdPrm.atb[table_id].dataLen = CPOLSimEfDataLen; | |
947 simShrdPrm.atb[table_id].recMax = NOT_PRESENT_8BIT; | |
948 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE; | |
949 simShrdPrm.atb[table_id].exchData = CPOLSimEfData; | |
950 simShrdPrm.atb[table_id].rplyCB = cmhSIM_WrCnfPlmnSel; | |
951 | |
952 simShrdPrm.aId = table_id; | |
953 | |
954 simEntStat.curCmd = AT_CMD_CPOL; | |
955 simEntStat.entOwn = simShrdPrm.owner = srcId; | |
956 | |
957 if(psaSIM_AccessSIMData() < 0) | |
958 { | |
959 TRACE_EVENT("FATAL ERROR psaSIM in +CPOL"); | |
960 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal ); | |
961 } | |
962 else | |
963 { | |
964 ret = AT_EXCT; | |
965 } | |
966 } | |
967 | |
968 return ( ret ); | |
969 } | |
970 | |
971 /* | |
972 +--------------------------------------------------------------------+ | |
973 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
974 | STATE : code ROUTINE : cmhSIM_WriteTranspEF | | |
975 +--------------------------------------------------------------------+ | |
976 | |
977 PURPOSE : This function starts writing of a transparent EF to SIM. | |
978 (SIM only busy with valid 'srcId') | |
979 */ | |
980 GLOBAL T_ACI_RETURN cmhSIM_WriteTranspEF (T_ACI_CMD_SRC srcId, | |
981 T_ACI_AT_CMD cmd, | |
982 USHORT datafield, | |
983 USHORT offset, | |
984 UBYTE datalen, | |
985 UBYTE * exchData, | |
986 void (*rplyCB)(SHORT)) | |
987 { | |
988 T_ACI_RETURN ret = AT_FAIL; | |
989 SHORT table_id; | |
990 | |
991 TRACE_FUNCTION ("cmhSIM_WriteTranspEF()"); | |
992 | |
993 /* | |
994 *----------------------------------------------------------------- | |
995 * request table id for SIM SAP access | |
996 *----------------------------------------------------------------- | |
997 */ | |
998 table_id = psaSIM_atbNewEntry(); | |
999 | |
1000 if(table_id NEQ NO_ENTRY) | |
1001 { | |
1002 simShrdPrm.atb[table_id].accType = ACT_WR_DAT; | |
1003 simShrdPrm.atb[table_id].reqDataFld = datafield; | |
1004 simShrdPrm.atb[table_id].dataOff = offset; | |
1005 simShrdPrm.atb[table_id].recNr = 0; | |
1006 simShrdPrm.atb[table_id].dataLen = datalen; | |
1007 simShrdPrm.atb[table_id].recMax = NOT_PRESENT_8BIT; | |
1008 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE; | |
1009 simShrdPrm.atb[table_id].exchData = exchData; | |
1010 simShrdPrm.atb[table_id].rplyCB = rplyCB; | |
1011 | |
1012 simShrdPrm.aId = table_id; | |
1013 | |
1014 if (srcId NEQ CMD_SRC_NONE) | |
1015 { | |
1016 simEntStat.curCmd = cmd; | |
1017 simEntStat.entOwn = simShrdPrm.owner = srcId; | |
1018 } | |
1019 if(psaSIM_AccessSIMData() < 0) | |
1020 { | |
1021 TRACE_EVENT("FATAL ERROR psaSIM"); | |
1022 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal ); | |
1023 } | |
1024 else | |
1025 { | |
1026 ret = AT_EXCT; | |
1027 } | |
1028 } | |
1029 | |
1030 return ( ret ); | |
1031 } | |
1032 | |
1033 /* | |
1034 +--------------------------------------------------------------------+ | |
1035 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
1036 | STATE : code ROUTINE : cmhSIM_ReadTranspEF | | |
1037 +--------------------------------------------------------------------+ | |
1038 | |
1039 PURPOSE : This function starts reading of EF PLMN SEL from SIM. | |
1040 (SIM only busy with valid 'srcId') | |
1041 */ | |
1042 GLOBAL T_ACI_RETURN cmhSIM_ReadTranspEF ( T_ACI_CMD_SRC srcId, | |
1043 T_ACI_AT_CMD cmd, | |
1044 USHORT datafield, | |
1045 USHORT offset, | |
1046 UBYTE explen, | |
1047 UBYTE * exchData, | |
1048 void (*rplyCB)(SHORT)) | |
1049 { | |
1050 T_ACI_RETURN ret = AT_FAIL; | |
1051 SHORT table_id; | |
1052 | |
1053 TRACE_FUNCTION ("cmhSIM_ReadTranspEF()"); | |
1054 | |
1055 /* | |
1056 *----------------------------------------------------------------- | |
1057 * request table id for SIM SAP access | |
1058 *----------------------------------------------------------------- | |
1059 */ | |
1060 table_id = psaSIM_atbNewEntry(); | |
1061 | |
1062 if(table_id NEQ NO_ENTRY) | |
1063 { | |
1064 simShrdPrm.atb[table_id].accType = ACT_RD_DAT; | |
1065 simShrdPrm.atb[table_id].reqDataFld = datafield; | |
1066 simShrdPrm.atb[table_id].dataOff = offset; | |
1067 simShrdPrm.atb[table_id].recNr = 0; | |
1068 simShrdPrm.atb[table_id].dataLen = NOT_PRESENT_8BIT; | |
1069 simShrdPrm.atb[table_id].recMax = explen; | |
1070 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE; | |
1071 simShrdPrm.atb[table_id].exchData = exchData; | |
1072 simShrdPrm.atb[table_id].rplyCB = rplyCB; | |
1073 | |
1074 simShrdPrm.aId = table_id; | |
1075 | |
1076 if (srcId NEQ CMD_SRC_NONE) | |
1077 { | |
1078 simEntStat.curCmd = cmd; | |
1079 simEntStat.entOwn = simShrdPrm.owner = srcId; | |
1080 } | |
1081 if(psaSIM_AccessSIMData() < 0) | |
1082 { | |
1083 TRACE_EVENT("FATAL ERROR psaSIM"); | |
1084 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal ); | |
1085 } | |
1086 else | |
1087 { | |
1088 ret = AT_EXCT; | |
1089 } | |
1090 } | |
1091 | |
1092 return ( ret ); | |
1093 } | |
1094 | |
1095 /* | |
1096 +--------------------------------------------------------------------+ | |
1097 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
1098 | STATE : code ROUTINE : cmhSIM_WriteRecordEF | | |
1099 +--------------------------------------------------------------------+ | |
1100 | |
1101 PURPOSE : This function starts writing of a transparent EF to SIM. | |
1102 (SIM only busy with valid 'srcId') | |
1103 */ | |
1104 GLOBAL T_ACI_RETURN cmhSIM_WriteRecordEF (T_ACI_CMD_SRC srcId, | |
1105 T_ACI_AT_CMD cmd, | |
1106 USHORT datafield, | |
1107 UBYTE record, | |
1108 UBYTE datalen, | |
1109 UBYTE * exchData, | |
1110 void (*rplyCB)(SHORT)) | |
1111 { | |
1112 T_ACI_RETURN ret = AT_FAIL; | |
1113 SHORT table_id; | |
1114 | |
1115 TRACE_FUNCTION ("cmhSIM_WriteRecordEF()"); | |
1116 | |
1117 /* | |
1118 *----------------------------------------------------------------- | |
1119 * request table id for SIM SAP access | |
1120 *----------------------------------------------------------------- | |
1121 */ | |
1122 table_id = psaSIM_atbNewEntry(); | |
1123 | |
1124 if(table_id NEQ NO_ENTRY) | |
1125 { | |
1126 simShrdPrm.atb[table_id].accType = ACT_WR_REC; | |
1127 simShrdPrm.atb[table_id].reqDataFld = datafield; | |
1128 simShrdPrm.atb[table_id].dataOff = 0; | |
1129 simShrdPrm.atb[table_id].dataLen = datalen; | |
1130 simShrdPrm.atb[table_id].recNr = record; | |
1131 simShrdPrm.atb[table_id].recMax = NOT_PRESENT_8BIT; | |
1132 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE; | |
1133 simShrdPrm.atb[table_id].exchData = exchData; | |
1134 simShrdPrm.atb[table_id].rplyCB = rplyCB; | |
1135 | |
1136 simShrdPrm.aId = table_id; | |
1137 | |
1138 if (srcId NEQ CMD_SRC_NONE) | |
1139 { | |
1140 simEntStat.curCmd = cmd; | |
1141 simEntStat.entOwn = simShrdPrm.owner = srcId; | |
1142 } | |
1143 if(psaSIM_AccessSIMData() < 0) | |
1144 { | |
1145 TRACE_EVENT("FATAL ERROR psaSIM"); | |
1146 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal ); | |
1147 } | |
1148 else | |
1149 { | |
1150 ret = AT_EXCT; | |
1151 } | |
1152 } | |
1153 | |
1154 return ( ret ); | |
1155 } | |
1156 | |
1157 /* | |
1158 +--------------------------------------------------------------------+ | |
1159 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
1160 | STATE : code ROUTINE : cmhSIM_ReadRecordEF | | |
1161 +--------------------------------------------------------------------+ | |
1162 | |
1163 PURPOSE : This function starts reading of EF PLMN SEL from SIM. | |
1164 (SIM only busy with valid 'srcId') | |
1165 */ | |
1166 GLOBAL T_ACI_RETURN cmhSIM_ReadRecordEF ( T_ACI_CMD_SRC srcId, | |
1167 T_ACI_AT_CMD cmd, | |
1168 USHORT datafield, | |
1169 UBYTE record, | |
1170 UBYTE explen, | |
1171 UBYTE * exchData, | |
1172 void (*rplyCB)(SHORT)) | |
1173 { | |
1174 T_ACI_RETURN ret = AT_FAIL; | |
1175 SHORT table_id; | |
1176 | |
1177 TRACE_FUNCTION ("cmhSIM_ReadRecordEF()"); | |
1178 | |
1179 /* | |
1180 *----------------------------------------------------------------- | |
1181 * request table id for SIM SAP access | |
1182 *----------------------------------------------------------------- | |
1183 */ | |
1184 table_id = psaSIM_atbNewEntry(); | |
1185 | |
1186 if(table_id NEQ NO_ENTRY) | |
1187 { | |
1188 simShrdPrm.atb[table_id].accType = ACT_RD_REC; | |
1189 simShrdPrm.atb[table_id].reqDataFld = datafield; | |
1190 simShrdPrm.atb[table_id].dataOff = 0; | |
1191 simShrdPrm.atb[table_id].recNr = record; | |
1192 /* for CPHS (and this shall probably be extended to other SIM | |
1193 access operations) dataLen passed in SIM_READ_RECORD_REQ should | |
1194 be NOT_PRESENT_8BIT (to let the SIM entity handling this length: | |
1195 ACI does not know it anyway...). Yet size of received data should | |
1196 be checked when conf is received (to avoid crashes with exotic SIM cards */ | |
1197 #ifdef FF_CPHS | |
1198 if(cmd EQ AT_CMD_CPHS) | |
1199 { | |
1200 simShrdPrm.atb[table_id].check_dataLen = TRUE; | |
1201 } | |
1202 #endif /* FF_CPHS */ | |
1203 simShrdPrm.atb[table_id].dataLen = explen; | |
1204 simShrdPrm.atb[table_id].recMax = NOT_PRESENT_8BIT; | |
1205 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE; | |
1206 simShrdPrm.atb[table_id].exchData = exchData; | |
1207 simShrdPrm.atb[table_id].rplyCB = rplyCB; | |
1208 | |
1209 simShrdPrm.aId = table_id; | |
1210 | |
1211 if (srcId NEQ CMD_SRC_NONE) | |
1212 { | |
1213 simEntStat.curCmd = cmd; | |
1214 simEntStat.entOwn = simShrdPrm.owner = srcId; | |
1215 } | |
1216 if(psaSIM_AccessSIMData() < 0) | |
1217 { | |
1218 TRACE_EVENT("FATAL ERROR psaSIM"); | |
1219 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal ); | |
1220 } | |
1221 else | |
1222 { | |
1223 ret = AT_EXCT; | |
1224 } | |
1225 } | |
1226 | |
1227 return ( ret ); | |
1228 } | |
1229 | |
1230 /* | |
1231 +--------------------------------------------------------------------+ | |
1232 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
1233 | STATE : code ROUTINE : SimStatusError | | |
1234 +--------------------------------------------------------------------+ | |
1235 | |
1236 PURPOSE : sync_notification: TRUE if notification through asynchrone callback | |
1237 FALSE if notif. whithin synchrone context. | |
1238 | |
1239 */ | |
1240 #define GetSIMError (1) | |
1241 #define CheckSimStatus (0) | |
1242 | |
1243 LOCAL T_ACI_RETURN SimStatusError ( T_ACI_CMD_SRC srcBuf, | |
1244 T_ACI_AT_CMD cmdBuf, | |
1245 UBYTE sync_notification) | |
1246 { | |
1247 T_ACI_CPIN_RSLT code = CPIN_RSLT_NotPresent; | |
1248 T_ACI_CME_ERR err = CME_ERR_NotPresent; | |
1249 | |
1250 /* trace if needed... TRACE_EVENT_P1("simShrdPrm.SIMStat: %d", simShrdPrm.SIMStat); */ | |
1251 | |
1252 switch( simShrdPrm.SIMStat ) | |
1253 { | |
1254 case( SS_OK ): | |
1255 if ( qAT_PlusCPIN(CMD_SRC_LCL, &code) EQ AT_CMPL ) | |
1256 { | |
1257 switch ( code ) | |
1258 { | |
1259 case CPIN_RSLT_PhSimPinReq: | |
1260 err = CME_ERR_PhSimPinReq; | |
1261 break; | |
1262 case CPIN_RSLT_SimPinReq: | |
1263 err = CME_ERR_SimPinReq; | |
1264 break; | |
1265 case CPIN_RSLT_SimPin2Req: | |
1266 err = CME_ERR_SimPin2Req; | |
1267 break; | |
1268 case(CPIN_RSLT_PhFSimPinReq): | |
1269 err = CME_ERR_PhFSimPinReq; | |
1270 break; | |
1271 case(CPIN_RSLT_PhFSimPukReq): | |
1272 err = CME_ERR_PhFSimPukReq; | |
1273 break; | |
1274 case(CPIN_RSLT_PhNetPinReq): | |
1275 err = CME_ERR_NetworkPersPinReq; | |
1276 break; | |
1277 case(CPIN_RSLT_PhNetPukReq): | |
1278 err = CME_ERR_NetworkPersPukReq; | |
1279 break; | |
1280 case(CPIN_RSLT_PhNetSubPinReq): | |
1281 err = CME_ERR_NetworkSubsetPersPinReq; | |
1282 break; | |
1283 case(CPIN_RSLT_PhNetSubPukReq): | |
1284 err = CME_ERR_NetworkSubsetPersPukReq; | |
1285 break; | |
1286 case(CPIN_RSLT_PhSPPinReq): | |
1287 err = CME_ERR_ProviderPersPinReq; | |
1288 break; | |
1289 case(CPIN_RSLT_PhSPPukReq): | |
1290 err = CME_ERR_ProviderPersPukReq; | |
1291 break; | |
1292 case(CPIN_RSLT_PhCorpPinReq): | |
1293 err = CME_ERR_CorporatePersPinReq; | |
1294 break; | |
1295 case(CPIN_RSLT_PhCorpPukReq): | |
1296 err = CME_ERR_CorporatePersPukReq; | |
1297 break; | |
1298 | |
1299 } | |
1300 } | |
1301 break; | |
1302 | |
1303 case( SS_BLKD ): | |
1304 if ( qAT_PlusCPIN(CMD_SRC_LCL, &code) EQ AT_CMPL ) | |
1305 { | |
1306 switch ( code ) | |
1307 { | |
1308 case CPIN_RSLT_SimPukReq: | |
1309 err = CME_ERR_SimPukReq; | |
1310 break; | |
1311 case CPIN_RSLT_SimPuk2Req: | |
1312 err = CME_ERR_SimPuk2Req; | |
1313 break; | |
1314 } | |
1315 } | |
1316 break; | |
1317 | |
1318 case( SS_INV ): | |
1319 err = CME_ERR_SimWrong; | |
1320 break; | |
1321 | |
1322 case( SS_URCHB ): | |
1323 err = CME_ERR_SimFail; | |
1324 break; | |
1325 | |
1326 default: /* unexpected result */ | |
1327 break; | |
1328 } | |
1329 | |
1330 if( err EQ CME_ERR_NotPresent ) | |
1331 { | |
1332 return ( AT_FAIL ); | |
1333 } | |
1334 else | |
1335 { | |
1336 TRACE_EVENT_P1("err: %d", err); | |
1337 } | |
1338 | |
1339 switch( sync_notification ) | |
1340 { | |
1341 case( GetSIMError ): | |
1342 R_AT( RAT_CME, srcBuf ) ( cmdBuf, err ); | |
1343 break; | |
1344 | |
1345 case( CheckSimStatus ): | |
1346 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, err ); | |
1347 break; | |
1348 } | |
1349 return( AT_CMPL ); | |
1350 } | |
1351 | |
1352 /* | |
1353 +--------------------------------------------------------------------+ | |
1354 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
1355 | STATE : code ROUTINE : cmhSIM_GetSIMError | | |
1356 +--------------------------------------------------------------------+ | |
1357 | |
1358 PURPOSE : This function is used to request the SIM error status. | |
1359 | |
1360 */ | |
1361 GLOBAL T_ACI_RETURN cmhSIM_GetSIMError ( T_ACI_CMD_SRC srcBuf, | |
1362 T_ACI_AT_CMD cmdBuf ) | |
1363 { | |
1364 TRACE_FUNCTION("cmhSIM_GetSIMError"); | |
1365 | |
1366 return(SimStatusError( srcBuf, cmdBuf, GetSIMError )); | |
1367 } | |
1368 | |
1369 /* | |
1370 +--------------------------------------------------------------------+ | |
1371 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
1372 | STATE : code ROUTINE : cmhSIM_GetSIMError | | |
1373 +--------------------------------------------------------------------+ | |
1374 | |
1375 PURPOSE : This function is used to check the SIM pin status. | |
1376 | |
1377 */ | |
1378 GLOBAL T_ACI_RETURN cmhSIM_CheckSimPinStatus ( T_ACI_CMD_SRC srcBuf, | |
1379 T_ACI_AT_CMD cmdBuf ) | |
1380 { | |
1381 TRACE_FUNCTION("cmhSIM_CheckSimPinStatus"); | |
1382 | |
1383 return(SimStatusError( srcBuf, cmdBuf, CheckSimStatus )); | |
1384 } | |
1385 | |
1386 /* | |
1387 +--------------------------------------------------------------------+ | |
1388 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMS | | |
1389 | STATE : code ROUTINE : cmhSIM_ReqLanguage | | |
1390 +--------------------------------------------------------------------+ | |
1391 | |
1392 PURPOSE : This function starts reading of ELP field from SIM. | |
1393 */ | |
1394 GLOBAL T_ACI_RETURN cmhSIM_ReqLanguage ( T_ACI_CMD_SRC srcId) | |
1395 | |
1396 { | |
1397 T_ACI_RETURN ret = AT_FAIL; | |
1398 SHORT table_id; | |
1399 | |
1400 TRACE_FUNCTION ("cmhSIM_ReqLanguage()"); | |
1401 | |
1402 /* | |
1403 *----------------------------------------------------------------- | |
1404 * request table id for SIM SAP access | |
1405 *----------------------------------------------------------------- | |
1406 */ | |
1407 table_id = psaSIM_atbNewEntry(); | |
1408 | |
1409 if(table_id NEQ NO_ENTRY) | |
1410 { | |
1411 simShrdPrm.atb[table_id].accType = ACT_RD_DAT; | |
1412 simShrdPrm.atb[table_id].reqDataFld = SIM_ELP; | |
1413 simShrdPrm.atb[table_id].dataOff = 0; | |
1414 /* length is variable */ | |
1415 simShrdPrm.atb[table_id].dataLen = NOT_PRESENT_8BIT; | |
1416 simShrdPrm.atb[table_id].recMax = ACI_LEN_LAN_FLD; | |
1417 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE; | |
1418 simShrdPrm.atb[table_id].exchData = CLANSimEfData; | |
1419 simShrdPrm.atb[table_id].rplyCB = cmhSIM_RdCnfLangELP; | |
1420 | |
1421 | |
1422 simShrdPrm.aId = table_id; | |
1423 | |
1424 simEntStat.curCmd = AT_CMD_CLAN; | |
1425 simEntStat.entOwn = simShrdPrm.owner = srcId; | |
1426 | |
1427 if(psaSIM_AccessSIMData() < 0) | |
1428 { | |
1429 TRACE_EVENT("FATAL ERROR psaSIM in +CLAN"); | |
1430 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal ); | |
1431 } | |
1432 else | |
1433 { | |
1434 ret = AT_EXCT; | |
1435 } | |
1436 } | |
1437 | |
1438 return ( ret ); | |
1439 } | |
1440 | |
1441 | |
1442 /* | |
1443 +-----------------------------------------------------------------------+ | |
1444 | PROJECT : MODULE : SAT | | |
1445 | STATE : code ROUTINE : cmhSIM_ReqLanguagePrf | | |
1446 +-----------------------------------------------------------------------+ | |
1447 | |
1448 PURPOSE : This function starts reading of ELP field from SIM for SAT feature LS. | |
1449 */ | |
1450 GLOBAL BOOL cmhSIM_ReqLanguagePrf(void) | |
1451 | |
1452 { | |
1453 BOOL ret = FALSE; | |
1454 SHORT table_id; | |
1455 | |
1456 TRACE_FUNCTION ("cmhSIM_ReqLanguagePrf()"); | |
1457 | |
1458 /* | |
1459 *----------------------------------------------------------------- | |
1460 * request table id for SIM SAP access | |
1461 *----------------------------------------------------------------- | |
1462 */ | |
1463 table_id = psaSIM_atbNewEntry(); | |
1464 | |
1465 if(table_id NEQ NO_ENTRY) | |
1466 { | |
1467 simShrdPrm.atb[table_id].accType = ACT_RD_DAT; | |
1468 simShrdPrm.atb[table_id].reqDataFld = SIM_ELP; | |
1469 simShrdPrm.atb[table_id].dataOff = 0; | |
1470 // length is variable | |
1471 simShrdPrm.atb[table_id].dataLen = NOT_PRESENT_8BIT; | |
1472 simShrdPrm.atb[table_id].recMax = ACI_LEN_LAN_FLD; | |
1473 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE; | |
1474 simShrdPrm.atb[table_id].exchData = CLANSimEfData; | |
1475 simShrdPrm.atb[table_id].rplyCB = cmhSIM_RdCnfLangPrfELP; | |
1476 | |
1477 | |
1478 simShrdPrm.aId = table_id; | |
1479 | |
1480 | |
1481 if(psaSIM_AccessSIMData() < 0) | |
1482 { | |
1483 return ( ret ); | |
1484 } | |
1485 else | |
1486 { | |
1487 ret = TRUE; | |
1488 } | |
1489 } | |
1490 | |
1491 return ( ret ); | |
1492 } | |
1493 | |
1494 | |
1495 | |
1496 /* | |
1497 +--------------------------------------------------------------------+ | |
1498 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
1499 | STATE : code ROUTINE : getSupLangFromPCM | | |
1500 +--------------------------------------------------------------------+ | |
1501 | |
1502 PURPOSE : get Supported Language from PCM and compare it | |
1503 with Language table. | |
1504 */ | |
1505 GLOBAL T_ACI_RETURN getSupLangFromPCM ( T_ACI_LAN_SUP *lanlst, SHORT *lastIdx) | |
1506 | |
1507 { | |
1508 CHAR *ef = EF_MSSUP_ID; | |
1509 pcm_FileInfo_Type fileInfo; | |
1510 EF_MSSUP mssup; | |
1511 LONG value; | |
1512 SHORT i, idx=0; | |
1513 LONG bitmask = 0x01; | |
1514 | |
1515 TRACE_FUNCTION ("getSupLangFromPCM()"); | |
1516 | |
1517 /* | |
1518 *------------------------------------------------------------------- | |
1519 * read supported language from ME | |
1520 *------------------------------------------------------------------- | |
1521 */if (pcm_GetFileInfo ( (UBYTE*)ef, &fileInfo) NEQ PCM_OK) | |
1522 { | |
1523 TRACE_EVENT("Error getting datas from PCM"); | |
1524 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_MemFail ); | |
1525 return( AT_FAIL ); | |
1526 } | |
1527 else | |
1528 { | |
1529 if ( pcm_ReadFile ( ( UBYTE* )ef,fileInfo.FileSize, | |
1530 ( UBYTE*) &mssup, | |
1531 &fileInfo.Version) EQ PCM_OK ) | |
1532 { | |
1533 value =mssup.lng1; | |
1534 value |=mssup.lng2 <<8; | |
1535 value |=mssup.lng3 <<16; | |
1536 | |
1537 for(i=0;i<MAX_LAN;i++) | |
1538 { | |
1539 if (bitmask & value) | |
1540 { | |
1541 lanlst[idx].lng =i; | |
1542 idx++; | |
1543 } | |
1544 | |
1545 bitmask= bitmask<< 1; | |
1546 } | |
1547 | |
1548 } | |
1549 else | |
1550 { | |
1551 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_MemFail ); | |
1552 return( AT_FAIL ); | |
1553 } | |
1554 } | |
1555 | |
1556 /* | |
1557 *------------------------------------------------------------------- | |
1558 * terminate list and set last index | |
1559 *------------------------------------------------------------------- | |
1560 */ | |
1561 if( idx < MAX_LAN ) | |
1562 { | |
1563 lanlst[idx].str = 0x0; | |
1564 lanlst[idx].lng = 0x0; | |
1565 | |
1566 } | |
1567 *lastIdx = idx; | |
1568 | |
1569 /* | |
1570 *------------------------------------------------------------------- | |
1571 * compare the code of supported language in PCM with | |
1572 * Language table to get the char code | |
1573 *------------------------------------------------------------------- | |
1574 */ | |
1575 for(i=0;i < *lastIdx;i++) | |
1576 { | |
1577 idx=0; | |
1578 while (lngs[idx].str NEQ NULL AND | |
1579 lngs[idx].lng NEQ lanlst[i].lng) | |
1580 idx++; | |
1581 | |
1582 if (lngs[idx].lng EQ lanlst[i].lng) | |
1583 lanlst[i].str=lngs[idx].str; | |
1584 } | |
1585 | |
1586 return( AT_CMPL ); | |
1587 } | |
1588 | |
1589 | |
1590 /* | |
1591 +--------------------------------------------------------------------+ | |
1592 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
1593 | STATE : code ROUTINE : checkSuppLangInELP | | |
1594 +--------------------------------------------------------------------+ | |
1595 | |
1596 PURPOSE : check if the language to be read from the EF ELP | |
1597 is supported in PCM | |
1598 | |
1599 SupLng: is true if the language is supprted else False | |
1600 */ | |
1601 | |
1602 GLOBAL BOOL checkSuppLang (T_ACI_LAN_SUP *lanlst, | |
1603 SHORT lastIdx, | |
1604 T_ACI_LAN_SUP *clng) | |
1605 { | |
1606 USHORT i; | |
1607 BOOL SupLng=FALSE; | |
1608 | |
1609 /* | |
1610 *----------------------------------------------------------------- | |
1611 * check if the Language from EF ELP is supported in PCM | |
1612 *----------------------------------------------------------------- | |
1613 */ | |
1614 for(i=0;i < lastIdx;i++) | |
1615 { | |
1616 if (!strcmp(lanlst[i].str,clng->str) ) | |
1617 { | |
1618 clng->lng=lanlst[i].lng; | |
1619 SupLng= TRUE; | |
1620 break; | |
1621 } | |
1622 } | |
1623 | |
1624 return( SupLng ); | |
1625 } | |
1626 | |
1627 /* | |
1628 +--------------------------------------------------------------------+ | |
1629 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
1630 | STATE : code ROUTINE : checkSuppLangInLP | | |
1631 +--------------------------------------------------------------------+ | |
1632 | |
1633 PURPOSE : check if the language to be read from the EF LP | |
1634 is supported in PCM | |
1635 | |
1636 SupLng: is true if the language is supprted else False | |
1637 */ | |
1638 | |
1639 GLOBAL BOOL checkSuppLangInLP(T_ACI_LAN_SUP *lanlst,SHORT lastIdx, | |
1640 T_ACI_LAN_SUP *clng) | |
1641 { | |
1642 USHORT i; | |
1643 BOOL SupLng=FALSE; | |
1644 | |
1645 /* | |
1646 *----------------------------------------------------------------- | |
1647 * check if the Language from EF LP is supported in PCM | |
1648 *----------------------------------------------------------------- | |
1649 */ | |
1650 for(i=0;i < lastIdx;i++) | |
1651 { | |
1652 if (lanlst[i].lng EQ clng->lng ) | |
1653 { | |
1654 clng->str=lanlst[i].str; | |
1655 SupLng= TRUE; | |
1656 break; | |
1657 } | |
1658 } | |
1659 | |
1660 return( SupLng ); | |
1661 } | |
1662 | |
1663 #if 0 | |
1664 /* | |
1665 +------------------------------------------------------------------------+ | |
1666 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMS | | |
1667 | STATE : code ROUTINE : cmhSIM_LanguageLP_Update| | |
1668 +------------------------------------------------------------------------+ | |
1669 | |
1670 PURPOSE : | |
1671 */ | |
1672 GLOBAL BOOL cmhSIM_LanguageLP_Update ( int ref, T_SIM_FILE_UPDATE_IND *fu) | |
1673 { | |
1674 T_ACI_CMD_SRC ownBuf; /* buffers current owner */ | |
1675 UBYTE i; | |
1676 BOOL found = FALSE; | |
1677 | |
1678 char *auptr="au"; | |
1679 CHAR *ef = EF_CLNG_ID; | |
1680 pcm_FileInfo_Type fileInfo; | |
1681 EF_CLNG lng; | |
1682 | |
1683 | |
1684 TRACE_FUNCTION ("cmhSIM_LanguageLP_Update()"); | |
1685 | |
1686 ownBuf = simEntStat.entOwn; | |
1687 | |
1688 for (i = 0; i < (int)fu->val_nr; i++) | |
1689 { | |
1690 if (!found AND | |
1691 (fu->file_id[i] EQ SIM_LP)) | |
1692 { | |
1693 found = TRUE; | |
1694 } | |
1695 } | |
1696 | |
1697 if (found) | |
1698 { | |
1699 /* | |
1700 *------------------------------------------------------------------- | |
1701 * read supported language from ME | |
1702 *------------------------------------------------------------------- | |
1703 */ | |
1704 if (pcm_GetFileInfo ( ( UBYTE* ) ef, &fileInfo) NEQ PCM_OK) | |
1705 { | |
1706 TRACE_EVENT("cmhSIM_LanguageLP_Update: error returned by pcm_GetFileInfo()" ); | |
1707 return TRUE; | |
1708 } | |
1709 else | |
1710 { | |
1711 | |
1712 if ( pcm_ReadFile ( (UBYTE*)ef, | |
1713 fileInfo.FileSize, | |
1714 (UBYTE*) &lng, | |
1715 &fileInfo.Version) EQ PCM_OK ) | |
1716 { | |
1717 } | |
1718 else | |
1719 { | |
1720 TRACE_EVENT("cmhSIM_LanguageLP_Update: error returned by pcm_ReadFile()" ); | |
1721 return TRUE; | |
1722 } | |
1723 } | |
1724 | |
1725 /* | |
1726 *------------------------------------------------------------------- | |
1727 * Read EF LP from the sim if Automatic language is selected | |
1728 *------------------------------------------------------------------- | |
1729 */ | |
1730 if (!strncmp((char*)&lng.data[0], auptr, 2)) | |
1731 { | |
1732 cmhSIM_ReqLanguageLP(ownBuf); /* reading files */ | |
1733 simShrdPrm.fuRef = (UBYTE)ref; | |
1734 return FALSE; | |
1735 } | |
1736 else | |
1737 { | |
1738 return TRUE; | |
1739 } | |
1740 } | |
1741 else | |
1742 { | |
1743 return TRUE; /* nothing to do */ | |
1744 } | |
1745 } | |
1746 #endif | |
1747 | |
1748 /* | |
1749 +--------------------------------------------------------------------+ | |
1750 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMS | | |
1751 | STATE : code ROUTINE : cmhSIM_ReqLanguageLP| | |
1752 +--------------------------------------------------------------------+ | |
1753 | |
1754 PURPOSE : This function starts reading of ELP OR LP field from SIM. | |
1755 */ | |
1756 GLOBAL T_ACI_RETURN cmhSIM_ReqLanguageLP ( T_ACI_CMD_SRC srcId ) | |
1757 { | |
1758 T_ACI_RETURN ret = AT_FAIL; | |
1759 SHORT table_id; | |
1760 | |
1761 TRACE_FUNCTION ("cmhSIM_ReqLanguageLP()"); | |
1762 | |
1763 /* | |
1764 *----------------------------------------------------------------- | |
1765 * request table id for SIM SAP access | |
1766 *----------------------------------------------------------------- | |
1767 */ | |
1768 table_id = psaSIM_atbNewEntry(); | |
1769 | |
1770 if(table_id NEQ NO_ENTRY) | |
1771 { | |
1772 simShrdPrm.atb[table_id].accType = ACT_RD_DAT; | |
1773 simShrdPrm.atb[table_id].reqDataFld = SIM_LP; | |
1774 simShrdPrm.atb[table_id].dataOff = 0; | |
1775 /* length is variable */ | |
1776 simShrdPrm.atb[table_id].dataLen = NOT_PRESENT_8BIT; | |
1777 simShrdPrm.atb[table_id].recMax = ACI_MAX_LAN_LP_NTRY; | |
1778 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE; | |
1779 simShrdPrm.atb[table_id].exchData = CLANSimEfDataLP; | |
1780 simShrdPrm.atb[table_id].rplyCB = cmhSIM_RdCnfLangLP; | |
1781 | |
1782 | |
1783 simShrdPrm.aId = table_id; | |
1784 | |
1785 simEntStat.curCmd = AT_CMD_CLAN; | |
1786 simEntStat.entOwn = simShrdPrm.owner = srcId; | |
1787 | |
1788 if(psaSIM_AccessSIMData() < 0) | |
1789 { | |
1790 TRACE_EVENT("FATAL ERROR psaSIM in +CLAN"); | |
1791 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Internal ); | |
1792 } | |
1793 else | |
1794 { | |
1795 ret = AT_EXCT; | |
1796 } | |
1797 } | |
1798 | |
1799 return ( ret ); | |
1800 } | |
1801 | |
1802 | |
1803 /* | |
1804 +-----------------------------------------------------------------------+ | |
1805 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMS | | |
1806 | STATE : code ROUTINE : cmhSIM_ReqLanguagePrfLP| | |
1807 +-----------------------------------------------------------------------+ | |
1808 | |
1809 PURPOSE : This function starts reading of LP field from SIM for SAT | |
1810 fetaure LS. | |
1811 */ | |
1812 GLOBAL BOOL cmhSIM_ReqLanguagePrfLP (void) | |
1813 { | |
1814 BOOL ret = FALSE; | |
1815 SHORT table_id; | |
1816 | |
1817 TRACE_FUNCTION ("cmhSIM_ReqLanguagePrfLP()"); | |
1818 | |
1819 /* | |
1820 *----------------------------------------------------------------- | |
1821 * request table id for SIM SAP access | |
1822 *----------------------------------------------------------------- | |
1823 */ | |
1824 table_id = psaSIM_atbNewEntry(); | |
1825 | |
1826 if(table_id NEQ NO_ENTRY) | |
1827 { | |
1828 simShrdPrm.atb[table_id].accType = ACT_RD_DAT; | |
1829 simShrdPrm.atb[table_id].reqDataFld = SIM_LP; | |
1830 simShrdPrm.atb[table_id].dataOff = 0; | |
1831 // length is variable | |
1832 simShrdPrm.atb[table_id].dataLen = NOT_PRESENT_8BIT; | |
1833 simShrdPrm.atb[table_id].recMax = ACI_MAX_LAN_LP_NTRY; | |
1834 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE; | |
1835 simShrdPrm.atb[table_id].exchData = CLANSimEfDataLP; | |
1836 simShrdPrm.atb[table_id].rplyCB = cmhSIM_RdCnfLangPrfLP; | |
1837 | |
1838 simShrdPrm.aId = table_id; | |
1839 | |
1840 | |
1841 if(psaSIM_AccessSIMData() < 0) | |
1842 { | |
1843 return ( ret ); | |
1844 } | |
1845 else | |
1846 { | |
1847 ret = TRUE; | |
1848 } | |
1849 } | |
1850 | |
1851 return ( ret ); | |
1852 } | |
1853 | |
1854 | |
1855 /* | |
1856 +--------------------------------------------------------------------+ | |
1857 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
1858 | STATE : code ROUTINE : cmhSIM_AD_Update | | |
1859 +--------------------------------------------------------------------+ | |
1860 | |
1861 PURPOSE : This function is used to request the SIM Administrative | |
1862 Data (EF_AD). | |
1863 | |
1864 */ | |
1865 GLOBAL BOOL cmhSIM_AD_Update (int ref, T_SIM_FILE_UPDATE_IND *fu) | |
1866 { | |
1867 BOOL found = FALSE; | |
1868 UBYTE i; | |
1869 TRACE_FUNCTION ("cmhSIM_AD_Update()"); | |
1870 | |
1871 for (i = 0; i < (int)fu->val_nr; i++) | |
1872 { | |
1873 if (!found AND (fu->file_id[i] EQ SIM_AD)) | |
1874 { | |
1875 found = TRUE; | |
1876 } | |
1877 } | |
1878 if (found) | |
1879 { | |
1880 cmhSIM_Read_AD(); | |
1881 simShrdPrm.fuRef = (UBYTE)ref; | |
1882 return FALSE; /* reading files */ | |
1883 } | |
1884 else | |
1885 { | |
1886 return TRUE; /* nothing to do */ | |
1887 } | |
1888 } | |
1889 | |
1890 | |
1891 /* | |
1892 +--------------------------------------------------------------------+ | |
1893 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
1894 | STATE : code ROUTINE : cmhSIM_Read_AD | | |
1895 +--------------------------------------------------------------------+ | |
1896 | |
1897 PURPOSE : This function is used to request the SIM Administrative | |
1898 Data (EF_AD). | |
1899 | |
1900 */ | |
1901 GLOBAL T_ACI_RETURN cmhSIM_Read_AD() | |
1902 { | |
1903 SHORT table_id; | |
1904 | |
1905 TRACE_FUNCTION ("cmhSIM_Read_AD()"); | |
1906 | |
1907 table_id = psaSIM_atbNewEntry(); | |
1908 | |
1909 if(table_id NEQ NO_ENTRY) | |
1910 { | |
1911 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE; | |
1912 simShrdPrm.atb[table_id].accType = ACT_RD_DAT; | |
1913 simShrdPrm.atb[table_id].reqDataFld = SIM_AD; | |
1914 simShrdPrm.atb[table_id].dataOff = 0; | |
1915 simShrdPrm.atb[table_id].dataLen = NOT_PRESENT_8BIT; | |
1916 simShrdPrm.atb[table_id].recMax = 0; | |
1917 simShrdPrm.atb[table_id].exchData = NULL; | |
1918 simShrdPrm.atb[table_id].rplyCB = cmhSIM_Read_AD_cb; | |
1919 | |
1920 simShrdPrm.aId = table_id; | |
1921 | |
1922 if(psaSIM_AccessSIMData() < 0) | |
1923 { | |
1924 TRACE_EVENT("FATAL ERROR"); | |
1925 return ( AT_FAIL ); | |
1926 } | |
1927 | |
1928 return ( AT_CMPL ); | |
1929 } | |
1930 return ( AT_FAIL ); | |
1931 } | |
1932 | |
1933 /* | |
1934 +-------------------------------------------------------------------+ | |
1935 | PROJECT : MODULE : CMH_SIMF | | |
1936 | STATE : code ROUTINE : cmhSIM_EvalMNCLength | | |
1937 +-------------------------------------------------------------------+ | |
1938 | |
1939 PURPOSE : This function evaluates the MNC length by extracting MNC | |
1940 from IMSI and comparing it with the MNC in operListFixed. | |
1941 */ | |
1942 GLOBAL UBYTE cmhSIM_EvalMNCLength(void) | |
1943 { | |
1944 UBYTE digit; /* holds 4bit digit */ | |
1945 USHORT i; /* holds counter */ | |
1946 SHORT sim_mcc; /* holds mcc from operListFixed */ | |
1947 SHORT sim_mnc; /* holds mnc from operListFixed */ | |
1948 SHORT mcc; /* holds mcc extracted from IMSI */ | |
1949 SHORT mnc; /* holds mnc extracted from IMSI */ | |
1950 | |
1951 mcc = mnc = 0; /* Initialize mcc, mnc */ | |
1952 | |
1953 for (i = 0; i < SIZE_MCC + SIZE_MNC; i++) /* Extract MCC and MNC. */ | |
1954 { | |
1955 digit = (i & 1) ? | |
1956 (simShrdPrm.imsi.field[(i + 1)/2] & 0x0f) : | |
1957 (simShrdPrm.imsi.field[(i + 1)/2] & 0xf0) >> 4; | |
1958 if (i < SIZE_MCC) | |
1959 mcc = (mcc << 4) | digit; | |
1960 else | |
1961 mnc = (mnc << 4) | digit; | |
1962 } | |
1963 | |
1964 for( i = 0; operListFixed[i].mcc NEQ -1 AND operListFixed[i].mnc NEQ -1; i++ ) /* Evaluate mnc length */ | |
1965 { | |
1966 sim_mcc = operListFixed[i].mcc; | |
1967 sim_mnc = operListFixed[i].mnc; | |
1968 | |
1969 if ( sim_mcc EQ mcc ) | |
1970 { | |
1971 if ( (sim_mnc & 0xff0) EQ (mnc & 0xff0) ) | |
1972 { | |
1973 if ( (sim_mnc & 0x0f) EQ 0x0f ) | |
1974 { | |
1975 return 2; | |
1976 } | |
1977 else | |
1978 { | |
1979 return 3; | |
1980 } | |
1981 } | |
1982 } | |
1983 } | |
1984 return NOT_PRESENT_8BIT; | |
1985 } | |
1986 | |
1987 /* | |
1988 +--------------------------------------------------------------------+ | |
1989 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
1990 | STATE : code ROUTINE : cmhSIM_Read_AD_cb | | |
1991 +--------------------------------------------------------------------+ | |
1992 | |
1993 PURPOSE : Call back for SIM read (EF_AD). | |
1994 | |
1995 */ | |
1996 void cmhSIM_Read_AD_cb(SHORT table_id) | |
1997 { | |
1998 #ifdef SIM_PERS | |
1999 T_SIMLOCK_STATUS sl_status; | |
2000 #endif | |
2001 | |
2002 | |
2003 TRACE_FUNCTION ("cmhSIM_Read_AD_cb()"); | |
2004 | |
2005 if ( simShrdPrm.atb[table_id].reqDataFld EQ SIM_AD ) | |
2006 { | |
2007 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR ) | |
2008 { | |
2009 /* | |
2010 * byte 2 and byte 3 of EF AD have only a meaning | |
2011 * if the bit1 of byte 1 is set | |
2012 */ | |
2013 if (simShrdPrm.atb[table_id].exchData[0] & 0x01) | |
2014 { | |
2015 if (simShrdPrm.atb[table_id].exchData[2] & 0x01) | |
2016 { | |
2017 /* ci enabled on SIM */ | |
2018 simShrdPrm.ciSIMEnabled = TRUE; | |
2019 } | |
2020 else | |
2021 { | |
2022 /* ci disabled on SIM, don't show indications */ | |
2023 simShrdPrm.ciSIMEnabled = FALSE; | |
2024 } | |
2025 } | |
2026 /* byte 4 is optional */ | |
2027 if (simShrdPrm.atb[table_id].dataLen >= 4) | |
2028 { | |
2029 switch (simShrdPrm.atb[table_id].exchData[3] & 0x0F) | |
2030 { | |
2031 case 2: simShrdPrm.mnc_len = 2; break; | |
2032 case 3: simShrdPrm.mnc_len = 3; break; | |
2033 default: simShrdPrm.mnc_len =NOT_PRESENT_8BIT; | |
2034 } | |
2035 } | |
2036 else | |
2037 { | |
2038 simShrdPrm.mnc_len = NOT_PRESENT_8BIT; | |
2039 } | |
2040 if (simShrdPrm.mnc_len NEQ 3) /* Update MNC length */ | |
2041 { | |
2042 simShrdPrm.mnc_len = cmhSIM_EvalMNCLength(); | |
2043 } | |
2044 | |
2045 } | |
2046 #ifdef SIM_TOOLKIT | |
2047 if (simShrdPrm.fuRef >= 0) | |
2048 { | |
2049 psaSAT_FUConfirm (simShrdPrm.fuRef, | |
2050 (USHORT)((simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR)? | |
2051 SIM_FU_SUCCESS: SIM_FU_ERROR)); | |
2052 } | |
2053 #endif | |
2054 } | |
2055 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE; | |
2056 if(last_sim_mmi_insert_ind NEQ NULL) | |
2057 { | |
2058 #ifdef SIM_PERS | |
2059 aci_slock_sim_config.sim_read_ad_first_byte = simShrdPrm.atb[table_id].exchData[0] ; | |
2060 aci_slock_sim_init(last_sim_mmi_insert_ind); | |
2061 /* To set the global variable config data */ | |
2062 aci_slock_set_CFG(); | |
2063 | |
2064 if(cfg_data EQ NULL) | |
2065 { | |
2066 AciSLockShrd.blocked = TRUE; | |
2067 cmhSIM_SIMInserted(); | |
2068 PFREE (last_sim_mmi_insert_ind); /* 11_Apr_05 */ | |
2069 last_sim_mmi_insert_ind= NULL; | |
2070 return; | |
2071 } | |
2072 aci_slock_init(); | |
2073 sl_status = SIMLOCK_ENABLED; | |
2074 AciSLockShrd.pb_load = FALSE; | |
2075 AciSLockShrd.check_lock = SIMLOCK_CHECK_PERS; | |
2076 sl_status = aci_slock_checkpersonalisation(SIMLOCK_NETWORK); | |
2077 | |
2078 #else | |
2079 /* | |
2080 * Start to build phonebook | |
2081 */ | |
2082 pb_reset(); | |
2083 | |
2084 #ifdef TI_PS_FFS_PHB | |
2085 pb_inserted_sim (MAX_SRV_TBL, | |
2086 last_sim_mmi_insert_ind->sim_serv, | |
2087 &last_sim_mmi_insert_ind->imsi_field, | |
2088 last_sim_mmi_insert_ind->func, | |
2089 last_sim_mmi_insert_ind->phase); | |
2090 #else | |
2091 pb_build_req(last_sim_mmi_insert_ind); | |
2092 #endif | |
2093 | |
2094 /* Request the Customer Service Profile from the SIM (EF_CPHS_CSP) */ | |
2095 cmhSIM_Get_CSP(); | |
2096 | |
2097 #ifdef SIM_TOOLKIT | |
2098 cmhSMS_ReadCbDtaDwnl (last_sim_mmi_insert_ind); | |
2099 #endif | |
2100 | |
2101 #ifdef FF_MMI_RIV | |
2102 rAT_PlusCFUNP (last_sim_mmi_insert_ind); | |
2103 #endif /* FF_MMI_RIV */ | |
2104 PFREE (last_sim_mmi_insert_ind); /* 11_Apr_05 */ | |
2105 last_sim_mmi_insert_ind= NULL; | |
2106 | |
2107 cmhSIM_SIMInserted(); | |
2108 #endif | |
2109 } | |
2110 | |
2111 } | |
2112 | |
2113 /* | |
2114 +--------------------------------------------------------------------+ | |
2115 | PROJECT : EONS MODULE : CMH_SIMF | | |
2116 | STATE : code ROUTINE : cmhSIM_OpUpdate | | |
2117 +--------------------------------------------------------------------+ | |
2118 | |
2119 PURPOSE : This function will be used to process the update of EFopl and EFpnn. | |
2120 | |
2121 */ | |
2122 GLOBAL BOOL cmhSIM_OpUpdate (int ref, T_SIM_FILE_UPDATE_IND *fu) | |
2123 { | |
2124 UBYTE i; | |
2125 BOOL ps_is_not_reading_files_1 = FALSE, | |
2126 ps_is_not_reading_files_2 = FALSE; | |
2127 | |
2128 TRACE_FUNCTION ("cmhSIM_OpUpdate()"); | |
2129 | |
2130 for (i = 0; i < (int)fu->val_nr; i++) | |
2131 { | |
2132 switch(fu->file_id[i]) | |
2133 { | |
2134 case SIM_OPL: | |
2135 TRACE_EVENT("EF_OPL has been updated "); | |
2136 ps_is_not_reading_files_1 = cmhSIM_UpdateOperatorName(SIM_OPL); | |
2137 /*lint -fallthrough */ | |
2138 | |
2139 case SIM_PNN: | |
2140 if(fu->file_id[i] NEQ SIM_OPL) | |
2141 { | |
2142 TRACE_EVENT("EF_PNN has been updated "); | |
2143 } | |
2144 ps_is_not_reading_files_2 = !cmhMM_OpUpdateName(); | |
2145 cmhMM_Registered(); | |
2146 simShrdPrm.fuRef = (UBYTE)ref; | |
2147 if(ps_is_not_reading_files_1 OR | |
2148 ps_is_not_reading_files_2) | |
2149 return(TRUE); | |
2150 | |
2151 return(FALSE); /* reading files ? */ | |
2152 | |
2153 default: | |
2154 break; | |
2155 } | |
2156 } | |
2157 return(TRUE); /* nothing to do */ | |
2158 } | |
2159 | |
2160 | |
2161 /* | |
2162 +-------------------------------------------------------------------+ | |
2163 | PROJECT : EONS MODULE : CMH_SIMF | | |
2164 | STATE : code ROUTINE : cmhSIM_OpReadOplRcd | | |
2165 +-------------------------------------------------------------------+ | |
2166 | |
2167 PURPOSE : Sends a SIM read request | |
2168 */ | |
2169 | |
2170 GLOBAL BOOL cmhSIM_OpReadOplRcd(UBYTE rcd) | |
2171 { | |
2172 SHORT table_id; | |
2173 | |
2174 TRACE_FUNCTION ("cmhSIM_OpReadOplRcd()"); | |
2175 | |
2176 table_id = psaSIM_atbNewEntry(); | |
2177 | |
2178 if(table_id NEQ NO_ENTRY) | |
2179 { | |
2180 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE; | |
2181 simShrdPrm.atb[table_id].accType = ACT_RD_REC; | |
2182 simShrdPrm.atb[table_id].reqDataFld = SIM_OPL; | |
2183 simShrdPrm.atb[table_id].dataOff = 0; | |
2184 simShrdPrm.atb[table_id].recNr = rcd; | |
2185 simShrdPrm.atb[table_id].recMax = 0; | |
2186 simShrdPrm.atb[table_id].exchData = NULL; | |
2187 simShrdPrm.atb[table_id].dataLen = NOT_PRESENT_8BIT; | |
2188 simShrdPrm.atb[table_id].rplyCB = cmhSIM_OpReadOplRcdCb; | |
2189 | |
2190 simShrdPrm.aId = table_id; | |
2191 | |
2192 if(psaSIM_AccessSIMData() < 0) | |
2193 { | |
2194 TRACE_EVENT("FATAL ERROR"); | |
2195 return FALSE; | |
2196 } | |
2197 | |
2198 return TRUE; | |
2199 } | |
2200 return TRUE; | |
2201 } | |
2202 | |
2203 | |
2204 /* | |
2205 +-------------------------------------------------------------------+ | |
2206 | PROJECT : EONS MODULE : CMH_SIMF | | |
2207 | STATE : code ROUTINE : cmhSIM_OpReadPnnRcd | | |
2208 +-------------------------------------------------------------------+ | |
2209 | |
2210 PURPOSE : Sends a SIM read request | |
2211 */ | |
2212 GLOBAL BOOL cmhSIM_OpReadPnnRcd(UBYTE rcd) | |
2213 { | |
2214 SHORT table_id; | |
2215 | |
2216 TRACE_FUNCTION ("cmhSIM_OpReadPnnRcd()"); | |
2217 | |
2218 table_id = psaSIM_atbNewEntry(); | |
2219 | |
2220 if(table_id NEQ NO_ENTRY) | |
2221 { | |
2222 simShrdPrm.atb[table_id].ntryUsdFlg = TRUE; | |
2223 simShrdPrm.atb[table_id].accType = ACT_RD_REC; | |
2224 simShrdPrm.atb[table_id].reqDataFld = SIM_PNN; | |
2225 simShrdPrm.atb[table_id].dataOff = 0; | |
2226 simShrdPrm.atb[table_id].recNr = rcd; | |
2227 simShrdPrm.atb[table_id].recMax = 0; | |
2228 simShrdPrm.atb[table_id].exchData = NULL; | |
2229 simShrdPrm.atb[table_id].dataLen = NOT_PRESENT_8BIT; | |
2230 simShrdPrm.atb[table_id].rplyCB = cmhSIM_OpReadPnnRcdCb; | |
2231 | |
2232 simShrdPrm.aId = table_id; | |
2233 | |
2234 if(psaSIM_AccessSIMData() < 0) | |
2235 { | |
2236 TRACE_EVENT("FATAL ERROR"); | |
2237 return FALSE; | |
2238 } | |
2239 | |
2240 return TRUE; | |
2241 } | |
2242 return TRUE; | |
2243 } | |
2244 | |
2245 | |
2246 /* | |
2247 +-------------------------------------------------------------------+ | |
2248 | PROJECT : EONS MODULE : CMH_SIMF | | |
2249 | STATE : code ROUTINE : cmhSIM_BuildOPLList | | |
2250 +-------------------------------------------------------------------+ | |
2251 | |
2252 PURPOSE : | |
2253 */ | |
2254 LOCAL void cmhSIM_BuildOPLList(SHORT table_id) | |
2255 { | |
2256 UBYTE *data = simShrdPrm.atb[table_id].exchData; | |
2257 T_opl *opl_entry = &simShrdPrm.opl_list.opl_rcd[simShrdPrm.opl_list.num_rcd]; | |
2258 | |
2259 /* Test if record is valid */ | |
2260 /* opl_entry->plmn.v_plmn = (data[0] EQ 0xFF) ? INVLD_PLMN : VLD_PLMN; */ | |
2261 | |
2262 /* Copy MCC and MNC from SIM data to OPL list */ | |
2263 memcpy (opl_entry->plmn, data, UBYTES_PER_PLMN); | |
2264 | |
2265 /* Extract LAC from SIM data and copy to OPL list*/ | |
2266 opl_entry->lac1 = data[3] << 8 | data[4]; | |
2267 opl_entry->lac2 = data[5] << 8 | data[6]; | |
2268 | |
2269 /* Extract PNN record number from SIM data and copy to OPL list*/ | |
2270 opl_entry->pnn_rec_num = data[7]; | |
2271 } | |
2272 | |
2273 | |
2274 /* | |
2275 +-------------------------------------------------------------------+ | |
2276 | PROJECT : EONS MODULE : CMH_SIMF | | |
2277 | STATE : code ROUTINE : cmhSIM_OpReadOplRcdCb | | |
2278 +-------------------------------------------------------------------+ | |
2279 | |
2280 PURPOSE : Call back for SIM retrieval of EF_OPL. | |
2281 */ | |
2282 GLOBAL void cmhSIM_OpReadOplRcdCb(SHORT table_id) | |
2283 { | |
2284 TRACE_FUNCTION("cmhSIM_OpReadOplRcdCb"); | |
2285 | |
2286 /* Decode and copy OPL record data to OPL list*/ | |
2287 /*------------------------------------------*/ | |
2288 if(simShrdPrm.atb[table_id].dataLen AND simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR) | |
2289 { | |
2290 cmhSIM_BuildOPLList(table_id); | |
2291 | |
2292 simShrdPrm.opl_list.opl_status = TRUE; | |
2293 /* | |
2294 if ((memcmp (simShrdPrm.opl_list.opl_rcd[simShrdPrm.opl_list.num_rcd].plmn, | |
2295 PLMNselEmpty, | |
2296 UBYTES_PER_PLMN) NEQ 0)) | |
2297 { | |
2298 cmhSIM_OpReadPnnRcd(simShrdPrm.opl_list.opl_rcd[simShrdPrm.opl_list.num_rcd].pnn_rec_num); | |
2299 } | |
2300 */ | |
2301 } | |
2302 else | |
2303 { | |
2304 TRACE_EVENT("Empty OPL record"); | |
2305 } | |
2306 | |
2307 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE; | |
2308 | |
2309 | |
2310 /* If not last EF_OPL reoord retrieve next record*/ | |
2311 /*------------------------------------------*/ | |
2312 simShrdPrm.atb[table_id].recNr++; | |
2313 simShrdPrm.opl_list.num_rcd++; | |
2314 | |
2315 if(simShrdPrm.opl_list.num_rcd > OPL_MAX_RECORDS) | |
2316 { | |
2317 TRACE_EVENT("Max OPL records reached"); | |
2318 } | |
2319 else if(simShrdPrm.atb[table_id].recNr <= simShrdPrm.atb[table_id].recMax ) | |
2320 { | |
2321 TRACE_EVENT_P1("Read next OPL record: %d",simShrdPrm.atb[table_id].recNr); | |
2322 cmhSIM_OpReadOplRcd(simShrdPrm.atb[table_id].recNr); | |
2323 return; | |
2324 } | |
2325 | |
2326 TRACE_EVENT("Retrieval of OPL records finished"); | |
2327 /* continue with next one */ | |
2328 cmhSIM_StartOperatorName(); | |
2329 } | |
2330 | |
2331 | |
2332 | |
2333 /* | |
2334 +-------------------------------------------------------------------+ | |
2335 | PROJECT : EONS MODULE : CMH_SIMF | | |
2336 | STATE : code ROUTINE : cmhSIM_BuildPnnList | | |
2337 +-------------------------------------------------------------------+ | |
2338 | |
2339 PURPOSE : decodes EF_PNN record read from SIM | |
2340 */ | |
2341 LOCAL void cmhSIM_BuildPnnList(SHORT table_id) | |
2342 { | |
2343 UBYTE *data = simShrdPrm.atb[table_id].exchData; | |
2344 T_pnn *pnn_entry = &simShrdPrm.pnn_list.pnn_rcd[simShrdPrm.pnn_list.num_rcd]; | |
2345 | |
2346 if (*data++ EQ PNN_LONG_NAME_IEI) | |
2347 { | |
2348 pnn_entry->v_plmn = TRUE; | |
2349 | |
2350 pnn_entry->long_len = (*data++)-1; /* adjust dcs */ | |
2351 pnn_entry->long_ext_dcs = *data++; | |
2352 memcpy(pnn_entry->long_name, | |
2353 data, | |
2354 MINIMUM(pnn_entry->long_len, sizeof(pnn_entry->long_name))); | |
2355 data += pnn_entry->long_len; | |
2356 | |
2357 /*----- IEI PNN short name ------*/ | |
2358 if (*data++ EQ PNN_SHORT_NAME_IEI) | |
2359 { | |
2360 pnn_entry->shrt_len = (*data++)-1; /* adjust dcs */ | |
2361 pnn_entry->shrt_ext_dcs = *data++; | |
2362 memcpy(pnn_entry->shrt_name, | |
2363 data, | |
2364 MINIMUM(pnn_entry->shrt_len, sizeof(pnn_entry->shrt_name))); | |
2365 } | |
2366 else | |
2367 { | |
2368 pnn_entry->shrt_len = 0; | |
2369 } | |
2370 } | |
2371 else | |
2372 { | |
2373 /* marc record as unused */ | |
2374 pnn_entry->v_plmn = FALSE; | |
2375 pnn_entry->long_len = pnn_entry->shrt_len = 0; | |
2376 } | |
2377 | |
2378 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE; | |
2379 } | |
2380 | |
2381 | |
2382 /* | |
2383 +-------------------------------------------------------------------+ | |
2384 | PROJECT : EONS MODULE : CMH_SIMF | | |
2385 | STATE : code ROUTINE : cmhSIM_OpReadPnnRcdCb | | |
2386 +-------------------------------------------------------------------+ | |
2387 | |
2388 PURPOSE : Call back for SIM retrieval of EF_PNN. | |
2389 */ | |
2390 GLOBAL void cmhSIM_OpReadPnnRcdCb(SHORT table_id) | |
2391 { | |
2392 | |
2393 TRACE_FUNCTION("cmhSIM_OpReadPnnRcdCb"); | |
2394 | |
2395 /* Decode and copy PNN record data to PNN list*/ | |
2396 /*------------------------------------------*/ | |
2397 if(simShrdPrm.atb[table_id].dataLen AND simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR ) | |
2398 { | |
2399 cmhSIM_BuildPnnList(table_id); | |
2400 simShrdPrm.pnn_list.pnn_status = TRUE; | |
2401 } | |
2402 else | |
2403 { | |
2404 TRACE_EVENT("Empty PNN record"); | |
2405 } | |
2406 | |
2407 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE; | |
2408 | |
2409 | |
2410 /* If not last EF_PNN reoord retrieve next record*/ | |
2411 /*------------------------------------------*/ | |
2412 simShrdPrm.atb[table_id].recNr++; | |
2413 simShrdPrm.pnn_list.num_rcd++; | |
2414 | |
2415 if(simShrdPrm.pnn_list.num_rcd > PNN_MAX_RECORDS) | |
2416 { | |
2417 TRACE_EVENT("Max OPL records reached"); | |
2418 } | |
2419 else if(simShrdPrm.atb[table_id].recNr <= simShrdPrm.atb[table_id].recMax ) | |
2420 { | |
2421 TRACE_EVENT_P1("Read next PNN record: %d",simShrdPrm.atb[table_id].recNr); | |
2422 cmhSIM_OpReadPnnRcd(simShrdPrm.atb[table_id].recNr); | |
2423 return; | |
2424 } | |
2425 | |
2426 TRACE_EVENT("Retrieval of PNN records finished"); | |
2427 | |
2428 /* continue with next one */ | |
2429 cmhSIM_StartOperatorName(); | |
2430 } | |
2431 | |
2432 | |
2433 /* | |
2434 +-------------------------------------------------------------------+ | |
2435 | PROJECT : EONS MODULE : CMH_SIMF | | |
2436 | STATE : code ROUTINE : cmhSIM_StartOperatorName | | |
2437 +-------------------------------------------------------------------+ | |
2438 | |
2439 PURPOSE : Start retireval of EF_OPL from SIM | |
2440 */ | |
2441 GLOBAL BOOL cmhSIM_StartOperatorName() | |
2442 { | |
2443 TRACE_FUNCTION ("cmhSIM_StartOperatorName()"); | |
2444 | |
2445 /* If EF_PNN and/or EF_OPL are allocated then start retrieval of from EF_OPL */ | |
2446 if (simShrdPrm.opl_list.num_rcd EQ 0 AND psaSIM_ChkSIMSrvSup(SRV_PNN) AND psaSIM_ChkSIMSrvSup(SRV_OPL)) | |
2447 { | |
2448 TRACE_EVENT (" start reading SIM_OPL"); | |
2449 return(!cmhSIM_OpReadOplRcd(1)); | |
2450 } | |
2451 | |
2452 if (simShrdPrm.pnn_list.num_rcd EQ 0 AND psaSIM_ChkSIMSrvSup(SRV_PNN)) | |
2453 { | |
2454 TRACE_EVENT (" start reading SIM_PNN"); | |
2455 return(!cmhSIM_OpReadPnnRcd(1)); | |
2456 } | |
2457 | |
2458 TRACE_EVENT (" reading finished!"); | |
2459 | |
2460 if(psaSIM_ChkSIMSrvSup(SRV_PNN)) | |
2461 { | |
2462 if (simShrdPrm.pnn_list.pnn_status EQ TRUE) | |
2463 { | |
2464 percentCSTAT_indication(STATE_MSG_EONS, ENTITY_STATUS_Ready); | |
2465 } | |
2466 else if (psaSIM_ChkSIMSrvSup(SRV_OPL) AND simShrdPrm.opl_list.opl_status EQ TRUE) | |
2467 { | |
2468 percentCSTAT_indication(STATE_MSG_EONS, ENTITY_STATUS_Ready); | |
2469 } | |
2470 else | |
2471 { | |
2472 percentCSTAT_indication(STATE_MSG_EONS, ENTITY_STATUS_NotReady); | |
2473 } | |
2474 } | |
2475 else | |
2476 { | |
2477 percentCSTAT_indication(STATE_MSG_EONS, ENTITY_STATUS_NotReady); | |
2478 } | |
2479 | |
2480 | |
2481 | |
2482 if (mmShrdPrm.regStat EQ RS_FULL_SRV) | |
2483 { | |
2484 cmhMM_Registered(); | |
2485 } | |
2486 | |
2487 return(TRUE); | |
2488 } | |
2489 | |
2490 | |
2491 /* | |
2492 +-------------------------------------------------------------------+ | |
2493 | PROJECT : EONS MODULE : CMH_SIMF | | |
2494 | STATE : code ROUTINE : cmhSIM_UpdateOperatorName | | |
2495 +-------------------------------------------------------------------+ | |
2496 | |
2497 PURPOSE : Start File Update of EF_OPL from SIM | |
2498 */ | |
2499 GLOBAL BOOL cmhSIM_UpdateOperatorName(USHORT reqDataFld) | |
2500 { | |
2501 int i; | |
2502 TRACE_FUNCTION ("cmhSIM_UpdateOperatorName()"); | |
2503 | |
2504 if (reqDataFld EQ SIM_OPL OR reqDataFld EQ NOT_PRESENT_16BIT) | |
2505 { | |
2506 simShrdPrm.opl_list.num_rcd = 0; | |
2507 for (i=0; i<OPL_MAX_RECORDS; i++) | |
2508 { | |
2509 memcpy (simShrdPrm.opl_list.opl_rcd[i].plmn, | |
2510 PLMNselEmpty, | |
2511 UBYTES_PER_PLMN); | |
2512 } | |
2513 } | |
2514 | |
2515 if (reqDataFld EQ SIM_PNN OR reqDataFld EQ NOT_PRESENT_16BIT) | |
2516 { | |
2517 simShrdPrm.pnn_list.num_rcd = 0; | |
2518 for (i=0; i<PNN_MAX_RECORDS; i++) | |
2519 { | |
2520 simShrdPrm.pnn_list.pnn_rcd[i].v_plmn=FALSE; | |
2521 } | |
2522 } | |
2523 | |
2524 return (!cmhSIM_StartOperatorName()); | |
2525 } | |
2526 | |
2527 | |
2528 GLOBAL T_opl_field* cmhSIM_GetOPL() | |
2529 { | |
2530 return &simShrdPrm.opl_list; | |
2531 } | |
2532 | |
2533 /* | |
2534 +--------------------------------------------------------------------+ | |
2535 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
2536 | STATE : code ROUTINE : cmhSIM_Read_AD | | |
2537 +--------------------------------------------------------------------+ | |
2538 | |
2539 PURPOSE : This function returns the current PLMN mode bit value | |
2540 | |
2541 */ | |
2542 GLOBAL UBYTE cmhSIM_isplmnmodebit_set() | |
2543 { | |
2544 return simShrdPrm.PLMN_Mode_Bit; | |
2545 } | |
2546 /* | |
2547 +--------------------------------------------------------------------+ | |
2548 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
2549 | STATE : code ROUTINE : cmhSIM_ONS_Update | | |
2550 +--------------------------------------------------------------------+ | |
2551 | |
2552 PURPOSE : This function is used to Read the CPHS ONS file EF_ONS. | |
2553 | |
2554 */ | |
2555 | |
2556 GLOBAL BOOL cmhSIM_ONS_Update (int ref, T_SIM_FILE_UPDATE_IND *fu) | |
2557 { | |
2558 BOOL found = FALSE; | |
2559 UBYTE i; | |
2560 TRACE_FUNCTION ("cmhSIM_ONS_Update()"); | |
2561 | |
2562 for (i = 0; i < (int)fu->val_nr; i++) | |
2563 { | |
2564 if (fu->file_id[i] EQ SIM_CPHS_ONSTR) | |
2565 { | |
2566 found = TRUE; | |
2567 break; | |
2568 } | |
2569 } | |
2570 if (found) | |
2571 { | |
2572 cmhMM_ONSReadName(); | |
2573 simShrdPrm.fuRef = (UBYTE)ref; | |
2574 return FALSE; /* reading files */ | |
2575 } | |
2576 else | |
2577 { | |
2578 return TRUE; /* nothing to do */ | |
2579 } | |
2580 } | |
2581 | |
2582 /* | |
2583 +--------------------------------------------------------------------+ | |
2584 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
2585 | STATE : code ROUTINE : cmhSIM_Get_CSP | | |
2586 +--------------------------------------------------------------------+ | |
2587 | |
2588 PURPOSE : This function is used to request the SIM CPHS file | |
2589 | |
2590 */ | |
2591 GLOBAL void cmhSIM_Get_CSP() | |
2592 { | |
2593 | |
2594 TRACE_FUNCTION ("cmhSIM_Get_CSP()"); | |
2595 | |
2596 cmhSIM_ReadTranspEF( CMD_SRC_NONE, | |
2597 AT_CMD_NONE, | |
2598 SIM_CPHS_CINF, | |
2599 0, | |
2600 ACI_CPHS_INFO_SIZE, | |
2601 NULL, | |
2602 cmhSIM_Get_CSP_cb ); | |
2603 | |
2604 } | |
2605 | |
2606 | |
2607 /* | |
2608 +--------------------------------------------------------------------+ | |
2609 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
2610 | STATE : code ROUTINE : cmhSIM_Get_CSP_cb | | |
2611 +--------------------------------------------------------------------+ | |
2612 | |
2613 PURPOSE : Call back for SIM read for CPHS. | |
2614 | |
2615 */ | |
2616 void cmhSIM_Get_CSP_cb(SHORT table_id) | |
2617 { | |
2618 | |
2619 TRACE_FUNCTION ("cmhSIM_Get_CSP_cb()"); | |
2620 | |
2621 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE; | |
2622 | |
2623 /* Step #1: Reading of CPHS Info */ | |
2624 if (simShrdPrm.atb[table_id].errCode NEQ SIM_NO_ERROR OR | |
2625 simShrdPrm.atb[table_id].exchData EQ NULL OR | |
2626 simShrdPrm.atb[table_id].dataLen < ACI_CPHS_INFO_SIZE ) | |
2627 { | |
2628 ; /* CPHS info not supported or invalid */ | |
2629 } | |
2630 else if ((simShrdPrm.atb[table_id].exchData[1] & 0x03) EQ ALLOCATED_AND_ACTIVATED) | |
2631 { | |
2632 /* continue with reading of CSP file */ | |
2633 cmhSIM_Read_CSP(); | |
2634 return; | |
2635 } | |
2636 | |
2637 } | |
2638 | |
2639 /* | |
2640 +--------------------------------------------------------------------+ | |
2641 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
2642 | STATE : code ROUTINE : cmhSIM_AD_Update | | |
2643 +--------------------------------------------------------------------+ | |
2644 | |
2645 PURPOSE : This function is used to request the SIM Customer Service Profile (EF_CPHS_CSP). | |
2646 | |
2647 */ | |
2648 GLOBAL BOOL cmhSIM_CSP_Update (int ref, T_SIM_FILE_UPDATE_IND *fu) | |
2649 { | |
2650 BOOL found = FALSE; | |
2651 UBYTE i; | |
2652 TRACE_FUNCTION ("cmhSIM_CSP_Update()"); | |
2653 | |
2654 for (i = 0; i < (int)fu->val_nr; i++) | |
2655 { | |
2656 if (!found AND (fu->file_id[i] EQ SIM_CPHS_CSP)) | |
2657 { | |
2658 found = TRUE; | |
2659 } | |
2660 } | |
2661 if (found) | |
2662 { | |
2663 cmhSIM_Read_CSP(); | |
2664 simShrdPrm.fuRef = (UBYTE)ref; | |
2665 return FALSE; /* reading files */ | |
2666 } | |
2667 else | |
2668 { | |
2669 return TRUE; /* nothing to do */ | |
2670 } | |
2671 } | |
2672 | |
2673 /* | |
2674 +--------------------------------------------------------------------+ | |
2675 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
2676 | STATE : code ROUTINE : cmhSIM_Read_CSP | | |
2677 +--------------------------------------------------------------------+ | |
2678 | |
2679 PURPOSE : This function is used to request the SIM Customer Service Profile | |
2680 (EF_CSP). | |
2681 | |
2682 */ | |
2683 GLOBAL void cmhSIM_Read_CSP() | |
2684 { | |
2685 | |
2686 TRACE_FUNCTION ("cmhSIM_Read_CSP()"); | |
2687 | |
2688 cmhSIM_ReadTranspEF( CMD_SRC_NONE, | |
2689 AT_CMD_NONE, | |
2690 SIM_CPHS_CSP, | |
2691 0, | |
2692 0, | |
2693 NULL, | |
2694 cmhSIM_Read_CSP_cb ); | |
2695 | |
2696 } | |
2697 | |
2698 | |
2699 /* | |
2700 +--------------------------------------------------------------------+ | |
2701 | PROJECT : GSM-F&D (8411) MODULE : CMH_SIMF | | |
2702 | STATE : code ROUTINE : cmhSIM_Read_CSP_cb | | |
2703 +--------------------------------------------------------------------+ | |
2704 | |
2705 PURPOSE : Call back for SIM read (EF_CSP). | |
2706 | |
2707 */ | |
2708 void cmhSIM_Read_CSP_cb(SHORT table_id) | |
2709 { | |
2710 | |
2711 TRACE_FUNCTION ("cmhSIM_Read_CSP_cb()"); | |
2712 | |
2713 if ( simShrdPrm.atb[table_id].reqDataFld EQ SIM_CPHS_CSP ) | |
2714 { | |
2715 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR ) | |
2716 { | |
2717 if(simShrdPrm.atb[table_id].dataLen >= ACI_CPHS_CSP_SIZE) | |
2718 { | |
2719 USHORT idx; | |
2720 for(idx=0; idx < simShrdPrm.atb[table_id].dataLen; idx = idx+2) | |
2721 { | |
2722 if(simShrdPrm.atb[table_id].exchData[idx] EQ VAS_SERVICE_GROUP_CODE) | |
2723 { | |
2724 if(simShrdPrm.atb[table_id].exchData[idx+1] & PLMN_MODE_BIT_ON) | |
2725 { | |
2726 simShrdPrm.PLMN_Mode_Bit = CPHS_CSP_PLMN_MODE_BIT_ON; | |
2727 } | |
2728 else | |
2729 { | |
2730 simShrdPrm.PLMN_Mode_Bit = CPHS_CSP_PLMN_MODE_BIT_OFF; | |
2731 } | |
2732 break; | |
2733 } | |
2734 } | |
2735 } | |
2736 } | |
2737 | |
2738 #ifdef SIM_TOOLKIT | |
2739 if (simShrdPrm.fuRef >= 0) | |
2740 { | |
2741 psaSAT_FUConfirm (simShrdPrm.fuRef, | |
2742 (USHORT)((simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR)? | |
2743 SIM_FU_SUCCESS: SIM_FU_ERROR)); | |
2744 } | |
2745 #endif | |
2746 } | |
2747 simShrdPrm.atb[table_id].ntryUsdFlg = FALSE; | |
2748 } | |
2749 | |
2750 | |
2751 #ifdef SIM_PERS_OTA | |
2752 | |
2753 /* | |
2754 +------------------------------------------------------------------------------ | |
2755 | Function : cmhSIM_Register_Read_DCK | |
2756 +------------------------------------------------------------------------------ | |
2757 | Description : This function is used to request the SIM De-personalization Control Keys | |
2758 | (EF_DCK) | |
2759 | Parameters : ref - Reference for file update | |
2760 | *fu - Pointer to T_SIM_FILE_UPDATE_IND | |
2761 | | |
2762 | Return : TRUE if no files left to read, | |
2763 | FALSE if some files are there to read | |
2764 | | |
2765 +------------------------------------------------------------------------------ | |
2766 */ | |
2767 | |
2768 GLOBAL BOOL cmhSIM_Register_Read_DCK (int ref, T_SIM_FILE_UPDATE_IND *fu) | |
2769 { | |
2770 BOOL found = FALSE; | |
2771 UBYTE i; | |
2772 | |
2773 TRACE_FUNCTION ("cmhSIM_Register_Read_DCK()"); | |
2774 | |
2775 for (i = 0; i < (int)fu->val_nr AND (fu->file_id[i] NEQ SIM_DCK); i++) | |
2776 { | |
2777 } | |
2778 | |
2779 if (i NEQ (int)fu->val_nr ) | |
2780 { | |
2781 | |
2782 if (psaSIM_ChkSIMSrvSup(SRV_DePersCK)) | |
2783 { | |
2784 TRACE_FUNCTION("SRV_DePersCK supported."); | |
2785 cmhSIM_ReadTranspEF( CMD_SRC_NONE, | |
2786 AT_CMD_NONE, | |
2787 SIM_DCK, | |
2788 0, | |
2789 16, | |
2790 NULL, | |
2791 cmhSIM_Read_DCK_cb ); | |
2792 } | |
2793 | |
2794 simShrdPrm.fuRef = (UBYTE)ref; | |
2795 return FALSE; /* reading files */ | |
2796 } | |
2797 else | |
2798 { | |
2799 return TRUE; /* nothing to do */ | |
2800 } | |
2801 } | |
2802 | |
2803 | |
2804 | |
2805 | |
2806 /* | |
2807 +------------------------------------------------------------------------------ | |
2808 | Function : cmhSIM_Read_DCK_cb | |
2809 +------------------------------------------------------------------------------ | |
2810 | Description : Call back for SIM read (EF_DCK). | |
2811 | Parameters : SHORT table_id | |
2812 | | |
2813 | Return : void | |
2814 | | |
2815 +------------------------------------------------------------------------------ | |
2816 */ | |
2817 void cmhSIM_Read_DCK_cb(SHORT table_id) | |
2818 { | |
2819 TRACE_FUNCTION ("cmhSIM_Read_DCK_cb()"); | |
2820 | |
2821 if ( simShrdPrm.atb[table_id].reqDataFld EQ SIM_DCK ) | |
2822 { | |
2823 if ( simShrdPrm.atb[table_id].errCode EQ SIM_NO_ERROR ) | |
2824 { | |
2825 aci_slock_psaSIM_decodeIMSI_without_parity (&simShrdPrm.atb[table_id].exchData[0], 8, (char *) nw_ctrl_key); | |
2826 aci_slock_psaSIM_decodeIMSI_without_parity (&simShrdPrm.atb[table_id].exchData[4], 8, (char *) nw_subset_ctrl_key); | |
2827 aci_slock_psaSIM_decodeIMSI_without_parity (&simShrdPrm.atb[table_id].exchData[8], 8, (char *) sp_ctrl_key); | |
2828 aci_slock_psaSIM_decodeIMSI_without_parity (&simShrdPrm.atb[table_id].exchData[12], 8, (char *) corp_ctrl_key); | |
2829 | |
2830 aci_slock_unlock(SIMLOCK_NETWORK, (char *) nw_ctrl_key); | |
2831 aci_slock_unlock(SIMLOCK_NETWORK_SUBSET, (char *) nw_subset_ctrl_key); | |
2832 aci_slock_unlock(SIMLOCK_SERVICE_PROVIDER, (char *) sp_ctrl_key); | |
2833 aci_slock_unlock(SIMLOCK_CORPORATE, (char *) corp_ctrl_key); | |
2834 cmhSIM_WriteDefaultValue_DCK(); | |
2835 } | |
2836 } | |
2837 } | |
2838 | |
2839 | |
2840 /* | |
2841 +------------------------------------------------------------------------------ | |
2842 | Function : cmhSIM_WriteDefaultValue_DCK | |
2843 +------------------------------------------------------------------------------ | |
2844 | Description : This function is used to write back the SIM De-personalization Control Keys | |
2845 | (EF_DCK) read during init after depersonalizing the ME | |
2846 | | |
2847 | Parameters : none | |
2848 | | |
2849 | Return : void | |
2850 | | |
2851 +------------------------------------------------------------------------------ | |
2852 */ | |
2853 GLOBAL void cmhSIM_WriteDefaultValue_DCK() | |
2854 { | |
2855 UBYTE all_keys[MAX_DCK_LEN]; | |
2856 | |
2857 TRACE_FUNCTION ("cmhSIM_WriteDefaultValue_DCK()"); | |
2858 memset(all_keys,NOT_PRESENT_8BIT,MAX_DCK_LEN); | |
2859 cmhSIM_WriteTranspEF( CMD_SRC_NONE, | |
2860 AT_CMD_NONE, | |
2861 SIM_DCK, | |
2862 0, | |
2863 MAX_DCK_LEN, | |
2864 all_keys , | |
2865 NULL ); | |
2866 } | |
2867 | |
2868 | |
2869 #endif //SIM_PERS_OTA | |
2870 /*==== EOF ========================================================*/ | |
2871 |