yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2009 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /******************************************************************************* |
| 37 | * Filename: |
| 38 | * --------- |
| 39 | * custom_ecc.c |
| 40 | * |
| 41 | * Project: |
| 42 | * -------- |
| 43 | * MAUI |
| 44 | * |
| 45 | * Description: |
| 46 | * ------------ |
| 47 | * This file contains ECC function. |
| 48 | * |
| 49 | * Author: |
| 50 | * ------- |
| 51 | * ------- |
| 52 | * |
| 53 | *============================================================================== |
| 54 | *******************************************************************************/ |
| 55 | |
| 56 | #include "kal_public_api.h" |
| 57 | #include "kal_general_types.h" |
| 58 | #include "kal_public_defs.h" //MSBB change #include "stack_config.h" |
| 59 | #include "string.h" |
| 60 | #include "sim_common_enums.h" /* SIM data type */ |
| 61 | #include "smu_common_enums.h" |
| 62 | #include "sim_public_api.h" |
| 63 | #include "custom_ecc.h" |
| 64 | #include "ps_public_utility.h" |
| 65 | #include "phb_utils.h" |
| 66 | |
| 67 | #define MAX_DIAL_PAD (81) |
| 68 | #define ENCODING_LENGTH 2 |
| 69 | |
| 70 | extern kal_uint8 phb_map_sim(kal_uint8 sim); |
| 71 | |
| 72 | //extern sim_interface_enum l4c_gemini_get_switched_sim_id(sim_interface_enum simId); |
| 73 | |
| 74 | |
| 75 | /* ECC buffers */ |
| 76 | /* The last word means whether this entry should be regarded as emergency call if SIM card is present */ |
| 77 | /* 0: ECC only if no SIM, 1: ECC always */ |
| 78 | const kal_uint16 ecc_default_num[ ][ECC_CUSTOM_DEFAULT_ECC_LENGTH + 1] = |
| 79 | { |
| 80 | {0x0031, 0x0031, 0x0032, 0x0000, 1}, /* 112 */ |
| 81 | {0x0039, 0x0031, 0x0031, 0x0000, 1}, /* 911 */ |
| 82 | #ifdef __MEXICO_ECC__ |
| 83 | {0x0030, 0x0038, 0x0030, 0x0000, 1}, /* 080 */ |
| 84 | {0x0030, 0x0036, 0x0030, 0x0000, 1}, /* 060 */ |
| 85 | #endif /* __MEXICO_ECC__ */ |
| 86 | #ifdef __RUSSIA_ECC__ |
| 87 | {0x0030, 0x0031, 0x0000, 0x0000, 1}, /* 01 */ |
| 88 | {0x0030, 0x0032, 0x0000, 0x0000, 1}, /* 02 */ |
| 89 | {0x0030, 0x0033, 0x0000, 0x0000, 1}, /* 03 */ |
| 90 | {0x0030, 0x0030, 0x0031, 0x0000, 1}, /* 001 */ |
| 91 | {0x0030, 0x0030, 0x0032, 0x0000, 1}, /* 002 */ |
| 92 | {0x0030, 0x0030, 0x0033, 0x0000, 1}, /* 003 */ |
| 93 | #endif /* __RUSSIA_ECC__ */ |
| 94 | #ifdef __PHILIPPINES_ECC__ |
| 95 | {0x0031, 0x0031, 0x0037, 0x0000, 1}, /* 117 */ |
| 96 | #endif /* __PHILIPPINES_ECC__ */ |
| 97 | #ifdef __BRAZIL_ECC__ |
| 98 | {0x0031, 0x0039, 0x0030, 0x0000, 1}, /* 190 */ |
| 99 | #endif /* __BRAZIL_ECC__ */ |
| 100 | #ifdef __PAKISTAN_ECC__ |
| 101 | {0x0031, 0x0035, 0x0000, 0x0000, 0}, /* 15 */ |
| 102 | {0x0031, 0x0031, 0x0035, 0x0000, 0}, /* 115 */ |
| 103 | #endif /* __PAKISTAN_ECC__ */ |
| 104 | #if defined(__OP01__) || defined(__OP02__) || defined(__OP09__) || defined(__CTA_ECC_SUPPORT__) |
| 105 | {0x0031, 0x0032, 0x0030, 0x0000, 0}, /* 120 */ |
| 106 | {0x0031, 0x0032, 0x0032, 0x0000, 0}, /* 122 */ |
| 107 | #endif |
| 108 | #if defined(__CPHS__) && defined(__CPHS_NUM_999_AS_ECC__) |
| 109 | {0x0039, 0x0039, 0x0039, 0x0000, 1}, /* 999 */ |
| 110 | #else |
| 111 | {0x0039, 0x0039, 0x0039, 0x0000, 0}, /* 999 */ |
| 112 | #endif |
| 113 | {0x0030, 0x0030, 0x0030, 0x0000, 0}, /* 000 */ |
| 114 | {0x0031, 0x0031, 0x0030, 0x0000, 0}, /* 110 */ |
| 115 | {0x0031, 0x0031, 0x0038, 0x0000, 0}, /* 118 */ |
| 116 | {0x0031, 0x0031, 0x0039, 0x0000, 0}, /* 119 */ |
| 117 | {0x0030, 0x0038, 0x0000, 0x0000, 0}, /* 08 */ |
| 118 | {0x0000, 0x0000, 0x0000, 0x0000, 0} |
| 119 | }; |
| 120 | |
| 121 | const kal_uint16 ecc_3gpp_num[ ][ECC_CUSTOM_DEFAULT_ECC_LENGTH + 1] = |
| 122 | { |
| 123 | {0x0031, 0x0031, 0x0032, 0x0000, 1}, /* 112 */ |
| 124 | {0x0039, 0x0031, 0x0031, 0x0000, 1}, /* 911 */ |
| 125 | {0x0039, 0x0039, 0x0039, 0x0000, 0}, /* 999 */ |
| 126 | {0x0030, 0x0030, 0x0030, 0x0000, 0}, /* 000 */ |
| 127 | {0x0031, 0x0031, 0x0030, 0x0000, 0}, /* 110 */ |
| 128 | {0x0031, 0x0031, 0x0038, 0x0000, 0}, /* 118 */ |
| 129 | {0x0031, 0x0031, 0x0039, 0x0000, 0}, /* 119 */ |
| 130 | {0x0030, 0x0038, 0x0000, 0x0000, 0}, /* 08 */ |
| 131 | {0x0000, 0x0000, 0x0000, 0x0000, 0} |
| 132 | }; |
| 133 | |
| 134 | const fdn_ecc_struct fdn_ecc_as_normal[] = |
| 135 | { |
| 136 | // ecc number is encode as BCD format |
| 137 | // {length of ecc string, BCD[0], BCD[1], BCD[2], MCCMNC string} |
| 138 | // example: 123 |
| 139 | // length of 123 --> 3 |
| 140 | // BCD[0] = 0x21 |
| 141 | // BCD[1] = 0xf3 |
| 142 | // BCD[2] = 0xff |
| 143 | // MCCMNC = "46000" |
| 144 | #ifdef __UMTS_TDD128_MODE__ |
| 145 | {3, 0x00, 0xF0, 0xFF, "46000"}, |
| 146 | {2, 0x80, 0xFF, 0xFF, "46000"}, |
| 147 | {3, 0x11, 0xF0, 0xFF, "46000"}, |
| 148 | {3, 0x21, 0xF0, 0xFF, "46000"}, |
| 149 | {3, 0x11, 0xF8, 0xFF, "46000"}, |
| 150 | {3, 0x11, 0xF9, 0xFF, "46000"}, |
| 151 | {3, 0x99, 0xF9, 0xFF, "46000"}, |
| 152 | {3, 0x11, 0xF1, 0xFF, "46000"}, |
| 153 | {3, 0x11, 0xF7, 0xFF, "46000"}, |
| 154 | {0, 0xFF, 0xFF, 0xFF, "00000"} // do not modify this row |
| 155 | #else |
| 156 | {3, 0x11, 0xF7, 0xFF, "46000"}, |
| 157 | {0, 0xFF, 0xFF, 0xFF, "00000"} // do not modify this row |
| 158 | #endif |
| 159 | }; |
| 160 | |
| 161 | const kal_uint16 * ecc_default_num_p = (kal_uint16 *)ecc_default_num; |
| 162 | |
| 163 | static ecc_record_struct ecc_sim1_number[ECC_CUSTOM_MAX_SIM_RECORD]; |
| 164 | static ecc_record_struct ecc_nw1_number[ECC_CUSTOM_MAX_NW_RECORD]; |
| 165 | #if defined(__GEMINI__) |
| 166 | static ecc_record_struct ecc_sim2_number[ECC_CUSTOM_MAX_SIM_RECORD]; |
| 167 | static ecc_record_struct ecc_nw2_number[ECC_CUSTOM_MAX_NW_RECORD]; |
| 168 | #if (GEMINI_PLUS >= 3) // Gemini+ |
| 169 | static ecc_record_struct ecc_sim3_number[ECC_CUSTOM_MAX_SIM_RECORD]; |
| 170 | static ecc_record_struct ecc_nw3_number[ECC_CUSTOM_MAX_NW_RECORD]; |
| 171 | #if (GEMINI_PLUS >= 4) // Gemini+ |
| 172 | static ecc_record_struct ecc_sim4_number[ECC_CUSTOM_MAX_SIM_RECORD]; |
| 173 | static ecc_record_struct ecc_nw4_number[ECC_CUSTOM_MAX_NW_RECORD]; |
| 174 | #endif |
| 175 | #endif |
| 176 | #endif /* __GEMINI__ */ |
| 177 | static ecc_record_struct ecc_nvram_number[ECC_CUSTOM_MAX_NVRAM_RECORD]; |
| 178 | |
| 179 | static kal_uint8 ecc_empty_display_buffer[ENCODING_LENGTH] = {0}; |
| 180 | |
| 181 | |
| 182 | /***************************************************************************** |
| 183 | * FUNCTION |
| 184 | * ecc_custom_decode_bcd_2_ansii |
| 185 | * DESCRIPTION |
| 186 | * |
| 187 | * PARAMETERS |
| 188 | * |
| 189 | * RETURNS |
| 190 | * void |
| 191 | *****************************************************************************/ |
| 192 | void ecc_custom_decode_bcd_2_ansii(kal_uint8 *ecc_asnii, kal_uint8 *ecc_bcd) |
| 193 | { |
| 194 | /*----------------------------------------------------------------*/ |
| 195 | /* Local Variables */ |
| 196 | /*----------------------------------------------------------------*/ |
| 197 | |
| 198 | /*----------------------------------------------------------------*/ |
| 199 | /* Code Body */ |
| 200 | /*----------------------------------------------------------------*/ |
| 201 | //if (length >= 1) refer to MOLY00295103 |
| 202 | { |
| 203 | *(ecc_asnii + 0) = (*(ecc_bcd + 0) & 0x0F) == 0x0F ? 0 : (kal_uint8) (0x30 + ( *(ecc_bcd + 0) & 0x0F)); |
| 204 | *(ecc_asnii + 1) = (*(ecc_bcd + 0) & 0xF0) == 0xF0 ? 0 : (kal_uint8) (0x30 + ((*(ecc_bcd + 0) & 0xF0) >> 4)); |
| 205 | } |
| 206 | |
| 207 | //if (length >= 2) |
| 208 | { |
| 209 | *(ecc_asnii + 2) = (*(ecc_bcd + 1) & 0x0F) == 0x0F ? 0 : (kal_uint8) (0x30 + ( *(ecc_bcd + 1) & 0x0F)); |
| 210 | *(ecc_asnii + 3) = (*(ecc_bcd + 1) & 0xF0) == 0xF0 ? 0 : (kal_uint8) (0x30 + ((*(ecc_bcd + 1) & 0xF0) >> 4)); |
| 211 | } |
| 212 | |
| 213 | //if (length >= 3) |
| 214 | { |
| 215 | *(ecc_asnii + 4) = (*(ecc_bcd + 2) & 0x0F) == 0x0F ? 0 : (kal_uint8) (0x30 + ( *(ecc_bcd + 2) & 0x0F)); |
| 216 | *(ecc_asnii + 5) = (*(ecc_bcd + 2) & 0xF0) == 0xF0 ? 0 : (kal_uint8) (0x30 + ((*(ecc_bcd + 2) & 0xF0) >> 4)); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | |
| 221 | /***************************************************************************** |
| 222 | * FUNCTION |
| 223 | * ecc_custom_bcd_digit_2_char |
| 224 | * DESCRIPTION |
| 225 | * |
| 226 | * PARAMETERS |
| 227 | * |
| 228 | * RETURNS |
| 229 | * char |
| 230 | *****************************************************************************/ |
| 231 | static char ecc_custom_bcd_digit_2_char(kal_uint8 digit) |
| 232 | { |
| 233 | /*----------------------------------------------------------------*/ |
| 234 | /* Local Variables */ |
| 235 | /*----------------------------------------------------------------*/ |
| 236 | |
| 237 | /*----------------------------------------------------------------*/ |
| 238 | /* Code Body */ |
| 239 | /*----------------------------------------------------------------*/ |
| 240 | /* Re-assign the value of BCD encoding numbers */ |
| 241 | if (digit < 0xa) |
| 242 | { |
| 243 | return ('0' + digit); |
| 244 | } |
| 245 | else if (digit == 0xa) |
| 246 | { |
| 247 | return '*'; |
| 248 | } |
| 249 | else if (digit == 0xb) |
| 250 | { |
| 251 | return '#'; |
| 252 | } |
| 253 | else if (digit == 0xc) |
| 254 | { |
| 255 | return 'p'; |
| 256 | } |
| 257 | else if (digit == 0xd) |
| 258 | { |
| 259 | return 'w'; |
| 260 | } |
| 261 | else |
| 262 | { |
| 263 | return (char)0xFF; |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | |
| 268 | /***************************************************************************** |
| 269 | * FUNCTION |
| 270 | * ecc_custom_bcd_2_string |
| 271 | * DESCRIPTION |
| 272 | * |
| 273 | * PARAMETERS |
| 274 | * |
| 275 | * RETURNS |
| 276 | * void |
| 277 | *****************************************************************************/ |
| 278 | static void ecc_custom_bcd_2_string(kal_uint8 *bcd_array, kal_uint16 size, char *buf, kal_uint16 buf_size) |
| 279 | { |
| 280 | /*----------------------------------------------------------------*/ |
| 281 | /* Local Variables */ |
| 282 | /*----------------------------------------------------------------*/ |
| 283 | kal_uint8 i, j = 0; |
| 284 | char digit; |
| 285 | |
| 286 | /*----------------------------------------------------------------*/ |
| 287 | /* Code Body */ |
| 288 | /*----------------------------------------------------------------*/ |
| 289 | if (bcd_array == NULL || size == 0 || buf == NULL || buf_size == 0) |
| 290 | { |
| 291 | return; |
| 292 | } |
| 293 | |
| 294 | memset(buf, 0x0, buf_size); |
| 295 | if ((bcd_array[0] & 0xF0) == 0x90) |
| 296 | { |
| 297 | buf[j++] = '+'; |
| 298 | } |
| 299 | |
| 300 | for (i = 1; i < size && j < buf_size - 1; i++) |
| 301 | { |
| 302 | if (j < buf_size - 1) |
| 303 | { |
| 304 | digit = ecc_custom_bcd_digit_2_char((kal_uint8)(bcd_array[i] & 0x0F)); |
| 305 | if (digit == (char)0xFF) |
| 306 | { |
| 307 | return; |
| 308 | } |
| 309 | buf[j] = digit; |
| 310 | j++; |
| 311 | } |
| 312 | if (j < buf_size - 1) |
| 313 | { |
| 314 | digit = ecc_custom_bcd_digit_2_char((kal_uint8)((bcd_array[i] >> 4) & 0x0F)); |
| 315 | if (digit == (char)0xFF) |
| 316 | { |
| 317 | return; |
| 318 | } |
| 319 | buf[j] = digit; |
| 320 | j++; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | buf[j] = 0; |
| 325 | } |
| 326 | |
| 327 | |
| 328 | |
| 329 | /***************************************************************************** |
| 330 | * FUNCTION |
| 331 | * ecc_custom_str_n_to_ucs2_str |
| 332 | * DESCRIPTION |
| 333 | * |
| 334 | * PARAMETERS |
| 335 | * |
| 336 | * RETURNS |
| 337 | * kal_uint16 |
| 338 | *****************************************************************************/ |
| 339 | static kal_uint16 ecc_custom_str_n_to_ucs2_str(kal_int8 *pOutBuffer, kal_int8 *pInBuffer, kal_uint32 len) |
| 340 | { |
| 341 | /*----------------------------------------------------------------*/ |
| 342 | /* Local Variables */ |
| 343 | /*----------------------------------------------------------------*/ |
| 344 | kal_int16 count = -1; |
| 345 | |
| 346 | /*----------------------------------------------------------------*/ |
| 347 | /* Code Body */ |
| 348 | /*----------------------------------------------------------------*/ |
| 349 | while (len) |
| 350 | { |
| 351 | pOutBuffer[++count] = *pInBuffer; |
| 352 | pOutBuffer[++count] = 0; |
| 353 | |
| 354 | if (*pInBuffer == '\0') |
| 355 | { |
| 356 | break; |
| 357 | } |
| 358 | else |
| 359 | { |
| 360 | len--; |
| 361 | pInBuffer++; |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | return count + 1; |
| 366 | } |
| 367 | |
| 368 | |
| 369 | /***************************************************************************** |
| 370 | * FUNCTION |
| 371 | * ecc_custom_prepare_number |
| 372 | * DESCRIPTION |
| 373 | * |
| 374 | * PARAMETERS |
| 375 | * |
| 376 | * RETURNS |
| 377 | * void |
| 378 | *****************************************************************************/ |
| 379 | static void ecc_custom_prepare_number(kal_uint8 *ecc_out, kal_uint8 *ecc_in, ecc_num_encoding_enum ecc_encoding) |
| 380 | { |
| 381 | /*----------------------------------------------------------------*/ |
| 382 | /* Local Variables */ |
| 383 | /*----------------------------------------------------------------*/ |
| 384 | kal_uint8 ecc_tmp[ECC_CUSTOM_MAX_BCD_LENGTH * 2 + 1] = {0}; |
| 385 | |
| 386 | /*----------------------------------------------------------------*/ |
| 387 | /* Code Body */ |
| 388 | /*----------------------------------------------------------------*/ |
| 389 | memset(ecc_out, 0, (ECC_CUSTOM_MAX_BCD_LENGTH * 2 + 1) * ENCODING_LENGTH); |
| 390 | |
| 391 | switch (ecc_encoding) |
| 392 | { |
| 393 | case ECC_ENCODING_ANSII: |
| 394 | ecc_custom_str_n_to_ucs2_str((kal_int8*) ecc_out, (kal_int8*) ecc_in, ECC_CUSTOM_MAX_BCD_LENGTH * 2); |
| 395 | break; |
| 396 | case ECC_ENCODING_UCS2: |
| 397 | kal_dchar_strncpy((char*) ecc_out, (char*) ecc_in, ECC_CUSTOM_MAX_BCD_LENGTH * 4); |
| 398 | break; |
| 399 | case ECC_ENCODING_BCD: |
| 400 | ecc_custom_decode_bcd_2_ansii(ecc_tmp, ecc_in); |
| 401 | ecc_custom_str_n_to_ucs2_str((kal_int8*) ecc_out, (kal_int8*) ecc_tmp, ECC_CUSTOM_MAX_BCD_LENGTH * 2); |
| 402 | break; |
| 403 | default: |
| 404 | break; |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | |
| 409 | /***************************************************************************** |
| 410 | * FUNCTION |
| 411 | * ecc_custom_get_sim_context |
| 412 | * DESCRIPTION |
| 413 | * |
| 414 | * PARAMETERS |
| 415 | * |
| 416 | * RETURNS |
| 417 | * ecc_record_struct * |
| 418 | *****************************************************************************/ |
| 419 | static ecc_record_struct *ecc_custom_get_sim_context(kal_uint8 entry_index, kal_uint8 sim_index) |
| 420 | { |
| 421 | /*----------------------------------------------------------------*/ |
| 422 | /* Local Variables */ |
| 423 | /*----------------------------------------------------------------*/ |
| 424 | |
| 425 | /*----------------------------------------------------------------*/ |
| 426 | /* Code Body */ |
| 427 | /*----------------------------------------------------------------*/ |
| 428 | sim_index = ECC_SIM1_CALL + phb_map_sim(sim_index - ECC_SIM1_CALL); |
| 429 | |
| 430 | if (sim_index == ECC_SIM1_CALL) |
| 431 | { |
| 432 | return &(ecc_sim1_number[entry_index]); |
| 433 | } |
| 434 | #if defined(__GEMINI__) |
| 435 | else if (sim_index == ECC_SIM2_CALL) |
| 436 | { |
| 437 | return &(ecc_sim2_number[entry_index]); |
| 438 | } |
| 439 | #if (GEMINI_PLUS >= 3) // Gemini+ |
| 440 | else if (sim_index == ECC_SIM3_CALL) |
| 441 | { |
| 442 | return &(ecc_sim3_number[entry_index]); |
| 443 | } |
| 444 | #if (GEMINI_PLUS >= 4) // Gemini+ |
| 445 | else if (sim_index == ECC_SIM4_CALL) |
| 446 | { |
| 447 | return &(ecc_sim4_number[entry_index]); |
| 448 | } |
| 449 | #endif |
| 450 | #endif |
| 451 | #endif /* __GEMINI__ */ |
| 452 | else |
| 453 | { |
| 454 | return NULL; |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | /***************************************************************************** |
| 459 | * FUNCTION |
| 460 | * ecc_custom_get_nw_context |
| 461 | * DESCRIPTION |
| 462 | * |
| 463 | * PARAMETERS |
| 464 | * |
| 465 | * RETURNS |
| 466 | * ecc_record_struct * |
| 467 | *****************************************************************************/ |
| 468 | static ecc_record_struct *ecc_custom_get_nw_context(kal_uint8 entry_index, kal_uint8 sim_index) |
| 469 | { |
| 470 | /*----------------------------------------------------------------*/ |
| 471 | /* Local Variables */ |
| 472 | /*----------------------------------------------------------------*/ |
| 473 | |
| 474 | /*----------------------------------------------------------------*/ |
| 475 | /* Code Body */ |
| 476 | /*----------------------------------------------------------------*/ |
| 477 | sim_index = ECC_SIM1_CALL + phb_map_sim(sim_index - ECC_SIM1_CALL); |
| 478 | |
| 479 | if (sim_index == ECC_SIM1_CALL) |
| 480 | { |
| 481 | return &(ecc_nw1_number[entry_index]); |
| 482 | } |
| 483 | #if defined(__GEMINI__) |
| 484 | else if (sim_index == ECC_SIM2_CALL) |
| 485 | { |
| 486 | return &(ecc_nw2_number[entry_index]); |
| 487 | } |
| 488 | #if (GEMINI_PLUS >= 3) // Gemini+ |
| 489 | else if (sim_index == ECC_SIM3_CALL) |
| 490 | { |
| 491 | return &(ecc_nw3_number[entry_index]); |
| 492 | } |
| 493 | #if (GEMINI_PLUS >= 4) // Gemini+ |
| 494 | else if (sim_index == ECC_SIM4_CALL) |
| 495 | { |
| 496 | return &(ecc_nw4_number[entry_index]); |
| 497 | } |
| 498 | #endif |
| 499 | #endif |
| 500 | #endif /* __GEMINI__ */ |
| 501 | else |
| 502 | { |
| 503 | return NULL; |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | static kal_bool ecc_custom_is_sim_inserted(sim_interface_enum sim_id) |
| 508 | { |
| 509 | /*----------------------------------------------------------------*/ |
| 510 | /* Local Variables */ |
| 511 | /*----------------------------------------------------------------*/ |
| 512 | |
| 513 | /*----------------------------------------------------------------*/ |
| 514 | /* Code Body */ |
| 515 | /*----------------------------------------------------------------*/ |
| 516 | #if defined(__GEMINI__) |
| 517 | if (check_sim_card_status(sim_id) == SIM_CARD_NOT_INSERTED) |
| 518 | #else |
| 519 | if (check_sim_card_status() == SIM_CARD_NOT_INSERTED) |
| 520 | #endif |
| 521 | { |
| 522 | return KAL_FALSE; |
| 523 | } |
| 524 | else if (l4csmu_get_pending_password_id_ext(sim_id) == ID_SIM_PIN1 || l4csmu_get_pending_password_id_ext(sim_id) == ID_SIM_PUK1) |
| 525 | { |
| 526 | return KAL_FALSE; |
| 527 | } |
| 528 | else |
| 529 | { |
| 530 | return KAL_TRUE; |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | |
| 535 | static kal_uint8 ecc_custom_is_sim_with_ecc_num(ecc_call_type_enum call_type, kal_bool ecc_always) |
| 536 | { |
| 537 | /*----------------------------------------------------------------*/ |
| 538 | /* Local Variables */ |
| 539 | /*----------------------------------------------------------------*/ |
| 540 | kal_uint8 sim_with_ecc_num_case = 0; |
| 541 | |
| 542 | /*----------------------------------------------------------------*/ |
| 543 | /* Code Body */ |
| 544 | /*----------------------------------------------------------------*/ |
| 545 | #if defined(__GEMINI__) |
| 546 | if (call_type == ECC_SIM1_CALL && ecc_custom_is_sim_inserted(SIM1) && !ecc_always) |
| 547 | { |
| 548 | sim_with_ecc_num_case = 1; |
| 549 | } |
| 550 | if (call_type == ECC_SIM2_CALL && ecc_custom_is_sim_inserted(SIM2) && !ecc_always) |
| 551 | { |
| 552 | sim_with_ecc_num_case = 1; |
| 553 | } |
| 554 | #if (GEMINI_PLUS >= 3) // Gemini+ |
| 555 | if (call_type == ECC_SIM3_CALL && ecc_custom_is_sim_inserted(SIM3) && !ecc_always) |
| 556 | { |
| 557 | sim_with_ecc_num_case = 1; |
| 558 | } |
| 559 | #if (GEMINI_PLUS >= 4) // Gemini+ |
| 560 | if (call_type == ECC_SIM4_CALL && ecc_custom_is_sim_inserted(SIM4) && !ecc_always) |
| 561 | { |
| 562 | sim_with_ecc_num_case = 1; |
| 563 | } |
| 564 | #endif |
| 565 | #endif |
| 566 | if (call_type == ECC_ALL_CALL && |
| 567 | ecc_custom_is_sim_inserted(SIM1) && |
| 568 | ecc_custom_is_sim_inserted(SIM2) && |
| 569 | #if (GEMINI_PLUS >= 3) // Gemini+ |
| 570 | ecc_custom_is_sim_inserted(SIM3) && |
| 571 | #if (GEMINI_PLUS >= 4) // Gemini+ |
| 572 | ecc_custom_is_sim_inserted(SIM4) && |
| 573 | #endif |
| 574 | #endif |
| 575 | !ecc_always) |
| 576 | { |
| 577 | sim_with_ecc_num_case = 1; |
| 578 | } |
| 579 | #else /* __GEMINI__ */ |
| 580 | if (ecc_custom_is_sim_inserted(SIM1) && !ecc_always) |
| 581 | { |
| 582 | sim_with_ecc_num_case = 1; |
| 583 | } |
| 584 | #endif /* __GEMINI__ */ |
| 585 | |
| 586 | return sim_with_ecc_num_case; |
| 587 | } |
| 588 | |
| 589 | |
| 590 | /***************************************************************************** |
| 591 | * FUNCTION |
| 592 | * ecc_custom_verify_emergency_number_with_suffix |
| 593 | * DESCRIPTION |
| 594 | * |
| 595 | * PARAMETERS |
| 596 | * |
| 597 | * RETURNS |
| 598 | * kal_bool |
| 599 | *****************************************************************************/ |
| 600 | static kal_bool ecc_custom_verify_emergency_number_with_suffix(kal_uint8 *in_number, kal_uint8 *ecc_number) |
| 601 | { |
| 602 | /*----------------------------------------------------------------*/ |
| 603 | /* Local Variables */ |
| 604 | /*----------------------------------------------------------------*/ |
| 605 | kal_uint8 ecc_default_num_ext[16]; |
| 606 | |
| 607 | /*----------------------------------------------------------------*/ |
| 608 | /* Code Body */ |
| 609 | /*----------------------------------------------------------------*/ |
| 610 | if (kal_dchar_strlen((char*) ecc_number) == 0) |
| 611 | { |
| 612 | return KAL_FALSE; |
| 613 | } |
| 614 | |
| 615 | /* Additional check for p or w after emergency call */ |
| 616 | kal_dchar_strcpy((char*) ecc_default_num_ext, (char*) ecc_number); |
| 617 | kal_dchar_strcat((char*) ecc_default_num_ext, (char*) L"p"); |
| 618 | if (kal_dchar_strncmp((char*) in_number, (char*) ecc_default_num_ext, kal_dchar_strlen((char*) ecc_default_num_ext)) == 0) |
| 619 | { |
| 620 | return KAL_TRUE; |
| 621 | } |
| 622 | |
| 623 | kal_dchar_strcpy((char*) ecc_default_num_ext, (char*) ecc_number); |
| 624 | kal_dchar_strcat((char*) ecc_default_num_ext, (char*) L"w"); |
| 625 | if (kal_dchar_strncmp((char*) in_number, (char*) ecc_default_num_ext, kal_dchar_strlen((char*) ecc_default_num_ext)) == 0) |
| 626 | { |
| 627 | return KAL_TRUE; |
| 628 | } |
| 629 | |
| 630 | /* diamond, 2006/05/12 Additional check for + after emergency call */ |
| 631 | kal_dchar_strcpy((char*) ecc_default_num_ext, (char*) ecc_number); |
| 632 | kal_dchar_strcat((char*) ecc_default_num_ext, (char*) L"+"); |
| 633 | if (kal_dchar_strncmp((char*) in_number, (char*) ecc_default_num_ext, kal_dchar_strlen((char*) ecc_default_num_ext)) == 0 && |
| 634 | kal_dchar_strncmp((char*) (in_number + (kal_dchar_strlen((char*) in_number) - 2)), (char*) L"#", 2) != 0) |
| 635 | { |
| 636 | return KAL_TRUE; |
| 637 | } |
| 638 | |
| 639 | return KAL_FALSE; |
| 640 | } |
| 641 | |
| 642 | |
| 643 | /***************************************************************************** |
| 644 | * FUNCTION |
| 645 | * ecc_custom_verify_emergency_number |
| 646 | * DESCRIPTION |
| 647 | * Verify calling number from ECC pool |
| 648 | * PARAMETERS |
| 649 | * number [IN] verified ECC number |
| 650 | * num_length [IN] verified ECC number length |
| 651 | * num_encoding [IN] verified ECC number coding scheme |
| 652 | * call_type [IN] verified ECC number call type |
| 653 | * ecc_category [OUT] returned verified ECC number category (REL5 only) |
| 654 | * ecc_display [OUT] returned verified ECC number display string (REL5 only) |
| 655 | * verify_detail [OUT] returned match detail |
| 656 | * RETURNS |
| 657 | * kal_bool |
| 658 | *****************************************************************************/ |
| 659 | kal_bool ecc_custom_verify_emergency_number( |
| 660 | kal_uint8 *number, |
| 661 | kal_uint8 num_length, |
| 662 | ecc_num_encoding_enum num_encoding, |
| 663 | ecc_call_type_enum call_type, |
| 664 | kal_uint8 *ecc_category, |
| 665 | kal_uint8 **ecc_display, |
| 666 | kal_uint8 *verify_detail) |
| 667 | { |
| 668 | /*----------------------------------------------------------------*/ |
| 669 | /* Local Variables */ |
| 670 | /*----------------------------------------------------------------*/ |
| 671 | #if 0 |
| 672 | /* under construction !*/ |
| 673 | /* under construction !*/ |
| 674 | /* under construction !*/ |
| 675 | /* under construction !*/ |
| 676 | /* under construction !*/ |
| 677 | /* under construction !*/ |
| 678 | /* under construction !*/ |
| 679 | /* under construction !*/ |
| 680 | #endif |
| 681 | kal_uint16 ecc_additional_check_number[2][4] = |
| 682 | { |
| 683 | {0x002A, 0x0033, 0x0031, 0x0023}, /* prefix = *31# */ |
| 684 | {0x0023, 0x0033, 0x0031, 0x0023} /* prefix = #31# */ |
| 685 | }; |
| 686 | |
| 687 | kal_uint16 ecc_sat_number[] = {0x0031, 0x0031, 0x0032, 0x0000}; |
| 688 | |
| 689 | kal_uint8 ecc_buffer[MAX_DIAL_PAD * ENCODING_LENGTH] = {0}; |
| 690 | kal_uint8 ecc_tmp[MAX_DIAL_PAD] = {0}; |
| 691 | kal_uint8 *ecc_verify; |
| 692 | kal_uint8 i, j; |
| 693 | kal_uint8 sim_with_ecc_num_case = 0; |
| 694 | sim_interface_enum sim_id; |
| 695 | |
| 696 | #ifdef GEMINI_PLUS |
| 697 | kal_uint8 loop_count = GEMINI_PLUS; |
| 698 | #else |
| 699 | kal_uint8 loop_count = 1; |
| 700 | #endif |
| 701 | |
| 702 | ecc_record_struct *sim_context; |
| 703 | ecc_record_struct *nw_context; |
| 704 | |
| 705 | /*----------------------------------------------------------------*/ |
| 706 | /* Code Body */ |
| 707 | /*----------------------------------------------------------------*/ |
| 708 | |
| 709 | /* default response data */ |
| 710 | if (ecc_category != NULL) |
| 711 | { |
| 712 | *ecc_category = 0; |
| 713 | } |
| 714 | |
| 715 | if (ecc_display != NULL) |
| 716 | { |
| 717 | *ecc_display = &ecc_empty_display_buffer[0]; |
| 718 | } |
| 719 | |
| 720 | if (verify_detail != NULL) |
| 721 | { |
| 722 | *verify_detail = ECC_NOT_MATCH; |
| 723 | } |
| 724 | |
| 725 | switch (num_encoding) |
| 726 | { |
| 727 | case ECC_ENCODING_ANSII: |
| 728 | ecc_custom_str_n_to_ucs2_str((kal_int8*) ecc_buffer, (kal_int8*) number, MAX_DIAL_PAD - 1); |
| 729 | break; |
| 730 | case ECC_ENCODING_UCS2: |
| 731 | kal_dchar_strncpy((char*) ecc_buffer, (char*) number, (MAX_DIAL_PAD - 1) * ENCODING_LENGTH); |
| 732 | break; |
| 733 | case ECC_ENCODING_BCD: |
| 734 | ecc_custom_bcd_2_string(number, num_length, (char*) ecc_tmp, MAX_DIAL_PAD); |
| 735 | ecc_custom_str_n_to_ucs2_str((kal_int8*) ecc_buffer, (kal_int8*) ecc_tmp, MAX_DIAL_PAD - 1); |
| 736 | break; |
| 737 | default: |
| 738 | return KAL_FALSE; |
| 739 | } |
| 740 | |
| 741 | if (kal_dchar_strlen((char*) ecc_buffer) == 0) |
| 742 | { |
| 743 | return KAL_FALSE; |
| 744 | } |
| 745 | |
| 746 | /* Additional check for *31# and #31# before emergency call */ |
| 747 | /* Additional check for + before emergency call */ |
| 748 | #if 0 |
| 749 | /* under construction !*/ |
| 750 | /* under construction !*/ |
| 751 | /* under construction !*/ |
| 752 | /* under construction !*/ |
| 753 | /* under construction !*/ |
| 754 | /* under construction !*/ |
| 755 | /* under construction !*/ |
| 756 | /* under construction !*/ |
| 757 | /* under construction !*/ |
| 758 | /* under construction !*/ |
| 759 | /* under construction !*/ |
| 760 | /* under construction !*/ |
| 761 | /* under construction !*/ |
| 762 | /* under construction !*/ |
| 763 | #endif |
| 764 | if ((kal_dchar_strncmp((char*) ecc_buffer, (char*) ecc_additional_check_number[0], 8) == 0) || |
| 765 | (kal_dchar_strncmp((char*) ecc_buffer, (char*) ecc_additional_check_number[1], 8) == 0)) |
| 766 | { |
| 767 | ecc_verify = ecc_buffer + 8; |
| 768 | } |
| 769 | else |
| 770 | { |
| 771 | ecc_verify = ecc_buffer; |
| 772 | } |
| 773 | |
| 774 | if (kal_dchar_strlen((char*) ecc_verify) == 0) |
| 775 | { |
| 776 | return KAL_FALSE; |
| 777 | } |
| 778 | |
| 779 | if (call_type == ECC_SAT_CALL) |
| 780 | { |
| 781 | if (kal_dchar_strcmp((char*) ecc_verify, (char*) ecc_sat_number) == 0) |
| 782 | { |
| 783 | if (verify_detail != NULL) *verify_detail = ECC_FULLY_MATCH; |
| 784 | return KAL_TRUE; |
| 785 | } |
| 786 | else |
| 787 | { |
| 788 | return KAL_FALSE; |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | if(sbp_query_md_feature_by_ps(SBP_KOR_CUSTOMIZATION, (protocol_id_enum)phb_which_sim_ex()) == KAL_TRUE) |
| 793 | { |
| 794 | /* Korea Operator Requirements : NW_ECC is as 1st priority */ |
| 795 | /* verify NW record second */ |
| 796 | for (j = ECC_SIM1_CALL; j < loop_count; j++) |
| 797 | { |
| 798 | if (call_type != j && call_type != ECC_ALL_CALL) |
| 799 | { |
| 800 | continue; |
| 801 | } |
| 802 | |
| 803 | for (i = 0; i < ECC_CUSTOM_MAX_NW_RECORD; i++) |
| 804 | { |
| 805 | //#ifdef __GEMINI_3G_SWITCH__ |
| 806 | // sim_id = l4c_gemini_get_switched_sim_id(j); |
| 807 | //#else |
| 808 | sim_id = j; |
| 809 | //#endif |
| 810 | nw_context = ecc_custom_get_nw_context(i, sim_id); |
| 811 | |
| 812 | if (kal_dchar_strcmp((char*) ecc_verify, (char*) nw_context->ecc_number) == 0) |
| 813 | { |
| 814 | if (ecc_category != NULL) *ecc_category = nw_context->ecc_category; |
| 815 | if (verify_detail != NULL) *verify_detail = ECC_FULLY_MATCH; |
| 816 | return KAL_TRUE; |
| 817 | } |
| 818 | |
| 819 | if (ecc_custom_verify_emergency_number_with_suffix(ecc_verify, nw_context->ecc_number)) |
| 820 | { |
| 821 | if (ecc_category != NULL) *ecc_category = nw_context->ecc_category; |
| 822 | if (verify_detail != NULL) *verify_detail = ECC_FULLY_MATCH; |
| 823 | return KAL_TRUE; |
| 824 | } |
| 825 | |
| 826 | if (verify_detail != NULL && kal_dchar_strncmp((char*) nw_context->ecc_number, (char*) ecc_verify, kal_dchar_strlen((char*) ecc_verify)) == 0) |
| 827 | { |
| 828 | *verify_detail = ECC_PARTIALLY_MATCH; |
| 829 | } |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | /* verify SIM record first */ |
| 834 | for (j = ECC_SIM1_CALL; j < loop_count; j++) |
| 835 | { |
| 836 | if (call_type != j && call_type != ECC_ALL_CALL) |
| 837 | { |
| 838 | continue; |
| 839 | } |
| 840 | |
| 841 | for (i = 0; i < ECC_CUSTOM_MAX_SIM_RECORD; i++) |
| 842 | { |
| 843 | //#ifdef __GEMINI_3G_SWITCH__ |
| 844 | // sim_id = l4c_gemini_get_switched_sim_id(j); |
| 845 | //#else |
| 846 | sim_id = j; |
| 847 | //#endif |
| 848 | sim_context = ecc_custom_get_sim_context(i, sim_id); |
| 849 | |
| 850 | if (kal_dchar_strcmp((char*) ecc_verify, (char*) sim_context->ecc_number) == 0) |
| 851 | { |
| 852 | if (ecc_category != NULL) *ecc_category = sim_context->ecc_category; |
| 853 | if (verify_detail != NULL) *verify_detail = ECC_FULLY_MATCH; |
| 854 | return KAL_TRUE; |
| 855 | } |
| 856 | |
| 857 | if (ecc_custom_verify_emergency_number_with_suffix(ecc_verify, sim_context->ecc_number)) |
| 858 | { |
| 859 | if (ecc_category != NULL) *ecc_category = sim_context->ecc_category; |
| 860 | if (verify_detail != NULL) *verify_detail = ECC_FULLY_MATCH; |
| 861 | return KAL_TRUE; |
| 862 | } |
| 863 | |
| 864 | if (verify_detail != NULL && kal_dchar_strncmp((char*) sim_context->ecc_number, (char*) ecc_verify, kal_dchar_strlen((char*) ecc_verify)) == 0) |
| 865 | { |
| 866 | *verify_detail = ECC_PARTIALLY_MATCH; |
| 867 | } |
| 868 | } |
| 869 | } |
| 870 | } |
| 871 | else |
| 872 | { |
| 873 | /* verify SIM record first */ |
| 874 | for (j = ECC_SIM1_CALL; j < loop_count; j++) |
| 875 | { |
| 876 | if (call_type != j && call_type != ECC_ALL_CALL) |
| 877 | { |
| 878 | continue; |
| 879 | } |
| 880 | |
| 881 | for (i = 0; i < ECC_CUSTOM_MAX_SIM_RECORD; i++) |
| 882 | { |
| 883 | //#ifdef __GEMINI_3G_SWITCH__ |
| 884 | // sim_id = l4c_gemini_get_switched_sim_id(j); |
| 885 | //#else |
| 886 | sim_id = j; |
| 887 | //#endif |
| 888 | sim_context = ecc_custom_get_sim_context(i, sim_id); |
| 889 | |
| 890 | if (kal_dchar_strcmp((char*) ecc_verify, (char*) sim_context->ecc_number) == 0) |
| 891 | { |
| 892 | if (ecc_category != NULL) *ecc_category = sim_context->ecc_category; |
| 893 | if (verify_detail != NULL) *verify_detail = ECC_FULLY_MATCH; |
| 894 | return KAL_TRUE; |
| 895 | } |
| 896 | |
| 897 | if (ecc_custom_verify_emergency_number_with_suffix(ecc_verify, sim_context->ecc_number)) |
| 898 | { |
| 899 | if (ecc_category != NULL) *ecc_category = sim_context->ecc_category; |
| 900 | if (verify_detail != NULL) *verify_detail = ECC_FULLY_MATCH; |
| 901 | return KAL_TRUE; |
| 902 | } |
| 903 | |
| 904 | if (verify_detail != NULL && kal_dchar_strncmp((char*) sim_context->ecc_number, (char*) ecc_verify, kal_dchar_strlen((char*) ecc_verify)) == 0) |
| 905 | { |
| 906 | *verify_detail = ECC_PARTIALLY_MATCH; |
| 907 | } |
| 908 | } |
| 909 | } |
| 910 | |
| 911 | /* verify NW record second */ |
| 912 | for (j = ECC_SIM1_CALL; j < loop_count; j++) |
| 913 | { |
| 914 | if (call_type != j && call_type != ECC_ALL_CALL) |
| 915 | { |
| 916 | continue; |
| 917 | } |
| 918 | |
| 919 | for (i = 0; i < ECC_CUSTOM_MAX_NW_RECORD; i++) |
| 920 | { |
| 921 | //#ifdef __GEMINI_3G_SWITCH__ |
| 922 | // sim_id = l4c_gemini_get_switched_sim_id(j); |
| 923 | //#else |
| 924 | sim_id = j; |
| 925 | //#endif |
| 926 | nw_context = ecc_custom_get_nw_context(i, sim_id); |
| 927 | |
| 928 | if (kal_dchar_strcmp((char*) ecc_verify, (char*) nw_context->ecc_number) == 0) |
| 929 | { |
| 930 | if (ecc_category != NULL) *ecc_category = nw_context->ecc_category; |
| 931 | if (verify_detail != NULL) *verify_detail = ECC_FULLY_MATCH; |
| 932 | return KAL_TRUE; |
| 933 | } |
| 934 | |
| 935 | if (ecc_custom_verify_emergency_number_with_suffix(ecc_verify, nw_context->ecc_number)) |
| 936 | { |
| 937 | if (ecc_category != NULL) *ecc_category = nw_context->ecc_category; |
| 938 | if (verify_detail != NULL) *verify_detail = ECC_FULLY_MATCH; |
| 939 | return KAL_TRUE; |
| 940 | } |
| 941 | |
| 942 | if (verify_detail != NULL && kal_dchar_strncmp((char*) nw_context->ecc_number, (char*) ecc_verify, kal_dchar_strlen((char*) ecc_verify)) == 0) |
| 943 | { |
| 944 | *verify_detail = ECC_PARTIALLY_MATCH; |
| 945 | } |
| 946 | } |
| 947 | } |
| 948 | } |
| 949 | |
| 950 | /* verify NVRAM record next */ |
| 951 | for (i = 0; i < ECC_CUSTOM_MAX_NVRAM_RECORD; i++) |
| 952 | { |
| 953 | if (kal_dchar_strcmp((char*) ecc_verify, (char*) ecc_nvram_number[i].ecc_number) == 0) |
| 954 | { |
| 955 | if (verify_detail != NULL) *verify_detail = ECC_FULLY_MATCH; |
| 956 | if (ecc_category != NULL) *ecc_category = ecc_nvram_number[i].ecc_category; |
| 957 | |
| 958 | sim_with_ecc_num_case = ecc_custom_is_sim_with_ecc_num(call_type, ecc_nvram_number[i].ecc_always); |
| 959 | |
| 960 | if (sim_with_ecc_num_case != 0) |
| 961 | { |
| 962 | sim_with_ecc_num_case = 0; |
| 963 | return KAL_FALSE; |
| 964 | } |
| 965 | return KAL_TRUE; |
| 966 | } |
| 967 | |
| 968 | if (ecc_custom_verify_emergency_number_with_suffix(ecc_verify, ecc_nvram_number[i].ecc_number)) |
| 969 | { |
| 970 | if (verify_detail != NULL) *verify_detail = ECC_FULLY_MATCH; |
| 971 | if (ecc_category != NULL) *ecc_category = ecc_nvram_number[i].ecc_category; |
| 972 | |
| 973 | sim_with_ecc_num_case = ecc_custom_is_sim_with_ecc_num(call_type, ecc_nvram_number[i].ecc_always); |
| 974 | |
| 975 | if (sim_with_ecc_num_case != 0) |
| 976 | { |
| 977 | sim_with_ecc_num_case = 0; |
| 978 | return KAL_FALSE; |
| 979 | } |
| 980 | return KAL_TRUE; |
| 981 | } |
| 982 | |
| 983 | if (verify_detail != NULL && kal_dchar_strncmp((char*) ecc_nvram_number[i].ecc_number, (char*) ecc_verify, kal_dchar_strlen((char*) ecc_verify)) == 0) |
| 984 | { |
| 985 | *verify_detail = ECC_PARTIALLY_MATCH; |
| 986 | } |
| 987 | } |
| 988 | |
| 989 | /* Korea Operator Requirements not use default number */ |
| 990 | if(sbp_query_md_feature_by_ps(SBP_KOR_CUSTOMIZATION, (protocol_id_enum)phb_which_sim_ex()) == KAL_TRUE) |
| 991 | { |
| 992 | return KAL_FALSE; |
| 993 | } |
| 994 | |
| 995 | /* verify default record finally */ |
| 996 | for (i = 0; ecc_default_num_p[i * (ECC_CUSTOM_DEFAULT_ECC_LENGTH + 1)] != 0x00; i++) |
| 997 | { |
| 998 | sim_with_ecc_num_case = ecc_custom_is_sim_with_ecc_num(call_type, (kal_bool) ecc_default_num_p[i * (ECC_CUSTOM_DEFAULT_ECC_LENGTH + 1 ) + ECC_CUSTOM_DEFAULT_ECC_LENGTH]); |
| 999 | |
| 1000 | if (sim_with_ecc_num_case != 0) |
| 1001 | { |
| 1002 | sim_with_ecc_num_case = 0; |
| 1003 | continue; |
| 1004 | } |
| 1005 | |
| 1006 | if (kal_dchar_strcmp((char*) ecc_verify, (char*) (ecc_default_num_p + i * (ECC_CUSTOM_DEFAULT_ECC_LENGTH + 1))) == 0) |
| 1007 | { |
| 1008 | if (verify_detail != NULL) *verify_detail = ECC_FULLY_MATCH; |
| 1009 | |
| 1010 | return KAL_TRUE; |
| 1011 | } |
| 1012 | |
| 1013 | if (ecc_custom_verify_emergency_number_with_suffix(ecc_verify, (kal_uint8*) (ecc_default_num_p + i * (ECC_CUSTOM_DEFAULT_ECC_LENGTH + 1)))) |
| 1014 | { |
| 1015 | if (verify_detail != NULL) *verify_detail = ECC_FULLY_MATCH; |
| 1016 | |
| 1017 | return KAL_TRUE; |
| 1018 | } |
| 1019 | |
| 1020 | if (verify_detail != NULL && kal_dchar_strncmp((char*) (ecc_default_num_p + i * (ECC_CUSTOM_DEFAULT_ECC_LENGTH + 1)), (char*) ecc_verify, kal_dchar_strlen((char*) ecc_verify)) == 0) |
| 1021 | { |
| 1022 | *verify_detail = ECC_PARTIALLY_MATCH; |
| 1023 | } |
| 1024 | } |
| 1025 | |
| 1026 | return KAL_FALSE; |
| 1027 | } |
| 1028 | |
| 1029 | |
| 1030 | /***************************************************************************** |
| 1031 | * FUNCTION |
| 1032 | * ecc_custom_update_emergency_number |
| 1033 | * DESCRIPTION |
| 1034 | * Update ECC pool from applications |
| 1035 | * PARAMETERS |
| 1036 | * number [IN] input ECC number |
| 1037 | * num_encoding [IN] input ECC number coding scheme |
| 1038 | * ecc_src [IN] input ECC number source |
| 1039 | * ecc_category [IN] input ECC number category (REL5 only) |
| 1040 | * ecc_display [IN] input ECC number display string (REL5 only) |
| 1041 | * index [IN] input ECC number index (ex: 1 ~ 5) |
| 1042 | * total [IN] input ECC number total (ex: 5) |
| 1043 | * RETURNS |
| 1044 | * void |
| 1045 | *****************************************************************************/ |
| 1046 | void ecc_custom_update_emergency_number( |
| 1047 | kal_uint8 *number, |
| 1048 | ecc_num_encoding_enum num_encoding, |
| 1049 | ecc_src_type_enum ecc_src, |
| 1050 | kal_uint8 ecc_category, |
| 1051 | kal_uint8 *ecc_display, |
| 1052 | kal_uint8 index, |
| 1053 | kal_uint8 total) |
| 1054 | { |
| 1055 | /*----------------------------------------------------------------*/ |
| 1056 | /* Local Variables */ |
| 1057 | /*----------------------------------------------------------------*/ |
| 1058 | ecc_record_struct *sim_context; |
| 1059 | ecc_record_struct *nw_context; |
| 1060 | |
| 1061 | /*----------------------------------------------------------------*/ |
| 1062 | /* Code Body */ |
| 1063 | /*----------------------------------------------------------------*/ |
| 1064 | if (index <= 0 || index > total) |
| 1065 | { |
| 1066 | return; |
| 1067 | } |
| 1068 | |
| 1069 | if (number != NULL && *number == 0xFF) |
| 1070 | { |
| 1071 | return; /* skip invalid entry */ |
| 1072 | } |
| 1073 | |
| 1074 | switch (ecc_src) |
| 1075 | { |
| 1076 | case ECC_SRC_SIM1: |
| 1077 | #if defined(__GEMINI__) |
| 1078 | case ECC_SRC_SIM2: |
| 1079 | #if (GEMINI_PLUS >= 3) // Gemini+ |
| 1080 | case ECC_SRC_SIM3: |
| 1081 | #if (GEMINI_PLUS >= 4) // Gemini+ |
| 1082 | case ECC_SRC_SIM4: |
| 1083 | #endif |
| 1084 | #endif |
| 1085 | #endif /* __GEMINI__ */ |
| 1086 | sim_context = ecc_custom_get_sim_context(index - 1, ecc_src - ECC_SRC_SIM1); |
| 1087 | if (number != NULL) |
| 1088 | { |
| 1089 | ecc_custom_prepare_number(sim_context->ecc_number, number, num_encoding); |
| 1090 | sim_context->ecc_category = ecc_category; |
| 1091 | } |
| 1092 | break; |
| 1093 | |
| 1094 | case ECC_SRC_NW1: |
| 1095 | #if defined(__GEMINI__) |
| 1096 | case ECC_SRC_NW2: |
| 1097 | #if (GEMINI_PLUS >= 3) // Gemini+ |
| 1098 | case ECC_SRC_NW3: |
| 1099 | #if (GEMINI_PLUS >= 4) // Gemini+ |
| 1100 | case ECC_SRC_NW4: |
| 1101 | #endif |
| 1102 | #endif |
| 1103 | #endif /* __GEMINI__ */ |
| 1104 | if (number != NULL) |
| 1105 | { |
| 1106 | nw_context = ecc_custom_get_nw_context(index - 1, ecc_src - ECC_SRC_NW1); |
| 1107 | ecc_custom_prepare_number(nw_context->ecc_number, number, num_encoding); |
| 1108 | nw_context->ecc_category = ecc_category; |
| 1109 | } |
| 1110 | break; |
| 1111 | |
| 1112 | case ECC_SRC_NVRAM: |
| 1113 | break; |
| 1114 | |
| 1115 | default: |
| 1116 | break; |
| 1117 | } |
| 1118 | } |
| 1119 | |
| 1120 | |
| 1121 | /***************************************************************************** |
| 1122 | * FUNCTION |
| 1123 | * ecc_custom_update_emergency_number |
| 1124 | * DESCRIPTION |
| 1125 | * Update ECC pool from applications |
| 1126 | * PARAMETERS |
| 1127 | * number [IN] input ECC number |
| 1128 | * num_encoding [IN] input ECC number coding scheme |
| 1129 | * ecc_src [IN] input ECC number source |
| 1130 | * ecc_category [IN] input ECC number category (REL5 only) |
| 1131 | * ecc_display [IN] input ECC number display string (REL5 only) |
| 1132 | * index [IN] input ECC number index (ex: 1 ~ 5) |
| 1133 | * total [IN] input ECC number total (ex: 5) |
| 1134 | * RETURNS |
| 1135 | * void |
| 1136 | *****************************************************************************/ |
| 1137 | ecc_update_result_enum ecc_custom_update_emergency_number_ex( |
| 1138 | kal_uint8 *number, |
| 1139 | ecc_num_encoding_enum num_encoding, |
| 1140 | kal_uint8 ecc_category, |
| 1141 | kal_bool ecc_always) |
| 1142 | { |
| 1143 | /*----------------------------------------------------------------*/ |
| 1144 | /* Local Variables */ |
| 1145 | /*----------------------------------------------------------------*/ |
| 1146 | kal_uint8 index; |
| 1147 | kal_uint8 ecc_buffer[(ECC_CUSTOM_MAX_BCD_LENGTH * 2 + 1) * ENCODING_LENGTH] = {0}; |
| 1148 | kal_uint8 ecc_tmp[ECC_CUSTOM_MAX_BCD_LENGTH * 2 + 1] = {0}; |
| 1149 | |
| 1150 | /*----------------------------------------------------------------*/ |
| 1151 | /* Code Body */ |
| 1152 | /*----------------------------------------------------------------*/ |
| 1153 | if (number == NULL) |
| 1154 | { |
| 1155 | return ECC_RESULT_INVALID_ENTRY; |
| 1156 | } |
| 1157 | |
| 1158 | // for backward compatible |
| 1159 | ecc_default_num_p = (kal_uint16 *)ecc_3gpp_num; |
| 1160 | |
| 1161 | switch (num_encoding) |
| 1162 | { |
| 1163 | case ECC_ENCODING_ANSII: |
| 1164 | ecc_custom_str_n_to_ucs2_str((kal_int8*) ecc_buffer, (kal_int8*) number, ECC_CUSTOM_MAX_BCD_LENGTH * 2); |
| 1165 | break; |
| 1166 | case ECC_ENCODING_UCS2: |
| 1167 | kal_dchar_strncpy((char*) ecc_buffer, (char*) number, ECC_CUSTOM_MAX_BCD_LENGTH * 4); |
| 1168 | break; |
| 1169 | case ECC_ENCODING_BCD: |
| 1170 | ecc_custom_decode_bcd_2_ansii(ecc_tmp, number); |
| 1171 | ecc_custom_str_n_to_ucs2_str((kal_int8*) ecc_buffer, (kal_int8*) ecc_tmp, ECC_CUSTOM_MAX_BCD_LENGTH * 2); |
| 1172 | break; |
| 1173 | default: |
| 1174 | return ECC_RESULT_INVALID_ENTRY; |
| 1175 | } |
| 1176 | |
| 1177 | if (kal_dchar_strlen((char*) ecc_buffer) == 0) |
| 1178 | { |
| 1179 | return ECC_RESULT_INVALID_ENTRY; |
| 1180 | } |
| 1181 | |
| 1182 | for (index = 0; index < ECC_CUSTOM_MAX_NVRAM_RECORD; index++) |
| 1183 | { |
| 1184 | if (kal_dchar_strlen((char*) ecc_nvram_number[index].ecc_number) == 0 || kal_dchar_strcmp((char*) ecc_buffer, (char*) ecc_nvram_number[index].ecc_number) == 0) |
| 1185 | { |
| 1186 | break; |
| 1187 | } |
| 1188 | } |
| 1189 | |
| 1190 | if (index >= ECC_CUSTOM_MAX_NVRAM_RECORD) |
| 1191 | { |
| 1192 | return ECC_RESULT_CAPACITY_EXCEEDED; |
| 1193 | } |
| 1194 | |
| 1195 | ecc_custom_prepare_number(ecc_nvram_number[index].ecc_number, number, num_encoding); |
| 1196 | ecc_nvram_number[index].ecc_category = ecc_category; |
| 1197 | ecc_nvram_number[index].ecc_always = ecc_always; |
| 1198 | |
| 1199 | return ECC_RESULT_OK; |
| 1200 | } |
| 1201 | |
| 1202 | |
| 1203 | /***************************************************************************** |
| 1204 | * FUNCTION |
| 1205 | * ecc_custom_get_first_2_default_num |
| 1206 | * DESCRIPTION |
| 1207 | * Get ECC pool first 2 default items |
| 1208 | * PARAMETERS |
| 1209 | * ecc_num1 [IN] return ECC number |
| 1210 | * ecc_num2 [IN] return ECC number |
| 1211 | * RETURNS |
| 1212 | * void |
| 1213 | *****************************************************************************/ |
| 1214 | void ecc_custom_get_first_2_default_num( |
| 1215 | kal_uint8 **ecc_num1, |
| 1216 | kal_uint8 **ecc_num2) |
| 1217 | { |
| 1218 | /*----------------------------------------------------------------*/ |
| 1219 | /* Local Variables */ |
| 1220 | /*----------------------------------------------------------------*/ |
| 1221 | |
| 1222 | /*----------------------------------------------------------------*/ |
| 1223 | /* Code Body */ |
| 1224 | /*----------------------------------------------------------------*/ |
| 1225 | *ecc_num1 = (kal_uint8*) (&ecc_default_num[0][0]); |
| 1226 | *ecc_num2 = (kal_uint8*) (&ecc_default_num[1][0]); |
| 1227 | } |
| 1228 | |
| 1229 | |
| 1230 | /***************************************************************************** |
| 1231 | * FUNCTION |
| 1232 | * ecc_custom_support_enhance_retry |
| 1233 | * DESCRIPTION |
| 1234 | * if support ECC enhancement retry, return true |
| 1235 | * PARAMETERS |
| 1236 | * RETURNS |
| 1237 | * kal_bool |
| 1238 | *****************************************************************************/ |
| 1239 | kal_bool ecc_custom_support_enhance_retry(void) |
| 1240 | { |
| 1241 | kal_bool support; |
| 1242 | |
| 1243 | #ifdef __ECC_RETRY_ENHANCEMENT__ |
| 1244 | support = KAL_TRUE; |
| 1245 | #else |
| 1246 | support = KAL_FALSE; |
| 1247 | #endif |
| 1248 | |
| 1249 | return support; |
| 1250 | } |
| 1251 | /***************************************************************************** |
| 1252 | * FUNCTION |
| 1253 | * ecc_custom_reset_sim_context |
| 1254 | * DESCRIPTION |
| 1255 | * Update ECC pool from applications |
| 1256 | * PARAMETERS |
| 1257 | * ecc_src [IN] input ECC number source |
| 1258 | * RETURNS |
| 1259 | * void |
| 1260 | *****************************************************************************/ |
| 1261 | void ecc_custom_reset_sim_context(ecc_src_type_enum ecc_src) |
| 1262 | { |
| 1263 | /*----------------------------------------------------------------*/ |
| 1264 | /* Local Variables */ |
| 1265 | /*----------------------------------------------------------------*/ |
| 1266 | ecc_record_struct *sim_context; |
| 1267 | kal_uint8 i; |
| 1268 | /*----------------------------------------------------------------*/ |
| 1269 | /* Code Body */ |
| 1270 | /*----------------------------------------------------------------*/ |
| 1271 | for(i = 0; i < ECC_CUSTOM_MAX_SIM_RECORD; i++) |
| 1272 | { |
| 1273 | sim_context = ecc_custom_get_sim_context(i, ecc_src - ECC_SRC_SIM1); |
| 1274 | kal_mem_set(sim_context, 0, sizeof(ecc_record_struct)); |
| 1275 | } |
| 1276 | |
| 1277 | } |
| 1278 | |
| 1279 | /***************************************************************************** |
| 1280 | * FUNCTION |
| 1281 | * ecc_custom_reset_nw_context |
| 1282 | * DESCRIPTION |
| 1283 | * Update ECC pool from applications |
| 1284 | * PARAMETERS |
| 1285 | * ecc_src [IN] input ECC number source |
| 1286 | * RETURNS |
| 1287 | * void |
| 1288 | *****************************************************************************/ |
| 1289 | void ecc_custom_reset_nw_context(ecc_src_type_enum ecc_src) |
| 1290 | { |
| 1291 | /*----------------------------------------------------------------*/ |
| 1292 | /* Local Variables */ |
| 1293 | /*----------------------------------------------------------------*/ |
| 1294 | ecc_record_struct *nw_context; |
| 1295 | kal_uint8 i; |
| 1296 | /*----------------------------------------------------------------*/ |
| 1297 | /* Code Body */ |
| 1298 | /*----------------------------------------------------------------*/ |
| 1299 | for(i = 0; i < ECC_CUSTOM_MAX_NW_RECORD; i++) |
| 1300 | { |
| 1301 | nw_context = ecc_custom_get_nw_context(i, ecc_src - ECC_SRC_NW1); |
| 1302 | kal_mem_set(nw_context, 0, sizeof(ecc_record_struct)); |
| 1303 | } |
| 1304 | |
| 1305 | } |
| 1306 | |
| 1307 | void ecc_custom_swap_nw_context(void) |
| 1308 | { |
| 1309 | /*----------------------------------------------------------------*/ |
| 1310 | /* Local Variables */ |
| 1311 | /*----------------------------------------------------------------*/ |
| 1312 | ecc_record_struct *nw_context1, *nw_context2, temp; |
| 1313 | kal_uint8 i; |
| 1314 | /*----------------------------------------------------------------*/ |
| 1315 | /* Code Body */ |
| 1316 | /*----------------------------------------------------------------*/ |
| 1317 | for(i = 0; i < ECC_CUSTOM_MAX_NW_RECORD; i++) |
| 1318 | { |
| 1319 | nw_context1 = ecc_custom_get_nw_context(i, ECC_SIM1_CALL); |
| 1320 | nw_context2 = ecc_custom_get_nw_context(i, ECC_SIM2_CALL); |
| 1321 | |
| 1322 | memcpy(&temp, nw_context1, sizeof(ecc_record_struct)); |
| 1323 | memcpy(nw_context1, nw_context2, sizeof(ecc_record_struct)); |
| 1324 | memcpy(nw_context2, &temp, sizeof(ecc_record_struct)); |
| 1325 | } |
| 1326 | } |
| 1327 | |
| 1328 | void* phb_get_fdn_ecc_as_normal_tbl(void) |
| 1329 | { |
| 1330 | return (void*)&fdn_ecc_as_normal[0]; |
| 1331 | } |
| 1332 | |
| 1333 | /* __KOR_CUSTOMIZATION__ */ |
| 1334 | /***************************************************************************** |
| 1335 | * FUNCTION |
| 1336 | * is_ecc_custom_kor_operator_barred_num |
| 1337 | * DESCRIPTION |
| 1338 | * KOR operator requirements - skip 127 in SIM EFecc |
| 1339 | * PARAMETERS |
| 1340 | * number [IN] input ECC number |
| 1341 | * num_encoding [IN] input ECC number coding scheme |
| 1342 | * RETURNS |
| 1343 | * boolean |
| 1344 | *****************************************************************************/ |
| 1345 | kal_bool is_ecc_custom_kor_operator_barred_num( |
| 1346 | kal_uint8 * number, |
| 1347 | ecc_num_encoding_enum num_encoding ) |
| 1348 | { |
| 1349 | kal_uint8 ecc_number[(ECC_CUSTOM_MAX_BCD_LENGTH * 2 + 1) * 2 /*ENCODING_LENGTH*/]; /* in UCS2, max bytes: 14 */ |
| 1350 | kal_uint16 ecc_barred_number[] = {0x0031, 0x0032, 0x0037, 0x0000 }; /* KOR operator requirement barring 127 */ |
| 1351 | |
| 1352 | if (number != NULL ) |
| 1353 | { |
| 1354 | ecc_custom_prepare_number(ecc_number, number, num_encoding); |
| 1355 | if (kal_dchar_strcmp((char*) ecc_number, (char*) ecc_barred_number) == 0) |
| 1356 | { |
| 1357 | return KAL_TRUE; |
| 1358 | } |
| 1359 | } |
| 1360 | return KAL_FALSE; |
| 1361 | } |
| 1362 | /* __KOR_CUSTOMIZATION__ */ |