1 /* 2 * Copyright (C) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef SMS_PDU_CODE_TYPE_H 17 #define SMS_PDU_CODE_TYPE_H 18 19 #include <cstdint> 20 21 namespace OHOS { 22 namespace Telephony { 23 static constexpr uint8_t SMS_MAX_ADDRESS_LEN = 21; 24 static constexpr uint8_t MAX_UD_HEADER_NUM = 7; 25 static constexpr uint8_t MAX_USER_DATA_LEN = 160; 26 27 enum SmsNumberPlanType : uint8_t { 28 SMS_NPI_UNKNOWN = 0, 29 SMS_NPI_ISDN = 1, 30 SMS_NPI_DATA = 3, 31 SMS_NPI_TELEX = 4, 32 SMS_NPI_PRIVATE = 9, 33 SMS_NPI_RESERVED = 15, 34 }; 35 36 /** 37 * @brief SmsIndicatorType 38 * from 3GPP TS 23.040 V5.1.0 9.2.3.24.2 Special SMS Message Indication 39 */ 40 enum SmsIndicatorType { 41 SMS_VOICE_INDICATOR = 0, // Voice Message Waiting 42 SMS_VOICE2_INDICATOR, /* Only for CPSH */ 43 SMS_FAX_INDICATOR, // Fax Message Waiting 44 SMS_EMAIL_INDICATOR, // Electronic Mail Message Waiting 45 SMS_OTHER_INDICATOR, // Other Message Waiting 46 }; 47 48 enum SmsTimeFormat : uint8_t { SMS_TIME_EMPTY = 0, SMS_TIME_RELATIVE, SMS_TIME_ABSOLUTE }; 49 50 // cdma 51 typedef enum SmsRelativeTime : uint8_t { 52 SMS_REL_TIME_5_MINS = 0, 53 SMS_REL_TIME_12_HOURS = 143, 54 SMS_REL_TIME_1_DAY = 167, 55 SMS_REL_TIME_2_DAYS = 168, 56 SMS_REL_TIME_3_DAYS = 169, 57 SMS_REL_TIME_1_WEEK = 173, 58 SMS_REL_TIME_INDEFINITE = 245, 59 SMS_REL_TIME_IMMEDIATE = 246, 60 SMS_REL_TIME_ACTIVE = 247, 61 SMS_REL_TIME_REGISTRATION = 248, 62 SMS_REL_TIME_RESERVED 63 } SmsRelativeTimeEnum; 64 65 struct SmsTimeRel { 66 uint8_t time; 67 }; 68 69 struct SmsTimeAbs { 70 uint8_t year; /* range 00-99 (96~99 : 19xx, 00~95 : 20xx) */ 71 uint8_t month; /* range 1-12 */ 72 uint8_t day; 73 uint8_t hour; /* range 0-23 */ 74 uint8_t minute; /* range 0-59 */ 75 uint8_t second; /* range 0-59 */ 76 int32_t timeZone; // gsm 77 }; 78 79 /** 80 * @brief SmsConcat8Bit 81 * from 3GPP TS 23.040 V5.1.0 9.2.3.24.1 Concatenated Short Messages 82 */ 83 typedef struct SmsConcat8Bit { 84 uint8_t msgRef; 85 uint8_t totalSeg; 86 uint8_t seqNum; 87 } SmsConcat8Bit_; 88 89 /** 90 * @brief SmsConcat16Bit 91 * from 3GPP TS 23.040 V5.1.0 9.2.3.24.8 Concatenated short messages, 16-bit reference number 92 */ 93 typedef struct SmsConcat16Bit { 94 unsigned short msgRef; 95 uint8_t totalSeg; 96 uint8_t seqNum; 97 } SmsConcat16Bit_; 98 99 /** 100 * @brief SmsAppPort8Bits 101 * from 3GPP TS 23.040 V5.1.0 9.2.3.24.3 Application Port Addressing 8 bit address 102 */ 103 typedef struct SmsAppPort8Bits { 104 uint8_t destPort; 105 uint8_t originPort; 106 } SmsAppPort8Bits_; 107 108 /** 109 * @brief SmsAppPort16Bit 110 * from 3GPP TS 23.040 V5.1.0 9.2.3.24.4 Application Port Addressing 16 bit address 111 */ 112 typedef struct SmsAppPort16Bit { 113 unsigned short destPort; 114 unsigned short originPort; 115 } SmsAppPort16Bit_; 116 117 /** 118 * @brief SmsSpecialIndication 119 * from 3GPP TS 23.040 V5.1.0 9.2.3.24.2 Special SMS Message Indication 120 */ 121 typedef struct SmsSpecialIndication { 122 bool bStore; 123 unsigned short msgInd; 124 unsigned short waitMsgNum; 125 } SmsSpecialIndication_; 126 127 typedef struct MsgSingleShift { 128 uint8_t langId; 129 } MsgSingleShift_; 130 131 typedef struct MsgLockingShifi { 132 uint8_t langId; 133 } MsgLockingShifi_; 134 135 typedef struct AddressNumber { 136 uint8_t ton; 137 uint8_t npi; 138 char address[SMS_MAX_ADDRESS_LEN + 1]; /* < null terminated string */ 139 } SmsAddress_S; 140 141 /** 142 * @brief Sms User Data Header 143 * from 3GPP TS 23.040 V5.1.0 9.2.3.24.6 UDH Source Indicator 144 */ 145 struct SmsUDH { 146 uint8_t udhType; 147 union { 148 struct SmsConcat8Bit concat8bit; 149 struct SmsConcat16Bit concat16bit; 150 struct SmsAppPort8Bits appPort8bit; 151 struct SmsAppPort16Bit appPort16bit; 152 struct SmsSpecialIndication specialInd; 153 struct MsgSingleShift singleShift; 154 struct MsgLockingShifi lockingShift; 155 struct AddressNumber alternateAddress; 156 } udh; 157 }; 158 159 /** 160 * @brief SmsUDPackage 161 * from 3GPP TS 23.040 V5.1.0 9.2.3.24 TP User Data (TP UD) 162 */ 163 typedef struct SmsUDPackage { 164 uint8_t headerCnt; 165 struct SmsUDH header[MAX_UD_HEADER_NUM]; 166 uint8_t length; 167 char data[MAX_USER_DATA_LEN + 1]; 168 } SmsUserData_; 169 } // namespace Telephony 170 } // namespace OHOS 171 #endif