1 /* 2 * Copyright (C) 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 GSM_PDU_CODE_TYPE_H 17 #define GSM_PDU_CODE_TYPE_H 18 19 #include "sms_pdu_code_type.h" 20 21 namespace OHOS { 22 namespace Telephony { 23 // According to 3GPP 23040 9/1/2/5, the maximum address length (including AddressLength, TypeofAddress, AddressValue) 24 // is 12 octets. The maximum length of AddressLength and TypeofAddress is 1 byte, so the maximum length of AddressValue 25 // is 10 bytes (including '\0'). The total length is 21 bytes. 26 static constexpr uint8_t MAX_ADDRESS_LEN = 21; 27 static constexpr uint8_t MAX_SEGMENT_NUM = 15; 28 29 using SMS_TON_T = uint8_t; 30 using SMS_NPI_T = uint8_t; 31 32 // from 3GPP TS 23.040 V5.1.0 9.1.2.5 Address fields 33 enum TypeOfNum { 34 TYPE_UNKNOWN = 0, /* unknown */ 35 TYPE_INTERNATIONAL = 1, /* international number */ 36 TYPE_NATIONAL = 2, /* national number */ 37 TYPE_NETWORK_SPECIFIC = 3, /* network specific number */ 38 TYPE_DEDICATED_ACCESS = 4, /* subscriber number */ 39 TYPE_ALPHA_NUMERIC = 5, /* alphanumeric, GSM 7-bit default */ 40 TYPE_ABBREVIATED_NUMBER = 6, /* abbreviated number */ 41 TYPE_RESERVED_FOR_EXT = 7 /* reserved for extension */ 42 }; 43 44 // from 3GPP TS 23.038 V4.3.0 5 CBS Data Coding Scheme 45 enum SmsMessageClass { 46 /** class0 Indicates an instant message, which is displayed immediately after being received. */ 47 SMS_INSTANT_MESSAGE = 0, 48 /** class1 Indicates an SMS message that can be stored on the device or SIM card based on the storage status. */ 49 SMS_OPTIONAL_MESSAGE, 50 /** class2 Indicates an SMS message containing SIM card information, which is to be stored in a SIM card. */ 51 SMS_SIM_MESSAGE, 52 /** class3 Indicates an SMS message to be forwarded to another device. */ 53 SMS_FORWARD_MESSAGE, 54 /** Indicates an unknown type. */ 55 SMS_CLASS_UNKNOWN, 56 }; 57 58 // from 3GPP TS 23.038 V4.3.0 4 SMS Data Coding Scheme 59 enum PduSchemeGroup { 60 CODING_GENERAL_GROUP = 0, // General Data Coding indication 61 SMS_CLASS_GROUP, // Data coding/message class 62 CODING_DELETION_GROUP, // Message Marked for Automatic Deletion Group 63 CODING_DISCARD_GROUP, // Message Waiting Indication Group: Discard Message 64 CODING_STORE_GROUP, // Message Waiting Indication Group: Store Message 65 CODING_UNKNOWN_GROUP, // Reserved coding groups 66 }; 67 68 // from 3GPP TS 23.040 V5.1.0 3.2.3 Protocol Identifier 69 enum SmsPid { 70 SMS_NORMAL_PID = 71 0x00, // implicit device type is specific to this SC, or can be concluded on the basis of the address 72 73 SMS_TELEX_PID = 0x21, // telex (or teletex reduced to telex format) 74 SMS_GROUP3_TELEX_PID = 0x22, // group 3 telefax 75 SMS_GROUP4_TELEX_PID = 0x23, // group 4 telefax 76 SMS_VOICE_PID = 0x24, // voice telephone (i.e. conversion to speech) 77 SMS_ERMES_PID = 0x25, // ERMES (European Radio Messaging System) 78 SMS_NPS_PID = 0x26, // National Paging system (known to the SC) 79 SMS_VIDEO_PID = 0x27, // Videotex (T.100 [20] /T.101 [21]) 80 SMS_TELETEX_UNSPEC_PID = 0x28, // teletex, carrier unspecified 81 SMS_TELETEX_PSPDN_PID = 0x29, // teletex, in PSPDN 82 SMS_TELETEX_CSPDN_PID = 0x2A, // teletex, in CSPDN 83 SMS_TELETEX_PSTN_PID = 0x2B, // teletex, in analog PSTN 84 SMS_TELETEX_ISDN_PID = 0x2C, // teletex, in digital ISDN 85 SMS_UCI_PID = 0x2D, // UCI (Universal Computer Interface, ETSI DE/PS 3 01 3) 86 SMS_x400_PID = 0x31, // any public X.400 based message handling system 87 SMS_EMAIL_PID = 0x32, // Internet Electronic Mail 88 89 SMS_TYPE0_PID = 0x40, // Short Message Type 0 90 SMS_REPLACE_TYPE1_PID = 0x41, // Replace Short Message Type 1 91 SMS_REPLACE_TYPE2_PID = 0x42, // Replace Short Message Type 2 92 SMS_REPLACE_TYPE3_PID = 0x43, // Replace Short Message Type 3 93 SMS_REPLACE_TYPE4_PID = 0x44, // Replace Short Message Type 4 94 SMS_REPLACE_TYPE5_PID = 0x45, // Replace Short Message Type 5 95 SMS_REPLACE_TYPE6_PID = 0x46, // Replace Short Message Type 6 96 SMS_REPLACE_TYPE7_PID = 0x47, // Replace Short Message Type 7 97 98 SMS_RETURN_CALL_PID = 0x5F, 99 }; 100 101 /** 102 * from 3GPP TS 23.040 V5.1.0 9.2.3.10 TP Data Coding Scheme (TP DCS) 103 */ 104 enum DataCodingScheme { 105 DATA_CODING_7BIT = 0, // GSM 7 bit default alphabet 106 DATA_CODING_8BIT, // 8 bit data 107 DATA_CODING_UCS2, // UCS2 (16bit) [10] 108 DATA_CODING_AUTO, 109 DATA_CODING_EUCKR, 110 DATA_CODING_ASCII7BIT, // cdma 7 bit defualt alphabet 111 }; 112 113 struct SmsTimeStamp { 114 enum SmsTimeFormat format; 115 union { 116 struct SmsTimeRel relative; 117 struct SmsTimeAbs absolute; 118 } time; 119 }; 120 121 /** 122 * form 3GPP TS 23.038 V4.3.0 4 SMS Data Coding Scheme 123 */ 124 typedef struct SmsDcs { 125 // indicates the text is compressed using the compression algorithm defined in 3GPP TS 23.042 [13] 126 bool bCompressed; 127 // Message Waiting Indication Group: Discard Message 128 bool bMWI; 129 bool bIndActive; 130 enum SmsMessageClass msgClass; 131 enum DataCodingScheme codingScheme; 132 enum PduSchemeGroup codingGroup; 133 enum SmsIndicatorType indType; 134 } SmsDcs_; 135 136 /** 137 * from 3GPP TS 23.040 V5.1.0 9.2.3.3 TP Validity Period Format (TP VPF) 138 */ 139 enum SmsVpf { 140 SMS_VPF_NOT_PRESENT = 0, 141 SMS_VPF_ENHANCED, 142 SMS_VPF_RELATIVE, 143 SMS_VPF_ABSOLUTE, 144 }; 145 146 enum _SMS_REPORT_TYPE_E { SMS_REPORT_POSITIVE = 0, SMS_REPORT_NEGATIVE }; 147 148 /** 149 * from 3GPP TS 23.040 V5.1.0 9.2.2.2 SMS SUBMIT type 150 */ 151 typedef struct SmsSubmit { 152 bool bRejectDup; // TP Reject Duplicates 153 bool bStatusReport; // TP Status report capabilities 154 bool bHeaderInd; // TP User Data Header Indicator (TP UDHI) 155 bool bReplyPath; // TP Reply Path 156 uint8_t msgRef; // TP Concatenated Short Messages 157 enum SmsVpf vpf; // TP Validity Period Format (TP VPF) 158 struct AddressNumber destAddress; // TP Destination Address (TP DA) 159 enum SmsPid pid; // TP Protocol Identifier (TP PID) 160 struct SmsDcs dcs; // TP Data Coding Scheme (TP DCS) 161 struct SmsTimeStamp validityPeriod; // TP Validity Period Format 162 struct SmsUDPackage userData; // TP User Data (TP UD) 163 } SmsSubmit_; 164 165 typedef struct SmsTpud { 166 uint8_t udl; 167 char ud[MAX_USER_DATA_LEN + 1]; 168 } SmsTpud_; 169 170 /** 171 * from 3GPP TS 23.040 V5.1.0 9.2.2.1 SMS DELIVER type 172 */ 173 typedef struct SmsDeliver { 174 bool bMoreMsg; // TP More Messages to Send 175 bool bStatusReport; // TP Status report capabilities 176 bool bHeaderInd; // TP User Data Header Indicator (TP UDHI) 177 bool bReplyPath; // TP Reply Path 178 struct AddressNumber originAddress; // TP Originating Address (TP OA) 179 enum SmsPid pid; // TP Protocol Identifier (TP PID) 180 struct SmsDcs dcs; // TP Data Coding Scheme (TP DCS) 181 struct SmsTimeStamp timeStamp; // TP Service Centre Time Stamp 182 struct SmsUDPackage userData; // TP User Data (TP UD) 183 struct SmsTpud udData; // TP User Data (TP UD) 184 } SmsDeliver_; 185 186 using SMS_REPORT_TYPE_T = uint8_t; 187 using SMS_FAIL_CAUSE_T = uint8_t; 188 189 /** 190 * from 3GPP TS 23.040 V5.1.0 9.2.2.1a SMS DELIVER REPORT type 191 */ 192 typedef struct SmsDeliverReport { 193 SMS_REPORT_TYPE_T reportType; // TP Message Type Indicator 194 bool bHeaderInd; // TP User Data Header Indicator (TP UDHI) 195 SMS_FAIL_CAUSE_T failCause; // TP Failure Cause 196 uint8_t paramInd; // TP Parameter Indicator 197 enum SmsPid pid; // TP Protocol Identifier (TP PID) 198 struct SmsDcs dcs; // TP Data Coding Scheme (TP DCS) 199 struct SmsUDPackage userData; // TP User Data (TP UD) 200 } SmsDeliverReport_; 201 202 using SMS_STATUS_T = uint8_t; 203 204 /** 205 * from 3GPP TS 23.040 V5.1.0 9.2.2.3 SMS STATUS REPORT type 206 */ 207 typedef struct SmsStatusReport { 208 bool bMoreMsg; // More Messages to Send 209 bool bStatusReport; // TP Status Report Qualifier 210 bool bHeaderInd; // TP-User-Data-Header-Indication 211 uint8_t msgRef; // TP Message Reference 212 struct AddressNumber recipAddress; // TP Recipient Address 213 struct SmsTimeStamp timeStamp; // TP Service Centre Time Stamp 214 struct SmsTimeStamp dischargeTime; // TP Discharge Time 215 SMS_STATUS_T status; // TP Status 216 uint8_t paramInd; // TP-Parameter-Indicator 217 enum SmsPid pid; // TP-Protocol-Identifier 218 struct SmsDcs dcs; // TP-Data-Coding-Scheme 219 struct SmsUDPackage userData; // TP-User-Data 220 } SmsStatusReport_; 221 222 // from 3GPP TS 23.040 V5.1.0 9.2.3.23 TP User Data Header Indicator (TP UDHI) 223 enum SmsTpduType { 224 SMS_TPDU_SUBMIT, 225 SMS_TPDU_DELIVER, 226 SMS_TPDU_DELIVER_REP, 227 SMS_TPDU_STATUS_REP, 228 }; 229 230 typedef struct SmsTpdu { 231 enum SmsTpduType tpduType; 232 union { 233 struct SmsSubmit submit; 234 struct SmsDeliver deliver; 235 struct SmsDeliverReport deliverRep; 236 struct SmsStatusReport statusRep; 237 } data; 238 } SmsTpdu_S; 239 240 // from 3GPP TS 23.040 V5.1.0 9.2.3.24.6 UDH Source Indicator 241 enum UserDataHeadType { 242 UDH_CONCAT_8BIT = 0x00, 243 UDH_SPECIAL_SMS = 0x01, 244 /* 0x02, 0x03 - Reserved */ 245 UDH_APP_PORT_8BIT = 0x04, 246 UDH_APP_PORT_16BIT = 0x05, 247 UDH_SC_CONTROL = 0x06, 248 UDH_SRC_IND = 0x07, 249 UDH_CONCAT_16BIT = 0x08, 250 UDH_WCMP = 0x09, 251 UDH_EMS_FIRST = 0x0a, 252 UDH_EMS_LAST = 0x1f, 253 UDH_ALTERNATE_REPLY_ADDRESS = 0x22, 254 UDH_SINGLE_SHIFT = 0x24, 255 UDH_LOCKING_SHIFT = 0x25, 256 UDH_NONE = 0xFF, 257 }; 258 } // namespace Telephony 259 } // namespace OHOS 260 #endif