rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [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) 2005 |
| 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 | * atp_public_utility.h |
| 40 | * |
| 41 | * |
| 42 | * Description: |
| 43 | * ------------ |
| 44 | * This file contains the function prototype for |
| 45 | * AT PROXY module utility functions. |
| 46 | * |
| 47 | * Author: |
| 48 | * ------- |
| 49 | * ------- |
| 50 | * |
| 51 | *******************************************************************************/ |
| 52 | |
| 53 | |
| 54 | #ifndef _ATP_PUBLIC_UTILITY_H |
| 55 | #define _ATP_PUBLIC_UTILITY_H |
| 56 | |
| 57 | #include "kal_general_types.h" |
| 58 | #include "atp_public_defs.h" |
| 59 | #include "sim_exported_enum.h" |
| 60 | |
| 61 | |
| 62 | #define ATP_VALIDATOR_OK 0 |
| 63 | #define ATP_VALIDATOR_ERROR 255 |
| 64 | |
| 65 | #define ATP_IS_NUMBER( alpha_char ) \ |
| 66 | ( ( (alpha_char >= ATP_CHAR_0) && (alpha_char <= ATP_CHAR_9) ) ? 1 : 0 ) |
| 67 | |
| 68 | #define ATP_IS_LOWER( alpha_char ) \ |
| 69 | ( ( (alpha_char >= atp_char_a) && (alpha_char <= atp_char_z) ) ? 1 : 0 ) |
| 70 | |
| 71 | #define ATP_IS_UPPER( alpha_char ) \ |
| 72 | ( ( (alpha_char >= ATP_CHAR_A) && (alpha_char <= ATP_CHAR_Z) ) ? 1 : 0 ) |
| 73 | |
| 74 | #define ATP_IS_ALPHA( alpha_char ) \ |
| 75 | ( ( ATP_IS_UPPER(alpha_char) || ATP_IS_LOWER(alpha_char) ) ? 1 : 0 ) |
| 76 | |
| 77 | #define atp_skip_spaces(source_string_ptr) \ |
| 78 | while ((source_string_ptr->index < source_string_ptr->string_length) \ |
| 79 | && (source_string_ptr->string_ptr[source_string_ptr->index] == ATP_SPACE)) \ |
| 80 | { \ |
| 81 | source_string_ptr->index++; \ |
| 82 | } |
| 83 | #define atp_skip_none_a(atp_string_ptr) \ |
| 84 | while( (atp_string_ptr->index < atp_string_ptr->string_length) && !((atp_string_ptr->string_ptr[ atp_string_ptr->index ] == ATP_CHAR_A) ||\ |
| 85 | (atp_string_ptr->string_ptr[ atp_string_ptr->index ] == atp_char_a)) ) \ |
| 86 | { \ |
| 87 | atp_string_ptr->index++; \ |
| 88 | } |
| 89 | |
| 90 | void atp_to_upper(kal_uint8 *str, kal_uint16 str_len); |
| 91 | |
| 92 | kal_uint32 atp_int_validator_ext(kal_uint8 *error_cause, |
| 93 | atp_string_struct *source_string_ptr, |
| 94 | kal_uint8 delimiter, |
| 95 | kal_uint16 str_len); |
| 96 | |
| 97 | kal_int32 atp_signed_int_validator(kal_uint8 *error_cause, atp_string_struct *source_string_ptr, kal_uint8 delimiter); |
| 98 | |
| 99 | kal_uint8 atp_hex_validator_ext(kal_uint8 *error_cause, |
| 100 | atp_string_struct *source_string_ptr, |
| 101 | kal_uint8 delimiter, |
| 102 | kal_uint16 max_length, |
| 103 | kal_uint8 *str); |
| 104 | |
| 105 | kal_uint8 atp_string_validator_ext(kal_uint8 *error_cause, |
| 106 | atp_string_struct *source_string_ptr, |
| 107 | kal_uint16 source_string_len, |
| 108 | kal_uint8 delimiter, |
| 109 | kal_uint16 max_length, |
| 110 | kal_uint8 *str); |
| 111 | |
| 112 | kal_uint32 atp_extract_number_ext(atp_string_struct *source_string_ptr, |
| 113 | atp_validator_cause_enum *result, |
| 114 | kal_uint32 max); |
| 115 | |
| 116 | void atp_int_to_ascii_converter(kal_uint32 digit, kal_uint8 *buff_ptr); |
| 117 | |
| 118 | kal_uint16 atp_fast_string_print(kal_uint8 *buff_ptr, |
| 119 | kal_uint8 *fmt, |
| 120 | void *arg_list[], |
| 121 | kal_uint8 nos_arg); |
| 122 | |
| 123 | kal_bool atp_hexstring_to_integer(kal_char *str, kal_uint32 *val); |
| 124 | |
| 125 | kal_bool atp_hexstring_to_integer_ext(kal_char *str, kal_uint32 *val, kal_uint16 str_len); |
| 126 | |
| 127 | kal_bool atp_hexstring_to_bytes(kal_char *str, kal_uint8 *val, kal_uint16 val_buf_size); |
| 128 | |
| 129 | // TODO:_Hong_ replace IMSP and RMMI utility functions by above utilities |
| 130 | |
| 131 | kal_uint32 atp_int_validator_range_check( |
| 132 | kal_uint8 *error_cause, |
| 133 | atp_string_struct *source_string_ptr, |
| 134 | kal_uint8 delimiter, |
| 135 | kal_uint32 max); |
| 136 | |
| 137 | |
| 138 | /***************************************************************************** |
| 139 | * FUNCTION |
| 140 | * atp_check_at_prefix |
| 141 | * |
| 142 | * DESCRIPTION |
| 143 | * check the input string begins with "AT" |
| 144 | * |
| 145 | * PARAMETERS |
| 146 | * str_ptr [IN] ASCII string |
| 147 | * str_len [IN] length of *str_ptr |
| 148 | * |
| 149 | * RETURNS |
| 150 | * KAL_TRUE/KAL_FALSE depends on success or fail. |
| 151 | * |
| 152 | *****************************************************************************/ |
| 153 | kal_bool atp_check_at_prefix(kal_uint8 *str_ptr, kal_uint16 str_len); |
| 154 | |
| 155 | /***************************************************************************** |
| 156 | * FUNCTION |
| 157 | * l4b_atp_find_cmd_mode |
| 158 | * |
| 159 | * DESCRIPTION |
| 160 | * find the command mode of *at_cmd_ptr |
| 161 | * |
| 162 | * PARAMETERS |
| 163 | * at_cmd_ptr [IN] ASCII string |
| 164 | * at_cmd_len [IN] length of *at_cmd_ptr |
| 165 | * |
| 166 | * RETURNS |
| 167 | * atp_cmd_mode_enum the command mode of *at_cmd_ptr |
| 168 | * |
| 169 | *****************************************************************************/ |
| 170 | atp_cmd_mode_enum l4b_atp_find_cmd_mode(atp_string_struct *at_cmd_ptr); |
| 171 | |
| 172 | /***************************************************************************** |
| 173 | * FUNCTION |
| 174 | * atp_get_urc_report_mode |
| 175 | * DESCRIPTION |
| 176 | * This function is used to get URC report mode value |
| 177 | * PARAMETERS |
| 178 | * ps_id [IN] which protocol id |
| 179 | * urc_type [IN] which URC's report mode you want to know |
| 180 | * RETURNS |
| 181 | * URC's report mode value is returned. |
| 182 | *****************************************************************************/ |
| 183 | kal_uint8 atp_get_urc_report_mode(protocol_id_enum ps_id, atp_urc_report_mode_enum urc_type); |
| 184 | |
| 185 | /***************************************************************************** |
| 186 | * FUNCTION |
| 187 | * atp_set_urc_report_mode |
| 188 | * DESCRIPTION |
| 189 | * This function is used to set URC report mode value |
| 190 | * PARAMETERS |
| 191 | * urc_type [IN] which URC's report mode value you want to set |
| 192 | * mode [IN] the value to be set. |
| 193 | * RETURNS |
| 194 | * void |
| 195 | *****************************************************************************/ |
| 196 | void atp_set_urc_report_mode(atp_urc_report_mode_enum urc_type, kal_uint8 mode); |
| 197 | |
| 198 | #ifdef __SENSITIVE_DATA_MOSAIC__ |
| 199 | /***************************************************************************** |
| 200 | * FUNCTION |
| 201 | * atp_copy_partial_string |
| 202 | * DESCRIPTION |
| 203 | * This function is used to mask the trace output |
| 204 | * PARAMETERS |
| 205 | * in_str_ptr [IN] Input string |
| 206 | * in_str_len [IN] Input string length |
| 207 | * at_str_ptr [IN] AT output string |
| 208 | * at_str_len [IN] AT output string length |
| 209 | * RETURNS |
| 210 | * void |
| 211 | *****************************************************************************/ |
| 212 | void atp_copy_partial_string(kal_uint8 *in_str_ptr, kal_uint16 in_str_len, kal_uint8 *at_str_ptr, kal_uint16 at_str_len); |
| 213 | |
| 214 | /***************************************************************************** |
| 215 | * FUNCTION |
| 216 | * atp_usir_command_analyzer |
| 217 | * DESCRIPTION |
| 218 | * This function is used to find sensitive AT cmd |
| 219 | * PARAMETERS |
| 220 | * hash_value1 [IN] hash_value1 for at command |
| 221 | * hash_value2 [IN] hash_value2 for at command |
| 222 | * index [IN] index of table for return |
| 223 | * RETURNS |
| 224 | * void |
| 225 | *****************************************************************************/ |
| 226 | kal_bool atp_usir_command_analyzer(kal_uint32 hash_value1, kal_uint32 hash_value2, kal_uint8 *index); |
| 227 | |
| 228 | /***************************************************************************** |
| 229 | * FUNCTION |
| 230 | * atp_check_sensitive_command |
| 231 | * DESCRIPTION |
| 232 | * This function is used to check sensitive AT cmd |
| 233 | * PARAMETERS |
| 234 | * buffer * [IN] command string pointer |
| 235 | * row_index [IN] index of table for return |
| 236 | * RETURNS |
| 237 | * kal_bool [OUT] find the command or not |
| 238 | *****************************************************************************/ |
| 239 | kal_bool atp_check_sensitive_command(kal_uint8 *buffer, kal_uint8 *row_index); |
| 240 | |
| 241 | /***************************************************************************** |
| 242 | * FUNCTION |
| 243 | * atp_public_usir_process_ft |
| 244 | * DESCRIPTION |
| 245 | * This function is used to check sensitive AT cmd |
| 246 | * PARAMETERS |
| 247 | * buffer * [IN] command string pointer |
| 248 | * row_index [IN] index of table for return |
| 249 | * RETURNS |
| 250 | * kal_bool [OUT] process the command or not |
| 251 | *****************************************************************************/ |
| 252 | kal_bool atp_public_usir_process_ft(kal_uint8 *buffer, kal_uint8 row_index); |
| 253 | |
| 254 | #endif /* __SENSITIVE_DATA_MOSAIC__ */ |
| 255 | |
| 256 | #endif /* _ATP_PUBLIC_UTILITY_H */ |