1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef GSM_SMS_PARAMCODEC_H 18 #define GSM_SMS_PARAMCODEC_H 19 20 #include "gsm_pdu_code_type.h" 21 22 namespace OHOS { 23 namespace Telephony { 24 class GsmSmsParamCodec { 25 public: 26 GsmSmsParamCodec() = default; 27 virtual ~GsmSmsParamCodec() = default; 28 29 static int EncodeAddress(const struct SmsAddress *pAddress, char **ppParam); 30 static int EncodeTime(const struct SmsTimeStamp *pTimeStamp, char **ppParam); 31 static int EncodeDCS(const struct SmsDcs *pDCS, char **ppParam); 32 static int EncodeSMSC(const char *pAddress, unsigned char *pEncodeAddr); 33 static int EncodeSMSC(const struct SmsAddress *pAddress, unsigned char *pSMSC, int smscLen); 34 35 static int DecodeAddress(const unsigned char *pTpdu, struct SmsAddress *pAddress); 36 static int DecodeTime(const unsigned char *pTpdu, struct SmsTimeStamp *pTimeStamp); 37 static int DecodeDCS(const unsigned char *pTpdu, struct SmsDcs *pDCS); 38 static void DecodeSMSC(unsigned char *pAddress, int AddrLen, enum SmsTon ton, char *pDecodeAddr); 39 static int DecodeSMSC(const unsigned char *pTpdu, int pduLen, struct SmsAddress &pAddress); 40 static bool CheckCphsVmiMsg(const unsigned char *pTpdu, int *setType, int *indType); 41 42 private: 43 constexpr static unsigned char NUMBER_TEN = 10; 44 static constexpr uint8_t MAX_TIME_LEN = 32; 45 static constexpr uint8_t MAX_ADDRESS_LEN = 21; 46 static constexpr uint8_t MAX_ADD_PARAM_LEN = 12; 47 static constexpr uint8_t MAX_REL_TIME_PARAM_LEN = 1; 48 static constexpr uint8_t MAX_SMSC_LEN = 20; 49 static constexpr uint8_t MAX_DCS_PARAM_LEN = 1; 50 static constexpr uint8_t MAX_ABS_TIME_PARAM_LEN = 7; 51 static constexpr uint8_t YEARY_OF_MON = 12; 52 static constexpr uint8_t HEX_BYTE_STEP = 2; 53 }; 54 } // namespace Telephony 55 } // namespace OHOS 56 #endif /* SMS_PLUGIN_PARAMCODEC_H */