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

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