blob: cbad770c2be248399939aefe1c4b718e2d60c822 [file] [log] [blame]
/*--------------------------------------------------------------------------------------------------------------------
(C) Copyright 2006, 2007 Marvell DSPC Ltd. All Rights Reserved.
-------------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------------
* INTEL CONFIDENTIAL
* Copyright 2006 Intel Corporation All Rights Reserved.
* The source code contained or described herein and all documents related to the source code (Material) are owned
* by Intel Corporation or its suppliers or licensors. Title to the Material remains with Intel Corporation or
* its suppliers and licensors. The Material contains trade secrets and proprietary and confidential information of
* Intel or its suppliers and licensors. The Material is protected by worldwide copyright and trade secret laws and
* treaty provisions. No part of the Material may be used, copied, reproduced, modified, published, uploaded, posted,
* transmitted, distributed, or disclosed in any way without Intels prior express written permission.
*
* No license under any patent, copyright, trade secret or other intellectual property right is granted to or
* conferred upon you by disclosure or delivery of the Materials, either expressly, by implication, inducement,
* estoppel or otherwise. Any license under such intellectual property rights must be express and approved by
* Intel in writing.
* -------------------------------------------------------------------------------------------------------------------
*
* Filename: telutl.h
*
* Description: header file for utility functions for Telephony Controller
*
* History:
* May 19, 2006 - Creation of file
*
* Notes:
*
******************************************************************************/
#ifndef TELUTL_H
#define TELUTL_H
#include <linux_types.h>
#include <telatci.h>
#include <tel3gdef.h>
#include <teldef.h>
#include "utlAtParser.h"
#define NULL_CHAR ('\0')
#define Gsm7bit_Ascii_Num 34
#define Gsm7bit_Ascii_2bytes_Num 19
#define SPACE_CHAR 0x20
#define NUM_GSM_ESCAPED ( sizeof( def_gsm_ext ) / sizeof( def_gsm_ext[0] ) )
extern BOOL g_isCbm;
BOOL getErrorRatioParam( const utlAtParameterValue_P2c param_value_p,
int index,
ErrorRatioLookup *errorRatioLookup_p,
INT32 defaultValue,
INT32 *ratio_p);
BOOL atParamToCiEnum(const utlAtParameterValue_P2c param_value_p,
int index,
int *param_p,
int DefaultValue,
EnumParamLookup *enumParamLookup_p);
BOOL operStringToPlmn( CHAR *plmnString_p, Plmn *convertedPlmn, INT16 plmnStringLen );
BOOL isValidCiSsClass( UINT16 *CiSsClass );
BOOL HexToBin(const char *input, int *output, int maxLen);
BOOL getExtendedParameter(INT32 inValue,
INT32 *value_p,
INT32 DefaultValue);
BOOL getExtValue( const utlAtParameterValue_P2c param_value_p,
int index,
int *value_p,
int minValue,
int maxValue,
int DefaultValue);
BOOL getExtUValue(const utlAtParameterValue_P2c param_value_p,int index,unsigned int *value_p,unsigned int minValue,unsigned int maxValue, unsigned int DefaultValue);
BOOL getExtendedString( CHAR *inString,
CHAR *outString,
INT16 maxStringLength,
INT16 *outStringLength);
BOOL getExtString( const utlAtParameterValue_P2c param_value_p,
int index,
CHAR *outString,
INT16 maxStringLength,
INT16 *outStringLength,
CHAR *defaultString);
CiAddrNumType DialNumTypeGSM2CI( INT32 GSMType );
INT32 DialNumTypeCI2GSM( CiAddrNumType CiType);
BOOL checkForNumericOnlyChars(const CHAR *password);
CiAddrNumType DialNumTypeGSM2CI( INT32 GSMType );
INT8 hexToNum(CHAR ch);
void string2BCD(UINT8* pp, char *tempBuf, UINT8 length);
BOOL str2NumericList( CHAR *str, CiNumericList *numList );
void PrintNumericList( const CiNumericList * pList, CHAR* targetStr );
int pb_encode_alpha_tag(const unsigned short *in, int in_len, unsigned char *out, int out_len);
int pb_decode_alpha_tag(const unsigned char *in, int in_len, unsigned short *out, int out_len);
int pb_encode_character(char *in, int in_len, AtciCharacterSet in_chset, char *out, int out_len);
int pb_decode_character(char *in, int in_len, char *out, int out_len, AtciCharacterSet out_chset);
enum string_binary_type
{
STR_BIN_TYPE_IRA,
STR_BIN_TYPE_HEX,
STR_BIN_TYPE_UCS2,
STR_BIN_TYPE_GSM
};
int libConvertIraBinToCSCSString(const void *in, int in_len, char *out, int out_len, AtciCharacterSet out_chset, UINT8 dcs);
int libConvertBinToCSCSString(const void *in, int in_len, enum string_binary_type bin_type, char *out, int out_len, AtciCharacterSet out_chset);
UINT16 libConvertCSCSStringToIraBin(const char *in, int in_len, AtciCharacterSet in_chset, void *out, int out_len, UINT8 dcs);
int libConvertCSCSStringToBin(const char *in, int in_len, AtciCharacterSet in_chset, void *out, int out_len, enum string_binary_type bin_type);
void convertBetweenGsm8andIra(int mode, CHAR* inBuf, int inLength, CHAR* outBuf, UINT16* outBufLength);
/*
* convert IRA strings to CSCS string according to out_chset
*/
#define libConvertIRAToCSCSString(in, in_len, out, out_len, out_chset) \
libConvertBinToCSCSString(in, in_len, STR_BIN_TYPE_IRA, out, out_len, out_chset)
/*
* convert in_chset coded CSCS string to IRA string
*/
#define libConvertCSCSStringToIRA(in, in_len, in_chset, out, out_len) \
libConvertCSCSStringToBin(in, in_len, in_chset, out, out_len, STR_BIN_TYPE_IRA)
/*
* convert UCS2 string to CSCS string according to out_chset
*/
#define libConvertUCS2ToCSCSString(in, in_len, out, out_len, out_chset) \
libConvertBinToCSCSString(in, in_len, STR_BIN_TYPE_UCS2, out, out_len, out_chset)
/*
* convert in_chset coded CSCS string to UCS2 string
*/
#define libConvertCSCSStringToUCS2(in, in_len, in_chset, out, out_len) \
libConvertCSCSStringToBin(in, in_len, in_chset, out, out_len, STR_BIN_TYPE_UCS2)
/*
* convert HEX strings to CSCS string according to out_chset
*/
#define libConvertHEXToCSCSString(in, in_len, out, out_len, out_chset) \
libConvertBinToCSCSString(in, in_len, STR_BIN_TYPE_HEX, out, out_len, out_chset)
/*
* convert in_chset coded CSCS string to HEX string
*/
#define libConvertCSCSStringToHEX(in, in_len, in_chset, out, out_len) \
libConvertCSCSStringToBin(in, in_len, in_chset, out, out_len, STR_BIN_TYPE_HEX)
/*
* convert GSM strings to CSCS string according to out_chset
*/
#define libConvertGSMToCSCSString(in, in_len, out, out_len, out_chset) \
libConvertBinToCSCSString(in, in_len, STR_BIN_TYPE_GSM, out, out_len, out_chset)
/*
* convert in_chset coded CSCS string to GSM string
*/
#define libConvertCSCSStringToGSM(in, in_len, in_chset, out, out_len) \
libConvertCSCSStringToBin(in, in_len, in_chset, out, out_len, STR_BIN_TYPE_GSM)
BOOL libGetAddrInfo_ (const CHAR *addrStr, int addrType, CiAddressInfo *pAddr);
BOOL libGetAddrInfo (const utlAtParameterValue_P2c parameter_values_p,
int index,
int max_address_len,
const CHAR *default_address,
int min_subaddrType,
int max_subaddrType,
int default_addrType,
CiAddressInfo *pAddr);
BOOL libGetSubaddrInfo (const utlAtParameterValue_P2c parameter_values_p,
int index,
int max_subaddress_len,
const CHAR *default_subaddress,
int min_subaddrType,
int max_subaddrType,
int default_subaddrType,
CiSubaddrInfo *pSubaddr);
struct mccmnc
{
unsigned short mcc;
unsigned short mnc;
};
struct opname
{
struct mccmnc mccmnc;
const char *short_alpha;
const char *long_alpha;
};
extern const struct opname opname_table[];
BOOL isMncTwoDigitsForMccMnc(unsigned short mcc, unsigned short mnc);
BOOL isMncThreeDigitsForMcc(unsigned short mcc);
typedef struct _NumericRange
{
int min; /* lower limit */
int max; /* upper limit */
}NumericRange;
BOOL IsInValidRange(int value, NumericRange *valueRangeArray, unsigned int size);
BOOL Iso639LangToBin(char *strValue,unsigned int * iOutput);
UINT16 translateUnpackedGsm7ToText( UINT8 *pGsm, UINT16 gsmLen, UINT8 *pText );
BOOL isDialNumber(char* strValue,int strLenght);
UINT16 telUtlTranslateUnpackedGsm7ToText( UINT8 *pGsm, UINT16 gsmLen, UINT8 *pText );
unsigned isGSMAlphabet(int cs); // cs is codingScheme
int isMatch(const char *pattern, const unsigned char byte);
int getBit(const int n, char byte);
void hex2str(UINT32 len, char *psrc, char *pdest);
int str_to_Hex(UINT32 src_len, char *psrc, char *pdest, UINT32 dest_len);
bool convertBinStrToDecInt(UINT8 *binStr, UINT32 *outDec);
BOOL convertDecIntToBinStr(UINT8 inValue, UINT8 *outStr,UINT8 maxLength);
char* strdup(const char* str);
unsigned char unicode2gsm(unsigned short us, int *is_ext);
unsigned short gsm2unicode(unsigned char uc, int is_ext);
CHAR *converttoCscsStr(TelAtParserID sAtpIndex, CHAR* inBuf, int inLength, UINT16* outLen);
CHAR *convertfromCscsStr(TelAtParserID sAtpIndex, char *input, int inLength, int *outputLength);
BOOL checkDataValidity(CHAR *pSmsData, INT32 smsDataLength, AtciCharacterSet *pchset_type);
BOOL removeDoubleQuotatiaon(CHAR* inBuf, CHAR* outBuf);
BOOL addDoubleQuotatiaon(CHAR* inBuf, CHAR* outBuf);
int executeShellCMD(const char *cmd, char *result);
#if defined(ATCMD_1901_CI) || defined(ATCMD_1903_CI)
UINT32 parseBitmap(UINT32 bitmap);
#endif
#endif
/* END OF FILE */