comparison g23m-aci/aci/cmh_simf.c @ 0:75a11d740a02

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